8004a5bef0391d49b518d17628792d9ebc07549d.svn-base 25 KB

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