index.vue 30 KB

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