Bladeren bron

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

黄梓星 1 jaar geleden
bovenliggende
commit
f1d7c65598

+ 3 - 0
src/views/purchase/apply/index.vue

@@ -239,6 +239,7 @@ export default {
       </el-button>
     </el-row>
     <el-table
+      v-if="tableData.length"
       :size="size"
       :data="tableData"
       highlight-current-row
@@ -287,7 +288,9 @@ export default {
         </template>
       </el-table-column>
     </el-table>
+    <el-empty v-else :image-size="200"></el-empty>
     <pagination
+      v-if="tableData.length"
       :total="page.total"
       :page.sync="page.pageNum"
       :limit.sync="page.pageSize"

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

@@ -1,56 +1,88 @@
 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: "dict-tag", dictName: "sys_price_type" },
+  },
+  {
+    item: { key: "effectiveDate", title: "价格生效日期" },
+    attr: {},
+  },
+  {
+    item: { key: "endDate", title: "价格失效日期" },
+    attr: {},
+  },
+  {
+    item: { key: "newTax", title: "税率" },
+    attr: {
+      component: "dr-computed-input",
+      formatter: (prop) => {
+        const { tax } = prop;
+        return (tax * 1).toFixed(6) + "%";
+      },
+    },
+  },
+  {
+    item: { key: "taxFreePrice", title: "无税单价" },
+    attr: {
+      component: "dr-computed-input",
+      formatter: (prop) => {
+        const { taxFreePrice } = prop;
+        return (taxFreePrice * 1).toFixed(6);
+      },
+    },
+  },
+  {
+    item: { key: "taxPrice", title: "主含税单价" },
+    attr: {
+      component: "dr-computed-input",
+      formatter: (prop) => {
+        const { taxPrice } = prop;
+        return (taxPrice * 1).toFixed(6);
+      },
     },
   },
-  { 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) => {
+        return prop.puQty - (prop.executeQty || 0);
       },
+      controlsPosition: "right",
+    },
+  },
+  {
+    item: { key: "arrivalDatePlan", title: "计划到货日期" },
+    attr: {
+      component: "el-date-picker",
+      valueFormat: "yyyy-MM-dd",
+      width: 300,
+      pickerOptions: {
+        disabledDate(time) {
+          return time.getTime() < Date.now();
+        },
+      },
+    },
+  },
+  {
+    item: { key: "note", title: "备注" },
+    attr: {
+      component: "el-input",
+      autosize: true,
+      type: "textarea",
     },
   },
-  { key: "note", title: "备注", inputType: "Textarea", width: 300 },
 ];

+ 39 - 31
src/views/purchase/task/first-direct/index.vue

@@ -1,10 +1,8 @@
 <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: {},
   data() {
     return {
@@ -14,11 +12,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 +40,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 +147,53 @@ 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.attr.component === '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]"
+              v-else-if="cItem.attr.component === 'dr-computed-input'"
+              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'"
+              v-else-if="cItem.attr.component === '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 - 37
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);
@@ -222,7 +195,7 @@ export default {
             >
               <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 +273,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>