461b5f520153860c561d20a31071c567b55c348c.svn-base 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558
  1. <template>
  2. <div>
  3. <div class="table">
  4. <el-table
  5. :key="table.tableKey"
  6. v-loading="table.listLoading"
  7. element-loading-text="给我一点时间"
  8. :data="table.list"
  9. border
  10. fit
  11. highlight-current-row
  12. style="width: 100%;"
  13. :row-style="rowStyle"
  14. :cell-style="cellStyle"
  15. class="elTable table-fixed"
  16. :span-method="objectSpanMethod"
  17. >
  18. <el-table-column :key="1" label="序号" align="center" type="index" width="50px" class-name="small-padding fixed-width" fixed="left">
  19. <template slot-scope="scope">
  20. <span>{{ scope.$index + (table.pageNum-1) * table.pageSize + 1 }}</span>
  21. </template>
  22. </el-table-column>
  23. <el-table-column :key="2" label="栏舍名称" prop="barname" min-width="90px" align="center" class-name="small-padding fixed-width" fixed="left" />
  24. <el-table-column :key="3" label="班次" prop="times" min-width="90px" align="center" class-name="small-padding fixed-width" fixed="left" />
  25. <el-table-column :key="4" label="软件牛头数" prop="softccount" min-width="70px" align="center" />
  26. <el-table-column :key="5" label="实际牛头数" min-width="100px" align="center">
  27. <template slot-scope="scope">
  28. <span v-if="scope.row.NoEdit">{{ scope.row.ccount }}</span>
  29. <el-input v-if="scope.row.Edit" v-model="scope.row.ccount" step="0.01" type="number" style="width:95%;padding:10px 0;" @blur="blurCcount(scope.row)" />
  30. </template>
  31. </el-table-column>
  32. <el-table-column :key="6" label="系数(%)" min-width="100px" align="center">
  33. <template slot-scope="scope">
  34. <span v-if="scope.row.NoEdit">{{ scope.row.ratio }}</span>
  35. <el-input v-if="scope.row.Edit" v-model="scope.row.ratio" step="0.01" type="number" style="width:95%;padding:10px 0;" @blur="blurRatio(scope.row)" />
  36. </template>
  37. </el-table-column>
  38. <el-table-column :key="7" label="系数头数" min-width="100px" align="center">
  39. <template slot-scope="scope">
  40. <span v-if="scope.row.NoEdit">{{ scope.row.ccountratio }}</span>
  41. <el-input v-if="scope.row.Edit" v-model="scope.row.ccountratio" step="0.01" type="number" style="width:95%;padding:10px 0;" @blur="blurCcountratio(scope.row)" />
  42. </template>
  43. </el-table-column>
  44. <el-table-column :key="8" label="配方模板" min-width="100px" align="center">
  45. <template slot-scope="scope">
  46. <span v-if="scope.row.NoEdit">{{ scope.row.ptname }}</span>
  47. <el-select v-if="scope.row.Edit" v-model="scope.row.ptid" filterable placeholder="配方模板" class="filter-item" style="width:99%;" @change="(value)=> {changeRecipeTemplate(value, scope.row)}">
  48. <el-option v-for="item in recipeTemplateList" :key="item.id" :label="item.tname" :value="item.id" />
  49. </el-select>
  50. </template>
  51. </el-table-column>
  52. <el-table-column v-if="table.isPtsfname" :key="9" label="补料配方" min-width="100px" align="center">
  53. <template slot-scope="scope">
  54. <span v-if="scope.row.NoEdit">{{ scope.row.ptsname }}</span>
  55. <el-select v-if="scope.row.Edit" v-model="scope.row.ptsid" clearable filterable placeholder="补料配方" class="filter-item" style="width:95%;padding:10px 0;" @change="(value)=> {changeFeedingFormula(value, scope.row)}">
  56. <el-option v-for="item in feedingFormulaList" :key="item.id" :label="item.tname" :value="item.id" />
  57. </el-select>
  58. </template>
  59. </el-table-column>
  60. <el-table-column :key="10" label="班次比例(%)" min-width="100px" align="center">
  61. <template slot-scope="scope">
  62. <span v-if="scope.row.NoEdit">{{ scope.row.tratio }}</span>
  63. <el-input v-if="scope.row.Edit" v-model="scope.row.tratio" :disabled="scope.row.isOneWeight" step="0.01" type="number" style="width:95%;padding:10px 0;" @blur="blurTratio(scope.row)" />
  64. </template>
  65. </el-table-column>
  66. <el-table-column :key="11" label="班次重量" min-width="100px" align="center">
  67. <template slot-scope="scope">
  68. <span v-if="scope.row.NoEdit">{{ scope.row.weight }}</span>
  69. <el-input v-if="scope.row.Edit" v-model="scope.row.weight" :disabled="scope.row.isOneWeight" step="0.01" type="number" style="width:95%;padding:10px 0;" @blur="blurWeight(scope.row)" />
  70. </template>
  71. </el-table-column>
  72. <el-table-column :key="12" label="配方重量" prop="pweight" min-width="85px" align="center" />
  73. <el-table-column v-if="table.isPtsfname" :key="13" label="补料重量" prop="ptweight" min-width="85px" align="center" />
  74. <el-table-column :key="14" label="配方干物质量" prop="dryweight" min-width="85px" align="center" />
  75. <el-table-column :key="15" label="饲喂干物质量" prop="swdryw" min-width="85px" align="center" />
  76. <el-table-column :key="16" label="采样干物质量" prop="cydryw" min-width="85px" align="center" />
  77. <el-table-column :key="17" label="日投喂量" prop="sumweight" min-width="85px" align="center" />
  78. <el-table-column label="操作" align="center" width="150" class-name="small-padding fixed-width" fixed="right">
  79. <template slot-scope="{row}">
  80. <!-- 编辑 -->
  81. <el-button v-if="row.isUpdate" class="miniSuccess" @click="handleUpdate(row)">编辑</el-button>
  82. <!-- 编辑保存 -->
  83. <el-button v-if="row.isUpdateSave" class="miniSuccess" :disabled="isokDisable" @click="updateData(row)">保存</el-button>
  84. <el-button v-if="row.isUpdateSave" class="minCancel" @click="updateCancel(row)">取消</el-button>
  85. </template>
  86. </el-table-column>
  87. </el-table>
  88. <pagination2 v-show="table.total>=0" :total="table.total" :page.sync="table.getdataListParm.offset" :limit.sync="table.getdataListParm.pagecount" @pagination="getList" />
  89. </div>
  90. </div>
  91. </template>
  92. <script>
  93. import { GetDataByName, GETNurJudge, GetDataByNames, compareSort, ExecDataByConfig, failproccess, PostDataByName, formatNum } from '@/api/common'
  94. import Pagination2 from '@/components/Pagination2'
  95. import { parseTime, json2excel, handleTableSpan, handleObjectSpanMethod } from '@/utils/index.js'
  96. import { MessageBox } from 'element-ui'
  97. import Cookies from 'js-cookie'
  98. import { getToken } from '@/utils/auth'
  99. export default {
  100. name: 'DhedFormula',
  101. inject: ['reload'],
  102. components: { Pagination2 },
  103. props: {
  104. show: { type: Boolean, default: false },
  105. parentDate: {
  106. type: String,
  107. defalut: ''
  108. }
  109. },
  110. data() {
  111. return {
  112. date: '',
  113. requestParams: [
  114. { name: 'getFTSWList', offset: 0, pagecount: 0, parammaps: { pastureid: Cookies.get('pastureid') }},
  115. { name: 'getFTBLList', offset: 0, pagecount: 0, parammaps: { pastureid: Cookies.get('pastureid') }},
  116. { name: 'getCowclassListEnable', offset: 0, pagecount: 0, parammaps: { pastureid: Cookies.get('pastureid') }}
  117. ],
  118. recipeTemplateList: [], // 配方模板
  119. feedingFormulaList: [], // 补料配方
  120. livestockTypeList: [], // 类别
  121. rules: {
  122. cowclassid: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }]
  123. },
  124. table: {
  125. getdataListParm: {
  126. name: 'getPlanModifyFPlist',
  127. page: 1,
  128. offset: 1,
  129. pagecount: 12,
  130. returntype: 'Map',
  131. parammaps: {
  132. pastureid: Cookies.get('pastureid')
  133. }
  134. },
  135. tableKey: 0,
  136. list: [],
  137. total: 0,
  138. listLoading: true,
  139. temp: {},
  140. rwList: [],
  141. isPtsfname: false, // 补料配方/补料重量
  142. getdataListParm2: {
  143. name: 'getSysoptEnable',
  144. page: 1,
  145. offset: 1,
  146. pagecount: 1,
  147. returntype: 'Map',
  148. parammaps: {
  149. pastureid: Cookies.get('pastureid'),
  150. inforname: 'isEnableSupplyFeed'
  151. }
  152. }
  153. },
  154. requestParam: {},
  155. spanObj: {},
  156. mergekeys: ['barname', 'sumweight'],
  157. isokDisable: false,
  158. rowStyle: { maxHeight: 50 + 'px', height: 35 + 'px' },
  159. cellStyle: { padding: 0 + 'px' }
  160. }
  161. },
  162. watch: {
  163. show: {
  164. immediate: true,
  165. handler(show) {
  166. this.visible = show
  167. }
  168. },
  169. parentDate: {
  170. immediate: true,
  171. handler(newVal, oldVal) {
  172. console.log(newVal, oldVal, 'newVal,oldVal')
  173. this.date = newVal
  174. }
  175. }
  176. },
  177. created() {
  178. this.getIsDisplay()
  179. this.getDownList()
  180. },
  181. methods: {
  182. // 下拉
  183. getDownList() {
  184. GetDataByNames(this.requestParams).then(response => {
  185. this.recipeTemplateList = response.data.getFTSWList.list
  186. this.feedingFormulaList = response.data.getFTBLList.list
  187. this.livestockTypeList = response.data.getCowclassListEnable.list
  188. })
  189. },
  190. // 补料是否显示
  191. getIsDisplay() {
  192. GetDataByName(this.table.getdataListParm2).then(response => {
  193. console.log(response.data.list[0].inforvalue)
  194. if (response.data.list !== null) {
  195. if (response.data.list[0].inforvalue == 0) {
  196. this.table.isPtsfname = false
  197. } else {
  198. this.table.isPtsfname = true
  199. }
  200. }
  201. })
  202. this.getList()
  203. },
  204. getList() {
  205. this.table.listLoading = true
  206. this.table.getdataListParm.parammaps.date = this.date
  207. GetDataByName(this.table.getdataListParm).then(response => {
  208. console.log('table数据', response.data.list)
  209. if (response.data.list !== null) {
  210. for (let i = 0; i < response.data.list.length; i++) {
  211. this.$set(response.data.list[i], 'Edit', false) // 编辑
  212. this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
  213. this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
  214. this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
  215. if (response.data.list[i].ptid == undefined || response.data.list[i].ptname == '') {
  216. this.$set(response.data.list[i], 'ptid', '')
  217. this.$set(response.data.list[i], 'ptname', '')
  218. }
  219. if (response.data.list[i].ratio == undefined) {
  220. this.$set(response.data.list[i], 'ratio', '')
  221. }
  222. if (response.data.list[i].ccount == undefined) {
  223. this.$set(response.data.list[i], 'ccount', '')
  224. }
  225. if (response.data.list[i].ccountratio == undefined) {
  226. this.$set(response.data.list[i], 'ccountratio', '')
  227. }
  228. }
  229. this.table.list = response.data.list
  230. console.log(this.table.list, 'this.table.list')
  231. this.table.pageNum = response.data.pageNum
  232. this.table.pageSize = response.data.pageSize
  233. this.table.total = response.data.total
  234. this.handleSpan()
  235. } else {
  236. this.table.list = []
  237. }
  238. setTimeout(() => {
  239. this.table.listLoading = false
  240. }, 100)
  241. })
  242. },
  243. handleSpan() {
  244. this.mergekeys.forEach(key => {
  245. this.spanObj[key] = []
  246. let position = 0
  247. this.table.list.forEach((item, index) => {
  248. if (index === 0) {
  249. this.spanObj[key].push(1)
  250. position = 0
  251. } else {
  252. if (key == 'sumweight') {
  253. if (this.table.list[index][key] === this.table.list[index - 1][key] && this.table.list[index]['barname'] === this.table.list[index - 1]['barname']) {
  254. this.spanObj[key][position] += 1
  255. this.spanObj[key].push(0)
  256. } else {
  257. this.spanObj[key].push(1)
  258. position = index
  259. }
  260. } else {
  261. if (this.table.list[index][key] === this.table.list[index - 1][key]) {
  262. this.spanObj[key][position] += 1
  263. this.spanObj[key].push(0)
  264. } else {
  265. this.spanObj[key].push(1)
  266. position = index
  267. }
  268. }
  269. }
  270. })
  271. })
  272. },
  273. objectSpanMethod({ row, column, rowIndex, columnIndex }) {
  274. for (let i = 0; i < this.mergekeys.length; i++) {
  275. if (column.property === this.mergekeys[i]) {
  276. const _row = this.spanObj[this.mergekeys[i]][rowIndex]
  277. const _col = _row > 0 ? 1 : 0
  278. return {
  279. rowspan: _row,
  280. colspan: _col
  281. }
  282. }
  283. }
  284. },
  285. handleUpdate(row) {
  286. console.log(row)
  287. for (let i = 0; i < this.table.list.length; i++) {
  288. if (this.table.list[i].Edit == true) {
  289. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  290. return false
  291. }
  292. }
  293. // 编辑true,不可编辑false
  294. row.Edit = true
  295. row.NoEdit = false
  296. // 编辑false,编辑保存true
  297. row.isUpdate = false
  298. row.isUpdateSave = true
  299. if (row.ptsfid == '-1') {
  300. row.ptsfid = ''
  301. }
  302. row.ptsfid = String(row.ptsfid)
  303. this.table.temp.ptid = row.ptid
  304. this.table.temp.ptname = row.ptname
  305. this.table.temp.ptsfid = row.ptsfid
  306. this.table.temp.ptsfname = row.ptsfname
  307. // row.sumweight = ''
  308. row.Sfweight = this.recipeTemplateList.find(obj => obj.id == row.ptid).Sfweight// Sfweight
  309. // SfweightLock
  310. row.SfweightLock = this.recipeTemplateList.find(obj => obj.id == row.ptid).SfweightLock
  311. },
  312. // 实际牛头数
  313. blurCcount(row) {
  314. if (row.ccount !== '' && row.ratio !== '') {
  315. row.ccountratio = formatNum(parseFloat(row.ccount) * parseFloat(row.ratio) / 100, 2)
  316. } else if (row.ratio !== '' && row.ccountratio !== '') {
  317. row.ccount = formatNum(parseFloat(row.ccountratio) * 100 / parseFloat(row.ratio) / 100, 2)
  318. } else if (row.ccount !== '' || row.ratio !== '') {
  319. row.ccountratio = ''
  320. }
  321. if (this.table.isPtsfname == false) {
  322. if (row.Sfweight !== '' && row.ccountratio !== '' && row.SfweightLock !== '' && row.ccount) {
  323. row.pweight = formatNum(parseFloat(row.Sfweight) * parseFloat(row.ccountratio) + parseFloat(row.SfweightLock) * parseFloat(row.ccount), 2)
  324. row.weight = formatNum(parseFloat(row.pweight) * (parseFloat(row.tratio) / 100), 2)
  325. } else {
  326. row.pweight = 0
  327. row.weight = 0
  328. }
  329. } else {
  330. if (row.supplyweight == 'NaN') {
  331. row.supplyweight = 0
  332. }
  333. if (row.Sfweight !== '' && row.ccountratio !== '' && row.SfweightLock !== '' && row.ccount) {
  334. row.pweight = formatNum(parseFloat(row.Sfweight) * parseFloat(row.ccountratio) + parseFloat(row.SfweightLock) * parseFloat(row.ccount), 2)
  335. row.weight = formatNum((parseFloat(row.pweight) + parseFloat(row.supplyweight)) * (parseFloat(row.tratio) / 100), 2)
  336. } else {
  337. row.pweight = 0
  338. row.weight = 0
  339. }
  340. }
  341. this.getSumWeight(row)
  342. },
  343. // 系数
  344. blurRatio(row) {
  345. if (row.ccount !== '' && row.ratio !== '') {
  346. row.ccountratio = formatNum(parseFloat(row.ccount) * parseFloat(row.ratio) / 100, 2)
  347. } else if (row.ccount !== '' && row.ccountratio !== '') {
  348. row.ratio = formatNum(parseFloat(row.ccountratio) * 100 / parseFloat(row.ccount), 2)
  349. } else if (row.ccount !== '' || row.ccountratio !== '') {
  350. row.ratio = ''
  351. }
  352. if (this.table.isPtsfname == false) {
  353. if (row.Sfweight !== '' && row.ccountratio !== '' && row.SfweightLock !== '' && row.ccount) {
  354. row.pweight = formatNum(parseFloat(row.Sfweight) * parseFloat(row.ccountratio) + parseFloat(row.SfweightLock) * parseFloat(row.ccount), 2)
  355. row.weight = formatNum(parseFloat(row.pweight) * (parseFloat(row.tratio) / 100), 2)
  356. } else {
  357. row.pweight = 0
  358. row.weight = 0
  359. }
  360. } else {
  361. if (row.supplyweight == 'NaN') {
  362. row.supplyweight = 0
  363. }
  364. if (row.Sfweight !== '' && row.ccountratio !== '' && row.SfweightLock !== '' && row.ccount) {
  365. row.pweight = formatNum(parseFloat(row.Sfweight) * parseFloat(row.ccountratio) + parseFloat(row.SfweightLock) * parseFloat(row.ccount), 2)
  366. row.weight = formatNum((parseFloat(row.pweight) + parseFloat(row.supplyweight)) * (parseFloat(row.tratio) / 100), 2)
  367. } else {
  368. row.pweight = 0
  369. row.weight = 0
  370. }
  371. }
  372. this.getSumWeight(row)
  373. },
  374. // 系数头数
  375. // 系数头数=实际牛头数*系数*100%;
  376. blurCcountratio(row) {
  377. if (row.ccountratio !== '' && row.ccount !== '' && row.ratio !== '') {
  378. row.ratio = formatNum(parseFloat(row.ccountratio) * 100 / parseFloat(row.ccount), 2)
  379. } else if (row.ccount !== '' && row.ratio !== '') {
  380. row.ccountratio = formatNum(parseFloat(row.ccount) * parseFloat(row.ratio) / 100, 2)
  381. } else if (row.ccountratio !== '' && row.ccount !== '') {
  382. row.ratio = formatNum(parseFloat(row.ccountratio) * 100 / parseFloat(row.ccount), 2)
  383. } else if (row.ccountratio !== '' && row.ratio !== '') {
  384. row.ccount = formatNum(parseFloat(row.ccountratio) * 100 / parseFloat(row.ratio) / 100, 2)
  385. }
  386. if (this.table.isPtsfname == false) {
  387. if (row.Sfweight !== '' && row.ccountratio !== '' && row.SfweightLock !== '' && row.ccount) {
  388. row.pweight = formatNum(parseFloat(row.Sfweight) * parseFloat(row.ccountratio) + parseFloat(row.SfweightLock) * parseFloat(row.ccount), 2)
  389. row.weight = formatNum(parseFloat(row.pweight) * (parseFloat(row.tratio) / 100), 2)
  390. } else {
  391. row.pweight = 0
  392. row.weight = 0
  393. }
  394. } else {
  395. if (row.supplyweight == 'NaN') {
  396. row.supplyweight = 0
  397. }
  398. if (row.Sfweight !== '' && row.ccountratio !== '' && row.SfweightLock !== '' && row.ccount) {
  399. row.pweight = formatNum(parseFloat(row.Sfweight) * parseFloat(row.ccountratio) + parseFloat(row.SfweightLock) * parseFloat(row.ccount), 2)
  400. row.weight = formatNum((parseFloat(row.pweight) + parseFloat(row.supplyweight)) * (parseFloat(row.tratio) / 100), 2)
  401. } else {
  402. row.pweight = 0
  403. row.weight = 0
  404. }
  405. }
  406. this.getSumWeight(row)
  407. },
  408. getSumWeight(row) {
  409. var barArr = []
  410. for (let i = 0; i < this.table.list.length; i++) {
  411. if (row.barid == this.table.list[i].barid) {
  412. barArr.push(this.table.list[i].weight)
  413. }
  414. }
  415. // console.log(barArr, 'barArr')
  416. var sumw = 0
  417. for (let i = 0; i < barArr.length; i++) {
  418. sumw += parseFloat(barArr[i])
  419. }
  420. // console.log(sumw, 'sumw')
  421. for (let i = 0; i < this.table.list.length; i++) {
  422. if (row.barid == this.table.list[i].barid) {
  423. this.table.list[i].sumweight = formatNum(sumw, 2)
  424. }
  425. }
  426. },
  427. // 配方模板
  428. changeRecipeTemplate(item, row) {
  429. row.ptname = this.recipeTemplateList.find(obj => obj.id == item).tname
  430. // Sfweight
  431. row.Sfweight = this.recipeTemplateList.find(obj => obj.id == item).Sfweight// Sfweight
  432. // SfweightLock
  433. row.SfweightLock = this.recipeTemplateList.find(obj => obj.id == item).SfweightLock// SfweightLock
  434. console.log('Sfweight', row.Sfweight)
  435. console.log('SfweightLock', row.SfweightLock)
  436. if (this.table.isPtsfname == false) {
  437. if (row.Sfweight !== '' && row.ccountratio !== '' && row.SfweightLock !== '' && row.ccount) {
  438. row.pweight = formatNum(parseFloat(row.Sfweight) * parseFloat(row.ccountratio) + parseFloat(row.SfweightLock) * parseFloat(row.ccount), 2)
  439. row.weight = formatNum(parseFloat(row.pweight) * (parseFloat(row.tratio) / 100), 2)
  440. } else {
  441. row.pweight = 0
  442. row.weight = 0
  443. }
  444. } else {
  445. if (row.supplyweight == 'NaN') {
  446. row.supplyweight = 0
  447. }
  448. if (row.Sfweight !== '' && row.ccountratio !== '' && row.SfweightLock !== '' && row.ccount) {
  449. row.pweight = formatNum(parseFloat(row.Sfweight) * parseFloat(row.ccountratio) + parseFloat(row.SfweightLock) * parseFloat(row.ccount), 2)
  450. row.weight = formatNum((parseFloat(row.pweight) + parseFloat(row.supplyweight)) * (parseFloat(row.tratio) / 100), 2)
  451. } else {
  452. row.pweight = 0
  453. row.weight = 0
  454. }
  455. }
  456. this.getSumWeight(row)
  457. },
  458. // 班次比例
  459. blurTratio(row) {
  460. if (row.pweight !== '' && row.ratio !== '' && row.tratio !== '') {
  461. row.weight = formatNum(parseFloat(row.pweight) * parseFloat(row.ratio) / 100 * parseFloat(row.tratio) / 100, 2)
  462. } else {
  463. row.weight = 0
  464. }
  465. this.getSumWeight(row)
  466. },
  467. // 班次重量
  468. blurWeight(row) {
  469. if (row.weight !== '' && row.pweight !== '' && row.ratio !== '') {
  470. row.tratio = formatNum(parseFloat(row.weight) / parseFloat(row.pweight) * parseFloat(row.ratio), 0)
  471. } else {
  472. row.tratio = 0
  473. }
  474. },
  475. updateData(row) {
  476. console.log(row, '编辑保存')
  477. this.isokDisable = true
  478. setTimeout(() => {
  479. this.isokDisable = false
  480. }, 5000)
  481. const positiveInteger = /^[1-9]\d*$/
  482. if (row.ccount !== '') {
  483. if (!positiveInteger.test(parseFloat(row.ccount))) {
  484. this.$message({ type: 'error', message: '实际牛头数请输入正整数', duration: 2000 })
  485. return false
  486. }
  487. } else {
  488. this.$message({ type: 'error', message: '实际牛头数不能为空', duration: 2000 })
  489. }
  490. const positiveNumber = /(^[1-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/
  491. if (row.ratio !== '') {
  492. if (!positiveNumber.test(parseFloat(row.ratio))) {
  493. this.$message({ type: 'error', message: '系数请输入正数', duration: 2000 })
  494. return false
  495. }
  496. } else {
  497. this.$message({ type: 'error', message: '系数不能为空', duration: 2000 })
  498. }
  499. if (row.ccountratio !== '') {
  500. if (!positiveNumber.test(parseFloat(row.ccountratio))) {
  501. this.$message({ type: 'error', message: '系数头数请输入正数', duration: 2000 })
  502. return false
  503. }
  504. } else {
  505. this.$message({ type: 'error', message: '系数头数不能为空', duration: 2000 })
  506. }
  507. this.requestParam = {}
  508. this.requestParam.common = { 'returnmap': '0' }
  509. this.requestParam.data = []
  510. this.requestParam.data[0] = { 'name': 'updatePlanModifyFPlist', 'type': 'e', 'parammaps': {
  511. pastureid: row.pastureid,
  512. date: this.date,
  513. id: row.id,
  514. ptweight: row.ptweight,
  515. pweight: row.pweight,
  516. weight: row.weight,
  517. tratio: row.tratio,
  518. cowcount: row.ccount,
  519. ccountradio: row.ratio,
  520. ptid: row.ptid,
  521. ptsid: row.ptsid
  522. }}
  523. this.requestParam.data[1] = { 'name': 'updateLPPbyFPChangedate', 'type': 'e', 'parammaps': {
  524. pastureid: row.pastureid,
  525. fpid: row.fpid,
  526. date: this.date,
  527. timesin: row.timesin
  528. }}
  529. ExecDataByConfig(this.requestParam).then(response => {
  530. if (response.msg === 'fail') {
  531. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  532. } else {
  533. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  534. this.getList()
  535. }
  536. })
  537. },
  538. updateCancel(row) {
  539. console.log('点击了编辑取消')
  540. // 编辑false,不可编辑true
  541. row.Edit = false
  542. row.NoEdit = true
  543. // 编辑true,编辑保存false
  544. row.isUpdate = true
  545. row.isUpdateSave = false
  546. console.log(this.table.getdataListParm.offset)
  547. this.table.getdataListParm.offset = this.table.getdataListParm.offset
  548. this.getList()
  549. }
  550. }
  551. }
  552. </script>
  553. <style>