Bläddra i källkod

Merge branch 'purchaseDev' of http://172.16.100.139/new-business/drp-web into purchaseDev

002390 2 år sedan
förälder
incheckning
e7f259ea42

+ 40 - 0
src/components/computed-input-v2/index.vue

@@ -0,0 +1,40 @@
+<template>
+  <span v-on="$listeners">{{ innerValue || "- -" }}</span>
+</template>
+
+<script>
+export default {
+  name: "ComputedInputV2",
+  props: {
+    // v-model
+    value: {
+      type: [Number, String],
+      require: true,
+    },
+    // formatter
+    formatter: {
+      type: Function,
+      default: () => {},
+      require: true,
+    },
+  },
+  data() {
+    return {};
+  },
+  computed: {
+    innerValue: {
+      get() {
+        return this.formatter(this.value);
+      },
+    },
+  },
+  watch: {},
+  methods: {},
+  created() {
+    console.log("formatter", this, (this.$parent.row.customerName = "D"));
+  },
+  mounted() {},
+  destroyed() {},
+};
+</script>
+<style scoped></style>

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

@@ -35,7 +35,6 @@ export default {
     newSource: {
       handler: function (newProp) {
         const { formatter } = this.$props;
-        console.log("formatter", formatter);
         this.$emit("input", formatter(newProp));
       },
       deep: true,
@@ -43,7 +42,13 @@ export default {
     },
   },
   methods: {},
-  created() {},
+  created() {
+    console.log(
+      "formatter",
+      this.$parent,
+      (this.$parent.row.customerName = "D")
+    );
+  },
   mounted() {},
   destroyed() {},
 };

+ 6 - 0
src/config/index.js

@@ -0,0 +1,6 @@
+export default {
+  // 尺寸
+  size: "mini",
+  // 保留小数位
+  precision: 6,
+};

+ 1 - 1
src/views/purchase/PurchaseDemandList/add.vue

@@ -110,7 +110,7 @@
          </el-col>
 
          <el-col :span="1.5">
-            <el-form-item label="业务类型">
+            <el-form-item label="业务类型" prop="billType" :rules="{ required: true, message: '请选择业务类型', trigger: 'blur' }">
               <el-select clearable v-model="basicForm.billType" @change="changeBillType" :disabled="sonDisable" size="mini" style="width: 200px">
                 <el-option v-for=" dict in dict.type.sys_business" :key="dict.value" :label="dict.label" :value="dict.value">
                 </el-option>

+ 0 - 1
src/views/purchase/apply/add/column.js

