120f0f5f040f3ee15cbbd4b4deb268051fa17aa0.svn-base 57 KB

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