Răsfoiți Sursa

Merge branch 'purchaseDev' into 'dev'

Purchase dev

See merge request new-business/drp-web!350
黄梓星 1 an în urmă
părinte
comite
ae6ced56dd

+ 44 - 4
src/components/super-form/index.vue

@@ -4,15 +4,15 @@ export default {
   props: {
     value: {
       type: [Object],
-      require: true,
+      required: true,
     },
     dict: {
       type: [Object],
-      require: true,
+      required: true,
     },
     columns: {
       type: [Array],
-      require: true,
+      required: true,
     },
   },
   components: {
@@ -46,6 +46,32 @@ export default {
   },
   watch: {},
   methods: {
+    //
+    getFormItemRequired(prop, value) {
+      if (typeof prop.required === "function") {
+        return prop.required(value);
+      }
+      if (typeof prop.required === "boolean") {
+        return prop.required;
+      }
+    },
+    //
+    getFormItemDisabled(prop, value) {
+      if (typeof prop.disabled === "function") {
+        return prop.disabled(value);
+      }
+      if (typeof prop.disabled === "boolean") {
+        return prop.disabled;
+      }
+    },
+    //
+    getPickerOptions(prop, value) {
+      if (typeof prop.disabled === "function") {
+        return prop.pickerOptions(value);
+      } else {
+        return prop.pickerOptions;
+      }
+    },
     // 继承el-table的Method
     extendMethod() {
       const refMethod = Object.entries(this.$refs["superForm"]);
@@ -78,7 +104,11 @@ export default {
         :key="index"
         :span="item.span"
       >
-        <el-form-item :prop="item.key" :label="item.title">
+        <el-form-item
+          :prop="item.key"
+          :label="item.title"
+          :required="getFormItemRequired(item, innerValue)"
+        >
           <slot :name="item.key" :row="innerValue" :item="item" :attr="attr">
             <component
               v-if="attr.is === 'el-select'"
@@ -129,9 +159,19 @@ export default {
             >
             </component>
             <component
+              v-else-if="attr.is === 'el-date-picker'"
+              v-bind="attr"
+              v-model="innerValue[item.key]"
+              :disabled="getFormItemDisabled(attr, innerValue)"
+              :pickerOptions="getPickerOptions(attr, innerValue)"
+              style="width: 100%"
+            >
+            </component>
+            <component
               v-else
               v-bind="attr"
               v-model="innerValue[item.key]"
+              :disabled="getFormItemDisabled(attr, innerValue)"
               style="width: 100%"
             >
             </component>

+ 3 - 4
src/components/super-table/index.vue

@@ -430,6 +430,9 @@ export default {
         justify-content: space-between;
         align-items: center;
       "
+      :style="{
+        height: checkbox || pagination ? '50px' : '0px',
+      }"
     >
       <div class="mr-4">
         <template v-if="checkbox">
@@ -452,10 +455,6 @@ export default {
         </template>
         <template v-if="convenitentOperation">
           <button-hide v-model="innerColumns" @change="onHide"></button-hide>
-          <!-- <button-freeze
-            v-model="showColumns"
-            @freeze="onFreeze"
-          ></button-freeze> -->
         </template>
       </div>
       <pagination

+ 1 - 1
src/utils/init.js

@@ -26,7 +26,7 @@ export const initParams = (prop, key = "key", value = "value") => {
 export const initRules = (prop) => {
   const rules = {};
   prop
-    .filter(({ item }) => item.require)
+    .filter(({ item }) => item.required)
     .forEach(({ item }) => {
       const message = `${item.title}不能为空`;
       rules[item.key] = [

+ 5 - 1
src/utils/request.js

@@ -164,7 +164,11 @@ service.interceptors.response.use(
       });
       // Message({ message: msg, type: "warning" });
       return Promise.reject("error");
-    } else if (code !== 200) {
+    } 
+    else if (code == 10000) {
+      return res.data;
+    }
+    else if (code !== 200) {
       Notification.error({
         title: msg.replaceAll(/(\n|\r|\r\n|↵)/g, "<br/>"),
         dangerouslyUseHTMLString: true,

+ 1 - 1
src/views/material/basicFile/columns.js

@@ -16,7 +16,7 @@ export const SearchColumns = [
   },
   {
     item:{
-      key: "code",
+      key: "codes",
       title: "物料编码",  
     },
     attr:{

+ 80 - 60
src/views/purchase/contract/add/columns.js

@@ -1,9 +1,10 @@
 import CONFIG from "@/config";
+import { iunitprice } from "@/utils/expression";
 
 export default function useColumns() {
   const TableColumns = [
     {
-      item: { key: "puOrgName", title: "采购组织", require: true, width: 150 },
+      item: { key: "puOrgName", title: "采购组织", required: true, width: 150 },
       attr: {
         is: "el-popover-select-v2",
         valueKey: "name",
@@ -31,11 +32,10 @@ export default function useColumns() {
       item: { key: "lastPuMoney", title: "上年度采购额", width: 100 },
       attr: {
         is: "el-input-number",
-        precision: CONFIG.precision,
       },
     },
     {
-      item: { key: "buyerName", title: "采购员", require: true, width: 100 },
+      item: { key: "buyerName", title: "采购员", required: true, width: 100 },
       attr: {
         is: "el-popover-select-v2",
         valueKey: "name",
@@ -49,7 +49,12 @@ export default function useColumns() {
       },
     },
     {
-      item: { key: "supplierName", title: "供应商", require: true, width: 100 },
+      item: {
+        key: "supplierName",
+        title: "供应商",
+        required: true,
+        width: 100,
+      },
       attr: {
         is: "el-popover-select-v2",
         valueKey: "name",
@@ -64,7 +69,7 @@ export default function useColumns() {
       item: {
         key: "contractType",
         title: "合同类型",
-        require: true,
+        required: true,
         width: 100,
       },
       attr: { is: "el-select", dictName: "puarchase_contract_contract_type" },
@@ -73,11 +78,15 @@ export default function useColumns() {
       item: { key: "puMoneyYear", title: "本年度采购额", width: 100 },
       attr: {
         is: "el-input-number",
-        precision: CONFIG.precision,
       },
     },
     {
-      item: { key: "puDeptName", title: "采购部门", require: true, width: 100 },
+      item: {
+        key: "puDeptName",
+        title: "采购部门",
+        required: true,
+        width: 100,
+      },
       attr: {
         is: "el-popover-select-v2",
         valueKey: "name",
@@ -92,7 +101,7 @@ export default function useColumns() {
       item: {
         key: "supplierTier",
         title: "供应商层级",
-        require: true,
+        required: true,
         width: 100,
       },
       attr: { is: "el-select", dictName: "puarchase_contract_supplier_tier" },
@@ -101,7 +110,7 @@ export default function useColumns() {
       item: {
         key: "contractName",
         title: "合同名称",
-        require: true,
+        required: true,
         width: 100,
       },
       attr: { is: "el-input" },
@@ -110,7 +119,7 @@ export default function useColumns() {
       item: {
         key: "grossRateAverage",
         title: "平均毛利率 (%)",
-        require: true,
+        required: true,
         width: 100,
       },
       attr: {
@@ -122,7 +131,7 @@ export default function useColumns() {
       item: {
         key: "approveFlow",
         title: "审批流程",
-        require: true,
+        required: true,
         width: 100,
       },
       attr: { is: "el-select", dictName: "puarchase_contract_approve_flow" },
@@ -131,7 +140,7 @@ export default function useColumns() {
       item: {
         key: "consumableClass",
         title: "耗材类别",
-        require: true,
+        required: true,
         width: 100,
       },
       attr: {
@@ -143,7 +152,7 @@ export default function useColumns() {
       item: {
         key: "effectiveDate",
         title: "合同生效日期",
-        require: true,
+        required: true,
         width: 100,
       },
       attr: {
@@ -155,7 +164,7 @@ export default function useColumns() {
       item: {
         key: "brandGrossRate",
         title: "同类品牌及毛利率 (%)",
-        require: true,
+        required: true,
       },
       attr: {
         is: "el-input-number",
@@ -166,7 +175,7 @@ export default function useColumns() {
       item: {
         key: "contractFormat",
         title: "合同格式",
-        require: true,
+        required: true,
         width: 100,
       },
       attr: {
@@ -178,7 +187,7 @@ export default function useColumns() {
       item: {
         key: "productName",
         title: "产品类别&名称",
-        require: true,
+        required: true,
         width: 100,
       },
       attr: { is: "el-input" },
@@ -187,16 +196,29 @@ export default function useColumns() {
       item: {
         key: "endDate",
         title: "合同终止日期",
-        require: true,
+        required: true,
         width: 100,
       },
-      attr: { is: "el-date-picker", valueFormat: "yyyy-MM-dd" },
+      attr: {
+        is: "el-date-picker",
+        valueFormat: "yyyy-MM-dd",
+        disabled: (prop) => !prop.effectiveDate,
+        pickerOptions: (prop) => {
+          return {
+            disabledDate(time) {
+              return (
+                time.getTime() < Date.now(prop.effectiveDate) - 3600 * 1000 * 24
+              );
+            },
+          };
+        },
+      },
     },
     {
       item: {
         key: "invoiceTax",
         title: "发票税率 (%)",
-        require: true,
+        required: true,
         width: 100,
       },
       attr: {
@@ -212,7 +234,7 @@ export default function useColumns() {
       item: {
         key: "emergencyDegree",
         title: "紧急程度",
-        require: true,
+        required: true,
         width: 100,
       },
       attr: {
@@ -221,14 +243,14 @@ export default function useColumns() {
       },
     },
     {
-      item: { key: "project", title: "项目医院", require: true, width: 100 },
+      item: { key: "project", title: "项目医院", required: true, width: 100 },
       attr: { is: "el-input" },
     },
     {
       item: {
         key: "deliveryType",
         title: "交货方式",
-        require: true,
+        required: true,
         width: 100,
       },
       attr: { is: "el-select", dictName: "puarchase_contract_delivery_type" },
@@ -253,7 +275,7 @@ export default function useColumns() {
       item: {
         key: "guaranteePeriodEnd",
         title: "质保期限",
-        require: true,
+        required: true,
         width: 100,
       },
       attr: { is: "el-input-number", precision: 2 },
@@ -270,11 +292,21 @@ export default function useColumns() {
       attr: { is: "el-date-picker", valueFormat: "yyyy-MM-dd" },
     },
     {
-      item: { key: "isTarget", title: "是否有指标", require: true, width: 100 },
+      item: {
+        key: "isTarget",
+        title: "是否有指标",
+        required: true,
+        width: 100,
+      },
       attr: { is: "el-select", dictName: "sys_yes_no" },
     },
     {
-      item: { key: "contractTarget", title: "合同指标", width: 100 },
+      item: {
+        key: "contractTarget",
+        title: "合同指标",
+        width: 100,
+        required: (prop) => prop.isTarget === "Y",
+      },
       attr: { is: "el-input", placeholder: '当【是否有指标】="有"时,必填' },
     },
     {
@@ -291,7 +323,12 @@ export default function useColumns() {
       },
     },
     {
-      item: { key: "isRebate", title: "是否有返利", require: true, width: 100 },
+      item: {
+        key: "isRebate",
+        title: "是否有返利",
+        required: true,
+        width: 100,
+      },
       attr: { is: "el-select", dictName: "sys_yes_no" },
     },
     {
@@ -299,8 +336,8 @@ export default function useColumns() {
         key: "rebatePolicy",
         title: "返利政策",
         span: 18,
-        require: true,
         width: 100,
+        required: (prop) => prop.isRebate === "Y",
       },
       attr: {
         is: "el-input",
@@ -315,7 +352,7 @@ export default function useColumns() {
       item: {
         key: "rollbackPolicy",
         title: "退换货政策",
-        require: true,
+        required: true,
         width: 100,
       },
       attr: { is: "el-input" },
@@ -328,7 +365,7 @@ export default function useColumns() {
       item: {
         key: "contractContent",
         title: "合同主要内容",
-        require: true,
+        required: true,
         span: 24,
         width: 100,
       },
@@ -338,14 +375,6 @@ export default function useColumns() {
       item: { key: "refusalReasons", title: "拒绝理由", span: 24, width: 100 },
       attr: { is: "el-input" },
     },
-    // {
-    //   item: { key: "pigeonhole", title: "是否归档" },
-    //   attr: { is: "el-select", dictName: "sys_yes_no", disabled: true },
-    // },
-    // {
-    //   item: { key: "pigeonholeFile", title: "归档附件", span: 24 },
-    //   attr: { is: "el-file-upload", fileType: ["pdf"], disabled: true },
-    // },
     {
       item: { key: "externalFile", title: "对外附件", span: 24, width: 100 },
       attr: { is: "el-file-upload", fileType: ["pdf"] },
@@ -385,7 +414,7 @@ export default function useColumns() {
       item: {
         key: "paymentAgreement",
         title: "付款协议",
-        require: true,
+        required: true,
         width: 100,
       },
       attr: {
@@ -402,11 +431,10 @@ export default function useColumns() {
       item: { key: "taxPrice", title: "价税合计", width: 100 },
       attr: {
         is: "el-input-number",
-        precision: CONFIG.precision,
       },
     },
     {
-      item: { key: "currencyName", title: "币种", require: true, width: 100 },
+      item: { key: "currencyName", title: "币种", required: true, width: 100 },
       attr: {
         is: "el-popover-select-v2",
         valueKey: "name",
@@ -421,7 +449,6 @@ export default function useColumns() {
       item: { key: "guaranteePeriod", title: "质保期", width: 100 },
       attr: {
         is: "el-input-number",
-        precision: CONFIG.precision,
       },
     },
   ].map(({ item, attr }) => ({
@@ -438,7 +465,7 @@ export default function useColumns() {
           item: {
             title: "物料名称",
             key: "materialName",
-            require: true,
+            required: true,
           },
           attr: {
             is: "el-popover-select-v2",
@@ -489,7 +516,7 @@ export default function useColumns() {
           },
         },
         {
-          item: { title: "税率%", key: "tax", require: true },
+          item: { title: "税率%", key: "tax", required: true },
           attr: {
             is: "el-popover-select-v2",
             valueKey: "ntaxrate",
@@ -506,10 +533,9 @@ export default function useColumns() {
           },
         },
         {
-          item: { title: "含税单价", key: "taxPrice", require: true },
+          item: { title: "含税单价", key: "taxPrice", required: true },
           attr: {
             is: "el-input-number",
-            precision: CONFIG.precision,
           },
         },
         {
@@ -523,14 +549,11 @@ export default function useColumns() {
           },
         },
         {
-          item: { title: "无税单价", key: "taxFreePrice", require: true },
+          item: { title: "无税单价", key: "taxFreePrice", required: true },
           attr: {
             formatter: (prop) => {
               const { tax = 0, taxPrice = 0 } = prop;
-              prop.taxFreePrice = ((taxPrice / (tax / 100 + 1)) * 1).toFixed(
-                CONFIG.precision
-              );
-              return prop.taxFreePrice;
+              return (prop.taxFreePrice = iunitprice(tax, taxPrice));
             },
           },
         },
@@ -539,8 +562,7 @@ export default function useColumns() {
           attr: {
             formatter: (prop) => {
               const { qty = 0, tax = 0, taxPrice = 0 } = prop;
-              prop.taxFreeMoney = qty * (taxPrice / (tax / 100 + 1)) * 1;
-              return prop.taxFreeMoney;
+              return (prop.taxFreeMoney = qty * iunitprice(tax, taxPrice));
             },
           },
         },
@@ -608,7 +630,7 @@ export default function useColumns() {
         },
         {
           item: { title: "费用金额", key: "money", width: "auto" },
-          attr: { is: "el-input-number", precision: CONFIG.precision },
+          attr: { is: "el-input-number" },
         },
       ],
     },
@@ -626,7 +648,7 @@ export default function useColumns() {
           item: {
             title: "付款起点",
             key: "origin",
-            require: true,
+            required: true,
           },
           attr: {
             is: "el-select",
@@ -634,24 +656,22 @@ export default function useColumns() {
           },
         },
         {
-          item: { title: "账期天数", key: "paymetDays", require: true },
+          item: { title: "账期天数", key: "paymetDays", required: true },
           attr: {
             is: "el-input-number",
             precision: 2,
           },
         },
         {
-          item: { title: "付款比例%", key: "ratio", require: true },
+          item: { title: "付款比例%", key: "ratio", required: true },
           attr: {
             is: "el-input-number",
-            precision: CONFIG.precision,
           },
         },
         {
           item: { title: "付款金额", key: "money" },
           attr: {
             is: "el-input-number",
-            precision: CONFIG.precision,
           },
         },
         {
@@ -678,7 +698,7 @@ export default function useColumns() {
           item: {
             title: "结算方式",
             key: "paymentMeans",
-            require: true,
+            required: true,
           },
           attr: {
             is: "el-popover-select-v2",
@@ -729,7 +749,7 @@ export default function useColumns() {
     item,
     TableColumns: TableColumns.map(({ item, attr }) => ({
       attr,
-      item: { ...item, hidden: true, span: item.span || 6 },
+      item: { ...item, hidden: true },
     })),
   }));
   return { TableColumns, TabColumns };

+ 120 - 122
src/views/purchase/contract/add/index.vue

@@ -4,7 +4,7 @@ import { ADD, CODE, LINKAGREEMENT } from "@/api/business/purchase/contract";
 import { tax, currency } from "@/components/popover-select-v2/fetch";
 
 export default {
-  name: "AddDrawer",
+  name: "AddFormModel",
   props: {
     selectData: {
       type: [Array],
@@ -14,9 +14,8 @@ export default {
       type: Object,
       require: true,
     },
-    addType: {
+    title: {
       type: String,
-      default: "add",
     },
   },
   components: {
@@ -37,9 +36,8 @@ export default {
     const rules = this.$init.rules([...TabColumns, ...TableColumns]);
     const params = this.$init.params([...TabColumns, ...TableColumns]);
     return {
-      width: "100%",
-      visible: false,
       loading: false,
+      loadingText: "",
       rules: rules,
       params: params,
       tabName: tabName,
@@ -47,50 +45,52 @@ export default {
       TableColumns: TableColumns,
     };
   },
-  computed: {
-    title: {
-      get() {
-        const { addType } = this.$props;
-        if (addType === "add") {
-          this.params.source = "自制";
-          return "新 增";
+  computed: {},
+  watch: {
+    "params.isRebate": {
+      handler: function (newValue) {
+        if (newValue === "Y") {
+          this.rules.rebatePolicy = [
+            { required: true, message: "返利政策不能为空", trigger: "change" },
+          ];
+        } else {
+          this.rules.rebatePolicy = null;
         }
-        if (addType === "record") {
-          this.params.source = "期初补录";
-          return "期初补录";
+      },
+      immediate: true,
+    },
+    "params.isTarget": {
+      handler: function (newValue) {
+        if (newValue === "Y") {
+          this.rules.contractTarget = [
+            { required: true, message: "合同指标不能为空", trigger: "change" },
+          ];
+        } else {
+          this.rules.contractTarget = null;
         }
       },
-      set() {},
+      immediate: true,
     },
   },
-  watch: {},
   methods: {
     //
-    async fetchCode() {
-      try {
-        // try
-        this.loading = true;
-        const data = await CODE();
-        if (data) {
-          this.params.code = data;
-        } else {
-        }
-      } catch (err) {
-        // catch
-        console.error(err);
-      } finally {
-        // finally
-        this.loading = false;
-      }
+    getTabTableColumnParams(prop) {
+      const { TableColumns } = this.TabColumns.find(
+        ({ item: { key } }) => key === prop
+      );
+      return this.$init.params(TableColumns);
     },
     //
     async changePaymentAgreement(prop) {
-      console.log(prop);
       const {
         selectData: { code },
       } = prop;
-      const res = await LINKAGREEMENT(code);
-      console.log("res", res);
+      const { data } = await LINKAGREEMENT(code);
+      this.tabName = "contractAgreementList";
+      this.params.contractAgreementList.push({
+        ...this.getTabTableColumnParams("contractAgreementList"),
+        ...data,
+      });
     },
     //
     async changeMaterialName(prop) {
@@ -111,50 +111,51 @@ export default {
     },
     //
     async open() {
-      this.visible = true;
-      this.fetchCode();
-      const {
-        user: {
-          deptId: puDept,
-          deptName: puDeptName,
-          name: buyer,
-          nickName: buyerName,
-          orgId: puOrg,
-          orgName: puOrgName,
-        },
-      } = this.$store.state;
-      this.params.puOrg = puOrg;
-      this.params.puOrgName = puOrgName;
-      this.params.buyer = buyer;
-      this.params.buyerName = buyerName;
-      this.params.puDept = puDept;
-      this.params.puDeptName = puDeptName;
-      const { id, code, name } = await currency("人民币");
-      this.params.currency = id;
-      this.params.currencyCode = code;
-      this.params.currencyName = name;
+      try {
+        //
+        this.loading = true;
+        this.loadingText = "获取合同编码中";
+        //
+        const {
+          user: {
+            deptId: puDept,
+            deptName: puDeptName,
+            name: buyer,
+            nickName: buyerName,
+            orgId: puOrg,
+            orgName: puOrgName,
+          },
+        } = this.$store.state;
+        this.params.puOrg = puOrg;
+        this.params.puOrgName = puOrgName;
+        this.params.buyer = buyer;
+        this.params.buyerName = buyerName;
+        this.params.puDept = puDept;
+        this.params.puDeptName = puDeptName;
+        //
+        const { title } = this.$props;
+        this.params.source = title === "新 增" ? "自制" : "期初补录";
+        //
+        const { id, code, name } = await currency("人民币");
+        this.params.currency = id;
+        this.params.currencyCode = code;
+        this.params.currencyName = name;
+        //
+        this.params.code = await CODE();
+        //
+        this.loading = false;
+      } catch (error) {
+        this.loading = false;
+        this.$notify.error(error);
+      }
     },
     //
     async hide() {
-      const {
-        TabColumns,
-        TableColumns,
-        TabColumns: [
-          {
-            item: { key: tabName },
-          },
-        ],
-      } = useColumns();
-      this.visible = false;
-      this.tabName = tabName;
-      this.params = this.$init.params([...TabColumns, ...TableColumns]);
+      this.$emit("close");
     },
     //
     async useRowAdd(prop) {
-      const { TableColumns } = this.TabColumns.find(
-        ({ item: { key } }) => key === prop
-      );
-      this.params[prop].push(this.$init.params(TableColumns));
+      this.params[prop].push(this.getTabTableColumnParams(prop));
     },
     //
     async useRowRemove(prop, scope) {
@@ -168,11 +169,12 @@ export default {
           try {
             // try
             this.loading = true;
+            this.loadingText = "提交合同中";
             const params = { ...this.params };
             const { msg, code } = await ADD(params);
             if (code === 200) {
               this.hide();
-              this.$emit("success");
+              this.$emit("submit-success");
               this.$notify.success(msg);
             }
           } catch (err) {
@@ -188,46 +190,41 @@ export default {
       });
     },
   },
-  created() {},
+  created() {
+    this.open();
+  },
   mounted() {},
   destroyed() {},
 };
 </script>
 <template>
-  <el-button v-bind="$attrs" v-on="$listeners" @click="open">
-    {{ title }}
-    <el-drawer
-      :size="width"
-      :title="title"
-      :visible.sync="visible"
-      append-to-body
-      destroy-on-close
-      :show-close="false"
-      @close="hide"
+  <div
+    v-loading="loading"
+    :element-loading-text="loadingText"
+    style="height: 100vh; display: flex; flex-direction: column"
+  >
+    <div
+      style="
+        height: 50px;
+        display: flex;
+        justify-content: space-between;
+        align-items: center;
+        padding: 0 18px;
+      "
     >
-      <div
-        slot="title"
-        style="
-          display: flex;
-          justify-content: space-between;
-          align-items: center;
-        "
+      <h4 class="m-0" style="font-weight: 500; flex: 1">{{ title }}</h4>
+      <el-button
+        type="primary"
+        :size="$attrs.size"
+        :loading="loading"
+        @click="useSubmit('superForm')"
+        >确 认</el-button
       >
-        <h3>{{ title }}</h3>
-        <div style="text-align: right">
-          <el-button
-            type="primary"
-            :size="$attrs.size"
-            :loading="loading"
-            @click="useSubmit('superForm')"
-            >确 认</el-button
-          >
-          <el-button :size="$attrs.size" :loading="loading" @click="hide"
-            >取 消</el-button
-          >
-        </div>
-      </div>
-
+      <el-button :size="$attrs.size" :loading="loading" @click="hide"
+        >取 消</el-button
+      >
+    </div>
+    <div v-if="params.code" style="flex: 1; overflow-y: auto">
       <el-super-form
         v-model="params"
         :dict="dict"
@@ -237,7 +234,7 @@ export default {
         ref="superForm"
         label-width="auto"
         label-position="right"
-        style="padding: 20px"
+        style="padding: 18px"
       >
         <template slot="paymentAgreement" slot-scope="scope">
           <component
@@ -250,15 +247,16 @@ export default {
           </component>
         </template>
       </el-super-form>
-
-      <el-tabs v-model="tabName" style="margin: 0 20px">
-        <el-tab-pane
-          v-for="{ item, TableColumns: columns } in TabColumns"
-          :key="item.key"
-          :label="item.title"
-          :name="item.key"
-          lazy
-        >
+    </div>
+    <el-tabs v-if="params.code" v-model="tabName" style="margin: 0 18px 18px">
+      <el-tab-pane
+        v-for="{ item, TableColumns: columns } in TabColumns"
+        :key="item.key"
+        :label="item.title"
+        :name="item.key"
+        lazy
+      >
+        <div style="height: 25vh; display: flex">
           <el-super-table
             v-model="params[item.key]"
             :dict="dict"
@@ -296,8 +294,8 @@ export default {
               </template>
             </el-table-column>
           </el-super-table>
-        </el-tab-pane>
-      </el-tabs>
-    </el-drawer>
-  </el-button>
+        </div>
+      </el-tab-pane>
+    </el-tabs>
+  </div>
 </template>

+ 260 - 143
src/views/purchase/contract/edit/columns.js

@@ -1,12 +1,13 @@
 import CONFIG from "@/config";
+import { iunitprice } from "@/utils/expression";
 
 export default function useColumns() {
   const TableColumns = [
     {
-      item: { width:100,key: "puOrgName", title: "采购组织", require: true ,},
+      item: { key: "puOrgName", title: "采购组织", required: true, width: 150 },
       attr: {
         is: "el-popover-select-v2",
-        valuewidth:100,key: "name",
+        valueKey: "name",
         referName: "ORG_PARAM",
         dataMapping: {
           puOrg: "code",
@@ -14,9 +15,12 @@ export default function useColumns() {
         },
       },
     },
-    { item: { width:100,key: "code", title: "合同编码" }, attr: { is: "el-input" } },
     {
-      item: { width:100,key: "status", title: "状态" },
+      item: { key: "code", title: "合同编码", width: 150 },
+      attr: { is: "el-input" },
+    },
+    {
+      item: { key: "status", title: "状态" },
       attr: {
         is: "el-select",
         dictName: "documents_status",
@@ -25,17 +29,16 @@ export default function useColumns() {
       },
     },
     {
-      item: { width:100,key: "lastPuMoney", title: "上年度采购额" },
+      item: { key: "lastPuMoney", title: "上年度采购额", width: 100 },
       attr: {
         is: "el-input-number",
-        precision: CONFIG.precision,
       },
     },
     {
-      item: { width:100,key: "buyerName", title: "采购员", require: true ,},
+      item: { key: "buyerName", title: "采购员", required: true, width: 100 },
       attr: {
         is: "el-popover-select-v2",
-        valuewidth:100,key: "name",
+        valueKey: "name",
         referName: "CONTACTS_PARAM",
         dataMapping: {
           buyer: "code",
@@ -46,10 +49,15 @@ export default function useColumns() {
       },
     },
     {
-      item: { width:100,key: "supplierName", title: "供应商", require: true, },
+      item: {
+        key: "supplierName",
+        title: "供应商",
+        required: true,
+        width: 100,
+      },
       attr: {
         is: "el-popover-select-v2",
-        valuewidth:100,key: "name",
+        valueKey: "name",
         referName: "SUPPLIER_PARAM",
         dataMapping: {
           supplier: "code",
@@ -58,21 +66,30 @@ export default function useColumns() {
       },
     },
     {
-      item: { width:100,key: "contractType", title: "合同类型", require: true ,},
+      item: {
+        key: "contractType",
+        title: "合同类型",
+        required: true,
+        width: 100,
+      },
       attr: { is: "el-select", dictName: "puarchase_contract_contract_type" },
     },
     {
-      item: { width:100,key: "puMoneyYear", title: "本年度采购额" },
+      item: { key: "puMoneyYear", title: "本年度采购额", width: 100 },
       attr: {
         is: "el-input-number",
-        precision: CONFIG.precision,
       },
     },
     {
-      item: { width:100,key: "puDeptName", title: "采购部门", require: true, },
+      item: {
+        key: "puDeptName",
+        title: "采购部门",
+        required: true,
+        width: 100,
+      },
       attr: {
         is: "el-popover-select-v2",
-        valuewidth:100,key: "name",
+        valueKey: "name",
         referName: "DEPT_PARAM",
         dataMapping: {
           puDept: "code",
@@ -81,33 +98,63 @@ export default function useColumns() {
       },
     },
     {
-      item: { width:100,key: "supplierTier", title: "供应商层级", require: true ,},
+      item: {
+        key: "supplierTier",
+        title: "供应商层级",
+        required: true,
+        width: 100,
+      },
       attr: { is: "el-select", dictName: "puarchase_contract_supplier_tier" },
     },
     {
-      item: { width:100,key: "contractName", title: "合同名称", require: true, },
+      item: {
+        key: "contractName",
+        title: "合同名称",
+        required: true,
+        width: 100,
+      },
       attr: { is: "el-input" },
     },
     {
-      item: { width:100,key: "grossRateAverage", title: "平均毛利率 (%)", require: true ,},
+      item: {
+        key: "grossRateAverage",
+        title: "平均毛利率 (%)",
+        required: true,
+        width: 100,
+      },
       attr: {
         is: "el-input-number",
         precision: 2,
       },
     },
     {
-      item: { width:100,key: "approveFlow", title: "审批流程", require: true, },
+      item: {
+        key: "approveFlow",
+        title: "审批流程",
+        required: true,
+        width: 100,
+      },
       attr: { is: "el-select", dictName: "puarchase_contract_approve_flow" },
     },
     {
-      item: { width:100,key: "consumableClass", title: "耗材类别", require: true, },
+      item: {
+        key: "consumableClass",
+        title: "耗材类别",
+        required: true,
+        width: 100,
+      },
       attr: {
         is: "el-select",
         dictName: "puarchase_contract_consumable_class",
       },
     },
     {
-      item: { width:100,key: "effectiveDate", title: "合同生效日期", require: true ,},
+      item: {
+        key: "effectiveDate",
+        title: "合同生效日期",
+        required: true,
+        width: 100,
+      },
       attr: {
         is: "el-date-picker",
         valueFormat: "yyyy-MM-dd",
@@ -115,9 +162,9 @@ export default function useColumns() {
     },
     {
       item: {
-        width:100,key: "brandGrossRate",
+        key: "brandGrossRate",
         title: "同类品牌及毛利率 (%)",
-        require: true,
+        required: true,
       },
       attr: {
         is: "el-input-number",
@@ -125,25 +172,58 @@ export default function useColumns() {
       },
     },
     {
-      item: { width:100,key: "contractFormat", title: "合同格式", require: true, },
+      item: {
+        key: "contractFormat",
+        title: "合同格式",
+        required: true,
+        width: 100,
+      },
       attr: {
         is: "el-select",
         dictName: "puarchase_contract_contract_format",
       },
     },
     {
-      item: { width:100,key: "productName", title: "产品类别&名称", require: true, },
+      item: {
+        key: "productName",
+        title: "产品类别&名称",
+        required: true,
+        width: 100,
+      },
       attr: { is: "el-input" },
     },
     {
-      item: { width:100,key: "endDate", title: "合同终止日期", require: true ,},
-      attr: { is: "el-date-picker", valueFormat: "yyyy-MM-dd" },
+      item: {
+        key: "endDate",
+        title: "合同终止日期",
+        required: true,
+        width: 100,
+      },
+      attr: {
+        is: "el-date-picker",
+        valueFormat: "yyyy-MM-dd",
+        disabled: (prop) => !prop.effectiveDate,
+        pickerOptions: (prop) => {
+          return {
+            disabledDate(time) {
+              return (
+                time.getTime() < Date.now(prop.effectiveDate) - 3600 * 1000 * 24
+              );
+            },
+          };
+        },
+      },
     },
     {
-      item: { width:100,key: "invoiceTax", title: "发票税率 (%)", require: true,},
+      item: {
+        key: "invoiceTax",
+        title: "发票税率 (%)",
+        required: true,
+        width: 100,
+      },
       attr: {
         is: "el-popover-select-v2",
-        valuewidth:100,key: "ntaxrate",
+        valueKey: "ntaxrate",
         referName: "TAX_RATE_PARAM",
         dataMapping: {
           invoiceTax: "ntaxrate",
@@ -151,29 +231,39 @@ export default function useColumns() {
       },
     },
     {
-      item: { width:100,key: "emergencyDegree", title: "紧急程度", require: true ,},
+      item: {
+        key: "emergencyDegree",
+        title: "紧急程度",
+        required: true,
+        width: 100,
+      },
       attr: {
         is: "el-select",
         dictName: "puarchase_contract_emergency_degree",
       },
     },
     {
-      item: { width:100,key: "project", title: "项目医院", require: true ,},
+      item: { key: "project", title: "项目医院", required: true, width: 100 },
       attr: { is: "el-input" },
     },
     {
-      item: { width:100,key: "deliveryType", title: "交货方式", require: true, },
+      item: {
+        key: "deliveryType",
+        title: "交货方式",
+        required: true,
+        width: 100,
+      },
       attr: { is: "el-select", dictName: "puarchase_contract_delivery_type" },
     },
     {
-      item: { width:100,key: "source", title: "合同来源" },
-      attr: { is: "el-input", value: "自制", disabled: true, },
+      item: { key: "source", title: "合同来源", width: 100 },
+      attr: { is: "el-input", value: "自制", disabled: true },
     },
     {
-      item: { width:100,key: "contractPartycName", title: "合同丙方" },
+      item: { key: "contractPartycName", title: "合同丙方", width: 100 },
       attr: {
         is: "el-popover-select-v2",
-        valuewidth:100,key: "name",
+        valueKey: "name",
         referName: "SUPPLIER_PARAM",
         dataMapping: {
           contractPartyc: "code",
@@ -182,30 +272,50 @@ export default function useColumns() {
       },
     },
     {
-      item: { width:100,key: "guaranteePeriodEnd", title: "质保期限", require: true ,},
+      item: {
+        key: "guaranteePeriodEnd",
+        title: "质保期限",
+        required: true,
+        width: 100,
+      },
       attr: { is: "el-input-number", precision: 2 },
     },
     {
-      item: { width:100,key: "freightMethods", title: "运费承担方式" },
+      item: { key: "freightMethods", title: "运费承担方式", width: 100 },
       attr: {
         is: "el-select",
         dictName: "puarchase_contract_freight_methods",
       },
     },
     {
-      item: { width:100,key: "signDate", title: "合同签订日期" },
+      item: { key: "signDate", title: "合同签订日期", width: 100 },
       attr: { is: "el-date-picker", valueFormat: "yyyy-MM-dd" },
     },
     {
-      item: { width:100,key: "isTarget", title: "是否有指标", require: true ,},
+      item: {
+        key: "isTarget",
+        title: "是否有指标",
+        required: true,
+        width: 100,
+      },
       attr: { is: "el-select", dictName: "sys_yes_no" },
     },
     {
-      item: { width:100,key: "contractTarget", title: "合同指标", require: true, },
+      item: {
+        key: "contractTarget",
+        title: "合同指标",
+        width: 100,
+        required: (prop) => prop.isTarget === "Y",
+      },
       attr: { is: "el-input", placeholder: '当【是否有指标】="有"时,必填' },
     },
     {
-      item: { width:100,key: "exemptionPostageCondtion", title: "包邮条件", span: 12 },
+      item: {
+        key: "exemptionPostageCondtion",
+        title: "包邮条件",
+        span: 12,
+        width: 100,
+      },
       attr: {
         is: "el-input",
         placeholder:
@@ -213,79 +323,103 @@ export default function useColumns() {
       },
     },
     {
-      item: { width:100,key: "isRebate", title: "是否有返利", require: true, },
+      item: {
+        key: "isRebate",
+        title: "是否有返利",
+        required: true,
+        width: 100,
+      },
       attr: { is: "el-select", dictName: "sys_yes_no" },
     },
     {
-      item: { width:100,key: "rebatePolicy", title: "返利政策", span: 18 },
+      item: {
+        key: "rebatePolicy",
+        title: "返利政策",
+        span: 18,
+        width: 100,
+        required: (prop) => prop.isRebate === "Y",
+      },
       attr: {
         is: "el-input",
         placeholder: '当【是否有返利】="有"时,必填',
       },
     },
     {
-      item: { width:100,key: "externalContract", title: "外部合同号" },
+      item: { key: "externalContract", title: "外部合同号", width: 100 },
       attr: { is: "el-input" },
     },
     {
-      item: { width:100,key: "rollbackPolicy", title: "退换货政策", require: true ,},
+      item: {
+        key: "rollbackPolicy",
+        title: "退换货政策",
+        required: true,
+        width: 100,
+      },
       attr: { is: "el-input" },
     },
     {
-      item: { width:100,key: "enquiryCode", title: "询价单号" },
+      item: { key: "enquiryCode", title: "询价单号", width: 100 },
       attr: { is: "el-input" },
     },
     {
       item: {
-        width:100,key: "contractContent",
+        key: "contractContent",
         title: "合同主要内容",
-        require: true,
+        required: true,
         span: 24,
+        width: 100,
       },
       attr: { is: "el-input", type: "textarea" },
     },
     {
-      item: { width:100,key: "refusalReasons", title: "拒绝理由", span: 24 },
+      item: { key: "refusalReasons", title: "拒绝理由", span: 24, width: 100 },
       attr: { is: "el-input" },
     },
-    // {
-    //   item: { width:100,key: "pigeonhole", title: "是否归档" },
-    //   attr: { is: "el-select", dictName: "sys_yes_no", disabled: true },
-    // },
-    // {
-    //   item: { width:100,key: "pigeonholeFile", title: "归档附件", span: 24 },
-    //   attr: { is: "el-file-upload", fileType: ["pdf"], disabled: true },
-    // },
     {
-      item: { width:100,key: "externalFile", title: "对外附件", span: 24 },
+      item: { key: "externalFile", title: "对外附件", span: 24, width: 100 },
       attr: { is: "el-file-upload", fileType: ["pdf"] },
     },
     {
-      item: { width:100,key: "puFile", title: "采购商盖章合同附件", span: 24 },
+      item: {
+        key: "puFile",
+        title: "采购商盖章合同附件",
+        span: 24,
+        width: 100,
+      },
       attr: { is: "el-file-upload", fileType: ["pdf"] },
     },
     {
-      item: { width:100,key: "supplierFile", title: "供应商盖章合同附件", span: 24 },
+      item: {
+        key: "supplierFile",
+        title: "供应商盖章合同附件",
+        span: 24,
+        width: 100,
+      },
       attr: { is: "el-file-upload", fileType: ["pdf"] },
     },
     {
-      item: { width:100,key: "projectCode", title: "项目编号" },
+      item: { key: "projectCode", title: "项目编号", width: 100 },
       attr: { is: "el-input" },
     },
     {
-      item: { width:100,key: "projectName", title: "项目名称" },
+      item: { key: "projectName", title: "项目名称", width: 100 },
       attr: { is: "el-input" },
     },
-    { item: { width:100,key: "area", title: "区域" }, attr: { is: "el-input" } },
+    { item: { key: "area", title: "区域" }, attr: { is: "el-input" } },
     {
-      item: { width:100,key: "consigneePhone", title: "收货人联系方式" },
+      item: { key: "consigneePhone", title: "收货人联系方式", width: 100 },
       attr: { is: "el-input" },
     },
     {
-      item: { width:100,key: "paymentAgreement", title: "付款协议", require: true, },
+      item: {
+        key: "paymentAgreement",
+        title: "付款协议",
+        required: true,
+        width: 100,
+      },
       attr: {
         is: "el-popover-select-v2",
-        valuewidth:100,key: "name",
+        valueKey: "name",
         referName: "PAYAGREEMENT_PARAM",
         dataMapping: {
           paymentAgreement: "code",
@@ -294,17 +428,16 @@ export default function useColumns() {
       },
     },
     {
-      item: { width:100,key: "taxPrice", title: "价税合计" },
+      item: { key: "taxPrice", title: "价税合计", width: 100 },
       attr: {
         is: "el-input-number",
-        precision: CONFIG.precision,
       },
     },
     {
-      item: { width:100,key: "currencyName", title: "币种", require: true, },
+      item: { key: "currencyName", title: "币种", required: true, width: 100 },
       attr: {
         is: "el-popover-select-v2",
-        valuewidth:100,key: "name",
+        valueKey: "name",
         referName: "CURRENCY_PARAM",
         dataMapping: {
           currency: "code",
@@ -313,10 +446,9 @@ export default function useColumns() {
       },
     },
     {
-      item: { width:100,key: "guaranteePeriod", title: "质保期" },
+      item: { key: "guaranteePeriod", title: "质保期", width: 100 },
       attr: {
         is: "el-input-number",
-        precision: CONFIG.precision,
       },
     },
   ].map(({ item, attr }) => ({
@@ -326,18 +458,18 @@ export default function useColumns() {
 
   const TabColumns = [
     {
-      item: { title: "物料基本信息", width:100,key: "contractItemList" },
+      item: { title: "物料基本信息", key: "contractItemList" },
       attr: { value: [] },
       TableColumns: [
         {
           item: {
             title: "物料名称",
-            width:100,key: "materialName",
-            require: true ,
+            key: "materialName",
+            required: true,
           },
           attr: {
             is: "el-popover-select-v2",
-            valuewidth:100,key: "name",
+            valueKey: "name",
             referName: "MATERIAL_PARAM",
             dataMapping: {
               material: "code",
@@ -352,32 +484,31 @@ export default function useColumns() {
         {
           item: {
             title: "物料编码",
-            width:100,key: "material",
-            require: true ,
+            key: "material",
           },
           attr: {},
         },
         {
           item: {
             title: "规格",
-            width:100,key: "specification",
+            key: "specification",
           },
           attr: {},
         },
         {
           item: {
             title: "生产厂家",
-            width:100,key: "manufacturer",
+            key: "manufacturer",
           },
           attr: {
             is: "el-input",
           },
         },
         {
-          item: { title: "采购单位", width:100,key: "puUnit" },
+          item: { title: "采购单位", key: "puUnit" },
           attr: {
             is: "el-popover-select-v2",
-            valuewidth:100,key: "name",
+            valueKey: "name",
             referName: "UNIT_PARAM",
             dataMapping: {
               puUnit: "name",
@@ -385,10 +516,10 @@ export default function useColumns() {
           },
         },
         {
-          item: { title: "税率%", width:100,key: "tax" ,require: true, },
+          item: { title: "税率%", key: "tax", required: true },
           attr: {
             is: "el-popover-select-v2",
-            valuewidth:100,key: "ntaxrate",
+            valueKey: "ntaxrate",
             referName: "TAX_RATE_PARAM",
             dataMapping: {
               tax: "ntaxrate",
@@ -396,65 +527,56 @@ export default function useColumns() {
           },
         },
         {
-          item: { title: "采购数量", width:100,key: "qty" },
+          item: { title: "采购数量", key: "qty" },
           attr: {
             is: "el-input-number",
           },
         },
         {
-          item: { title: "含税单价", width:100,key: "taxPrice" ,require: true, },
+          item: { title: "含税单价", key: "taxPrice", required: true },
           attr: {
             is: "el-input-number",
-            precision: CONFIG.precision,
           },
         },
         {
-          item: { title: "含税金额合计", width:100,key: "taxMoney" },
+          item: { title: "含税金额合计", key: "taxMoney" },
           attr: {
             formatter: (prop) => {
               const { qty = 0, taxPrice = 0 } = prop;
-              prop.taxMoney = (qty * taxPrice * 1);
+              prop.taxMoney = qty * taxPrice * 1;
               return prop.taxMoney;
             },
           },
         },
         {
-          item: { title: "无税单价", width:100,key: "taxFreePrice" ,require: true, },
+          item: { title: "无税单价", key: "taxFreePrice", required: true },
           attr: {
             formatter: (prop) => {
               const { tax = 0, taxPrice = 0 } = prop;
-              prop.taxFreePrice = ((taxPrice / (tax / 100 + 1)) * 1).toFixed(
-                CONFIG.precision
-              );
-              return prop.taxFreePrice;
+              return (prop.taxFreePrice = iunitprice(tax, taxPrice));
             },
           },
         },
         {
-          item: { title: "无税金额合计", width:100,key: "taxFreeMoney" },
+          item: { title: "无税金额合计", key: "taxFreeMoney" },
           attr: {
             formatter: (prop) => {
               const { qty = 0, tax = 0, taxPrice = 0 } = prop;
-              prop.taxFreeMoney = (
-                qty *
-                (taxPrice / (tax / 100 + 1)) *
-                1
-              );
-              return prop.taxFreeMoney;
+              return (prop.taxFreeMoney = qty * iunitprice(tax, taxPrice));
             },
           },
         },
         {
-          item: { title: "注册证号及备案凭证号", width:100,key: "registration" },
+          item: { title: "注册证号及备案凭证号", key: "registration" },
           attr: {
             is: "el-input",
           },
         },
         {
-          item: { title: "收货客户", width:100,key: "customerName" },
+          item: { title: "收货客户", key: "customerName" },
           attr: {
             is: "el-popover-select-v2",
-            valuewidth:100,key: "name",
+            valueKey: "name",
             referName: "CUSTOMER_PARAM",
             dataMapping: {
               customer: "code",
@@ -465,68 +587,68 @@ export default function useColumns() {
       ],
     },
     {
-      item: { title: "合同条款", width:100,key: "contractClauseList" },
+      item: { title: "合同条款", key: "contractClauseList" },
       attr: {
         value: [],
       },
       TableColumns: [
         {
-          item: { title: "条款编码", width:100,key: "code", width: "auto" },
+          item: { title: "条款编码", key: "code", width: "auto" },
           attr: { is: "el-input" },
         },
         {
-          item: { title: "条款名称", width:100,key: "name", width: "auto" },
+          item: { title: "条款名称", key: "name", width: "auto" },
           attr: { is: "el-input" },
         },
         {
-          item: { title: "条款内容", width:100,key: "content", width: "auto" },
+          item: { title: "条款内容", key: "content", width: "auto" },
           attr: { is: "el-input" },
         },
         {
-          item: { title: "变量序号", width:100,key: "variableRowno", width: "auto" },
+          item: { title: "变量序号", key: "variableRowno", width: "auto" },
           attr: { is: "el-input" },
         },
         {
-          item: { title: "变量内容", width:100,key: "variableContent", width: "auto" },
+          item: { title: "变量内容", key: "variableContent", width: "auto" },
           attr: { is: "el-input" },
         },
       ],
     },
     {
-      item: { title: "合同费用", width:100,key: "contractExpenseList" },
+      item: { title: "合同费用", key: "contractExpenseList" },
       attr: {
         value: [],
       },
       TableColumns: [
         {
-          item: { title: "费用编码", width:100,key: "code", width: "auto" },
+          item: { title: "费用编码", key: "code", width: "auto" },
           attr: { is: "el-input" },
         },
         {
-          item: { title: "费用名称", width:100,key: "name", width: "auto" },
+          item: { title: "费用名称", key: "name", width: "auto" },
           attr: { is: "el-input" },
         },
         {
-          item: { title: "费用金额", width:100,key: "money", width: "auto" },
-          attr: { is: "el-input-number", precision: CONFIG.precision },
+          item: { title: "费用金额", key: "money", width: "auto" },
+          attr: { is: "el-input-number" },
         },
       ],
     },
     {
-      item: { title: "付款协议信息", width:100,key: "contractAgreementList" },
+      item: { title: "付款协议信息", key: "contractAgreementList" },
       attr: {
         value: [],
       },
       TableColumns: [
         {
-          item: { title: "付款阶段", width:100,key: "satge" },
+          item: { title: "付款阶段", key: "satge" },
           attr: { is: "el-input-number" },
         },
         {
           item: {
             title: "付款起点",
-            width:100,key: "origin",
-            require: true 
+            key: "origin",
+            required: true,
           },
           attr: {
             is: "el-select",
@@ -534,30 +656,28 @@ export default function useColumns() {
           },
         },
         {
-          item: { title: "账期天数", width:100,key: "paymetDays" ,require: true, },
+          item: { title: "账期天数", key: "paymetDays", required: true },
           attr: {
             is: "el-input-number",
             precision: 2,
           },
         },
         {
-          item: { title: "付款比例%", width:100,key: "ratio",require: true,  },
+          item: { title: "付款比例%", key: "ratio", required: true },
           attr: {
             is: "el-input-number",
-            precision: CONFIG.precision,
           },
         },
         {
-          item: { title: "付款金额", width:100,key: "money" },
+          item: { title: "付款金额", key: "money" },
           attr: {
             is: "el-input-number",
-            precision: CONFIG.precision,
           },
         },
         {
           item: {
             title: "是否预付款",
-            width:100,key: "isAdvance",
+            key: "isAdvance",
           },
           attr: {
             is: "el-select",
@@ -567,7 +687,7 @@ export default function useColumns() {
         {
           item: {
             title: "是否质保金",
-            width:100,key: "isQuality",
+            key: "isQuality",
           },
           attr: {
             is: "el-select",
@@ -577,12 +697,12 @@ export default function useColumns() {
         {
           item: {
             title: "结算方式",
-            width:100,key: "paymentMeans",
-            require:true,
+            key: "paymentMeans",
+            required: true,
           },
           attr: {
             is: "el-popover-select-v2",
-            valuewidth:100,key: "name",
+            valueKey: "name",
             referName: "BALATYPE_PARAM",
             dataMapping: {
               paymentMeans: "name",
@@ -592,7 +712,7 @@ export default function useColumns() {
         {
           item: {
             title: "需进度确认",
-            width:100,key: "schedule",
+            key: "schedule",
           },
           attr: {
             is: "el-select",
@@ -602,18 +722,18 @@ export default function useColumns() {
       ],
     },
     {
-      item: { title: "合同执行组织范围", width:100,key: "contractApplyOrgList" },
+      item: { title: "合同执行组织范围", key: "contractApplyOrgList" },
       attr: { value: [] },
       TableColumns: [
         {
           item: {
             title: "组织名称",
-            width:100,key: "orgName",
+            key: "orgName",
             width: "auto",
           },
           attr: {
             is: "el-popover-select-v2",
-            valuewidth:100,key: "name",
+            valueKey: "name",
             referName: "ORG_PARAM",
             dataMapping: {
               org: "code",
@@ -621,19 +741,16 @@ export default function useColumns() {
             },
           },
         },
-        { item: { title: "组织编码", width:100,key: "org", width: "auto" }, attr: {} },
+        { item: { title: "组织编码", key: "org", width: "auto" }, attr: {} },
       ],
     },
-  ].map(({item,attr,TableColumns}) =>({
+  ].map(({ item, attr, TableColumns }) => ({
     attr,
     item,
-    TableColumns:TableColumns.map(({item, attr}) =>({
+    TableColumns: TableColumns.map(({ item, attr }) => ({
       attr,
-      item: { ...item, hidden: true, span: item.span || 6 },
-  
-    }))
-
-  }))
-  ;
+      item: { ...item, hidden: true },
+    })),
+  }));
   return { TableColumns, TabColumns };
 }

+ 116 - 91
src/views/purchase/contract/edit/index.vue

@@ -1,16 +1,15 @@
 <script>
 import useColumns from "./columns";
-import { initParams, initRules } from "@/utils/init.js";
-import { REFER } from "@/components/popover-select/api";
 import {
   EDIT,
   ITEM,
   TABLE,
   ALTERATION,
 } from "@/api/business/purchase/contract";
+import { tax } from "@/components/popover-select-v2/fetch";
 
 export default {
-  name: "EditDrawer",
+  name: "EditFormModel",
   props: {
     selectData: {
       type: [Array],
@@ -20,6 +19,9 @@ export default {
       type: Object,
       require: true,
     },
+    title: {
+      type: String,
+    },
   },
   components: {
     ElSuperForm: () => import("@/components/super-form/index.vue"),
@@ -39,10 +41,8 @@ export default {
     const rules = this.$init.rules(TableColumns);
     const params = this.$init.params([...TabColumns, ...TableColumns]);
     return {
-      title: "编 辑",
-      width: "100%",
-      visible: false,
       loading: false,
+      loadingText: "",
       rules: rules,
       params: params,
       tabName: tabName,
@@ -51,33 +51,68 @@ export default {
     };
   },
   computed: {
-    disabled: {
+    id: {
       get() {
-        const { selectData } = this;
-        if (selectData.length !== 1) {
-          return true;
-        }
+        return this.$props.selectData[0].id;
       },
       set() {},
     },
   },
-  watch: {},
+  watch: {
+    "params.isRebate": {
+      handler: function (newValue) {
+        if (newValue === "Y") {
+          this.rules.rebatePolicy = [
+            { required: true, message: "返利政策不能为空", trigger: "change" },
+          ];
+        } else {
+          this.rules.rebatePolicy = null;
+        }
+      },
+      immediate: true,
+    },
+    "params.isTarget": {
+      handler: function (newValue) {
+        if (newValue === "Y") {
+          this.rules.contractTarget = [
+            { required: true, message: "合同指标不能为空", trigger: "change" },
+          ];
+        } else {
+          this.rules.contractTarget = null;
+        }
+      },
+      immediate: true,
+    },
+  },
   methods: {
     //
+    getTabTableColumnParams(prop) {
+      const { TableColumns } = this.TabColumns.find(
+        ({ item: { key } }) => key === prop
+      );
+      return this.$init.params(TableColumns);
+    },
+    //
+    async changePaymentAgreement(prop) {
+      const {
+        selectData: { code },
+      } = prop;
+      const { data } = await LINKAGREEMENT(code);
+      this.tabName = "contractAgreementList";
+      this.params.contractAgreementList.push({
+        ...this.getTabTableColumnParams("contractAgreementList"),
+        ...data,
+      });
+    },
+    //
     async changeMaterialName(prop) {
       const { row } = prop;
       const { rateCode } = row;
       try {
         // try
         this.loading = true;
-        const { code, rows } = await REFER({
-          search: rateCode,
-          type: "TAX_RATE_PARAM",
-        });
-        if (code === 200) {
-          const [{ ntaxrate }] = rows;
-          row.tax = ntaxrate === "0E-8" ? "0.00000000" : ntaxrate;
-        }
+        const { ntaxrate } = await tax(rateCode);
+        row.tax = Number(ntaxrate === "0E-8" ? 0 : ntaxrate);
       } catch (err) {
         // catch
         console.error(err);
@@ -91,12 +126,11 @@ export default {
       try {
         // try
         this.loading = true;
+        this.loadingText = "获取合同中";
         const { code, data } = await ITEM(prop);
         if (code === 200) {
           this.params = data;
-          return true;
         } else {
-          return false;
         }
       } catch (err) {
         // catch
@@ -108,31 +142,15 @@ export default {
     },
     //
     async open() {
-      const { selectData } = this.$props;
-      const [{ id }] = selectData;
-      this.visible = await this.fetchItem(id);
+      await this.fetchItem(this.id);
     },
     //
     async hide() {
-      const {
-        TabColumns,
-        TableColumns,
-        TabColumns: [
-          {
-            item: { key: tabName },
-          },
-        ],
-      } = useColumns();
-      this.visible = false;
-      this.tabName = tabName;
-      this.params = this.$init.params([...TabColumns, ...TableColumns]);
+      this.$emit("close");
     },
     //
     async useRowAdd(prop) {
-      const { TableColumns } = this.TabColumns.find(
-        ({ item: { key } }) => key === prop
-      );
-      this.params[prop].push(this.$init.params(TableColumns));
+      this.params[prop].push(this.getTabTableColumnParams(prop));
     },
     //
     async useRowRemove(prop, scope) {
@@ -145,6 +163,7 @@ export default {
         try {
           // try
           this.loading = true;
+          this.loadingText = "删除子表中";
           const { code } = REMOVE(id, prop);
           if (code === 200) {
             this.fetchItem(contractId);
@@ -172,8 +191,10 @@ export default {
         // try
         this.loading = true;
         if (contractId) {
+          this.loadingText = "更新子表中";
           await EDIT(row, prop);
         } else {
+          this.loadingText = "新增信息中";
           await ADD({ ...row, contractId: id }, prop);
         }
       } catch (err) {
@@ -192,6 +213,7 @@ export default {
           try {
             // try
             this.loading = true;
+            this.loadingText = "更新合同中";
             const {
               params,
               params: { status },
@@ -200,7 +222,7 @@ export default {
             const { msg, code } = await TASK(params);
             if (code === 200) {
               this.hide();
-              this.$emit("success");
+              this.$emit("submit-success");
               this.$notify.success(msg);
             }
           } catch (err) {
@@ -216,50 +238,41 @@ export default {
       });
     },
   },
-  created() {},
+  created() {
+    this.open();
+  },
   mounted() {},
   destroyed() {},
 };
 </script>
 <template>
-  <el-button
-    v-bind="$attrs"
-    v-on="$listeners"
-    :disabled="disabled"
-    @click="open"
+  <div
+    v-loading="loading"
+    :element-loading-text="loadingText"
+    style="height: 100vh; display: flex; flex-direction: column"
   >
-    {{ title }}
-    <el-drawer
-      :size="width"
-      :title="title"
-      :visible.sync="visible"
-      append-to-body
-      :show-close="false"
-      destroy-on-close
-      @close="hide"
+    <div
+      style="
+        height: 50px;
+        display: flex;
+        justify-content: space-between;
+        align-items: center;
+        padding: 0 18px;
+      "
     >
-      <div
-        slot="title"
-        style="
-          display: flex;
-          justify-content: space-between;
-          align-items: center;
-        "
+      <h4 class="m-0" style="font-weight: 500; flex: 1">{{ title }}</h4>
+      <el-button
+        type="primary"
+        :size="$attrs.size"
+        :loading="loading"
+        @click="useSubmit('superForm')"
+        >确 认</el-button
       >
-        <h3>{{ title }}</h3>
-        <div style="text-align: right">
-          <el-button
-            type="primary"
-            :size="$attrs.size"
-            :loading="loading"
-            @click="useSubmit('superForm')"
-            >确 认</el-button
-          >
-          <el-button :size="$attrs.size" :loading="loading" @click="hide"
-            >取 消</el-button
-          >
-        </div>
-      </div>
+      <el-button :size="$attrs.size" :loading="loading" @click="hide"
+        >取 消</el-button
+      >
+    </div>
+    <div v-if="params.code" style="flex: 1; overflow-y: auto">
       <el-super-form
         v-model="params"
         :dict="dict"
@@ -269,16 +282,28 @@ export default {
         ref="superForm"
         label-width="auto"
         label-position="right"
-        style="padding: 20px"
+        style="padding: 18px"
+      >
+        <template slot="paymentAgreement" slot-scope="scope">
+          <component
+            v-bind="scope.attr"
+            v-model="scope.row[scope.item.key]"
+            :size="$attrs.size"
+            :source.sync="scope.row"
+            @change="changePaymentAgreement({ ...scope, selectData: $event })"
+          >
+          </component> </template
       ></el-super-form>
-      <el-tabs v-model="tabName" style="margin: 0 20px">
-        <el-tab-pane
-          v-for="{ item, TableColumns: columns } in TabColumns"
-          :key="item.key"
-          :label="item.title"
-          :name="item.key"
-          lazy
-        >
+    </div>
+    <el-tabs v-if="params.code" v-model="tabName" style="margin: 0 18px 18px">
+      <el-tab-pane
+        v-for="{ item, TableColumns: columns } in TabColumns"
+        :key="item.key"
+        :label="item.title"
+        :name="item.key"
+        lazy
+      >
+        <div style="height: 25vh; display: flex">
           <el-super-table
             v-model="params[item.key]"
             :dict="dict"
@@ -322,8 +347,8 @@ export default {
               </template>
             </el-table-column>
           </el-super-table>
-        </el-tab-pane>
-      </el-tabs>
-    </el-drawer>
-  </el-button>
+        </div>
+      </el-tab-pane>
+    </el-tabs>
+  </div>
 </template>

+ 86 - 34
src/views/purchase/contract/index.vue

@@ -6,9 +6,10 @@ export default {
   name: "PuchaseContract",
   dicts: dicts,
   components: {
-    AddButton: () => import("./add/index.vue"),
+    AddFormModel: () => import("./add/index.vue"),
+    EditFormModel: () => import("./edit/index.vue"),
+    SeeFormModel: () => import("./see/index.vue"),
     SeeButton: () => import("./see/index.vue"),
-    EditButton: () => import("./edit/index.vue"),
     DeleButton: () => import("./delete/index.vue"),
     SubmButton: () => import("./submit/index.vue"),
     TermButton: () => import("./termination/index.vue"),
@@ -23,6 +24,8 @@ export default {
     return {
       size: "mini",
       loading: false,
+      drawerVisible: false,
+      components: { is: "", title: "" },
       params: params,
       tableData: [],
       selectData: [],
@@ -31,7 +34,35 @@ export default {
       page: { pageNum: 1, pageSize: 10, total: 0 },
     };
   },
-  computed: {},
+  computed: {
+    SeeDisabled: {
+      get() {
+        const { selectData } = this;
+        if (selectData.length !== 1) {
+          return true;
+        }
+      },
+      set() {},
+    },
+    EditDisabled: {
+      get() {
+        const {
+          selectData,
+          selectData: [{ status } = {}],
+        } = this;
+        if (selectData.length !== 1) {
+          return true;
+        }
+        if (selectData.length === 1 && status === "1") {
+          return true;
+        }
+        if (selectData.length === 1 && status === "3") {
+          return true;
+        }
+      },
+      set() {},
+    },
+  },
   created() {
     this.useQuery(this.params, this.page);
   },
@@ -83,8 +114,27 @@ export default {
     // 明 细
     async useSee(prop) {
       const { id } = prop;
-      const { open } = this.$refs.SeeButton;
-      await open(id);
+      this.drawerVisible = true;
+      this.components.title = id ? "明 细-" + id : "明 细";
+      this.components.is = "SeeFormModel";
+    },
+    // 新 增
+    useAdd() {
+      this.drawerVisible = true;
+      this.components.title = "新 增";
+      this.components.is = "AddFormModel";
+    },
+    // 期 初 补 录
+    useReord() {
+      this.drawerVisible = true;
+      this.components.title = "期 初 补 录";
+      this.components.is = "AddFormModel";
+    },
+    // 编 辑
+    useEdit() {
+      this.drawerVisible = true;
+      this.components.title = "编 辑";
+      this.components.is = "EditFormModel";
     },
   },
 };
@@ -108,43 +158,45 @@ export default {
       @reset="useReset"
       @submit="useQuery(params, page)"
     ></el-super-search>
-    <div style="margin: 20px 0; text-align: right">
+    <el-drawer
+      size="100%"
+      title="title"
+      :show-close="false"
+      :with-header="false"
+      :visible.sync="drawerVisible"
+      append-to-body
+      destroy-on-close
+    >
+      <components
+        :size="size"
+        :dict="dict"
+        :is="components.is"
+        :title="components.title"
+        :select-data="selectData"
+        @close="drawerVisible = false"
+        @submit-success="useQuery(params, page)"
+      ></components>
+    </el-drawer>
+    <div style="margin: 18px 0; text-align: right">
       <el-button-group>
-        <add-button
-          :size="size"
-          :dict="dict"
-          :add-type="'add'"
-          :select-data="selectData"
-          @success="useQuery(params, page)"
-        ></add-button>
-        <add-button
-          :size="size"
-          :dict="dict"
-          :add-type="'record'"
-          :select-data="selectData"
-          @success="useQuery(params, page)"
-        ></add-button>
+        <el-button :size="size" :disabled="SeeDisabled" @click="useSee">
+          明细
+        </el-button>
       </el-button-group>
       <el-button-group>
-        <edit-button
-          :size="size"
-          :dict="dict"
-          :select-data="selectData"
-          @success="useQuery(params, page)"
-        ></edit-button>
+        <el-button :size="size" @click="useAdd">新增</el-button>
+        <el-button :size="size" @click="useReord">期初补录</el-button>
+      </el-button-group>
+      <el-button-group>
+        <el-button :size="size" :disabled="EditDisabled" @click="useEdit">
+          编辑
+        </el-button>
         <dele-button
           :size="size"
           :select-data="selectData"
           @success="useQuery(params, page)"
         ></dele-button>
-        <see-button
-          v-show="false"
-          :size="size"
-          :dict="dict"
-          :select-data="selectData"
-          ref="SeeButton"
-        ></see-button
-      ></el-button-group>
+      </el-button-group>
       <el-button-group>
         <subm-button
           :size="size"

+ 65 - 47
src/views/purchase/contract/see/index.vue

@@ -3,7 +3,7 @@ import useColumns from "./columns";
 import { ITEM } from "@/api/business/purchase/contract";
 
 export default {
-  name: "SeeDrawer",
+  name: "SeeFormModel",
   props: {
     dict: {
       type: Object,
@@ -12,6 +12,9 @@ export default {
       type: [Array],
       require: true,
     },
+    title: {
+      type: String,
+    },
   },
   components: {
     ElSuperDescriptions: () =>
@@ -30,23 +33,20 @@ export default {
     } = useColumns();
     return {
       column: 2,
-      width: "100%",
-      title: "明 细",
-      visible: false,
       loading: false,
+      loadingText: "",
       params: {},
       tabName: tabName,
-      TabColumns,
-      TableColumns,
+      TabColumns: TabColumns,
+      TableColumns: TableColumns,
     };
   },
   computed: {
-    disabled: {
+    id: {
       get() {
-        const { selectData } = this;
-        if (selectData.length !== 1) {
-          return true;
-        }
+        const { title, selectData } = this.$props;
+        const id = title.split("-")[1];
+        return id ? id : selectData[0].id;
       },
       set() {},
     },
@@ -57,12 +57,11 @@ export default {
       try {
         // try
         this.loading = true;
+        this.loadingText = "获取合同中";
         const { code, data } = await ITEM(prop);
         if (code === 200) {
           this.params = data;
-          return true;
         } else {
-          return false;
         }
       } catch (err) {
         // catch
@@ -74,56 +73,75 @@ export default {
     },
     //
     async open(prop) {
-      this.visible = await this.fetchItem(prop);
+      this.fetchItem(prop ? prop : this.id);
     },
     //
     async hide() {
-      const {
-        TabColumns: [
-          {
-            item: { key: tabName },
-          },
-        ],
-      } = useColumns();
-      this.visible = false;
-      this.tabName = tabName;
+      this.$emit("close");
     },
   },
-  created() {},
+  created() {
+    this.open();
+  },
   mounted() {},
   destroyed() {},
 };
 </script>
 <template>
-  <el-button
-    v-bind="$attrs"
-    v-on="$listeners"
-    :disabled="disabled"
-    @click="open(selectData[0])"
+  <div
+    v-loading="loading"
+    :element-loading-text="loadingText"
+    style="height: 100vh; display: flex; flex-direction: column"
   >
-    {{ title }}
-    <el-drawer
-      :size="width"
-      :title="title"
-      :visible.sync="visible"
-      append-to-body
+    <div
+      style="
+        height: 50px;
+        display: flex;
+        justify-content: space-between;
+        align-items: center;
+        padding: 0 18px;
+      "
     >
+      <h4 class="m-0" style="font-weight: 500; flex: 1">
+        {{ title.split("-")[0] }}
+      </h4>
+      <el-button
+        type="primary"
+        :size="$attrs.size"
+        :loading="loading"
+        @click="useSubmit('superForm')"
+        >确 认</el-button
+      >
+      <el-button :size="$attrs.size" :loading="loading" @click="hide"
+        >取 消</el-button
+      >
+    </div>
+    <div v-if="params.code" style="flex: 1; overflow-y: auto">
       <el-super-descriptions
+        v-if="params.code"
         v-model="params"
         :dict="dict"
         :column="column"
         :size="$attrs.size"
         :columns="TableColumns"
+        style="padding: 18px"
       >
       </el-super-descriptions>
-      <el-tabs v-model="tabName" :size="$attrs.size" style="margin: 10px">
-        <el-tab-pane
-          v-for="{ item, TableColumns: columns } in TabColumns"
-          :key="item.key"
-          :name="item.key"
-          :label="item.title"
-          lazy
-        >
+    </div>
+    <el-tabs
+      v-if="params.code"
+      v-model="tabName"
+      :size="$attrs.size"
+      style="margin: 0 18px 18px"
+    >
+      <el-tab-pane
+        v-for="{ item, TableColumns: columns } in TabColumns"
+        :key="item.key"
+        :name="item.key"
+        :label="item.title"
+        lazy
+      >
+        <div style="height: 25vh; display: flex">
           <el-super-table
             v-model="params[item.key]"
             :size="$attrs.size"
@@ -132,8 +150,8 @@ export default {
             :iconOperation="false"
           >
           </el-super-table>
-        </el-tab-pane>
-      </el-tabs>
-    </el-drawer>
-  </el-button>
+        </div>
+      </el-tab-pane>
+    </el-tabs>
+  </div>
 </template>

+ 18 - 4
src/views/purchase/purchase-order/column.js

@@ -1097,12 +1097,13 @@ export const SearchColumns = [
   },
   {
     item:{
-      key: "code",
+      key: "orderCode",
       title: "订单编号",  
     },
     attr: {
       clearable:true,
       is: "el-input",
+      placeholder:'请输入订单编号,多个使用,隔开',
     },
   },
   {
@@ -1165,9 +1166,11 @@ export const SearchColumns = [
     },
     attr: {
       clearable:true,
-      is: "el-popover-select-v2",
-      valueKey: "code",
-      referName: "MATERIAL_PARAM",
+      is: "el-input",
+      placeholder:'请输入物料编码,多个使用,隔开',
+      // is: "el-popover-multiple-select-v2",
+      // valueKey: "code",
+      // referName: "MATERIAL_PARAM",
     },
   },
   {
@@ -1248,6 +1251,7 @@ export const SearchColumns = [
     attr: {
       clearable:true,
       is: "el-input",
+      placeholder:'请输入采购需求单号,多个使用,隔开',
     },
   },
   { 
@@ -1261,6 +1265,16 @@ export const SearchColumns = [
       dictName: "sys_yes_no",
     },
   },
+  { 
+    item:{
+      key: "erpOrderCode",
+      title: "NC订单号", 
+    },
+    attr: {
+      clearable:true,
+      is: "el-input",
+    },
+  },
 ].map(({ item, attr }) => ({
   attr,
   item: { ...item, hidden: true, span: item.span || 6 },

+ 36 - 6
src/views/purchase/purchase-order/index.vue

@@ -304,19 +304,49 @@ export default {
     },
     fetchSubmit(puOrderIds){
 
+      let _this = this;
+
       this.handleConfirmTips(async()=>{
       
         try {
 
+          _this.loading = true;
 
-          this.loading = true;
-
-          let { code } = await orderApi.submit({ puOrderIds});
-
+          let { code,msg } = await orderApi.submit({ puOrderIds,checkAmount:true});
+          console.log(code,'code');
           if (code == 200) {
 
-          this.handleRefreshList();
-
+            _this.handleRefreshList();
+
+          }else if(code == 10000){
+
+            _this.$alert(msg, '提示', {
+              showCancelButton: true,
+              confirmButtonText: '置为0并提交',
+              cancelButtonText: '取消',
+              beforeClose: async(action, instance, done) => {
+                if (action === 'confirm') {
+                  try {
+                    instance.confirmButtonLoading = true;
+                    instance.confirmButtonText = '执行中...';
+                    let { code,msg } = await orderApi.submit({ puOrderIds,checkAmount:false});
+                    if(code == 200){
+                      done();
+                      _this.handleRefreshList();
+                    }
+                    
+                  } catch (error) {
+                    
+                  }finally{
+                    instance.confirmButtonLoading = false;
+                  }
+                
+                } else {
+                  done();
+                }
+              }
+            });
+            
           }
 
         }  catch (error) {}