@@ -158,7 +158,6 @@ export const TabColumns = [
         attr: {
           component: "el-input-number",
           precision: 6,
-          formatter: (prop) => (prop ? (prop * 1).toFixed(6) : null),
         },
       },
       {

+ 1 - 1
src/views/purchase/catalogue/hooks/data.js

@@ -1,4 +1,4 @@
-import { initRules, initParams } from "@/utils/init";
+import { initRules, initParams } from "@/utils/init/index.js";
 
 export default function useData(prop) {
   const { FormColumns } = prop;

+ 1 - 1
src/views/purchase/catalogue/hooks/dicts.js

@@ -1,4 +1,4 @@
-import { initDicts } from "@/utils/init";
+import { initDicts } from "@/utils/init/index.js";
 
 export default function useDicts(prop) {
   const { FormColumns = [], TabColumns = [] } = prop;

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

@@ -1,7 +1,7 @@
 <script>
 import { FormColumns, SearchColumns } from "./column";
 import { LIST } from "@/api/business/purchase/catalogue";
-import { initPage, initDicts, initParams } from "@/utils/init";
+import { initPage, initDicts, initParams } from "@/utils/init/index.js";
 export default {
   name: "PuchaseCatalogue",
   dicts: [...initDicts(SearchColumns), ...initDicts(FormColumns)],

+ 1 - 1
src/views/purchase/contract/hooks/data.js

@@ -1,4 +1,4 @@
-import { initRules, initParams } from "@/utils/init";
+import { initRules, initParams } from "@/utils/init/index.js";
 
 export default function useData(prop) {
   const { FormColumns, TabColumns } = prop;

+ 1 - 1
src/views/purchase/contract/hooks/dicts.js

@@ -1,4 +1,4 @@
-import { initDicts } from "@/utils/init";
+import { initDicts } from "@/utils/init/index.js";
 
 export default function useDicts(prop) {
   const { FormColumns = [], TabColumns = [] } = prop;

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

@@ -1,7 +1,7 @@
 <script>
 import { FormColumns, SearchColumns } from "./column";
 import { LIST } from "@/api/business/purchase/contract";
-import { initPage, initDicts, initParams } from "@/utils/init";
+import { initPage, initDicts, initParams } from "@/utils/init/index.js";
 export default {
   name: "PuchaseContract",
   dicts: [...initDicts(SearchColumns), ...initDicts(FormColumns)],

+ 11 - 11
src/views/purchase/task/column.js

@@ -45,7 +45,7 @@ export const SearchColumns = [
       title: "物料分类",
     },
     attr: {
-      component: "dr-popover-tree-select",
+      is: "dr-popover-tree-select",
       referName: "MATERIALCLASSIFY_PARAM",
       multiple: true,
       valueKey: "id",
@@ -57,7 +57,7 @@ export const SearchColumns = [
       title: "物料编码",
     },
     attr: {
-      component: "el-popover-multiple-select-v2",
+      is: "el-popover-multiple-select-v2",
       valueKey: "code",
       referName: "MATERIAL_PARAM",
     },
@@ -68,7 +68,7 @@ export const SearchColumns = [
       title: "物料描述",
     },
     attr: {
-      component: "el-input",
+      is: "el-input",
     },
   },
   {
@@ -77,7 +77,7 @@ export const SearchColumns = [
       title: "单据号",
     },
     attr: {
-      component: "el-input",
+      is: "el-input",
     },
   },
   {
@@ -86,7 +86,7 @@ export const SearchColumns = [
       title: "采购组织",
     },
     attr: {
-      component: "el-popover-multiple-select-v2",
+      is: "el-popover-multiple-select-v2",
       referName: "ORG_PARAM",
       valueKey: "id",
     },
@@ -97,7 +97,7 @@ export const SearchColumns = [
       title: "状态",
     },
     attr: {
-      component: "el-select",
+      is: "el-select",
       dictName: "purchase_task_status",
       clearable: true,
     },
@@ -108,7 +108,7 @@ export const SearchColumns = [
       title: "创建时间",
     },
     attr: {
-      component: "el-date-picker",
+      is: "el-date-picker",
       type: "daterange",
       unlinkPanels: true,
       rangeSeparator: "至",
@@ -125,7 +125,7 @@ export const SearchColumns = [
       title: "采购员",
     },
     attr: {
-      component: "el-popover-multiple-select-v2",
+      is: "el-popover-multiple-select-v2",
       referName: "CONTACTS_PARAM",
       valueKey: "code",
     },
@@ -136,7 +136,7 @@ export const SearchColumns = [
       title: "生产厂家",
     },
     attr: {
-      component: "el-input",
+      is: "el-input",
     },
   },
   {
@@ -145,7 +145,7 @@ export const SearchColumns = [
       title: "收货客户",
     },
     attr: {
-      component: "el-popover-select-v2",
+      is: "el-popover-select-v2",
       referName: "CUSTOMERDEPT_PARAM",
       valueKey: "name",
     },
@@ -157,7 +157,7 @@ export const SearchColumns = [
       span: 12,
     },
     attr: {
-      component: "el-input",
+      is: "el-input",
       placeholder: "请输入来源单据号,多个用,分隔",
     },
   },

+ 85 - 49
src/views/purchase/task/first-direct/column.js

@@ -1,56 +1,92 @@
+import CONFIG from "@/config";
+
 export const TableColumns = [
-  // { key: "supplier", title: "供应商" },
-  { key: "supplierName", title: "供应商" },
-  // { key: "puOrg", title: "采购组织" },
-  { key: "puOrgName", title: "采购组织" },
-  // { key: "customer", title: "客户" },
-  { key: "customerName", title: "客户" },
-  {
-    key: "priceType",
-    title: "价格类型",
-    inputType: "Select",
-    referName: "sys_price_type",
-  },
-  // {
-  //   key: "isDistribution",
-  //   title: "配送价",
-  //   inputType: "Select",
-  //   referName: "sys_yes_no",
-  // },
-  { key: "effectiveDate", title: "价格生效日期" },
-  { key: "endDate", title: "价格失效日期" },
-  {
-    key: "newTax",
-    title: "税率",
-    inputType: "ComputedInput",
-    width: 200,
-    computed: (prop) => {
-      const { tax } = prop;
-      return tax.toFixed(6) + "%";
+  {
+    item: { key: "supplierName", title: "供应商" },
+    attr: {},
+  },
+  {
+    item: { key: "puOrgName", title: "采购组织" },
+    attr: {},
+  },
+  {
+    item: { key: "customerName", title: "客户" },
+    attr: {},
+  },
+  {
+    item: { key: "priceType", title: "价格类型" },
+    attr: { component: "el-dict-tag", dictName: "sys_price_type" },
+  },
+  {
+    item: { key: "effectiveDate", title: "价格生效日期" },
+    attr: {},
+  },
+  {
+    item: { key: "endDate", title: "价格失效日期" },
+    attr: {},
+  },
+  {
+    item: { key: "tax", title: "税率" },
+    attr: {
+      component: "el-computed-input-v2",
+      formatter: (prop) => {
+        return (prop * 1).toFixed(CONFIG.precision) + "%";
+      },
+    },
+  },
+  {
+    item: { key: "taxFreePrice", title: "无税单价" },
+    attr: {
+      component: "el-computed-input-v2",
+      formatter: (prop) => {
+        return (prop * 1).toFixed(CONFIG.precision);
+      },
+    },
+    listeners: {
+      click: (prop) => {
+        console.log("prop", prop);
+      },
+    },
+  },
+  {
+    item: { key: "taxPrice", title: "主含税单价" },
+    attr: {
+      component: "el-computed-input-v2",
+      formatter: (prop) => {
+        return (prop * 1).toFixed(CONFIG.precision);
+      },
     },
   },
-  { key: "taxFreePrice", title: "无税单价" },
-  { key: "taxPrice", title: "主含税单价" },
-  {
-    key: "purchaseQuantity",
-    title: "本次采购数量",
-    inputType: "InputNumber",
-    width: 300,
-    min: (prop) => 0,
-    max: (prop) => prop.puQty - (prop.executeQty || 0),
-    controlsPosition: "right",
-  },
-  {
-    key: "arrivalDatePlan",
-    title: "计划到货日期",
-    inputType: "DatePicker",
-    valueFormat: "yyyy-MM-dd",
-    width: 300,
-    pickerOptions: {
-      disabledDate(time) {
-        return time.getTime() < Date.now();
+  {
+    item: { key: "purchaseQuantity", title: "本次采购数量" },
+    attr: {
+      component: "el-input-number",
+      min: () => 0,
+      max: (prop) => {
+        const { puQty = 0, executeQty = 0 } = prop;
+        return puQty - executeQty;
+      },
+      controlsPosition: "right",
+    },
+  },
+  {
+    item: { key: "arrivalDatePlan", title: "计划到货日期" },
+    attr: {
+      component: "el-date-picker",
+      valueFormat: "yyyy-MM-dd",
+      pickerOptions: {
+        disabledDate(time) {
+          return time.getTime() < Date.now();
+        },
       },
     },
   },
-  { key: "note", title: "备注", inputType: "Textarea", width: 300 },
+  {
+    item: { key: "note", title: "备注" },
+    attr: {
+      component: "el-input",
+      autosize: true,
+      type: "textarea",
+    },
+  },
 ];

+ 47 - 35
src/views/purchase/task/first-direct/index.vue

@@ -1,11 +1,12 @@
 <script>
 import { TableColumns } from "./column";
-import { initDicts, initColumns } from "@/utils/init";
 import { FIRSTDIRECT, ADD } from "@/api/business/purchase/task";
 export default {
   name: "FirstDirectPurchaseDrawer",
-  dicts: initDicts(TableColumns),
-  components: {},
+  components: {
+    ElDictTag: () => import("@/components/DictTag/index.vue"),
+    ElComputedInputV2: () => import("@/components/computed-input-v2/index.vue"),
+  },
   data() {
     return {
       size: "mini",
@@ -14,11 +15,17 @@ export default {
       column: 3,
       visible: false,
       loading: false,
-      tableColumns: initColumns(TableColumns),
+      tableColumns: TableColumns,
       data: [],
     };
   },
-  computed: {},
+  computed: {
+    $dicts: {
+      get: function () {
+        return this.$parent.$parent.$dicts;
+      },
+    },
+  },
   watch: {},
   methods: {
     //
@@ -36,7 +43,14 @@ export default {
         this.loading = true;
         const { code, data } = await FIRSTDIRECT(prop);
         if (code === 200) {
-          this.data = data;
+          this.data = data.map((item) => ({
+            ...item,
+            orderPriceVos: item.orderPriceVos.map((cItem) => ({
+              ...item,
+              ...cItem,
+            })),
+          }));
+          console.log("this.data", this.data);
           return true;
         } else {
           return false;
@@ -136,56 +150,54 @@ export default {
         <el-table-column
           v-for="(cItem, cIndex) in tableColumns"
           :key="cIndex"
-          :prop="cItem.key"
-          :label="cItem.title"
-          :fixed="cItem.fixed"
-          :width="cItem.width || 200"
+          :prop="cItem.item.key"
+          :label="cItem.item.title"
+          :fixed="cItem.item.fixed"
+          :width="cItem.item.width || 250"
           show-overflow-tooltip
         >
           <template slot-scope="scope">
             <el-input-number
-              v-if="cItem.inputType === 'InputNumber'"
-              v-model="scope.row[cItem.key]"
+              v-if="cItem.item.key === 'el-input-number'"
+              v-model="scope.row[cItem.item.key]"
               :size="size"
-              :min="cItem.min(item)"
-              :max="cItem.max(item)"
-              :placeholder="cItem.placeholder"
-              :controls-position="cItem.controlsPosition"
+              :min="cItem.attr.min(item)"
+              :max="cItem.attr.max(item)"
+              :controls-position="cItem.attr.controlsPosition"
               style="width: 90%"
             ></el-input-number>
             <el-date-picker
-              v-else-if="cItem.inputType === 'DatePicker'"
-              v-model="scope.row[cItem.key]"
+              v-else-if="cItem.attr.component === 'el-date-picker'"
+              v-model="scope.row[cItem.item.key]"
               :size="size"
-              :type="cItem.type"
-              :placeholder="cItem.placeholder"
-              :value-format="cItem.valueFormat"
-              :picker-options="cItem.pickerOptions"
+              :type="cItem.attr.type"
+              :value-format="cItem.attr.valueFormat"
+              :picker-options="cItem.attr.pickerOptions"
               style="width: 90%"
             ></el-date-picker>
             <el-input
-              v-else-if="cItem.inputType === 'Textarea'"
-              v-model="scope.row[cItem.key]"
+              v-else-if="cItem.attr.component === 'el-input'"
+              v-model="scope.row[cItem.item.key]"
               :size="size"
               autosize
               type="textarea"
               style="width: 90%"
             ></el-input>
-            <dr-computed-input
-              v-else-if="cItem.inputType === 'ComputedInput'"
-              v-model="scope.row[cItem.key]"
+            <el-computed-input-v2
+              v-else-if="cItem.attr.component === 'el-computed-input-v2'"
+              v-on="cItem.listeners"
+              v-model="scope.row[cItem.item.key]"
               :source="scope.row"
-              :computed="cItem.computed"
-              :placeholder="cItem.placeholder"
+              :formatter="cItem.attr.formatter"
               style="width: 100%"
-            ></dr-computed-input>
-            <dict-tag
-              v-else-if="cItem.inputType === 'Select'"
+            ></el-computed-input-v2>
+            <el-dict-tag
+              v-else-if="cItem.attr.component === 'el-dict-tag'"
               :size="size"
-              :value="scope.row[cItem.key]"
-              :options="dict.type[cItem.referName]"
+              :value="scope.row[cItem.item.key]"
+              :options="$dicts[cItem.attr.dictName]"
             />
-            <span v-else>{{ scope.row[cItem.key] }}</span>
+            <span v-else>{{ scope.row[cItem.item.key] }}</span>
           </template>
         </el-table-column>
       </el-table>

+ 10 - 38
src/views/purchase/task/index.vue

@@ -1,34 +1,7 @@
 <script>
 import { LIST } from "@/api/business/purchase/task";
 import { TableColumns, SearchColumns } from "./column";
-
-const initParams = (prop, key = "key", value = "value") => {
-  // get params
-  const object1 = Object.fromEntries(
-    prop.map(({ item, attr }) => [item[key], attr[value]])
-  );
-  // get mapping params
-  const object2 = {};
-  prop
-    .filter((item) => item.attr.dataMapping)
-    .map(({ attr: { dataMapping } }) => {
-      for (let key in dataMapping) {
-        object2[key] = null;
-      }
-    });
-  return { ...object1, ...object2 };
-};
-
-// 初始化字典
-const initDicts = (prop) => {
-  return Array.from(
-    new Set(
-      prop
-        .filter((item) => item.attr.dictName)
-        .map((item) => item.attr.dictName)
-    )
-  );
-};
+import { initParams, initDicts } from "@/utils/init.js";
 
 export default {
   name: "PuchaseTask",
@@ -56,14 +29,14 @@ export default {
       page: { pageNum: 1, pageSize: 10, total: 0 },
     };
   },
-  computed: {},
-  watch: {},
-  provide() {
-    return {
-      initParams,
-      $dicts: () => this.dict.type,
-    };
+  computed: {
+    $dicts: {
+      get: function () {
+        return this.dict.type;
+      },
+    },
   },
+  watch: {},
   created() {
     this.params.status = "0";
     this.useQuery(this.params, this.page);
@@ -215,14 +188,13 @@ export default {
               v-bind="column.attr"
               v-model="params[column.item.key]"
               :source.sync="params"
-              :is="column.attr.component"
               @change="useQuery(params, page)"
               @keyup.enter.native="useQuery(params, page)"
               style="width: 100%"
             >
               <template v-if="column.attr.dictName">
                 <el-option
-                  v-for="item in dict.type[column.attr.dictName]"
+                  v-for="item in $dicts[column.attr.dictName]"
                   :key="item.value"
                   :label="item.label"
                   :value="item.value"
@@ -300,7 +272,7 @@ export default {
             v-if="column.attr.dictName"
             :size="size"
             :value="scope.row[column.item.key]"
-            :options="dict.type[column.attr.dictName]"
+            :options="$dicts[column.attr.dictName]"
           />
           <component is="span" v-else>{{
             scope.row[column.item.key]

+ 12 - 7
src/views/purchase/task/see/index.vue

@@ -1,10 +1,9 @@
 <script>
-import { TableColumns as Columns } from "../column";
+import { TableColumns } from "../column";
 import { ITEM } from "@/api/business/purchase/task";
 export default {
   name: "SeeDialog",
   components: {},
-  inject: ["$dicts", "initParams"],
   data() {
     return {
       size: "mini",
@@ -13,11 +12,17 @@ export default {
       column: 3,
       visible: false,
       loading: false,
-      columns: Columns,
+      columns: TableColumns,
       params: {},
     };
   },
-  computed: {},
+  computed: {
+    $dicts: {
+      get: function () {
+        return this.$parent.$parent.$dicts;
+      },
+    },
+  },
   watch: {},
   methods: {
     // 查 询
@@ -39,8 +44,8 @@ export default {
       }
     },
     //
-    open(prop) {
-      this.visible = this.fetchItem(prop);
+    async open(prop) {
+      this.visible = await this.fetchItem(prop);
     },
   },
   created() {},
@@ -78,7 +83,7 @@ export default {
           v-if="column.attr.dictName"
           :size="size"
           :value="params[column.item.key]"
-          :options="$dicts()[column.attr.dictName]"
+          :options="$dicts[column.attr.dictName]"
         />
         <span v-else>{{ params[column.item.key] }}</span>
       </el-descriptions-item>