Selaa lähdekoodia

增加新旧值对比

lichao 3 vuotta sitten
vanhempi
commit
b5700b4a62
2 muutettua tiedostoa jossa 107 lisäystä ja 41 poistoa
  1. 53 20
      src/views/dealer/purchase/detail.vue
  2. 54 21
      src/views/dealer/sales/detail.vue

+ 53 - 20
src/views/dealer/purchase/detail.vue

@@ -98,7 +98,13 @@
           @resetColumn="resetColumn"
         >
           <template slot="headerSerial" slot-scope="{column}">
-            <el-button type="primary" icon="el-icon-circle-plus-outline" circle size="mini" @click="$refs.crud.rowCellAdd()"></el-button>
+            <el-button
+              type="primary"
+              icon="el-icon-circle-plus-outline"
+              circle
+              size="mini"
+              :disabled="disabled || confirmDisabled"
+              @click="$refs.crud.rowCellAdd()"></el-button>
           </template>
           <template slot="menuLeft">
             <el-button
@@ -433,6 +439,7 @@ import {getDetail} from "@/api/basicData/inventoryAccount";
 import { getToken } from "@/util/auth";
 import { getCurrentDate } from "@/util/date";
 import viewHistory from '../componet/history';
+import { contrastObj, contrastList } from "@/util/contrastData";
 
 export default {
   name: "detail",
@@ -664,6 +671,9 @@ export default {
         total: 0
       },
       goodLoading: false,
+      oldForm: {},
+      oldDataList: [],
+      oldUploadData: [],
     }
   },
   async created() {
@@ -751,6 +761,9 @@ export default {
         this.uploadData = this.form.orderFilesList? this.form.orderFilesList: [];
         delete this.form.orderItemsList;
         delete this.form.orderFilesList;
+        this.oldForm = {...this.form};
+        this.oldDataList = [...this.dataList];
+        this.oldUploadData = [...this.uploadData];
       }).finally(() => {
         this.pageLoading = false;
       })
@@ -1255,26 +1268,28 @@ export default {
     },
     // 确认或者取消订单
     dealerSubmit() {
-      let dealer;
-      if (this.form.status == 0) {
-        dealer = 1;
-      } else if (this.form.status == 3) {
-        dealer = 2;
-      }
-      this.btnLoading = true;
-      dealerSubmit({
-        id: this.form.id,
-        dealer
-      }).then(res => {
-        if (res.data.code == 200) {
-          this.$message.success('操作成功')
-          this.queryData(this.form.id)
-        } else {
-          this.$message.error(res.data.msg)
+      if (this.verification()) {
+        let dealer;
+        if (this.form.status == 0) {
+          dealer = 1;
+        } else if (this.form.status == 3) {
+          dealer = 2;
         }
-      }).finally(() => {
-        this.btnLoading = false;
-      })
+        this.btnLoading = true;
+        dealerSubmit({
+          id: this.form.id,
+          dealer
+        }).then(res => {
+          if (res.data.code == 200) {
+            this.$message.success('操作成功')
+            this.queryData(this.form.id)
+          } else {
+            this.$message.error(res.data.msg)
+          }
+        }).finally(() => {
+          this.btnLoading = false;
+        })
+      }
     },
     // 下载模板
     downloadHandle() {
@@ -1369,6 +1384,24 @@ export default {
         this.goodLoading = false;
       })
     },
+    // 验证新旧值对比
+    verification() {
+      if (contrastObj(this.form, this.oldForm) ||
+        contrastList(this.dataList, this.oldDataList) ||
+        contrastList(this.uploadData, this.oldUploadData)) {
+        this.$confirm("数据发生变化未有提交记录, 是否提交?", "提示", {
+          confirmButtonText: "确定",
+          cancelButtonText: "取消",
+          type: "warning"
+        }).then(() => {
+          this.editCustomer();
+        }).catch(() => {
+          return false;   //取消改动数据
+        })
+      } else {
+        return true;
+      }
+    },
   },
 }
 </script>

