index.vue 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186
  1. <template>
  2. <div class="app-container">
  3. <div class="operation">
  4. <el-button v-if="isRoleEdit" class="success" icon="el-icon-plus" style="float: left;" @click="handleCreate1">设置推料时间</el-button>
  5. <el-button v-if="isRoleEdit" class="success" icon="el-icon-plus" style="float: left;" @click="handleCreate2">设置允许误差时间</el-button>
  6. <el-button v-if="isRoleEdit" class="success" icon="el-icon-open" style="float: left;" @click="handleTakeEffect">启用</el-button>
  7. <el-button v-if="isRoleEdit" class="danger" icon="el-icon-turn-off" style="float: left;" @click="handleDisable">禁用</el-button>
  8. <el-button v-if="isRoleEdit" class="success" style="float: left;" @click="handleCheck">校验</el-button>
  9. <el-button class="import" style="float: right;" @click="handleHistoryRecords">历史记录</el-button>
  10. </div>
  11. <div class="table">
  12. <el-table
  13. :key="table.tableKey"
  14. ref="table"
  15. v-loading="table.listLoading"
  16. element-loading-text="给我一点时间"
  17. :data="table.list"
  18. border
  19. fit
  20. highlight-current-row
  21. style="width: 100%;"
  22. :row-style="rowStyle"
  23. :cell-style="cellStyle"
  24. class="elTable table-fixed"
  25. :max-height="myHeight"
  26. @header-click="headerClick"
  27. @cell-click="cellClick"
  28. @selection-change="handleSelect"
  29. @cell-dblclick="celldblclick"
  30. >
  31. <el-table-column type="selection" width="50" />
  32. <el-table-column :key="1" label="序号" align="center" type="index" width="50px" class-name="small-padding fixed-width" fixed="left" />
  33. <el-table-column label="栏舍名称" min-width="100px" align="center" class-name="small-padding fixed-width" fixed="left">
  34. <template slot-scope="scope">
  35. <span >{{ scope.row.bname }}</span>
  36. </template>
  37. </el-table-column>
  38. <el-table-column :key="2" label="推料车名称" min-width="70px" align="center">
  39. <template slot-scope="scope">
  40. <span v-if="scope.row.NoEdit">{{ scope.row.tmrname }}</span>
  41. <el-select v-if="scope.row.Edit" v-model="scope.row.tmrid" filterable placeholder="推料车名称" class="filter-item" style="width:95%;padding:10px 0;" @change="changeTmrCode(scope.$index, scope.row, $event)">
  42. <el-option v-for="item in tmrCodeList" :key="item.id" :label="item.name" :value="item.id" />
  43. </el-select>
  44. </template>
  45. </el-table-column>
  46. <el-table-column :key="3" label="推料车编号" min-width="90px" align="center">
  47. <template slot-scope="scope">
  48. <span >{{ scope.row.tmrcode }}</span>
  49. </template>
  50. </el-table-column>
  51. <el-table-column :key="4" label="推料时间(每天)" min-width="85px" align="center">
  52. <template slot-scope="scope">
  53. <span v-if="scope.row.NoEdit">{{ scope.row.times }}</span>
  54. <el-tag v-if="scope.row.Edit" v-for="tag in scope.row.timesArr" :key="tag" closable @close="tag_close(scope.$index, scope.row, tag)" type="success">{{tag}}</el-tag>
  55. <el-time-picker v-if="scope.row.Edit"
  56. v-model="scope.row.times"
  57. :picker-options="{ selectableRange: '00:00:00 - 23:59:59' }"
  58. value-format="HH:mm"
  59. @change="change_time(scope.$index, scope.row, $event)" format="HH:mm"
  60. placeholder="任意时间点">
  61. </el-time-picker>
  62. </template>
  63. </el-table-column>
  64. <el-table-column :key="5" label="允许误差时间(分钟)" min-width="85px" align="center">
  65. <template slot-scope="scope">
  66. <span v-if="scope.row.NoEdit">{{ scope.row.allowableerror }}</span>
  67. <el-input v-if="scope.row.Edit" v-model="scope.row.allowableerror" type="number" style="width:95%;padding:10px 0;" />
  68. </template>
  69. </el-table-column>
  70. <el-table-column label="是否启用" min-width="90px" align="center">
  71. <template slot-scope="scope">
  72. <el-switch v-model="scope.row.enable" :disabled="scope.row.NoEdit==true" active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" />
  73. </template>
  74. </el-table-column>
  75. <el-table-column label="操作" align="center" width="80" class-name="small-padding fixed-width" fixed="right">
  76. <template slot-scope="{row}">
  77. <el-button v-if="row.isUpdate && isRoleEdit" class="miniSuccess" icon="el-icon-edit-outline" @click="handleUpdate(row)" />
  78. <el-button v-if="row.isUpdateSave && isRoleEdit" :disabled="isokDisable" icon="el-icon-folder-checked" class="miniSuccess" @click="updateData(row)" />
  79. <span v-if="row.isUpdateSave && isRoleEdit" class="centerSpan">|</span>
  80. <el-button v-if="row.isUpdateSave && isRoleEdit" class="minCancel" icon="el-icon-close" @click="updateCancel(row)" />
  81. <!-- <el-button v-if="isRoleEdit" class="miniDanger" icon="el-icon-delete" @click="handleRowDelete(row)" /> -->
  82. </template>
  83. </el-table-column>
  84. </el-table>
  85. <!-- <pagination v-show="table.total>=0" :total="table.total" :page.sync="table.getdataListParm.offset" :limit.sync="table.getdataListParm.pagecount" @pagination="getList" /> -->
  86. </div>
  87. <el-dialog :fullscreen="dialogFull" :visible.sync="create1.dialogFormVisible" :close-on-click-modal="false" width="50%">
  88. <template slot="title">
  89. <div class="avue-crud__dialog__header">
  90. <span class="el-dialog__title">
  91. <span style="display:inline-block;width:3px;height:20px;margin-right:5px; float: left;margin-top:2px" />
  92. 推料计划
  93. </span>
  94. <div class="avue-crud__dialog__menu" @click="dialogFull? dialogFull=false: dialogFull=true">
  95. <svg-icon v-if="dialogFull" icon-class="exit-fullscreen" />
  96. <svg-icon v-else icon-class="fullscreen" />
  97. </div>
  98. </div>
  99. </template>
  100. <div class="app-add">
  101. <el-form ref="temp" :rules="create1.rules" :model="create1.temp" label-position="right" label-width="155px" style="width: 100%;margin:0 auto 50px">
  102. <el-row>
  103. <el-col :span="6">
  104. <el-form-item label="设置时间:" prop="useinbarid">
  105. <el-time-picker
  106. v-model="timevalue1"
  107. :picker-options="{ selectableRange: '00:00:00 - 23:59:59' }"
  108. value-format="HH:mm"
  109. @change="change_time1" format="HH:mm"
  110. placeholder="任意时间点">
  111. </el-time-picker>
  112. </el-form-item>
  113. </el-col>
  114. </el-row>
  115. <el-row>
  116. <el-tag v-for="tag in timetags1" :key="tag.name" closable @close="tag_close1(tag)" type="success">{{tag}}</el-tag>
  117. </el-row>
  118. </el-form>
  119. <div slot="footer" class="dialog-footer">
  120. <el-button class="cancelClose" @click="create1.dialogFormVisible = false;getList()">关闭</el-button>
  121. <el-button class="save" @click="create_sure1">确认</el-button>
  122. </div>
  123. </div>
  124. </el-dialog>
  125. <el-dialog :fullscreen="dialogFull" :visible.sync="create2.dialogFormVisible" :close-on-click-modal="false" width="50%">
  126. <template slot="title">
  127. <div class="avue-crud__dialog__header">
  128. <span class="el-dialog__title">
  129. <span style="display:inline-block;width:3px;height:20px;margin-right:5px; float: left;margin-top:2px" />
  130. 允许误差时间
  131. </span>
  132. <div class="avue-crud__dialog__menu" @click="dialogFull? dialogFull=false: dialogFull=true">
  133. <svg-icon v-if="dialogFull" icon-class="exit-fullscreen" />
  134. <svg-icon v-else icon-class="fullscreen" />
  135. </div>
  136. </div>
  137. </template>
  138. <div class="app-add">
  139. <el-form ref="temp" :rules="create2.rules" :model="create2.temp" label-position="right" label-width="155px" style="width: 100%;margin:0 auto 50px">
  140. <el-row>
  141. <el-col :span="12">
  142. <el-form-item label="允许误差时间(分钟):" prop="allowableerror">
  143. <el-input ref="time" v-model="create2.temp.allowableerror" class="filter-item" placeholder="请输入" type="text" />
  144. </el-form-item>
  145. </el-col>
  146. </el-row>
  147. </el-form>
  148. <div slot="footer" class="dialog-footer">
  149. <el-button class="cancelClose" @click="create2.dialogFormVisible = false;getList()">关闭</el-button>
  150. <el-button class="save" @click="create_sure2">确认</el-button>
  151. </div>
  152. </div>
  153. </el-dialog>
  154. <!-- 校验 -->
  155. <el-dialog title="提示" :destroy-on-close="true" :visible.sync="check.dialogFormVisible" :close-on-click-modal="false" width="30%">
  156. <div class="check">
  157. <p v-if="check.temp.isDistribution1 == '0'">未启用分配如下:</p>
  158. <p v-else>当前栏舍已分配完</p>
  159. {{ check.temp.banme1 }}
  160. <p v-if="check.temp.isDistribution2 == '0'">未启用栏舍如下:</p>
  161. <p v-else>当前栏舍已全部启用</p>
  162. {{ check.temp.banme2 }}
  163. </div>
  164. <div slot="footer" class="dialog-footer" style="bottom: 10px;">
  165. <el-button class="save" @click="check.dialogFormVisible=false;">确认</el-button>
  166. </div>
  167. </el-dialog>
  168. <!-- 历史记录 -->
  169. <el-dialog :fullscreen="dialogFull" :destroy-on-close="true" :visible.sync="history.dialogFormVisible" :close-on-click-modal="false" width="90%">
  170. <template slot="title">
  171. <div class="avue-crud__dialog__header">
  172. <span class="el-dialog__title">
  173. <span style="display:inline-block;width:3px;height:20px;margin-right:5px; float: left;margin-top:2px" />
  174. 历史记录
  175. </span>
  176. <div class="avue-crud__dialog__menu" @click="dialogFull? dialogFull=false: dialogFull=true">
  177. <svg-icon v-if="dialogFull" icon-class="exit-fullscreen" />
  178. <svg-icon v-else icon-class="fullscreen" />
  179. </div>
  180. </div>
  181. </template>
  182. <div class="app-history">
  183. <div class="search">
  184. <el-date-picker v-model="history.getdataListParm.parammaps.changeTime" type="date" placeholder="请选择历史记录时间" :clearable="false" style="width: 180px;" format="yyyy-MM-dd" value-format="yyyy-MM-dd" @change="changeDate" />
  185. <!-- <el-button class="successBorder" @click="handleApplication">应用</el-button> -->
  186. </div>
  187. <div class="table">
  188. <el-table
  189. :key="history.tableKey"
  190. v-loading="history.listLoading"
  191. element-loading-text="给我一点时间"
  192. :data="history.list"
  193. border
  194. fit
  195. highlight-current-row
  196. style="width: 100%;"
  197. :row-style="rowStyle"
  198. :cell-style="cellStyle"
  199. class="elTable table-fixed"
  200. >
  201. <el-table-column label="栏舍名称" min-width="130px" align="center">
  202. <template slot-scope="scope">
  203. <span>{{ scope.row.barname }}</span>
  204. </template>
  205. </el-table-column>
  206. <el-table-column label="推料车名称" prop="weight" min-width="130px" align="center">
  207. <template slot-scope="scope">
  208. <span>{{ scope.row.tmrname }}</span>
  209. </template>
  210. </el-table-column>
  211. <el-table-column label="推料车编号" prop="weight" min-width="130px" align="center">
  212. <template slot-scope="scope">
  213. <span>{{ scope.row.tmrcode }}</span>
  214. </template>
  215. </el-table-column>
  216. <el-table-column label="推料时间(每天)" min-width="130px" align="center">
  217. <template slot-scope="scope">
  218. <span>{{ scope.row.tisms }}</span>
  219. </template>
  220. </el-table-column>
  221. <el-table-column label="误差时间(分钟)" min-width="180px" align="center">
  222. <template slot-scope="scope">
  223. <span>{{ scope.row.allowableerror }}</span>
  224. </template>
  225. </el-table-column>
  226. </el-table>
  227. <pagination v-show="history.total>0" :total="history.total" :page.sync="history.getdataListParm.offset" :limit.sync="history.getdataListParm.pagecount" @pagination="getHistoryList" />
  228. </div>
  229. </div>
  230. <div slot="footer" class="dialog-footer">
  231. <el-button class="cancelClose cancelClose1" @click="history.dialogFormVisible = false; ">关闭</el-button>
  232. </div>
  233. </el-dialog>
  234. </div>
  235. </template>
  236. <script>
  237. import { GetDataByName, postJson, GetDataByNames, compareSort, ExecDataByConfig, failproccess, PostDataByName, formatNum, checkButtons, checkDates } from '@/api/common'
  238. import Pagination from '@/components/Pagination'
  239. import Pagination2 from '@/components/Pagination2'
  240. import { parseTime, json2excel, handleTableSpan, handleObjectSpanMethod } from '@/utils/index.js'
  241. import { MessageBox } from 'element-ui'
  242. import Cookies from 'js-cookie'
  243. import axios from 'axios'
  244. import { getToken } from '@/utils/auth'
  245. export default {
  246. inject: ['reload'],
  247. name: 'PushMaterialPlan',
  248. components: { Pagination, Pagination2 },
  249. data() {
  250. return {
  251. history: {
  252. dialogFormVisible: false,
  253. dialogStatus: '',
  254. temp: {},
  255. rules: {},
  256. tableKey: 0,
  257. list: [],
  258. total: 0,
  259. listLoading: true,
  260. getdataDateParm: {
  261. name: 'getPushingHistoryDate',
  262. page: 1,
  263. offset: 1,
  264. pagecount: 10,
  265. returntype: 'Map',
  266. parammaps: {
  267. pastureid: Cookies.get('pastureid')
  268. }
  269. },
  270. getdataListParm: {
  271. name: 'getPushingHistory',
  272. page: 1,
  273. offset: 1,
  274. pagecount: 10,
  275. returntype: 'Map',
  276. parammaps: {
  277. pastureid: Cookies.get('pastureid'),
  278. changeTime: ''
  279. }
  280. }
  281. },
  282. tmrCodeList:[
  283. // {Code: "001", id: 46, name: "一号推料车"},
  284. // {Code: "002", id: 47, name: "二号推料车"}
  285. ],
  286. table: {
  287. getdataListParm: {
  288. name: 'getPushingList',
  289. page: 1,
  290. offset: 1,
  291. pagecount: '',
  292. returntype: 'Map',
  293. parammaps: {
  294. pastureid: Cookies.get('pastureid'),
  295. }
  296. },
  297. tableKey: 0,
  298. list: [],
  299. total: 0,
  300. listLoading: true,
  301. temp: {},
  302. },
  303. create1: {
  304. dialogFormVisible: false,
  305. dialogStatus: '',
  306. temp: { pastureid: Cookies.get('pastureid'), fname: ''},
  307. rules: {
  308. // fname: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  309. // fclassid: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  310. // feedcode: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }]
  311. }
  312. },
  313. create2: {
  314. dialogFormVisible: false,
  315. dialogStatus: '',
  316. temp: { pastureid: Cookies.get('pastureid'), allowableerror: ''},
  317. rules: {
  318. // fname: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  319. // fclassid: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  320. // feedcode: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }]
  321. }
  322. },
  323. check: {
  324. dialogFormVisible: false,
  325. dialogStatus: '',
  326. getCheckParm: {
  327. name: 'checkRemainplan',
  328. page: 1,
  329. offset: 1,
  330. pagecount: 10,
  331. returntype: 'Map',
  332. parammaps: {
  333. pastureid: Cookies.get('pastureid')
  334. }
  335. },
  336. temp: {
  337. bnames: '',
  338. isDistribution1: '',
  339. isDistribution2: ''
  340. }
  341. },
  342. timevalue1: new Date(2022, 9, 10, 18, 40),
  343. timetags1: [],
  344. dialogFull: false,
  345. isRoleEdit: [],
  346. headerList: [],
  347. pickerMinDate: '',
  348. rules: {
  349. cowclassid: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }]
  350. },
  351. selectList: [],
  352. requestParam: {},
  353. download: {
  354. getdataListParm: {
  355. name: 'getFPList',
  356. page: 1,
  357. offset: 1,
  358. pagecount: 0,
  359. returntype: 'Map',
  360. parammaps: {
  361. pastureid: Cookies.get('pastureid'),
  362. enable: ''
  363. }
  364. },
  365. list: []
  366. },
  367. spanObj: {},
  368. mergekeys: ['barname', 'sumweight'],
  369. isShowDialog: false,
  370. isokDisable: false,
  371. rowStyle: { maxHeight: 30 + 'px', height: 30 + 'px' },
  372. cellStyle: { padding: 0 + 'px' },
  373. myHeight: document.documentElement.clientHeight - 85 - 140,
  374. oldRowList:{},
  375. }
  376. },
  377. computed: {
  378. },
  379. created() {
  380. this.getButtons()
  381. this.getTMRlist()
  382. this.getList()
  383. },
  384. methods: {
  385. getButtons() {
  386. const Edit = 'DhedFormula'
  387. const isRoleEdit = checkButtons(JSON.parse(sessionStorage.getItem('buttons')), Edit)
  388. this.isRoleEdit = isRoleEdit
  389. },
  390. getTMRlist() {
  391. var send_data = {"name":"getPushingTmrList","page":1,"offset":1,"pagecount":"","returntype":"Map","parammaps":{"dictname":"推料车"}}
  392. GetDataByName(send_data).then(response => {
  393. if (response.data.list !== null) {
  394. this.tmrCodeList = response.data.list
  395. } else {
  396. this.tmrCodeList = []
  397. }
  398. console.log("tmrCodeList",this.tmrCodeList)
  399. })
  400. },
  401. getList() {
  402. this.table.listLoading = true
  403. GetDataByName(this.table.getdataListParm).then(response => {
  404. console.log('table数据', response.data.list)
  405. if (response.data.list !== null) {
  406. for (let i = 0; i < response.data.list.length; i++) {
  407. this.$set(response.data.list[i], 'Edit', false) // 编辑
  408. this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
  409. this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
  410. this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
  411. }
  412. response.data.list.forEach(function(item){
  413. if(item.times !== ""){
  414. item.timesArr = item.times.split(',')
  415. }else{
  416. item.timesArr = []
  417. }
  418. })
  419. // console.log(response.data.list, sumr)
  420. this.table.list = response.data.list
  421. console.log(this.table.list, 'this.table.list')
  422. this.table.pageNum = response.data.pageNum
  423. this.table.pageSize = response.data.pageSize
  424. this.table.total = response.data.total
  425. } else {
  426. this.table.list = []
  427. }
  428. setTimeout(() => {
  429. this.table.listLoading = false
  430. }, 100)
  431. })
  432. },
  433. // 推料车
  434. changeTmrCode(index,row,item) {
  435. console.log("推料车:====",index,row,item)
  436. var Code = this.tmrCodeList.find(obj => obj.id === row.tmrid).Code
  437. var itemName = this.tmrCodeList.find(obj => obj.id === row.tmrid).name
  438. console.log( "推料车编号:====",Code , itemName)
  439. this.table.list[index].tmrcode = Code
  440. this.table.list[index].tmrname = itemName
  441. },
  442. // 新增
  443. handleCreate1() {
  444. console.log('点击了新增')
  445. if (this.selectList.length == 0) {
  446. this.$message({ type: 'error', message: '请选择推料信息', duration: 2000 })
  447. } else {
  448. this.resetTemp1()
  449. this.dialogFull = false
  450. this.create1.dialogStatus = 'create'
  451. this.create1.dialogFormVisible = true
  452. }
  453. },
  454. resetTemp1() {
  455. this.timetags1 = []
  456. },
  457. create_sure1(){
  458. console.log('timetags1-----',this.timetags1)
  459. console.log('selectList-----',this.selectList)
  460. var timeArrRea = this.timetags1
  461. var selectArr = this.selectList
  462. var idsArr = []
  463. selectArr.forEach(function(item){
  464. idsArr.push(item.id)
  465. })
  466. var timeIdArr = []
  467. selectArr.forEach(function(item){
  468. timeArrRea.forEach(function(items){
  469. timeIdArr.push({"time":items,"tmrname":item.tmrname,"tmrid":item.tmrid,"id":item.id})
  470. })
  471. })
  472. console.log("timeIdArr",timeIdArr)
  473. var send_data = {
  474. "common":{"returnmap":"0"},
  475. "data":[
  476. {
  477. "name":"checkPushing",
  478. "resultmaps":{
  479. "list":timeIdArr
  480. },
  481. "children":[
  482. {
  483. "name":"checkPushing","type":"e","parammaps": {"tmrname":"@checkPushing.tmrname","tmrid":"@checkPushing.tmrid","id":"@checkPushing.id","time":"@checkPushing.time","type":0}
  484. }
  485. ]
  486. }
  487. ]}
  488. var send_data2 = {
  489. "common":{"returnmap":"0"},
  490. "data":[
  491. {"name":"insertPushingHistory","type":"e","parammaps":{"ids":idsArr.join(","),"pastureid":Cookies.get('pastureid')}},
  492. {
  493. "name":"delPushingDetailByIds",
  494. "type":"e",
  495. "parammaps":{"ids":idsArr.join(",")}
  496. },
  497. {
  498. "name":"insertPushingDetail",
  499. "resultmaps":{
  500. "list":timeIdArr
  501. },
  502. "children":[{"name":"insertPushingDetailByPushingId","type":"e","parammaps":
  503. {"pastureid":Cookies.get('pastureid'),"id":"@insertPushingDetail.id","time":"@insertPushingDetail.time","type":0}}]}
  504. ]}
  505. checkDates(send_data).then(response => {
  506. console.log(response)
  507. if (response.data === true) {
  508. ExecDataByConfig(send_data2).then(response => {
  509. console.log('设置推料', send_data2)
  510. console.log('设置推料', response)
  511. if (response.msg === 'fail') {
  512. this.$notify({ title: '设置失败', message: response.data, type: 'warning', duration: 2000 })
  513. } else {
  514. this.$notify({ title: '设置成功', message: '设置成功', type: 'success', duration: 2000 })
  515. this.create1.dialogFormVisible = false
  516. this.getList()
  517. }
  518. })
  519. } else {
  520. this.$notify({ title: '设置失败', message: response.data, type: 'warning', duration: 2000 })
  521. }
  522. })
  523. },
  524. handleCreate2() {
  525. if (this.selectList.length == 0) {
  526. this.$message({ type: 'error', message: '请选择推料信息', duration: 2000 })
  527. } else {
  528. console.log('点击了新增')
  529. this.resetTemp2()
  530. this.dialogFull = false
  531. this.create2.dialogStatus = 'create'
  532. this.create2.dialogFormVisible = true
  533. }
  534. },
  535. resetTemp2() {
  536. this.create2.temp = { pastureid: Cookies.get('pastureid'), 'allowableerror': '' }
  537. },
  538. create_sure2(){
  539. console.log(this.selectList)
  540. var allowableerror = this.create2.temp.allowableerror
  541. var selectArr = this.selectList
  542. var idsArr = []
  543. selectArr.forEach(function(item){
  544. idsArr.push(item.id)
  545. })
  546. var send_data = {"name":"updateAllowableerrorByIds","parammaps":{"allowableerror":allowableerror,"ids":idsArr.join(",")}}
  547. PostDataByName(send_data).then(response => {
  548. if (response.msg === 'fail') {
  549. this.$notify({ title: '设置失败', message: response.data, type: 'warning', duration: 2000 })
  550. } else {
  551. this.$notify({ title: '设置成功', message: '设置成功', type: 'success', duration: 2000 })
  552. this.create2.dialogFormVisible = false
  553. this.getList()
  554. }
  555. })
  556. },
  557. change_time1(tag){
  558. console.log("tag", tag)
  559. console.log("timetags1", this.timetags1)
  560. this.timetags1.push(tag)
  561. },
  562. tag_close1(tag){
  563. console.log("tag", tag)
  564. console.log("timetags1", this.timetags1)
  565. this.timetags1.splice(this.timetags1.indexOf(tag), 1);
  566. },
  567. change_time(index,row,item){
  568. console.log("item", index,row,item)
  569. this.table.list[index].timesArr.push(item)
  570. },
  571. tag_close(index,row,tag){
  572. console.log("tag", index,row,tag)
  573. this.table.list[index].timesArr.splice(this.table.list[index].timesArr.indexOf(tag), 1);
  574. },
  575. // 校验
  576. handleCheck() {
  577. console.log('点击了校验')
  578. this.check.dialogStatus = 'check'
  579. this.check.dialogFormVisible = true
  580. this.getCheckList()
  581. },
  582. getCheckList() {
  583. var check_data = {"name":"checkPushingBar","offset":0,"pagecount":0,"parammaps":{"pastureid":Cookies.get('pastureid')}}
  584. GetDataByName(check_data).then(response => {
  585. console.log(response)
  586. if (response.data.list[0].banme1 !== undefined) {
  587. this.check.temp.isDistribution1 = 0
  588. this.check.temp.banme1 = response.data.list[0].banme1
  589. } else {
  590. this.check.temp.isDistribution1 = 1
  591. }
  592. if (response.data.list[0].banme2 !== undefined) {
  593. this.check.temp.isDistribution2 = 0
  594. this.check.temp.banme2 = response.data.list[0].banme2
  595. } else {
  596. this.check.temp.isDistribution2 = 1
  597. }
  598. })
  599. },
  600. handleTakeEffect() {
  601. console.log(this.selectList)
  602. if (this.selectList.length == 0) {
  603. this.$message({ type: 'error', message: '请选择推料信息', duration: 2000 })
  604. } else {
  605. MessageBox.confirm('当前选中' + this.selectList.length + '条信息,是否生效?', {
  606. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  607. }).then(() => {
  608. var selectArr = this.selectList
  609. var idsArr = []
  610. selectArr.forEach(function(item){
  611. idsArr.push(item.id)
  612. })
  613. var send_data = {
  614. "name":"updateEnableByIds",
  615. "parammaps":{"enable":"1","ids":idsArr.join(",")}
  616. }
  617. GetDataByName(send_data).then(response => {
  618. if (response.msg == 'fail') {
  619. this.$notify({ title: '生效失败', message: response.data, type: 'warning', duration: 2000 })
  620. } else {
  621. this.$notify({ title: '', message: '生效成功', type: 'success', duration: 2000 })
  622. this.getList()
  623. }
  624. })
  625. })
  626. }
  627. },
  628. handleDisable() {
  629. if (this.selectList.length == 0) {
  630. this.$message({ type: 'error', message: '请选择推料信息', duration: 2000 })
  631. } else {
  632. MessageBox.confirm('当前选中' + this.selectList.length + '条信息,是否禁用?', {
  633. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  634. }).then(() => {
  635. var selectArr = this.selectList
  636. var idsArr = []
  637. selectArr.forEach(function(item){
  638. idsArr.push(item.id)
  639. })
  640. var send_data = {
  641. "name":"updateEnableByIds",
  642. "parammaps":{"enable":"0","ids":idsArr.join(",")}
  643. }
  644. GetDataByName(send_data).then(response => {
  645. if (response.msg == 'fail') {
  646. this.$notify({ title: '禁用失败', message: response.data, type: 'warning', duration: 2000 })
  647. } else {
  648. this.$notify({ title: '', message: '禁用成功', type: 'success', duration: 2000 })
  649. this.getList()
  650. }
  651. })
  652. })
  653. }
  654. },
  655. renderHeader(h, { column, $index }) { // h即为cerateElement的简写,具体可看vue官方文档
  656. return h(
  657. 'div',
  658. [
  659. h('span', column.label),
  660. h('i', {
  661. class: 'el-icon-unlock',
  662. ref: 'el-icon-unlock',
  663. style: 'margin-left:5px;'
  664. })
  665. ]
  666. )
  667. },
  668. headerClick(column, event) {
  669. console.log(column, event)
  670. this.headerList.push(event)
  671. for (let i = 0; i < this.table.list.length; i++) {
  672. if (this.table.list[i].Edit == true) {
  673. if (event.target.outerHTML == '<i class="el-icon-unlock" style="margin-left: 5px;"></i>') {
  674. event.target.className = 'el-icon-lock'
  675. this.$set(this.table.list[i], 'isTwoWeight', true) // 锁住不可编辑
  676. } else if (event.target.outerHTML == '<i class="el-icon-lock" style="margin-left: 5px;"></i>') {
  677. event.target.className = 'el-icon-unlock'
  678. this.$set(this.table.list[i], 'isTwoWeight', false) // 解锁可编辑
  679. }
  680. }
  681. }
  682. },
  683. celldblclick(row, column, cell, event) {
  684. console.log(row, '=====')
  685. this.handleUpdate(row)
  686. },
  687. // 编辑
  688. handleUpdate(row) {
  689. console.log(row)
  690. this.oldRowList = {...row}
  691. for (let i = 0; i < this.table.list.length; i++) {
  692. if (this.table.list[i].Edit == true) {
  693. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  694. return false
  695. }
  696. }
  697. // 编辑true,不可编辑false
  698. row.Edit = true
  699. row.NoEdit = false
  700. // 编辑false,编辑保存true
  701. row.isUpdate = false
  702. row.isUpdateSave = true
  703. },
  704. updateData(row) {
  705. console.log('点击了编辑保存', row)
  706. row.pastureid = Cookies.get('pastureid')
  707. if (row.tmrid === '' || row.tmrid == null ) {
  708. this.$message({ type: 'error', message: '推料车名称不能为空', duration: 2000 })
  709. return false
  710. }
  711. const positiveInteger = /^[0-9]\d*$/
  712. if (!positiveInteger.test(parseFloat(row.allowableerror))) {
  713. this.$message({
  714. type: 'error',
  715. message: '允许误差数请输入0-60正整数',
  716. duration: 2000
  717. })
  718. return false
  719. } else if(parseFloat(row.allowableerror) > 60){
  720. this.$message({
  721. type: 'error',
  722. message: '允许误差数请输入0-60正整数',
  723. duration: 2000
  724. })
  725. return false
  726. }
  727. this.isokDisable = true
  728. setTimeout(() => {
  729. this.isokDisable = false
  730. }, 1000)
  731. var timeArrRea = row.timesArr
  732. var timesTempArr = []
  733. timeArrRea.forEach(function(item){
  734. timesTempArr.push({"time":item})
  735. })
  736. var send_data = {
  737. "common":{"returnmap":"0"},
  738. "data":[
  739. {
  740. "name":"checkPushing","resultmaps":{"list":timesTempArr},
  741. "children":[
  742. {
  743. "name":"checkPushing","type":"v",
  744. "parammaps": {
  745. "tmrname":row.tmrname,
  746. "tmrid":row.tmrid,
  747. "id":row.id,
  748. "time":"@checkPushing.time",
  749. "type":0
  750. }
  751. }
  752. ]
  753. }
  754. ]
  755. }
  756. if(row.id == 0){
  757. var send_data2 = {
  758. "common":{"returnmap":"0"},
  759. "data":[
  760. {"name":"insertPushing","type":"e",
  761. "parammaps": row
  762. },
  763. {"name":"insertPushingDetail",
  764. "resultmaps":{
  765. "list":timesTempArr
  766. },
  767. "children":[
  768. {
  769. "name":"insertPushingDetail","type":"e","parammaps":
  770. {
  771. "pastureid":Cookies.get('pastureid'),
  772. "barid":row.barid,"time":"@insertPushingDetail.time","type":0}}]}
  773. ]}
  774. }else {
  775. var send_data2 = {
  776. "common":{"returnmap":"0"},
  777. "data":[
  778. {"name":"insertPushingHistory","type":"e","parammaps":{"ids":row.id,"pastureid":Cookies.get('pastureid')}},
  779. {"name":"updatePushing","type":"e",
  780. "parammaps":row
  781. },
  782. {"name": "delPushingDetail","type": "e",
  783. "parammaps": {"id": row.id }
  784. },
  785. {"name":"insertPushingDetail",
  786. "resultmaps":{"list":timesTempArr},
  787. "children":[
  788. {"name":"insertPushingDetail","type":"e",
  789. "parammaps":
  790. {"pastureid":Cookies.get('pastureid'),
  791. "barid":row.barid,"time":"@insertPushingDetail.time","type":0}}]}
  792. ]}
  793. }
  794. checkDates(send_data).then(response => {
  795. console.log(response)
  796. if (response.data === true) {
  797. ExecDataByConfig(send_data2).then(response => {
  798. console.log('编辑保存发送参数', send_data2)
  799. console.log('编辑保存', response)
  800. if (response.msg === 'fail') {
  801. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  802. } else {
  803. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  804. this.getList()
  805. }
  806. })
  807. } else {
  808. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  809. }
  810. })
  811. },
  812. updateCancel(row) {
  813. console.log('点击了编辑取消')
  814. // 编辑false,不可编辑true
  815. row.Edit = false
  816. row.NoEdit = true
  817. // 编辑true,编辑保存false
  818. row.isUpdate = true
  819. row.isUpdateSave = false
  820. // this.reload()
  821. for (let i = 0; i < this.headerList.length; i++) {
  822. if (this.headerList[i].target.className == 'el-icon-lock') {
  823. this.headerList[i].target.className = 'el-icon-unlock'
  824. this.$set(this.headerList[i].target, 'className', 'el-icon-unlock')
  825. }
  826. }
  827. console.log(this.table.getdataListParm.offset)
  828. this.table.getdataListParm.offset = this.table.getdataListParm.offset
  829. this.getList()
  830. // this.$router.push('/formulationPlan/dhedFormula')
  831. },
  832. cellClick(row, column, event) {
  833. console.log(column)
  834. },
  835. handleSelect(val) {
  836. console.log('勾选数据', val)
  837. this.selectList = val
  838. },
  839. tableRowClassName({ row }) {
  840. // console.log(row)
  841. if (row.isColor == '0') {
  842. return 'red-row'
  843. } else {
  844. return ''
  845. }
  846. },
  847. // 历史记录
  848. handleHistoryRecords() {
  849. console.log('点击了历史记录')
  850. this.dialogFull = false
  851. this.history.dialogStatus = 'history'
  852. this.history.dialogFormVisible = true
  853. this.getDateList()
  854. },
  855. // 历史时间
  856. getDateList() {
  857. GetDataByName(this.history.getdataDateParm).then(response => {
  858. console.log('table数据', response)
  859. if (response.data.list !== null) {
  860. this.history.getdataListParm.parammaps.changeTime = response.data.list[0].changeTime
  861. this.getHistoryList()
  862. } else {
  863. this.history.getdataListParm.parammaps.changeTime = ''
  864. }
  865. })
  866. },
  867. changeDate() {
  868. this.getHistoryList()
  869. },
  870. getHistoryList() {
  871. this.history.listLoading = true
  872. GetDataByName(this.history.getdataListParm).then(response => {
  873. console.log('table数据', response.data.list)
  874. if (response.data.list !== null) {
  875. console.log('table数据', response.data.list)
  876. this.history.list = response.data.list
  877. this.history.pageNum = response.data.pageNum
  878. this.history.pageSize = response.data.pageSize
  879. this.history.total = response.data.total
  880. } else {
  881. this.history.list = []
  882. }
  883. setTimeout(() => {
  884. this.history.listLoading = false
  885. }, 100)
  886. })
  887. },
  888. // 应用
  889. handleApplication() {
  890. console.log('点击了应用')
  891. MessageBox.confirm('是否确认将' + this.history.getdataListParm.parammaps.date + '的数据应用到当前?', {
  892. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  893. }).then(() => {
  894. this.requestParam.name = 'applyFPdate'
  895. this.requestParam.parammaps = {}
  896. this.requestParam.parammaps.pastureid = Cookies.get('pastureid')
  897. this.requestParam.parammaps.date = this.history.getdataListParm.parammaps.date
  898. PostDataByName(this.requestParam).then(response => {
  899. if (response.msg === 'fail') {
  900. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  901. } else {
  902. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  903. this.getList()
  904. }
  905. })
  906. }).catch(() => {
  907. this.$message({ type: 'info', message: '已取消应用' })
  908. })
  909. },
  910. formatJson(filterVal, jsonData) {
  911. return jsonData.map(v =>
  912. filterVal.map(j => {
  913. if (j === 'timestamp') {
  914. return parseTime(v[j])
  915. } else {
  916. return v[j]
  917. }
  918. })
  919. )
  920. },
  921. blurBw(row) {
  922. console.log(row)
  923. },
  924. focusBw(row) {
  925. console.log(row)
  926. }
  927. }
  928. }
  929. </script>
  930. <style lang="scss" scoped>
  931. .search {
  932. clear: both;
  933. }
  934. .table {
  935. margin-top: 10px;
  936. }
  937. .el-tag{margin-right: 5px;}
  938. </style>
  939. <style lang="scss">
  940. .red-row{
  941. background: #fde2e2 !important;
  942. }
  943. </style>