浏览代码

分类管理

quwangxin 3 年之前
父节点
当前提交
b2f5e6a978

+ 17 - 6
src/api/system/dictionary-data/index.js

@@ -4,19 +4,30 @@ import request from '@/utils/request';
  * 分页查询字典数据
  * @param params 查询条件
  */
-export async function pageDictionaryData(id) {
+export async function pageDictionaryData (id) {
   const res = await request.get(`/system/dict/getById/${id}`, {});
   if (res.data.code == 0) {
     return res.data;
   }
   return Promise.reject(new Error(res.data.message));
 }
+/**
+ * 根据code查字典
+ * @param params 查询条件
+ */
+export async function getByCode (code) {
+  const res = await request.get(`/system/dict/getByCode/${code}`, {});
+  if (res.data.code == 0) {
+    return res.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
 
 /**
  * 查询字典数据列表
  * @param params 查询条件
  */
-export async function listDictionaryData(params) {
+export async function listDictionaryData (params) {
   const res = await request.get('/system/dictionary-data', {
     params
   });
@@ -30,7 +41,7 @@ export async function listDictionaryData(params) {
  * 添加字典数据
  * @param data 字典数据信息
  */
-export async function addDictionaryData(data) {
+export async function addDictionaryData (data) {
   const res = await request.post('/system/dictionary-data', data);
   if (res.data.code === 0) {
     return res.data.message;
@@ -42,7 +53,7 @@ export async function addDictionaryData(data) {
  * 修改字典数据
  * @param data 字典数据信息
  */
-export async function updateDictionaryData(data) {
+export async function updateDictionaryData (data) {
   const res = await request.put('/system/dictionary-data', data);
   if (res.data.code === 0) {
     return res.data.message;
@@ -54,7 +65,7 @@ export async function updateDictionaryData(data) {
  * 删除字典数据
  * @param id 字典数据id
  */
-export async function removeDictionaryData(id) {
+export async function removeDictionaryData (id) {
   const res = await request.post('/system/dict/removeDictInfoById', [id]);
   if (res.data.code == 0) {
     return res.data.message;
@@ -66,7 +77,7 @@ export async function removeDictionaryData(id) {
  * 批量删除字典数据
  * @param data 字典数据id集合
  */
-export async function removeDictionaryDataBatch(data) {
+export async function removeDictionaryDataBatch (data) {
   const res = await request.delete('/system/dictionary-data/batch', {
     data
   });

+ 22 - 8
src/store/modules/dict.js

@@ -1,6 +1,6 @@
 import dictEnum from '@/enum/dict';
 import Vue from 'vue';
-import { pageDictionaryData } from '@/api/system/dictionary-data';
+import { getByCode } from '@/api/system/dictionary-data';
 //非枚举定义
 const otherDictConfig = {
   //   [dictEnum.物品类型]: {
@@ -49,7 +49,7 @@ const actions = {
       console.log(config);
       //非枚举定义
       res = await config.request();
-      if (res?.success) {
+      if (res?.code == 0) {
         let list = config.resKey ? res.data[config.resKey] : res.data;
         commit('ADD_DICT', {
           code,
@@ -62,11 +62,18 @@ const actions = {
         return res.list;
       }
     } else {
-      res = await pageDictionaryData(code);
-      if (res?.success) {
+      res = await getByCode(code);
+      if (res?.code == 0) {
         commit('ADD_DICT', {
           code,
-          dict: res.data
+          dict: res.data.map((item) => {
+            const arr = Object.entries(item)[0] || [];
+
+            return {
+              dictCode: arr[1],
+              dictValue: arr[0]
+            };
+          })
         });
         return res.data;
       }
@@ -77,11 +84,18 @@ const actions = {
   // 更新字典
   async reloadRequestDict ({ commit }, enumName) {
     const code = dictEnum[enumName];
-    const res = await pageDictionaryData(code);
-    if (res?.success) {
+    const res = await getByCode(code);
+    if (res?.code == 0) {
       commit('ADD_DICT', {
         code,
-        dict: res.data
+        dict: res.data.map((item) => {
+          const arr = Object.entries(item);
+
+          return {
+            dictCode: arr[1],
+            dictValue: arr[0]
+          };
+        })
       });
       return res.data;
     }

+ 3 - 0
src/store/modules/user.js

@@ -13,10 +13,13 @@ const formatRouter = (list) => {
     let arr = [];
     for (const p of list) {
       if (p.menuType === 2) {
+        p.children = [];
         authorities.push(p);
       } else {
         if (p.children?.length) {
           p.children = fn(p.children);
+        } else {
+          p.children = [];
         }
         arr.push(p);
       }

+ 28 - 24
src/views/classifyManage/components/list-edit.vue

@@ -14,6 +14,7 @@
           <el-input
             clearable
             :maxlength="20"
+            :disabled="isUpdate"
             v-model="formData.code"
             placeholder="请输入"
           />
@@ -26,7 +27,7 @@
             placeholder="请输入"
           />
         </el-form-item>
-        <el-form-item label="类型用途:" prop="type">
+        <el-form-item label="类型用途:" prop="type" :key="data.id">
           <DictSelection dictName="类型用途" clearable v-model="formData.type">
           </DictSelection>
           <!-- <el-select
@@ -61,25 +62,17 @@
         <el-form-item label="父级节点:">
           {{ parentData.name }}
         </el-form-item>
-        <el-form-item label="层级全览:" prop="name">
+        <el-form-item label="层级全览:">
           {{ fullName }}
         </el-form-item>
         <el-form-item label="节点编码:" prop="code">
-          <el-select
+          <el-input
             clearable
-            class="w100"
             :maxlength="20"
+            :disabled="isUpdate"
             v-model="formData.code"
-            placeholder="请选择"
-          >
-            <el-option
-              v-for="item in typeList"
-              :key="item.code"
-              :label="item.label"
-              :value="item.code"
-            >
-            </el-option>
-          </el-select>
+            placeholder="请输入"
+          />
         </el-form-item>
         <el-form-item label="节点名称:" prop="name">
           <el-input
@@ -89,13 +82,13 @@
             placeholder="请输入"
           />
         </el-form-item>
-        <el-form-item label="与下层分隔:" prop="remark">
+        <el-form-item label="与下层分隔:" prop="separate">
           <el-select
             class="w100"
             clearable
             type="textarea"
             :maxlength="20"
-            v-model="formData.remark"
+            v-model="formData.separate"
             placeholder="请输入"
           >
             <el-option
@@ -106,12 +99,11 @@
             ></el-option>
           </el-select>
         </el-form-item>
-        <el-form-item label="本层排序:" prop="remark">
+        <el-form-item label="本层排序:" prop="sort">
           <el-input
             clearable
-            type="textarea"
             :maxlength="20"
-            v-model="formData.remark"
+            v-model.number="formData.sort"
             placeholder="请输入"
           />
         </el-form-item>
@@ -141,6 +133,8 @@
       const defaultForm = {
         name: '',
         code: '',
+        separate: '',
+        sort: '',
         type: '',
         remark: '',
         parentId: 0
@@ -197,14 +191,19 @@
     computed: {
       fullName () {
         let str = '';
+        let codeStr = '';
         let node = this.curNode;
-
+        console.log(this.curNode);
         while (node?.data?.name) {
           str = node.data.name + '-' + str;
+          codeStr = node.data.code + '-' + codeStr;
           node = node?.parent;
         }
 
-        return str;
+        return (
+          str.substring(str, str.length - 1) +
+          `(${codeStr.substring(str, str.length - 1)})`
+        );
       }
     },
     methods: {
@@ -220,9 +219,14 @@
             return false;
           }
           this.loading = true;
-          saveOrUpdate({
-            ...this.formData
-          })
+
+          const params = { ...this.formData };
+          if (this.parentData?.id) {
+            params.parentId = this.parentData?.id;
+            params.type = this.parentData.type;
+          }
+
+          saveOrUpdate(params)
             .then((msg) => {
               this.loading = false;
               this.$message.success(msg);

+ 31 - 12
src/views/classifyManage/details.vue

@@ -100,28 +100,28 @@
                   <el-col v-bind="styleResponsive ? { sm: 12 } : { span: 12 }">
                     <el-form-item label="层级全览:">
                       <div class="ele-text-secondary">
-                        {{ current.module }}
+                        {{ fullName }}
                       </div>
                     </el-form-item>
                   </el-col>
                   <el-col v-bind="styleResponsive ? { sm: 12 } : { span: 12 }">
                     <el-form-item label="节点编码:">
                       <div class="ele-text-secondary">
-                        {{ current.createTime }}
+                        {{ current.code }}
                       </div>
                     </el-form-item>
                   </el-col>
                   <el-col v-bind="styleResponsive ? { sm: 12 } : { span: 12 }">
                     <el-form-item label="节点名称:">
                       <div class="ele-text-secondary">
-                        {{ current.requestMethod }}
+                        {{ current.name }}
                       </div>
                     </el-form-item>
                   </el-col>
                   <el-col v-bind="styleResponsive ? { sm: 12 } : { span: 12 }">
                     <el-form-item label="与下层分隔:">
                       <div class="ele-text-secondary">
-                        {{ current.requestMethod }}
+                        {{ current.separate }}
                       </div>
                     </el-form-item>
                   </el-col>
@@ -176,14 +176,31 @@
       },
       rootId () {
         return this.$route.query.id;
+      },
+      fullName () {
+        let str = '';
+        let codeStr = '';
+        let node = this.curNode;
+        while (node?.data?.name) {
+          str = node.data.name + node.data.separate + str;
+          codeStr = node.data.code + node.data.separate + codeStr;
+          node = node?.parent;
+        }
+
+        return (
+          str.substring(0, str.length - 1) +
+          `(${codeStr.substring(0, codeStr.length - 1)})`
+        );
       }
     },
     created () {
       this.getTree().then(() => {
         this.$nextTick(() => {
           console.log(this.treeData[0]?.id);
-          this.$refs.treeRef.setCurrentKey(this.treeData[0]?.id);
-          this.current = this.treeData[0];
+          this.getDetail(this.treeData[0]?.id);
+          // this.$refs.treeRef.setCurrentKey(this.treeData[0]?.id);
+          // this.current = this.treeData[0];
+          // this.curNode = { data: this.current };
         });
       });
     },
@@ -207,9 +224,11 @@
           if (res?.code == '0') {
             this.getTree().then(() => {
               this.$nextTick(() => {
-                console.log(this.treeData[0]?.id);
-                this.$refs.treeRef.setCurrentKey(this.treeData[0]?.id);
-                this.current = this.treeData[0];
+                this.getDetail(this.treeData[0]?.id);
+                // console.log(this.treeData[0]?.id);
+                // this.$refs.treeRef.setCurrentKey(this.treeData[0]?.id);
+                // this.current = this.treeData[0];
+                // this.curNode = { data: this.current };
               });
             });
             this.$message.success('删除成功!');
@@ -230,16 +249,16 @@
         this.loading = true;
         const res = await getInfoById(id);
         this.loading = false;
-        if (res?.success) {
-          console.log(res);
+        if (res.code == '0') {
+          this.current = res.data;
         }
       },
       openEdit (isAdd = true) {
         this.$refs.editRef.open(isAdd ? null : this.current, this.current);
       },
       handleNodeClick (data, node) {
-        this.current = data;
         this.curNode = node;
+        this.getDetail(data.id);
         console.log(node);
       }
     }

+ 3 - 3
vue.config.js

@@ -17,9 +17,9 @@ module.exports = {
       '/api': {
         // target: 'http://192.168.3.51:18086', // 跨域请求的地址
         // target: 'http://192.168.3.35:8080', // kang杨威
-        target: 'http://192.168.3.25:8080', // 黄峥嵘
+        // target: 'http://192.168.3.25:8080', // 黄峥嵘
         // target: 'http://192.168.3.41:8080', // 何江鹏
-        // target: 'http://192.168.3.33:8080', // 谢一平
+        target: 'http://192.168.3.33:8080', // 谢一平
 
         changeOrigin: true, // 只有这个值为true的情况下 才表示开启跨域
         pathRewrite: {
@@ -28,7 +28,7 @@ module.exports = {
       }
     }
   },
-  chainWebpack(config) {
+  chainWebpack (config) {
     config.plugins.delete('prefetch');
     if (process.env.NODE_ENV !== 'development') {
       // gzip 压缩