index.vue 29 KB

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