750e41ba546b677084107442bbb04f64697e6f78.svn-base 65 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554
  1. <template>
  2. <div class="app-container">
  3. <!-- 配方模板表 -->
  4. <div ref="template" class="template">
  5. <div class="recipeTemplate">
  6. <p>日执行计划</p>
  7. </div>
  8. <div class="operation" style="margin-bottom: 10px;">
  9. <el-button class="success" @click="handleCreate">新生成</el-button>
  10. <el-button class="success" @click="handleRevisePlan">修改计划</el-button>
  11. <el-button class="success" @click="handleCopy">复制计划</el-button>
  12. <el-button v-if="isOrder" class="success" @click="handleChangeOrder">更改顺序</el-button>
  13. <div v-else style="margin-left: 10px;display: inline-block;">
  14. <el-button class="success" @click="saveChangeOrder">保存</el-button>
  15. <el-button class="success" @click="cancelChangeOrder">取消</el-button>
  16. </div>
  17. </div>
  18. <div class="search">
  19. <el-date-picker v-model="table.getdataListParm.parammaps.mydate" type="date" placeholder="选择日期" style="width: 150px;" format="yyyy-MM-dd" value-format="yyyy-MM-dd" :clearable="false" @change="changeDate" />
  20. <el-button class="el-icon-arrow-left elIconArrowLeft" @click="handleBefore" />
  21. <el-button class="el-icon-arrow-right elIconArrowRight" @click="handleNext" />
  22. <el-select v-model="table.getdataListParm.parammaps.lpplantype" filterable placeholder="计划类型" class="filter-item" clearable style="width: 120px;" @change="changePlanType">
  23. <el-option v-for="item in planTypeList" :key="item.value" :label="item.lable" :value="item.value" />
  24. </el-select>
  25. <el-select v-model="table.getdataListParm.parammaps.times" filterable placeholder="班次" class="filter-item" style="width: 120px;" clearable @change="changeFrequency">
  26. <el-option v-for="item in frequencyList" :key="item.id" :label="item.name" :value="item.id" />
  27. </el-select>
  28. <el-select v-model="table.getdataListParm.parammaps.enable" filterable placeholder="打印类型" class="filter-item" clearable style="width: 120px;">
  29. <el-option v-for="item in printingTypeList" :key="item.value" :label="item.label" :value="item.value" />
  30. </el-select>
  31. <el-select v-model="table.getdataListParm.parammaps.enable" filterable placeholder="计划维度" class="filter-item" style="width: 120px;" clearable>
  32. <el-option v-for="item in planningDimensionList" :key="item.value" :label="item.label" :value="item.value" />
  33. </el-select>
  34. <el-select v-model="table.getdataListParm.parammaps.enable" filterable placeholder="导出类型" class="filter-item" style="width: 120px;" clearable>
  35. <el-option v-for="item in exportTypeList" :key="item.value" :label="item.label" :value="item.value" />
  36. </el-select>
  37. <el-button class="export" @click="handleExport">导出</el-button>
  38. </div>
  39. <!-- 日执行计划 -->
  40. <div class="table">
  41. <el-table
  42. id="table1"
  43. ref="parent"
  44. :key="table.tableKey"
  45. v-loading="table.listLoading"
  46. element-loading-text="给我一点时间"
  47. :data="table.list"
  48. border
  49. fit
  50. highlight-current-row
  51. style="width: 98%;"
  52. row-key="sort"
  53. :row-style="rowStyle"
  54. :cell-style="cellStyle"
  55. class="elTable table-fixed"
  56. :row-class-name="tableRowClassName"
  57. :height="370"
  58. @row-click="tableRowClick"
  59. >
  60. <el-table-column label="序号" align="center" prop="sort" width="50px" />
  61. <el-table-column label="计划名称" min-width="110px" align="center">
  62. <template slot-scope="scope">
  63. <span>{{ scope.row.projname }}</span>
  64. </template>
  65. </el-table-column>
  66. <el-table-column label="计划类型" prop="weight" min-width="110px" align="center" :formatter="lpplantype" />
  67. <el-table-column label="TMR编号" min-width="110px" align="center">
  68. <template slot-scope="scope">
  69. <span>{{ scope.row.tmrtname }}</span>
  70. </template>
  71. </el-table-column>
  72. <el-table-column label="驾驶员" min-width="90px" align="center">
  73. <template slot-scope="scope">
  74. <span>{{ scope.row.driver }}</span>
  75. </template>
  76. </el-table-column>
  77. <el-table-column label="已执行" min-width="90px" align="center">
  78. <template slot-scope="scope">
  79. <span v-if="scope.row.havebutton == 0">否</span>
  80. <span v-else>是</span>
  81. </template>
  82. </el-table-column>
  83. <el-table-column label="班次" min-width="110px" align="center">
  84. <template slot-scope="scope">
  85. <span>{{ scope.row.times }}</span>
  86. </template>
  87. </el-table-column>
  88. <el-table-column label="理论量" min-width="110px" align="center">
  89. <template slot-scope="scope">
  90. <span>{{ scope.row.lweight }}</span>
  91. </template>
  92. </el-table-column>
  93. <el-table-column label="时间" min-width="180px" align="center">
  94. <template slot-scope="scope">
  95. <span>{{ scope.row.plantime }}</span>
  96. </template>
  97. </el-table-column>
  98. <el-table-column label="发料位" min-width="180px" align="left">
  99. <template slot-scope="scope">
  100. <span>{{ scope.row.barnames }}</span>
  101. </template>
  102. </el-table-column>
  103. </el-table>
  104. </div>
  105. </div>
  106. <!-- 预混料 -->
  107. <div v-if="table3.getdataListParm.parammaps.lpplantype == 4" class="content">
  108. <div class="table2">
  109. <div class="contentOperation">
  110. <p>计划内容<br>操作详情</p>
  111. </div>
  112. <div class="content-table">
  113. <el-table
  114. :key="table2.tableKey"
  115. v-loading="table2.listLoading"
  116. element-loading-text="给我一点时间"
  117. :data="table2.list"
  118. fit
  119. highlight-current-row
  120. style="width: 100%;"
  121. height="450"
  122. :row-style="rowStyle"
  123. :cell-style="cellStyle"
  124. class="elTable table-fixed"
  125. >
  126. <el-table-column label="操作序号" min-width="130px" align="center">
  127. <template slot-scope="scope">
  128. <span>{{ scope.row.sort }}</span>
  129. </template>
  130. </el-table-column>
  131. <el-table-column label="饲料名称" prop="fname" min-width="130px" align="center">
  132. <template slot-scope="scope">
  133. <span>{{ scope.row.fname }}</span>
  134. </template>
  135. </el-table-column>
  136. <el-table-column label="设计重量(KG)" prop="weight" min-width="130px" align="center">
  137. <template slot-scope="scope">
  138. <span>{{ scope.row.weight }}</span>
  139. </template>
  140. </el-table-column>
  141. </el-table>
  142. </div>
  143. </div>
  144. </div>
  145. <!-- 撒料 -->
  146. <div v-if="table3.getdataListParm.parammaps.lpplantype == 0" class="content">
  147. <div class="table2">
  148. <div class="contentOperation">
  149. <p>计划内容<br>操作详情</p>
  150. </div>
  151. <div class="content-table">
  152. <el-table
  153. :key="table2.tableKey"
  154. v-loading="table2.listLoading"
  155. element-loading-text="给我一点时间"
  156. :data="table2.list"
  157. fit
  158. highlight-current-row
  159. style="width: 100%;"
  160. height="450"
  161. :row-style="rowStyle"
  162. :cell-style="cellStyle"
  163. class="elTable table-fixed"
  164. >
  165. <el-table-column label="操作序号" min-width="130px" align="center">
  166. <template slot-scope="scope">
  167. <span>{{ scope.row.sort }}</span>
  168. </template>
  169. </el-table-column>
  170. <el-table-column label="饲料名称" prop="fname" min-width="130px" align="center">
  171. <template slot-scope="scope">
  172. <span>{{ scope.row.fname }}</span>
  173. </template>
  174. </el-table-column>
  175. <el-table-column label="设计重量(KG)" prop="weight" min-width="130px" align="center">
  176. <template slot-scope="scope">
  177. <span>{{ scope.row.weight }}</span>
  178. </template>
  179. </el-table-column>
  180. </el-table>
  181. </div>
  182. </div>
  183. <div class="table3">
  184. <div class="contentOperation">
  185. <p>计划内容<br>栏舍详情</p>
  186. </div>
  187. <div class="content-table">
  188. <el-table
  189. :key="table3.tableKey"
  190. v-loading="table3.listLoading"
  191. element-loading-text="给我一点时间"
  192. :data="table3.list"
  193. height="450"
  194. fit
  195. highlight-current-row
  196. style="width: 100%;"
  197. :row-style="rowStyle"
  198. :cell-style="cellStyle"
  199. class="elTable table-fixed"
  200. >
  201. <el-table-column label=" 操作序号" min-width="130px" align="center">
  202. <template slot-scope="scope">
  203. <span>{{ scope.row.sort }}</span>
  204. </template>
  205. </el-table-column>
  206. <el-table-column label="栏舍" min-width="130px" align="center">
  207. <template slot-scope="scope">
  208. <span>{{ scope.row.fname }}</span>
  209. </template>
  210. </el-table-column>
  211. <el-table-column label="设计重量(KG)" prop="weight" min-width="130px" align="center">
  212. <template slot-scope="scope">
  213. <span>{{ scope.row.weight }}</span>
  214. </template>
  215. </el-table-column>
  216. </el-table>
  217. </div>
  218. </div>
  219. </div>
  220. <!-- 剩料 -->
  221. <div v-if="table3.getdataListParm.parammaps.lpplantype == 3" class="content">
  222. <div class="table2">
  223. <div class="contentOperation">
  224. <p>计划内容<br>操作详情</p>
  225. </div>
  226. <div class="content-table">
  227. <el-table
  228. :key="table2.tableKey"
  229. v-loading="table2.listLoading"
  230. element-loading-text="给我一点时间"
  231. :data="table2.list"
  232. fit
  233. highlight-current-row
  234. style="width: 100%;"
  235. height="450"
  236. :row-style="rowStyle"
  237. :cell-style="cellStyle"
  238. class="elTable table-fixed"
  239. >
  240. <el-table-column label="操作序号" min-width="130px" align="center">
  241. <template slot-scope="scope">
  242. <span>{{ scope.row.sort }}</span>
  243. </template>
  244. </el-table-column>
  245. <el-table-column label="取料栏舍" prop="fname" min-width="130px" align="center">
  246. <template slot-scope="scope">
  247. <span>{{ scope.row.fname }}</span>
  248. </template>
  249. </el-table-column>
  250. <el-table-column label="处理方式" prop="useinbar" min-width="130px" align="center">
  251. <template slot-scope="scope">
  252. <span>{{ scope.row.useinbar }}</span>
  253. </template>
  254. </el-table-column>
  255. </el-table>
  256. </div>
  257. </div>
  258. <div class="table3">
  259. <div class="contentOperation">
  260. <p>计划内容<br>栏舍详情</p>
  261. </div>
  262. <div class="content-table">
  263. <el-table
  264. :key="table3.tableKey"
  265. v-loading="table3.listLoading"
  266. element-loading-text="给我一点时间"
  267. :data="table3.list"
  268. height="450"
  269. fit
  270. highlight-current-row
  271. style="width: 100%;"
  272. :row-style="rowStyle"
  273. :cell-style="cellStyle"
  274. class="elTable table-fixed"
  275. >
  276. <el-table-column label="操作序号" min-width="130px" align="center">
  277. <template slot-scope="scope">
  278. <span>{{ scope.row.sort }}</span>
  279. </template>
  280. </el-table-column>
  281. <el-table-column label="转投栏舍" min-width="130px" align="center">
  282. <template slot-scope="scope">
  283. <span>{{ scope.row.fname }}</span>
  284. </template>
  285. </el-table-column>
  286. </el-table>
  287. </div>
  288. </div>
  289. </div>
  290. <!-- 撒料计划-混料 -->
  291. <div v-if="table3.getdataListParm.parammaps.lpplantype == 1 || table3.getdataListParm.parammaps.lpplantype == 5" class="content">
  292. <div class="table2">
  293. <div class="contentOperation">
  294. <p>计划内容<br>操作详情</p>
  295. </div>
  296. <div class="content-table">
  297. <el-table
  298. :key="table2.tableKey"
  299. v-loading="table2.listLoading"
  300. element-loading-text="给我一点时间"
  301. :data="table2.list"
  302. fit
  303. highlight-current-row
  304. style="width: 100%;"
  305. height="450"
  306. :row-style="rowStyle"
  307. :cell-style="cellStyle"
  308. class="elTable table-fixed"
  309. >
  310. <el-table-column label="操作序号" min-width="130px" align="center">
  311. <template slot-scope="scope">
  312. <span>{{ scope.row.sort }}</span>
  313. </template>
  314. </el-table-column>
  315. <el-table-column label="饲料名称" prop="fname" min-width="130px" align="center">
  316. <template slot-scope="scope">
  317. <span>{{ scope.row.fname }}</span>
  318. </template>
  319. </el-table-column>
  320. <el-table-column label="设计重量(KG)" prop="weight" min-width="130px" align="center">
  321. <template slot-scope="scope">
  322. <span>{{ scope.row.weight }}</span>
  323. </template>
  324. </el-table-column>
  325. </el-table>
  326. </div>
  327. </div>
  328. <div class="table3">
  329. <div class="contentOperation">
  330. <p>计划内容<br>栏舍详情</p>
  331. </div>
  332. <div class="content-table">
  333. <el-table
  334. :key="table3.tableKey"
  335. v-loading="table3.listLoading"
  336. element-loading-text="给我一点时间"
  337. :data="table3.list"
  338. height="450"
  339. fit
  340. highlight-current-row
  341. style="width: 100%;"
  342. :row-style="rowStyle"
  343. :cell-style="cellStyle"
  344. class="elTable table-fixed"
  345. >
  346. <el-table-column label=" 操作序号" min-width="130px" align="center">
  347. <template slot-scope="scope">
  348. <span>{{ scope.row.sort }}</span>
  349. </template>
  350. </el-table-column>
  351. <el-table-column label="撒料车辆" min-width="130px" align="center">
  352. <template slot-scope="scope">
  353. <span>{{ scope.row.fname }}</span>
  354. </template>
  355. </el-table-column>
  356. <el-table-column label="设计重量(KG)" min-width="130px" align="center">
  357. <template slot-scope="scope">
  358. <span>{{ scope.row.weight }}</span>
  359. </template>
  360. </el-table-column>
  361. </el-table>
  362. </div>
  363. </div>
  364. </div>
  365. <!-- 撒料计划-撒料 -->
  366. <div v-if="table3.getdataListParm.parammaps.lpplantype == 2" class="content">
  367. <div class="table3">
  368. <div class="contentOperation">
  369. <p>计划内容<br>栏舍详情</p>
  370. </div>
  371. <div class="content-table">
  372. <el-table
  373. :key="table3.tableKey"
  374. v-loading="table3.listLoading"
  375. element-loading-text="给我一点时间"
  376. :data="table3.list"
  377. height="450"
  378. fit
  379. highlight-current-row
  380. style="width: 100%;"
  381. :row-style="rowStyle"
  382. :cell-style="cellStyle"
  383. class="elTable table-fixed"
  384. >
  385. <el-table-column label=" 操作序号" min-width="130px" align="center">
  386. <template slot-scope="scope">
  387. <span>{{ scope.row.sort }}</span>
  388. </template>
  389. </el-table-column>
  390. <el-table-column label="撒料车辆" min-width="130px" align="center">
  391. <template slot-scope="scope">
  392. <span>{{ scope.row.fname }}</span>
  393. </template>
  394. </el-table-column>
  395. <el-table-column label="设计重量(KG)" min-width="130px" align="center">
  396. <template slot-scope="scope">
  397. <span>{{ scope.row.weight }}</span>
  398. </template>
  399. </el-table-column>
  400. </el-table>
  401. </div>
  402. </div>
  403. <div class="table2">
  404. <div class="contentOperation">
  405. <p>计划内容<br>操作详情</p>
  406. </div>
  407. <div class="content-table">
  408. <el-table
  409. :key="table2.tableKey"
  410. v-loading="table2.listLoading"
  411. element-loading-text="给我一点时间"
  412. :data="table2.list"
  413. fit
  414. highlight-current-row
  415. style="width: 100%;"
  416. height="450"
  417. :row-style="rowStyle"
  418. :cell-style="cellStyle"
  419. class="elTable table-fixed"
  420. >
  421. <el-table-column label="操作序号" min-width="130px" align="center">
  422. <template slot-scope="scope">
  423. <span>{{ scope.row.sort }}</span>
  424. </template>
  425. </el-table-column>
  426. <el-table-column label="栏舍名称" prop="fname" min-width="130px" align="center">
  427. <template slot-scope="scope">
  428. <span>{{ scope.row.fname }}</span>
  429. </template>
  430. </el-table-column>
  431. <el-table-column label="设计重量(KG)" prop="weight" min-width="130px" align="center">
  432. <template slot-scope="scope">
  433. <span>{{ scope.row.weight }}</span>
  434. </template>
  435. </el-table-column>
  436. </el-table>
  437. </div>
  438. </div>
  439. </div>
  440. <!-- 新生成 -->
  441. <el-dialog :title="textMap[newGeneration.dialogStatus]" :destroy-on-close="true" :visible.sync="newGeneration.dialogFormVisible" :close-on-click-modal="false" width="50%">
  442. <div class="newGeneration">
  443. <el-form ref="temp" :rules="newGeneration.rules" :model="newGeneration.temp" label-position="right" label-width="155px" style="width: 100%;margin:0 auto 50px">
  444. <el-row v-if="newGeneration.dialogStatus== 'newGeneration'">
  445. <el-col :span="16">
  446. <el-form-item label="时间范围:" prop="inputDatetime">
  447. <el-date-picker v-model="newGeneration.temp.inputDatetime" class="inputDatetime filter-item" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" style="width: 100%;" :clearable="false" :picker-options="pickerOptions2" />
  448. </el-form-item>
  449. </el-col>
  450. </el-row>
  451. <el-row v-else>
  452. <el-col :span="16">
  453. <el-form-item label="时间范围:" prop="copyInputDatetime">
  454. <el-date-picker v-model="newGeneration.temp.copyInputDatetime" :picker-options="pickerOptions" class="inputDatetime filter-item" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" style="width: 100%;" :clearable="false" />
  455. </el-form-item>
  456. </el-col>
  457. </el-row>
  458. </el-form>
  459. <div slot="footer" class="dialog-footer" style="bottom:10px">
  460. <el-button class="cancelClose" @click="newGeneration.dialogFormVisible = false;getList()">取消</el-button>
  461. <el-button v-if="newGeneration.dialogStatus== 'newGeneration'" class="success" :disabled="isokDisable" @click="newGenerationData()">确认</el-button>
  462. <el-button v-else class="success" :disabled="isokDisable" @click="copyData()">确认</el-button>
  463. </div>
  464. </div>
  465. </el-dialog>
  466. <!-- 历史记录 -->
  467. <el-dialog :title="textMap[historyRecord.dialogStatus]" :destroy-on-close="true" :visible.sync="historyRecord.dialogFormVisible" :close-on-click-modal="false" width="90%">
  468. <div class="historyRecord">
  469. <keep-alive>
  470. <component :is="historyRecord.myComponent" ref="historyRecord" />
  471. </keep-alive>
  472. </div>
  473. <div slot="footer" class="dialog-footer" style="bottom: 10px;">
  474. <el-button class="cancelClose" @click="historyRecord.dialogFormVisible = false; ">关闭</el-button>
  475. </div>
  476. </el-dialog>
  477. <!-- 修改计划 -->
  478. <RevisePlan :show.sync="isShowDialog" :parent-active-name="activeName" :parent-date="parentDate" />
  479. </div>
  480. </template>
  481. <script>
  482. import { GetDataByName, GetDataByNames, ExecDataByConfig, PostDataByName } from '@/api/common'
  483. import RevisePlan from './revisePlan.vue'
  484. import { parseTime } from '@/utils/index.js'
  485. import Cookies from 'js-cookie'
  486. import Sortable from 'sortablejs'
  487. export default {
  488. name: 'DailyExecutionPlan',
  489. components: {
  490. RevisePlan
  491. },
  492. data() {
  493. return {
  494. requestParams: [
  495. // { name: 'getDictByName', offset: 0, pagecount: 0, params: ['牲畜父类'] }
  496. ],
  497. planTypeList: [{ lable: '预混计划', value: '4' }, { lable: '撒料计划', value: '0' }, { lable: '剩料计划', value: '3' }, { lable: '撒料计划-混料', value: '1' }, { lable: '撒料计划-撒料', value: '2' }, { lable: '预称重计划', value: '5' }], // 计划类型
  498. printingTypeList: [{ lable: '所有', value: '0' }, { lable: '精料', value: '1' }, { lable: '铲车', value: '2' }], // 打印类型
  499. frequencyList: [], // 班次
  500. planningDimensionList: [{ lable: '发料顺序', value: '0' }, { lable: 'TMR', value: '1' }], // 发料顺序
  501. exportTypeList: [{ lable: '投料简打', value: '0' }, { lable: '投料简打', value: '1' }], // 导出类型
  502. // 班次
  503. maxTime: {
  504. getMaxTimesParm: {
  505. name: 'getSysoptEnable',
  506. page: 1,
  507. offset: 1,
  508. pagecount: 1,
  509. returntype: 'Map',
  510. parammaps: {
  511. pastureid: Cookies.get('pastureid'),
  512. inforname: 'times'
  513. }
  514. }
  515. },
  516. isOrder: true,
  517. table: {
  518. getdataListParm: {
  519. name: 'getDownloadedplanList',
  520. page: 1,
  521. offset: 1,
  522. pagecount: '',
  523. returntype: 'Map',
  524. parammaps: {
  525. pastureid: Cookies.get('pastureid'),
  526. barid: '',
  527. mydate: parseTime(new Date(), '{y}-{m}-{d}'),
  528. times: '',
  529. lpplantype: ''
  530. }
  531. },
  532. tableKey: 0,
  533. list: [],
  534. total: 0,
  535. listLoading: false
  536. },
  537. // 计划内容操作详情
  538. table2: {
  539. getdataListParm: {
  540. name: 'getDownloadplandtl1ListV2',
  541. page: 1,
  542. offset: 1,
  543. returntype: 'Map',
  544. parammaps: {
  545. pastureid: Cookies.get('pastureid'),
  546. date: '',
  547. id: ''
  548. }
  549. },
  550. tableKey: 0,
  551. list: [],
  552. total: 0,
  553. listLoading: false
  554. },
  555. // 计划内容 舍栏详情
  556. table3: {
  557. getdataListParm: {
  558. name: 'getDownloadplandt2ListV2',
  559. page: 1,
  560. offset: 1,
  561. returntype: 'Map',
  562. parammaps: {
  563. pastureid: Cookies.get('pastureid'),
  564. date: '',
  565. id: ''
  566. }
  567. },
  568. tableKey: 0,
  569. list: [],
  570. total: 0,
  571. listLoading: false
  572. },
  573. // 新生成
  574. newGeneration: {
  575. dialogFormVisible: false,
  576. dialogStatus: '',
  577. getdataListParm: {
  578. name: 'checkLLPIsDistribution',
  579. page: 1,
  580. offset: 1,
  581. pagecount: 1,
  582. returntype: 'Map',
  583. parammaps: {
  584. pastureid: Cookies.get('pastureid')
  585. }
  586. },
  587. temp: {
  588. inputDatetime: [parseTime(new Date(), '{y}-{m}-{d}'), parseTime(new Date(), '{y}-{m}-{d}')]
  589. },
  590. rules: {
  591. inputDatetime: [{ type: 'array', required: true, message: '必填', trigger: 'blur' }],
  592. copyInputDatetime: [{ type: 'array', required: true, message: '必填', trigger: 'blur' }]
  593. }
  594. },
  595. pickerMinDate: '',
  596. pickerOptions: {
  597. onPick: ({ maxDate, minDate }) => {
  598. this.pickerMinDate = minDate.getTime()
  599. if (maxDate) {
  600. this.pickerMinDate = ''
  601. }
  602. },
  603. disabledDate: (time) => {
  604. if (this.pickerMinDate !== '') {
  605. const one = 31 * 24 * 3600 * 1000
  606. const minTime = this.pickerMinDate
  607. const maxTime = this.pickerMinDate + one
  608. return time.getTime() < minTime || time.getTime() > maxTime - 8.64e7
  609. }
  610. return time.getTime() < Date.now() - 8.64e7
  611. }
  612. },
  613. pickerOptions2: {
  614. onPick: ({ maxDate, minDate }) => {
  615. this.pickerMinDate = minDate.getTime()
  616. if (maxDate) {
  617. this.pickerMinDate = ''
  618. }
  619. },
  620. disabledDate: (time) => {
  621. if (this.pickerMinDate !== '') {
  622. const one = 14 * 24 * 3600 * 1000
  623. const minTime = this.pickerMinDate
  624. const maxTime = this.pickerMinDate + one
  625. return time.getTime() < minTime || time.getTime() > maxTime - 8.64e7
  626. }
  627. return time.getTime() < Date.now() - 8.64e7
  628. }
  629. },
  630. historyRecord: {
  631. dialogFormVisible: false,
  632. dialogStatus: '',
  633. myComponent: null
  634. },
  635. textMap: {
  636. newGeneration: '新生成',
  637. historyRecord: '历史记录',
  638. revisePlan: '修改计划',
  639. copy: '复制计划'
  640. },
  641. isokDisable: false,
  642. requestParam: {},
  643. rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
  644. cellStyle: { padding: 0 + 'px' },
  645. isShowDialog: false,
  646. activeName: '栏舍配方',
  647. parentDate: ''
  648. }
  649. },
  650. created() {
  651. this.parentDate = this.table.getdataListParm.parammaps.mydate
  652. console.log(this.parentDate, 'this.parentDate')
  653. this.getList()
  654. this.getDownList()
  655. this.getIsDisplay()
  656. },
  657. mounted() {
  658. this.table.getdataListParm.parammaps.mydate = parseTime(new Date(), '{y}-{m}-{d}')
  659. },
  660. methods: {
  661. getIsDisplay() {
  662. GetDataByName(this.maxTime.getMaxTimesParm).then(response => {
  663. console.log(response.data.list[0].inforvalue)
  664. if (response.data.list[0].inforvalue == 1) {
  665. this.frequencyList = [{ id: '1', name: '第一班' }]
  666. } else if (response.data.list[0].inforvalue == 2) {
  667. this.frequencyList = [{ id: '1', name: '第一班' }, { id: '2', name: '第二班' }]
  668. } else if (response.data.list[0].inforvalue == 3) {
  669. this.frequencyList = [{ id: '1', name: '第一班' }, { id: '2', name: '第二班' }, { id: '3', name: '第三班' }]
  670. } else if (response.data.list[0].inforvalue == 4) {
  671. this.frequencyList = [{ id: '1', name: '第一班' }, { id: '2', name: '第二班' }, { id: '3', name: '第三班' }, { id: '4', name: '第四班' }]
  672. }
  673. })
  674. },
  675. getDownList() {
  676. GetDataByNames(this.requestParams).then(response => {
  677. // this.livestockTypeList = response.data.getDictByName.list
  678. })
  679. },
  680. // -------------------日执行计划-----------------------------
  681. handleBefore() {
  682. if (this.table.getdataListParm.parammaps.mydate !== '' && this.table.getdataListParm.parammaps.mydate !== null) {
  683. this.table.getdataListParm.parammaps.mydate = new Date(this.table.getdataListParm.parammaps.mydate)
  684. var start = new Date(this.table.getdataListParm.parammaps.mydate.setDate(this.table.getdataListParm.parammaps.mydate.getDate() - 1))
  685. // var start = this.table.getdataListParm.parammaps.mydate - 1
  686. this.table.getdataListParm.parammaps.mydate = parseTime(start, '{y}-{m}-{d}')
  687. // this.$forceUpdate()
  688. this.parentDate = this.table.getdataListParm.parammaps.mydate
  689. this.getList()
  690. }
  691. },
  692. handleNext() {
  693. if (this.table.getdataListParm.parammaps.mydate !== '' && this.table.getdataListParm.parammaps.mydate !== null) {
  694. this.table.getdataListParm.parammaps.mydate = new Date(this.table.getdataListParm.parammaps.mydate)
  695. var stop = new Date(this.table.getdataListParm.parammaps.mydate.setDate(this.table.getdataListParm.parammaps.mydate.getDate() + 1))
  696. this.table.getdataListParm.parammaps.mydate = parseTime(stop, '{y}-{m}-{d}')
  697. this.parentDate = this.table.getdataListParm.parammaps.mydate
  698. this.getList()
  699. }
  700. },
  701. getList() {
  702. this.table.listLoading = true
  703. GetDataByName(this.table.getdataListParm).then(response => {
  704. console.log('table数据', response.data.list)
  705. if (response.data.list !== null) {
  706. // var obj = { 'id': '580999', 'havebutton': '0', 'lpplantype': 2, 'pid': '3283220207862547456', 'times': '第二班', 'projname': '2.666' }
  707. // response.data.list[6] = obj
  708. this.getIsColor(response.data.list)
  709. this.table.list = response.data.list
  710. this.table.pageNum = response.data.pageNum
  711. this.table.pageSize = response.data.pageSize
  712. this.table.total = response.data.total
  713. console.log('计划类型', response.data.list[0].lpplantype)
  714. if (response.data.list[0].lpplantype == 0) {
  715. // 撒料
  716. this.table2.getdataListParm.name = 'getDownloadplandtl1ListV2'
  717. this.table3.getdataListParm.name = 'getDownloadplandt2ListV2'
  718. this.table2.getdataListParm.parammaps.useinbartype = ''
  719. this.table3.getdataListParm.parammaps.useinbartype = ''
  720. this.table2.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
  721. this.table3.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
  722. this.table2.getdataListParm.parammaps.id = response.data.list[0].id
  723. this.table3.getdataListParm.parammaps.id = response.data.list[0].id
  724. this.table3.getdataListParm.parammaps.lpplantype = response.data.list[0].lpplantype
  725. this.getList2()
  726. this.getList3()
  727. } else if (response.data.list[0].lpplantype == 1) {
  728. // 撒料计划-混料
  729. this.table2.getdataListParm.name = 'getDownloadplandtl1ListV2'
  730. this.table3.getdataListParm.name = 'getDownloadplandt2ListV2'
  731. this.table2.getdataListParm.parammaps.useinbartype = ''
  732. this.table3.getdataListParm.parammaps.useinbartype = ''
  733. this.table2.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
  734. this.table3.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
  735. this.table2.getdataListParm.parammaps.id = response.data.list[0].id
  736. this.table3.getdataListParm.parammaps.id = response.data.list[0].id
  737. this.table3.getdataListParm.parammaps.lpplantype = response.data.list[0].lpplantype
  738. this.getList2()
  739. this.getList3()
  740. } else if (response.data.list[0].lpplantype == 2) {
  741. // 撒料计划-撒料
  742. this.table2.getdataListParm.name = 'getDownloadplandt2ListV2'
  743. this.table3.getdataListParm.name = 'getDownloadplandtl1ListV2'
  744. this.table2.getdataListParm.parammaps.useinbartype = ''
  745. this.table3.getdataListParm.parammaps.useinbartype = ''
  746. this.table2.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
  747. this.table3.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
  748. this.table2.getdataListParm.parammaps.id = response.data.list[0].id
  749. this.table3.getdataListParm.parammaps.id = response.data.list[0].id
  750. this.table3.getdataListParm.parammaps.lpplantype = response.data.list[0].lpplantype
  751. this.getList2()
  752. this.getList3()
  753. } else if (response.data.list[0].lpplantype == 3) {
  754. // 剩料
  755. this.table2.getdataListParm.name = 'getDownloadplandt2ListV2'
  756. this.table3.getdataListParm.name = 'getDownloadplandt2ListV2'
  757. this.table2.getdataListParm.parammaps.useinbartype = 0
  758. this.table3.getdataListParm.parammaps.useinbartype = 1
  759. this.table2.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
  760. this.table3.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
  761. this.table2.getdataListParm.parammaps.id = response.data.list[0].id
  762. this.table3.getdataListParm.parammaps.id = response.data.list[0].id
  763. this.table3.getdataListParm.parammaps.lpplantype = response.data.list[0].lpplantype
  764. this.getList2()
  765. this.getList3()
  766. } else if (response.data.list[0].lpplantype == 4) {
  767. // 预混
  768. this.table2.getdataListParm.name = 'getDownloadplandtl1ListV2'
  769. this.table2.getdataListParm.parammaps.useinbartype = ''
  770. this.table3.getdataListParm.parammaps.useinbartype = ''
  771. this.table2.getdataListParm.parammaps.id = response.data.list[0].id
  772. this.table3.getdataListParm.parammaps.lpplantype = response.data.list[0].lpplantype
  773. this.getList2()
  774. } else if (response.data.list[0].lpplantype == 5) {
  775. // 预称重计划
  776. this.table2.getdataListParm.name = 'getDownloadplandtl1ListV2'
  777. this.table3.getdataListParm.name = 'getDownloadplandt2ListV2'
  778. this.table2.getdataListParm.parammaps.useinbartype = ''
  779. this.table3.getdataListParm.parammaps.useinbartype = ''
  780. this.table2.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
  781. this.table3.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
  782. this.table2.getdataListParm.parammaps.id = response.data.list[0].id
  783. this.table3.getdataListParm.parammaps.id = response.data.list[0].id
  784. this.table3.getdataListParm.parammaps.lpplantype = response.data.list[0].lpplantype
  785. this.getList2()
  786. this.getList3()
  787. }
  788. } else {
  789. this.table.list = []
  790. this.table3.getdataListParm.parammaps.lpplantype = ''
  791. this.table2.getdataListParm.parammaps.id = ''
  792. this.table3.getdataListParm.parammaps.id = ''
  793. console.log(222222222222222)
  794. // this.getList2()
  795. // this.getList3()
  796. this.table2.list = []
  797. this.table3.list = []
  798. }
  799. setTimeout(() => {
  800. this.table.listLoading = false
  801. }, 100)
  802. })
  803. },
  804. getIsColor(arr) {
  805. var map = {}
  806. var dest = []
  807. for (var i = 0; i < arr.length; i++) {
  808. var ai = arr[i]
  809. if (!map[ai.pid]) {
  810. dest.push({
  811. pid: ai.pid,
  812. data: [ai]
  813. })
  814. map[ai.pid] = ai
  815. } else {
  816. for (var j = 0; j < dest.length; j++) {
  817. var dj = dest[j]
  818. if (dj.pid == ai.pid) {
  819. dj.data.push(ai)
  820. break
  821. }
  822. }
  823. }
  824. }
  825. console.log(dest)
  826. var newArr1 = []
  827. for (var i = 0; i < dest.length; i++) {
  828. var newArr = dest[i].data
  829. for (var j = 0; j < dest[i].data.length; j++) {
  830. dest[i].data[j].isColor = i
  831. newArr1.push(dest[i].data[j])
  832. }
  833. }
  834. console.log(newArr1)
  835. this.table.list = newArr1
  836. },
  837. tableRowClassName({ row }) {
  838. if (row.isColor % 2 == 0) {
  839. return 'warning-row'
  840. } else {
  841. return 'success-row'
  842. }
  843. },
  844. lpplantype: function(cellValue) {
  845. if (cellValue.lpplantype == 0) {
  846. return '撒料计划'
  847. } else if (cellValue.lpplantype == 1) {
  848. return '撒料计划-混料'
  849. } else if (cellValue.lpplantype == 2) {
  850. return '撒料计划-撒料'
  851. } else if (cellValue.lpplantype == 3) {
  852. return '剩料计划'
  853. } else if (cellValue.lpplantype == 4) {
  854. return '预混计划'
  855. } else if (cellValue.lpplantype == 5) {
  856. return '预称重计划'
  857. }
  858. },
  859. changeDate(val) {
  860. console.log('选择了日期', val)
  861. this.getList()
  862. // this.getList2()
  863. // this.getList3()
  864. this.parentDate = this.table.getdataListParm.parammaps.mydate
  865. console.log(this.parentDate, 'this.parentDate')
  866. },
  867. changePlanType(val) {
  868. console.log('选择了计划类型', val)
  869. this.getList()
  870. this.getList2()
  871. this.getList3()
  872. },
  873. changeFrequency(val) {
  874. console.log('选择了班次', val)
  875. this.getList()
  876. this.getList2()
  877. this.getList3()
  878. },
  879. // 日执行计划行点击
  880. tableRowClick(row, column, event) {
  881. console.log(row, column, event)
  882. console.log('点击计划类型', row.lpplantype)
  883. // 撒料计划0/撒料计划-混料1/撒料计划-撒料2/剩料计划3/预混计划4/预称重计划5
  884. if (row.lpplantype == 0) {
  885. // 撒料
  886. this.table2.getdataListParm.name = 'getDownloadplandtl1ListV2'
  887. this.table3.getdataListParm.name = 'getDownloadplandt2ListV2'
  888. this.table2.getdataListParm.parammaps.useinbartype = ''
  889. this.table3.getdataListParm.parammaps.useinbartype = ''
  890. this.table2.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
  891. this.table3.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
  892. this.table2.getdataListParm.parammaps.id = row.id
  893. this.table3.getdataListParm.parammaps.id = row.id
  894. this.table3.getdataListParm.parammaps.lpplantype = row.lpplantype
  895. this.getList2()
  896. this.getList3()
  897. } else if (row.lpplantype == 1) {
  898. // 撒料计划-混料
  899. this.table2.getdataListParm.name = 'getDownloadplandtl1ListV2'
  900. this.table3.getdataListParm.name = 'getDownloadplandt2ListV2'
  901. this.table2.getdataListParm.parammaps.useinbartype = ''
  902. this.table3.getdataListParm.parammaps.useinbartype = ''
  903. this.table2.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
  904. this.table3.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
  905. this.table2.getdataListParm.parammaps.id = row.id
  906. this.table3.getdataListParm.parammaps.id = row.id
  907. this.table3.getdataListParm.parammaps.lpplantype = row.lpplantype
  908. this.getList2()
  909. this.getList3()
  910. } else if (row.lpplantype == 2) {
  911. // 撒料计划-撒料
  912. this.table2.getdataListParm.name = 'getDownloadplandt2ListV2'
  913. this.table3.getdataListParm.name = 'getDownloadplandtl1ListV2'
  914. this.table2.getdataListParm.parammaps.useinbartype = ''
  915. this.table3.getdataListParm.parammaps.useinbartype = ''
  916. this.table2.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
  917. this.table3.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
  918. this.table2.getdataListParm.parammaps.id = row.id
  919. this.table3.getdataListParm.parammaps.id = row.id
  920. this.table3.getdataListParm.parammaps.lpplantype = row.lpplantype
  921. this.getList2()
  922. this.getList3()
  923. console.log(this.table3.getdataListParm.parammaps.lpplantype)
  924. } else if (row.lpplantype == 3) {
  925. // 剩料
  926. this.table2.getdataListParm.name = 'getDownloadplandt2ListV2'
  927. this.table3.getdataListParm.name = 'getDownloadplandt2ListV2'
  928. this.table2.getdataListParm.parammaps.useinbartype = 0
  929. this.table3.getdataListParm.parammaps.useinbartype = 1
  930. this.table2.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
  931. this.table3.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
  932. this.table2.getdataListParm.parammaps.id = row.id
  933. this.table3.getdataListParm.parammaps.id = row.id
  934. this.table3.getdataListParm.parammaps.lpplantype = row.lpplantype
  935. this.getList2()
  936. this.getList3()
  937. } else if (row.lpplantype == 4) {
  938. // 预混
  939. this.table2.getdataListParm.name = 'getDownloadplandtl1ListV2'
  940. this.table3.getdataListParm.name = 'getDownloadplandt2ListV2'
  941. this.table2.getdataListParm.parammaps.useinbartype = ''
  942. this.table3.getdataListParm.parammaps.useinbartype = ''
  943. this.table2.getdataListParm.parammaps.id = row.id
  944. this.table3.getdataListParm.parammaps.lpplantype = row.lpplantype
  945. this.getList2()
  946. } else if (row.lpplantype == 5) {
  947. // 预称重计划
  948. this.table2.getdataListParm.name = 'getDownloadplandtl1ListV2'
  949. this.table3.getdataListParm.name = 'getDownloadplandt2ListV2'
  950. this.table2.getdataListParm.parammaps.useinbartype = ''
  951. this.table3.getdataListParm.parammaps.useinbartype = ''
  952. this.table2.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
  953. this.table3.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
  954. this.table2.getdataListParm.parammaps.id = row.id
  955. this.table3.getdataListParm.parammaps.id = row.id
  956. this.table3.getdataListParm.parammaps.lpplantype = row.lpplantype
  957. this.getList2()
  958. this.getList3()
  959. }
  960. this.$forceUpdate()
  961. },
  962. // 计划内容操作详情
  963. getList2() {
  964. this.table2.listLoading = true
  965. this.table2.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
  966. GetDataByName(this.table2.getdataListParm).then(response => {
  967. console.log('table数据', response.data.list)
  968. if (response.data.list !== null) {
  969. this.table2.list = response.data.list
  970. // 撒料计划0/撒料计划-混料1/撒料计划-撒料2/剩料计划3/预混计划4
  971. if (this.table3.getdataListParm.parammaps.lpplantype == 0 || this.table3.getdataListParm.parammaps.lpplantype == 1 || this.table3.getdataListParm.parammaps.lpplantype == 4) {
  972. const arr = []
  973. var a = 0
  974. let b = this.table2.list[0].sort
  975. let c = 0
  976. for (let i = 0; i < this.table2.list.length; i++) {
  977. if (b !== parseInt(this.table2.list[i].sort)) {
  978. b = this.table2.list[i].sort
  979. arr.push({ 'sort': '小计', 'weight': a.toFixed(2) })
  980. a = 0
  981. }
  982. a = a + parseFloat(this.table2.list[i].weight)
  983. c = c + parseFloat(this.table2.list[i].weight)
  984. arr.push(this.table2.list[i])
  985. }
  986. arr.push({ 'sort': '小计', 'weight': a })
  987. arr.push({ 'sort': '总计', 'weight': c.toFixed(2) })
  988. this.table2.list = arr
  989. }
  990. if (this.table3.getdataListParm.parammaps.lpplantype == 2) {
  991. const arr = []
  992. var aa = 0
  993. let bb = this.table2.list[0].sort
  994. let cc = 0
  995. for (let i = 0; i < this.table2.list.length; i++) {
  996. if (bb !== parseInt(this.table2.list[i].sort)) {
  997. bb = this.table2.list[i].sort
  998. aa = 0
  999. }
  1000. aa = aa + parseFloat(this.table2.list[i].weight)
  1001. cc = cc + parseFloat(this.table2.list[i].weight)
  1002. arr.push(this.table2.list[i])
  1003. }
  1004. arr.push({ 'sort': '总计', 'weight': cc.toFixed(2) })
  1005. this.table2.list = arr
  1006. console.log('this.table2.list', this.table2.list)
  1007. console.log(this.table3.getdataListParm.parammaps.lpplantype)
  1008. }
  1009. console.log(this.table2.list)
  1010. this.table2.pageNum = response.data.pageNum
  1011. this.table2.pageSize = response.data.pageSize
  1012. this.table2.total = response.data.total
  1013. } else {
  1014. this.table2.list = []
  1015. }
  1016. setTimeout(() => {
  1017. this.table2.listLoading = false
  1018. }, 100)
  1019. })
  1020. },
  1021. // 计划内容栏舍详情
  1022. getList3() {
  1023. this.table3.listLoading = true
  1024. this.table3.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
  1025. GetDataByName(this.table3.getdataListParm).then(response => {
  1026. console.log('table数据', response.data.list)
  1027. if (response.data.list !== null) {
  1028. this.table3.list = response.data.list
  1029. if (this.table3.getdataListParm.parammaps.lpplantype == 0) {
  1030. const arr = []
  1031. var a = 0
  1032. let b = this.table3.list[0].sort
  1033. let c = 0
  1034. for (let i = 0; i < this.table3.list.length; i++) {
  1035. if (b !== parseInt(this.table3.list[i].sort)) {
  1036. b = this.table3.list[i].sort
  1037. a = 0
  1038. }
  1039. a = a + parseFloat(this.table3.list[i].weight)
  1040. c = c + parseFloat(this.table3.list[i].weight)
  1041. arr.push(this.table3.list[i])
  1042. }
  1043. arr.push({ 'sort': '总计', 'weight': c.toFixed(2) })
  1044. this.table3.list = arr
  1045. }
  1046. this.table3.pageNum = response.data.pageNum
  1047. this.table3.pageSize = response.data.pageSize
  1048. this.table3.total = response.data.total
  1049. } else {
  1050. this.table3.list = []
  1051. }
  1052. setTimeout(() => {
  1053. this.table3.listLoading = false
  1054. }, 100)
  1055. })
  1056. },
  1057. // 新生成
  1058. handleCreate() {
  1059. console.log('点击了新生成')
  1060. this.newGeneration.temp.inputDatetime = [parseTime(new Date(), '{y}-{m}-{d}'), parseTime(new Date(), '{y}-{m}-{d}')]
  1061. this.newGeneration.dialogStatus = 'newGeneration'
  1062. this.newGeneration.dialogFormVisible = true
  1063. GetDataByName(this.newGeneration.getdataListParm).then(response => {
  1064. console.log('table数据', response.data.list)
  1065. if (response.data.list !== null) {
  1066. if (response.data.list[0].vmsg == '存在未分配') {
  1067. this.$message({ type: 'warning', message: '撒料计划中存在未分配完栏舍,建议及时进行分配', duration: 2000 })
  1068. }
  1069. }
  1070. })
  1071. },
  1072. DateDiff(sDate1, sDate2) {
  1073. console.log(sDate1, sDate2)
  1074. var aDate, oDate1, oDate2, iDays
  1075. aDate = sDate1.split('-')
  1076. oDate1 = new Date(aDate[0], aDate[1], aDate[2]) // 转换为12-18-2006格式
  1077. aDate = sDate2.split('-')
  1078. oDate2 = new Date(aDate[0], aDate[1], aDate[2])
  1079. iDays = parseInt(Math.abs(oDate1 - oDate2) / 1000 / 60 / 60 / 24) // 把相差的毫秒数转换为天数
  1080. this.newGeneration.temp.days = parseInt(iDays) + 1
  1081. return iDays
  1082. },
  1083. newGenerationData() {
  1084. console.log('点击了新生成保存', this.newGeneration.temp)
  1085. this.isokDisable = true
  1086. setTimeout(() => {
  1087. this.isokDisable = false
  1088. }, 5000)
  1089. this.$refs['temp'].validate(valid => {
  1090. if (valid) {
  1091. this.newGeneration.temp.startTime = parseTime(this.newGeneration.temp.inputDatetime[0], '{y}-{m}-{d}')
  1092. this.newGeneration.temp.stopTime = parseTime(this.newGeneration.temp.inputDatetime[1], '{y}-{m}-{d}')
  1093. this.DateDiff(this.newGeneration.temp.stopTime, this.newGeneration.temp.startTime)
  1094. this.requestParam = {}
  1095. this.requestParam.common = { 'returnmap': '0' }
  1096. this.requestParam.data = []
  1097. this.requestParam.data[0] = { 'name': 'checkDLPIsStart', 'type': 'v', 'parammaps': {
  1098. pastureid: Cookies.get('pastureid'),
  1099. startTime: this.newGeneration.temp.startTime
  1100. }}
  1101. this.requestParam.data[1] = { 'name': 'checkPreMixStorage', 'type': 'e', 'parammaps': {
  1102. pastureid: Cookies.get('pastureid'),
  1103. days: this.newGeneration.temp.days
  1104. }}
  1105. this.requestParam.data[2] = { 'name': 'createdownloadedplan', 'type': 'e', 'parammaps': {
  1106. pastureid: Cookies.get('pastureid'),
  1107. startTime: this.newGeneration.temp.startTime,
  1108. stopTime: this.newGeneration.temp.stopTime
  1109. }}
  1110. ExecDataByConfig(this.requestParam).then(response => {
  1111. console.log('新生成保存发送参数', this.requestParam)
  1112. if (response.msg === 'fail') {
  1113. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1114. } else {
  1115. this.$notify({ title: '', message: '保存成功', type: 'success', duration: 2000 })
  1116. this.newGeneration.dialogFormVisible = false
  1117. this.getList()
  1118. }
  1119. })
  1120. }
  1121. })
  1122. },
  1123. // 修改计划
  1124. handleRevisePlan(data) {
  1125. var arr = []
  1126. for (let i = 0; i < this.table.list.length; i++) {
  1127. if (this.table.list[i].havebutton == 1) {
  1128. arr.push(this.table.list[i])
  1129. }
  1130. }
  1131. if (arr.length !== this.table.list.length) {
  1132. console.log('点击了修改计划1', this.activeName)
  1133. this.isShowDialog = true
  1134. this.activeName = '栏舍配方'
  1135. console.log('点击了修改计划2', this.activeName)
  1136. } else {
  1137. this.$message({ type: 'erro', message: '当前日期不可修改计划,请重新选择日期' })
  1138. }
  1139. },
  1140. handleExport() {
  1141. console.log('点击了导出')
  1142. },
  1143. rowDrop() {
  1144. console.log(document.querySelector('#table1 .el-table__body-wrapper tbody'))
  1145. const tbody = document.querySelector('#table1 .el-table__body-wrapper tbody')
  1146. // this.sorTable()
  1147. const that = this
  1148. var sortable = Sortable.create(tbody, {
  1149. disabled: that.dropState,
  1150. onChoose({ newIndex, oldIndex }) {
  1151. console.log(that.isOrder, 'that.isOrder == false')
  1152. console.log(that.dropState, 'that.dropState')
  1153. if (that.dropState == true || that.isOrder == true) {
  1154. sortable.destroy()
  1155. }
  1156. },
  1157. onEnd(evt) {
  1158. var tableList = [...that.table.list] // 保留拖动前数据
  1159. const targetRow = that.table.list.splice(evt.oldIndex, 1)[0] // 拖动数据
  1160. const targetRow2 = that.table.list[evt.newIndex] // 拖动后下方数据
  1161. const targetRow3 = that.table.list[evt.newIndex - 1] // 拖动后上方数据
  1162. console.log(targetRow, 'targetRow')
  1163. console.log(targetRow2, 'targetRow2')
  1164. console.log(targetRow3, 'targetRow3')
  1165. that.table.list.splice(evt.newIndex, 0, targetRow)
  1166. // ==========
  1167. // 已执行的计划不可拖动
  1168. if (targetRow.havebutton == 1) {
  1169. that.$nextTick(() => {
  1170. that.$set(that.table, 'list', tableList)
  1171. })
  1172. that.$message({ type: 'error', message: '因已执行的计划不可调整顺序', duration: 2000 })
  1173. return false
  1174. }
  1175. // 相同班次之间可以拖动
  1176. if (targetRow2 !== undefined && targetRow3 !== undefined) {
  1177. if (targetRow.times !== targetRow2.times && targetRow.times !== targetRow3.times) {
  1178. that.$nextTick(() => {
  1179. that.$set(that.table, 'list', tableList)
  1180. })
  1181. that.$message({ type: 'error', message: '因班次不同不可调整顺序', duration: 2000 })
  1182. return false
  1183. }
  1184. } else if (targetRow2 !== undefined && targetRow3 == undefined) {
  1185. if (targetRow.times !== targetRow2.times) {
  1186. that.$nextTick(() => {
  1187. that.$set(that.table, 'list', tableList)
  1188. })
  1189. that.$message({ type: 'error', message: '因班次不同不可调整顺序', duration: 2000 })
  1190. return false
  1191. }
  1192. } else if (targetRow2 == undefined && targetRow3 !== undefined) {
  1193. if (targetRow.times !== targetRow3.times) {
  1194. that.$nextTick(() => {
  1195. that.$set(that.table, 'list', tableList)
  1196. })
  1197. that.$message({ type: 'error', message: '因班次不同不可调整顺序', duration: 2000 })
  1198. return false
  1199. }
  1200. }
  1201. // 撒料计划0,
  1202. // 撒料计划-混料1
  1203. // 撒料计划-撒料2
  1204. // 剩料计划3
  1205. // 预混计划4
  1206. // 预称重计划5
  1207. if (targetRow.lpplantype == 1) { // 拖动数据为撒料计划-混料
  1208. if (targetRow2 == undefined) {
  1209. that.$nextTick(() => {
  1210. that.$set(that.table, 'list', tableList)
  1211. })
  1212. } else if (targetRow2 !== undefined && targetRow2.pid == targetRow.pid) {
  1213. that.$nextTick(() => {
  1214. that.$set(that.table, 'list', tableList)
  1215. })
  1216. } else {
  1217. var pidArr = [] // pid相同的值
  1218. var pidArr1 = [] //
  1219. var index // 索引
  1220. for (let i = 0; i < tableList.length; i++) {
  1221. if (tableList[i].pid == targetRow.pid) {
  1222. pidArr.push(tableList[i])
  1223. } else {
  1224. pidArr1.push(tableList[i])
  1225. }
  1226. }
  1227. // 找到对应上方pid 的ID
  1228. // 比如说id 580243 找到对应的索引
  1229. if (targetRow3 !== undefined) {
  1230. for (let i = 0; i < pidArr1.length; i++) {
  1231. if (pidArr1[i].id == targetRow3.id) {
  1232. index = i
  1233. }
  1234. }
  1235. } else {
  1236. for (let i = 0; i < pidArr1.length; i++) {
  1237. if (pidArr1[i].id == targetRow2.id) {
  1238. index = i - 1
  1239. }
  1240. }
  1241. }
  1242. pidArr1.splice(index + 1, 0, ...pidArr)
  1243. console.log(pidArr1)
  1244. that.$nextTick(() => {
  1245. that.table.list = pidArr1
  1246. })
  1247. }
  1248. if (targetRow2 !== undefined && targetRow3 !== undefined) {
  1249. if (targetRow2.pid == targetRow3.pid) {
  1250. that.$nextTick(() => {
  1251. that.$set(that.table, 'list', tableList)
  1252. })
  1253. that.$message({ type: 'error', message: '不可将其他计划拖动至预称重计划之间', duration: 2000 })
  1254. return false
  1255. }
  1256. }
  1257. } else if (targetRow.lpplantype == 5) { // 拖动数据为预称重计划
  1258. if (targetRow2 !== undefined) {
  1259. if (targetRow3.pid !== targetRow.pid && targetRow2.pid !== targetRow.pid) {
  1260. that.$nextTick(() => {
  1261. that.$set(that.table, 'list', tableList)
  1262. })
  1263. that.$message({ type: 'error', message: '预称重计划不可拖动至其他位置', duration: 2000 })
  1264. return false
  1265. } else {
  1266. if (targetRow3.lpplantype == 0 && targetRow2.pid !== targetRow.pid) {
  1267. that.$nextTick(() => {
  1268. that.$set(that.table, 'list', tableList)
  1269. })
  1270. that.$message({ type: 'error', message: '预称重计划不可拖动至撒料计划下方', duration: 2000 })
  1271. return false
  1272. }
  1273. }
  1274. } else {
  1275. if (targetRow2 == undefined) {
  1276. that.$nextTick(() => {
  1277. that.$set(that.table, 'list', tableList)
  1278. })
  1279. that.$message({ type: 'error', message: '预称重计划不可拖动至其他位置', duration: 2000 })
  1280. return false
  1281. } else if (targetRow3.pid !== targetRow.pid) {
  1282. that.$nextTick(() => {
  1283. that.$set(that.table, 'list', tableList)
  1284. })
  1285. that.$message({ type: 'error', message: '预称重计划不可拖动至其他位置', duration: 2000 })
  1286. return false
  1287. } else {
  1288. if (targetRow3.lpplantype == 0) {
  1289. that.$nextTick(() => {
  1290. that.$set(that.table, 'list', tableList)
  1291. })
  1292. that.$message({ type: 'error', message: '预称重计划不可拖动至撒料计划下方', duration: 2000 })
  1293. return false
  1294. }
  1295. }
  1296. }
  1297. if (targetRow2 !== undefined && targetRow3 !== undefined) {
  1298. if (targetRow2.pid !== targetRow.pid && targetRow3.pid !== targetRow.pid) {
  1299. that.$nextTick(() => {
  1300. that.$set(that.table, 'list', tableList)
  1301. })
  1302. that.$message({ type: 'error', message: '不可将其他计划拖动至预称重计划之间', duration: 2000 })
  1303. return false
  1304. } else if (targetRow3.pid == targetRow.pid && (targetRow3.lpplantype == 1 || targetRow3.lpplantype == 2)) {
  1305. that.$nextTick(() => {
  1306. that.$set(that.table, 'list', tableList)
  1307. })
  1308. that.$message({ type: 'error', message: '预称重计划不可拖动至其他位置', duration: 2000 })
  1309. return false
  1310. }
  1311. }
  1312. } else if (targetRow.lpplantype == 2) { // 拖动数据为撒料计划-撒料
  1313. if (targetRow2 == undefined) {
  1314. if (targetRow3.pid !== targetRow.pid) {
  1315. that.$nextTick(() => {
  1316. that.$set(that.table, 'list', tableList)
  1317. })
  1318. that.$message({ type: 'error', message: '撒料计划-撒料不可拖动至其他位置', duration: 2000 })
  1319. return false
  1320. }
  1321. } else {
  1322. if (targetRow2.lpplantype == 1 && (targetRow2.pid == targetRow.pid || targetRow2 == undefined)) {
  1323. // 拖动数据下方为撒料计划-混料时且pid相同,不可拖动,提示
  1324. that.$nextTick(() => {
  1325. that.$set(that.table, 'list', tableList)
  1326. })
  1327. that.$message({ type: 'error', message: '撒料计划-撒料不可拖动至撒料计划-混料上方', duration: 2000 })
  1328. return false
  1329. } else if (targetRow.lpplantype == 2 && (targetRow2.pid == targetRow.pid || targetRow3.pid == targetRow.pid || targetRow2 == undefined || targetRow3 == undefined)) {
  1330. console.log('正常拖动')
  1331. } else {
  1332. that.$nextTick(() => {
  1333. that.$set(that.table, 'list', tableList)
  1334. })
  1335. that.$message({ type: 'error', message: '撒料计划-撒料不可拖动至其他位置', duration: 2000 })
  1336. return false
  1337. }
  1338. }
  1339. if (targetRow2 !== undefined && targetRow3 !== undefined) {
  1340. if (targetRow2.pid == targetRow3.pid) {
  1341. that.$nextTick(() => {
  1342. that.$set(that.table, 'list', tableList)
  1343. })
  1344. that.$message({ type: 'error', message: '不可将其他计划拖动至预称重计划之间', duration: 2000 })
  1345. return false
  1346. }
  1347. }
  1348. } else if (targetRow.lpplantype == 0) { // 拖动数据为撒料计划
  1349. console.log('遍历有相同的pid,一起跟着拖动3')
  1350. var pidArr = [] // pid相同的值
  1351. var pidArr1 = [] //
  1352. var index // 索引
  1353. for (let i = 0; i < tableList.length; i++) {
  1354. if (tableList[i].pid == targetRow.pid) {
  1355. pidArr.push(tableList[i])
  1356. } else {
  1357. pidArr1.push(tableList[i])
  1358. }
  1359. }
  1360. if (pidArr.length > 0) {
  1361. // 找到对应上方pid 的ID
  1362. // 比如说id 580243 找到对应的索引
  1363. if (targetRow3 !== undefined) {
  1364. for (let i = 0; i < pidArr1.length; i++) {
  1365. if (pidArr1[i].id == targetRow3.id) {
  1366. index = i
  1367. }
  1368. }
  1369. } else {
  1370. for (let i = 0; i < pidArr1.length; i++) {
  1371. if (pidArr1[i].id == targetRow2.id) {
  1372. index = i - 1
  1373. }
  1374. }
  1375. }
  1376. pidArr1.splice(index + 1, 0, ...pidArr)
  1377. console.log(pidArr1)
  1378. that.$nextTick(() => {
  1379. that.table.list = pidArr1
  1380. })
  1381. }
  1382. if (targetRow2 !== undefined && targetRow3 !== undefined) {
  1383. if (targetRow2.pid == targetRow3.pid) {
  1384. that.$nextTick(() => {
  1385. that.$set(that.table, 'list', tableList)
  1386. })
  1387. that.$message({ type: 'error', message: '不可将其他计划拖动至预称重计划之间', duration: 2000 })
  1388. return false
  1389. }
  1390. }
  1391. } else if (targetRow.lpplantype == 3 || targetRow.lpplantype == 4) {
  1392. if (targetRow2 !== undefined && targetRow3 !== undefined) {
  1393. if (targetRow2.pid == targetRow3.pid) {
  1394. if (targetRow2.lpplantype == 5 && targetRow3.lpplantype == 5) {
  1395. that.$nextTick(() => {
  1396. that.$set(that.table, 'list', tableList)
  1397. })
  1398. that.$message({ type: 'error', message: '不可拖动至预称重计划跟预称重计划之间', duration: 2000 })
  1399. return false
  1400. } else {
  1401. that.$nextTick(() => {
  1402. that.$set(that.table, 'list', tableList)
  1403. })
  1404. that.$message({ type: 'error', message: '不可拖动至撒料计划-撒料跟撒料计划-混料之间', duration: 2000 })
  1405. return false
  1406. }
  1407. }
  1408. }
  1409. }
  1410. // ===
  1411. }
  1412. })
  1413. },
  1414. // 复制
  1415. handleCopy() {
  1416. if (this.table.list.length > 0) {
  1417. this.newGeneration.temp = {}
  1418. this.newGeneration.dialogStatus = 'copy'
  1419. this.newGeneration.dialogFormVisible = true
  1420. } else {
  1421. this.$message({ type: 'error', message: '当前无计划可复制' })
  1422. }
  1423. },
  1424. copyData() {
  1425. console.log(this.newGeneration.temp.copyInputDatetime)
  1426. this.isokDisable = true
  1427. setTimeout(() => {
  1428. this.isokDisable = false
  1429. }, 5000)
  1430. this.$refs['temp'].validate(valid => {
  1431. if (valid) {
  1432. this.requestParam.name = 'copydownloadedplan'
  1433. this.requestParam.parammaps = {}
  1434. this.requestParam.parammaps.pastureid = Cookies.get('pastureid')
  1435. this.requestParam.parammaps.date = this.table.getdataListParm.parammaps.mydate
  1436. this.requestParam.parammaps.startTime = parseTime(this.newGeneration.temp.copyInputDatetime[0], '{y}-{m}-{d}')
  1437. this.requestParam.parammaps.stopTime = parseTime(this.newGeneration.temp.copyInputDatetime[1], '{y}-{m}-{d}')
  1438. PostDataByName(this.requestParam).then(response => {
  1439. if (response.msg === 'fail') {
  1440. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1441. } else {
  1442. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1443. this.newGeneration.dialogFormVisible = false
  1444. this.getList()
  1445. }
  1446. })
  1447. }
  1448. })
  1449. },
  1450. handleChangeOrder() {
  1451. // 拖动顺序
  1452. this.isOrder = false
  1453. this.rowDrop()
  1454. },
  1455. saveChangeOrder() {
  1456. // 保存顺序
  1457. var sortList = []
  1458. for (let i = 0; i < this.table.list.length; i++) {
  1459. var obj = {}
  1460. obj.sort = i
  1461. obj.pastureid = this.table.list[i].pastureid
  1462. obj.id = this.table.list[i].id
  1463. sortList.push(obj)
  1464. }
  1465. console.log(sortList)
  1466. this.requestParam = {}
  1467. this.requestParam.common = { 'returnmap': '0' }
  1468. this.requestParam.data = []
  1469. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': sortList }}
  1470. this.requestParam.data[0].children = []
  1471. this.requestParam.data[0].children[0] = { 'name': 'updatedownloadesort', 'type': 'e', 'parammaps': {
  1472. id: '@insertSpotList.id',
  1473. pastureid: '@insertSpotList.pastureid',
  1474. sort: '@insertSpotList.sort'
  1475. }}
  1476. ExecDataByConfig(this.requestParam).then(response => {
  1477. console.log('顺序切换保存发送参数', this.requestParam)
  1478. if (response.msg === 'fail') {
  1479. this.$notify({ title: '顺序切换失败', message: response.data, type: 'warning', duration: 2000 })
  1480. } else {
  1481. this.$notify({ title: '', message: '顺序切换成功', type: 'success', duration: 2000 })
  1482. this.getList()
  1483. this.isOrder = true
  1484. }
  1485. })
  1486. },
  1487. cancelChangeOrder() {
  1488. // 取消顺序
  1489. this.getList()
  1490. this.isOrder = true
  1491. }
  1492. }
  1493. }
  1494. </script>
  1495. <style>
  1496. .el-table .warning-row {
  1497. background: oldlace;
  1498. }
  1499. .el-table .success-row {
  1500. background: #f0f9eb;
  1501. }
  1502. </style>
  1503. <style lang="scss" scoped>
  1504. .operation{margin-bottom:10px;}
  1505. .search{margin-top:10px;}
  1506. .table{margin-top:10px;}
  1507. .template{
  1508. background: #fff;
  1509. position: relative;
  1510. }
  1511. .table2{
  1512. float: left;width: 49%;margin-right: 1%;background: red;
  1513. background: #fff;
  1514. position: relative;
  1515. .content-table{margin-top: 70px;}
  1516. }
  1517. .table3{
  1518. float: left;
  1519. width: 49%;
  1520. background: #fff;
  1521. position: relative;
  1522. .content-table{margin-top: 70px;}
  1523. }
  1524. </style>