index.vue 60 KB

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