3c089c38f086a13af0a6652dc37e2d4fefc60f18.svn-base 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  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. // 软件牛头数softccount实际牛头数ccount系数(%)ratio系数头数ccountratio
  324. // row.pweight = formatNum(parseFloat(row.Sfweight) * parseFloat(row.ccountratio) + parseFloat(row.SfweightLock) * parseFloat(row.ccount), 2)
  325. // row.weight = formatNum(parseFloat(row.pweight) * (parseFloat(row.tratio) / 100), 2)
  326. row.pweight = formatNum(parseFloat(row.Sfweight) * parseFloat(row.ccount) * parseFloat(row.ratio) / 100 + parseFloat(row.SfweightLock) * parseFloat(row.ccount), 2)
  327. row.weight = formatNum(parseFloat(row.pweight) * (parseFloat(row.tratio) / 100), 2)
  328. } else {
  329. row.pweight = 0
  330. row.weight = 0
  331. }
  332. } else {
  333. if (row.supplyweight == 'NaN') {
  334. row.supplyweight = 0
  335. }
  336. if (row.Sfweight !== '' && row.ccountratio !== '' && row.SfweightLock !== '' && row.ccount) {
  337. // row.pweight = formatNum(parseFloat(row.Sfweight) * parseFloat(row.ccountratio) + parseFloat(row.SfweightLock) * parseFloat(row.ccount), 2)
  338. // row.weight = formatNum((parseFloat(row.pweight) + parseFloat(row.supplyweight)) * (parseFloat(row.tratio) / 100), 2)
  339. row.pweight = formatNum(parseFloat(row.Sfweight) * parseFloat(row.ccount) * parseFloat(row.ratio) / 100 + parseFloat(row.SfweightLock) * parseFloat(row.ccount), 2)
  340. row.weight = formatNum((parseFloat(row.pweight) + parseFloat(row.supplyweight)) * (parseFloat(row.tratio) / 100), 2)
  341. } else {
  342. row.pweight = 0
  343. row.weight = 0
  344. }
  345. }
  346. this.getSumWeight(row)
  347. },
  348. // 系数
  349. blurRatio(row) {
  350. if (row.ccount !== '' && row.ratio !== '') {
  351. row.ccountratio = formatNum(parseFloat(row.ccount) * parseFloat(row.ratio) / 100, 2)
  352. } else if (row.ccount !== '' && row.ccountratio !== '') {
  353. row.ratio = formatNum(parseFloat(row.ccountratio) * 100 / parseFloat(row.ccount), 2)
  354. } else if (row.ccount !== '' || row.ccountratio !== '') {
  355. row.ratio = ''
  356. }
  357. if (this.table.isPtsfname == false) {
  358. if (row.Sfweight !== '' && row.ccountratio !== '' && row.SfweightLock !== '' && row.ccount) {
  359. // row.pweight = formatNum(parseFloat(row.Sfweight) * parseFloat(row.ccountratio) + parseFloat(row.SfweightLock) * parseFloat(row.ccount), 2)
  360. row.pweight = formatNum(parseFloat(row.Sfweight) * parseFloat(row.ccount) * parseFloat(row.ratio) / 100 + parseFloat(row.SfweightLock) * parseFloat(row.ccount), 2)
  361. row.weight = formatNum(parseFloat(row.pweight) * (parseFloat(row.tratio) / 100), 2)
  362. } else {
  363. row.pweight = 0
  364. row.weight = 0
  365. }
  366. } else {
  367. if (row.supplyweight == 'NaN') {
  368. row.supplyweight = 0
  369. }
  370. if (row.Sfweight !== '' && row.ccountratio !== '' && row.SfweightLock !== '' && row.ccount) {
  371. // row.pweight = formatNum(parseFloat(row.Sfweight) * parseFloat(row.ccountratio) + parseFloat(row.SfweightLock) * parseFloat(row.ccount), 2)
  372. row.pweight = formatNum(parseFloat(row.Sfweight) * parseFloat(row.ccount) * parseFloat(row.ratio) / 100 + parseFloat(row.SfweightLock) * parseFloat(row.ccount), 2)
  373. row.weight = formatNum((parseFloat(row.pweight) + parseFloat(row.supplyweight)) * (parseFloat(row.tratio) / 100), 2)
  374. } else {
  375. row.pweight = 0
  376. row.weight = 0
  377. }
  378. }
  379. this.getSumWeight(row)
  380. },
  381. // 系数头数
  382. // 系数头数=实际牛头数*系数*100%;
  383. blurCcountratio(row) {
  384. if (row.ccountratio !== '' && row.ccount !== '' && row.ratio !== '') {
  385. row.ratio = formatNum(parseFloat(row.ccountratio) * 100 / parseFloat(row.ccount), 2)
  386. } else if (row.ccount !== '' && row.ratio !== '') {
  387. row.ccountratio = formatNum(parseFloat(row.ccount) * parseFloat(row.ratio) / 100, 2)
  388. } else if (row.ccountratio !== '' && row.ccount !== '') {
  389. row.ratio = formatNum(parseFloat(row.ccountratio) * 100 / parseFloat(row.ccount), 2)
  390. } else if (row.ccountratio !== '' && row.ratio !== '') {
  391. row.ccount = formatNum(parseFloat(row.ccountratio) * 100 / parseFloat(row.ratio) / 100, 2)
  392. }
  393. if (this.table.isPtsfname == false) {
  394. if (row.Sfweight !== '' && row.ccountratio !== '' && row.SfweightLock !== '' && row.ccount) {
  395. // row.pweight = formatNum(parseFloat(row.Sfweight) * parseFloat(row.ccountratio) + parseFloat(row.SfweightLock) * parseFloat(row.ccount), 2)
  396. row.pweight = formatNum(parseFloat(row.Sfweight) * parseFloat(row.ccount) * parseFloat(row.ratio) / 100 + parseFloat(row.SfweightLock) * parseFloat(row.ccount), 2)
  397. row.weight = formatNum(parseFloat(row.pweight) * (parseFloat(row.tratio) / 100), 2)
  398. } else {
  399. row.pweight = 0
  400. row.weight = 0
  401. }
  402. } else {
  403. if (row.supplyweight == 'NaN') {
  404. row.supplyweight = 0
  405. }
  406. if (row.Sfweight !== '' && row.ccountratio !== '' && row.SfweightLock !== '' && row.ccount) {
  407. // row.pweight = formatNum(parseFloat(row.Sfweight) * parseFloat(row.ccountratio) + parseFloat(row.SfweightLock) * parseFloat(row.ccount), 2)
  408. row.pweight = formatNum(parseFloat(row.Sfweight) * parseFloat(row.ccount) * parseFloat(row.ratio) / 100 + parseFloat(row.SfweightLock) * parseFloat(row.ccount), 2)
  409. row.weight = formatNum((parseFloat(row.pweight) + parseFloat(row.supplyweight)) * (parseFloat(row.tratio) / 100), 2)
  410. } else {
  411. row.pweight = 0
  412. row.weight = 0
  413. }
  414. }
  415. this.getSumWeight(row)
  416. },
  417. getSumWeight(row) {
  418. var barArr = []
  419. for (let i = 0; i < this.table.list.length; i++) {
  420. if (row.barid == this.table.list[i].barid) {
  421. barArr.push(this.table.list[i].weight)
  422. }
  423. }
  424. // console.log(barArr, 'barArr')
  425. var sumw = 0
  426. for (let i = 0; i < barArr.length; i++) {
  427. sumw += parseFloat(barArr[i])
  428. }
  429. // console.log(sumw, 'sumw')
  430. for (let i = 0; i < this.table.list.length; i++) {
  431. if (row.barid == this.table.list[i].barid) {
  432. this.table.list[i].sumweight = formatNum(sumw, 2)
  433. }
  434. }
  435. },
  436. // 配方模板
  437. changeRecipeTemplate(item, row) {
  438. row.ptname = this.recipeTemplateList.find(obj => obj.id == item).tname
  439. // Sfweight
  440. row.Sfweight = this.recipeTemplateList.find(obj => obj.id == item).Sfweight// Sfweight
  441. // SfweightLock
  442. row.SfweightLock = this.recipeTemplateList.find(obj => obj.id == item).SfweightLock// SfweightLock
  443. console.log('Sfweight', row.Sfweight)
  444. console.log('SfweightLock', row.SfweightLock)
  445. if (this.table.isPtsfname == false) {
  446. if (row.Sfweight !== '' && row.ccountratio !== '' && row.SfweightLock !== '' && row.ccount) {
  447. // row.pweight = formatNum(parseFloat(row.Sfweight) * parseFloat(row.ccountratio) + parseFloat(row.SfweightLock) * parseFloat(row.ccount), 2)
  448. row.pweight = formatNum(parseFloat(row.Sfweight) * parseFloat(row.ccount) * parseFloat(row.ratio) / 100 + parseFloat(row.SfweightLock) * parseFloat(row.ccount), 2)
  449. row.weight = formatNum(parseFloat(row.pweight) * (parseFloat(row.tratio) / 100), 2)
  450. } else {
  451. row.pweight = 0
  452. row.weight = 0
  453. }
  454. } else {
  455. if (row.supplyweight == 'NaN') {
  456. row.supplyweight = 0
  457. }
  458. if (row.Sfweight !== '' && row.ccountratio !== '' && row.SfweightLock !== '' && row.ccount) {
  459. // row.pweight = formatNum(parseFloat(row.Sfweight) * parseFloat(row.ccountratio) + parseFloat(row.SfweightLock) * parseFloat(row.ccount), 2)
  460. row.pweight = formatNum(parseFloat(row.Sfweight) * parseFloat(row.ccount) * parseFloat(row.ratio) / 100 + parseFloat(row.SfweightLock) * parseFloat(row.ccount), 2)
  461. row.weight = formatNum((parseFloat(row.pweight) + parseFloat(row.supplyweight)) * (parseFloat(row.tratio) / 100), 2)
  462. } else {
  463. row.pweight = 0
  464. row.weight = 0
  465. }
  466. }
  467. this.getSumWeight(row)
  468. },
  469. // 班次比例
  470. blurTratio(row) {
  471. if (row.pweight !== '' && row.tratio !== '') {
  472. row.weight = formatNum(parseFloat(row.pweight) * parseFloat(row.tratio) / 100, 2)
  473. } else {
  474. row.weight = 0
  475. }
  476. this.getSumWeight(row)
  477. },
  478. // 班次重量
  479. blurWeight(row) {
  480. if (row.weight !== '' && row.pweight !== '' && row.ratio !== '') {
  481. // row.tratio = formatNum(parseFloat(row.weight) / parseFloat(row.pweight) * parseFloat(row.ratio), 0)
  482. // row.tratio = formatNum(parseFloat(row.pweight) / parseFloat(row.weight), 0)
  483. row.tratio = formatNum(parseFloat(row.weight) / parseFloat(row.pweight) * 100, 0)
  484. } else {
  485. row.tratio = 0
  486. }
  487. },
  488. updateData(row) {
  489. console.log(row, '编辑保存')
  490. this.isokDisable = true
  491. setTimeout(() => {
  492. this.isokDisable = false
  493. }, 5000)
  494. const positiveInteger = /^[1-9]\d*$/
  495. if (row.ccount !== '') {
  496. if (!positiveInteger.test(parseFloat(row.ccount))) {
  497. this.$message({ type: 'error', message: '实际牛头数请输入正整数', duration: 2000 })
  498. return false
  499. }
  500. } else {
  501. this.$message({ type: 'error', message: '实际牛头数不能为空', duration: 2000 })
  502. }
  503. const positiveNumber = /(^[1-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/
  504. if (row.ratio !== '') {
  505. if (!positiveNumber.test(parseFloat(row.ratio))) {
  506. this.$message({ type: 'error', message: '系数请输入正数', duration: 2000 })
  507. return false
  508. }
  509. } else {
  510. this.$message({ type: 'error', message: '系数不能为空', duration: 2000 })
  511. }
  512. if (row.ccountratio !== '') {
  513. if (!positiveNumber.test(parseFloat(row.ccountratio))) {
  514. this.$message({ type: 'error', message: '系数头数请输入正数', duration: 2000 })
  515. return false
  516. }
  517. } else {
  518. this.$message({ type: 'error', message: '系数头数不能为空', duration: 2000 })
  519. }
  520. this.requestParam = {}
  521. this.requestParam.common = { 'returnmap': '0' }
  522. this.requestParam.data = []
  523. this.requestParam.data[0] = { 'name': 'updatePlanModifyFPlist', 'type': 'e', 'parammaps': {
  524. pastureid: row.pastureid,
  525. date: this.date,
  526. id: row.id,
  527. ptweight: row.ptweight,
  528. pweight: row.pweight,
  529. weight: row.weight,
  530. tratio: row.tratio,
  531. cowcount: row.ccount,
  532. ccountradio: row.ratio,
  533. ptid: row.ptid,
  534. ptsid: row.ptsid
  535. }}
  536. this.requestParam.data[1] = { 'name': 'updateLPPbyFPChangedate', 'type': 'e', 'parammaps': {
  537. pastureid: row.pastureid,
  538. fpid: row.fpid,
  539. date: this.date,
  540. timesin: row.timesin
  541. }}
  542. ExecDataByConfig(this.requestParam).then(response => {
  543. if (response.msg === 'fail') {
  544. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  545. } else {
  546. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  547. this.getList()
  548. }
  549. })
  550. },
  551. updateCancel(row) {
  552. console.log('点击了编辑取消')
  553. // 编辑false,不可编辑true
  554. row.Edit = false
  555. row.NoEdit = true
  556. // 编辑true,编辑保存false
  557. row.isUpdate = true
  558. row.isUpdateSave = false
  559. console.log(this.table.getdataListParm.offset)
  560. this.table.getdataListParm.offset = this.table.getdataListParm.offset
  561. this.getList()
  562. }
  563. }
  564. }
  565. </script>
  566. <style>