index.vue 59 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501
  1. <template>
  2. <div class="app-container">
  3. <div class="search">
  4. <el-select v-model="table.getdataListParm.parammaps.times" filterable placeholder="班次" class="filter-item" style="width: 120px;" @change="changeFrequency">
  5. <el-option v-for="item in frequencyList" :key="item.id" :label="item.name" :value="item.id" />
  6. </el-select>
  7. </div>
  8. <div class="operation">
  9. <el-button v-if="isRoleEdit" class="success" icon="el-icon-plus" style="float:left;" @click="handleCreate">新增车次
  10. </el-button>
  11. <el-button v-if="isRoleEdit" class="danger" icon="el-icon-delete" style="float:left;" @click="handleReduceTrains">减少车次</el-button>
  12. <el-button v-if="isRoleEdit" class="success" icon="el-icon-download" style="float:left;" @click="handleAutomaticGeneration">自动生成</el-button>
  13. <el-button v-if="isOrder && isRoleEdit" icon="el-icon-sort" style="float: left;" class="success" @click="handleChangeOrder">更改顺序</el-button>
  14. <div v-else style="float: left;margin-left: 10px;">
  15. <el-button v-if="isRoleEdit" icon="el-icon-folder-checked" class="success" @click="saveChangeOrder">保存 </el-button>
  16. <el-button v-if="isRoleEdit" icon="el-icon-close" class="sortCancel" @click="cancelChangeOrder">取消</el-button>
  17. </div>
  18. <el-button v-if="isRoleEdit" class="success" icon="el-icon-open" style="float: left;" @click="handleTakeEffect"> 生效</el-button>
  19. <el-button v-if="isRoleEdit" class="danger" icon="el-icon-turn-off" style="float: left;" @click="handleDisable"> 禁用</el-button>
  20. <el-button class="success" icon="el-icon-time" style="float:right;" @click="handleHistoryRecord">历史记录 </el-button>
  21. </div>
  22. <div class="table">
  23. <el-table
  24. id="table"
  25. :key="table.tableKey"
  26. ref="table"
  27. v-loading="table.listLoading"
  28. element-loading-text="给我一点时间"
  29. :data="table.list"
  30. border
  31. highlight-current-row
  32. style="width: 100%;"
  33. :height="height"
  34. :row-style="rowStyle"
  35. :cell-style="cellStyle"
  36. class="elTable"
  37. row-key="id"
  38. @selection-change="handleSelect"
  39. >
  40. <el-table-column type="selection" width="50" />
  41. <el-table-column label="车次" width="50px" align="center" class-name="small-padding fixed-width" fixed="">
  42. <template slot-scope="scope">
  43. <span>{{ scope.row.sort }}</span>
  44. </template>
  45. </el-table-column>
  46. <el-table-column label="TMR编号" width="110px" align="center" class-name="small-padding fixed-width" fixed="left">
  47. <template slot-scope="scope">
  48. <span>{{ scope.row.tmrname }}</span>
  49. </template>
  50. </el-table-column>
  51. <el-table-column label="描述" width="110px" align="center">
  52. <template slot-scope="scope">
  53. <span>{{ scope.row.display }}</span>
  54. </template>
  55. </el-table-column>
  56. <el-table-column label="生效" width="70px" align="center">
  57. <template slot-scope="scope">
  58. <el-switch v-model="scope.row.sel" disabled active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" />
  59. </template>
  60. </el-table-column>
  61. <el-table-column label="班次" width="65px" align="center">
  62. <template slot-scope="scope">
  63. <span>{{ scope.row.timesstr }}</span>
  64. </template>
  65. </el-table-column>
  66. <el-table-column label="时间" width="55px" align="center">
  67. <template slot-scope="scope">
  68. <span>{{ scope.row.begintime }}</span>
  69. </template>
  70. </el-table-column>
  71. <el-table-column label="最大重量" width="75px" align="center">
  72. <template slot-scope="scope">
  73. <span>{{ scope.row.maxweight }}</span>
  74. </template>
  75. </el-table-column>
  76. <el-table-column label="合计重量" width="80px" align="center">
  77. <template slot-scope="scope">
  78. <span>{{ scope.row.sumweight }}</span>
  79. </template>
  80. </el-table-column>
  81. <el-table-column label="模板配方" width="90px" align="center">
  82. <template slot-scope="scope">
  83. <span>{{ scope.row.ftname }}</span>
  84. </template>
  85. </el-table-column>
  86. <el-table-column v-show="isInforvalue" label="是否提前小料拆分" width="70px" align="center">
  87. <template slot-scope="scope">
  88. <el-switch v-model="scope.row.issplit" disabled active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" />
  89. </template>
  90. </el-table-column>
  91. <el-table-column label="撒料" min-width="250px" align="left" header-align="center">
  92. <template slot-scope="scope">
  93. <div v-for="element in scope.row.arrList" :key="element.name" class="list">
  94. <el-tooltip placement="top" :open-delay="1000">
  95. <div slot="content">
  96. <div> 栏舍全称:{{ element.barname }} </div>
  97. <div> 饲料重量:{{ element.weight }} </div>
  98. <div> 撒料车:{{ element.tmrname }} </div>
  99. </div>
  100. <div :style="{'background':element.background}" class="tmrname">{{ element.barname }}</div>
  101. </el-tooltip>
  102. </div>
  103. </template>
  104. </el-table-column>
  105. <el-table-column label="操作" align="center" width="70" class-name="small-padding fixed-width" fixed="right">
  106. <template slot-scope="{row}">
  107. <el-button v-if="isRoleEdit" class="miniSuccess" icon="el-icon-edit-outline" @click="handleUpdate(row)" />
  108. <span v-if="isRoleEdit" class="centerSpan">|</span>
  109. <el-button v-if="isRoleEdit" class="miniDanger" icon="el-icon-delete" @click="handleRowDelete(row)" />
  110. </template>
  111. </el-table-column>
  112. </el-table>
  113. <span v-if="table.listLoading == false" style="margin-right: 30px;margin-top: 10px;font-size: 14px;">共{{ table.total }}条</span>
  114. </div>
  115. <!-- 自动生成 -->
  116. <el-dialog :fullscreen="dialogFull" :destroy-on-close="true" :visible.sync="automaticGeneration.dialogFormVisible" :close-on-click-modal="false" width="30%">
  117. <template slot="title">
  118. <div class="avue-crud__dialog__header">
  119. <span class="el-dialog__title">
  120. <span style="display:inline-block;width:3px;height:20px;margin-right:5px; float: left;margin-top:2px" />
  121. {{ textMap[automaticGeneration.dialogStatus] }}
  122. </span>
  123. <div class="avue-crud__dialog__menu" @click="dialogFull? dialogFull=false: dialogFull=true">
  124. <svg-icon v-if="dialogFull" icon-class="exit-fullscreen" />
  125. <svg-icon v-else icon-class="fullscreen" />
  126. </div>
  127. </div>
  128. </template>
  129. <div class="app-automaticGeneration" style="margin: 0 auto;">
  130. <div style="width: 210px;margin:60px auto 120px;font-weight: 16px;">
  131. 请选择自动生成方式:<br>
  132. 清空计划并生成新计划;<br>
  133. 当前计划基础上继续生成计划;<br>
  134. </div>
  135. <div slot="footer" class="dialog-footer">
  136. <el-button style="right:240px;" class="cancelClose" @click="automaticGeneration.dialogFormVisible = false;">关闭</el-button>
  137. <el-button style="right:130px;" class="save" :disabled="isokDisable" @click="continueData(0)">继续生成 </el-button>
  138. <el-button style="right:20px;" class="save" :disabled="isokDisable" @click="continueData(1)">重新生成 </el-button>
  139. </div>
  140. </div>
  141. </el-dialog>
  142. <!-- 历史记录 -->
  143. <el-dialog :fullscreen="dialogFull" :destroy-on-close="true" :visible.sync="historyRecord.dialogFormVisible" :close-on-click-modal="false" width="90%">
  144. <template slot="title">
  145. <div class="avue-crud__dialog__header">
  146. <span class="el-dialog__title">
  147. <span style="display:inline-block;width:3px;height:20px;margin-right:5px; float: left;margin-top:2px" />
  148. {{ textMap[historyRecord.dialogStatus] }}
  149. </span>
  150. <div class="avue-crud__dialog__menu" @click="dialogFull? dialogFull=false: dialogFull=true">
  151. <svg-icon v-if="dialogFull" icon-class="exit-fullscreen" />
  152. <svg-icon v-else icon-class="fullscreen" />
  153. </div>
  154. </div>
  155. </template>
  156. <div class="historyRecord">
  157. <keep-alive>
  158. <component :is="historyRecord.myComponent" ref="historyRecord" />
  159. </keep-alive>
  160. </div>
  161. <div slot="footer" class="dialog-footer">
  162. <el-button class="cancelClose cancelClose1" @click="historyRecord.dialogFormVisible = false; ">关闭</el-button>
  163. </div>
  164. </el-dialog>
  165. <!-- 新增、编辑 -->
  166. <el-dialog :fullscreen="dialogFull" :destroy-on-close="true" :visible.sync="create.dialogFormVisible" :before-close="close" :close-on-click-modal="false" width="90%">
  167. <template slot="title">
  168. <div class="avue-crud__dialog__header">
  169. <span class="el-dialog__title">
  170. <span style="display:inline-block;width:3px;height:20px;margin-right:5px; float: left;margin-top:2px" />
  171. {{ textMap[create.dialogStatus] }}
  172. </span>
  173. <div class="avue-crud__dialog__menu" @click="dialogFull? dialogFull=false: dialogFull=true">
  174. <svg-icon v-if="dialogFull" icon-class="exit-fullscreen" />
  175. <svg-icon v-else icon-class="fullscreen" />
  176. </div>
  177. </div>
  178. </template>
  179. <div class="create">
  180. <el-form ref="temp" :rules="create.rules" :model="create.temp" label-position="right" label-width="135px" style="width: 100%;margin:0 auto 10px;">
  181. <el-row>
  182. <el-col :span="8">
  183. <el-form-item label="生效:" prop="sel">
  184. <el-switch v-model="create.temp.sel" active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" />
  185. </el-form-item>
  186. </el-col>
  187. <el-col :span="8">
  188. <el-form-item label="TMR编号:" prop="tmrid2">
  189. <el-select v-model="create.temp.tmrid2" style="width: 100%;" placeholder="TMR编号" @change="changeTMRNumber">
  190. <el-option v-for="item in equipmentList" :key="item.id" :label="`${item.tclassname}/${item.eqcode}`" :value="item.id" />
  191. </el-select>
  192. </el-form-item>
  193. </el-col>
  194. <el-col :span="8">
  195. <el-form-item label="班次:" prop="times">
  196. <el-select v-model="create.temp.times" :disabled="create.list2.length>0" placeholder="班次" style="width:100%;" @change="changeTimes">
  197. <el-option v-for="item in frequencyList" :key="item.id" :label="item.name" :value="item.id" />
  198. </el-select>
  199. </el-form-item>
  200. </el-col>
  201. </el-row>
  202. <el-row>
  203. <el-col :span="8">
  204. <el-form-item label="提前小料拆分:" prop="issplit">
  205. <el-switch v-model="create.temp.issplit" active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" />
  206. </el-form-item>
  207. </el-col>
  208. <el-col :span="8">
  209. <el-form-item label="时间:" prop="begintime">
  210. <el-time-picker v-model="create.temp.begintime" style="width: 100%;" :clearable="false" type="datetime" placeholder="时间" format="HH:mm" value-format="HH:mm" />
  211. </el-form-item>
  212. </el-col>
  213. <el-col :span="8">
  214. <el-form-item label="模板配方:" prop="ftid">
  215. <el-select v-model="create.temp.ftid" :disabled="create.list2.length>0" placeholder="模板配方" style="width:100%;" @change="changeTemplateFormulation">
  216. <el-option v-for="item in templateFormulationList" :key="item.id" :label="item.tname" :value="item.id" />
  217. </el-select>
  218. </el-form-item>
  219. </el-col>
  220. </el-row>
  221. <el-row>
  222. <el-col :span="8">
  223. <el-form-item label="描述:" prop="display">
  224. <el-input v-model="create.temp.display" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" placeholder="描述" maxlength="255" style="width: 100%;" />
  225. </el-form-item>
  226. </el-col>
  227. </el-row>
  228. </el-form>
  229. <div v-if="create.dialogStatus !=='update' && !isDispaly" slot="footer" class="dialog-footer">
  230. <el-button class="cancelClose" @click="create.dialogFormVisible = false;getList()">关闭</el-button>
  231. <el-button v-if="create.dialogStatus==='create'" class="save" :disabled="isokDisable" @click="distributionAndSpreading()">分配撒料</el-button>
  232. </div>
  233. <!-- 栏舍 -->
  234. <div v-if="create.dialogStatus =='update' || isDispaly" class="bottom" style="border-top: 1px solid #009C69;">
  235. <el-row>
  236. <el-col :span="20">
  237. <div class="fenceHouse">
  238. <ul v-loading="create.listLoadingTimes" class="fenceHouseList">
  239. <li v-for="element in create.list1" :key="element.arrid">
  240. <span v-if="element.isShowTitle" class="fenceHouseTitle">{{ element.ftname }}:</span>
  241. <div v-for="item in element.arrList" :key="item.id" class="colorBlock">
  242. <div style="position: relative;">
  243. <el-tooltip placement="top" style="height: 18px;line-height: 18px;" :style="{'background':item.background}">
  244. <div slot="content">{{ item.barname }}</div>
  245. <div class="barname">
  246. <span style="float: left;width: 70px;overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">{{ item.barname }}</span>
  247. <b style="background: red;float: right;width: 18px;font-size: 18px;" class="el-icon-check" @click="clickBar(item)" />
  248. </div>
  249. </el-tooltip>
  250. <div class="barWeight" :style="{ background: 'rgba('+item.background2+ ',0.1)' }"> {{ item.weight }} </div>
  251. </div>
  252. </div>
  253. </li>
  254. </ul>
  255. </div>
  256. </el-col>
  257. <el-col :span="4">
  258. <div style="text-align: center;height: 100px;margin-top: 40px;">
  259. <div class="maxweight" style="line-height:20px;"><b>最大重量:</b>{{ create.temp.maxweight }} (KG)</div>
  260. <div class="sumweight" style="line-height:20px;margin-top: 10px;"><b>合计重量:</b>{{ create.temp.sumweight }} (KG) </div>
  261. </div>
  262. </el-col>
  263. </el-row>
  264. <!-- 撒料 -->
  265. <div class="spreadingMaterial">
  266. <div>撒料:</div>
  267. <div class="spreadingMaterialList">
  268. <div v-for="element in create.list2" :key="element.name" class="list-group-item2 item">
  269. <div class="arr-l" :style="{'background':element.tbackground}">
  270. <div class="arr-l-t">
  271. <div class="arr-l-t-t" />
  272. <el-select
  273. v-model="element.tmrid"
  274. placeholder="撒料设备"
  275. class="arr-l-t-b el-icon-arrow-down"
  276. @change="(value)=> {changeEquipment(value, element.fttype,element.id)}"
  277. >
  278. <el-option
  279. v-for="item in equipmentList"
  280. :key="item.id"
  281. :label="item.tname"
  282. :value="item.id"
  283. />
  284. </el-select>
  285. </div>
  286. <div class="arr-l-b">
  287. <el-tooltip placement="top" class="list-group-item1 item" style="height: 18px;line-height: 18px;">
  288. <div slot="content">{{ element.tmrname }}</div>
  289. <div class="tmrname">{{ element.tmrname }}</div>
  290. </el-tooltip>
  291. </div>
  292. <div v-if="element.fttype==0" style="background: #009C69;position:absolute;bottom: 0;left: 0;">补</div>
  293. </div>
  294. <div class="arr-r">
  295. <div class="arr-r-l">
  296. <el-tooltip placement="top">
  297. <div slot="content">{{ element.barname }}</div>
  298. <div class="barname">{{ element.barname }}</div>
  299. </el-tooltip>
  300. </div>
  301. <div class="arr-r-c">-</div>
  302. <div class="arr-r-r">
  303. <el-tooltip placement="top">
  304. <div slot="content">{{ element.weight }}</div>
  305. <input
  306. ref="weight"
  307. v-model="element.weight"
  308. :autofocus="element.focusState"
  309. type="number"
  310. placeholder="重量"
  311. step="0.01"
  312. class="filter-item2"
  313. style="display: inline-block;height:25px;padding:4px 4px 4px 0;text-align:right;font-size:12px;width: 95%;border: 1px solid #e6e6e6;"
  314. @keyup.enter="$event.target.blur"
  315. @blur="blurWeight(element)"
  316. >
  317. </el-tooltip>
  318. </div>
  319. </div>
  320. <div class="arr-t" :style="{'background':element.background}">
  321. <i class="el-icon-close" style="position: absolute;right: 0;" @click="handleFLDelete(element)" />
  322. </div>
  323. </div>
  324. </div>
  325. </div>
  326. <div slot="footer" class="dialog-footer">
  327. <el-button class="cancelClose" :disabled="isokDisable" @click="close()">关闭</el-button>
  328. <el-button class="save" :disabled="isokDisable" @click="updateData()">确认</el-button>
  329. </div>
  330. </div>
  331. </div>
  332. </el-dialog>
  333. </div>
  334. </template>
  335. <script>
  336. import Cookies from 'js-cookie'
  337. import Sortable from 'sortablejs'
  338. import { checkButtons, ExecDataByConfig, postJson } from '@/api/common'
  339. import { MessageBox } from 'element-ui'
  340. export default {
  341. data() {
  342. return {
  343. isRoleEdit: [],
  344. rowStyle: { maxHeight: 25 + 'px', height: 25 + 'px' },
  345. cellStyle: { padding: 0 + 'px' },
  346. height: document.body.clientHeight - 220, // table高度
  347. table: {
  348. getdataListParm: {
  349. page: 1,
  350. offset: 1,
  351. pagecount: 0,
  352. returntype: 'Map',
  353. parammaps: {
  354. pastureid: Cookies.get('pastureid'),
  355. times: 1,
  356. refresh: 1
  357. }
  358. },
  359. tableKey: 0,
  360. list: [],
  361. total: 0,
  362. listLoading: false
  363. },
  364. frequencyList: [], // 班次
  365. maxTime: {
  366. getMaxTimesParm: {
  367. name: 'getSysoptEnable',
  368. page: 1,
  369. offset: 1,
  370. pagecount: 1,
  371. returntype: 'Map',
  372. parammaps: {
  373. pastureid: Cookies.get('pastureid'),
  374. inforname: 'times'
  375. }
  376. }
  377. },
  378. // 是否显示小料拆分
  379. isInforvalue: false,
  380. selectList: [],
  381. historyRecord: {
  382. dialogFormVisible: false,
  383. dialogStatus: '',
  384. myComponent: null
  385. },
  386. // 自动生成
  387. automaticGeneration: {
  388. dialogFormVisible: false,
  389. dialogStatus: ''
  390. },
  391. textMap: {
  392. automaticGeneration: '提示',
  393. historyRecord: '历史记录',
  394. create: '新增',
  395. update: '编辑'
  396. },
  397. dialogFull: false,
  398. isOrder: true,
  399. requestParam: {},
  400. isokDisable: false,
  401. create: {
  402. dialogFormVisible: false,
  403. dialogStatus: '',
  404. temp: { sel: 1, tmrid: '', tmrid2: '', maxweight: '', issplit: 1, begintime: '', sumweight: 0, display: '', times: 1, ftid: '', ftname: '', tmrname: '', maxweight: '' },
  405. rules: {
  406. tmrid2: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  407. times: [{ type: 'number', required: true, message: '必填', trigger: 'blur' }],
  408. ftid: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }]
  409. },
  410. listLoadingTimes: false,
  411. list1: [],
  412. list2: [],
  413. checkBarList: []
  414. },
  415. TMRNumberList: [], // TMR编号
  416. equipmentList: [], // 撒料设备
  417. templateFormulationList: [], // 模板配方
  418. isDispaly: false
  419. }
  420. },
  421. created() {
  422. this.getButtons()
  423. this.getIsDisplay()
  424. this.getList()
  425. },
  426. methods: {
  427. getButtons() {
  428. const Edit = 'MaterialIssuancePlan'
  429. const isRoleEdit = checkButtons(JSON.parse(sessionStorage.getItem('buttons')), Edit)
  430. this.isRoleEdit = isRoleEdit
  431. },
  432. // 下拉列表
  433. getDownList() {
  434. const url = 'authdata/GetDataByName'
  435. const data1 = {
  436. name: 'getTMRListEnableType',
  437. offset: 0,
  438. parammaps: {
  439. pastureid: Cookies.get('pastureid'),
  440. eqtype: '1'
  441. }
  442. }
  443. postJson(url, data1).then(response => {
  444. if (response.data !== null) {
  445. this.TMRNumberList = response.data.list
  446. } else {
  447. this.TMRNumberList = []
  448. }
  449. })
  450. const data2 = {
  451. name: 'getTMRListEnableTypeAll',
  452. offset: 0,
  453. parammaps: {
  454. pastureid: Cookies.get('pastureid'),
  455. eqtype: '1'
  456. }
  457. }
  458. postJson(url, data2).then(response => {
  459. if (response.data !== null) {
  460. this.equipmentList = response.data.list
  461. if(this.create.dialogStatus == 'update'){
  462. this.create.temp.tclassname = this.equipmentList.find(obj => obj.id == this.create.temp.tmrid).tclassname
  463. }
  464. } else {
  465. this.equipmentList = []
  466. }
  467. })
  468. const data3 = {
  469. name: 'getFTSWList',
  470. offset: 0,
  471. parammaps: {
  472. pastureid: Cookies.get('pastureid')
  473. }
  474. }
  475. postJson(url, data3).then(response => {
  476. if (response.data !== null) {
  477. this.templateFormulationList = response.data.list
  478. } else {
  479. this.templateFormulationList = []
  480. }
  481. })
  482. const data4 = {
  483. name: 'getSysoptEnable',
  484. offset: 0,
  485. parammaps: {
  486. pastureid: Cookies.get('pastureid'),
  487. inforname: 'isSmallMaterial'
  488. }
  489. }
  490. postJson(url, data4).then(response => {
  491. if (response.data !== null) {
  492. if (response.data.list[0].inforvalue == 0) {
  493. this.isInforvalue = false
  494. } else {
  495. this.isInforvalue = true
  496. }
  497. } else {
  498. this.isInforvalue = false
  499. }
  500. })
  501. },
  502. getIsDisplay() {
  503. const url = 'authdata/GetDataByName'
  504. const data = this.maxTime.getMaxTimesParm
  505. postJson(url, data).then(response => {
  506. console.log(response.data.list[0].inforvalue)
  507. if (response.data.list[0].inforvalue == 1) {
  508. this.frequencyList = [{ id: 1, name: '第一班' }]
  509. } else if (response.data.list[0].inforvalue == 2) {
  510. this.frequencyList = [
  511. { id: 1, name: '第一班' },
  512. { id: 2, name: '第二班' }
  513. ]
  514. } else if (response.data.list[0].inforvalue == 3) {
  515. this.frequencyList = [
  516. { id: 1, name: '第一班' },
  517. { id: 2, name: '第二班' },
  518. { id: 3, name: '第三班' }
  519. ]
  520. } else if (response.data.list[0].inforvalue == 4) {
  521. this.frequencyList = [
  522. { id: 1, name: '第一班' },
  523. { id: 2, name: '第二班' },
  524. { id: 3, name: '第三班' },
  525. { id: 4, name: '第四班' }
  526. ]
  527. }
  528. })
  529. },
  530. getList() {
  531. this.table.listLoading = true
  532. const url = 'authdata/spillage'
  533. const data = this.table.getdataListParm
  534. postJson(url, data).then(response => {
  535. if (response.data.list !== undefined) {
  536. if (response.data.list !== null) {
  537. console.log('table数据', response.data.list)
  538. for (let i = 0; i < response.data.list.length; i++) {
  539. if (response.data.list[i].arrList == null) {
  540. this.$set(response.data.list[i], 'arrList', [])
  541. }
  542. }
  543. this.table.list = response.data.list
  544. this.table.total = response.data.list.length
  545. setTimeout(() => {
  546. this.$refs.table.doLayout()
  547. }, 100)
  548. } else {
  549. this.table.list = []
  550. }
  551. }
  552. this.table.listLoading = false
  553. })
  554. },
  555. changeFrequency(val) {
  556. console.log('选择了班次', val)
  557. this.getList()
  558. },
  559. // 行内删除
  560. handleRowDelete(row) {
  561. console.log(row, '点击了行删除')
  562. if (row.arrList.length == 0) {
  563. MessageBox.confirm('是否确认删除此信息?', {
  564. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  565. }).then(() => {
  566. this.selectList = []
  567. this.requestParam = {}
  568. this.requestParam.name = 'deleteLpp'
  569. this.requestParam.parammaps = {}
  570. this.requestParam.parammaps.pastureid = row.pastureid
  571. this.requestParam.parammaps.id = row.id
  572. const url = 'authdata/PostDataByName'
  573. const data = this.requestParam
  574. postJson(url, data).then(response => {
  575. if (response.msg === 'fail') {
  576. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  577. } else {
  578. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  579. this.table.getdataListParm.parammaps.refresh = 1
  580. this.getList()
  581. }
  582. })
  583. }).catch(() => {
  584. this.$message({ type: 'info', message: '已取消删除' })
  585. })
  586. } else {
  587. this.$message({ type: 'error', message: '本车次已添加栏舍不可删除', duration: 2000 })
  588. return false
  589. }
  590. },
  591. handleSelect(val) {
  592. console.log('勾选数据', val)
  593. this.selectList = val
  594. },
  595. changeTemplateFormulation(item) {
  596. this.create.temp.ftname = this.templateFormulationList.find(obj => obj.id === item).tname
  597. this.getCreateList1()
  598. },
  599. changeTimes(item) {
  600. this.getCreateList1()
  601. },
  602. // TMR编号
  603. changeTMRNumber(item) {
  604. if (this.create.list2.length > 0) {
  605. MessageBox.confirm('更换TMR撒料设备,会清空撒料车,是否更换?', {
  606. confirmButtonText: '是', cancelButtonText: '否', type: 'warning'
  607. }).then(() => {
  608. this.create.temp.tmrid = this.create.temp.tmrid2
  609. this.create.temp.tmrname = this.equipmentList.find(obj => obj.id === item).eqcode
  610. this.create.temp.maxweight = this.equipmentList.find(obj => obj.id === item).maxstirfeed
  611. this.create.temp.tclassname = this.equipmentList.find(obj => obj.id === item).tclassname
  612. this.create.temp.mytmrid = this.create.temp.tmrid
  613. this.create.temp.mytmrname = this.create.temp.tmrname
  614. console.log('tmrname==>', this.create.temp)
  615. if (this.isDispaly || this.create.dialogStatus == 'update') {
  616. this.getClearList()
  617. }
  618. }).catch(() => {
  619. this.create.temp.tmrid2 = this.create.temp.tmrid
  620. this.create.temp.tmrname = this.equipmentList.find(obj => obj.id === this.create.temp.tmrid2).eqcode
  621. this.create.temp.maxweight = this.equipmentList.find(obj => obj.id === this.create.temp.tmrid2).maxstirfeed
  622. this.create.temp.tclassname = this.equipmentList.find(obj => obj.id === this.create.temp.tmrid2).tclassname
  623. this.create.temp.mytmrid = this.create.temp.tmrid2
  624. this.create.temp.mytmrname = this.create.temp.tmrname
  625. console.log(this.create.temp)
  626. this.$message({ type: 'info', message: '已取消' })
  627. })
  628. } else {
  629. this.create.temp.tmrid = this.create.temp.tmrid2
  630. this.create.temp.tmrname = this.equipmentList.find(obj => obj.id === item).eqcode
  631. this.create.temp.maxweight = this.equipmentList.find(obj => obj.id === item).maxstirfeed
  632. this.create.temp.tclassname = this.equipmentList.find(obj => obj.id === item).tclassname
  633. this.create.temp.mytmrid = this.create.temp.tmrid
  634. this.create.temp.mytmrname = this.create.temp.tmrname
  635. console.log('TMR编号item==>', item)
  636. }
  637. console.log('tmrname==>', this.create.temp)
  638. },
  639. getClearList() {
  640. const url = 'authdata/lpplandtl/del'
  641. const data = []
  642. this.create.list2.forEach((item, i) => {
  643. const obj = {}
  644. obj.pastureid = item.pastureid
  645. obj.lpplandtlid = item.id
  646. obj.fttype = item.fttype
  647. obj.lweight = item.lweight
  648. obj.fpdid = item.fpdid
  649. data.push(obj)
  650. })
  651. postJson(url, data).then(response => {
  652. if (response.msg === 'fail') {
  653. this.$notify({ title: '失败', message: response.data, type: 'warning', duration: 2000 })
  654. } else {
  655. this.$notify({ title: '', message: '成功', type: 'success', duration: 2000 })
  656. this.getCreateList1()
  657. }
  658. })
  659. },
  660. colorRgb(sColor) {
  661. sColor = sColor.toLowerCase()
  662. var reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/
  663. // 如果是16进制颜色
  664. if (sColor && reg.test(sColor)) {
  665. if (sColor.length === 4) {
  666. var sColorNew = '#'
  667. for (var i = 1; i < 4; i += 1) {
  668. sColorNew += sColor.slice(i, i + 1).concat(sColor.slice(i, i + 1))
  669. }
  670. sColor = sColorNew
  671. }
  672. // 处理六位的颜色值
  673. var sColorChange = []
  674. for (var i = 1; i < 7; i += 2) {
  675. sColorChange.push(parseInt('0x' + sColor.slice(i, i + 2)))
  676. }
  677. return sColorChange.join(',')
  678. }
  679. return 'rgba(' + sColorChange.join(',') + ')'
  680. },
  681. dbclickWeight(item) {
  682. console.log('item==>', item)
  683. console.log('isRoleEdit==>', this.isRoleEdit)
  684. this.$set(item, 'isWeight', true)
  685. this.$set(item, 'focusState', true)
  686. },
  687. blurWeight(item) {
  688. if (parseFloat(item.weight) <= 0) {
  689. this.$message({ type: 'error', message: '重量不可输入小于0的数据', duration: 2000 })
  690. return false
  691. }
  692. if (item.weight == '') {
  693. item.weight = 0
  694. }
  695. const lweight = String(parseFloat(item.weight) - parseFloat(item.lweight))
  696. let sum = 0
  697. this.create.list2.forEach((item, i) => {
  698. console.log('item==>', item)
  699. sum += parseFloat(item.weight)
  700. })
  701. if (sum > this.create.temp.maxweight) {
  702. this.$message({ type: 'error', message: '撒料车总重量大于最大重量', duration: 2000 })
  703. return false
  704. }
  705. this.requestParam = {}
  706. this.requestParam.common = { 'returnmap': '0' }
  707. this.requestParam.data = []
  708. this.requestParam.data[0] = {
  709. 'name': 'checkFPdLeftW', 'type': 'v',
  710. 'parammaps': {
  711. pastureid: item.pastureid, fpdid: item.fpdid, fttype: item.fttype,
  712. lweight: lweight
  713. }
  714. }
  715. this.requestParam.data[1] = {
  716. 'name': 'updateLppd', 'type': 'e',
  717. 'parammaps': {
  718. pastureid: this.create.temp.pastureid, lppid: this.create.temp.id, barid: item.barid,
  719. barname: item.barname, fpdid: item.fpdid, fttype: item.fttype,
  720. lweight: item.weight, sort: item.sort, tmrid: item.tmrid,
  721. tmrname: item.tmrname, background: item.background, id: item.id
  722. }
  723. }
  724. this.requestParam.data[2] = {
  725. 'name': 'updateFpdetailUse', 'type': 'e',
  726. 'parammaps': {
  727. pastureid: item.pastureid, id: item.fpdid,
  728. fttype: item.fttype, lweight: lweight
  729. }
  730. }
  731. ExecDataByConfig(this.requestParam).then(response => {
  732. if (response.msg === 'fail') {
  733. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  734. } else {
  735. // this.$notify({ title: '', message: '保存成功', type: 'success', duration: 2000 })
  736. }
  737. this.getCreateList1()
  738. })
  739. },
  740. handleFLDelete(ele) {
  741. console.log(ele, '点击了撒料删除')
  742. this.requestParam = {}
  743. this.requestParam.common = { 'returnmap': '0' }
  744. this.requestParam.data = []
  745. this.requestParam.data[0] = {
  746. 'name': 'deleteLppd', 'type': 'e',
  747. 'parammaps': { pastureid: ele.pastureid, id: ele.id }
  748. }
  749. this.requestParam.data[1] = {
  750. 'name': 'updateFpdetailUse', 'type': 'e',
  751. 'parammaps': { pastureid: ele.pastureid, id: ele.fpdid, fttype: ele.fttype, lweight: '-' + parseFloat(ele.weight) }
  752. }
  753. const url = 'authdata/ExecDataByConfig'
  754. const data = this.requestParam
  755. postJson(url, data).then(response => {
  756. if (response.msg === 'fail') {
  757. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  758. } else {
  759. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  760. this.getCreateList1()
  761. }
  762. })
  763. },
  764. handleCreate() {
  765. console.log('新增车次')
  766. this.create.temp = { sel: 1, tmrid: '', tmrid2: '', maxweight: '', issplit: 1, begintime: '', sumweight: 0, display: '', times: 1, ftid: '', ftname: '', tmrname: '', maxweight: '' }
  767. this.getDownList()
  768. this.isDispaly = false
  769. this.dialogFull = false
  770. this.create.dialogStatus = 'create'
  771. this.create.dialogFormVisible = true
  772. this.create.list1 = []
  773. this.create.list2 = []
  774. this.create.checkBarList = []
  775. },
  776. distributionAndSpreading() {
  777. console.log('点击了分配撒料')
  778. this.$refs['temp'].validate(valid => {
  779. if (valid) {
  780. this.isokDisable = true
  781. setTimeout(() => {
  782. this.isokDisable = false
  783. }, 1000)
  784. const url = 'authdata/lpplan/add'
  785. const data = {}
  786. this.create.temp.pastureid = Cookies.get('pastureid')
  787. this.create.temp.times = parseInt(this.create.temp.times)
  788. data.parammaps = this.create.temp
  789. postJson(url, data).then(response => {
  790. console.log('新增保存发送参数', this.requestParam)
  791. if (response.msg !== 'fail') {
  792. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  793. this.create.temp.id = response.data.Id
  794. this.isDispaly = true
  795. } else {
  796. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  797. }
  798. })
  799. this.getCreateList1()
  800. }
  801. })
  802. },
  803. getCreateList1() {
  804. this.create.listLoadingTimes = true
  805. const url = 'authdata/spillage'
  806. const data = {
  807. page: 1,
  808. offset: 1,
  809. pagecount: 0,
  810. returntype: 'Map',
  811. parammaps: {
  812. pastureid: Cookies.get('pastureid'),
  813. times: this.create.temp.times,
  814. refresh: 2,
  815. ftid: this.create.temp.ftid
  816. }
  817. }
  818. postJson(url, data).then(response => {
  819. if (response.data.ftlist !== null) {
  820. for (let i = 0; i < response.data.ftlist.length; i++) {
  821. this.$set(response.data.ftlist[i], 'isShowTitle', true)
  822. if (response.data.ftlist[i].arrList == null) {
  823. this.$set(response.data.ftlist[i], 'isShowTitle', false)
  824. } else {
  825. for (let j = 0; j < response.data.ftlist[i].arrList.length; j++) {
  826. this.$set(response.data.ftlist[i].arrList[j], 'background2', this.colorRgb(response.data.ftlist[i].arrList[j].background))
  827. }
  828. }
  829. }
  830. this.create.list1 = response.data.ftlist
  831. } else {
  832. this.create.list1 = []
  833. }
  834. this.create.listLoadingTimes = false
  835. })
  836. this.getCreateList2()
  837. },
  838. getCreateList2() {
  839. const url = 'authdata/lpplandtl'
  840. const data = {}
  841. data.parammaps = {}
  842. data.parammaps.pastureid = Cookies.get('pastureid'),
  843. data.parammaps.id = this.create.temp.id
  844. postJson(url, data).then(response => {
  845. if (response.data !== null) {
  846. this.create.list2 = response.data
  847. this.create.temp.sort = response.data.length + 1
  848. var sumweight = 0
  849. for (let i = 0; i < this.create.list2.length; i++) {
  850. sumweight += parseFloat(this.create.list2[i].weight)
  851. this.$set(this.create.list2[i], 'isWeight', false)
  852. this.$set(this.create.list2[i], 'focusState', false)
  853. }
  854. console.log('sumweight==>', sumweight)
  855. this.create.temp.sumweight = (sumweight).toFixed(2)
  856. } else {
  857. this.create.list2 = []
  858. this.create.temp.sort = 0
  859. this.create.temp.sumweight = 0
  860. }
  861. })
  862. },
  863. clickBar(item) {
  864. console.log('点击了栏舍item==>', item)
  865. this.create.temp.sumweight = parseFloat(this.create.temp.sumweight)
  866. console.log('temp==>',this.create.temp)
  867. console.log('this.equipmentList==>',this.equipmentList)
  868. if(this.create.temp.tclassname == '固定式'){
  869. // console.log(this.equipmentList.find(obj => obj.tclassname == '撒料设备'))
  870. if(this.equipmentList.find(obj => obj.tclassname == '撒料设备') !== undefined){
  871. this.create.temp.tmrname = this.equipmentList.find(obj => obj.tclassname == '撒料设备').eqcode
  872. this.create.temp.tmrid = this.equipmentList.find(obj => obj.tclassname == '撒料设备').id
  873. }else if(this.equipmentList.find(obj => obj.tclassname == '自走式') !== undefined){
  874. this.create.temp.tmrname = this.equipmentList.find(obj => obj.tclassname == '自走式').eqcode
  875. this.create.temp.tmrid = this.equipmentList.find(obj => obj.tclassname == '自走式').id
  876. }else{
  877. this.$message({ type: 'error', message: '请先在TMR设备中创建撒料设备', duration: 2000 })
  878. return
  879. }
  880. }
  881. var evt = this.create.temp
  882. if (parseFloat(evt.maxweight) - parseFloat(evt.sumweight) < parseFloat(item.weight)) {
  883. if (parseFloat(evt.sumweight) + parseFloat(item.weight) > parseFloat(evt.maxweight)) {
  884. this.$set(item, 'weight', (parseFloat(evt.maxweight) - parseFloat(evt.sumweight)).toFixed(2))
  885. }
  886. }
  887. if (parseFloat(evt.maxweight) == parseFloat(evt.sumweight) || parseFloat(evt.maxweight) < parseFloat(evt.sumweight)) {
  888. this.$message({ type: 'error', message: '计划配方已经是最大容量', duration: 2000 })
  889. this.getCreateList1()
  890. return
  891. }
  892. console.log('item.weight===>', item.weight)
  893. this.requestParam = {}
  894. this.requestParam.common = { 'returnmap': '0' }
  895. this.requestParam.data = []
  896. this.requestParam.data[0] = { 'name': 'updateLpplandtlSorts', 'type': 'e',
  897. 'parammaps': { pastureid: evt.pastureid, sort: evt.sort, lppid: evt.id }
  898. }
  899. this.requestParam.data[1] = { 'name': 'insertLppd', 'type': 'e',
  900. 'parammaps': {
  901. pastureid: evt.pastureid, lppid: evt.id, barid: item.barid, barname: item.barname, fpdid: item.id, fttype: item.fttype,
  902. lweight: item.weight, sort: evt.sort, tmrid: evt.tmrid, tmrname: evt.tmrname,
  903. background: item.background, ccountradio: item.ccountradio, cowcount: item.cowcount
  904. }
  905. }
  906. this.requestParam.data[2] = { 'name': 'updateFpdetailUse', 'type': 'e',
  907. 'parammaps': { pastureid: item.pastureid, id: item.id, fttype: item.fttype, lweight: item.weight }
  908. }
  909. const url = 'authdata/ExecDataByConfig'
  910. const data = this.requestParam
  911. postJson(url, data).then(response => {
  912. if (response.msg === 'fail') {
  913. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  914. } else {
  915. this.$notify({ title: '', message: '保存成功', type: 'success', duration: 2000 })
  916. }
  917. this.getCreateList1()
  918. })
  919. },
  920. handleUpdate(row) {
  921. console.log(row)
  922. console.log(this.equipmentList)
  923. this.getDownList()
  924. this.dialogFull = false
  925. this.create.dialogStatus = 'update'
  926. this.create.dialogFormVisible = true
  927. row.tmrid2 = row.tmrid
  928. this.create.temp = Object.assign({}, row)
  929. this.create.temp.mytmrname = row.tmrname
  930. this.create.temp.mytmrid = row.tmrid
  931. this.create.checkBarList = []
  932. console.log(this.create.temp,'this.create.temp')
  933. this.getCreateList1()
  934. },
  935. updateData() {
  936. this.$refs['temp'].validate(valid => {
  937. if (valid) {
  938. this.isokDisable = true
  939. setTimeout(() => {
  940. this.isokDisable = false
  941. }, 1000)
  942. const url = 'authdata/lpplan/edit'
  943. const data = {}
  944. this.create.temp.pastureid = Cookies.get('pastureid')
  945. this.create.temp.times = parseInt(this.create.temp.times)
  946. data.parammaps = this.create.temp
  947. data.parammaps.tmrid = this.create.temp.mytmrid
  948. data.parammaps.tmrname = this.create.temp.mytmrname
  949. postJson(url, data).then(response => {
  950. console.log('新增保存发送参数', this.requestParam)
  951. if (response.msg !== 'fail') {
  952. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  953. this.isDispaly = false
  954. this.dialogFull = false
  955. this.create.dialogFormVisible = false
  956. this.getList()
  957. } else {
  958. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  959. }
  960. })
  961. }
  962. })
  963. },
  964. close() {
  965. if (this.create.dialogStatus == 'create') {
  966. console.log('新增关闭')
  967. this.isokDisable = true
  968. setTimeout(() => {
  969. this.isokDisable = false
  970. }, 1000)
  971. const url = 'authdata/lpplandtl/restore'
  972. const data = {}
  973. data.old = []
  974. data.new = this.create.list2
  975. postJson(url, data).then(response => {
  976. console.log('新增保存发送参数', this.requestParam)
  977. if (response.msg !== 'fail') {
  978. this.isDispaly = false
  979. this.dialogFull = false
  980. this.create.dialogFormVisible = false
  981. this.getList()
  982. }
  983. })
  984. } else {
  985. console.log('编辑关闭')
  986. this.isokDisable = true
  987. setTimeout(() => {
  988. this.isokDisable = false
  989. }, 1000)
  990. const url = 'authdata/lpplandtl/restore'
  991. const data = {}
  992. data.old = this.create.temp.arrList
  993. data.new = this.create.list2
  994. postJson(url, data).then(response => {
  995. console.log('新增保存发送参数', this.requestParam)
  996. if (response.msg !== 'fail') {
  997. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  998. this.isDispaly = false
  999. this.dialogFull = false
  1000. this.create.dialogFormVisible = false
  1001. this.getList()
  1002. } else {
  1003. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1004. }
  1005. })
  1006. }
  1007. },
  1008. changeEquipment(item, fttype, myid) {
  1009. console.log('item==>',item)
  1010. console.log('fttype==>',fttype)
  1011. console.log('myid==>',myid)
  1012. let tclassname = this.equipmentList.find(obj => obj.id == item).tclassname
  1013. let maxstirfeed = this.equipmentList.find(obj => obj.id == item).maxstirfeed
  1014. if(tclassname == '固定式'){
  1015. this.$message({ type: 'error', message: '固定式设备无法撒料,请选择撒料设备', duration: 2000 })
  1016. this.getCreateList2()
  1017. return
  1018. }
  1019. var objList = {}
  1020. for (let i = 0; i < this.create.list2.length; i++) {
  1021. if (this.create.list2[i].fttype == fttype && this.create.list2[i].id == myid) {
  1022. this.create.list2[i].tmrname = this.equipmentList.find(obj => obj.id === item).tname
  1023. objList = this.create.list2[i]
  1024. if(parseFloat(this.create.list2[i].weight) > parseFloat(maxstirfeed)){
  1025. objList.weight = maxstirfeed
  1026. }
  1027. }
  1028. }
  1029. this.requestParam = {}
  1030. this.requestParam.common = {
  1031. 'returnmap': '0'
  1032. }
  1033. this.requestParam.data = []
  1034. this.requestParam.data[0] = {
  1035. 'name': 'updateLppd',
  1036. 'type': 'e',
  1037. 'parammaps': {
  1038. pastureid: this.create.temp.pastureid,
  1039. lppid: this.create.temp.id,
  1040. barid: objList.barid,
  1041. barname: objList.barname,
  1042. fpdid: objList.fpdid,
  1043. fttype: objList.fttype,
  1044. lweight: objList.weight,
  1045. sort: objList.sort,
  1046. tmrid: objList.tmrid,
  1047. tmrname: objList.tmrname,
  1048. background: objList.background,
  1049. id: objList.id
  1050. }
  1051. }
  1052. ExecDataByConfig(this.requestParam).then(response => {
  1053. console.log('编辑保存发送参数', this.requestParam)
  1054. if (response.msg === 'fail') {
  1055. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1056. } else {
  1057. this.getCreateList2()
  1058. this.$notify({ title: '', message: '保存成功', type: 'success', duration: 2000 })
  1059. }
  1060. })
  1061. },
  1062. // 减少车次
  1063. handleReduceTrains() {
  1064. if (this.selectList.length == 0) {
  1065. this.$message({ type: 'error', message: '请选择车次', duration: 2000 })
  1066. return false
  1067. } else {
  1068. // 减少对应车次
  1069. for (let i = 0; i < this.selectList.length; i++) {
  1070. if (this.selectList[i].arrList.length > 0) {
  1071. this.$message({ type: 'error', message: '本车次已添加栏舍不可删除', duration: 2000 })
  1072. return false
  1073. }
  1074. }
  1075. MessageBox.confirm('是否确认删除此信息?', {
  1076. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1077. }).then(() => {
  1078. console.log(this.selectList)
  1079. this.requestParam = {}
  1080. this.requestParam.common = { 'returnmap': '0' }
  1081. this.requestParam.data = []
  1082. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  1083. this.requestParam.data[0].children = []
  1084. this.requestParam.data[0].children[0] = {
  1085. 'name': 'deleteLpp', 'type': 'e', 'parammaps': { id: '@insertSpotList.id', pastureid: '@insertSpotList.pastureid' }
  1086. }
  1087. ExecDataByConfig(this.requestParam).then(response => {
  1088. console.log('删除保存发送参数', this.requestParam)
  1089. if (response.msg === 'fail') {
  1090. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  1091. } else {
  1092. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  1093. this.table.getdataListParm.parammaps.refresh = 1
  1094. this.getList()
  1095. }
  1096. })
  1097. })
  1098. }
  1099. },
  1100. // 自动生成
  1101. handleAutomaticGeneration() {
  1102. this.dialogFull = false
  1103. this.automaticGeneration.dialogStatus = 'automaticGeneration'
  1104. this.automaticGeneration.dialogFormVisible = true
  1105. },
  1106. continueData(item) {
  1107. if (item == 0) {
  1108. console.log('点击继续生成')
  1109. this.requestParam = {}
  1110. this.requestParam.pastureid = Cookies.get('pastureid')
  1111. this.requestParam.type = 0
  1112. const url = 'authdata/autogeneration'
  1113. const data = this.requestParam
  1114. postJson(url, data).then(response => {
  1115. console.log('新增保存发送参数', this.requestParam)
  1116. if (response.msg !== 'fail') {
  1117. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1118. this.automaticGeneration.dialogFormVisible = false
  1119. this.getIsDisplay()
  1120. } else {
  1121. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1122. }
  1123. })
  1124. } else {
  1125. console.log('点击重新生成')
  1126. MessageBox.confirm('重新生成计划会将原有计划清空再生成,是否确认重新生成?', {
  1127. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1128. }).then(() => {
  1129. this.automaticGeneration.dialogFormVisible = false
  1130. this.requestParam = {}
  1131. this.requestParam.pastureid = Cookies.get('pastureid')
  1132. this.requestParam.type = 1
  1133. const url = 'authdata/autogeneration'
  1134. const data = this.requestParam
  1135. postJson(url, data).then(response => {
  1136. console.log('新增保存发送参数', this.requestParam)
  1137. if (response.msg !== 'fail') {
  1138. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1139. this.automaticGeneration.dialogFormVisible = false
  1140. this.getIsDisplay()
  1141. } else {
  1142. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1143. }
  1144. })
  1145. }).catch(() => {
  1146. this.$message({ type: 'info', message: '已取消重新生成' })
  1147. })
  1148. }
  1149. },
  1150. handleChangeOrder() {
  1151. console.log('更改顺序')
  1152. this.isOrder = false
  1153. this.rowDrop()
  1154. },
  1155. // 行拖拽
  1156. rowDrop() {
  1157. console.log(document.querySelector('#table .el-table__body-wrapper tbody'))
  1158. const tbody = document.querySelector('#table .el-table__body-wrapper tbody')
  1159. const that = this
  1160. var sortable = Sortable.create(tbody, {
  1161. disabled: that.dropState,
  1162. onChoose({ newIndex, oldIndex }) {
  1163. console.log(that.isOrder, 'that.isOrder == false')
  1164. console.log(that.dropState, 'that.dropState')
  1165. if (that.dropState == true || that.isOrder == true) {
  1166. sortable.destroy()
  1167. }
  1168. },
  1169. onEnd({ newIndex, oldIndex }) {
  1170. const currRow = that.table.list.splice(oldIndex, 1)[0]
  1171. that.table.list.splice(newIndex, 0, currRow)
  1172. console.log('索引', newIndex)
  1173. console.log('拖动数据', currRow)
  1174. console.log('上', that.table.list[newIndex - 1])
  1175. console.log('下', that.table.list[newIndex + 1])
  1176. }
  1177. })
  1178. },
  1179. saveChangeOrder() {
  1180. // 保存顺序
  1181. var sortArr = []
  1182. for (let i = 0; i < this.table.list.length; i++) {
  1183. var obj = {}
  1184. obj.sort = i + 1
  1185. obj.id = this.table.list[i].id
  1186. obj.pastureid = this.table.list[i].pastureid
  1187. sortArr.push(obj)
  1188. }
  1189. const url = 'authdata/trains'
  1190. const data = sortArr
  1191. postJson(url, data).then(response => {
  1192. if (response.msg === 'fail') {
  1193. this.$notify({ title: '顺序切换失败', message: response.data, type: 'warning', duration: 2000 })
  1194. } else {
  1195. this.$notify({ title: '', message: '顺序切换成功', type: 'success', duration: 2000 })
  1196. this.table.getdataListParm.parammaps.refresh = 1
  1197. this.getList()
  1198. this.isOrder = true
  1199. }
  1200. })
  1201. },
  1202. cancelChangeOrder() {
  1203. console.log('取消顺序')
  1204. this.table.getdataListParm.parammaps.refresh = 1
  1205. this.getList()
  1206. this.isOrder = true
  1207. },
  1208. handleTakeEffect() {
  1209. if (this.selectList.length == 0) {
  1210. this.$message({ type: 'error', message: '请选择车次信息', duration: 2000 })
  1211. } else {
  1212. MessageBox.confirm('当前选中' + this.selectList.length + '条信息,是否生效?', {
  1213. confirmButtonText: '确认',
  1214. cancelButtonText: '取消',
  1215. type: 'warning'
  1216. }).then(() => {
  1217. for (let i = 0; i < this.selectList.length; i++) {
  1218. this.selectList[i].sel = 1
  1219. }
  1220. console.log('生效', this.selectList)
  1221. this.requestParam.common = { 'returnmap': '0' }
  1222. this.requestParam.data = []
  1223. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  1224. this.requestParam.data[0].children = []
  1225. this.requestParam.data[0].children[0] = {
  1226. 'name': 'updatelpplanEnable', 'type': 'e', 'parammaps': { sel: '@insertSpotList.sel', id: '@insertSpotList.id', pastureid: '@insertSpotList.pastureid' }
  1227. }
  1228. ExecDataByConfig(this.requestParam).then(response => {
  1229. console.log('生效保存发送参数', this.requestParam)
  1230. if (response.msg === 'fail') {
  1231. this.$notify({ title: '生效失败', message: response.data, type: 'warning', duration: 2000 })
  1232. } else {
  1233. this.$notify({ title: '', message: '生效成功', type: 'success', duration: 2000 })
  1234. this.table.getdataListParm.parammaps.refresh = 1
  1235. this.getList()
  1236. }
  1237. })
  1238. })
  1239. }
  1240. },
  1241. handleDisable() {
  1242. if (this.selectList.length == 0) {
  1243. this.$message({ type: 'error', message: '请选择车次信息', duration: 2000 })
  1244. } else {
  1245. MessageBox.confirm('当前选中' + this.selectList.length + '条信息,是否禁用?', {
  1246. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1247. }).then(() => {
  1248. for (let i = 0; i < this.selectList.length; i++) {
  1249. this.selectList[i].sel = 0
  1250. }
  1251. console.log('禁用', this.selectList)
  1252. this.requestParam.common = { 'returnmap': '0' }
  1253. this.requestParam.data = []
  1254. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  1255. this.requestParam.data[0].children = []
  1256. this.requestParam.data[0].children[0] = {
  1257. 'name': 'updatelpplanEnable',
  1258. 'type': 'e',
  1259. 'parammaps': { sel: '@insertSpotList.sel', id: '@insertSpotList.id', pastureid: '@insertSpotList.pastureid' }
  1260. }
  1261. ExecDataByConfig(this.requestParam).then(response => {
  1262. console.log('禁用保存发送参数', this.requestParam)
  1263. if (response.msg === 'fail') {
  1264. this.$notify({ title: '禁用失败', message: response.data, type: 'warning', duration: 2000 })
  1265. } else {
  1266. this.$notify({ title: '禁用成功', message: '禁用成功', type: 'success', duration: 2000 })
  1267. this.table.getdataListParm.parammaps.refresh = 1
  1268. this.getList()
  1269. }
  1270. })
  1271. })
  1272. }
  1273. },
  1274. // 历史记录
  1275. handleHistoryRecord() {
  1276. console.log('点击历史记录')
  1277. this.dialogFull = false
  1278. this.historyRecord.dialogStatus = 'historyRecord'
  1279. this.historyRecord.dialogFormVisible = true
  1280. const vue = this
  1281. var myComponent = () => import('./historyRecord.vue')
  1282. return vue.historyRecord.myComponent = myComponent
  1283. }
  1284. }
  1285. }
  1286. </script>
  1287. <style lang="scss" scoped>
  1288. .list{width: 60px;display: inline-block;margin: 5px 5px;text-align: center;
  1289. .tmrname{
  1290. width:100%;padding: 5px 5px;overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  1291. }
  1292. }
  1293. .fenceHouse {
  1294. height: 130px;
  1295. background: #fff;
  1296. position: relative;
  1297. ::-webkit-scrollbar {
  1298. width: 7px;
  1299. height: 7px;
  1300. background-color: #F5F5F5;
  1301. }
  1302. ::-webkit-scrollbar-track {
  1303. box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
  1304. -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
  1305. border-radius: 10px;
  1306. background-color: #F5F5F5;
  1307. }
  1308. ::-webkit-scrollbar-thumb {
  1309. border-radius: 10px;
  1310. box-shadow: inset 0 0 6px rgba(0, 0, 0, .1);
  1311. -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, .1);
  1312. background-color: #c8c8c8;
  1313. }
  1314. .fenceHouseList {
  1315. position: absolute;
  1316. width: 100%;
  1317. margin: 0 0;
  1318. height: 130px;
  1319. list-style: none;
  1320. padding: 0 0;
  1321. overflow: auto;
  1322. font-size: 12px;
  1323. .fenceHouseTitle {
  1324. float: left;
  1325. width: 105px;
  1326. white-space: nowrap;
  1327. overflow: hidden;
  1328. text-overflow: ellipsis;
  1329. margin: 5px 5px;
  1330. border-radius: 7px;
  1331. text-align: center;
  1332. color: #000;
  1333. height: 36px;
  1334. line-height: 36px;
  1335. }
  1336. li {
  1337. text-align: center;
  1338. color: #fff;
  1339. .barname {
  1340. display: block;
  1341. width: 100%;
  1342. overflow: hidden;
  1343. text-overflow: ellipsis;
  1344. white-space: nowrap;
  1345. }
  1346. .barWeight{
  1347. display: block;
  1348. line-height: 18px;
  1349. height: 18px;
  1350. color: #000;
  1351. width: 100%;
  1352. margin: 0 auto;
  1353. }
  1354. .colorBlock{
  1355. width: 88px;float: left;margin:5px 5px;height: 36px;
  1356. }
  1357. }
  1358. }
  1359. }
  1360. </style>
  1361. <style lang="scss" >
  1362. .spreadingMaterial {
  1363. height: 200px;
  1364. ::-webkit-scrollbar {
  1365. width: 7px;
  1366. height: 7px;
  1367. background-color: #F5F5F5;
  1368. }
  1369. ::-webkit-scrollbar-track {
  1370. box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
  1371. -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
  1372. border-radius: 10px;
  1373. background-color: #F5F5F5;
  1374. }
  1375. ::-webkit-scrollbar-thumb {
  1376. border-radius: 10px;
  1377. box-shadow: inset 0 0 6px rgba(0, 0, 0, .1);
  1378. -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, .1);
  1379. background-color: #c8c8c8;
  1380. }
  1381. .spreadingMaterialList{height: 100%;overflow: auto;}
  1382. .list-group-item2 {
  1383. width: 220px;
  1384. height: 50px;
  1385. overflow: hidden;
  1386. float: left;
  1387. margin: 5px 5px;
  1388. position: relative;
  1389. color: #fff;
  1390. .arr-t {
  1391. height: 50px;
  1392. border-radius: 5px 5px;
  1393. }
  1394. .arr-l {
  1395. float: left;
  1396. width: 60px;
  1397. height: 50px;
  1398. overflow: hidden;
  1399. border-radius: 5px 50% 50% 5px;
  1400. .arr-l-t {
  1401. position: relative;
  1402. .arr-l-t-t {
  1403. width: 0;
  1404. height: 0;
  1405. border-top: 26px solid #3479f2;
  1406. border-right: 26px solid transparent;
  1407. }
  1408. .arr-l-t-b {
  1409. position: absolute;
  1410. top: 4px;
  1411. left: 1px;
  1412. color: #fff;
  1413. width: 10px;
  1414. height: 10px;
  1415. .el-input--suffix {
  1416. opacity: 0;
  1417. .el-input__inner {
  1418. height: 10px;
  1419. }
  1420. }
  1421. }
  1422. }
  1423. .arr-l-b {
  1424. width: 45px;
  1425. position: absolute;
  1426. top: 15px;
  1427. left: 10px;
  1428. color: #fff !important;
  1429. font-size: 12px;
  1430. .tmrname {
  1431. width: 100%;
  1432. overflow: hidden;
  1433. text-overflow: ellipsis;
  1434. white-space: nowrap;
  1435. }
  1436. }
  1437. }
  1438. .arr-c {
  1439. position: absolute;
  1440. top: 0px;
  1441. left: 0;
  1442. }
  1443. .arr-r {
  1444. float: right;
  1445. width: 160px;
  1446. height: 50px;
  1447. overflow: hidden;
  1448. line-height: 50px;
  1449. .arr-r-l {
  1450. float: left;
  1451. width: 70px;
  1452. .barname {
  1453. width: 95%;
  1454. overflow: hidden;
  1455. text-overflow: ellipsis;
  1456. white-space: nowrap;
  1457. font-size: 14px;
  1458. text-align: center;
  1459. }
  1460. }
  1461. .arr-r-c {
  1462. float: left;
  1463. width: 10px;
  1464. }
  1465. .arr-r-r {
  1466. float: left;
  1467. width: 65px;
  1468. .weight {
  1469. width: 100%;
  1470. overflow: hidden;
  1471. text-overflow: ellipsis;
  1472. white-space: nowrap;
  1473. font-size: 14px;
  1474. }
  1475. }
  1476. }
  1477. }
  1478. }
  1479. </style>