002201 %!s(int64=2) %!d(string=hai) anos
pai
achega
3e1c3a081b

+ 10 - 30
src/views/purchase/apply/add/index.vue

@@ -2,9 +2,11 @@
 import Column from "./column";
 import useData from "../hooks/data";
 import useDicts from "../hooks/dicts";
+import useWatch from "../hooks/watch";
 import useMethods from "../hooks/function";
 import useTable from "../hooks/table-function";
 import { SAVE } from "@/api/business/purchase/apply";
+const { watchPuOrg } = useWatch();
 
 export default {
   name: "AddDrawer",
@@ -18,28 +20,7 @@ export default {
   },
   computed: {},
   watch: {
-    "params.puOrg": {
-      handler: function (newProp, oldProp) {
-        if (oldProp) {
-          this.params.priceApplyOrgs = this.params.priceApplyOrgs.filter(
-            (item) => item.org !== oldProp
-          );
-        }
-        if (newProp) {
-          const { puOrg: org, puOrgName: orgName } = this.params;
-          this.params.priceApplyOrgs.push({
-            org,
-            orgName,
-            createByName: undefined,
-            updateByName: undefined,
-          });
-        }
-      },
-    },
-    "params.priceApplyItems": {
-      handler: function () {},
-      deep: true,
-    },
+    "params.puOrg": watchPuOrg(),
   },
   methods: {
     //
@@ -135,16 +116,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
@@ -210,7 +192,6 @@ export default {
             ></file-upload>
           </el-form-item>
         </el-col>
-        <el-divider></el-divider>
         <el-col :span="24">
           <el-form-item label-width="0">
             <el-tabs v-model="tabName">
@@ -312,7 +293,6 @@ export default {
                   <el-table-column fixed="right" label="操作" width="100">
                     <template slot="header" slot-scope="scope">
                       <el-button
-                        v-if="params.puOrgName && params.supplierName"
                         circle
                         icon="el-icon-plus"
                         :size="size"

+ 0 - 394
src/views/purchase/apply/edit/column.js

@@ -1,394 +0,0 @@
-export const FormColumns = [
-  {
-    key: "priceName",
-    title: "价格名称",
-    inputType: "Input",
-    value: "价格申报单",
-  },
-  {
-    key: "supplierName",
-    title: "供应商",
-    inputType: "PopoverSelect",
-    referName: "SUPPLIER_PARAM",
-    valueKey: "name",
-    dataMapping: {
-      supplier: "code",
-      supplierName: "name",
-    },
-    require: true,
-  },
-  {
-    key: "supplier",
-    title: "供应商编码",
-    inputType: "Input",
-    disabled: true,
-    readonly: true,
-  },
-  {
-    key: "puOrgName",
-    title: "采购组织",
-    inputType: "PopoverSelect",
-    referName: "ORG_PARAM",
-    valueKey: "name",
-    dataMapping: {
-      puOrg: "id",
-      puOrgName: "name",
-    },
-    require: true,
-  },
-  {
-    key: "puOrg",
-    title: "采购组织编码",
-    inputType: "Input",
-    disabled: true,
-    readonly: true,
-  },
-  {
-    key: "currencyName",
-    title: "币种",
-    inputType: "PopoverSelect",
-    referName: "CURRENCY_PARAM",
-    dataMapping: {
-      currency: "code",
-      currencyName: "name",
-    },
-    require: true,
-  },
-  {
-    key: "currency",
-    title: "币种编码",
-    inputType: "Input",
-    disabled: true,
-    readonly: true,
-  },
-  {
-    key: "explainStr",
-    title: "价格合理性说明",
-    inputType: "Input",
-    require: true,
-  },
-  {
-    key: "buyerName",
-    title: "采购员",
-    inputType: "PopoverSelect",
-    referName: "CONTACTS_PARAM",
-    dataMapping: {
-      buyer: "code",
-      buyerName: "name",
-    },
-    require: true,
-  },
-  {
-    key: "buyer",
-    title: "采购员编码",
-    inputType: "Input",
-    disabled: true,
-    readonly: true,
-  },
-  {
-    key: "puDeptName",
-    title: "采购部门",
-    inputType: "PopoverSelect",
-    referName: "DEPT_PARAM",
-    dataMapping: {
-      puDept: "code",
-      puDeptName: "name",
-    },
-    require: true,
-  },
-  {
-    key: "puDept",
-    title: "采购部门编码",
-    inputType: "Input",
-    disabled: true,
-    readonly: true,
-  },
-  {
-    key: "createByName",
-    title: "创建人",
-    inputType: "Input",
-    disabled: true,
-    readonly: true,
-  },
-  {
-    key: "source",
-    title: "来源单据号",
-    inputType: "Input",
-    disabled: true,
-    readonly: true,
-  },
-  {
-    key: "id",
-    title: "来源单据id",
-    inputType: "Input",
-    disabled: true,
-    readonly: true,
-  },
-  {
-    key: "isEffective",
-    title: "是否已推价格",
-    inputType: "Select",
-    referName: "is_effective",
-  },
-  {
-    key: "effectiveDate",
-    title: "生效日期",
-    inputType: "Input",
-    disabled: true,
-    readonly: true,
-  },
-  {
-    key: "file",
-    title: "附件",
-    inputType: "Upload",
-    span: 24,
-    disabled: true,
-    readonly: true,
-    value: [],
-  },
-  {
-    key: "sourceType",
-    title: "来源单据类型",
-    inputType: "Input",
-    disabled: true,
-    readonly: true,
-  },
-  {
-    key: "status",
-    title: "单据状态",
-    inputType: "Select",
-    referName: "sys_status",
-    disabled: true,
-    readonly: true,
-    value: "0",
-  },
-];
-
-export const TabColumns = [
-  {
-    title: "物料信息表",
-    key: "priceApplyItems",
-    tableColumns: [
-      {
-        title: "物料名称",
-        key: "materialName",
-        inputType: "PopoverSelect",
-        width: 300,
-        referName: "MATERIAL_PARAM",
-        dataMapping: {
-          model: "model",
-          material: "id",
-          materialCode: "code",
-          materialName: "name",
-          unitName: "unitIdName",
-          puUnitName: "unitIdName",
-          specification: "specification",
-          manufacturer: "manufacturerId",
-          manufacturerName: "manufacturerIdName",
-        },
-        require: true,
-      },
-      { title: "物料编码", key: "materialCode" },
-      {
-        title: "生产厂家",
-        key: "manufacturerName",
-      },
-      {
-        title: "生产厂家编码",
-        key: "manufacturer",
-      },
-      {
-        title: "规格",
-        key: "specification",
-      },
-      {
-        title: "型号",
-        key: "model",
-      },
-      {
-        title: "单位名称",
-        key: "unitName",
-        inputType: "PopoverSelect",
-        width: 300,
-        referName: "UNIT_PARAM",
-        dataMapping: {
-          unit: "code",
-          unitName: "name",
-        },
-      },
-      {
-        title: "单位",
-        key: "unit",
-      },
-      {
-        title: "采购单位名称",
-        key: "puUnitName",
-        inputType: "PopoverSelect",
-        width: 300,
-        referName: "UNIT_PARAM",
-        dataMapping: {
-          puUnit: "code",
-          puUnitName: "name",
-        },
-      },
-      {
-        title: "采购单位",
-        key: "puUnit",
-      },
-      {
-        title: "采购换算率",
-        key: "conversionRate",
-        inputType: "InputNumber",
-        width: 300,
-        require: true,
-      },
-      {
-        title: "税率%",
-        key: "tax",
-        inputType: "PopoverSelect",
-        referName: "TAX_RATE_PARAM",
-        dataMapping: {
-          tax: "ntaxrate",
-        },
-        width: 300,
-        require: true,
-      },
-      {
-        title: "含税单价",
-        key: "taxPrice",
-        inputType: "InputNumber",
-        width: 300,
-        require: true,
-      },
-      {
-        title: "无税单价",
-        key: "price",
-        inputType: "ComputedInput",
-        width: 300,
-        computed: (prop) => {
-          const { tax, taxPrice } = prop;
-          const newTax = Number(tax) / 100;
-          const price = (taxPrice / (1 + newTax)).toFixed(8);
-          return price === "NaN" ? null : price;
-        },
-        require: true,
-      },
-      {
-        key: "currencyName",
-        title: "币种名称",
-        inputType: "PopoverSelect",
-        referName: "CURRENCY_PARAM",
-        dataMapping: {
-          currency: "code",
-          currencyName: "name",
-        },
-      },
-      {
-        title: "币种",
-        key: "currency",
-      },
-      {
-        key: "periodBegin",
-        title: "价格有效期(起)",
-        inputType: "DatePicker",
-        valueFormat: "yyyy-MM-dd",
-        value: new Date(),
-        require: true,
-      },
-      {
-        key: "periodEnd",
-        title: "价格有效期(止)",
-        inputType: "DatePicker",
-        valueFormat: "yyyy-MM-dd",
-        pickerOptions: {
-          disabledDate(time) {
-            return time.getTime() < Date.now() + 3600 * 1000 * 24 * 365;
-          },
-        },
-        require: true,
-      },
-      {
-        title: "客户名称",
-        key: "customerName",
-        inputType: "PopoverSelect",
-        width: 300,
-        referName: "CUSTOMER_PARAM",
-        dataMapping: {
-          customer: "code",
-          customerName: "name",
-        },
-      },
-      {
-        title: "客户",
-        key: "customer",
-      },
-      {
-        title: "最近价格",
-        key: "recentlyPrice",
-      },
-      {
-        title: "首次报批",
-        key: "isApprovalFirst",
-        width: 300,
-        inputType: "Select",
-        referName: "is_effective",
-      },
-      {
-        title: "价格调整",
-        key: "isPriceAdjustment",
-        width: 300,
-        inputType: "Select",
-        referName: "is_effective",
-      },
-      {
-        key: "priceType",
-        title: "价格类型",
-        inputType: "Select",
-        referName: "sys_price_type",
-      },
-      {
-        title: "配送价",
-        key: "isDistributionPrice",
-        width: 300,
-        inputType: "Select",
-        referName: "is_effective",
-        require: true,
-      },
-      {
-        title: "创建人名称",
-        key: "createByName",
-      },
-      {
-        title: "更新人名称",
-        key: "updateByName",
-      },
-    ],
-  },
-  {
-    title: "合同执行组织范围",
-    key: "priceApplyOrgs",
-    tableColumns: [
-      {
-        title: "组织名称",
-        key: "orgName",
-        inputType: "PopoverSelect",
-        referName: "ORG_PARAM",
-        dataMapping: {
-          org: "code",
-          orgName: "name",
-        },
-      },
-      { title: "组织编码", key: "org" },
-      {
-        title: "创建人名称",
-        key: "createByName",
-      },
-      {
-        title: "更新人名称",
-        key: "updateByName",
-      },
-    ],
-  },
-];
-
-export default { FormColumns, TabColumns };

+ 6 - 17
src/views/purchase/apply/edit/index.vue

@@ -1,10 +1,12 @@
 <script>
-import Column from "./column";
+import Column from "../add/column";
 import useData from "../hooks/data";
 import useDicts from "../hooks/dicts";
+import useWatch from "../hooks/watch";
 import useMethods from "../hooks/function";
 import useTable from "../hooks/table-function";
 import { SAVE } from "@/api/business/purchase/apply";
+const { watchPuOrg, watchPriceApplyOrgs, watchPriceApplyItems } = useWatch();
 
 export default {
   name: "EditDrawer",
@@ -22,22 +24,9 @@ export default {
   },
   computed: {},
   watch: {
-    "params.priceApplyOrgs": {
-      handler: function (newValue) {
-        this.newParams.priceApplyOrgs = newValue.filter(
-          (item) => item.delFlag === "0"
-        );
-      },
-      deep: true,
-    },
-    "params.priceApplyItems": {
-      handler: function (newValue) {
-        this.newParams.priceApplyItems = newValue.filter(
-          (item) => item.delFlag === "0"
-        );
-      },
-      deep: true,
-    },
+    "params.puOrg": watchPuOrg(),
+    "params.priceApplyOrgs": watchPriceApplyOrgs(),
+    "params.priceApplyItems": watchPriceApplyItems(),
   },
   methods: {
     //

+ 7 - 0
src/views/purchase/apply/hooks/table-function.js

@@ -3,6 +3,13 @@ import { initParams } from "@/utils/init";
 export default function useTable() {
   // 新 增
   const add = ({ _this, prop }) => {
+    const { puOrgName, supplierName } = _this.params;
+    if (!supplierName) {
+      return _this.$notify.info("请选择供应商");
+    }
+    if (!puOrgName) {
+      return _this.$notify.info("请选择采购组织");
+    }
     const { tableColumns } = _this.tabColumns.find(
       (element) => element.key === prop
     );

+ 37 - 0
src/views/purchase/apply/hooks/watch.js

@@ -0,0 +1,37 @@
+export default function useWatch() {
+  const watchPuOrg = () => ({
+    handler: function (newProp, oldProp) {
+      if (oldProp) {
+        this.params.priceApplyOrgs = this.params.priceApplyOrgs.filter(
+          (item) => item.org !== oldProp
+        );
+      }
+      if (newProp) {
+        const { puOrg: org, puOrgName: orgName } = this.params;
+        this.params.priceApplyOrgs.push({
+          org,
+          orgName,
+          createByName: undefined,
+          updateByName: undefined,
+        });
+      }
+    },
+  });
+  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 { watchPuOrg, watchPriceApplyOrgs, watchPriceApplyItems };
+}

+ 7 - 6
src/views/purchase/apply/see/index.vue

@@ -75,12 +75,6 @@ export default {
     <template slot="title">
       <span>{{ title }}</span>
       <span>
-        <el-button
-          :size="size"
-          circle
-          icon="el-icon-close"
-          @click="hide"
-        ></el-button>
         <el-tooltip
           class="item"
           effect="dark"
@@ -135,6 +129,13 @@ export default {
             @click="useSubmit([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">