index.vue 87 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975
  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="search">
  9. <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" />
  10. <el-button class="el-icon-arrow-left elIconArrowLeft" @click="handleBefore" />
  11. <el-button class="el-icon-arrow-right elIconArrowRight" @click="handleNext" />
  12. <el-select v-model="table.getdataListParm.parammaps.lpplantype" filterable placeholder="计划类型" class="filter-item" clearable style="width: 120px;" @change="changePlanType">
  13. <el-option v-for="item in planTypeList" :key="item.value" :label="item.lable" :value="item.value" />
  14. </el-select>
  15. <el-select v-model="table.getdataListParm.parammaps.times" filterable placeholder="班次" class="filter-item" style="width: 120px;" clearable @change="changeFrequency">
  16. <el-option v-for="item in frequencyList" :key="item.id" :label="item.name" :value="item.id" />
  17. </el-select>
  18. <el-select v-model="table.getdataListParm.parammaps.printType" filterable placeholder="打印类型" class="filter-item" :clearable="false" style="width: 120px;">
  19. <el-option v-for="item in printingTypeList" :key="item.value" :label="item.lable" :value="item.value" />
  20. </el-select>
  21. <el-select v-model="table.getdataListParm.parammaps.plandimen" filterable placeholder="计划维度" class="filter-item" style="width: 120px;" :clearable="false">
  22. <el-option v-for="item in planningDimensionList" :key="item.value" :label="item.lable" :value="item.value" />
  23. </el-select>
  24. <el-select v-model="table.getdataListParm.parammaps.enable3" filterable placeholder="导出类型" class="filter-item" style="width: 120px;" :clearable="false">
  25. <el-option v-for="item in exportTypeList" :key="item.value" :label="item.lable" :value="item.value" />
  26. </el-select>
  27. <el-button class="export" icon="el-icon-upload2" @click="handleExport">导出</el-button>
  28. </div>
  29. <div class="operation" style="margin-bottom: 10px;">
  30. <el-button v-if="isRoleEdit" class="success" icon="el-icon-plus" @click="handleCreate">新生成</el-button>
  31. <el-button v-if="isRoleEdit" class="success" icon="el-icon-edit-outline" @click="handleRevisePlan">修改计划</el-button>
  32. <el-button v-if="isRoleEdit" class="copy" icon="el-icon-copy-document" @click="handleCopy">复制计划</el-button>
  33. <el-button v-if="isOrder && isRoleEdit" icon="el-icon-sort" class="success" @click="handleChangeOrder">更改顺序</el-button>
  34. <div v-else style="margin-left: 10px;display: inline-block;">
  35. <el-button v-if="isRoleEdit" icon="el-icon-folder-checked" class="success" @click="saveChangeOrder">保存</el-button>
  36. <el-button v-if="isRoleEdit" icon="el-icon-close" class="sortCancel" @click="cancelChangeOrder">取消</el-button>
  37. </div>
  38. <el-button v-if="dataSynchronization.isDataSynchronization && isRoleEdit" class="success" @click="handleDataSynchronization">数据同步</el-button>
  39. </div>
  40. <!-- 日执行计划 -->
  41. <div class="table">
  42. <el-table
  43. id="table1"
  44. ref="parent"
  45. :key="table.tableKey"
  46. v-loading="table.listLoading"
  47. element-loading-text="给我一点时间"
  48. :data="table.list"
  49. border
  50. fit
  51. highlight-current-row
  52. style="width: 98%;"
  53. row-key="sort"
  54. :row-style="rowStyle"
  55. :cell-style="cellStyle"
  56. class="elTable table-fixed"
  57. :row-class-name="tableRowClassName"
  58. :height="370"
  59. @row-click="tableRowClick"
  60. >
  61. <el-table-column label="序号" align="center" prop="sort" width="50px" />
  62. <el-table-column label="计划名称" min-width="90px" align="center">
  63. <template slot-scope="scope">
  64. <span>{{ scope.row.projname }}</span>
  65. </template>
  66. </el-table-column>
  67. <el-table-column label="计划类型" prop="weight" min-width="90px" align="center" :formatter="lpplantype" />
  68. <el-table-column label="TMR编号" min-width="90px" align="center">
  69. <template slot-scope="scope">
  70. <span>{{ scope.row.tmrtname }}</span>
  71. </template>
  72. </el-table-column>
  73. <el-table-column label="驾驶员" min-width="80px" align="center">
  74. <template slot-scope="scope">
  75. <span>{{ scope.row.driver }}</span>
  76. </template>
  77. </el-table-column>
  78. <el-table-column label="已执行" min-width="70px" align="center">
  79. <template slot-scope="scope">
  80. <span v-if="scope.row.havebutton == 0">否</span>
  81. <span v-else>是</span>
  82. </template>
  83. </el-table-column>
  84. <el-table-column label="班次" min-width="80px" align="center">
  85. <template slot-scope="scope">
  86. <span>{{ scope.row.times }}</span>
  87. </template>
  88. </el-table-column>
  89. <el-table-column label="理论量" min-width="80px" align="center">
  90. <template slot-scope="scope">
  91. <span>{{ scope.row.lweight }}</span>
  92. </template>
  93. </el-table-column>
  94. <el-table-column label="启用" min-width="70px" align="center">
  95. <template slot-scope="scope">
  96. <el-switch v-if="dataDisabled == false" v-model="scope.row.enable" :disabled="scope.row.havebutton == 1" active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" @change="handleEnableChange(scope.row)" />
  97. <el-switch v-else v-model="scope.row.enable" disabled active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" @change="handleEnableChange(scope.row)" />
  98. </template>
  99. </el-table-column>
  100. <el-table-column label="时间" min-width="80px" align="center">
  101. <template slot-scope="scope">
  102. <span>{{ scope.row.plantime }}</span>
  103. </template>
  104. </el-table-column>
  105. <el-table-column label="配方名称" min-width="100px" align="center">
  106. <template slot-scope="scope">
  107. <span>{{ scope.row.ftname }}</span>
  108. </template>
  109. </el-table-column>
  110. <el-table-column label="牛头数" min-width="80px" align="center">
  111. <template slot-scope="scope">
  112. <span>{{ scope.row.cowcount }}</span>
  113. </template>
  114. </el-table-column>
  115. <el-table-column label="描述" min-width="80px" align="center">
  116. <template slot-scope="scope">
  117. <span>{{ scope.row.display }}</span>
  118. </template>
  119. </el-table-column>
  120. <el-table-column label="发料位" min-width="80px" align="left">
  121. <template slot-scope="scope">
  122. <span>{{ scope.row.barnames }}</span>
  123. </template>
  124. </el-table-column>
  125. <el-table-column align="center" width="100" label="操作" class-name="small-padding fixed-width" fixed="right">
  126. <template slot-scope="{row}">
  127. <el-button class="miniDanger" icon="el-icon-delete" @click="handleRowDelete(row)" />
  128. </template>
  129. </el-table-column>
  130. </el-table>
  131. <span v-if="table.listLoading == false" style="margin-right: 30px;margin-top: 10px;font-size: 14px;">共{{ table.total }}条</span>
  132. </div>
  133. </div>
  134. <!-- 预混料 -->
  135. <div v-if="table3.getdataListParm.parammaps.lpplantype == 4" class="content">
  136. <el-row :gutter="20">
  137. <el-col :span="12">
  138. <div class="table2">
  139. <div class="contentOperation">
  140. <p>计划详情</p>
  141. </div>
  142. <div class="content-table">
  143. <el-table
  144. :key="table2.tableKey"
  145. v-loading="table2.listLoading"
  146. element-loading-text="给我一点时间"
  147. :data="table2.list"
  148. fit
  149. border
  150. highlight-current-row
  151. style="width: 100%;"
  152. height="450"
  153. :row-style="rowStyle"
  154. :cell-style="cellStyle"
  155. class="elTable table-fixed"
  156. >
  157. <el-table-column label="操作序号" min-width="130px" align="center">
  158. <template slot-scope="scope">
  159. <span>{{ scope.row.sort }}</span>
  160. </template>
  161. </el-table-column>
  162. <el-table-column label="饲料名称" prop="fname" min-width="130px" align="center">
  163. <template slot-scope="scope">
  164. <span>{{ scope.row.fname }}</span>
  165. </template>
  166. </el-table-column>
  167. <el-table-column label="设计重量(KG)" prop="weight" min-width="130px" align="center">
  168. <template slot-scope="scope">
  169. <span>{{ scope.row.weight }}</span>
  170. </template>
  171. </el-table-column>
  172. </el-table>
  173. </div>
  174. </div>
  175. </el-col>
  176. </el-row>
  177. </div>
  178. <!-- 撒料 -->
  179. <div v-if="table3.getdataListParm.parammaps.lpplantype == 0" class="content">
  180. <el-row :gutter="20">
  181. <el-col :span="12">
  182. <div class="table2">
  183. <div class="contentOperation">
  184. <p>计划详情</p>
  185. </div>
  186. <div class="content-table">
  187. <el-table
  188. :key="table2.tableKey"
  189. v-loading="table2.listLoading"
  190. element-loading-text="给我一点时间"
  191. :data="table2.list"
  192. fit
  193. border
  194. highlight-current-row
  195. style="width: 100%;"
  196. height="450"
  197. :row-style="rowStyle"
  198. :cell-style="cellStyle"
  199. class="elTable table-fixed"
  200. >
  201. <el-table-column label="操作序号" min-width="130px" align="center">
  202. <template slot-scope="scope">
  203. <span>{{ scope.row.sort }}</span>
  204. </template>
  205. </el-table-column>
  206. <el-table-column label="饲料名称" prop="fname" min-width="130px" align="center">
  207. <template slot-scope="scope">
  208. <span>{{ scope.row.fname }}</span>
  209. </template>
  210. </el-table-column>
  211. <el-table-column label="设计重量(KG)" prop="weight" min-width="130px" align="center">
  212. <template slot-scope="scope">
  213. <span>{{ scope.row.weight }}</span>
  214. </template>
  215. </el-table-column>
  216. </el-table>
  217. </div>
  218. </div>
  219. </el-col>
  220. <el-col :span="12">
  221. <div class="table3">
  222. <div class="contentOperation">
  223. <p>栏舍详情</p>
  224. </div>
  225. <div class="content-table">
  226. <el-table
  227. :key="table3.tableKey"
  228. v-loading="table3.listLoading"
  229. element-loading-text="给我一点时间"
  230. :data="table3.list"
  231. height="450"
  232. fit
  233. border
  234. highlight-current-row
  235. style="width: 100%;"
  236. :row-style="rowStyle"
  237. :cell-style="cellStyle"
  238. class="elTable table-fixed"
  239. >
  240. <el-table-column label=" 操作序号" min-width="130px" align="center">
  241. <template slot-scope="scope">
  242. <span>{{ scope.row.sort }}</span>
  243. </template>
  244. </el-table-column>
  245. <el-table-column label="栏舍" min-width="130px" align="center">
  246. <template slot-scope="scope">
  247. <span>{{ scope.row.fname }}</span>
  248. </template>
  249. </el-table-column>
  250. <el-table-column label="设计重量(KG)" prop="weight" min-width="130px" align="center">
  251. <template slot-scope="scope">
  252. <span>{{ scope.row.weight }}</span>
  253. </template>
  254. </el-table-column>
  255. </el-table>
  256. </div>
  257. </div>
  258. </el-col>
  259. </el-row>
  260. </div>
  261. <!-- 剩料 -->
  262. <div v-if="table3.getdataListParm.parammaps.lpplantype == 3" class="content">
  263. <el-row :gutter="20">
  264. <el-col :span="12"><div class="table2">
  265. <div class="contentOperation">
  266. <p>计划详情</p>
  267. </div>
  268. <div class="content-table">
  269. <el-table
  270. :key="table2.tableKey"
  271. v-loading="table2.listLoading"
  272. element-loading-text="给我一点时间"
  273. :data="table2.list"
  274. fit
  275. border
  276. highlight-current-row
  277. style="width: 100%;"
  278. height="450"
  279. :row-style="rowStyle"
  280. :cell-style="cellStyle"
  281. class="elTable table-fixed"
  282. >
  283. <el-table-column label="操作序号" min-width="130px" align="center">
  284. <template slot-scope="scope">
  285. <span>{{ scope.row.sort }}</span>
  286. </template>
  287. </el-table-column>
  288. <el-table-column label="取料栏舍" prop="fname" min-width="130px" align="center">
  289. <template slot-scope="scope">
  290. <span>{{ scope.row.fname }}</span>
  291. </template>
  292. </el-table-column>
  293. <el-table-column label="处理方式" prop="useinbar" min-width="130px" align="center">
  294. <template slot-scope="scope">
  295. <span>{{ scope.row.useinbar }}</span>
  296. </template>
  297. </el-table-column>
  298. </el-table>
  299. </div>
  300. </div>
  301. </el-col>
  302. <el-col :span="12">
  303. <div class="table3">
  304. <div class="contentOperation">
  305. <p>栏舍详情</p>
  306. </div>
  307. <div class="content-table">
  308. <el-table
  309. :key="table3.tableKey"
  310. v-loading="table3.listLoading"
  311. element-loading-text="给我一点时间"
  312. :data="table3.list"
  313. height="450"
  314. fit
  315. border
  316. highlight-current-row
  317. style="width: 100%;"
  318. :row-style="rowStyle"
  319. :cell-style="cellStyle"
  320. class="elTable table-fixed"
  321. >
  322. <el-table-column label="操作序号" min-width="130px" align="center">
  323. <template slot-scope="scope">
  324. <span>{{ scope.row.sort }}</span>
  325. </template>
  326. </el-table-column>
  327. <el-table-column label="转投栏舍" min-width="130px" align="center">
  328. <template slot-scope="scope">
  329. <span>{{ scope.row.fname }}</span>
  330. </template>
  331. </el-table-column>
  332. </el-table>
  333. </div>
  334. </div>
  335. </el-col>
  336. </el-row>
  337. </div>
  338. <!-- 撒料计划-混料 -->
  339. <div v-if="table3.getdataListParm.parammaps.lpplantype == 1 || table3.getdataListParm.parammaps.lpplantype == 5" class="content">
  340. <el-row :gutter="20">
  341. <el-col :span="12">
  342. <div class="table2">
  343. <div class="contentOperation">
  344. <p>计划详情</p>
  345. </div>
  346. <div class="content-table">
  347. <el-table
  348. :key="table2.tableKey"
  349. v-loading="table2.listLoading"
  350. element-loading-text="给我一点时间"
  351. :data="table2.list"
  352. fit
  353. border
  354. highlight-current-row
  355. style="width: 100%;"
  356. height="450"
  357. :row-style="rowStyle"
  358. :cell-style="cellStyle"
  359. class="elTable table-fixed"
  360. >
  361. <el-table-column label="操作序号" min-width="130px" align="center">
  362. <template slot-scope="scope">
  363. <span>{{ scope.row.sort }}</span>
  364. </template>
  365. </el-table-column>
  366. <el-table-column label="饲料名称" prop="fname" min-width="130px" align="center">
  367. <template slot-scope="scope">
  368. <span>{{ scope.row.fname }}</span>
  369. </template>
  370. </el-table-column>
  371. <el-table-column label="设计重量(KG)" prop="weight" min-width="130px" align="center">
  372. <template slot-scope="scope">
  373. <span>{{ scope.row.weight }}</span>
  374. </template>
  375. </el-table-column>
  376. </el-table>
  377. </div>
  378. </div>
  379. </el-col>
  380. <el-col :span="12">
  381. <div class="table3">
  382. <div class="contentOperation">
  383. <p>栏舍详情</p>
  384. </div>
  385. <div class="content-table">
  386. <el-table
  387. :key="table3.tableKey"
  388. v-loading="table3.listLoading"
  389. element-loading-text="给我一点时间"
  390. :data="table3.list"
  391. height="450"
  392. fit
  393. border
  394. highlight-current-row
  395. style="width: 100%;"
  396. :row-style="rowStyle"
  397. :cell-style="cellStyle"
  398. class="elTable table-fixed"
  399. >
  400. <el-table-column label=" 操作序号" min-width="130px" align="center">
  401. <template slot-scope="scope">
  402. <span>{{ scope.row.sort }}</span>
  403. </template>
  404. </el-table-column>
  405. <el-table-column label="撒料车辆" min-width="130px" align="center">
  406. <template slot-scope="scope">
  407. <span>{{ scope.row.fname }}</span>
  408. </template>
  409. </el-table-column>
  410. <el-table-column label="设计重量(KG)" min-width="130px" align="center">
  411. <template slot-scope="scope">
  412. <span>{{ scope.row.weight }}</span>
  413. </template>
  414. </el-table-column>
  415. </el-table>
  416. </div>
  417. </div>
  418. </el-col>
  419. </el-row>
  420. </div>
  421. <!-- 撒料计划-撒料 -->
  422. <div v-if="table3.getdataListParm.parammaps.lpplantype == 2" class="content">
  423. <el-row :gutter="20">
  424. <el-col :span="12">
  425. <div class="table3">
  426. <div class="contentOperation">
  427. <p>栏舍详情</p>
  428. </div>
  429. <div class="content-table">
  430. <el-table
  431. :key="table3.tableKey"
  432. v-loading="table3.listLoading"
  433. element-loading-text="给我一点时间"
  434. :data="table3.list"
  435. height="450"
  436. fit
  437. border
  438. highlight-current-row
  439. style="width: 100%;"
  440. :row-style="rowStyle"
  441. :cell-style="cellStyle"
  442. class="elTable table-fixed"
  443. >
  444. <el-table-column label=" 操作序号" min-width="130px" align="center">
  445. <template slot-scope="scope">
  446. <span>{{ scope.row.sort }}</span>
  447. </template>
  448. </el-table-column>
  449. <el-table-column label="撒料车辆" min-width="130px" align="center">
  450. <template slot-scope="scope">
  451. <span>{{ scope.row.fname }}</span>
  452. </template>
  453. </el-table-column>
  454. <el-table-column label="设计重量(KG)" min-width="130px" align="center">
  455. <template slot-scope="scope">
  456. <span>{{ scope.row.weight }}</span>
  457. </template>
  458. </el-table-column>
  459. </el-table>
  460. </div>
  461. </div>
  462. </el-col>
  463. <el-col :span="12">
  464. <div class="table2">
  465. <div class="contentOperation">
  466. <p>计划详情</p>
  467. </div>
  468. <div class="content-table">
  469. <el-table
  470. :key="table2.tableKey"
  471. v-loading="table2.listLoading"
  472. element-loading-text="给我一点时间"
  473. :data="table2.list"
  474. fit
  475. border
  476. highlight-current-row
  477. style="width: 100%;"
  478. height="450"
  479. :row-style="rowStyle"
  480. :cell-style="cellStyle"
  481. class="elTable table-fixed"
  482. >
  483. <el-table-column label="操作序号" min-width="130px" align="center">
  484. <template slot-scope="scope">
  485. <span>{{ scope.row.sort }}</span>
  486. </template>
  487. </el-table-column>
  488. <el-table-column label="栏舍名称" prop="fname" min-width="130px" align="center">
  489. <template slot-scope="scope">
  490. <span>{{ scope.row.fname }}</span>
  491. </template>
  492. </el-table-column>
  493. <el-table-column label="设计重量(KG)" prop="weight" min-width="130px" align="center">
  494. <template slot-scope="scope">
  495. <span>{{ scope.row.weight }}</span>
  496. </template>
  497. </el-table-column>
  498. </el-table>
  499. </div>
  500. </div>
  501. </el-col>
  502. </el-row>
  503. </div>
  504. <!-- 新生成 -->
  505. <el-dialog :title="textMap[newGeneration.dialogStatus]" :destroy-on-close="true" :visible.sync="newGeneration.dialogFormVisible" :close-on-click-modal="false" width="30%">
  506. <div class="newGeneration" v-loading="newGenerationLoading" >
  507. <el-form ref="temp" :rules="newGeneration.rules" :model="newGeneration.temp" label-position="right" label-width="100px" style="width: 100%;margin:0 auto 50px">
  508. <el-row v-if="newGeneration.dialogStatus== 'newGeneration'">
  509. <el-col :span="24">
  510. <el-form-item label="时间范围:" prop="inputDatetime">
  511. <el-date-picker v-model="newGeneration.temp.inputDatetime" class="inputDatetime filter-item" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" style="width: 100%;" :clearable="false" :picker-options="pickerOptions2" />
  512. </el-form-item>
  513. </el-col>
  514. </el-row>
  515. <el-row v-else>
  516. <el-col :span="24">
  517. <el-form-item label="时间范围:" prop="copyInputDatetime">
  518. <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" />
  519. </el-form-item>
  520. </el-col>
  521. </el-row>
  522. </el-form>
  523. <div slot="footer" class="dialog-footer" style="bottom:20px">
  524. <el-button class="cancelClose" @click="newGeneration.dialogFormVisible = false;getList()">取消</el-button>
  525. <el-button v-if="newGeneration.dialogStatus== 'newGeneration'" class="save" :disabled="isokDisable" @click="newGenerationData()">确认</el-button>
  526. <el-button v-else class="save" :disabled="isokDisable" @click="copyData()">确认</el-button>
  527. </div>
  528. </div>
  529. </el-dialog>
  530. <!-- 历史记录 -->
  531. <el-dialog :fullscreen="dialogFull" :destroy-on-close="true" :visible.sync="historyRecord.dialogFormVisible" :close-on-click-modal="false" width="90%">
  532. <template slot="title">
  533. <div class="avue-crud__dialog__header">
  534. <span class="el-dialog__title">
  535. <span style="display:inline-block;width:3px;height:20px;margin-right:5px; float: left;margin-top:2px" />
  536. {{ textMap[historyRecord.dialogStatus] }}
  537. </span>
  538. <div class="avue-crud__dialog__menu" @click="dialogFull? dialogFull=false: dialogFull=true">
  539. <svg-icon v-if="dialogFull" icon-class="exit-fullscreen" />
  540. <svg-icon v-else icon-class="fullscreen" />
  541. </div>
  542. </div>
  543. </template>
  544. <div class="historyRecord">
  545. <keep-alive>
  546. <component :is="historyRecord.myComponent" ref="historyRecord" />
  547. </keep-alive>
  548. </div>
  549. <div slot="footer" class="dialog-footer">
  550. <el-button class="cancelClose cancelClose1" @click="historyRecord.dialogFormVisible = false; ">关闭</el-button>
  551. </div>
  552. </el-dialog>
  553. <!-- 正在同步中 -->
  554. <el-dialog :destroy-on-close="true" :visible.sync="dataSynchronization.dialogFormVisible" :close-on-click-modal="false" width="30%">
  555. <div class="dataSynchronization" style="text-align: center;font-size: 18px;">
  556. <i class="el-icon-loading" />
  557. <span>正在同步</span>
  558. <div slot="footer" class="dialog-footer" style="bottom:10px">
  559. <el-button class="miniPrimary" @click="dataSynchronization.dialogFormVisible = false;">确认</el-button>
  560. </div>
  561. </div>
  562. </el-dialog>
  563. <!-- 修改计划 -->
  564. <RevisePlan :show.sync="isShowDialog" :parent-active-name="activeName" :parent-date="parentDate" />
  565. </div>
  566. </template>
  567. <script>
  568. import { GetDataByName, GetDataByNames, ExecDataByConfig, PostDataByName, getDorm, GetReportform, checkButtons } from '@/api/common'
  569. import RevisePlan from './revisePlan.vue'
  570. import { parseTime, json2excel } from '@/utils/index.js'
  571. import Cookies from 'js-cookie'
  572. import Sortable from 'sortablejs'
  573. import { MessageBox } from 'element-ui'
  574. export default {
  575. name: 'DailyExecutionPlan',
  576. components: {
  577. RevisePlan
  578. },
  579. data() {
  580. return {
  581. newGenerationLoading:false,
  582. dialogFull: false,
  583. isRoleEdit: [],
  584. dataDisabled: false,
  585. requestParams: [
  586. // { name: 'getDictByName', offset: 0, pagecount: 0, params: ['牲畜父类'] }
  587. ],
  588. planTypeList: [{ lable: '预混计划', value: '4' }, { lable: '撒料计划', value: '0' }, { lable: '剩料计划', value: '3' }, { lable: '撒料计划-混料', value: '1' }, { lable: '撒料计划-撒料', value: '2' }, { lable: '预称重计划', value: '5' }], // 计划类型
  589. printingTypeList: [{ lable: '精料', value: '1' }, { lable: '铲车', value: '2' }], // 打印类型
  590. frequencyList: [], // 班次
  591. planningDimensionList: [{ lable: '发料顺序', value: '0' }, { lable: 'TMR', value: '1' }], // 发料顺序
  592. exportTypeList: [{ lable: '投料简打', value: '0' }, { lable: '累加投料', value: '1' }, { lable: '撒料简打', value: '2' }, { lable: '投撒料简打', value: '3' }, { lable: '投撒料累加', value: '4' }, { lable: '包装简打', value: '5' }, { lable: '实发简打', value: '6' }], // 导出类型
  593. // 班次
  594. maxTime: {
  595. getMaxTimesParm: {
  596. name: 'getSysoptEnable',
  597. page: 1,
  598. offset: 1,
  599. pagecount: 1,
  600. returntype: 'Map',
  601. parammaps: {
  602. pastureid: Cookies.get('pastureid'),
  603. inforname: 'times'
  604. }
  605. }
  606. },
  607. isOrder: true,
  608. table: {
  609. getdataListParm: {
  610. name: 'getDownloadedplanList',
  611. page: 1,
  612. offset: 1,
  613. pagecount: '',
  614. returntype: 'Map',
  615. parammaps: {
  616. pastureid: Cookies.get('pastureid'),
  617. barid: '',
  618. mydate: parseTime(new Date(), '{y}-{m}-{d}'),
  619. times: '',
  620. lpplantype: '',
  621. printType: '',
  622. plandimen: '0',
  623. enable3: '0'
  624. }
  625. },
  626. tableKey: 0,
  627. list: [],
  628. total: 0,
  629. listLoading: false
  630. },
  631. // 计划内容操作详情
  632. table2: {
  633. getdataListParm: {
  634. name: 'getDownloadplandtl1ListV2',
  635. page: 1,
  636. offset: 1,
  637. returntype: 'Map',
  638. parammaps: {
  639. pastureid: Cookies.get('pastureid'),
  640. date: '',
  641. id: ''
  642. }
  643. },
  644. tableKey: 0,
  645. list: [],
  646. total: 0,
  647. listLoading: false
  648. },
  649. // 计划内容 舍栏详情
  650. table3: {
  651. getdataListParm: {
  652. name: 'getDownloadplandt2ListV2',
  653. page: 1,
  654. offset: 1,
  655. returntype: 'Map',
  656. parammaps: {
  657. pastureid: Cookies.get('pastureid'),
  658. date: '',
  659. id: ''
  660. }
  661. },
  662. tableKey: 0,
  663. list: [],
  664. total: 0,
  665. listLoading: false
  666. },
  667. // 新生成
  668. newGeneration: {
  669. dialogFormVisible: false,
  670. dialogStatus: '',
  671. getdataListParm: {
  672. name: 'checkLLPIsDistribution',
  673. page: 1,
  674. offset: 1,
  675. pagecount: 1,
  676. returntype: 'Map',
  677. parammaps: {
  678. pastureid: Cookies.get('pastureid')
  679. }
  680. },
  681. temp: {
  682. inputDatetime: [parseTime(new Date(), '{y}-{m}-{d}'), parseTime(new Date(), '{y}-{m}-{d}')]
  683. },
  684. rules: {
  685. inputDatetime: [{ type: 'array', required: true, message: '必填', trigger: 'blur' }],
  686. copyInputDatetime: [{ type: 'array', required: true, message: '必填', trigger: 'blur' }]
  687. }
  688. },
  689. pickerMinDate: '',
  690. pickerOptions: {
  691. onPick: ({ maxDate, minDate }) => {
  692. this.pickerMinDate = minDate.getTime()
  693. if (maxDate) {
  694. this.pickerMinDate = ''
  695. }
  696. },
  697. disabledDate: (time) => {
  698. if (this.pickerMinDate !== '') {
  699. const one = 31 * 24 * 3600 * 1000
  700. const minTime = this.pickerMinDate
  701. const maxTime = this.pickerMinDate + one
  702. return time.getTime() < minTime || time.getTime() > maxTime - 8.64e7
  703. }
  704. return time.getTime() < Date.now() - 8.64e7
  705. }
  706. },
  707. pickerOptions2: {
  708. onPick: ({ maxDate, minDate }) => {
  709. this.pickerMinDate = minDate.getTime()
  710. if (maxDate) {
  711. this.pickerMinDate = ''
  712. }
  713. },
  714. disabledDate: (time) => {
  715. if (this.pickerMinDate !== '') {
  716. const one = 14 * 24 * 3600 * 1000
  717. const minTime = this.pickerMinDate
  718. const maxTime = this.pickerMinDate + one
  719. return time.getTime() < minTime || time.getTime() > maxTime - 8.64e7
  720. }
  721. return time.getTime() < Date.now() - 8.64e7
  722. }
  723. },
  724. historyRecord: {
  725. dialogFormVisible: false,
  726. dialogStatus: '',
  727. myComponent: null
  728. },
  729. dataSynchronization: {
  730. dialogFormVisible: false,
  731. dialogStatus: '',
  732. getdataListParm: {
  733. name: 'getSysoptEnable',
  734. page: 1,
  735. offset: 1,
  736. pagecount: 1,
  737. returntype: 'Map',
  738. parammaps: {
  739. pastureid: Cookies.get('pastureid'),
  740. inforname: 'isDataSync'
  741. }
  742. },
  743. isDataSynchronization: false
  744. },
  745. textMap: {
  746. newGeneration: '新生成',
  747. historyRecord: '历史记录',
  748. revisePlan: '修改计划',
  749. copy: '复制计划'
  750. },
  751. isokDisable: false,
  752. requestParam: {},
  753. rowStyle: { maxHeight: 30 + 'px', height: 30 + 'px' },
  754. cellStyle: { padding: 0 + 'px' },
  755. isShowDialog: false,
  756. activeName: '栏舍配方',
  757. parentDate: '',
  758. downLoad: {
  759. getdataListParm: {
  760. name: '',
  761. page: 1,
  762. offset: 1,
  763. pagecount: '',
  764. returntype: 'Map',
  765. parammaps: {
  766. pastureid: Cookies.get('pastureid'),
  767. date: ''
  768. }
  769. },
  770. list: [],
  771. labelList: []
  772. }
  773. }
  774. },
  775. created() {
  776. this.parentDate = this.table.getdataListParm.parammaps.mydate
  777. console.log(this.parentDate, 'this.parentDate')
  778. this.getDataSynchronization()
  779. this.getButtons()
  780. this.getList()
  781. this.getDownList()
  782. this.getIsDisplay()
  783. },
  784. mounted() {
  785. this.table.getdataListParm.parammaps.mydate = parseTime(new Date(), '{y}-{m}-{d}')
  786. },
  787. methods: {
  788. getButtons() {
  789. const Edit = 'DailyExecutionPlan'
  790. const isRoleEdit = checkButtons(JSON.parse(sessionStorage.getItem('buttons')), Edit)
  791. this.isRoleEdit = isRoleEdit
  792. },
  793. getDataSynchronization() {
  794. GetDataByName(this.dataSynchronization.getdataListParm).then(response => {
  795. // console.log(response.data.list[0])
  796. if (response.data.list[0].inforvalue == 0) {
  797. this.dataSynchronization.isDataSynchronization = false
  798. } else {
  799. this.dataSynchronization.isDataSynchronization = true
  800. }
  801. })
  802. },
  803. getIsDisplay() {
  804. GetDataByName(this.maxTime.getMaxTimesParm).then(response => {
  805. console.log(response.data.list[0].inforvalue)
  806. if (response.data.list[0].inforvalue == 1) {
  807. this.frequencyList = [{ id: '1', name: '第一班' }]
  808. } else if (response.data.list[0].inforvalue == 2) {
  809. this.frequencyList = [{ id: '1', name: '第一班' }, { id: '2', name: '第二班' }]
  810. } else if (response.data.list[0].inforvalue == 3) {
  811. this.frequencyList = [{ id: '1', name: '第一班' }, { id: '2', name: '第二班' }, { id: '3', name: '第三班' }]
  812. } else if (response.data.list[0].inforvalue == 4) {
  813. this.frequencyList = [{ id: '1', name: '第一班' }, { id: '2', name: '第二班' }, { id: '3', name: '第三班' }, { id: '4', name: '第四班' }]
  814. }
  815. })
  816. },
  817. getDownList() {
  818. GetDataByNames(this.requestParams).then(response => {
  819. // this.livestockTypeList = response.data.getDictByName.list
  820. })
  821. },
  822. // -------------------日执行计划-----------------------------
  823. handleBefore() {
  824. if (this.table.getdataListParm.parammaps.mydate !== '' && this.table.getdataListParm.parammaps.mydate !== null) {
  825. this.table.getdataListParm.parammaps.mydate = new Date(this.table.getdataListParm.parammaps.mydate)
  826. var start = new Date(this.table.getdataListParm.parammaps.mydate.setDate(this.table.getdataListParm.parammaps.mydate.getDate() - 1))
  827. // var start = this.table.getdataListParm.parammaps.mydate - 1
  828. this.table.getdataListParm.parammaps.mydate = parseTime(start, '{y}-{m}-{d}')
  829. // this.$forceUpdate()
  830. this.parentDate = this.table.getdataListParm.parammaps.mydate
  831. this.getList()
  832. }
  833. var d = this.table.getdataListParm.parammaps.mydate
  834. var curDate = parseTime(new Date(), '{y}-{m}-{d}')
  835. if (d < curDate) {
  836. this.dataDisabled = true
  837. } else {
  838. this.dataDisabled = false
  839. }
  840. console.log(this.dataDisabled)
  841. },
  842. handleNext() {
  843. if (this.table.getdataListParm.parammaps.mydate !== '' && this.table.getdataListParm.parammaps.mydate !== null) {
  844. this.table.getdataListParm.parammaps.mydate = new Date(this.table.getdataListParm.parammaps.mydate)
  845. var stop = new Date(this.table.getdataListParm.parammaps.mydate.setDate(this.table.getdataListParm.parammaps.mydate.getDate() + 1))
  846. this.table.getdataListParm.parammaps.mydate = parseTime(stop, '{y}-{m}-{d}')
  847. this.parentDate = this.table.getdataListParm.parammaps.mydate
  848. this.getList()
  849. }
  850. var d = this.table.getdataListParm.parammaps.mydate
  851. var curDate = parseTime(new Date(), '{y}-{m}-{d}')
  852. if (d < curDate) {
  853. this.dataDisabled = true
  854. } else {
  855. this.dataDisabled = false
  856. }
  857. console.log(this.dataDisabled)
  858. },
  859. getList() {
  860. this.table.listLoading = true
  861. GetDataByName(this.table.getdataListParm).then(response => {
  862. console.log('table数据', response.data.list)
  863. if (response.data.list !== null) {
  864. // var obj = { 'id': '580999', 'havebutton': '0', 'lpplantype': 2, 'pid': '3283220207862547456', 'times': '第二班', 'projname': '2.666' }
  865. // response.data.list[6] = obj
  866. this.getIsColor(response.data.list)
  867. this.table.list = response.data.list
  868. this.table.pageNum = response.data.pageNum
  869. this.table.pageSize = response.data.pageSize
  870. this.table.total = response.data.total
  871. console.log('计划类型', response.data.list[0].lpplantype)
  872. if (response.data.list[0].lpplantype == 0) {
  873. // 撒料
  874. this.table2.getdataListParm.name = 'getDownloadplandtl1ListV2'
  875. this.table3.getdataListParm.name = 'getDownloadplandt2ListV2'
  876. this.table2.getdataListParm.parammaps.useinbartype = ''
  877. this.table3.getdataListParm.parammaps.useinbartype = ''
  878. this.table2.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
  879. this.table3.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
  880. this.table2.getdataListParm.parammaps.id = response.data.list[0].id
  881. this.table3.getdataListParm.parammaps.id = response.data.list[0].id
  882. this.table3.getdataListParm.parammaps.lpplantype = response.data.list[0].lpplantype
  883. this.getList2()
  884. this.getList3()
  885. } else if (response.data.list[0].lpplantype == 1) {
  886. // 撒料计划-混料
  887. this.table2.getdataListParm.name = 'getDownloadplandtl1ListV2'
  888. this.table3.getdataListParm.name = 'getDownloadplandt2ListV2'
  889. this.table2.getdataListParm.parammaps.useinbartype = ''
  890. this.table3.getdataListParm.parammaps.useinbartype = ''
  891. this.table2.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
  892. this.table3.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
  893. this.table2.getdataListParm.parammaps.id = response.data.list[0].id
  894. this.table3.getdataListParm.parammaps.id = response.data.list[0].id
  895. this.table3.getdataListParm.parammaps.lpplantype = response.data.list[0].lpplantype
  896. this.getList2()
  897. this.getList3()
  898. } else if (response.data.list[0].lpplantype == 2) {
  899. // 撒料计划-撒料
  900. this.table2.getdataListParm.name = 'getDownloadplandt2ListV2'
  901. this.table3.getdataListParm.name = 'getDownloadplandtl1ListV2'
  902. this.table2.getdataListParm.parammaps.useinbartype = ''
  903. this.table3.getdataListParm.parammaps.useinbartype = ''
  904. this.table2.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
  905. this.table3.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
  906. this.table2.getdataListParm.parammaps.id = response.data.list[0].id
  907. this.table3.getdataListParm.parammaps.id = response.data.list[0].id
  908. this.table3.getdataListParm.parammaps.lpplantype = response.data.list[0].lpplantype
  909. this.getList2()
  910. this.getList3()
  911. } else if (response.data.list[0].lpplantype == 3) {
  912. // 剩料
  913. this.table2.getdataListParm.name = 'getDownloadplandt2ListV2'
  914. this.table3.getdataListParm.name = 'getDownloadplandt2ListV2'
  915. this.table2.getdataListParm.parammaps.useinbartype = 0
  916. this.table3.getdataListParm.parammaps.useinbartype = 1
  917. this.table2.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
  918. this.table3.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
  919. this.table2.getdataListParm.parammaps.id = response.data.list[0].id
  920. this.table3.getdataListParm.parammaps.id = response.data.list[0].id
  921. this.table3.getdataListParm.parammaps.lpplantype = response.data.list[0].lpplantype
  922. this.getList2()
  923. this.getList3()
  924. } else if (response.data.list[0].lpplantype == 4) {
  925. // 预混
  926. this.table2.getdataListParm.name = 'getDownloadplandtl1ListV2'
  927. this.table2.getdataListParm.parammaps.useinbartype = ''
  928. this.table3.getdataListParm.parammaps.useinbartype = ''
  929. this.table2.getdataListParm.parammaps.id = response.data.list[0].id
  930. this.table3.getdataListParm.parammaps.lpplantype = response.data.list[0].lpplantype
  931. this.getList2()
  932. } else if (response.data.list[0].lpplantype == 5) {
  933. // 预称重计划
  934. this.table2.getdataListParm.name = 'getDownloadplandtl1ListV2'
  935. this.table3.getdataListParm.name = 'getDownloadplandt2ListV2'
  936. this.table2.getdataListParm.parammaps.useinbartype = ''
  937. this.table3.getdataListParm.parammaps.useinbartype = ''
  938. this.table2.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
  939. this.table3.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
  940. this.table2.getdataListParm.parammaps.id = response.data.list[0].id
  941. this.table3.getdataListParm.parammaps.id = response.data.list[0].id
  942. this.table3.getdataListParm.parammaps.lpplantype = response.data.list[0].lpplantype
  943. this.getList2()
  944. this.getList3()
  945. }
  946. } else {
  947. this.table.list = []
  948. this.table3.getdataListParm.parammaps.lpplantype = ''
  949. this.table2.getdataListParm.parammaps.id = ''
  950. this.table3.getdataListParm.parammaps.id = ''
  951. // this.getList2()
  952. // this.getList3()
  953. this.table2.list = []
  954. this.table3.list = []
  955. }
  956. setTimeout(() => {
  957. this.table.listLoading = false
  958. }, 100)
  959. })
  960. },
  961. handleEnableChange(row) {
  962. this.requestParam.name = 'updatedownloadenable'
  963. this.requestParam.parammaps = {}
  964. this.requestParam.parammaps.pastureid = row.pastureid
  965. this.requestParam.parammaps.id = row.id
  966. this.requestParam.parammaps.enable = row.enable
  967. PostDataByName(this.requestParam).then(response => {
  968. if (response.msg === 'fail') {
  969. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  970. } else {
  971. this.$notify({ title: '', message: '保存成功', type: 'success', duration: 2000 })
  972. this.getList()
  973. }
  974. })
  975. },
  976. getIsColor(arr) {
  977. var map = {}
  978. var dest = []
  979. for (var i = 0; i < arr.length; i++) {
  980. var ai = arr[i]
  981. if (!map[ai.pid]) {
  982. dest.push({
  983. pid: ai.pid,
  984. data: [ai]
  985. })
  986. map[ai.pid] = ai
  987. } else {
  988. for (var j = 0; j < dest.length; j++) {
  989. var dj = dest[j]
  990. if (dj.pid == ai.pid) {
  991. dj.data.push(ai)
  992. break
  993. }
  994. }
  995. }
  996. }
  997. console.log(dest)
  998. var newArr1 = []
  999. for (var i = 0; i < dest.length; i++) {
  1000. var newArr = dest[i].data
  1001. for (var j = 0; j < dest[i].data.length; j++) {
  1002. dest[i].data[j].isColor = i
  1003. newArr1.push(dest[i].data[j])
  1004. }
  1005. }
  1006. console.log(newArr1)
  1007. this.table.list = newArr1
  1008. },
  1009. tableRowClassName({ row }) {
  1010. if (row.isColor % 2 == 0) {
  1011. return 'warning-row'
  1012. } else {
  1013. return 'success-row'
  1014. }
  1015. },
  1016. lpplantype: function(cellValue) {
  1017. if (cellValue.lpplantype == 0) {
  1018. return '撒料计划'
  1019. } else if (cellValue.lpplantype == 1) {
  1020. return '撒料计划-混料'
  1021. } else if (cellValue.lpplantype == 2) {
  1022. return '撒料计划-撒料'
  1023. } else if (cellValue.lpplantype == 3) {
  1024. return '剩料计划'
  1025. } else if (cellValue.lpplantype == 4) {
  1026. return '预混计划'
  1027. } else if (cellValue.lpplantype == 5) {
  1028. return '预称重计划'
  1029. }
  1030. },
  1031. changeDate(val) {
  1032. console.log('选择了日期', val)
  1033. this.getList()
  1034. // this.getList2()
  1035. // this.getList3()
  1036. var d = this.table.getdataListParm.parammaps.mydate
  1037. var curDate = parseTime(new Date(), '{y}-{m}-{d}')
  1038. if (d < curDate) {
  1039. this.dataDisabled = true
  1040. } else {
  1041. this.dataDisabled = false
  1042. }
  1043. console.log(this.dataDisabled)
  1044. this.parentDate = this.table.getdataListParm.parammaps.mydate
  1045. console.log(this.parentDate, 'this.parentDate')
  1046. },
  1047. changePlanType(val) {
  1048. console.log('选择了计划类型', val)
  1049. this.getList()
  1050. this.getList2()
  1051. this.getList3()
  1052. },
  1053. changeFrequency(val) {
  1054. console.log('选择了班次', val)
  1055. this.getList()
  1056. this.getList2()
  1057. this.getList3()
  1058. },
  1059. // 日执行计划行点击
  1060. tableRowClick(row, column, event) {
  1061. console.log(row, column, event)
  1062. console.log('点击计划类型', row.lpplantype)
  1063. // 撒料计划0/撒料计划-混料1/撒料计划-撒料2/剩料计划3/预混计划4/预称重计划5
  1064. if (row.lpplantype == 0) {
  1065. // 撒料
  1066. this.table2.getdataListParm.name = 'getDownloadplandtl1ListV2'
  1067. this.table3.getdataListParm.name = 'getDownloadplandt2ListV2'
  1068. this.table2.getdataListParm.parammaps.useinbartype = ''
  1069. this.table3.getdataListParm.parammaps.useinbartype = ''
  1070. this.table2.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
  1071. this.table3.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
  1072. this.table2.getdataListParm.parammaps.id = row.id
  1073. this.table3.getdataListParm.parammaps.id = row.id
  1074. this.table3.getdataListParm.parammaps.lpplantype = row.lpplantype
  1075. this.getList2()
  1076. this.getList3()
  1077. } else if (row.lpplantype == 1) {
  1078. // 撒料计划-混料
  1079. this.table2.getdataListParm.name = 'getDownloadplandtl1ListV2'
  1080. this.table3.getdataListParm.name = 'getDownloadplandt2ListV2'
  1081. this.table2.getdataListParm.parammaps.useinbartype = ''
  1082. this.table3.getdataListParm.parammaps.useinbartype = ''
  1083. this.table2.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
  1084. this.table3.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
  1085. this.table2.getdataListParm.parammaps.id = row.id
  1086. this.table3.getdataListParm.parammaps.id = row.id
  1087. this.table3.getdataListParm.parammaps.lpplantype = row.lpplantype
  1088. this.getList2()
  1089. this.getList3()
  1090. } else if (row.lpplantype == 2) {
  1091. // 撒料计划-撒料
  1092. this.table2.getdataListParm.name = 'getDownloadplandt2ListV2'
  1093. this.table3.getdataListParm.name = 'getDownloadplandtl1ListV2'
  1094. this.table2.getdataListParm.parammaps.useinbartype = ''
  1095. this.table3.getdataListParm.parammaps.useinbartype = ''
  1096. this.table2.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
  1097. this.table3.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
  1098. this.table2.getdataListParm.parammaps.id = row.id
  1099. this.table3.getdataListParm.parammaps.id = row.id
  1100. this.table3.getdataListParm.parammaps.lpplantype = row.lpplantype
  1101. this.getList2()
  1102. this.getList3()
  1103. console.log(this.table3.getdataListParm.parammaps.lpplantype)
  1104. } else if (row.lpplantype == 3) {
  1105. // 剩料
  1106. this.table2.getdataListParm.name = 'getDownloadplandt2ListV2'
  1107. this.table3.getdataListParm.name = 'getDownloadplandt2ListV2'
  1108. this.table2.getdataListParm.parammaps.useinbartype = 0
  1109. this.table3.getdataListParm.parammaps.useinbartype = 1
  1110. this.table2.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
  1111. this.table3.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
  1112. this.table2.getdataListParm.parammaps.id = row.id
  1113. this.table3.getdataListParm.parammaps.id = row.id
  1114. this.table3.getdataListParm.parammaps.lpplantype = row.lpplantype
  1115. this.getList2()
  1116. this.getList3()
  1117. } else if (row.lpplantype == 4) {
  1118. // 预混
  1119. this.table2.getdataListParm.name = 'getDownloadplandtl1ListV2'
  1120. this.table3.getdataListParm.name = 'getDownloadplandt2ListV2'
  1121. this.table2.getdataListParm.parammaps.useinbartype = ''
  1122. this.table3.getdataListParm.parammaps.useinbartype = ''
  1123. this.table2.getdataListParm.parammaps.id = row.id
  1124. this.table3.getdataListParm.parammaps.lpplantype = row.lpplantype
  1125. this.getList2()
  1126. } else if (row.lpplantype == 5) {
  1127. // 预称重计划
  1128. this.table2.getdataListParm.name = 'getDownloadplandtl1ListV2'
  1129. this.table3.getdataListParm.name = 'getDownloadplandt2ListV2'
  1130. this.table2.getdataListParm.parammaps.useinbartype = ''
  1131. this.table3.getdataListParm.parammaps.useinbartype = ''
  1132. this.table2.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
  1133. this.table3.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
  1134. this.table2.getdataListParm.parammaps.id = row.id
  1135. this.table3.getdataListParm.parammaps.id = row.id
  1136. this.table3.getdataListParm.parammaps.lpplantype = row.lpplantype
  1137. this.getList2()
  1138. this.getList3()
  1139. }
  1140. this.$forceUpdate()
  1141. },
  1142. // 计划内容操作详情
  1143. getList2() {
  1144. this.table2.listLoading = true
  1145. this.table2.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
  1146. GetDataByName(this.table2.getdataListParm).then(response => {
  1147. console.log('table数据', response.data.list)
  1148. if (response.data.list !== null) {
  1149. this.table2.list = response.data.list
  1150. // 撒料计划0/撒料计划-混料1/撒料计划-撒料2/剩料计划3/预混计划4
  1151. if (this.table3.getdataListParm.parammaps.lpplantype == 0 || this.table3.getdataListParm.parammaps.lpplantype == 1 || this.table3.getdataListParm.parammaps.lpplantype == 4) {
  1152. const arr = []
  1153. var a = 0
  1154. let b = this.table2.list[0].sort
  1155. let c = 0
  1156. for (let i = 0; i < this.table2.list.length; i++) {
  1157. if (b !== parseInt(this.table2.list[i].sort)) {
  1158. b = this.table2.list[i].sort
  1159. arr.push({ 'sort': '小计', 'weight': a.toFixed(parseInt(Cookies.get('decimal'))) })
  1160. a = 0
  1161. }
  1162. a = a + parseFloat(this.table2.list[i].weight)
  1163. c = c + parseFloat(this.table2.list[i].weight)
  1164. arr.push(this.table2.list[i])
  1165. }
  1166. arr.push({ 'sort': '小计', 'weight': a.toFixed(parseInt(Cookies.get('decimal'))) })
  1167. arr.push({ 'sort': '总计', 'weight': c.toFixed(parseInt(Cookies.get('decimal'))) })
  1168. this.table2.list = arr
  1169. }
  1170. if (this.table3.getdataListParm.parammaps.lpplantype == 2) {
  1171. const arr = []
  1172. var aa = 0
  1173. let bb = this.table2.list[0].sort
  1174. let cc = 0
  1175. for (let i = 0; i < this.table2.list.length; i++) {
  1176. if (bb !== parseInt(this.table2.list[i].sort)) {
  1177. bb = this.table2.list[i].sort
  1178. aa = 0
  1179. }
  1180. aa = aa + parseFloat(this.table2.list[i].weight)
  1181. cc = cc + parseFloat(this.table2.list[i].weight)
  1182. arr.push(this.table2.list[i])
  1183. }
  1184. arr.push({ 'sort': '总计', 'weight': cc.toFixed(parseInt(Cookies.get('decimal'))) })
  1185. this.table2.list = arr
  1186. console.log('this.table2.list', this.table2.list)
  1187. console.log(this.table3.getdataListParm.parammaps.lpplantype)
  1188. }
  1189. console.log(this.table2.list)
  1190. this.table2.pageNum = response.data.pageNum
  1191. this.table2.pageSize = response.data.pageSize
  1192. this.table2.total = response.data.total
  1193. } else {
  1194. this.table2.list = []
  1195. }
  1196. setTimeout(() => {
  1197. this.table2.listLoading = false
  1198. }, 100)
  1199. })
  1200. },
  1201. // 计划内容栏舍详情
  1202. getList3() {
  1203. this.table3.listLoading = true
  1204. this.table3.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
  1205. GetDataByName(this.table3.getdataListParm).then(response => {
  1206. console.log('table数据', response.data.list)
  1207. if (response.data.list !== null) {
  1208. this.table3.list = response.data.list
  1209. if (this.table3.getdataListParm.parammaps.lpplantype == 0) {
  1210. const arr = []
  1211. var a = 0
  1212. let b = this.table3.list[0].sort
  1213. let c = 0
  1214. for (let i = 0; i < this.table3.list.length; i++) {
  1215. if (b !== parseInt(this.table3.list[i].sort)) {
  1216. b = this.table3.list[i].sort
  1217. a = 0
  1218. }
  1219. a = a + parseFloat(this.table3.list[i].weight)
  1220. c = c + parseFloat(this.table3.list[i].weight)
  1221. arr.push(this.table3.list[i])
  1222. }
  1223. arr.push({ 'sort': '总计', 'weight': c.toFixed(parseInt(Cookies.get('decimal'))) })
  1224. this.table3.list = arr
  1225. }
  1226. this.table3.pageNum = response.data.pageNum
  1227. this.table3.pageSize = response.data.pageSize
  1228. this.table3.total = response.data.total
  1229. } else {
  1230. this.table3.list = []
  1231. }
  1232. setTimeout(() => {
  1233. this.table3.listLoading = false
  1234. }, 100)
  1235. })
  1236. },
  1237. // 新生成
  1238. handleCreate() {
  1239. console.log('点击了新生成')
  1240. this.newGeneration.temp.inputDatetime = [parseTime(new Date(), '{y}-{m}-{d}'), parseTime(new Date(), '{y}-{m}-{d}')]
  1241. this.newGeneration.dialogStatus = 'newGeneration'
  1242. this.newGeneration.dialogFormVisible = true
  1243. GetDataByName(this.newGeneration.getdataListParm).then(response => {
  1244. console.log('table数据', response.data.list)
  1245. if (response.data.list !== null) {
  1246. if (response.data.list[0].vmsg == '存在未分配') {
  1247. this.$message({ type: 'warning', message: '撒料计划中存在未分配完栏舍,建议及时进行分配', duration: 2000 })
  1248. }
  1249. }
  1250. })
  1251. },
  1252. DateDiff(sDate1, sDate2) {
  1253. console.log(sDate1, sDate2)
  1254. var aDate, oDate1, oDate2, iDays
  1255. aDate = sDate1.split('-')
  1256. oDate1 = new Date(aDate[0], aDate[1], aDate[2]) // 转换为12-18-2006格式
  1257. aDate = sDate2.split('-')
  1258. oDate2 = new Date(aDate[0], aDate[1], aDate[2])
  1259. iDays = parseInt(Math.abs(oDate1 - oDate2) / 1000 / 60 / 60 / 24) // 把相差的毫秒数转换为天数
  1260. this.newGeneration.temp.days = parseInt(iDays) + 1
  1261. return iDays
  1262. },
  1263. newGenerationData() {
  1264. console.log('点击了新生成保存', this.newGeneration.temp)
  1265. this.newGenerationLoading = true
  1266. this.isokDisable = true
  1267. this.$refs['temp'].validate(valid => {
  1268. if (valid) {
  1269. this.newGeneration.temp.startTime = parseTime(this.newGeneration.temp.inputDatetime[0], '{y}-{m}-{d}')
  1270. this.newGeneration.temp.stopTime = parseTime(this.newGeneration.temp.inputDatetime[1], '{y}-{m}-{d}')
  1271. this.DateDiff(this.newGeneration.temp.stopTime, this.newGeneration.temp.startTime)
  1272. this.requestParam = {}
  1273. this.requestParam.common = { 'returnmap': '0' }
  1274. this.requestParam.data = []
  1275. this.requestParam.data[0] = { 'name': 'checkDLPIsStart', 'type': 'v', 'parammaps': {
  1276. pastureid: Cookies.get('pastureid'),
  1277. startTime: this.newGeneration.temp.startTime
  1278. }}
  1279. this.requestParam.data[1] = { 'name': 'checkPreMixStorage', 'type': 'e', 'parammaps': {
  1280. pastureid: Cookies.get('pastureid'),
  1281. days: this.newGeneration.temp.days
  1282. }}
  1283. this.requestParam.data[2] = { 'name': 'createdownloadedplan', 'type': 'e', 'parammaps': {
  1284. pastureid: Cookies.get('pastureid'),
  1285. startTime: this.newGeneration.temp.startTime,
  1286. stopTime: this.newGeneration.temp.stopTime
  1287. }}
  1288. ExecDataByConfig(this.requestParam).then(response => {
  1289. console.log('新生成保存发送参数', this.requestParam)
  1290. if (response.msg === 'fail') {
  1291. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1292. this.isokDisable = false
  1293. this.newGenerationLoading = false
  1294. } else {
  1295. this.$notify({ title: '', message: '保存成功', type: 'success', duration: 2000 })
  1296. this.newGeneration.dialogFormVisible = false
  1297. this.getList()
  1298. this.isokDisable = false
  1299. this.newGenerationLoading = false
  1300. }
  1301. })
  1302. }
  1303. })
  1304. },
  1305. // 修改计划
  1306. handleRevisePlan(data) {
  1307. this.dialogFull = false
  1308. var arr = []
  1309. if (this.table.list.length > 0) {
  1310. for (let i = 0; i < this.table.list.length; i++) {
  1311. if (this.table.list[i].havebutton == 1) {
  1312. arr.push(this.table.list[i])
  1313. }
  1314. }
  1315. }
  1316. if (arr.length !== this.table.list.length) {
  1317. console.log('点击了修改计划1', this.activeName)
  1318. this.isShowDialog = true
  1319. this.activeName = '栏舍配方'
  1320. console.log('点击了修改计划2', this.activeName)
  1321. } else {
  1322. this.$message({ type: 'error', message: '当前日期不可修改计划,请重新选择日期' })
  1323. }
  1324. },
  1325. handleExport() {
  1326. this.downLoad.getdataListParm.parammaps.date = this.table.getdataListParm.parammaps.mydate
  1327. this.downLoad.getdataListParm.parammaps.lpplantype = this.table.getdataListParm.parammaps.lpplantype
  1328. this.downLoad.getdataListParm.parammaps.times = this.table.getdataListParm.parammaps.times
  1329. this.downLoad.getdataListParm.parammaps.enable = this.table.getdataListParm.parammaps.enable
  1330. this.downLoad.getdataListParm.parammaps.enable2 = this.table.getdataListParm.parammaps.enable2
  1331. var exportTitle = ''
  1332. if (this.table.getdataListParm.parammaps.plandimen == '1') {
  1333. if (this.table.getdataListParm.parammaps.enable3 == '0') {
  1334. this.downLoad.getdataListParm.name = 'downloadPlanTLJDTMR'
  1335. exportTitle = this.table.getdataListParm.parammaps.mydate + '投料简打'
  1336. } else if (this.table.getdataListParm.parammaps.enable3 == '1') {
  1337. this.downLoad.getdataListParm.name = 'downloadPlanTLLDTMR'
  1338. exportTitle = this.table.getdataListParm.parammaps.mydate + '累加投料'
  1339. } else if (this.table.getdataListParm.parammaps.enable3 == '2') {
  1340. this.downLoad.getdataListParm.name = 'downloadPlanSLJDTMR'
  1341. exportTitle = this.table.getdataListParm.parammaps.mydate + '撒料简打'
  1342. } else if (this.table.getdataListParm.parammaps.enable3 == '3') {
  1343. this.downLoad.getdataListParm.name = 'downloadPlanTSLJDTMR'
  1344. exportTitle = this.table.getdataListParm.parammaps.mydate + '投撒料简打'
  1345. } else if (this.table.getdataListParm.parammaps.enable3 == '4') {
  1346. this.downLoad.getdataListParm.name = 'downloadPlanTSLLDTMR'
  1347. exportTitle = this.table.getdataListParm.parammaps.mydate + '投撒料累加'
  1348. } else if (this.table.getdataListParm.parammaps.enable3 == '5') {
  1349. this.downLoad.getdataListParm.name = 'downloadPlanBZJDTMR'
  1350. exportTitle = this.table.getdataListParm.parammaps.mydate + '包装简打'
  1351. } else {
  1352. this.downLoad.getdataListParm.name = 'downloadPlanSFJDTMR'
  1353. exportTitle = this.table.getdataListParm.parammaps.mydate + '实发简打'
  1354. }
  1355. } else {
  1356. if (this.table.getdataListParm.parammaps.enable3 == '0') {
  1357. this.downLoad.getdataListParm.name = 'downloadPlanTLJD'
  1358. exportTitle = this.table.getdataListParm.parammaps.mydate + '投料简打'
  1359. } else if (this.table.getdataListParm.parammaps.enable3 == '1') {
  1360. this.downLoad.getdataListParm.name = 'downloadPlanTLLD'
  1361. exportTitle = this.table.getdataListParm.parammaps.mydate + '累加投料'
  1362. } else if (this.table.getdataListParm.parammaps.enable3 == '2') {
  1363. this.downLoad.getdataListParm.name = 'downloadPlanSLJD'
  1364. exportTitle = this.table.getdataListParm.parammaps.mydate + '撒料简打'
  1365. } else if (this.table.getdataListParm.parammaps.enable3 == '3') {
  1366. this.downLoad.getdataListParm.name = 'downloadPlanTSLJD'
  1367. exportTitle = this.table.getdataListParm.parammaps.mydate + '投撒料简打'
  1368. } else if (this.table.getdataListParm.parammaps.enable3 == '4') {
  1369. this.downLoad.getdataListParm.name = 'downloadPlanTSLLD'
  1370. exportTitle = this.table.getdataListParm.parammaps.mydate + '投撒料累加'
  1371. } else if (this.table.getdataListParm.parammaps.enable3 == '5') {
  1372. this.downLoad.getdataListParm.name = 'downloadPlanBZJD'
  1373. exportTitle = this.table.getdataListParm.parammaps.mydate + '包装简打'
  1374. } else {
  1375. this.downLoad.getdataListParm.name = 'downloadPlanSFJD'
  1376. exportTitle = this.table.getdataListParm.parammaps.mydate + '实发简打'
  1377. }
  1378. }
  1379. GetReportform(this.downLoad.getdataListParm).then(response => {
  1380. if (response.data.list !== null) {
  1381. this.downLoad.labelList = []
  1382. var filterValArr = []
  1383. for (let i = 0; i < response.data.list.data1.length; i++) {
  1384. this.downLoad.labelList.push(response.data.list.data1[i].label)
  1385. filterValArr.push(response.data.list.data1[i].prop)
  1386. }
  1387. this.downLoad.list = response.data.list.data2
  1388. } else {
  1389. this.downLoad.list = []
  1390. }
  1391. var multiHeaderArr = []
  1392. for (let i = 0; i < this.downLoad.labelList.length; i++) {
  1393. if (i == 0) {
  1394. multiHeaderArr.push(exportTitle)
  1395. } else {
  1396. multiHeaderArr.push('')
  1397. }
  1398. }
  1399. import('@/vendor/Export5Excel').then(excel => {
  1400. const multiHeader = [
  1401. multiHeaderArr
  1402. ]
  1403. const multiHeader2 = [
  1404. this.downLoad.labelList
  1405. ]
  1406. const filterVal = filterValArr
  1407. const data = this.downLoad.list.map((v) => filterVal.map((j) => v[j]))
  1408. const merges = []
  1409. excel.export_json_to_excel({ multiHeader, multiHeader2, data, filename: exportTitle, merges })
  1410. })
  1411. })
  1412. },
  1413. rowDrop() {
  1414. console.log(document.querySelector('#table1 .el-table__body-wrapper tbody'))
  1415. const tbody = document.querySelector('#table1 .el-table__body-wrapper tbody')
  1416. // this.sorTable()
  1417. const that = this
  1418. var sortable = Sortable.create(tbody, {
  1419. disabled: that.dropState,
  1420. onChoose({ newIndex, oldIndex }) {
  1421. console.log(that.isOrder, 'that.isOrder == false')
  1422. console.log(that.dropState, 'that.dropState')
  1423. if (that.dropState == true || that.isOrder == true) {
  1424. sortable.destroy()
  1425. }
  1426. },
  1427. onEnd(evt) {
  1428. var tableList = [...that.table.list] // 保留拖动前数据
  1429. const targetRow = that.table.list.splice(evt.oldIndex, 1)[0] // 拖动数据
  1430. const targetRow2 = that.table.list[evt.newIndex] // 拖动后下方数据
  1431. const targetRow3 = that.table.list[evt.newIndex - 1] // 拖动后上方数据
  1432. console.log(targetRow, 'targetRow')
  1433. console.log(targetRow2, 'targetRow2')
  1434. console.log(targetRow3, 'targetRow3')
  1435. that.table.list.splice(evt.newIndex, 0, targetRow)
  1436. // ==========
  1437. // 已执行的计划不可拖动
  1438. if (targetRow.havebutton == 1) {
  1439. that.$nextTick(() => {
  1440. that.$set(that.table, 'list', tableList)
  1441. })
  1442. that.$message({ type: 'error', message: '因已执行的计划不可调整顺序', duration: 2000 })
  1443. return false
  1444. }
  1445. // 相同班次之间可以拖动
  1446. if (targetRow2 !== undefined && targetRow3 !== undefined) {
  1447. if (targetRow.times !== targetRow2.times && targetRow.times !== targetRow3.times) {
  1448. that.$nextTick(() => {
  1449. that.$set(that.table, 'list', tableList)
  1450. })
  1451. that.$message({ type: 'error', message: '因班次不同不可调整顺序', duration: 2000 })
  1452. return false
  1453. }
  1454. } else if (targetRow2 !== undefined && targetRow3 == undefined) {
  1455. if (targetRow.times !== targetRow2.times) {
  1456. that.$nextTick(() => {
  1457. that.$set(that.table, 'list', tableList)
  1458. })
  1459. that.$message({ type: 'error', message: '因班次不同不可调整顺序', duration: 2000 })
  1460. return false
  1461. }
  1462. } else if (targetRow2 == undefined && targetRow3 !== undefined) {
  1463. if (targetRow.times !== targetRow3.times) {
  1464. that.$nextTick(() => {
  1465. that.$set(that.table, 'list', tableList)
  1466. })
  1467. that.$message({ type: 'error', message: '因班次不同不可调整顺序', duration: 2000 })
  1468. return false
  1469. }
  1470. }
  1471. // 撒料计划0,
  1472. // 撒料计划-混料1
  1473. // 撒料计划-撒料2
  1474. // 剩料计划3
  1475. // 预混计划4
  1476. // 预称重计划5
  1477. if (targetRow.lpplantype == 1) { // 拖动数据为撒料计划-混料
  1478. if (targetRow2 == undefined) {
  1479. that.$nextTick(() => {
  1480. that.$set(that.table, 'list', tableList)
  1481. })
  1482. } else if (targetRow2 !== undefined && targetRow2.pid == targetRow.pid) {
  1483. that.$nextTick(() => {
  1484. that.$set(that.table, 'list', tableList)
  1485. })
  1486. } else {
  1487. var pidArr = [] // pid相同的值
  1488. var pidArr1 = [] //
  1489. var index // 索引
  1490. for (let i = 0; i < tableList.length; i++) {
  1491. if (tableList[i].pid == targetRow.pid) {
  1492. pidArr.push(tableList[i])
  1493. } else {
  1494. pidArr1.push(tableList[i])
  1495. }
  1496. }
  1497. // 找到对应上方pid 的ID
  1498. // 比如说id 580243 找到对应的索引
  1499. if (targetRow3 !== undefined) {
  1500. for (let i = 0; i < pidArr1.length; i++) {
  1501. if (pidArr1[i].id == targetRow3.id) {
  1502. index = i
  1503. }
  1504. }
  1505. } else {
  1506. for (let i = 0; i < pidArr1.length; i++) {
  1507. if (pidArr1[i].id == targetRow2.id) {
  1508. index = i - 1
  1509. }
  1510. }
  1511. }
  1512. pidArr1.splice(index + 1, 0, ...pidArr)
  1513. console.log(pidArr1)
  1514. that.$nextTick(() => {
  1515. that.table.list = pidArr1
  1516. })
  1517. }
  1518. if (targetRow2 !== undefined && targetRow3 !== undefined) {
  1519. if (targetRow2.pid == targetRow3.pid) {
  1520. that.$nextTick(() => {
  1521. that.$set(that.table, 'list', tableList)
  1522. })
  1523. that.$message({ type: 'error', message: '不可将其他计划拖动至预称重计划之间', duration: 2000 })
  1524. return false
  1525. }
  1526. }
  1527. } else if (targetRow.lpplantype == 5) { // 拖动数据为预称重计划
  1528. if (targetRow2 !== undefined) {
  1529. console.log(targetRow3, targetRow2, 'zhidao')
  1530. if (targetRow3 !== undefined) {
  1531. if (targetRow3.pid !== targetRow.pid && targetRow2.pid !== targetRow.pid) {
  1532. that.$nextTick(() => {
  1533. that.$set(that.table, 'list', tableList)
  1534. })
  1535. that.$message({ type: 'error', message: '预称重计划不可拖动至其他位置', duration: 2000 })
  1536. return false
  1537. } else {
  1538. console.log('wojinlaile', targetRow2, targetRow)
  1539. if (targetRow3.lpplantype == 0 && targetRow2.pid !== targetRow.pid) {
  1540. that.$nextTick(() => {
  1541. that.$set(that.table, 'list', tableList)
  1542. })
  1543. that.$message({ type: 'error', message: '预称重计划不可拖动至撒料计划下方', duration: 2000 })
  1544. return false
  1545. }
  1546. if (targetRow2.lpplantype !== 5 && targetRow3.lpplantype !== 5) {
  1547. that.$nextTick(() => {
  1548. that.$set(that.table, 'list', tableList)
  1549. })
  1550. that.$message({ type: 'error', message: '预称重计划不可拖动至其他位置', duration: 2000 })
  1551. return false
  1552. }
  1553. }
  1554. } else {
  1555. if (targetRow2.pid !== targetRow.pid) {
  1556. that.$nextTick(() => {
  1557. that.$set(that.table, 'list', tableList)
  1558. })
  1559. that.$message({ type: 'error', message: '预称重计划不可拖动至其他位置', duration: 2000 })
  1560. return false
  1561. } else {
  1562. if (targetRow2.pid !== targetRow.pid) {
  1563. that.$nextTick(() => {
  1564. that.$set(that.table, 'list', tableList)
  1565. })
  1566. that.$message({ type: 'error', message: '预称重计划不可拖动至撒料计划下方', duration: 2000 })
  1567. return false
  1568. }
  1569. }
  1570. }
  1571. } else {
  1572. if (targetRow2 == undefined) {
  1573. that.$nextTick(() => {
  1574. that.$set(that.table, 'list', tableList)
  1575. })
  1576. that.$message({ type: 'error', message: '预称重计划不可拖动至其他位置', duration: 2000 })
  1577. return false
  1578. } else if (targetRow3.pid !== targetRow.pid) {
  1579. that.$nextTick(() => {
  1580. that.$set(that.table, 'list', tableList)
  1581. })
  1582. that.$message({ type: 'error', message: '预称重计划不可拖动至其他位置', duration: 2000 })
  1583. return false
  1584. } else {
  1585. if (targetRow3.lpplantype == 0) {
  1586. that.$nextTick(() => {
  1587. that.$set(that.table, 'list', tableList)
  1588. })
  1589. that.$message({ type: 'error', message: '预称重计划不可拖动至撒料计划下方', duration: 2000 })
  1590. return false
  1591. }
  1592. }
  1593. }
  1594. if (targetRow2 !== undefined && targetRow3 !== undefined) {
  1595. if (targetRow2.pid !== targetRow.pid && targetRow3.pid !== targetRow.pid) {
  1596. that.$nextTick(() => {
  1597. that.$set(that.table, 'list', tableList)
  1598. })
  1599. that.$message({ type: 'error', message: '不可将其他计划拖动至预称重计划之间', duration: 2000 })
  1600. return false
  1601. } else if (targetRow3.pid == targetRow.pid && (targetRow3.lpplantype == 1 || targetRow3.lpplantype == 2)) {
  1602. that.$nextTick(() => {
  1603. that.$set(that.table, 'list', tableList)
  1604. })
  1605. that.$message({ type: 'error', message: '预称重计划不可拖动至其他位置', duration: 2000 })
  1606. return false
  1607. }
  1608. }
  1609. } else if (targetRow.lpplantype == 2) { // 拖动数据为撒料计划-撒料
  1610. if (targetRow2 == undefined) {
  1611. if (targetRow3.pid !== targetRow.pid) {
  1612. that.$nextTick(() => {
  1613. that.$set(that.table, 'list', tableList)
  1614. })
  1615. that.$message({ type: 'error', message: '撒料计划-撒料不可拖动至其他位置', duration: 2000 })
  1616. return false
  1617. }
  1618. } else {
  1619. if (targetRow2.lpplantype == 1 && (targetRow2.pid == targetRow.pid || targetRow2 == undefined)) {
  1620. // 拖动数据下方为撒料计划-混料时且pid相同,不可拖动,提示
  1621. that.$nextTick(() => {
  1622. that.$set(that.table, 'list', tableList)
  1623. })
  1624. that.$message({ type: 'error', message: '撒料计划-撒料不可拖动至撒料计划-混料上方', duration: 2000 })
  1625. return false
  1626. } else if (targetRow.lpplantype == 2 && (targetRow2.pid == targetRow.pid || targetRow3.pid == targetRow.pid || targetRow2 == undefined || targetRow3 == undefined)) {
  1627. console.log('正常拖动')
  1628. } else {
  1629. that.$nextTick(() => {
  1630. that.$set(that.table, 'list', tableList)
  1631. })
  1632. that.$message({ type: 'error', message: '撒料计划-撒料不可拖动至其他位置', duration: 2000 })
  1633. return false
  1634. }
  1635. }
  1636. if (targetRow2 !== undefined && targetRow3 !== undefined) {
  1637. if (targetRow2.pid == targetRow3.pid) {
  1638. that.$nextTick(() => {
  1639. that.$set(that.table, 'list', tableList)
  1640. })
  1641. that.$message({ type: 'error', message: '不可将其他计划拖动至预称重计划之间', duration: 2000 })
  1642. return false
  1643. }
  1644. }
  1645. } else if (targetRow.lpplantype == 0) { // 拖动数据为撒料计划
  1646. console.log('遍历有相同的pid,一起跟着拖动3')
  1647. var pidArr = [] // pid相同的值
  1648. var pidArr1 = [] //
  1649. var index // 索引
  1650. for (let i = 0; i < tableList.length; i++) {
  1651. if (tableList[i].pid == targetRow.pid) {
  1652. pidArr.push(tableList[i])
  1653. } else {
  1654. pidArr1.push(tableList[i])
  1655. }
  1656. }
  1657. if (pidArr.length > 0) {
  1658. // 找到对应上方pid 的ID
  1659. // 比如说id 580243 找到对应的索引
  1660. if (targetRow3 !== undefined) {
  1661. for (let i = 0; i < pidArr1.length; i++) {
  1662. if (pidArr1[i].id == targetRow3.id) {
  1663. index = i
  1664. }
  1665. }
  1666. } else {
  1667. for (let i = 0; i < pidArr1.length; i++) {
  1668. if (pidArr1[i].id == targetRow2.id) {
  1669. index = i - 1
  1670. }
  1671. }
  1672. }
  1673. pidArr1.splice(index + 1, 0, ...pidArr)
  1674. console.log(pidArr1)
  1675. that.$nextTick(() => {
  1676. that.table.list = pidArr1
  1677. })
  1678. }
  1679. if (targetRow2 !== undefined && targetRow3 !== undefined) {
  1680. if (targetRow2.pid == targetRow3.pid) {
  1681. that.$nextTick(() => {
  1682. that.$set(that.table, 'list', tableList)
  1683. })
  1684. that.$message({ type: 'error', message: '不可拖动至其他计划中间;', duration: 2000 })
  1685. return false
  1686. }
  1687. }
  1688. } else if (targetRow.lpplantype == 3 || targetRow.lpplantype == 4) {
  1689. if (targetRow2 !== undefined && targetRow3 !== undefined) {
  1690. if (targetRow2.pid == targetRow3.pid) {
  1691. if (targetRow2.lpplantype == 5 && targetRow3.lpplantype == 5) {
  1692. that.$nextTick(() => {
  1693. that.$set(that.table, 'list', tableList)
  1694. })
  1695. that.$message({ type: 'error', message: '不可拖动至预称重计划跟预称重计划之间', duration: 2000 })
  1696. return false
  1697. } else if (targetRow.pid == targetRow2.pid && targetRow.lpplantype == 3 && targetRow2.lpplantype == 3 || targetRow.pid == targetRow3.pid && targetRow.lpplantype == 3 && targetRow3.lpplantype == 3) {
  1698. console.log('剩料之间可以互相拖动')
  1699. console.log(tableList)
  1700. } else {
  1701. that.$nextTick(() => {
  1702. that.$set(that.table, 'list', tableList)
  1703. })
  1704. // 撒料计划0,
  1705. // 撒料计划-混料1
  1706. // 撒料计划-撒料2
  1707. // 剩料计划3
  1708. // 预混计划4
  1709. // 预称重计划5
  1710. if (targetRow3.lpplantype == 0) {
  1711. that.$set(targetRow3, 'mylpplantype', '撒料计划')
  1712. } else if (targetRow3.lpplantype == 1) {
  1713. that.$set(targetRow3, 'mylpplantype', '撒料计划-混料')
  1714. } else if (targetRow3.lpplantype == 2) {
  1715. that.$set(targetRow3, 'mylpplantype', '撒料计划-撒料')
  1716. } else if (targetRow3.lpplantype == 3) {
  1717. that.$set(targetRow3, 'mylpplantype', '剩料计划')
  1718. } else if (targetRow3.lpplantype == 4) {
  1719. that.$set(targetRow3, 'mylpplantype', '预混计划')
  1720. } else if (targetRow3.lpplantype == 5) {
  1721. that.$set(targetRow3, 'mylpplantype', '预称重计划')
  1722. }
  1723. if (targetRow2.lpplantype == 0) {
  1724. that.$set(targetRow2, 'mylpplantype', '撒料计划')
  1725. } else if (targetRow2.lpplantype == 1) {
  1726. that.$set(targetRow2, 'mylpplantype', '撒料计划-混料')
  1727. } else if (targetRow2.lpplantype == 2) {
  1728. that.$set(targetRow2, 'mylpplantype', '撒料计划-撒料')
  1729. } else if (targetRow2.lpplantype == 3) {
  1730. that.$set(targetRow2, 'mylpplantype', '剩料计划')
  1731. } else if (targetRow2.lpplantype == 4) {
  1732. that.$set(targetRow2, 'mylpplantype', '预混计划')
  1733. } else if (targetRow2.lpplantype == 5) {
  1734. that.$set(targetRow2, 'mylpplantype', '预称重计划')
  1735. }
  1736. var message = '不可拖动至' + targetRow3.mylpplantype + '跟' + targetRow2.mylpplantype + '之间'
  1737. that.$message({ type: 'error', message: message, duration: 2000 })
  1738. return false
  1739. }
  1740. }
  1741. }
  1742. // ========
  1743. // var pidArr = [] // pid相同的值
  1744. // var pidArr1 = [] //
  1745. // var index // 索引
  1746. // for (let i = 0; i < tableList.length; i++) {
  1747. // if (tableList[i].pid == targetRow.pid) {
  1748. // pidArr.push(tableList[i])
  1749. // } else {
  1750. // pidArr1.push(tableList[i])
  1751. // }
  1752. // }
  1753. // if (pidArr.length > 0) {
  1754. // // 找到对应上方pid 的ID
  1755. // // 比如说id 580243 找到对应的索引
  1756. // if (targetRow3 !== undefined) {
  1757. // for (let i = 0; i < pidArr1.length; i++) {
  1758. // if (pidArr1[i].id == targetRow3.id) {
  1759. // index = i
  1760. // }
  1761. // }
  1762. // } else {
  1763. // for (let i = 0; i < pidArr1.length; i++) {
  1764. // if (pidArr1[i].id == targetRow2.id) {
  1765. // index = i - 1
  1766. // }
  1767. // }
  1768. // }
  1769. // pidArr1.splice(index + 1, 0, ...pidArr)
  1770. // console.log(pidArr1)
  1771. // that.$nextTick(() => {
  1772. // that.table.list = pidArr1
  1773. // })
  1774. // }
  1775. // if (targetRow2 !== undefined && targetRow3 !== undefined) {
  1776. // if (targetRow2.pid == targetRow3.pid) {
  1777. // that.$nextTick(() => {
  1778. // that.$set(that.table, 'list', tableList)
  1779. // })
  1780. // that.$message({ type: 'error', message: '不可将其他计划拖动至预称重计划之间9999', duration: 2000 })
  1781. // return false
  1782. // }
  1783. // }
  1784. }
  1785. // ===
  1786. }
  1787. })
  1788. },
  1789. // 复制
  1790. handleCopy() {
  1791. if (this.table.list.length > 0) {
  1792. this.newGeneration.temp = {}
  1793. this.newGeneration.dialogStatus = 'copy'
  1794. this.newGeneration.dialogFormVisible = true
  1795. } else {
  1796. this.$message({ type: 'error', message: '当前无计划可复制' })
  1797. }
  1798. },
  1799. copyData() {
  1800. console.log(this.newGeneration.temp.copyInputDatetime)
  1801. this.isokDisable = true
  1802. setTimeout(() => {
  1803. this.isokDisable = false
  1804. }, 5000)
  1805. this.$refs['temp'].validate(valid => {
  1806. if (valid) {
  1807. this.requestParam.name = 'copydownloadedplan'
  1808. this.requestParam.parammaps = {}
  1809. this.requestParam.parammaps.pastureid = Cookies.get('pastureid')
  1810. this.requestParam.parammaps.date = this.table.getdataListParm.parammaps.mydate
  1811. this.requestParam.parammaps.startTime = parseTime(this.newGeneration.temp.copyInputDatetime[0], '{y}-{m}-{d}')
  1812. this.requestParam.parammaps.stopTime = parseTime(this.newGeneration.temp.copyInputDatetime[1], '{y}-{m}-{d}')
  1813. PostDataByName(this.requestParam).then(response => {
  1814. if (response.msg === 'fail') {
  1815. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1816. } else {
  1817. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1818. this.newGeneration.dialogFormVisible = false
  1819. this.getList()
  1820. }
  1821. })
  1822. }
  1823. })
  1824. },
  1825. handleChangeOrder() {
  1826. // 拖动顺序
  1827. this.isOrder = false
  1828. this.rowDrop()
  1829. },
  1830. saveChangeOrder() {
  1831. // 保存顺序
  1832. var sortList = []
  1833. for (let i = 0; i < this.table.list.length; i++) {
  1834. var obj = {}
  1835. obj.sort = i
  1836. obj.pastureid = this.table.list[i].pastureid
  1837. obj.id = this.table.list[i].id
  1838. sortList.push(obj)
  1839. }
  1840. console.log(sortList)
  1841. this.requestParam = {}
  1842. this.requestParam.common = { 'returnmap': '0' }
  1843. this.requestParam.data = []
  1844. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': sortList }}
  1845. this.requestParam.data[0].children = []
  1846. this.requestParam.data[0].children[0] = { 'name': 'updatedownloadesort', 'type': 'e', 'parammaps': {
  1847. id: '@insertSpotList.id',
  1848. pastureid: '@insertSpotList.pastureid',
  1849. sort: '@insertSpotList.sort'
  1850. }}
  1851. ExecDataByConfig(this.requestParam).then(response => {
  1852. console.log('顺序切换保存发送参数', this.requestParam)
  1853. if (response.msg === 'fail') {
  1854. this.$notify({ title: '顺序切换失败', message: response.data, type: 'warning', duration: 2000 })
  1855. } else {
  1856. this.$notify({ title: '', message: '顺序切换成功', type: 'success', duration: 2000 })
  1857. this.getList()
  1858. this.isOrder = true
  1859. }
  1860. })
  1861. },
  1862. cancelChangeOrder() {
  1863. // 取消顺序
  1864. this.getList()
  1865. this.isOrder = true
  1866. },
  1867. handleDataSynchronization() {
  1868. MessageBox.confirm('是否确认同步数据?', {
  1869. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1870. }).then(() => {
  1871. this.requestParam = {}
  1872. this.requestParam.pastureid = Cookies.get('pastureid')
  1873. // this.$alert('正在同步', { confirmButtonText: '确定' })
  1874. this.dataSynchronization.dialogFormVisible = true
  1875. getDorm(this.requestParam).then(response => {
  1876. console.log(response)
  1877. if (response.msg == 'ok') {
  1878. this.dataSynchronization.dialogFormVisible = false
  1879. this.$notify({ title: '同步成功', message: '同步成功', type: 'success', duration: 2000 })
  1880. } else {
  1881. this.$notify({ title: '同步失败', message: response.data, type: 'warning', duration: 2000 })
  1882. this.dataSynchronization.dialogFormVisible = false
  1883. }
  1884. })
  1885. }).catch(() => {
  1886. this.$message({ type: 'info', message: '已取消数据同步' })
  1887. })
  1888. },
  1889. handleRowDelete(row) {
  1890. console.log('删除')
  1891. MessageBox.confirm('是否确认删除此信息?', {
  1892. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1893. }).then(() => {
  1894. this.selectList = []
  1895. this.requestParam = {}
  1896. this.requestParam.name = 'delDownloadedplan'
  1897. this.requestParam.parammaps = {}
  1898. this.requestParam.parammaps.pastureid = row.pastureid
  1899. this.requestParam.parammaps.id = row.id
  1900. PostDataByName(this.requestParam).then(response => {
  1901. if (response.msg === 'fail') {
  1902. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  1903. } else {
  1904. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  1905. this.getList()
  1906. }
  1907. })
  1908. }).catch(() => {
  1909. this.$message({ type: 'info', message: '已取消删除' })
  1910. })
  1911. }
  1912. }
  1913. }
  1914. </script>
  1915. <style>
  1916. .el-table .warning-row {
  1917. background: oldlace;
  1918. }
  1919. .el-table .success-row {
  1920. background: #f0f9eb;
  1921. }
  1922. </style>
  1923. <style lang="scss" scoped>
  1924. .app-container{background: #fff;}
  1925. .operation{}
  1926. .search{margin-top:10px;}
  1927. .table{margin-bottom:20px;}
  1928. .template{
  1929. background: #fff;
  1930. position: relative;
  1931. }
  1932. .table2{
  1933. // float: left;width: 50%;
  1934. background: #fff;
  1935. position: relative;
  1936. .content-table{margin-top: 20px;}
  1937. .contentOperation{right: -50px;z-index: 1;}
  1938. }
  1939. .table3{
  1940. // float: left;width: 50%;
  1941. background: #fff;
  1942. position: relative;
  1943. .content-table{margin-top: 20px;}
  1944. .contentOperation{right: -50px;z-index: 1;}
  1945. }
  1946. </style>