Преглед на файлове

完善采购合同生成

002201 преди 2 години
родител
ревизия
e2be348ef9

+ 26 - 20
src/views/purchase/apply/add/column.js

@@ -6,6 +6,13 @@ export const FormColumns = [
     value: "价格申报单",
   },
   {
+    key: "priceCode",
+    title: "价格编码",
+    inputType: "Input",
+    disabled: true,
+    readonly: true,
+  },
+  {
     key: "supplierName",
     title: "供应商",
     inputType: "PopoverSelect",
@@ -146,8 +153,7 @@ export const FormColumns = [
     title: "附件",
     inputType: "Upload",
     span: 24,
-    disabled: true,
-    readonly: true,
+    require: true,
     value: [],
   },
   {
@@ -193,7 +199,7 @@ export const TabColumns = [
         require: true,
       },
       { title: "物料编码", key: "materialCode" },
-      { title: "物料ID", key: "material" },
+      // { title: "物料ID", key: "material" },
       {
         title: "生产厂家",
         key: "manufacturerName",
@@ -226,10 +232,10 @@ export const TabColumns = [
         title: "单位编码",
         key: "unitCode",
       },
-      {
-        title: "单位ID",
-        key: "unit",
-      },
+      // {
+      //   title: "单位ID",
+      //   key: "unit",
+      // },
       {
         title: "采购单位名称",
         key: "puUnitName",
@@ -246,10 +252,10 @@ export const TabColumns = [
         title: "采购单位编码",
         key: "puUnitCode",
       },
-      {
-        title: "采购单位ID",
-        key: "puUnit",
-      },
+      // {
+      //   title: "采购单位ID",
+      //   key: "puUnit",
+      // },
       {
         title: "采购换算率",
         key: "conversionRate",
@@ -303,10 +309,10 @@ export const TabColumns = [
         title: "币种编码",
         key: "currencyCode",
       },
-      {
-        title: "币种ID",
-        key: "currency",
-      },
+      // {
+      //   title: "币种ID",
+      //   key: "currency",
+      // },
       {
         key: "periodBegin",
         title: "价格有效期(起)",
@@ -344,10 +350,10 @@ export const TabColumns = [
         title: "客户编码",
         key: "customerCode",
       },
-      {
-        title: "客户ID",
-        key: "customer",
-      },
+      // {
+      //   title: "客户ID",
+      //   key: "customer",
+      // },
       {
         title: "最近价格",
         key: "recentlyPrice",
@@ -406,7 +412,7 @@ export const TabColumns = [
         },
       },
       { title: "组织编码", key: "orgCode" },
-      { title: "组织ID", key: "org" },
+      // { title: "组织ID", key: "org" },
       {
         title: "创建人名称",
         key: "createByName",

+ 4 - 0
src/views/purchase/apply/column.js

@@ -4,6 +4,10 @@ export const FormColumns = [
     title: "价格名称",
   },
   {
+    key: "priceCode",
+    title: "价格编码",
+  },
+  {
     key: "status",
     title: "状态",
     inputType: "Select",

+ 1 - 1
src/views/purchase/apply/index.vue

@@ -281,7 +281,7 @@ export default {
             :options="dict.type[column.referName]"
           />
           <dr-file-preview
-            v-else-if="column.inputType === 'Upload'"
+            v-else-if="column.inputType === 'Upload' && scope.row[column.key]"
             v-model="scope.row[column.key]"
           ></dr-file-preview>
           <span v-else>{{ scope.row[column.key] }}</span>

+ 88 - 22
src/views/purchase/contract/add/index.vue

@@ -2,9 +2,10 @@
 import Column from "./column";
 import useData from "../hooks/data";
 import useDicts from "../hooks/dicts";
-import useTable from "../hooks/table-function";
 import useWatch from "../hooks/watch";
-import useMethods from "../hooks/function";
+import { initParams } from "@/utils/init";
+import { REFER } from "@/components/popover-select/api";
+import { ADD, CODE } from "@/api/business/purchase/contract";
 const { watchContractType } = useWatch();
 
 export default {
@@ -22,16 +23,50 @@ export default {
     "params.contractType": watchContractType(),
   },
   methods: {
-    //
+    async fetchCode() {
+      try {
+        // try
+        this.loading = true;
+        const data = await CODE();
+        if (data) {
+          this.params.code = data;
+          return true;
+        } else {
+          return false;
+        }
+      } catch (err) {
+        // catch
+        console.error(err);
+      } finally {
+        // finally
+        this.loading = false;
+      }
+    },
     async fetchRefer(prop, type, source) {
-      const { fetchRefer } = useMethods();
-      await fetchRefer({ _this: this, prop, type, source });
+      const { rateCode } = prop;
+      if (type === "MATERIAL_PARAM") {
+        try {
+          // try
+          this.loading = true;
+          const { code, rows } = await REFER({
+            search: rateCode,
+            type: "TAX_RATE_PARAM",
+          });
+          if (code === 200) {
+            const [{ ntaxrate }] = rows;
+            source.tax = ntaxrate === "0E-8" ? "0.00000000" : ntaxrate;
+          }
+        } catch (err) {
+          // catch
+          console.error(err);
+        } finally {
+          // finally
+          this.loading = false;
+        }
+      }
     },
     //
     async open() {
-      const { open, fetchCode } = useMethods();
-      await open({ _this: this });
-      await fetchCode({ _this: this });
       const {
         user: {
           deptId: puDept,
@@ -48,26 +83,56 @@ export default {
       this.params.buyerName = buyerName;
       this.params.puDept = puDept;
       this.params.puDeptName = puDeptName;
+      this.visible = await this.fetchCode();
     },
     //
     async hide() {
-      const { hide } = useMethods();
-      await hide({ _this: this });
+      this.visible = false;
+      this.tabName = this.tabColumns[0].key;
+      this.params = initParams(FormColumns);
+      this.params.contractItemList = [];
+      this.params.contractClauseList = [];
+      this.params.contractExpenseList = [];
+      this.params.contractApplyOrgList = [];
+      this.params.contractAgreementList = [];
     },
     //
     async useRowAdd(prop) {
-      const { add } = useTable();
-      await add({ _this: this, prop });
+      const { tableColumns } = this.tabColumns.find(
+        (item) => item.key === prop
+      );
+      this.params[prop].push(initParams(tableColumns));
     },
     //
     async useRowRemove(prop, scope) {
-      const { remove } = useTable();
-      await remove({ _this: this, prop, scope });
+      const { $index } = scope;
+      this.params[prop].splice($index, 1);
     },
     //
     async useSubmit(prop) {
-      const { submit } = useMethods();
-      await submit({ _this: this, prop, type: "ADD" });
+      this.$refs[prop].validate(async (valid) => {
+        if (valid) {
+          try {
+            // try
+            this.loading = true;
+            const params = { ...this.params };
+            const { msg, code } = await ADD(params);
+            if (code === 200) {
+              this.hide();
+              this.$emit("success");
+              this.$notify.success(msg);
+            }
+          } catch (err) {
+            // catch
+            console.error(err);
+          } finally {
+            // finally
+            this.loading = false;
+          }
+        } else {
+          return false;
+        }
+      });
     },
   },
   created() {},
@@ -88,16 +153,17 @@ export default {
         <el-button
           :size="size"
           circle
-          icon="el-icon-close"
-          @click="hide"
-        ></el-button>
-        <el-button
-          :size="size"
-          circle
           icon="el-icon-check"
           @click="useSubmit('ruleForm')"
         >
         </el-button>
+        <el-button
+          :size="size"
+          circle
+          type="danger"
+          icon="el-icon-close"
+          @click="hide"
+        ></el-button>
       </span>
     </template>
     <el-form

+ 24 - 22
src/views/purchase/contract/alteration/index.vue

@@ -11,29 +11,31 @@ export default {
   methods: {
     //
     open(prop) {
-      this.$confirm("是否变更数据项?", "提示", {
-        confirmButtonText: "确定",
-        cancelButtonText: "取消",
-        type: "info",
-      })
-        .then(async () => {
-          try {
-            // try
-            const { msg, code } = await ALTERATION(prop);
-            if (code === 200) {
-              this.$emit("success");
-              this.$notify.success(msg);
-            }
-          } catch (err) {
-            // catch
-            console.error(err);
-          } finally {
-            // finally
-          }
+      return new Promise((resolve, reject) => {
+        this.$confirm("是否变更数据项?", "提示", {
+          confirmButtonText: "确定",
+          cancelButtonText: "取消",
+          type: "info",
         })
-        .catch((err) => {
-          console.error(err);
-        });
+          .then(async () => {
+            try {
+              // try
+              const { msg, code } = await ALTERATION(prop);
+              if (code === 200) {
+                resolve(true);
+                this.$emit("success");
+                this.$notify.success(msg);
+              }
+            } catch (err) {
+              // catch
+              reject(false);
+              console.error(err);
+            } finally {
+              // finally
+            }
+          })
+          .catch(() => reject(false));
+      });
     },
   },
   created() {},

+ 11 - 1
src/views/purchase/contract/column.js

@@ -159,7 +159,17 @@ export const FormColumns = [
     title: "合同主要内容",
   },
   { key: "refusalReasons", title: "拒绝理由" },
-
+  {
+    key: "pigeonhole",
+    title: "是否归档",
+    inputType: "Select",
+    referName: "sys_yes_no",
+  },
+  {
+    key: "pigeonholeFile",
+    title: "归档附件",
+    inputType: "Upload",
+  },
   {
     key: "externalFile",
     title: "对外附件",

+ 24 - 22
src/views/purchase/contract/delete/index.vue

@@ -11,29 +11,31 @@ export default {
   methods: {
     //
     open(prop) {
-      this.$confirm("是否删除数据项?", "提示", {
-        confirmButtonText: "确定",
-        cancelButtonText: "取消",
-        type: "info",
-      })
-        .then(async () => {
-          try {
-            // try
-            const { msg, code } = await REMOVE(prop);
-            if (code === 200) {
-              this.$emit("success");
-              this.$notify.success(msg);
-            }
-          } catch (err) {
-            // catch
-            console.error(err);
-          } finally {
-            // finally
-          }
+      return new Promise((resolve, reject) => {
+        this.$confirm("是否删除数据项?", "提示", {
+          confirmButtonText: "确定",
+          cancelButtonText: "取消",
+          type: "info",
         })
-        .catch((err) => {
-          console.error(err);
-        });
+          .then(async () => {
+            try {
+              // try
+              const { msg, code } = await REMOVE(prop);
+              if (code === 200) {
+                resolve(true);
+                this.$emit("success");
+                this.$notify.success(msg);
+              }
+            } catch (err) {
+              // catch
+              reject(false);
+              console.error(err);
+            } finally {
+              // finally
+            }
+          })
+          .catch(() => reject(false));
+      });
     },
   },
   created() {},

+ 145 - 37
src/views/purchase/contract/edit/index.vue

@@ -2,9 +2,10 @@
 import Column from "../add/column";
 import useData from "../hooks/data";
 import useDicts from "../hooks/dicts";
-import useTable from "../hooks/table-function";
 import useWatch from "../hooks/watch";
-import useMethods from "../hooks/function";
+import { initParams } from "@/utils/init";
+import { REFER } from "@/components/popover-select/api";
+import { EDIT, ITEM, TABLE } from "@/api/business/purchase/contract";
 const { watchContractType } = useWatch();
 
 export default {
@@ -17,6 +18,9 @@ export default {
     };
   },
   computed: {
+    root: function () {
+      return this.$parent.$parent;
+    },
     hasPowerAlteration: function () {
       return this.$parent.$parent.hasPowerAlteration;
     },
@@ -25,47 +29,143 @@ export default {
     "params.contractType": watchContractType(),
   },
   methods: {
-    //
     async fetchRefer(prop, type, source) {
-      const { fetchRefer } = useMethods();
-      await fetchRefer({ _this: this, prop, type, source });
+      const { rateCode } = prop;
+      if (type === "MATERIAL_PARAM") {
+        try {
+          // try
+          this.loading = true;
+          const { code, rows } = await REFER({
+            search: rateCode,
+            type: "TAX_RATE_PARAM",
+          });
+          if (code === 200) {
+            const [{ ntaxrate }] = rows;
+            source.tax = ntaxrate === "0E-8" ? "0.00000000" : ntaxrate;
+          }
+        } catch (err) {
+          // catch
+          console.error(err);
+        } finally {
+          // finally
+          this.loading = false;
+        }
+      }
+    },
+    async fetchItem(prop) {
+      try {
+        // try
+        this.loading = true;
+        const { code, data } = await ITEM(prop);
+        if (code === 200) {
+          this.params = data;
+          return true;
+        } else {
+          return false;
+        }
+      } catch (err) {
+        // catch
+        console.error(err);
+      } finally {
+        // finally
+        this.loading = false;
+      }
     },
     //
     async open(prop) {
-      const { open, fetchItem } = useMethods();
-      await open({ _this: this });
-      await fetchItem({ _this: this, prop });
+      this.visible = await this.fetchItem(prop);
     },
     //
     async hide() {
-      const { hide } = useMethods();
-      await hide({ _this: this });
+      this.visible = false;
+      this.tabName = this.tabColumns[0].key;
     },
     //
     async useRowAdd(prop) {
-      const { add } = useTable();
-
-      await add({ _this: this, prop });
+      const { tableColumns } = this.tabColumns.find(
+        (item) => item.key === prop
+      );
+      this.params[prop].push(initParams(tableColumns));
     },
     //
     async useRowRemove(prop, scope) {
-      const { remove } = useTable();
-      await remove({ _this: this, prop, scope });
+      const { ROMVE } = TABLE;
+      const {
+        row: { id, contractId },
+      } = scope;
+      try {
+        // try
+        this.loading = true;
+        const { code } = ROMVE(id, prop);
+        if (code === 200) {
+          this.fetchItem(contractId);
+        }
+      } catch (err) {
+        // catch
+        console.error(err);
+      } finally {
+        // finally
+        this.loading = false;
+      }
     },
     //
     async useRowSubmit(prop, scope) {
-      const { submit } = useTable();
-      await submit({ _this: this, prop, scope });
+      const {
+        row: { contractId },
+      } = scope;
+      const { id } = this.params;
+      const { ADD, EDIT } = TABLE;
+      try {
+        // try
+        this.loading = true;
+        if (contractId) {
+          await EDIT(row, prop);
+        } else {
+          await ADD({ ...row, contractId: id }, prop);
+        }
+      } catch (err) {
+        // catch
+        console.error(err);
+      } finally {
+        // finally
+        this.fetchItem(id);
+        this.loading = false;
+      }
     },
     //
     async useSubmit(prop) {
-      const { submit } = useMethods();
-      await submit({ _this: this, prop, type: "EDIT" });
+      this.$refs[prop].validate(async (valid) => {
+        if (valid) {
+          try {
+            // try
+            this.loading = true;
+            const params = { ...this.params };
+            const { msg, code } = await EDIT(params);
+            if (code === 200) {
+              this.hide();
+              this.$emit("success");
+              this.$notify.success(msg);
+            }
+          } catch (err) {
+            // catch
+            console.error(err);
+          } finally {
+            // finally
+            this.loading = false;
+          }
+        } else {
+          return false;
+        }
+      });
     },
     //
     async useAlteration(prop) {
-      const { useAlteration } = this.$parent.$parent;
-      await useAlteration(prop);
+      await this.root
+        .useAlteration(prop)
+        .then(() => {
+          this.hide();
+        })
+        .catch(() => {});
     },
   },
   created() {},
@@ -83,28 +183,36 @@ export default {
     <template slot="title">
       <span>{{ title }}</span>
       <span>
+        <el-tooltip
+          v-if="root.hasPowerAlteration([params])"
+          effect="dark"
+          content="变 更"
+          placement="bottom-end"
+        >
+          <el-button
+            :size="size"
+            circle
+            icon="el-icon-check"
+            @click="useAlteration([params])"
+          >
+          </el-button>
+        </el-tooltip>
+        <el-tooltip v-else effect="dark" content="更 新" placement="bottom-end">
+          <el-button
+            :size="size"
+            circle
+            icon="el-icon-check"
+            @click="useSubmit('ruleForm')"
+          >
+          </el-button>
+        </el-tooltip>
         <el-button
           :size="size"
           circle
+          type="danger"
           icon="el-icon-close"
           @click="hide"
         ></el-button>
-        <el-button
-          v-if="hasPowerAlteration([params])"
-          :size="size"
-          circle
-          icon="el-icon-check"
-          @click="useAlteration([params])"
-        >
-        </el-button>
-        <el-button
-          v-else
-          :size="size"
-          circle
-          icon="el-icon-check"
-          @click="useSubmit('ruleForm')"
-        >
-        </el-button>
       </span>
     </template>
     <el-form

+ 0 - 109
src/views/purchase/contract/hooks/function.js

@@ -1,109 +0,0 @@
-import { REFER } from "@/components/popover-select/api";
-import { ADD, EDIT, ITEM, CODE } from "@/api/business/purchase/contract";
-
-export default function useMethods() {
-  const fetchCode = async ({ _this }) => {
-    try {
-      // try
-      _this.loading = true;
-      const code = await CODE();
-      _this.params.code = code;
-    } catch (err) {
-      // catch
-      console.error(err);
-    } finally {
-      // finally
-      _this.loading = false;
-    }
-  };
-  const fetchItem = async ({ _this, prop }) => {
-    try {
-      // try
-      _this.loading = true;
-      const { code, data } = await ITEM(prop);
-      if (code === 200) {
-        _this.params = data;
-      }
-    } catch (err) {
-      // catch
-      console.error(err);
-    } finally {
-      // finally
-      _this.loading = false;
-    }
-  };
-  const fetchRefer = async ({ _this, prop, type, source }) => {
-    const { rateCode } = prop;
-    if (type === "MATERIAL_PARAM") {
-      try {
-        // try
-        _this.loading = true;
-        const { code, rows } = await REFER({
-          search: rateCode,
-          type: "TAX_RATE_PARAM",
-        });
-        if (code === 200) {
-          const [{ ntaxrate }] = rows;
-          source.tax = ntaxrate === "0E-8" ? "0.00000000" : ntaxrate;
-        }
-      } catch (err) {
-        // catch
-        console.error(err);
-      } finally {
-        // finally
-        _this.loading = false;
-      }
-    }
-  };
-  const open = ({ _this }) => {
-    _this.visible = true;
-    _this.tabName = _this.tabColumns[0].key;
-  };
-  const hide = ({ _this }) => {
-    _this.visible = false;
-  };
-  const submit = ({ _this, prop, type }) => {
-    _this.$refs[prop].validate(async (valid) => {
-      if (valid) {
-        try {
-          // try
-          _this.loading = true;
-          const { buyer: createById, buyerName: createByName } = _this.params;
-          const {
-            user: { id: updateById, name: updateByName },
-          } = _this.$store.state;
-          const params = {
-            createById,
-            createByName,
-            updateById,
-            updateByName,
-            ..._this.params,
-          };
-          const { msg, code } =
-            type === "ADD" ? await ADD(params) : await EDIT(params);
-          if (code === 200) {
-            _this.hide();
-            _this.$emit("success");
-            _this.$notify.success(msg);
-          }
-        } catch (err) {
-          // catch
-          console.error(err);
-        } finally {
-          // finally
-          _this.loading = false;
-        }
-      } else {
-        return false;
-      }
-    });
-  };
-  return {
-    open,
-    hide,
-    submit,
-    fetchRefer,
-    fetchCode,
-    fetchItem,
-  };
-}

+ 0 - 61
src/views/purchase/contract/hooks/table-function.js

@@ -1,61 +0,0 @@
-import { initParams } from "@/utils/init";
-import { TABLE } from "@/api/business/purchase/contract";
-
-export default function useTable() {
-  // 新 增
-  const add = ({ _this, prop }) => {
-    const { tableColumns } = _this.tabColumns.find(
-      (element) => element.key === prop
-    );
-    _this.params[prop].push(initParams(tableColumns));
-  };
-  // 提 交
-  const submit = async ({ _this, prop, scope }, done = () => {}) => {
-    const { row } = scope;
-    const { ADD, EDIT } = TABLE;
-    try {
-      // try
-      _this.loading = true;
-      const { contractId } = row;
-      const { id } = _this.params;
-      if (contractId) {
-        await EDIT(row, prop);
-      } else {
-        await ADD({ ...row, contractId: id }, prop);
-      }
-      await done();
-    } catch (err) {
-      // catch
-      console.error(err);
-    } finally {
-      // finally
-      _this.loading = false;
-    }
-  };
-  // 删 除
-  const remove = ({ _this, prop, scope }, done = () => {}) => {
-    const {
-      row: { id },
-      $index,
-    } = scope;
-    const { ROMVE } = TABLE;
-    if (id) {
-      try {
-        // try
-        _this.loading = true;
-        const { code } = ROMVE(id, prop);
-        if (code === 200) done();
-      } catch (err) {
-        // catch
-        console.error(err);
-      } finally {
-        // finally
-        _this.loading = false;
-      }
-    } else {
-      _this.params[prop].splice($index, 1);
-    }
-  };
-
-  return { add, submit, remove };
-}

+ 18 - 23
src/views/purchase/contract/index.vue

@@ -85,8 +85,11 @@ export default {
     },
     hasPowerDelete(prop) {
       if (prop.length === 1) {
+        return true;
         const [{ status }] = prop;
-        if (status !== "2") return true;
+        if (status === "0") return true;
+        else if (status === "3") return true;
+        else if (!status) return true;
         else return false;
       }
     },
@@ -97,6 +100,7 @@ export default {
       await open(id);
     },
     hasPowerEdit(prop) {
+      return true;
       if (prop.length === 1) {
         const [{ status }] = prop;
         if (status !== "2") return true;
@@ -130,8 +134,8 @@ export default {
     },
     hasPowerPigeonhole(prop) {
       if (prop.length === 1) {
-        const [{ status }] = prop;
-        if (status === "2") return true;
+        const [{ pigeonhole }] = prop;
+        if (pigeonhole !== "Y") return true;
         else return false;
       }
     },
@@ -148,8 +152,8 @@ export default {
       }
     },
     // 导 出
-    async useExport(prop) {
-      const { pageNum, pageSize } = this.page;
+    async useExport(prop, page) {
+      const { pageNum, pageSize } = page;
       const { open } = this.$refs.ExportModel;
       await open({ ...prop, pageNum, pageSize });
     },
@@ -179,7 +183,10 @@ export default {
     :body-style="{ padding: 0 }"
   >
     <see-model ref="SeeModel"></see-model>
-    <add-model ref="AddModel" @success="useReset"></add-model>
+    <add-model
+      ref="AddModel"
+      @success="useReset"
+    ></add-model>
     <record-model ref="RecordModel" @success="useReset"></record-model>
     <edit-model ref="EditModel" @success="useQuery(params, page)"></edit-model>
     <export-model ref="ExportModel"></export-model>
@@ -231,6 +238,9 @@ export default {
       <el-button :size="size" @click="useReset"> 重 置 </el-button>
       <el-button :size="size" @click="useAdd"> 新 增 </el-button>
       <el-button :size="size" @click="useRecord"> 期初补录 </el-button>
+      <el-button :size="size" @click="useExport(params, page)">
+        导 出
+      </el-button>
       <el-button
         v-show="hasPowerDelete(selectData)"
         :size="size"
@@ -241,7 +251,6 @@ export default {
       <el-button
         v-show="hasPowerTermination(selectData)"
         :size="size"
-        :disabled="!selectData.length"
         @click="useTermination(selectData)"
       >
         终 止
@@ -253,20 +262,6 @@ export default {
       >
         归 档
       </el-button>
-      <el-button
-        v-show="hasPowerAlteration(selectData)"
-        :size="size"
-        @click="useAlteration(selectData)"
-      >
-        变 更
-      </el-button>
-      <el-button
-        :size="size"
-        :disabled="!selectData.length"
-        @click="useExport(params)"
-      >
-        导 出
-      </el-button>
       <!-- <el-button :size="size" @click="useImport"> 导 入 </el-button> -->
     </el-row>
     <el-table
@@ -285,7 +280,7 @@ export default {
         :key="index"
         :prop="column.key"
         :label="column.title"
-        :width="column.width || 180"
+        :width="column.width || 200"
         show-overflow-tooltip
       >
         <template slot-scope="scope">
@@ -296,7 +291,7 @@ export default {
             :options="dict.type[column.referName]"
           />
           <dr-file-preview
-            v-else-if="column.inputType === 'Upload'"
+            v-else-if="column.inputType === 'Upload' && scope.row[column.key]"
             v-model="scope.row[column.key]"
           ></dr-file-preview>
           <span v-else>{{ scope.row[column.key] }}</span>

+ 17 - 8
src/views/purchase/contract/pigeonhole/index.vue

@@ -12,7 +12,11 @@ export default {
       params: { id: "", pigeonholeFile: "" },
     };
   },
-  computed: {},
+  computed: {
+    root: function () {
+      return this.$parent.$parent;
+    },
+  },
   watch: {},
   methods: {
     //
@@ -67,18 +71,19 @@ export default {
       <span>
         <el-button
           :size="size"
-          :disabled="loading"
+          :disabled="!params.pigeonholeFile || loading"
           circle
-          icon="el-icon-close"
-          @click="visible = false"
+          icon="el-icon-check"
+          @click="submit(params)"
         >
         </el-button>
         <el-button
           :size="size"
-          :disabled="!params.pigeonholeFile || loading"
+          :disabled="loading"
           circle
-          icon="el-icon-check"
-          @click="submit(params)"
+          type="danger"
+          icon="el-icon-close"
+          @click="visible = false"
         >
         </el-button>
       </span>
@@ -90,7 +95,11 @@ export default {
       label-position="right"
     >
       <el-form-item prop="pigeonholeFile" label="">
-        <file-upload v-model="params.pigeonholeFile" :limit="1"></file-upload>
+        <file-upload
+          v-model="params.pigeonholeFile"
+          :limit="1"
+          style="text-align: center"
+        ></file-upload>
       </el-form-item>
     </el-form>
   </el-dialog>

+ 88 - 22
src/views/purchase/contract/record/index.vue

@@ -2,9 +2,10 @@
 import Column from "../add/column";
 import useData from "../hooks/data";
 import useDicts from "../hooks/dicts";
-import useTable from "../hooks/table-function";
 import useWatch from "../hooks/watch";
-import useMethods from "../hooks/function";
+import { initParams } from "@/utils/init";
+import { REFER } from "@/components/popover-select/api";
+import { ADD, CODE } from "@/api/business/purchase/contract";
 const { watchContractType } = useWatch();
 
 export default {
@@ -22,16 +23,50 @@ export default {
     "params.contractType": watchContractType(),
   },
   methods: {
-    //
+    async fetchCode() {
+      try {
+        // try
+        this.loading = true;
+        const data = await CODE();
+        if (data) {
+          this.params.code = data;
+          return true;
+        } else {
+          return false;
+        }
+      } catch (err) {
+        // catch
+        console.error(err);
+      } finally {
+        // finally
+        this.loading = false;
+      }
+    },
     async fetchRefer(prop, type, source) {
-      const { fetchRefer } = useMethods();
-      await fetchRefer({ _this: this, prop, type, source });
+      const { rateCode } = prop;
+      if (type === "MATERIAL_PARAM") {
+        try {
+          // try
+          this.loading = true;
+          const { code, rows } = await REFER({
+            search: rateCode,
+            type: "TAX_RATE_PARAM",
+          });
+          if (code === 200) {
+            const [{ ntaxrate }] = rows;
+            source.tax = ntaxrate === "0E-8" ? "0.00000000" : ntaxrate;
+          }
+        } catch (err) {
+          // catch
+          console.error(err);
+        } finally {
+          // finally
+          this.loading = false;
+        }
+      }
     },
     //
     async open() {
-      const { open, fetchCode } = useMethods();
-      await open({ _this: this });
-      await fetchCode({ _this: this });
       const {
         user: {
           deptId: puDept,
@@ -49,26 +84,56 @@ export default {
       this.params.puDept = puDept;
       this.params.puDeptName = puDeptName;
       this.params.source = "期初补录";
+      this.visible = await this.fetchCode();
     },
     //
     async hide() {
-      const { hide } = useMethods();
-      await hide({ _this: this });
+      this.visible = false;
+      this.tabName = this.tabColumns[0].key;
+      this.params = initParams(FormColumns);
+      this.params.contractItemList = [];
+      this.params.contractClauseList = [];
+      this.params.contractExpenseList = [];
+      this.params.contractApplyOrgList = [];
+      this.params.contractAgreementList = [];
     },
     //
     async useRowAdd(prop) {
-      const { add } = useTable();
-      await add({ _this: this, prop });
+      const { tableColumns } = this.tabColumns.find(
+        (item) => item.key === prop
+      );
+      this.params[prop].push(initParams(tableColumns));
     },
     //
     async useRowRemove(prop, scope) {
-      const { remove } = useTable();
-      await remove({ _this: this, prop, scope });
+      const { $index } = scope;
+      this.params[prop].splice($index, 1);
     },
     //
     async useSubmit(prop) {
-      const { submit } = useMethods();
-      await submit({ _this: this, prop, type: "ADD" });
+      this.$refs[prop].validate(async (valid) => {
+        if (valid) {
+          try {
+            // try
+            this.loading = true;
+            const params = { ...this.params };
+            const { msg, code } = await ADD(params);
+            if (code === 200) {
+              this.hide();
+              this.$emit("success");
+              this.$notify.success(msg);
+            }
+          } catch (err) {
+            // catch
+            console.error(err);
+          } finally {
+            // finally
+            this.loading = false;
+          }
+        } else {
+          return false;
+        }
+      });
     },
   },
   created() {},
@@ -89,16 +154,17 @@ export default {
         <el-button
           :size="size"
           circle
-          icon="el-icon-close"
-          @click="hide"
-        ></el-button>
-        <el-button
-          :size="size"
-          circle
           icon="el-icon-check"
           @click="useSubmit('ruleForm')"
         >
         </el-button>
+        <el-button
+          :size="size"
+          circle
+          type="danger"
+          icon="el-icon-close"
+          @click="hide"
+        ></el-button>
       </span>
     </template>
     <el-form

+ 50 - 64
src/views/purchase/contract/see/index.vue

@@ -2,7 +2,7 @@
 import Column from "../add/column";
 import useData from "../hooks/data";
 import useDicts from "../hooks/dicts";
-import useMethods from "../hooks/function";
+import { ITEM } from "@/api/business/purchase/contract";
 
 export default {
   name: "SeeDrawer",
@@ -16,59 +16,57 @@ export default {
     };
   },
   computed: {
-    hasPowerEdit: function () {
-      return this.$parent.$parent.hasPowerEdit;
-    },
-    hasPowerDelete: function () {
-      return this.$parent.$parent.hasPowerDelete;
-    },
-    hasPowerAlteration: function () {
-      return this.$parent.$parent.hasPowerAlteration;
-    },
-    hasPowerPigeonhole: function () {
-      return this.$parent.$parent.hasPowerPigeonhole;
-    },
-    hasPowerTermination: function () {
-      return this.$parent.$parent.hasPowerTermination;
+    root: function () {
+      return this.$parent.$parent;
     },
   },
   watch: {},
   methods: {
+    async fetchItem(prop) {
+      try {
+        // try
+        this.loading = true;
+        const { code, data } = await ITEM(prop);
+        if (code === 200) {
+          this.params = data;
+          this.tabName = this.tabColumns[0].key;
+          return true;
+        } else {
+          return false;
+        }
+      } catch (err) {
+        // catch
+        console.error(err);
+      } finally {
+        // finally
+        this.loading = false;
+      }
+    },
     //
     async open(prop) {
-      const { open, fetchItem } = useMethods();
-      await open({ _this: this });
-      await fetchItem({ _this: this, prop });
+      this.visible = await this.fetchItem(prop);
     },
     //
     async hide() {
-      const { hide } = useMethods();
-      await hide({ _this: this });
-    },
-    //
-    async useEdit(prop) {
-      const { useEdit } = this.$parent.$parent;
-      await useEdit(prop);
+      this.visible = false;
     },
     //
     async useDelete(prop) {
-      const { useDelete } = this.$parent.$parent;
-      await useDelete(prop);
+      await this.root
+        .useDelete(prop)
+        .then(() => {
+          this.hide();
+        })
+        .catch(() => {});
     },
     //
     async useTermination(prop) {
-      const { useTermination } = this.$parent.$parent;
-      await useTermination(prop);
-    },
-    //
-    async usePigeonhole(prop) {
-      const { usePigeonhole } = this.$parent.$parent;
-      await usePigeonhole(prop);
-    },
-    //
-    async useAlteration(prop) {
-      const { useAlteration } = this.$parent.$parent;
-      await useAlteration(prop);
+      await this.root
+        .useTermination(prop)
+        .then(() => {
+          this.fetchItem(this.params.id);
+        })
+        .catch(() => {});
     },
   },
   created() {},
@@ -86,14 +84,8 @@ export default {
     <template slot="title">
       <span>{{ title }}</span>
       <span>
-        <el-button
-          :size="size"
-          circle
-          icon="el-icon-close"
-          @click="hide"
-        ></el-button>
         <el-tooltip
-          v-if="hasPowerDelete([params])"
+          v-if="root.hasPowerDelete([params])"
           effect="dark"
           content="删 除"
           placement="bottom-end"
@@ -106,7 +98,7 @@ export default {
           ></el-button>
         </el-tooltip>
         <el-tooltip
-          v-if="hasPowerEdit([params])"
+          v-if="root.hasPowerEdit([params])"
           effect="dark"
           content="编 辑"
           placement="bottom-end"
@@ -115,11 +107,11 @@ export default {
             :size="size"
             circle
             icon="el-icon-edit"
-            @click="useEdit([params])"
+            @click="root.useEdit([params])"
           ></el-button>
         </el-tooltip>
         <el-tooltip
-          v-if="hasPowerTermination([params])"
+          v-if="root.hasPowerTermination([params])"
           effect="dark"
           content="终 止"
           placement="bottom-end"
@@ -132,7 +124,7 @@ export default {
           ></el-button>
         </el-tooltip>
         <el-tooltip
-          v-if="hasPowerPigeonhole([params])"
+          v-if="root.hasPowerPigeonhole([params])"
           effect="dark"
           content="归 档"
           placement="bottom-end"
@@ -141,22 +133,16 @@ export default {
             :size="size"
             circle
             icon="el-icon-lightning"
-            @click="usePigeonhole([params])"
-          ></el-button>
-        </el-tooltip>
-        <el-tooltip
-          v-if="hasPowerAlteration([params])"
-          effect="dark"
-          content="变 更"
-          placement="bottom-end"
-        >
-          <el-button
-            :size="size"
-            circle
-            icon="el-icon-heavy-rain"
-            @click="useAlteration([params])"
+            @click="root.usePigeonhole([params])"
           ></el-button>
         </el-tooltip>
+        <el-button
+          :size="size"
+          circle
+          type="danger"
+          icon="el-icon-close"
+          @click="hide"
+        ></el-button>
       </span>
     </template>
     <el-descriptions :size="size" :column="column" border style="margin: 10px">

+ 24 - 22
src/views/purchase/contract/termination/index.vue

@@ -11,29 +11,31 @@ export default {
   methods: {
     //
     open(prop) {
-      this.$confirm("是否终止数据项?", "提示", {
-        confirmButtonText: "确定",
-        cancelButtonText: "取消",
-        type: "info",
-      })
-        .then(async () => {
-          try {
-            // try
-            const { code } = await TERMINATION({ id: prop });
-            if (code === 200) {
-              this.$emit("success");
-              this.$notify.success(msg);
-            }
-          } catch (err) {
-            // catch
-            console.error(err);
-          } finally {
-            // finally
-          }
+      return new Promise((resolve, reject) => {
+        this.$confirm("是否终止数据项?", "提示", {
+          confirmButtonText: "确定",
+          cancelButtonText: "取消",
+          type: "info",
         })
-        .catch((err) => {
-          console.error(err);
-        });
+          .then(async () => {
+            try {
+              // try
+              const { msg, code } = await TERMINATION({ id: prop });
+              if (code === 200) {
+                resolve(true);
+                this.$emit("success");
+                this.$notify.success(msg);
+              }
+            } catch (err) {
+              // catch
+              reject(false);
+              console.error(err);
+            } finally {
+              // finally
+            }
+          })
+          .catch(() => reject(false));
+      });
     },
   },
   created() {},