quwangxin 2 ani în urmă
părinte
comite
7b0279e2f8

+ 2 - 2
src/api/material/BOM.js

@@ -34,8 +34,8 @@ export async function bomDelete (pid) {
   return Promise.reject(new Error(res.data.message));
 }
 // 详情分页
-export async function detailPage (pid) {
-  const res = await request.get(`/main/bom/detail/page`);
+export async function detailPage (params) {
+  const res = await request.get(`/main/bom/detail/page`, { params });
   if (res.data.code == 0) {
     return res.data.data;
   }

+ 2 - 0
src/enum/dict.js

@@ -27,3 +27,5 @@ export default {
   文件模块: 'file_module',
   分类层级: 'bom_level'
 };
+
+export const numberList = [];

+ 47 - 61
src/store/modules/dict.js

@@ -1,15 +1,16 @@
-import dictEnum from '@/enum/dict';
+import dictEnum, { numberList } from '@/enum/dict';
 import Vue from 'vue';
 import { getByCode } from '@/api/system/dictionary-data';
+
 //非枚举定义
-const otherDictConfig = {
-  //   [dictEnum.物品类型]: {
-  //     request: getSubListByParentId,
-  //     dictCode: 'type',
-  //     dictValue: 'name',
-  //     resKey: '' //为空选 data
-  //   }
-};
+// const otherDictConfig = {
+//   //   [dictEnum.物品类型]: {
+//   //     request: getSubListByParentId,
+//   //     dictCode: 'type',
+//   //     dictValue: 'name',
+//   //     resKey: '' //为空选 data
+//   //   }
+// };
 
 const state = {};
 
@@ -18,73 +19,58 @@ const mutations = {
   ADD_DICT: (state, { code, dict }) => {
     Vue.set(state, code, dict);
   }
-
-  // // 根据字典enumName  和 dictCode 获取字典项
-  // GET_DICT (state, { enumName, dictCode }) {
-  //   return (
-  //     (state[dictEnum[enumName]] || []).find(
-  //       item => item.dictCode === dictCode
-  //     ) || {}
-  //   )
-  // },
-  // // 根据字典enumName  和 dictCode 获取字典 值(名称
-  // GET_DICT_VALUE (state, { enumName, dictCode }) {
-  //   const obj = (state[dictEnum[enumName]] || []).find(
-  //     item => item.dictCode === dictCode
-  //   )
-
-  //   return obj && obj.dictValue
-  // }
 };
 
 const actions = {
   // 根据字典enumName请求字典 已获取的不做重复请求
-  async requestDict({ commit, state }, enumName) {
+  async requestDict ({ commit, state }, enumName) {
     const code = dictEnum[enumName];
 
     if (state[code]?.length) return state[code];
     let res;
-    if (otherDictConfig[dictEnum[enumName]]) {
-      const config = otherDictConfig[dictEnum[enumName]];
-      console.log(config);
-      //非枚举定义
-      res = await config.request();
-      if (res?.code == 0) {
-        let list = config.resKey ? res.data[config.resKey] : res.data;
-        commit('ADD_DICT', {
-          code,
-          dict: list.map((item) => ({
-            ...item,
-            dictCode: item[config.dictCode],
-            dictValue: item[config.dictValue]
-          }))
-        });
-        return res.list;
-      }
-    } else {
-      res = await getByCode(code);
-      if (res?.code == 0) {
-        commit('ADD_DICT', {
-          code,
-          dict: res.data.map((item) => {
-            const arr = Object.entries(item)[0] || [];
+    // if (otherDictConfig[dictEnum[enumName]]) {
+    //   const config = otherDictConfig[dictEnum[enumName]];
+    //   console.log(config);
+    //   //非枚举定义
+    //   res = await config.request();
+    //   if (res?.code == 0) {
+    //     let list = config.resKey ? res.data[config.resKey] : res.data;
+    //     commit('ADD_DICT', {
+    //       code,
+    //       dict: list.map((item) => ({
+    //         ...item,
+    //         dictCode: item[config.dictCode],
+    //         dictValue: item[config.dictValue]
+    //       }))
+    //     });
+    //     return res.list;
+    //   }
+    // } else {
+    res = await getByCode(code);
+    if (res?.code == 0) {
+      const isNumber = numberList.includes(code);
+      commit('ADD_DICT', {
+        code,
+        dict: res.data.map((item) => {
+          const arr = Object.entries(item)[0] || [];
 
-            return {
-              dictCode: arr[0],
-              dictValue: arr[1]
-            };
-          })
-        });
-        return res.data;
-      }
+          return {
+            dictCode: isNumber ? Number(arr[0]) : arr[0],
+            dictValue: arr[1]
+          };
+        })
+      });
+      return res.data;
     }
+    // }
 
     return [];
   },
   // 更新字典
-  async reloadRequestDict({ commit }, enumName) {
+  async reloadRequestDict ({ commit }, enumName) {
     const code = dictEnum[enumName];
     const res = await getByCode(code);
+    const isNumber = numberList.includes(code);
     if (res?.code == 0) {
       commit('ADD_DICT', {
         code,
@@ -92,7 +78,7 @@ const actions = {
           const arr = Object.entries(item);
 
           return {
-            dictCode: arr[0],
+            dictCode: isNumber ? Number(arr[0]) : arr[0],
             dictValue: arr[1]
           };
         })

+ 30 - 25
src/views/material/materialBOM/components/view-dialog.vue

@@ -39,11 +39,15 @@
           </el-form-item>
         </el-col>
         <el-col :span="8">
-          {{ formData.baseCount }}
-          {{ formData.baseCountUnit }}
+          <el-form-item label="计量单位" prop="categoryType">
+            {{ formData.baseCount }}
+            {{ formData.baseCountUnit }}
+          </el-form-item>
         </el-col>
         <el-col :span="8">
-          {{ statusOpt[formData.status] }}
+          <el-form-item label="状态" prop="categoryType">
+            {{ statusOpt[formData.status] }}
+          </el-form-item>
         </el-col>
       </el-row>
     </el-form>
@@ -56,9 +60,9 @@
     >
     </ele-pro-table>
 
-    <div slot="footer" class="footer">
+    <!-- <div slot="footer" class="footer">
       <el-button @click="cancel">返回</el-button>
-    </div>
+    </div> -->
   </ele-modal>
 </template>
 
@@ -94,15 +98,11 @@
           },
           {
             label: '子项编号',
-            prop: 'subCode',
-            slot: 'subCode',
-            action: 'subCode'
+            prop: 'subCode'
           },
           {
             label: '物料名称',
-            prop: 'categoryName',
-            slot: 'categoryName',
-            action: 'categoryName'
+            prop: 'categoryName'
           },
           {
             label: '物料编码',
@@ -114,22 +114,20 @@
           },
           {
             label: '型号',
-            prop: 'modelType'
+            prop: 'model'
           },
           {
             label: '需量(子)',
-            slot: 'count',
-            action: 'count'
+            prop: 'count'
           },
           {
             label: '单位',
-            slot: 'unit',
-            action: 'unit'
-          },
-          {
-            action: 'action',
-            slot: 'action',
-            label: '操作'
+            prop: 'unit'
+            // },
+            // {
+            //   action: 'action',
+            //   slot: 'action',
+            //   label: '操作'
           }
         ]
       };
@@ -138,13 +136,20 @@
       open (row) {
         this.visible = true;
         this._getById(row.id);
-        this.$refs.table.reload({ bomId: row.id });
+        this.$nextTick(() => {
+          this.$refs.table.reload({ where: { bomId: row.id } });
+        });
       },
       async _getById (id) {
-        const res = await getById(id);
-        this.formData = res.data;
+        const data = await getById(id);
+        this.formData = data;
+      },
+      cancel () {
+        this.visible = false;
       },
-      datasource ({ page, limit, where }) {
+      datasource (res) {
+        const { page, limit, where } = res;
+        console.log(res, 222);
         return detailPage({
           pageNum: page,
           size: limit,

+ 13 - 16
src/views/material/materialBOM/index.vue

@@ -13,27 +13,24 @@
         <!-- <template v-slot:toolbar>
           <el-button type="primary" @click="handelEdit('新建')">新建</el-button>
           <el-button type="primary">复制</el-button>
-        </template>
-        <template v-slot:action="{ row }">
-          <el-link type="primary" @click="handelEdit('编辑', row)"
-            >编辑</el-link
-          >
-          <el-link type="primary">删除</el-link> 
         </template>-->
+        <template v-slot:action="{ row }">
+          <el-link type="primary" @click="handelEdit(row)">详情</el-link>
+        </template>
       </ele-pro-table>
     </el-card>
-    <EditDialog ref="editDialogRef" :statusOpt="statusOpt" />
+    <ViewDialog ref="editDialogRef" :statusOpt="statusOpt" />
   </div>
 </template>
 
 <script>
   import BOMSearch from './components/BOM-search.vue';
-  import EditDialog from './components/edit-dialog.vue';
+  import ViewDialog from './components/view-dialog.vue';
   import { getPage } from '@/api/material/BOM';
 
   export default {
     name: 'SystemDictionary',
-    components: { BOMSearch, EditDialog },
+    components: { BOMSearch, ViewDialog },
     data () {
       return {
         // 表格列配置
@@ -82,12 +79,12 @@
             prop: 'createTime',
             label: '创建日期',
             showOverflowTooltip: true
+          },
+          {
+            action: 'action',
+            slot: 'action',
+            label: '操作'
           }
-          // {
-          //   action: 'action',
-          //   slot: 'action',
-          //   label: '操作'
-          // }
         ],
         statusOpt: {
           '-1': '草稿',
@@ -106,8 +103,8 @@
           size: limit
         });
       },
-      handelEdit (type, row) {
-        this.$refs.editDialogRef.open(type, row);
+      handelEdit (row) {
+        this.$refs.editDialogRef.open(row);
       },
       /* 刷新表格 */
       reload (where) {