32e4783b20767167f0d3695bb1abe287d27b076f.svn-base 49 KB

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