Browse Source

fixed:#545

huangbin 4 years ago
parent
commit
0119a997ac
1 changed files with 41 additions and 20 deletions
  1. 41 20
      src/common/components/permanceTemp/addPermanceTemp.vue

+ 41 - 20
src/common/components/permanceTemp/addPermanceTemp.vue

@@ -119,6 +119,7 @@ import { requestResultLoadingAndInfo } from '@/common/methods/request/resultInfo
 import { addPerformanceTemp } from '@/services/proto/performance';
 import { addPerformanceTemp } from '@/services/proto/performance';
 import { geLoginID_number } from '@/services/bus/login';
 import { geLoginID_number } from '@/services/bus/login';
 import { onMounted } from '@vue/runtime-core';
 import { onMounted } from '@vue/runtime-core';
+import { RuleObject } from 'ant-design-vue/lib/form/interface';
 
 
 // 初始化 模板
 // 初始化 模板
 const initTemp = (): PermanceTemp => {
 const initTemp = (): PermanceTemp => {
@@ -155,17 +156,21 @@ const useEditeTemp = (typeList: Ref<QueryWrPerformanceStepTypeRsp[]>) => {
     }
     }
     // 汇总
     // 汇总
     function isSummary({ steptypename }: PermanceTemp) {
     function isSummary({ steptypename }: PermanceTemp) {
-        return steptypename === '买方支付汇总' || steptypename === '卖方收款汇总' ? true : false;
+        return steptypename === '买方支付' || steptypename === '卖方收款' ? false : true;
     }
     }
     // 切换步骤类型
     // 切换步骤类型
     function stepTypeChange(item: PermanceTemp) {
     function stepTypeChange(item: PermanceTemp) {
         const stepType = findTemp(item)!;
         const stepType = findTemp(item)!;
         item.steptypename = stepType.steptypename;
         item.steptypename = stepType.steptypename;
         // 卖方收款汇总值必须为100%;
         // 卖方收款汇总值必须为100%;
-        if (isSummary(item)) {
-            item.stepvalue = 100;
-        }
+        // if (!isSummary(item)) {
+        //     item.stepvalue = 100;
+        // }
     }
     }
+    // function isDisable(temp: PermanceTemp) {
+    //     const { steptypename } = findTemp(temp)!;
+    //     return steptypename === '买方支付' || steptypename === '卖方收款';
+    // }
     return { isSummary, stepTypeChange };
     return { isSummary, stepTypeChange };
 };
 };
 
 
@@ -203,23 +208,39 @@ const userForm = (selectedRow: QueryPermancePlanTmpRsp) => {
         }
         }
         return Promise.resolve();
         return Promise.resolve();
     }
     }
-    function validateStepValue(value: any) {
-        const buyTotal = total('买方支付');
-        const sellTotal = total('卖方收款');
-        if (findIndex('买方支付') !== -1) {
-            if (buyTotal !== 100) {
-                return Promise.reject('买方支付汇总值必须为100%');
-            }
-        }
-        if (findIndex('卖方收款') !== -1) {
-            if (sellTotal !== 100) {
-                return Promise.reject('卖方收款汇总值必须为100%');
+
+    function validateStepValue(rule: any, value: number) {
+        debugger;
+        if (rule.field) {
+            const arr = rule.fullField.split('.');
+            if (Array.isArray(arr) && arr.length === 3) {
+                const index = +arr[1];
+                const item = formState.domains[index];
+                const steptypename = item.steptypename;
+                if (steptypename === '买方支付' || steptypename === '卖方收款') {
+                    if (!value) {
+                        return Promise.reject('请输入步骤值');
+                    }
+                    const buyTotal = total('买方支付');
+                    const sellTotal = total('卖方收款');
+                    if (findIndex('买方支付') !== -1) {
+                        if (buyTotal !== 100) {
+                            return Promise.reject('买方支付汇总值必须为100%');
+                        }
+                    }
+                    if (findIndex('卖方收款') !== -1) {
+                        if (sellTotal !== 100) {
+                            return Promise.reject('卖方收款汇总值必须为100%');
+                        }
+                    }
+
+                    if (sellTotal > buyTotal) {
+                        return Promise.reject('卖方收款不能多于买方付款');
+                    }
+                }
             }
             }
         }
         }
 
 
-        if (sellTotal > buyTotal) {
-            return Promise.reject('卖方收款不能多于买方付款');
-        }
         return Promise.resolve();
         return Promise.resolve();
     }
     }
     const rules = {
     const rules = {
@@ -230,8 +251,8 @@ const userForm = (selectedRow: QueryPermancePlanTmpRsp) => {
                 { required: true, validator: validateSepeTypeId },
                 { required: true, validator: validateSepeTypeId },
             ],
             ],
             stepvalue: [
             stepvalue: [
-                { required: true, message: '请输入步骤值', trigger: 'blur', type: 'number' },
-                { required: true, validator: validateStepValue },
+                // { required: true, message: '请输入步骤值', trigger: 'blur', type: 'number' },
+                { required: true, validator: validateStepValue, type: 'number' },
             ],
             ],
             stepdays: { required: true, message: '请输入距离上一步天数', trigger: 'blur', type: 'number' },
             stepdays: { required: true, message: '请输入距离上一步天数', trigger: 'blur', type: 'number' },
         },
         },