002201 1 vuosi sitten
vanhempi
commit
894e58f38b

+ 3 - 0
src/components/popover-select-v2/index.vue

@@ -288,4 +288,7 @@ export default {
 .popover-select-v2 .el-autocomplete .el-icon-search {
   cursor: pointer;
 }
+::v-deep .el-table--mini .el-table__cell {
+  height: 50px;
+}
 </style>

+ 2 - 9
src/components/popover-select-v2/multiple.vue

@@ -299,14 +299,7 @@ export default {
   transform: translateY(-50%);
   width: calc(100% - 40px);
 }
-::v-deep .popover-select-v2 .popover-select-v2_tags .el-scrollbar__view {
-  display: flex;
-  align-items: center;
-  padding-bottom: 10px;
+::v-deep .el-table--mini .el-table__cell {
+  height: 50px;
 }
-/* .popover-select-v2 .popover-select-v2_tags::-webkit-scrollbar {
-  width: 10px;
-  height: 10px;
-  cursor: pointer;
-} */
 </style>

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

@@ -205,7 +205,7 @@ export default {
     >
       <el-row :gutter="20" style="display: flex; flex-wrap: wrap">
         <el-col
-          v-for="(column, index) in TableColumns"
+          v-for="(column, index) in tableColumns"
           :key="index"
           :span="column.span || 8"
         >

+ 0 - 110
src/views/purchase/apply/column copy.js

@@ -1,110 +0,0 @@
-export const TableColumns = [
-  { item: { key: "priceName", title: "价格名称" }, attr: {} },
-  { item: { key: "priceCode", title: "价格编码" }, attr: {} },
-  {
-    item: { key: "status", title: "状态" },
-    attr: { dictName: "sys_status" },
-  },
-  { item: { key: "supplierName", title: "供应商" }, attr: {} },
-  { item: { key: "currencyName", title: "币种" }, attr: {} },
-  { item: { key: "explainStr", title: "价格合理性说明" }, attr: {} },
-  { item: { key: "buyerName", title: "采购员" }, attr: {} },
-  { item: { key: "puDeptName", title: "采购部门" }, attr: {} },
-  {
-    item: { key: "file", title: "附件" },
-    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: "sourceType", title: "来源单据类型" }, attr: {} },
-];
-console.log(
-  JSON.stringify(
-    TableColumns.map((item) => ({
-      item: { key: item.key, title: item.title },
-      attr: {
-        component: item.inputType,
-        dictName: item.referName,
-      },
-    }))
-  )
-);
-export const SearchColumns = [
-  {
-    item: { key: "supplierName", title: "供应商" },
-    attr: {
-      component: "el-popover-select-v2",
-      referName: "SUPPLIER_PARAM",
-      dataMapping: { supplier: "code", supplierName: "name" },
-    },
-  },
-  {
-    item: { key: "puOrgName", title: "采购组织" },
-    attr: {
-      component: "el-popover-select-v2",
-      referName: "ORG_PARAM",
-      dataMapping: { puOrg: "code", puOrgName: "name" },
-    },
-  },
-  {
-    item: { key: "buyerName", title: "采购员" },
-    attr: {
-      component: "el-popover-select-v2",
-      referName: "CONTACTS_PARAM",
-      dataMapping: { buyer: "code", buyerName: "name" },
-    },
-  },
-  {
-    item: { key: "currencyName", title: "币种" },
-    attr: {
-      component: "el-popover-select-v2",
-      referName: "CURRENCY_PARAM",
-      dataMapping: { currency: "code", currencyName: "name" },
-    },
-  },
-  {
-    item: { key: "puDeptName", title: "采购部门" },
-    attr: {
-      component: "el-popover-select-v2",
-      referName: "DEPT_PARAM",
-      dataMapping: { puDept: "code", puDeptName: "name" },
-    },
-  },
-  {
-    item: { key: "isEffective", title: "是否推价" },
-    attr: {
-      component: "Select",
-      dictName: "is_effective",
-      clearable: true,
-    },
-  },
-  {
-    item: { key: "status", title: "状态" },
-    attr: {
-      component: "Select",
-      dictName: "sys_status",
-      clearable: true,
-    },
-  },
-];
-
-console.log(
-  JSON.stringify(
-    SearchColumns.map((item) => ({
-      item: { key: item.key, title: item.title },
-      attr: {
-        component: item.inputType,
-        dictName: item.referName,
-        referName: item.referName,
-        clearable: item.clearable,
-        dataMapping: item.dataMapping,
-      },
-    }))
-  )
-);

+ 87 - 110
src/views/purchase/apply/column.js

@@ -1,138 +1,115 @@
-export const FormColumns = [
+export const TableColumns = [
+  { item: { key: "priceName", title: "价格名称" }, attr: {} },
+  { item: { key: "priceCode", title: "价格编码" }, attr: {} },
   {
-    key: "priceName",
-    title: "价格名称",
+    item: { key: "status", title: "状态" },
+    attr: { dictName: "sys_status" },
   },
+  { item: { key: "supplierName", title: "供应商" }, attr: {} },
+  { item: { key: "currencyName", title: "币种" }, attr: {} },
+  { item: { key: "explainStr", title: "价格合理性说明" }, attr: {} },
+  { item: { key: "buyerName", title: "采购员" }, attr: {} },
+  { item: { key: "puDeptName", title: "采购部门" }, attr: {} },
   {
-    key: "priceCode",
-    title: "价格编码",
+    item: { key: "file", title: "附件" },
+    attr: { component: "dr-file-preview" },
   },
+  { item: { key: "createByName", title: "创建人" }, attr: {} },
+  { item: { key: "source", title: "来源单据号" }, attr: {} },
+  { item: { key: "id", title: "来源单据id" }, attr: {} },
   {
-    key: "status",
-    title: "状态",
-    inputType: "Select",
-    referName: "sys_status",
-  },
-  {
-    key: "supplierName",
-    title: "供应商",
-  },
-  // {
-  //   key: "puOrgName",
-  //   title: "采购组织",
-  // },
-  {
-    key: "currencyName",
-    title: "币种",
-  },
-  {
-    key: "explainStr",
-    title: "价格合理性说明",
-  },
-  {
-    key: "buyerName",
-    title: "采购员",
-  },
-  {
-    key: "puDeptName",
-    title: "采购部门",
-  },
-  {
-    key: "file",
-    title: "附件",
-    inputType: "Upload",
-  },
-  {
-    key: "createByName",
-    title: "创建人",
-  },
-  {
-    key: "source",
-    title: "来源单据号",
-  },
-  {
-    key: "id",
-    title: "来源单据id",
-  },
-  {
-    key: "isEffective",
-    title: "是否已推价格",
-    inputType: "Select",
-    referName: "is_effective",
-  },
-  {
-    key: "effectiveDate",
-    title: "生效日期",
-  },
-  {
-    key: "sourceType",
-    title: "来源单据类型",
+    item: { key: "isEffective", title: "是否已推价格" },
+    attr: { dictName: "is_effective" },
   },
+  { item: { key: "effectiveDate", title: "生效日期" }, attr: {} },
+  { item: { key: "sourceType", title: "来源单据类型" }, attr: {} },
 ];
-
+console.log(
+  JSON.stringify(
+    TableColumns.map((item) => ({
+      item: { key: item.key, title: item.title },
+      attr: {
+        component: item.inputType,
+        dictName: item.referName,
+      },
+    }))
+  )
+);
 export const SearchColumns = [
   {
-    key: "supplierName",
-    title: "供应商",
-    inputType: "PopoverSelect",
-    referName: "SUPPLIER_PARAM",
-    dataMapping: {
-      supplier: "code",
-      supplierName: "name",
+    item: { key: "supplierName", title: "供应商" },
+    attr: {
+      component: "el-popover-select-v2",
+      referName: "SUPPLIER_PARAM",
+      valueKey: "name",
+      dataMapping: { supplier: "id", supplierName: "name" },
     },
   },
   {
-    key: "puOrgName",
-    title: "采购组织",
-    inputType: "PopoverSelect",
-    referName: "ORG_PARAM",
-    dataMapping: {
-      puOrg: "code",
-      puOrgName: "name",
+    item: { key: "puOrgName", title: "采购组织" },
+    attr: {
+      component: "el-popover-select-v2",
+      referName: "ORG_PARAM",
+      valueKey: "name",
+      dataMapping: { puOrg: "id", puOrgName: "name" },
     },
   },
   {
-    key: "buyerName",
-    title: "采购员",
-    inputType: "PopoverSelect",
-    referName: "CONTACTS_PARAM",
-    dataMapping: {
-      buyer: "code",
-      buyerName: "name",
+    item: { key: "buyerName", title: "采购员" },
+    attr: {
+      component: "el-popover-select-v2",
+      referName: "CONTACTS_PARAM",
+      valueKey: "name",
+      dataMapping: { buyer: "id", buyerName: "name" },
     },
   },
   {
-    key: "currencyName",
-    title: "币种",
-    inputType: "PopoverSelect",
-    referName: "CURRENCY_PARAM",
-    dataMapping: {
-      currency: "code",
-      currencyName: "name",
+    item: { key: "currencyName", title: "币种" },
+    attr: {
+      component: "el-popover-select-v2",
+      referName: "CURRENCY_PARAM",
+      valueKey: "name",
+      dataMapping: { currency: "id", currencyName: "name" },
     },
   },
   {
-    key: "puDeptName",
-    title: "采购部门",
-    inputType: "PopoverSelect",
-    referName: "DEPT_PARAM",
-    dataMapping: {
-      puDept: "code",
-      puDeptName: "name",
+    item: { key: "puDeptName", title: "采购部门" },
+    attr: {
+      component: "el-popover-select-v2",
+      referName: "DEPT_PARAM",
+      valueKey: "name",
+      dataMapping: { puDept: "id", puDeptName: "name" },
     },
   },
   {
-    key: "isEffective",
-    title: "是否推价",
-    inputType: "Select",
-    referName: "is_effective",
-    clearable: true,
+    item: { key: "isEffective", title: "是否推价" },
+    attr: {
+      component: "el-select",
+      dictName: "is_effective",
+      clearable: true,
+    },
   },
   {
-    key: "status",
-    title: "状态",
-    inputType: "Select",
-    referName: "sys_status",
-    clearable: true,
+    item: { key: "status", title: "状态" },
+    attr: {
+      component: "el-select",
+      dictName: "sys_status",
+      clearable: true,
+    },
   },
 ];
+
+console.log(
+  JSON.stringify(
+    SearchColumns.map((item) => ({
+      item: { key: item.key, title: item.title },
+      attr: {
+        component: item.inputType,
+        dictName: item.referName,
+        referName: item.referName,
+        clearable: item.clearable,
+        dataMapping: item.dataMapping,
+      },
+    }))
+  )
+);

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

@@ -192,7 +192,7 @@ export default {
     >
       <el-row :gutter="20" style="display: flex; flex-wrap: wrap">
         <el-col
-          v-for="(column, index) in TableColumns"
+          v-for="(column, index) in tableColumns"
           :key="index"
           :span="column.span || 8"
         >

+ 2 - 2
src/views/purchase/apply/hooks/data.js

@@ -6,7 +6,7 @@ export default function useData(prop) {
   const width = "100%";
   const visible = false;
   const loading = false;
-  const TableColumns = TableColumns;
+  const tableColumns = TableColumns;
   const rules = initRules(TableColumns);
   const params = {
     priceApplyOrgs: [],
@@ -25,7 +25,7 @@ export default function useData(prop) {
     width,
     visible,
     loading,
-    TableColumns,
+    tableColumns,
     rules,
     params,
     tabColumns,

+ 106 - 60
src/views/purchase/apply/index.vue

@@ -1,16 +1,44 @@
 <script>
 import { LIST } from "@/api/business/purchase/apply";
-import { FormColumns, SearchColumns } from "./column";
-import { initPage, initDicts, initParams } from "@/utils/init";
+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)
+    )
+  );
+};
+
 export default {
   name: "PuchaseApply",
-  dicts: [...initDicts(SearchColumns), ...initDicts(FormColumns)],
+  dicts: [...initDicts([...TableColumns, ...SearchColumns])],
   components: {
     AddModel: () => import("./add/index.vue"),
     SeeModel: () => import("./see/index.vue"),
     EditModel: () => import("./edit/index.vue"),
     SubmitModel: () => import("./submit/index.vue"),
     DeleteModel: () => import("./delete/index.vue"),
+    ElPopoverSelectV2: () => import("@/components/popover-select-v2/index.vue"),
   },
   data() {
     return {
@@ -20,7 +48,7 @@ export default {
       params: initParams(SearchColumns),
       tableData: [],
       selectData: [],
-      tableColumns: FormColumns,
+      tableColumns: TableColumns,
       page: { pageNum: 1, pageSize: 10, total: 0 },
     };
   },
@@ -29,6 +57,12 @@ export default {
     this.params.status = "0";
     this.useQuery(this.params, this.page);
   },
+  provide() {
+    return {
+      initParams,
+      $dicts: () => this.dict.type,
+    };
+  },
   methods: {
     //
     setSelectable(row) {
@@ -74,7 +108,8 @@ export default {
     },
     // 重 置
     useReset() {
-      this.page = initPage();
+      this.page.pageNum = 1;
+      this.page.pageSize = 10;
       this.params = initParams(SearchColumns);
       this.useQuery(this.params, this.page);
     },
@@ -153,16 +188,7 @@ export default {
 </script>
 
 <template>
-  <el-card
-    v-loading="loading"
-    style="
-      width: calc(100% - 20px);
-      height: 100%;
-      margin: 10px;
-      padding: 0 20px 20px 0;
-    "
-    :body-style="{ padding: 0 }"
-  >
+  <el-card v-loading="loading" :body-style="{ padding: 0 }">
     <see-model ref="SeeModel"></see-model>
     <add-model ref="AddModel" @success="useReset"></add-model>
     <edit-model ref="EditModel" @success="useQuery(params, page)"></edit-model>
@@ -179,56 +205,48 @@ export default {
       :model="params"
       label-width="auto"
       label-position="right"
-      style="padding: 20px 20px 0"
+      @submit.native.prevent
     >
-      <el-row :gutter="20" style="display: flex; flex-wrap: wrap">
+      <el-row :gutter="20">
         <el-col
           v-for="column in searchColumns"
-          :key="column.title"
-          :span="column.span || 6"
+          :key="column.item.title"
+          :span="column.item.span || 6"
         >
-          <el-form-item :prop="column.key" :label="column.title">
-            <el-input
-              v-if="column.inputType === 'Input'"
-              v-model="params[column.key]"
-              :placeholder="column.placeholder"
-              style="width: 100%"
-              @keyup.enter.native="useQuery(params, page)"
-            ></el-input>
-            <el-select
-              v-if="column.inputType === 'Select'"
-              v-model="params[column.key]"
-              :disabled="column.disabled"
-              :clearable="column.clearable"
-              :placeholder="column.placeholder"
-              style="width: 100%"
+          <el-form-item :prop="column.item.key" :label="column.item.title">
+            <component
+              v-if="column.attr.referName"
+              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)"
+            ></component>
+            <component
+              v-else-if="column.attr.dictName"
+              v-bind="column.attr"
+              v-model="params[column.item.key]"
+              :is="column.attr.component"
+              @change="useQuery(params, page)"
+              style="width: 100%"
             >
               <el-option
-                v-for="item in dict.type[column.referName]"
+                v-for="item in dict.type[column.attr.dictName]"
                 :key="item.value"
                 :label="item.label"
                 :value="item.value"
               >
-              </el-option>
-            </el-select>
-            <dr-popover-select
-              v-if="column.inputType === 'PopoverSelect'"
-              v-model="params[column.key]"
-              :size="size"
-              :source.sync="params"
-              :title="column.title"
-              :type="column.referName"
-              :multiple="column.multiple"
-              :readonly="column.readonly"
-              :value-key="column.valueKey"
-              :placeholder="column.placeholder"
-              :data-mapping="column.dataMapping"
+              </el-option
+            ></component>
+            <component
+              v-else
+              v-bind="column.attr"
+              v-model="params[column.item.key]"
+              :is="column.attr.component"
               @change="useQuery(params, page)"
               @keyup.enter.native="useQuery(params, page)"
-            >
-            </dr-popover-select>
+            ></component>
           </el-form-item>
         </el-col>
       </el-row>
@@ -279,23 +297,28 @@ export default {
       <el-table-column
         v-for="(column, index) in tableColumns"
         :key="index"
-        :prop="column.key"
-        :label="column.title"
-        :width="column.width || 200"
+        :prop="column.item.key"
+        :label="column.item.title"
+        :width="column.item.width || 200"
         show-overflow-tooltip
       >
         <template slot-scope="scope">
           <dict-tag
-            v-if="column.inputType === 'Select'"
+            v-if="column.attr.dictName"
             :size="size"
-            :value="scope.row[column.key]"
-            :options="dict.type[column.referName]"
+            :value="scope.row[column.item.key]"
+            :options="dict.type[column.attr.dictName]"
           />
           <dr-file-preview
-            v-else-if="column.inputType === 'Upload' && scope.row[column.key]"
-            v-model="scope.row[column.key]"
+            v-else-if="
+              column.attr.component === 'dr-file-preview' &&
+              scope.row[column.item.key]
+            "
+            v-model="scope.row[column.item.key]"
           ></dr-file-preview>
-          <span v-else>{{ scope.row[column.key] }}</span>
+          <component is="span" v-else>{{
+            scope.row[column.item.key]
+          }}</component>
         </template>
       </el-table-column>
     </el-table>
@@ -307,3 +330,26 @@ export default {
     />
   </el-card>
 </template>
+<style scoped lang="scss">
+.el-card {
+  width: calc(100% - 20px);
+  height: 100%;
+  margin: 10px;
+  padding: 0 0 20px 0;
+  .el-form {
+    padding: 20px 0 0;
+  }
+  .el-row {
+    display: flex;
+    flex-wrap: wrap;
+    padding: 0 20px;
+  }
+  ::v-deep .el-table--mini {
+    width: 100%;
+    margin: 20px 0 0 0;
+    .el-table__cell {
+      height: 50px;
+    }
+  }
+}
+</style>

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

@@ -174,7 +174,7 @@ export default {
     <el-descriptions :size="size" :column="column" border style="margin: 10px">
       <el-descriptions-item
         v-if="params[column.key]"
-        v-for="(column, index) in TableColumns"
+        v-for="(column, index) in tableColumns"
         :key="index"
         :label="column.title"
       >

+ 3 - 2
src/views/purchase/task/index.vue

@@ -20,14 +20,15 @@ const initParams = (prop, key = "key", value = "value") => {
 };
 
 // 初始化字典
-const initDicts = (prop) =>
-  Array.from(
+const initDicts = (prop) => {
+  return Array.from(
     new Set(
       prop
         .filter((item) => item.attr.dictName)
         .map((item) => item.attr.dictName)
     )
   );
+};
 
 export default {
   name: "PuchaseTask",