3326e89ff60b5d0bdaf62f9f61430f9a72f1a768.svn-base 64 KB

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