|
@@ -318,6 +318,11 @@
|
|
|
<u-table-column :key="15" label="饲喂干物质量" prop="swdryw" min-width="70px" align="center" />
|
|
|
<u-table-column :key="16" label="采样干物质量" prop="cydryw" min-width="70px" align="center" />
|
|
|
<u-table-column :key="17" label="日投喂量" prop="sumweight" min-width="70px" align="center" />
|
|
|
+ <u-table-column :key="18" label="操作" prop="sumweight" align="center" width="80" class-name="small-padding fixed-width" fixed="right">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <span style="color: blue;" @click="handleRestore(scope.row)">恢复</span>
|
|
|
+ </template>
|
|
|
+ </u-table-column>
|
|
|
</u-table>
|
|
|
<!-- <pagination2 v-show="history.total>0" :total="history.total" :page.sync="history.getdataListParm.offset" :limit.sync="history.getdataListParm.pagecount" @pagination="getHistoryList" /> -->
|
|
|
</div>
|
|
@@ -3414,6 +3419,85 @@ export default {
|
|
|
this.getList()
|
|
|
this.isproportion = false
|
|
|
},
|
|
|
+ handleRestore(row){
|
|
|
+ // 恢复
|
|
|
+ MessageBox.confirm('是否进行恢复?', {
|
|
|
+ confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
|
|
|
+ }).then(() => {
|
|
|
+ const dataList = this.history.list
|
|
|
+ const result = dataList.filter(obj => obj.barname === row.barname);
|
|
|
+
|
|
|
+ const barList = []
|
|
|
+ result.forEach((item)=>{
|
|
|
+ let obj = {}
|
|
|
+ obj.barname = item.barname
|
|
|
+ obj.ccount = item.ccount
|
|
|
+ obj.ratio = item.ratio
|
|
|
+ // obj.ftname = item.ftname
|
|
|
+ // obj.ptsfname = item.ptsfname
|
|
|
+ if(item.timesin == '1'){ obj.times1 = item.tratio }else{ obj.times1 = 0 }
|
|
|
+ if(item.timesin == '2'){ obj.times2 = item.tratio }else{ obj.times2 = 0 }
|
|
|
+ if(item.timesin == '3'){ obj.times3 = item.tratio }else{ obj.times3 = 0 }
|
|
|
+ if(item.timesin == '4'){ obj.times4 = item.tratio }else{ obj.times4 = 0 }
|
|
|
+ if(item.timesin == '5'){ obj.times5 = item.tratio }else{ obj.times5 = 0 }
|
|
|
+ if(item.timesin == '6'){ obj.times6 = item.tratio }else{ obj.times6 = 0 }
|
|
|
+ barList.push(obj)
|
|
|
+ })
|
|
|
+
|
|
|
+ // 根据 "barname" 属性进行分组
|
|
|
+ const groupedData = barList.reduce((acc, obj) => {
|
|
|
+ const key = obj.barname;
|
|
|
+ if (!acc[key]) {
|
|
|
+ acc[key] = [obj];
|
|
|
+ } else {
|
|
|
+ acc[key].push(obj);
|
|
|
+ }
|
|
|
+ return acc;
|
|
|
+ }, {});
|
|
|
+
|
|
|
+ // 合并相同 "barname" 值的对象
|
|
|
+ const result1 = {};
|
|
|
+ for (const key in groupedData) {
|
|
|
+ if (Object.hasOwnProperty.call(groupedData, key)) {
|
|
|
+ result1[key] = this.mergeObjects(groupedData[key]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let arr1 = []
|
|
|
+ arr1.push(result1[row.barname])
|
|
|
+ console.log(arr1,'arr1')
|
|
|
+ const url = 'authdata/fpdetail/batch/edit'
|
|
|
+ let data = {
|
|
|
+ pastureId:Cookies.get('pastureid'),
|
|
|
+ barList:arr1
|
|
|
+ }
|
|
|
+ postJson(url, data).then(response => {
|
|
|
+ if(response.msg !== 'fail'){
|
|
|
+ this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
|
|
|
+ this.getDateList()
|
|
|
+ }else{
|
|
|
+ this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
|
|
|
+ }
|
|
|
+ this.isproportion = false
|
|
|
+ })
|
|
|
+ }).catch(() => {
|
|
|
+ this.$message({ type: 'info', message: '已取消恢复' })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ mergeObjects(arr) {
|
|
|
+ return arr.reduce((acc, obj) => {
|
|
|
+ for (const key in obj) {
|
|
|
+ if (Object.hasOwnProperty.call(obj, key)) {
|
|
|
+ if (!acc.hasOwnProperty(key)) {
|
|
|
+ acc[key] = obj[key];
|
|
|
+ } else if (!isNaN(parseFloat(obj[key]))) {
|
|
|
+ acc[key] = parseFloat(acc[key]) + parseFloat(obj[key]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return acc;
|
|
|
+ }, {});
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
</script>
|