Przeglądaj źródła

完善价格申报单问题

002201 1 rok temu
rodzic
commit
64eca93d83

+ 1 - 7
src/components/computed-input/index.vue

@@ -42,13 +42,7 @@ export default {
     },
   },
   methods: {},
-  created() {
-    console.log(
-      "formatter",
-      this.$parent,
-      (this.$parent.row.customerName = "D")
-    );
-  },
+  created() {},
   mounted() {},
   destroyed() {},
 };

+ 50 - 63
src/views/purchase/apply/add/column.js

@@ -1,16 +1,16 @@
-export const TableColumns = [
+export const FormColumns = [
   {
     item: { key: "priceName", title: "价格名称" },
-    attr: { component: "el-input", value: "价格申报单" },
+    attr: { is: "el-input", value: "价格申报单" },
   },
   {
     item: { key: "priceCode", title: "价格编码" },
-    attr: { component: "el-input", disabled: true, readonly: true },
+    attr: { is: "el-input", disabled: true, readonly: true },
   },
   {
     item: { key: "supplierName", title: "供应商", require: true },
     attr: {
-      component: "el-popover-select-v2",
+      is: "el-popover-select-v2",
       valueKey: "name",
       referName: "SUPPLIER_PARAM",
       dataMapping: {
@@ -23,7 +23,7 @@ export const TableColumns = [
   {
     item: { key: "puOrgName", title: "采购组织", require: true },
     attr: {
-      component: "el-popover-select-v2",
+      is: "el-popover-select-v2",
       valueKey: "name",
       referName: "ORG_PARAM",
       dataMapping: { puOrg: "id", puOrgCode: "code", puOrgName: "name" },
@@ -32,7 +32,7 @@ export const TableColumns = [
   {
     item: { key: "currencyName", title: "币种", require: true },
     attr: {
-      component: "el-popover-select-v2",
+      is: "el-popover-select-v2",
       valueKey: "name",
       referName: "CURRENCY_PARAM",
       dataMapping: {
@@ -44,12 +44,12 @@ export const TableColumns = [
   },
   {
     item: { key: "explainStr", title: "价格合理性说明", require: true },
-    attr: { component: "el-input" },
+    attr: { is: "el-input" },
   },
   {
     item: { key: "buyerName", title: "采购员", require: true },
     attr: {
-      component: "el-popover-select-v2",
+      is: "el-popover-select-v2",
       valueKey: "name",
       referName: "CONTACTS_PARAM",
       dataMapping: { buyer: "code", buyerName: "name" },
@@ -58,7 +58,7 @@ export const TableColumns = [
   {
     item: { key: "puDeptName", title: "采购部门", require: true },
     attr: {
-      component: "el-popover-select-v2",
+      is: "el-popover-select-v2",
       valueKey: "name",
       referName: "DEPT_PARAM",
       dataMapping: { puDept: "id", puDeptCode: "code", puDeptName: "name" },
@@ -66,39 +66,39 @@ export const TableColumns = [
   },
   {
     item: { key: "createByName", title: "创建人" },
-    attr: { component: "el-input", disabled: true, readonly: true },
+    attr: { is: "el-input", disabled: true, readonly: true },
   },
   {
     item: { key: "source", title: "来源单据号" },
-    attr: { component: "el-input", disabled: true, readonly: true },
+    attr: { is: "el-input", disabled: true, readonly: true },
   },
   {
     item: { key: "id", title: "来源单据id" },
-    attr: { component: "el-input", disabled: true, readonly: true },
+    attr: { is: "el-input", disabled: true, readonly: true },
   },
   {
     item: { key: "isEffective", title: "是否已推价格" },
     attr: {
-      component: "el-select",
+      is: "el-select",
       dictName: "is_effective",
     },
   },
   {
     item: { key: "effectiveDate", title: "生效日期" },
-    attr: { component: "el-input", disabled: true, readonly: true },
+    attr: { is: "el-input", disabled: true, readonly: true },
   },
   {
     item: { key: "file", title: "附件", require: true, span: 24 },
-    attr: { component: "file-upload" },
+    attr: { is: "file-upload" },
   },
   {
     item: { key: "sourceType", title: "来源单据类型" },
-    attr: { component: "el-input", disabled: true, readonly: true },
+    attr: { is: "el-input", disabled: true, readonly: true },
   },
   {
     item: { key: "status", title: "单据状态" },
     attr: {
-      component: "el-select",
+      is: "el-select",
       dictName: "sys_status",
       disabled: true,
       readonly: true,
@@ -109,13 +109,18 @@ export const TableColumns = [
 
 export const TabColumns = [
   {
-    title: "物料信息表",
-    key: "priceApplyItems",
-    tableColumns: [
+    item: {
+      title: "物料信息表",
+      key: "priceApplyItems",
+    },
+    attr: {
+      value: [],
+    },
+    TableColumns: [
       {
         item: { key: "materialName", title: "物料名称", require: true },
         attr: {
-          component: "el-popover-select-v2",
+          is: "el-popover-select-v2",
           valueKey: "name",
           referName: "MATERIAL_PARAM",
           dataMapping: {
@@ -138,7 +143,7 @@ export const TabColumns = [
       {
         item: { key: "unitName", title: "单位" },
         attr: {
-          component: "el-popover-select-v2",
+          is: "el-popover-select-v2",
           valueKey: "name",
           referName: "UNIT_PARAM",
           dataMapping: { unit: "id", unitCode: "code", unitName: "name" },
@@ -147,7 +152,7 @@ export const TabColumns = [
       {
         item: { key: "puUnitName", title: "采购单位" },
         attr: {
-          component: "el-popover-select-v2",
+          is: "el-popover-select-v2",
           valueKey: "name",
           referName: "UNIT_PARAM",
           dataMapping: { puUnit: "id", puUnitCode: "code", puUnitName: "name" },
@@ -156,24 +161,23 @@ export const TabColumns = [
       {
         item: { key: "conversionRate", title: "采购换算率", require: true },
         attr: {
-          component: "el-input-number",
+          is: "el-input-number",
           precision: 6,
         },
       },
       {
         item: { key: "tax", title: "税率%", require: true },
         attr: {
-          component: "el-popover-select-v2",
+          is: "el-popover-select-v2",
           valueKey: "ntaxrate",
           referName: "TAX_RATE_PARAM",
           dataMapping: { tax: "ntaxrate" },
-          formatter: (prop) => (prop ? (prop * 1).toFixed(6) : null),
         },
       },
       {
         item: { key: "taxPrice", title: "含税单价", require: true },
         attr: {
-          component: "el-input-number",
+          is: "el-input-number",
           precision: 6,
           formatter: (prop) => (prop ? (prop * 1).toFixed(6) : null),
         },
@@ -181,7 +185,7 @@ export const TabColumns = [
       {
         item: { key: "price", title: "无税单价", require: true },
         attr: {
-          component: "el-computed-input",
+          is: "el-computed-input",
           formatter: (prop) => {
             const { tax, taxPrice } = prop;
             const newTax = Number(tax) / 100;
@@ -193,7 +197,7 @@ export const TabColumns = [
       {
         item: { key: "currencyName", title: "币种" },
         attr: {
-          component: "el-popover-select-v2",
+          is: "el-popover-select-v2",
           valueKey: "name",
           referName: "CURRENCY_PARAM",
           dataMapping: {
@@ -206,7 +210,7 @@ export const TabColumns = [
       {
         item: { key: "periodBegin", title: "价格有效期(起)", require: true },
         attr: {
-          component: "el-date-picker",
+          is: "el-date-picker",
           valueFormat: "yyyy-MM-dd",
           value: new Date(),
         },
@@ -214,7 +218,7 @@ export const TabColumns = [
       {
         item: { key: "periodEnd", title: "价格有效期(止)", require: true },
         attr: {
-          component: "el-date-picker",
+          is: "el-date-picker",
           valueFormat: "yyyy-MM-dd",
           pickerOptions: {
             disabledDate(time) {
@@ -228,7 +232,7 @@ export const TabColumns = [
       {
         item: { key: "customerName", title: "客户" },
         attr: {
-          component: "el-popover-select-v2",
+          is: "el-popover-select-v2",
           valueKey: "name",
           referName: "CUSTOMER_PARAM",
           dataMapping: {
@@ -242,28 +246,28 @@ export const TabColumns = [
       {
         item: { key: "isApprovalFirst", title: "首次报批" },
         attr: {
-          component: "el-select",
+          is: "el-select",
           dictName: "is_effective",
         },
       },
       {
         item: { key: "isPriceAdjustment", title: "价格调整" },
         attr: {
-          component: "el-select",
+          is: "el-select",
           dictName: "is_effective",
         },
       },
       {
         item: { key: "priceType", title: "价格类型" },
         attr: {
-          component: "el-select",
+          is: "el-select",
           dictName: "sys_price_type",
         },
       },
       {
         item: { key: "isDistributionPrice", title: "配送价", require: true },
         attr: {
-          component: "el-select",
+          is: "el-select",
           dictName: "is_effective",
         },
       },
@@ -272,13 +276,18 @@ export const TabColumns = [
     ],
   },
   {
-    title: "合同执行组织范围",
-    key: "priceApplyOrgs",
-    tableColumns: [
+    item: {
+      title: "合同执行组织范围",
+      key: "priceApplyOrgs",
+    },
+    attr: {
+      value: [],
+    },
+    TableColumns: [
       {
         item: { key: "orgName", title: "组织", require: true, width: "auto" },
         attr: {
-          component: "el-popover-select-v2",
+          is: "el-popover-select-v2",
           valueKey: "name",
           referName: "ORG_PARAM",
           dataMapping: {
@@ -300,26 +309,4 @@ export const TabColumns = [
   },
 ];
 
-// console.log(
-//   JSON.stringify(
-//     TabColumns[0].tableColumns.map((item) => ({
-//       item: { key: item.key, title: item.title, require: item.require },
-//       attr: {
-//         component: item.inputType,
-//         dictName: item.referName,
-//         referName: item.referName,
-//         clearable: item.clearable,
-//         dataMapping: item.dataMapping,
-//         disabled: item.disabled,
-//         readonly: item.readonly,
-//         formatter: item.formatter,
-//         valueFormat: item.valueFormat,
-//         pickerOptions: item.pickerOptions,
-//         computed: item.computed,
-//         value: item.value,
-//       },
-//     }))
-//   )
-// );
-
-export default { TableColumns, TabColumns };
+export default { FormColumns, TabColumns };

+ 66 - 73
src/views/purchase/apply/add/index.vue

@@ -3,10 +3,10 @@ import Column from "./column";
 import useData from "../hooks/data";
 import useWatch from "../hooks/watch";
 import useMethods from "../hooks/function";
-import { initParams } from "@/utils/init.js";
 import { ITEM, SAVE } from "@/api/business/purchase/apply";
 
-const { watchPuOrgName } = useWatch();
+const { watchPuOrgName: w1 } = useWatch();
+const { fetchTax, fetchUnit, fetchExist } = useMethods();
 
 export default {
   name: "AddDrawer",
@@ -28,22 +28,24 @@ export default {
     },
   },
   watch: {
-    "params.puOrgName": watchPuOrgName(),
+    "params.puOrgName": w1(),
   },
   methods: {
     //
-    async fetchRefer(prop, type, source) {
-      const { fetchTax, fetchUnit, fetchExist } = useMethods();
-      if (type === "MATERIAL_PARAM") {
+    async fetchRefer(row, prop = {}) {
+      const { source, referName } = prop;
+      if (referName === "MATERIAL_PARAM") {
         const { puOrg, customer, supplier } = this.params;
-        const { rateCode, unitIdName, code: materialCode } = prop;
+        const { rateCode, unitIdName, code: materialCode } = row;
         // task 1
-        fetchTax(rateCode).then(({ ntaxrate }) => {
+        fetchTax(rateCode).then((res) => {
+          const { ntaxrate } = res;
           source.tax =
             ntaxrate === "0E-8" ? "0.000000" : (ntaxrate * 1).toFixed(6);
         });
         // task 2
-        fetchUnit(unitIdName).then(({ id, code, name }) => {
+        fetchUnit(unitIdName).then((res) => {
+          const { id, code, name } = res;
           source.unit = id;
           source.unitCode = code;
           source.unitName = name;
@@ -52,13 +54,12 @@ export default {
           source.puUnitName = name;
         });
         // task 3
-        fetchExist({ puOrg, customer, supplier, materialCode }).then(
-          ({ recentlyPrice, isApprovalFirst, isPriceAdjustment }) => {
-            source.recentlyPrice = recentlyPrice;
-            source.isApprovalFirst = isApprovalFirst;
-            source.isPriceAdjustment = isPriceAdjustment;
-          }
-        );
+        fetchExist({ puOrg, customer, supplier, materialCode }).then((res) => {
+          const { recentlyPrice, isApprovalFirst, isPriceAdjustment } = res;
+          source.recentlyPrice = recentlyPrice;
+          source.isApprovalFirst = isApprovalFirst;
+          source.isPriceAdjustment = isPriceAdjustment;
+        });
       }
     },
     //
@@ -69,15 +70,28 @@ export default {
         const { code, data } = await ITEM(prop);
         if (code === 200) {
           this.params = data;
+          this.params.id = null;
           this.params.createBy = null;
           this.params.priceCode = null;
           this.params.createByName = null;
           this.params.effectiveDate = null;
           this.params.priceApplyItems = this.params.priceApplyItems.map(
-            (item) => ({ ...item, createByName: null, updateByName: null })
+            (item) => ({
+              ...item,
+              id: null,
+              applyId: null,
+              createByName: null,
+              updateByName: null,
+            })
           );
           this.params.priceApplyOrgs = this.params.priceApplyOrgs.map(
-            (item) => ({ ...item, createByName: null, updateByName: null })
+            (item) => ({
+              ...item,
+              id: null,
+              applyId: null,
+              createByName: null,
+              updateByName: null,
+            })
           );
           return true;
         } else {
@@ -97,15 +111,17 @@ export default {
     },
     //
     async hide() {
+      const { TabColumns, FormColumns, initParams } = this;
       this.visible = false;
-      this.params = this.resetParams();
-      this.tabName = this.tabColumns[0].key;
+      this.tabName = TabColumns[0].item.key;
+      this.params = initParams([...TabColumns, ...FormColumns]);
     },
     //
     async useRowAdd(prop) {
       const {
         $notify,
-        tabColumns,
+        initParams,
+        TabColumns,
         params: { puOrgName, supplierName },
       } = this;
       if (!supplierName) {
@@ -114,10 +130,8 @@ export default {
       if (!puOrgName) {
         return $notify.info("请选择采购组织");
       }
-      const { tableColumns } = tabColumns.find(
-        (element) => element.key === prop
-      );
-      this.params[prop].push(initParams(tableColumns));
+      const { TableColumns } = TabColumns.find(({ item }) => item.key === prop);
+      this.params[prop].push(initParams(TableColumns));
     },
     //
     async useRowRemove(prop, scope) {
@@ -130,28 +144,7 @@ export default {
         if (valid) {
           try {
             // try
-            const {
-              priceApplyOrgs: _priceApplyOrgs,
-              priceApplyItems: _priceApplyItems,
-            } = this.params;
-            const id = undefined;
-            const priceApplyOrgs = _priceApplyOrgs.map((item) => ({
-              ...item,
-              id: undefined,
-              applyId: undefined,
-            }));
-            const priceApplyItems = _priceApplyItems.map((item) => ({
-              ...item,
-              id: undefined,
-              applyId: undefined,
-            }));
-            const params = {
-              ...this.params,
-              id,
-              priceApplyOrgs,
-              priceApplyItems,
-            };
-            const { msg, code } = await SAVE(params);
+            const { msg, code } = await SAVE({ ...this.params });
             if (code === 200) {
               this.hide();
               this.$emit("success");
@@ -213,25 +206,24 @@ export default {
     >
       <el-row :gutter="20" style="display: flex; flex-wrap: wrap">
         <el-col
-          v-for="column in tableColumns"
-          :key="column.item.title"
-          :span="column.item.span || 8"
+          v-for="({ item, attr }, index) in FormColumns"
+          :key="index"
+          :span="item.span || 8"
         >
           <el-form-item
-            :prop="column.item.key"
-            :label="column.item.title"
-            :require="column.item.require"
+            :prop="item.key"
+            :label="item.title"
+            :require="item.require"
           >
             <component
-              v-bind="column.attr"
-              v-model="params[column.item.key]"
+              v-bind="attr"
+              v-model="params[item.key]"
               :source.sync="params"
-              :is="column.attr.component"
               style="width: 100%"
             >
-              <template v-if="column.attr.dictName">
+              <template v-if="attr.dictName">
                 <el-option
-                  v-for="item in $dicts[column.attr.dictName]"
+                  v-for="item in $dicts[attr.dictName]"
                   :key="item.value"
                   :label="item.label"
                   :value="item.value"
@@ -245,39 +237,40 @@ export default {
           <el-form-item label-width="0">
             <el-tabs v-model="tabName">
               <el-tab-pane
-                v-for="(column, index) in tabColumns"
+                v-for="({ item, attr, TableColumns }, index) in TabColumns"
                 :key="index"
-                :label="column.title"
-                :name="column.key"
+                :label="item.title"
+                :name="item.key"
                 lazy
               >
-                <el-table :size="size" :data="params[column.key]">
+                <el-table :size="size" :data="params[item.key]">
                   <el-table-column label="序号">
                     <template slot-scope="scope">
                       {{ scope.$index + 1 }}
                     </template>
                   </el-table-column>
                   <el-table-column
-                    v-for="(cColumn, cIndex) in column.tableColumns"
+                    v-for="(
+                      { item: cItem, attr: cAttr }, cIndex
+                    ) in TableColumns"
                     :key="cIndex"
-                    :prop="cColumn.item.key"
-                    :label="cColumn.item.title"
-                    :width="cColumn.item.width || 250"
+                    :prop="cItem.key"
+                    :label="cItem.title"
+                    :width="cItem.width || 250"
                     show-overflow-tooltip
                   >
                     <template slot-scope="scope">
                       <component
-                        v-if="cColumn.attr.component"
-                        v-bind="cColumn.attr"
-                        v-model="scope.row[cColumn.item.key]"
+                        v-if="cAttr.is"
+                        v-bind="cAttr"
+                        v-model="scope.row[cItem.key]"
                         :source.sync="scope.row"
-                        :is="cColumn.attr.component"
                         @change="fetchRefer"
                         style="width: 100%"
                       >
-                        <template v-if="cColumn.attr.dictName">
+                        <template v-if="cAttr.dictName">
                           <el-option
-                            v-for="item in $dicts[cColumn.attr.dictName]"
+                            v-for="item in $dicts[cAttr.dictName]"
                             :key="item.value"
                             :label="item.label"
                             :value="item.value"
@@ -285,7 +278,7 @@ export default {
                           </el-option>
                         </template>
                       </component>
-                      <span v-else> {{ scope.row[cColumn.item.key] }}</span>
+                      <span v-else> {{ scope.row[cItem.key] }}</span>
                     </template>
                   </el-table-column>
                   <el-table-column fixed="right" label="操作" width="100">

+ 2 - 2
src/views/purchase/apply/column.js

@@ -15,13 +15,13 @@ export const TableColumns = [
     attr: { component: "dr-file-preview" },
   },
   { item: { key: "createByName", title: "创建人" }, attr: {} },
-  { item: { key: "source", title: "来源单据号" }, attr: {} },
-  { item: { key: "id", title: "来源单据id" }, attr: {} },
   {
     item: { key: "isEffective", title: "是否已推价格" },
     attr: { dictName: "is_effective" },
   },
   { item: { key: "effectiveDate", title: "生效日期" }, attr: {} },
+  { item: { key: "id", title: "来源单据id" }, attr: {} },
+  { item: { key: "source", title: "来源单据号" }, attr: {} },
   { item: { key: "sourceType", title: "来源单据类型" }, attr: {} },
 ];
 

+ 69 - 69
src/views/purchase/apply/edit/index.vue

@@ -3,11 +3,10 @@ import Column from "../add/column";
 import useData from "../hooks/data";
 import useWatch from "../hooks/watch";
 import useMethods from "../hooks/function";
-import { initParams } from "@/utils/init.js";
 import { ITEM, SAVE } from "@/api/business/purchase/apply";
 
-const { watchPuOrgName, watchPriceApplyOrgs, watchPriceApplyItems } =
-  useWatch();
+const { watchPuOrgName: w1 } = useWatch();
+const { fetchTax, fetchUnit, fetchExist } = useMethods();
 
 export default {
   name: "EditDrawer",
@@ -18,17 +17,10 @@ export default {
   data() {
     return {
       title: "更 新",
-      newParams: {
-        priceApplyOrgs: [],
-        priceApplyItems: [],
-      },
       ...useData(Column),
     };
   },
   computed: {
-    root: function () {
-      return this.$parent.$parent;
-    },
     $dicts: {
       get: function () {
         return this.$parent.$parent.$dicts;
@@ -36,23 +28,24 @@ export default {
     },
   },
   watch: {
-    "params.puOrgName": watchPuOrgName(),
-    "params.priceApplyOrgs": watchPriceApplyOrgs(),
-    "params.priceApplyItems": watchPriceApplyItems(),
+    "params.puOrgName": w1(),
   },
   methods: {
     //
-    async fetchRefer(prop, type, source) {
-      const { fetchTax, fetchUnit, fetchExist } = useMethods();
-      if (type === "MATERIAL_PARAM") {
+    async fetchRefer(row, prop = {}) {
+      const { source, referName } = prop;
+      if (referName === "MATERIAL_PARAM") {
         const { puOrg, customer, supplier } = this.params;
-        const { rateCode, unitIdName, code: materialCode } = prop;
+        const { rateCode, unitIdName, code: materialCode } = row;
         // task 1
-        fetchTax(rateCode).then(({ ntaxrate }) => {
-          source.tax = ntaxrate === "0E-8" ? "0.00000000" : ntaxrate;
+        fetchTax(rateCode).then((res) => {
+          const { ntaxrate } = res;
+          source.tax =
+            ntaxrate === "0E-8" ? "0.000000" : (ntaxrate * 1).toFixed(6);
         });
         // task 2
-        fetchUnit(unitIdName).then(({ id, code, name }) => {
+        fetchUnit(unitIdName).then((res) => {
+          const { id, code, name } = res;
           source.unit = id;
           source.unitCode = code;
           source.unitName = name;
@@ -61,13 +54,12 @@ export default {
           source.puUnitName = name;
         });
         // task 3
-        fetchExist({ puOrg, customer, supplier, materialCode }).then(
-          ({ recentlyPrice, isApprovalFirst, isPriceAdjustment }) => {
-            source.recentlyPrice = recentlyPrice;
-            source.isApprovalFirst = isApprovalFirst;
-            source.isPriceAdjustment = isPriceAdjustment;
-          }
-        );
+        fetchExist({ puOrg, customer, supplier, materialCode }).then((res) => {
+          const { recentlyPrice, isApprovalFirst, isPriceAdjustment } = res;
+          source.recentlyPrice = recentlyPrice;
+          source.isApprovalFirst = isApprovalFirst;
+          source.isPriceAdjustment = isPriceAdjustment;
+        });
       }
     },
     //
@@ -96,15 +88,17 @@ export default {
     },
     //
     async hide() {
+      const { TabColumns, FormColumns, initParams } = this;
       this.visible = false;
-      this.params = this.resetParams();
-      this.tabName = this.tabColumns[0].key;
+      this.tabName = TabColumns[0].item.key;
+      this.params = initParams([...TabColumns, ...FormColumns]);
     },
     //
     async useRowAdd(prop) {
       const {
         $notify,
-        tabColumns,
+        TabColumns,
+        initParams,
         params: { puOrgName, supplierName },
       } = this;
       if (!supplierName) {
@@ -113,14 +107,14 @@ export default {
       if (!puOrgName) {
         return $notify.info("请选择采购组织");
       }
-      const { tableColumns } = tabColumns.find(
-        (element) => element.key === prop
-      );
-      this.params[prop].push({ ...initParams(tableColumns), delFlag: "0" });
+      const { TableColumns } = TabColumns.find(({ item }) => item.key === prop);
+      this.params[prop].push({ ...initParams(TableColumns), delFlag: "0" });
     },
     //
     async useRowRemove(prop, scope) {
-      const { $index } = scope;
+      const {
+        row: { $index },
+      } = scope;
       this.params[prop] = this.params[prop].map((item, index) => ({
         ...item,
         delFlag: index === $index ? "2" : item.delFlag,
@@ -135,9 +129,6 @@ export default {
             const params = { ...this.params };
             const { msg, code } = await SAVE(params);
             if (code === 200) {
-              const { id } = this.params;
-              const { fetchItem } = this.root.$refs.SeeModel;
-              await fetchItem(id);
               this.hide();
               this.$emit("success");
               this.$notify.success(msg);
@@ -173,14 +164,16 @@ export default {
         <el-button
           :size="size"
           circle
-          icon="el-icon-close"
-          @click="hide"
-        ></el-button>
+          icon="el-icon-check"
+          @click="useSubmit('ruleForm')"
+        >
+        </el-button>
         <el-button
           :size="size"
           circle
-          icon="el-icon-check"
-          @click="useSubmit('ruleForm')"
+          type="danger"
+          icon="el-icon-close"
+          @click="hide"
         ></el-button>
       </span>
     </template>
@@ -196,25 +189,24 @@ export default {
     >
       <el-row :gutter="20" style="display: flex; flex-wrap: wrap">
         <el-col
-          v-for="column in tableColumns"
-          :key="column.item.title"
-          :span="column.item.span || 8"
+          v-for="({ item, attr }, index) in FormColumns"
+          :key="index"
+          :span="item.span || 8"
         >
           <el-form-item
-            :prop="column.item.key"
-            :label="column.item.title"
-            :require="column.item.require"
+            :prop="item.key"
+            :label="item.title"
+            :require="item.require"
           >
             <component
-              v-bind="column.attr"
-              v-model="params[column.item.key]"
+              v-bind="attr"
+              v-model="params[item.key]"
               :source.sync="params"
-              :is="column.attr.component"
               style="width: 100%"
             >
-              <template v-if="column.attr.dictName">
+              <template v-if="attr.dictName">
                 <el-option
-                  v-for="item in $dicts[column.attr.dictName]"
+                  v-for="item in $dicts[attr.dictName]"
                   :key="item.value"
                   :label="item.label"
                   :value="item.value"
@@ -228,39 +220,47 @@ export default {
           <el-form-item label-width="0">
             <el-tabs v-model="tabName">
               <el-tab-pane
-                v-for="(column, index) in tabColumns"
+                v-for="({ item, attr, TableColumns }, index) in TabColumns"
                 :key="index"
-                :label="column.title"
-                :name="column.key"
+                :label="item.title"
+                :name="item.key"
                 lazy
               >
-                <el-table :size="size" :data="newParams[column.key]">
+                <el-table
+                  :size="size"
+                  :data="
+                    params[item.key]
+                      .map((item, index) => ({ ...item, $index: index }))
+                      .filter(({ delFlag }) => delFlag === '0')
+                  "
+                >
                   <el-table-column label="序号">
                     <template slot-scope="scope">
                       {{ scope.$index + 1 }}
                     </template>
                   </el-table-column>
                   <el-table-column
-                    v-for="(cColumn, cIndex) in column.tableColumns"
+                    v-for="(
+                      { item: cItem, attr: cAttr }, cIndex
+                    ) in TableColumns"
                     :key="cIndex"
-                    :prop="cColumn.item.key"
-                    :label="cColumn.item.title"
-                    :width="cColumn.item.width || 250"
+                    :prop="cItem.key"
+                    :label="cItem.title"
+                    :width="cItem.width || 250"
                     show-overflow-tooltip
                   >
                     <template slot-scope="scope">
                       <component
-                        v-if="cColumn.attr.component"
-                        v-bind="cColumn.attr"
-                        v-model="scope.row[cColumn.item.key]"
+                        v-if="cAttr.is"
+                        v-bind="cAttr"
+                        v-model="scope.row[cItem.key]"
                         :source.sync="scope.row"
-                        :is="cColumn.attr.component"
                         @change="fetchRefer"
                         style="width: 100%"
                       >
-                        <template v-if="cColumn.attr.dictName">
+                        <template v-if="cAttr.dictName">
                           <el-option
-                            v-for="item in $dicts[cColumn.attr.dictName]"
+                            v-for="item in $dicts[cAttr.dictName]"
                             :key="item.value"
                             :label="item.label"
                             :value="item.value"
@@ -268,7 +268,7 @@ export default {
                           </el-option>
                         </template>
                       </component>
-                      <span v-else> {{ scope.row[cColumn.item.key] }}</span>
+                      <span v-else> {{ scope.row[cItem.key] }}</span>
                     </template>
                   </el-table-column>
                   <el-table-column fixed="right" label="操作" width="100">

+ 6 - 17
src/views/purchase/apply/hooks/data.js

@@ -1,35 +1,24 @@
 import { initRules, initParams } from "@/utils/init.js";
 
 export default function useData(prop) {
-  const { TableColumns, TabColumns } = prop;
+  const { FormColumns, TabColumns } = prop;
   const size = "mini";
   const width = "100%";
   const visible = false;
   const loading = false;
-  const tableColumns = TableColumns;
-  const rules = initRules(TableColumns);
-  const params = {
-    priceApplyOrgs: [],
-    priceApplyItems: [],
-    ...initParams(TableColumns),
-  };
-  const resetParams = () => ({
-    priceApplyOrgs: [],
-    priceApplyItems: [],
-    ...initParams(TableColumns),
-  });
-  const tabColumns = TabColumns;
+  const rules = initRules(FormColumns);
+  const params = initParams([...TabColumns, ...FormColumns]);
   const tabName = "priceApplyItems";
   return {
     size,
     width,
     visible,
     loading,
-    tableColumns,
     rules,
     params,
-    tabColumns,
     tabName,
-    resetParams,
+    initParams,
+    TabColumns,
+    FormColumns,
   };
 }

+ 3 - 18
src/views/purchase/apply/hooks/watch.js

@@ -24,7 +24,7 @@ export default function useWatch() {
       const index = this.params.priceApplyOrgs.findIndex(
         (item) => item.orgName === newProp
       );
-      if (index === -1) {
+      if (index === -1 && newProp) {
         const {
           id: org,
           code: orgCode,
@@ -41,21 +41,6 @@ export default function useWatch() {
     },
     deep: true,
   });
-  const watchPriceApplyOrgs = () => ({
-    handler: function (newValue) {
-      this.newParams.priceApplyOrgs = newValue.filter(
-        (item) => item.delFlag === "0"
-      );
-    },
-    deep: true,
-  });
-  const watchPriceApplyItems = () => ({
-    handler: function (newValue) {
-      this.newParams.priceApplyItems = newValue.filter(
-        (item) => item.delFlag === "0"
-      );
-    },
-    deep: true,
-  });
-  return { watchPuOrgName, watchPriceApplyOrgs, watchPriceApplyItems };
+
+  return { watchPuOrgName };
 }

+ 92 - 37
src/views/purchase/apply/index.vue

@@ -18,6 +18,7 @@ export default {
     return {
       size: "mini",
       loading: false,
+      batching: false,
       searchColumns: SearchColumns,
       params: initParams(SearchColumns),
       tableData: [],
@@ -32,17 +33,37 @@ export default {
         return this.dict.type;
       },
     },
+    $power: {
+      get() {
+        const {
+          batching,
+          selectData,
+          selectData: [{ status } = {}],
+        } = this;
+        const rule1 = selectData.length === 1;
+        const rule2 = selectData.length > 1;
+        const rule3 = status === "0" || status === "3";
+        const copy = rule1;
+        const edit = rule1 && rule3;
+        const delt = rule1 ? rule1 && rule3 : rule2;
+        const subm = rule1 ? rule1 && rule3 : rule2;
+        return {
+          // 复 制
+          copy: copy,
+          // 修 改
+          edit: edit,
+          // 删 除
+          delt: delt,
+          // 审 核
+          subm: subm,
+        };
+      },
+    },
   },
   created() {
     this.params.status = "0";
     this.useQuery(this.params, this.page);
   },
-  provide() {
-    return {
-      initParams,
-      $dicts: this.$dicts,
-    };
-  },
   methods: {
     //
     setSelectable(row) {
@@ -94,8 +115,17 @@ export default {
       this.useQuery(this.params, this.page);
     },
     // 选 择
+    useRowClick(prop) {
+      if (!this.batching) this.selectData = prop;
+    },
+    // 选 择
     useSelect(prop) {
-      this.selectData = prop;
+      if (this.batching) this.selectData = prop;
+    },
+    // 批 量
+    useBatch() {
+      this.selectData = [];
+      this.batching = !this.batching;
     },
     // 新 增
     async useAdd() {
@@ -132,16 +162,6 @@ export default {
       const { open } = this.$refs.EditModel;
       await open(id);
     },
-    hasPowerEdit(prop) {
-      if (prop.length === 1) {
-        const [{ status }] = prop;
-        if (status === "1") return false;
-        else if (status === "2") return false;
-        else return true;
-      } else {
-        return !!prop.length;
-      }
-    },
     // 明 细
     async useSee(prop) {
       const { $index } = prop;
@@ -169,7 +189,7 @@ export default {
 
 <template>
   <el-card v-loading="loading" :body-style="{ padding: 0 }">
-    <see-model ref="SeeModel"></see-model>
+    <see-model ref="SeeModel" @success="useQuery(params, page)"></see-model>
     <add-model ref="AddModel" @success="useReset"></add-model>
     <edit-model ref="EditModel" @success="useQuery(params, page)"></edit-model>
     <submit-model
@@ -216,38 +236,69 @@ export default {
         </el-col>
       </el-row>
     </el-form>
-    <el-row style="padding: 0 20px">
-      <el-button :size="size" @click="useQuery(params, page)">
-        查 询
-      </el-button>
-      <el-button :size="size" @click="useReset"> 重 置 </el-button>
-      <el-button :size="size" @click="useAdd"> 新 增 </el-button>
-      <el-button
-        v-show="hasPowerCopy(selectData)"
-        :size="size"
-        @click="useCopy(selectData)"
-      >
-        复 制
-      </el-button>
-      <el-button
-        v-show="hasPowerDelete(selectData)"
+    <div style="padding: 0 20px; display: flex; justify-content: space-between">
+      <div>
+        <el-button :size="size" @click="useQuery(params, page)">
+          查 询
+        </el-button>
+        <el-button :size="size" @click="useReset">重 置</el-button>
+        <el-button :size="size" @click="useAdd">新 增</el-button>
+        <el-button
+          v-show="$power.copy"
+          :size="size"
+          @click="useCopy(selectData)"
+        >
+          复 制
+        </el-button>
+        <el-button
+          v-show="$power.edit"
+          :size="size"
+          @click="useEdit(selectData)"
+          >编 辑</el-button
+        >
+        <!-- <el-button
+        v-show="$power.delt"
         :size="size"
         @click="useDelete(selectData)"
       >
         删 除
-      </el-button>
-    </el-row>
+      </el-button> -->
+        <el-button
+          v-show="$power.delt"
+          :size="size"
+          @click="useDelete(selectData)"
+          >删 除</el-button
+        >
+        <el-button
+          v-show="$power.subm"
+          :size="size"
+          @click="useSubmit(selectData)"
+          >审 核</el-button
+        >
+      </div>
+      <div>
+        <el-button
+          :size="size"
+          :icon="batching ? 'el-icon-close' : 'el-icon-check'"
+          @click="useBatch"
+        >
+          批 量
+        </el-button>
+      </div>
+    </div>
     <el-table
       v-if="tableData.length"
       :size="size"
       :data="tableData"
+      border
       stripe
       highlight-current-row
       @row-dblclick="useSee"
       @selection-change="useSelect"
-      @row-click="useSelect([$event])"
+      @row-click="useRowClick([$event])"
     >
       <el-table-column
+        v-if="batching"
         fixed
         width="55"
         align="center"
@@ -255,7 +306,7 @@ export default {
         :selectable="setSelectable"
       >
       </el-table-column>
-      <el-table-column fixed width="55" align="center" type="index">
+      <el-table-column width="55" align="center" type="index">
         <template slot-scope="scope">
           {{ scope.row.$index }}
         </template>
@@ -318,6 +369,10 @@ export default {
     .el-table__cell {
       height: 50px;
     }
+    td.el-table__cell {
+      border-right: 0;
+      // border-bottom: 0;
+    }
   }
 }
 </style>

+ 46 - 43
src/views/purchase/apply/see/index.vue

@@ -66,26 +66,29 @@ export default {
     },
     //
     async hide() {
+      const { TabColumns, FormColumns, initParams } = this;
       this.visible = false;
+      this.tabName = TabColumns[0].item.key;
+      this.params = initParams([...TabColumns, ...FormColumns]);
     },
-    //
-    async useDelete(prop) {
-      await this.$father
-        .useDelete(prop)
-        .then(() => {
-          this.hide();
-        })
-        .catch(() => {});
-    },
-    //
-    async useSubmit(prop) {
-      await this.$father
-        .useSubmit(prop)
-        .then(() => {
-          this.hide();
-        })
-        .catch(() => {});
-    },
+    // //
+    // async useDelete(prop) {
+    //   await this.$father
+    //     .useDelete(prop)
+    //     .then(() => {
+    //       this.hide();
+    //     })
+    //     .catch(() => {});
+    // },
+    // //
+    // async useSubmit(prop) {
+    //   await this.$father
+    //     .useSubmit(prop)
+    //     .then(() => {
+    //       this.hide();
+    //     })
+    //     .catch(() => {});
+    // },
   },
   created() {},
   mounted() {},
@@ -130,7 +133,7 @@ export default {
     <template slot="title">
       <span>{{ title }}</span>
       <span>
-        <el-tooltip effect="dark" content="删 除" placement="bottom-end">
+        <!-- <el-tooltip effect="dark" content="删 除" placement="bottom-end">
           <el-button
             :size="size"
             circle
@@ -171,7 +174,7 @@ export default {
             icon="el-icon-check"
             @click="useSubmit([params])"
           ></el-button>
-        </el-tooltip>
+        </el-tooltip> -->
         <el-button
           :size="size"
           circle
@@ -183,52 +186,52 @@ export default {
     </template>
     <el-descriptions :size="size" :column="column" border style="margin: 10px">
       <el-descriptions-item
-        v-if="params[column.item.key]"
-        v-for="(column, index) in tableColumns"
+        v-if="params[item.key]"
+        v-for="({ item, attr }, index) in FormColumns"
         :key="index"
-        :label="column.item.title"
+        :label="item.title"
       >
         <dict-tag
-          v-if="column.attr.component === 'el-select'"
+          v-if="attr.is === 'el-select'"
           :size="size"
-          :value="params[column.item.key]"
-          :options="$dicts[column.attr.dictName]"
+          :value="params[item.key]"
+          :options="$dicts[attr.dictName]"
         />
         <dr-file-preview
-          v-else-if="column.attr.component === 'file-upload'"
-          v-model="params[column.item.key]"
+          v-else-if="attr.is === 'file-upload'"
+          v-model="params[item.key]"
         ></dr-file-preview>
-        <span v-else>{{ params[column.item.key] }}</span>
+        <span v-else>{{ params[item.key] }}</span>
       </el-descriptions-item>
     </el-descriptions>
     <el-tabs v-model="tabName" :size="size" style="margin: 10px">
       <el-tab-pane
-        v-for="(column, index) in tabColumns"
+        v-for="({ item, attr, TableColumns }, index) in TabColumns"
         :key="index"
-        :name="column.key"
-        :label="column.title"
+        :name="item.key"
+        :label="item.title"
         lazy
       >
-        <el-table :size="size" :data="params[column.key]">
+        <el-table :size="size" :data="params[item.key]">
           <el-table-column
-            v-for="(cColumn, cIndex) in column.tableColumns"
+            v-for="({ item: cItem, attr: cAttr }, cIndex) in TableColumns"
             :key="cIndex"
-            :prop="cColumn.item.key"
-            :label="cColumn.item.title"
-            :width="cColumn.item.width || 250"
+            :prop="cItem.key"
+            :label="cItem.title"
+            :width="cItem.width || 250"
             show-overflow-tooltip
           >
             <template slot-scope="scope">
               <dict-tag
-                v-if="cColumn.attr.component === 'el-select'"
+                v-if="cAttr.is === 'el-select'"
                 :size="size"
-                :value="scope.row[cColumn.item.key]"
-                :options="$dicts[cColumn.attr.dictName]"
+                :value="scope.row[cItem.key]"
+                :options="$dicts[cAttr.dictName]"
               />
               <span v-else>{{
-                cColumn.attr.formatter
-                  ? cColumn.attr.formatter(scope.row[cColumn.item.key])
-                  : scope.row[cColumn.item.key]
+                cAttr.formatter
+                  ? cAttr.formatter(scope.row[cItem.key])
+                  : scope.row[cItem.key]
               }}</span>
             </template>
           </el-table-column>