index.vue 32 KB

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