index.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890
  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)">
  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.time_single"
  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="6">
  141. <el-form-item label="允许误差时间(分钟):" prop="time">
  142. <el-input ref="time" v-model="create2.temp.time" 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="handleCreate2">确认</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.isDistribution == '0'">当前有栏舍未分配,建议及时进行分配,未分配栏舍如下:</p>
  157. <p v-else>已分配完:当前栏舍已分配完善</p>
  158. {{ check.temp.bnames }}
  159. </div>
  160. <div slot="footer" class="dialog-footer" style="bottom: 10px;">
  161. <el-button class="save" @click="check.dialogFormVisible=false;">确认</el-button>
  162. </div>
  163. </el-dialog>
  164. </div>
  165. </template>
  166. <script>
  167. import { GetDataByName, postJson, GetDataByNames, compareSort, ExecDataByConfig, failproccess, PostDataByName, formatNum, checkButtons } from '@/api/common'
  168. import Pagination from '@/components/Pagination'
  169. import Pagination2 from '@/components/Pagination2'
  170. import { parseTime, json2excel, handleTableSpan, handleObjectSpanMethod } from '@/utils/index.js'
  171. import { MessageBox } from 'element-ui'
  172. import Cookies from 'js-cookie'
  173. import axios from 'axios'
  174. import { getToken } from '@/utils/auth'
  175. export default {
  176. inject: ['reload'],
  177. name: 'PushMaterialPlan',
  178. components: { Pagination, Pagination2 },
  179. data() {
  180. return {
  181. tmrCodeList:[
  182. // {Code: "001", id: 46, name: "一号推料车"},
  183. // {Code: "002", id: 47, name: "二号推料车"}
  184. ],
  185. table: {
  186. getdataListParm: {
  187. name: 'getPushingList',
  188. page: 1,
  189. offset: 1,
  190. pagecount: '',
  191. returntype: 'Map',
  192. parammaps: {
  193. pastureid: Cookies.get('pastureid'),
  194. }
  195. },
  196. tableKey: 0,
  197. list: [],
  198. total: 0,
  199. listLoading: true,
  200. temp: {},
  201. },
  202. create1: {
  203. dialogFormVisible: false,
  204. dialogStatus: '',
  205. temp: { pastureid: Cookies.get('pastureid'), fname: ''},
  206. rules: {
  207. // fname: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  208. // fclassid: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  209. // feedcode: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }]
  210. }
  211. },
  212. create2: {
  213. dialogFormVisible: false,
  214. dialogStatus: '',
  215. temp: { pastureid: Cookies.get('pastureid'), time: ''},
  216. rules: {
  217. // fname: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  218. // fclassid: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  219. // feedcode: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }]
  220. }
  221. },
  222. check: {
  223. dialogFormVisible: false,
  224. dialogStatus: '',
  225. getCheckParm: {
  226. name: 'checkRemainplan',
  227. page: 1,
  228. offset: 1,
  229. pagecount: 10,
  230. returntype: 'Map',
  231. parammaps: {
  232. pastureid: Cookies.get('pastureid')
  233. }
  234. },
  235. temp: {
  236. bnames: '',
  237. isDistribution: ''
  238. }
  239. },
  240. timevalue1: new Date(2022, 9, 10, 18, 40),
  241. timetags1: [],
  242. dialogFull: false,
  243. isRoleEdit: [],
  244. headerList: [],
  245. pickerMinDate: '',
  246. rules: {
  247. cowclassid: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }]
  248. },
  249. selectList: [],
  250. requestParam: {},
  251. download: {
  252. getdataListParm: {
  253. name: 'getFPList',
  254. page: 1,
  255. offset: 1,
  256. pagecount: 0,
  257. returntype: 'Map',
  258. parammaps: {
  259. pastureid: Cookies.get('pastureid'),
  260. enable: ''
  261. }
  262. },
  263. list: []
  264. },
  265. spanObj: {},
  266. mergekeys: ['barname', 'sumweight'],
  267. isShowDialog: false,
  268. isokDisable: false,
  269. rowStyle: { maxHeight: 30 + 'px', height: 30 + 'px' },
  270. cellStyle: { padding: 0 + 'px' },
  271. myHeight: document.documentElement.clientHeight - 85 - 140,
  272. oldRowList:{},
  273. }
  274. },
  275. computed: {
  276. },
  277. created() {
  278. this.getButtons()
  279. this.getTMRlist()
  280. this.getList()
  281. },
  282. methods: {
  283. getButtons() {
  284. const Edit = 'DhedFormula'
  285. const isRoleEdit = checkButtons(JSON.parse(sessionStorage.getItem('buttons')), Edit)
  286. this.isRoleEdit = isRoleEdit
  287. },
  288. getTMRlist() {
  289. var send_data = {"name":"getPushingTmrList","page":1,"offset":1,"pagecount":"","returntype":"Map","parammaps":{"dictname":"推料车"}}
  290. GetDataByName(send_data).then(response => {
  291. if (response.data.list !== null) {
  292. this.tmrCodeList = response.data.list
  293. } else {
  294. this.tmrCodeList = []
  295. }
  296. console.log("tmrCodeList",this.tmrCodeList)
  297. })
  298. },
  299. getList() {
  300. this.table.listLoading = true
  301. GetDataByName(this.table.getdataListParm).then(response => {
  302. console.log('table数据', response.data.list)
  303. if (response.data.list !== null) {
  304. for (let i = 0; i < response.data.list.length; i++) {
  305. this.$set(response.data.list[i], 'Edit', false) // 编辑
  306. this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
  307. this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
  308. this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
  309. }
  310. response.data.list.forEach(function(item){
  311. if(item.times !== ""){
  312. item.timesArr = item.times.split(',')
  313. }
  314. })
  315. // console.log(response.data.list, sumr)
  316. this.table.list = response.data.list
  317. console.log(this.table.list, 'this.table.list')
  318. this.table.pageNum = response.data.pageNum
  319. this.table.pageSize = response.data.pageSize
  320. this.table.total = response.data.total
  321. } else {
  322. this.table.list = []
  323. }
  324. setTimeout(() => {
  325. this.table.listLoading = false
  326. }, 100)
  327. })
  328. },
  329. // 推料车
  330. changeTmrCode(index,row) {
  331. console.log("推料车:====",index,row)
  332. var Code = this.tmrCodeList.find(obj => obj.id === row.tmrid).Code
  333. console.log( "推料车编号:====",Code)
  334. this.table.list[index].tmrcode = Code
  335. },
  336. // 新增
  337. handleCreate1() {
  338. console.log('点击了新增')
  339. this.resetTemp1()
  340. this.dialogFull = false
  341. this.create1.dialogStatus = 'create'
  342. this.create1.dialogFormVisible = true
  343. },
  344. resetTemp1() {
  345. this.create1.temp = { pastureid: Cookies.get('pastureid'), 'myId': (new Date()).valueOf(), 'Edit': true, 'NoEdit': false, 'isCreate': true, 'isUpdate': false, 'isUpdateSave': false, 'enable': 1, 'sort': "", 'ftid': '', 'ftname': '', 'tmrcode': '', 'tmrid': '', 'times': '', 'lppcode': '', 'lppid': '', 'rtime': '', barid: '', 'treatmethod': '', 'useinbar': '', 'useinbarid': '' }
  346. },
  347. create_sure1(){
  348. console.log(this.timetags1)
  349. },
  350. handleCreate2() {
  351. console.log('点击了新增')
  352. this.resetTemp2()
  353. this.dialogFull = false
  354. this.create2.dialogStatus = 'create'
  355. this.create2.dialogFormVisible = true
  356. },
  357. resetTemp2() {
  358. this.create2.temp = { pastureid: Cookies.get('pastureid'), 'myId': (new Date()).valueOf(), 'Edit': true, 'NoEdit': false, 'isCreate': true, 'isUpdate': false, 'isUpdateSave': false, 'enable': 1, 'sort': "", 'ftid': '', 'ftname': '', 'tmrcode': '', 'tmrid': '', 'times': '', 'lppcode': '', 'lppid': '', 'rtime': '', barid: '', 'treatmethod': '', 'useinbar': '', 'useinbarid': '' }
  359. },
  360. change_time1(tag){
  361. console.log("tag", tag)
  362. console.log("timetags1", this.timetags1)
  363. this.timetags1.push(tag)
  364. },
  365. tag_close1(tag){
  366. console.log("tag", tag)
  367. console.log("timetags1", this.timetags1)
  368. this.timetags1.splice(this.timetags1.indexOf(tag), 1);
  369. },
  370. change_time(index,row,item){
  371. console.log("item", index,row,item)
  372. this.table.list[index].timesArr.push(item)
  373. },
  374. tag_close(index,row,tag){
  375. console.log("tag", index,row,tag)
  376. this.table.list[index].timesArr.splice(this.table.list[index].timesArr.indexOf(tag), 1);
  377. },
  378. // 校验
  379. handleCheck() {
  380. console.log('点击了校验')
  381. this.check.dialogStatus = 'check'
  382. this.check.dialogFormVisible = true
  383. this.getCheckList()
  384. },
  385. getCheckList() {
  386. GetDataByName(this.check.getCheckParm).then(response => {
  387. if (response.data.list[0].bnames !== undefined) {
  388. this.check.temp.isDistribution = 0
  389. this.check.temp.bnames = response.data.list[0].bnames
  390. } else {
  391. this.check.temp = {}
  392. this.check.temp.isDistribution = 1
  393. }
  394. })
  395. },
  396. handleTakeEffect() {
  397. console.log(this.selectList)
  398. if (this.selectList.length == 0) {
  399. this.$message({ type: 'error', message: '请选择推料信息', duration: 2000 })
  400. } else {
  401. MessageBox.confirm('当前选中' + this.selectList.length + '条信息,是否生效?', {
  402. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  403. }).then(() => {
  404. var selectArr = this.selectList
  405. var idsArr = []
  406. selectArr.forEach(function(item){
  407. idsArr.push(item.id)
  408. })
  409. var send_data = {
  410. "name":"updateEnableByIds",
  411. "parammaps":{"enable":"1","ids":idsArr.join(",")}
  412. }
  413. GetDataByName(send_data).then(response => {
  414. if (response.msg == 'fail') {
  415. this.$notify({ title: '生效失败', message: response.data, type: 'warning', duration: 2000 })
  416. } else {
  417. this.$notify({ title: '', message: '生效成功', type: 'success', duration: 2000 })
  418. this.getList()
  419. }
  420. })
  421. })
  422. }
  423. },
  424. handleDisable() {
  425. if (this.selectList.length == 0) {
  426. this.$message({ type: 'error', message: '请选择推料信息', duration: 2000 })
  427. } else {
  428. MessageBox.confirm('当前选中' + this.selectList.length + '条信息,是否禁用?', {
  429. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  430. }).then(() => {
  431. var selectArr = this.selectList
  432. var idsArr = []
  433. selectArr.forEach(function(item){
  434. idsArr.push(item.id)
  435. })
  436. var send_data = {
  437. "name":"updateEnableByIds",
  438. "parammaps":{"enable":"0","ids":idsArr.join(",")}
  439. }
  440. GetDataByName(send_data).then(response => {
  441. if (response.msg == 'fail') {
  442. this.$notify({ title: '禁用失败', message: response.data, type: 'warning', duration: 2000 })
  443. } else {
  444. this.$notify({ title: '', message: '禁用成功', type: 'success', duration: 2000 })
  445. this.getList()
  446. }
  447. })
  448. })
  449. }
  450. },
  451. renderHeader(h, { column, $index }) { // h即为cerateElement的简写,具体可看vue官方文档
  452. return h(
  453. 'div',
  454. [
  455. h('span', column.label),
  456. h('i', {
  457. class: 'el-icon-unlock',
  458. ref: 'el-icon-unlock',
  459. style: 'margin-left:5px;'
  460. })
  461. ]
  462. )
  463. },
  464. headerClick(column, event) {
  465. console.log(column, event)
  466. this.headerList.push(event)
  467. for (let i = 0; i < this.table.list.length; i++) {
  468. if (this.table.list[i].Edit == true) {
  469. if (event.target.outerHTML == '<i class="el-icon-unlock" style="margin-left: 5px;"></i>') {
  470. event.target.className = 'el-icon-lock'
  471. this.$set(this.table.list[i], 'isTwoWeight', true) // 锁住不可编辑
  472. } else if (event.target.outerHTML == '<i class="el-icon-lock" style="margin-left: 5px;"></i>') {
  473. event.target.className = 'el-icon-unlock'
  474. this.$set(this.table.list[i], 'isTwoWeight', false) // 解锁可编辑
  475. }
  476. }
  477. }
  478. },
  479. celldblclick(row, column, cell, event) {
  480. console.log(row, '=====')
  481. this.handleUpdate(row)
  482. },
  483. // 编辑
  484. handleUpdate(row) {
  485. console.log(row)
  486. this.oldRowList = {...row}
  487. for (let i = 0; i < this.table.list.length; i++) {
  488. if (this.table.list[i].Edit == true) {
  489. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  490. return false
  491. }
  492. }
  493. // 编辑true,不可编辑false
  494. row.Edit = true
  495. row.NoEdit = false
  496. // 编辑false,编辑保存true
  497. row.isUpdate = false
  498. row.isUpdateSave = true
  499. },
  500. updateData(row) {
  501. console.log('点击了编辑保存', row)
  502. row.pastureid = Cookies.get('pastureid')
  503. // if (this.table.temp.ccount === '') {
  504. // this.$message({ type: 'error', message: '实际牛头数不能为空', duration: 2000 })
  505. // return false
  506. // }
  507. // const positiveInteger = /^[0-9]\d*$/
  508. // if (!positiveInteger.test(parseFloat(this.table.temp.ccount))) {
  509. // this.$message({
  510. // type: 'error',
  511. // message: '实际牛头数请输入正整数',
  512. // duration: 2000
  513. // })
  514. // return false
  515. // }
  516. this.isokDisable = true
  517. setTimeout(() => {
  518. this.isokDisable = false
  519. }, 1000)
  520. var timeArrRea = row.timesArr
  521. var timesTempArr = []
  522. timeArrRea.forEach(function(item){
  523. timesTempArr.push({"time":item})
  524. })
  525. var send_data = {
  526. "common":{"returnmap":"0"},
  527. "data":[
  528. {
  529. "name":"checkPushing","resultmaps":{"list":timesTempArr},
  530. "children":[
  531. {
  532. "name":"checkPushing","type":"e",
  533. "parammaps": {
  534. "tmrname":row.tmrname,
  535. "tmrid":row.tmrid,
  536. "id":row.id,
  537. "time":"@checkPushing.time",
  538. "type":0
  539. }
  540. }
  541. ]
  542. }
  543. ]
  544. }
  545. PostDataByName(send_data).then(response => {
  546. console.log(response)
  547. if (response.msg === 'fail') {
  548. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  549. } else {
  550. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  551. }
  552. })
  553. if(id == 0){
  554. var send_data = {
  555. "common":{"returnmap":"0"},
  556. "data":[
  557. {"name":"insertPushing","type":"e",
  558. "parammaps": row
  559. },
  560. {"name":"insertPushingDetail",
  561. "resultmaps":{
  562. "list":[
  563. {"time":"10:00"},{"time":"12:00"}
  564. ]
  565. },
  566. "children":[
  567. {
  568. "name":"insertPushingDetail","type":"e","parammaps":
  569. {
  570. "pastureid":Cookies.get('pastureid'),
  571. "barid":row.barid,"time":"@insertPushingDetail.time","type":0}}]}
  572. ]}
  573. }else {
  574. }
  575. // ExecDataByConfig(this.requestParam).then(response => {
  576. // console.log('编辑保存发送参数', this.requestParam)
  577. // if (response.msg === 'fail') {
  578. // this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  579. // } else {
  580. // if(obj.data.length>0){
  581. // const url = 'authdata/fpdetail/edit'
  582. // const data = obj
  583. // postJson(url, data).then(response => {
  584. // if(response.msg !== 'fail'){
  585. // this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  586. // }
  587. // })
  588. // }else{
  589. // this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  590. // }
  591. // this.getList()
  592. // for (let i = 0; i < this.headerList.length; i++) {
  593. // if (this.headerList[i].target.className == 'el-icon-lock') {
  594. // this.headerList[i].target.className = 'el-icon-unlock'
  595. // this.$set(this.headerList[i].target, 'className', 'el-icon-unlock')
  596. // }
  597. // }
  598. // }
  599. // })
  600. },
  601. updateCancel(row) {
  602. console.log('点击了编辑取消')
  603. // 编辑false,不可编辑true
  604. row.Edit = false
  605. row.NoEdit = true
  606. // 编辑true,编辑保存false
  607. row.isUpdate = true
  608. row.isUpdateSave = false
  609. // this.reload()
  610. for (let i = 0; i < this.headerList.length; i++) {
  611. if (this.headerList[i].target.className == 'el-icon-lock') {
  612. this.headerList[i].target.className = 'el-icon-unlock'
  613. this.$set(this.headerList[i].target, 'className', 'el-icon-unlock')
  614. }
  615. }
  616. console.log(this.table.getdataListParm.offset)
  617. this.table.getdataListParm.offset = this.table.getdataListParm.offset
  618. this.getList()
  619. // this.$router.push('/formulationPlan/dhedFormula')
  620. },
  621. cellClick(row, column, event) {
  622. console.log(column)
  623. },
  624. handleSelect(val) {
  625. console.log('勾选数据', val)
  626. this.selectList = val
  627. },
  628. tableRowClassName({ row }) {
  629. // console.log(row)
  630. if (row.isColor == '0') {
  631. return 'red-row'
  632. } else {
  633. return ''
  634. }
  635. },
  636. // 删除
  637. handleRowDelete(row) {
  638. console.log('点击了行内删除')
  639. MessageBox.confirm('是否确认删除此信息?', {
  640. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  641. }).then(() => {
  642. this.selectList = []
  643. this.requestParam.name = 'deleteDungsieve'
  644. this.requestParam.parammaps = {}
  645. this.requestParam.parammaps.pastureid = row.pastureid
  646. this.requestParam.parammaps.id = row.id
  647. PostDataByName(this.requestParam).then(response => {
  648. if (response.msg === 'fail') {
  649. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  650. } else {
  651. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  652. this.getList()
  653. }
  654. })
  655. }).catch(() => {
  656. this.$message({ type: 'info', message: '已取消删除' })
  657. })
  658. },
  659. // 应用
  660. handleApplication() {
  661. console.log('点击了应用')
  662. MessageBox.confirm('是否确认将' + this.history.getdataListParm.parammaps.date + '的数据应用到当前?', {
  663. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  664. }).then(() => {
  665. this.requestParam.name = 'applyFPdate'
  666. this.requestParam.parammaps = {}
  667. this.requestParam.parammaps.pastureid = Cookies.get('pastureid')
  668. this.requestParam.parammaps.date = this.history.getdataListParm.parammaps.date
  669. PostDataByName(this.requestParam).then(response => {
  670. if (response.msg === 'fail') {
  671. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  672. } else {
  673. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  674. this.getList()
  675. }
  676. })
  677. }).catch(() => {
  678. this.$message({ type: 'info', message: '已取消应用' })
  679. })
  680. },
  681. formatJson(filterVal, jsonData) {
  682. return jsonData.map(v =>
  683. filterVal.map(j => {
  684. if (j === 'timestamp') {
  685. return parseTime(v[j])
  686. } else {
  687. return v[j]
  688. }
  689. })
  690. )
  691. },
  692. blurBw(row) {
  693. console.log(row)
  694. },
  695. focusBw(row) {
  696. console.log(row)
  697. }
  698. }
  699. }
  700. </script>
  701. <style lang="scss" scoped>
  702. .search {
  703. clear: both;
  704. }
  705. .table {
  706. margin-top: 10px;
  707. }
  708. </style>
  709. <style lang="scss">
  710. .red-row{
  711. background: #fde2e2 !important;
  712. }
  713. </style>