Browse Source

多人同时操作增加乐观锁、批量操作时的乐观锁

wang_xy 2 years ago
parent
commit
aa1a4a608c
4 changed files with 48 additions and 31 deletions
  1. 4 4
      src/api/gas/order.js
  2. 2 2
      src/views/gas/area/index.vue
  3. 18 12
      src/views/gas/order/index.vue
  4. 24 13
      src/views/gas/order/index1.vue

+ 4 - 4
src/api/gas/order.js

@@ -27,16 +27,16 @@ export function addOrder(data) {
 }
 
 // 批量合格
-export function submitY(id,reason, version) {
+export function submitY(id,reason, versions) {
   return request({
-    url: '/gas/order/submitY?ids=' + id+'&reason='+reason+'&version='+version,
+    url: '/gas/order/submitY?ids=' + id+'&reason='+reason+'&versions='+versions,
     method: 'get',
   })
 }
 // 批量不合格
-export function submitN(id,reason, version) {
+export function submitN(id,reason, versions) {
   return request({
-    url: '/gas/order/submitN?ids=' + id+'&reason='+reason+'&version='+version,
+    url: '/gas/order/submitN?ids=' + id+'&reason='+reason+'&versions='+versions,
     method: 'get',
   })
 }

+ 2 - 2
src/views/gas/area/index.vue

@@ -471,10 +471,10 @@ export default {
       this.upload.open = true;
     },
     handleUpload(row) {
-      // window.location.href="https://cczdsz.com/prod-api/gas/area/upload?id=" + row.id;
+      window.location.href="https://cczdsz.com/prod-api/gas/area/upload?id=" + row.id;
       // window.open("http://sz.cxcloudsci.com/prod-api/gas/area/upload?id=" + row.id, '_blank')
       // window.open("http://localhost:8080/gas/area/upload?id=" + row.id, '_blank')
-      window.location.href="http://localhost:8080/gas/area/upload?id=" + row.id;
+      // window.location.href="http://localhost:8080/gas/area/upload?id=" + row.id;
     },
     /** 下载模板操作 */
     importTemplate() {

+ 18 - 12
src/views/gas/order/index.vue

@@ -451,6 +451,8 @@ export default {
       houseList: [],
       // 选中数组
       ids: [],
+      // 选中数组的乐观锁
+      versions: [],
       // 非单个禁用
       single: true,
       // 非多个禁用
@@ -746,28 +748,30 @@ export default {
     submitY(row){
       if (this.form.id!=null){
         const ids = this.form.id;
+        const versions = this.form.version;
         this.$modal.confirm("确定审核?").then(() => {
           this.loading = true;
-          return submitY(ids,this.form.reason);
-        }).then(() => {
+          return submitY(ids,this.form.reason,versions);
+        }).then((res) => {
           this.open1 = false;
           this.loading = false;
           this.getList();
           this.getWorker();
-          this.$modal.msgSuccess("审核成功");
+          this.$modal.msgSuccess(res.msg);
         }).finally(() => {
           this.loading = false;
         });
       }else{
         const ids = row.id || this.ids;
+        const versions = row.version || this.versions;
         this.$modal.confirm("确定审核?").then(() => {
           this.loading = true;
-          return submitY(ids,this.form.reason);
-        }).then(() => {
+          return submitY(ids,this.form.reason,versions);
+        }).then((res) => {
           this.loading = false;
           this.getList();
           this.getWorker();
-          this.$modal.msgSuccess("审核成功");
+          this.$modal.msgSuccess(res.msg);
         }).finally(() => {
           this.loading = false;
         });
@@ -776,28 +780,30 @@ export default {
     submitN(row){
       if (this.form.id!=null){
         const ids = this.form.id;
+        const versions = this.form.version;
         this.$modal.confirm("确定审核?").then(() => {
           this.loading = true;
-          return submitN(ids,this.form.reason);
-        }).then(() => {
+          return submitN(ids,this.form.reason,versions);
+        }).then((res) => {
           this.open1 = false;
           this.loading = false;
           this.getList();
           this.getWorker();
-          this.$modal.msgSuccess("审核成功");
+          this.$modal.msgSuccess(res.msg);
         }).finally(() => {
           this.loading = false;
         });
       }else{
         const ids = row.id || this.ids;
+        const versions = row.version || this.versions;
         this.$modal.confirm("确定审核?").then(() => {
           this.loading = true;
-          return submitN(ids,this.form.reason);
-        }).then(() => {
+          return submitN(ids,this.form.reason,versions);
+        }).then((res) => {
           this.loading = false;
           this.getList();
           this.getWorker();
-          this.$modal.msgSuccess("审核成功");
+          this.$modal.msgSuccess(res.msg);
         }).finally(() => {
           this.loading = false;
         });

+ 24 - 13
src/views/gas/order/index1.vue

@@ -264,6 +264,8 @@ export default {
       houseList: [],
       // 选中数组
       ids: [],
+      // 选中数组的乐观锁
+      versions: [],
       // 非单个禁用
       single: true,
       // 非多个禁用
@@ -423,8 +425,13 @@ export default {
     // 多选框选中数据
     handleSelectionChange(selection) {
       this.ids = selection.map(item => item.id)
+      this.versions = selection.map(item => item.version)
       this.single = selection.length !== 1
-      this.multiple = !selection.length
+      this.multiple = !selection.length;
+
+      if(this.ids != null && this.ids.length>0){
+        this.form.id = null;
+      }
     },
     /** 修改按钮操作 */
     handleUpdate(row) {
@@ -472,28 +479,30 @@ export default {
     submitY(row){
       if (this.form.id!=null){
         const ids = this.form.id;
+        const versions = this.form.version;
         this.$modal.confirm("确定审核?").then(() => {
           this.loading = true;
-          return submitY(ids,this.form.reason,this.form.version);
-        }).then(() => {
+          return submitY(ids,this.form.reason,versions);
+        }).then((res) => {
           this.open = false;
           this.loading = false;
           this.getList();
           this.getWorker();
-          this.$modal.msgSuccess("审核成功");
+          this.$modal.msgSuccess(res.msg);
         }).finally(() => {
           this.loading = false;
         });
       }else{
         const ids = row.id || this.ids;
+        const versions = row.version || this.versions;
         this.$modal.confirm("确定审核?").then(() => {
           this.loading = true;
-          return submitY(ids,this.form.reason,this.form.version);
-        }).then(() => {
+          return submitY(ids,this.form.reason,versions);
+        }).then((res) => {
           this.loading = false;
           this.getList();
           this.getWorker();
-          this.$modal.msgSuccess("审核成功");
+          this.$modal.msgSuccess(res.msg);
         }).finally(() => {
           this.loading = false;
         });
@@ -502,28 +511,30 @@ export default {
     submitN(row){
       if (this.form.id!=null){
         const ids = this.form.id;
+        const versions = this.form.version;
         this.$modal.confirm("确定审核?").then(() => {
           this.loading = true;
-          return submitN(ids,this.form.reason,this.form.version);
-        }).then(() => {
+          return submitN(ids,this.form.reason,versions);
+        }).then((res) => {
           this.open = false;
           this.loading = false;
           this.getList();
           this.getWorker();
-          this.$modal.msgSuccess("审核成功");
+          this.$modal.msgSuccess(res.msg);
         }).finally(() => {
           this.loading = false;
         });
       }else{
         const ids = row.id || this.ids;
+        const versions = row.version || this.versions;
         this.$modal.confirm("确定审核?").then(() => {
           this.loading = true;
-          return submitN(ids,this.form.reason,this.form.version);
-        }).then(() => {
+          return submitN(ids,this.form.reason,versions);
+        }).then((res) => {
           this.loading = false;
           this.getList();
           this.getWorker();
-          this.$modal.msgSuccess("审核成功");
+          this.$modal.msgSuccess(res.msg);
         }).finally(() => {
           this.loading = false;
         });