+ 54 - 21
src/views/dealer/sales/detail.vue

@@ -119,7 +119,13 @@
           @resetColumn="resetColumn"
         >
           <template slot="headerSerial" slot-scope="{column}">
-            <el-button type="primary" icon="el-icon-circle-plus-outline" circle size="mini" @click="$refs.crud.rowCellAdd()"></el-button>
+            <el-button
+              type="primary"
+              icon="el-icon-circle-plus-outline"
+              circle
+              size="mini"
+              :disabled="disabled || !form.storageId || confirmDisabled"
+              @click="$refs.crud.rowCellAdd()"></el-button>
           </template>
           <template slot="menuLeft">
             <el-button
@@ -484,7 +490,8 @@ import {getDetail} from "@/api/basicData/inventoryAccount";
 import { getToken } from "@/util/auth";
 import { getCurrentDate } from "@/util/date";
 import viewHistory from '../componet/history';
-import { getMarketPrice, getPurchasePrice } from "@/api/basicData/fees"
+import { getMarketPrice, getPurchasePrice } from "@/api/basicData/fees";
+import { contrastObj, contrastList } from "@/util/contrastData";
 
 export default {
   name: "detail",
@@ -735,6 +742,9 @@ export default {
       uploadParam: {},
       historyVisible: false,
       historyParams: {},
+      oldForm: {},
+      oldDataList: [],
+      oldUploadData: [],
     }
   },
   async created() {
@@ -829,6 +839,9 @@ export default {
         this.uploadData = this.form.orderFilesList? this.form.orderFilesList: [];
         delete this.form.orderItemsList;
         delete this.form.orderFilesList;
+        this.oldForm = {...this.form};
+        this.oldDataList = [...this.dataList];
+        this.oldUploadData = [...this.uploadData];
         this.dataList.forEach(async item => {
           if (item.batch == 1) {
             item.arr = await this.getLotNo({
@@ -1483,26 +1496,28 @@ export default {
     },
     // 确认或者取消订单
     dealerSubmit() {
-      let dealer;
-      if (this.form.status == 0) {
-        dealer = 1;
-      } else if (this.form.status == 3) {
-        dealer = 2;
-      }
-      this.btnLoading = true;
-      dealerSubmit({
-        id: this.form.id,
-        dealer
-      }).then(res => {
-        if (res.data.code == 200) {
-          this.$message.success('操作成功')
-          this.queryData(this.form.id)
-        } else {
-          this.$message.error(res.data.msg)
+      if (this.verification()) {
+        let dealer;
+        if (this.form.status == 0) {
+          dealer = 1;
+        } else if (this.form.status == 3) {
+          dealer = 2;
         }
-      }).finally(() => {
-        this.btnLoading = false;
-      })
+        this.btnLoading = true;
+        dealerSubmit({
+          id: this.form.id,
+          dealer
+        }).then(res => {
+          if (res.data.code == 200) {
+            this.$message.success('操作成功')
+            this.queryData(this.form.id)
+          } else {
+            this.$message.error(res.data.msg)
+          }
+        }).finally(() => {
+          this.btnLoading = false;
+        })
+      }
     },
     // 下载模板
     downloadHandle() {
@@ -1589,6 +1604,24 @@ export default {
         this.salesPriceOtion = res.data.data
       })
     },
+    // 验证新旧值对比
+    verification() {
+      if (contrastObj(this.form, this.oldForm) ||
+        contrastList(this.dataList, this.oldDataList) ||
+        contrastList(this.uploadData, this.oldUploadData)) {
+        this.$confirm("数据发生变化未有提交记录, 是否提交?", "提示", {
+          confirmButtonText: "确定",
+          cancelButtonText: "取消",
+          type: "warning"
+        }).then(() => {
+          this.editCustomer();
+        }).catch(() => {
+          return false;   //取消改动数据
+        })
+      } else {
+        return true;
+      }
+    },
   },
 }
 </script>