Browse Source

关系计算添加限制,超过5个计算增加提示

zhangyu 3 years ago
parent
commit
5b4adc7851
2 changed files with 23 additions and 11 deletions
  1. 5 0
      src/components/relation/overview/CardList.vue
  2. 18 11
      src/views/relation/overview/index.vue

+ 5 - 0
src/components/relation/overview/CardList.vue

@@ -187,6 +187,7 @@ export default {
     content: Array,
     source: Array,
     TableVisibleMoreLoading: Boolean,
+		computingNum: Number,
     // cardDisabled: Boolean
   },
   data() {
@@ -241,6 +242,10 @@ export default {
         this.$emit("calcSpecialUpdate", params, this.isComputed);
     },
     computed(relation) {
+			if (this.computingNum >= 5) {
+				this.$message.info("当前计算过多,稍等一下");
+				return false;
+			}
       this.isComputed = relation // 当前要计算的对象
       if (relation.relationType) {
         this.$emit('calcSpecial', relation)

+ 18 - 11
src/views/relation/overview/index.vue

@@ -4,6 +4,7 @@
       :content="content"
       :source="source"
       :TableVisibleMoreLoading="TableVisibleMoreLoading"
+      :computingNum="computingNum"
       @calcSpecial="calcSpecial"
       @openComputed="openComputed"
       @RelationType="RelationType"
@@ -33,10 +34,12 @@ export default {
       loading: false,
       source: [], //源端数据
       currentRelationTypeName: "", //当前点击卡片的RelationTypeName
-      TableVisibleMoreLoading: false
+      TableVisibleMoreLoading: false,
+      computingNum: 0, //正在计算的关系数量
     };
   },
   created() {
+		this.computingNum = 0;
     this.init();
   },
   watch: {
@@ -123,7 +126,9 @@ export default {
           projectId: this.projectId
         }
       };
+      this.computingNum++;
       businessSpaceAll(param).then(res => {
+        this.computingNum--;
         if (res.data.result === "failure") {
           this.$message({
             message: "计算失败",
@@ -142,16 +147,18 @@ export default {
      * 计算需更新的关系
      */
     calcSpecialUpdate(params, obj) {
-        calcSpecial(params, res => {
-            if (res.result === "failure") {
-                this.$message.success('计算失败')
-            }
-            this.init();
-        })
-        obj.computationalState = 3
-        setTimeout(() => {
-            this.updateState();
-        })
+			this.computingNum++;
+			calcSpecial(params, res => {
+				this.computingNum--;
+				if (res.result === "failure") {
+					this.$message.success('计算失败')
+				}
+				this.init();
+			})
+			obj.computationalState = 3
+			setTimeout(() => {
+				this.updateState();
+			})
     },
     statusCard() {