b1ebfd0a6dcf30ebd7ff4b0a45b82f82ef827c8c.svn-base 62 KB

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