8a8f6e952d0cec6d7d8a4dedcebf6106c5950740.svn-base 52 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239
  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: 7,
  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. var obj = { 'id': '580999', 'havebutton': '0', 'lpplantype': 2, 'pid': '3283220207862547456', 'times': '第二班', 'projname': '2.666' }
  654. response.data.list[6] = obj
  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, 'targetRow')
  1059. console.log(targetRow2, 'targetRow2')
  1060. console.log(targetRow3, 'targetRow3')
  1061. that.table.list.splice(evt.newIndex, 0, targetRow)
  1062. // ==========
  1063. // 已执行的计划不可拖动
  1064. if (targetRow.havebutton == 1) {
  1065. that.$nextTick(() => {
  1066. that.$set(that.table, 'list', tableList)
  1067. })
  1068. that.$message({ type: 'error', message: '因已执行的计划不可调整顺序', duration: 2000 })
  1069. return false
  1070. }
  1071. // 相同班次之间可以拖动
  1072. if (targetRow2 !== undefined && targetRow3 !== undefined) {
  1073. if (targetRow.times !== targetRow2.times && targetRow.times !== targetRow3.times) {
  1074. that.$nextTick(() => {
  1075. that.$set(that.table, 'list', tableList)
  1076. })
  1077. that.$message({ type: 'error', message: '因班次不同不可调整顺序', duration: 2000 })
  1078. return false
  1079. }
  1080. } else if (targetRow2 !== undefined && targetRow3 == undefined) {
  1081. if (targetRow.times !== targetRow2.times) {
  1082. that.$nextTick(() => {
  1083. that.$set(that.table, 'list', tableList)
  1084. })
  1085. that.$message({ type: 'error', message: '因班次不同不可调整顺序', duration: 2000 })
  1086. return false
  1087. }
  1088. } else if (targetRow2 == undefined && targetRow3 !== undefined) {
  1089. if (targetRow.times !== targetRow3.times) {
  1090. that.$nextTick(() => {
  1091. that.$set(that.table, 'list', tableList)
  1092. })
  1093. that.$message({ type: 'error', message: '因班次不同不可调整顺序', duration: 2000 })
  1094. return false
  1095. }
  1096. }
  1097. // 撒料计划0,
  1098. // 撒料计划-混料1
  1099. // 撒料计划-撒料2
  1100. // 剩料计划3
  1101. // 预混计划4
  1102. // 预称重计划5
  1103. if (targetRow.lpplantype == 1) { // 拖动数据为撒料计划-混料
  1104. console.log('遍历有相同的pid,一起跟着拖动')
  1105. if (targetRow2 == undefined) {
  1106. that.$nextTick(() => {
  1107. that.$set(that.table, 'list', tableList)
  1108. })
  1109. } else if (targetRow2 !== undefined && targetRow2.pid == targetRow.pid) {
  1110. that.$nextTick(() => {
  1111. that.$set(that.table, 'list', tableList)
  1112. })
  1113. } else {
  1114. var pidArr = [] // pid相同的值
  1115. var pidArr1 = [] //
  1116. var index // 索引
  1117. for (let i = 0; i < tableList.length; i++) {
  1118. if (tableList[i].pid == targetRow.pid) {
  1119. pidArr.push(tableList[i])
  1120. } else {
  1121. pidArr1.push(tableList[i])
  1122. }
  1123. }
  1124. // 找到对应上方pid 的ID
  1125. // 比如说id 580243 找到对应的索引
  1126. for (let i = 0; i < pidArr1.length; i++) {
  1127. if (pidArr1[i].id == targetRow3.id) {
  1128. index = i
  1129. }
  1130. }
  1131. pidArr1.splice(index + 1, 0, ...pidArr)
  1132. that.$nextTick(() => {
  1133. that.table.list = pidArr1
  1134. })
  1135. }
  1136. } else if (targetRow.lpplantype == 2) { // 拖动数据为撒料计划-撒料
  1137. if (targetRow2 == undefined) {
  1138. if (targetRow3.pid !== targetRow.pid) {
  1139. that.$nextTick(() => {
  1140. that.$set(that.table, 'list', tableList)
  1141. })
  1142. that.$message({ type: 'error', message: '撒料计划-撒料不可拖动至其他位置', duration: 2000 })
  1143. return false
  1144. }
  1145. } else {
  1146. if (targetRow2.lpplantype == 1 && (targetRow2.pid == targetRow.pid || targetRow2 == undefined)) {
  1147. // 拖动数据下方为撒料计划-混料时且pid相同,不可拖动,提示
  1148. that.$nextTick(() => {
  1149. that.$set(that.table, 'list', tableList)
  1150. })
  1151. that.$message({ type: 'error', message: '撒料计划-撒料不可拖动至撒料计划-混料上方', duration: 2000 })
  1152. return false
  1153. } else if (targetRow.lpplantype == 2 && (targetRow2.pid == targetRow.pid || targetRow3.pid == targetRow.pid || targetRow2 == undefined || targetRow3 == undefined)) {
  1154. console.log('正常拖动')
  1155. } else {
  1156. that.$nextTick(() => {
  1157. that.$set(that.table, 'list', tableList)
  1158. })
  1159. that.$message({ type: 'error', message: '撒料计划-撒料不可拖动至其他位置', duration: 2000 })
  1160. return false
  1161. }
  1162. }
  1163. } else if (targetRow.lpplantype == 0 || targetRow.lpplantype == 3 || targetRow.lpplantype == 4 || targetRow.lpplantype == 5) {
  1164. if (targetRow2.pid == targetRow3.pid) {
  1165. that.$nextTick(() => {
  1166. that.$set(that.table, 'list', tableList)
  1167. })
  1168. that.$message({ type: 'error', message: '不可拖动至撒料计划-撒料跟撒料计划-混料之间', duration: 2000 })
  1169. return false
  1170. }
  1171. }
  1172. }
  1173. })
  1174. },
  1175. handleChangeOrder() {
  1176. // 拖动顺序
  1177. this.isOrder = false
  1178. this.rowDrop()
  1179. },
  1180. saveChangeOrder() {
  1181. // 保存顺序
  1182. },
  1183. cancelChangeOrder() {
  1184. // 取消顺序
  1185. this.getList()
  1186. this.isOrder = true
  1187. }
  1188. }
  1189. }
  1190. </script>
  1191. <style lang="scss" scoped>
  1192. .operation{margin-bottom:10px;}
  1193. .search{margin-top:10px;}
  1194. .table{margin-top:10px;}
  1195. .template{
  1196. background: #fff;
  1197. position: relative;
  1198. }
  1199. .table2{
  1200. float: left;width: 49%;margin-right: 1%;background: red;
  1201. background: #fff;
  1202. position: relative;
  1203. .content-table{margin-top: 70px;}
  1204. }
  1205. .table3{
  1206. float: left;
  1207. width: 49%;
  1208. background: #fff;
  1209. position: relative;
  1210. .content-table{margin-top: 70px;}
  1211. }
  1212. </style>