Forráskód Böngészése

1.销售公司新增时增加角色菜单信息
2、调整优化页面

yfh 3 hete
szülő
commit
8710782f59

+ 10 - 1
src/api/company/companyMenu.js

@@ -50,4 +50,13 @@ export function exportCompanyMenu(query) {
     method: 'get',
     params: query
   })
-}
+}
+
+
+// 查询菜单下拉树结构
+export function treeselect() {
+  return request({
+    url: '/company/companyMenu/treeselect',
+    method: 'get'
+  })
+}

+ 184 - 0
src/views/system/config/companyMenuConfig.vue

@@ -0,0 +1,184 @@
+<template>
+  <div class="app-container">
+    <el-tabs v-model="activeName" @tab-click="handleClick" >
+      <el-form ref="form14" :model="form14" :rules="rules14" label-width="180px">
+
+        <el-form-item label="菜单权限">
+          <el-checkbox v-model="menuExpand" @change="handleCheckedTreeExpand($event, 'menu')">展开/折叠</el-checkbox>
+          <el-checkbox v-model="menuNodeAll" @change="handleCheckedTreeNodeAll($event, 'menu')">全选/全不选</el-checkbox>
+          <el-checkbox v-model="menuCheckStrictly" @change="handleCheckedTreeConnect($event, 'menu')">父子联动</el-checkbox>
+          <el-tree
+            class="tree-border"
+            :data="menuOptions"
+            show-checkbox
+            ref="menu"
+            node-key="id"
+            :check-strictly="!menuCheckStrictly"
+            empty-text="加载中,请稍后"
+            :props="defaultProps"
+          ></el-tree>
+        </el-form-item>
+
+        <div   class="footer">
+          <el-button type="primary" @click="submitForm14">提  交</el-button>
+        </div>
+      </el-form>
+    </el-tabs>
+  </div>
+</template>
+
+<script>
+import Editor from '@/components/Editor/wang';
+import {   getConfigByKey,updateConfigByKey, clearCache } from "@/api/system/config";
+import {   listCompany } from "@/api/company/company";
+import Material from '@/components/Material'
+import {treeselect as menuTreeselect} from "@/api/company/companyMenu";
+export default {
+  name: "Config",
+  components: {
+    Material,
+    Editor
+  },
+  watch: {
+    photoArr: function(val) {
+      this.form1.certs = val.join(',')
+    },
+    images: function(val) {
+      this.form7.images = val.join(',')
+    }
+  },
+  data() {
+    return {
+      menuCheckStrictly: true,
+      defaultProps: {
+        children: "children",
+        label: "label"
+      },
+      // 菜单列表
+      menuOptions: [],
+      menuExpand: false,
+      menuNodeAll: false,
+      companyOptions:[],
+      activeName:"companymenu.config",
+      configId:null,
+      configKey:null,
+      form14:{},
+      rules14:{}
+    };
+  },
+  created() {
+    this.getConfigByKey(this.activeName);
+    this.getMenuTreeselect();
+  },
+  methods: {
+    handleClick(tab, event){
+      console.log(tab.name)
+      this.getConfigByKey(tab.name);
+    },
+    /** 查询菜单树结构 */
+    getMenuTreeselect() {
+      menuTreeselect().then(response => {
+        this.menuOptions = response.data;
+      });
+    },
+    // 树权限(展开/折叠)
+    handleCheckedTreeExpand(value, type) {
+      if (type == 'menu') {
+        let treeList = this.menuOptions;
+        for (let i = 0; i < treeList.length; i++) {
+          this.$refs.menu.store.nodesMap[treeList[i].id].expanded = value;
+        }
+      } else if (type == 'dept') {
+        let treeList = this.deptOptions;
+        for (let i = 0; i < treeList.length; i++) {
+          this.$refs.dept.store.nodesMap[treeList[i].id].expanded = value;
+        }
+      }
+    },
+    // 树权限(全选/全不选)
+    handleCheckedTreeNodeAll(value, type) {
+      if (type == 'menu') {
+        this.$refs.menu.setCheckedNodes(value ? this.menuOptions: []);
+      } else if (type == 'dept') {
+        this.$refs.dept.setCheckedNodes(value ? this.deptOptions: []);
+      }
+    },
+    // 树权限(父子联动)
+    handleCheckedTreeConnect(value, type) {
+      if (type == 'menu') {
+        this.menuCheckStrictly = value ? true: false;
+      } else if (type == 'dept') {
+        this.deptCheckStrictly = value ? true: false;
+      }
+    },
+    getCompanyOptions() {
+      listCompany().then(response=>{
+        this.companyOptions = response.rows
+      })
+    },
+    handleSuccess(response, file) {
+      // 上传成功后的回调函数
+      this.myloading.close();
+      this.form7.videoUrl = response.url;
+      this.$refs.upload.clearFiles();
+    },
+
+    getConfigByKey(key){
+      getConfigByKey(key).then(response => {
+        if(key == "companymenu.config"){
+          this.getCompanyOptions();
+          console.log(response.data.configId)
+          this.configId=response.data.configId;
+          this.configKey=response.data.configKey;
+          if(response.data.configValue != null) {
+            this.form14 = JSON.parse(response.data.configValue);
+            // 回显选中的菜单
+            this.$nextTick(() => {
+              if (this.form14.menuIds && this.form14.menuIds.length > 0) {
+                this.$refs.menu.setCheckedKeys(this.form14.menuIds);
+              }
+            });
+          } else {
+            this.form14 = { menuIds: [] };
+          }
+        }
+      });
+    },
+
+    submitForm14(){
+      this.form14.menuIds = this.getMenuAllCheckedKeys();
+      var param={configId:this.configId,configKey:this.configKey,configValue:JSON.stringify(this.form14)}
+      updateConfigByKey(param).then(response => {
+        if (response.code === 200) {
+          this.msgSuccess("修改成功");
+        }
+      });
+    },
+    // 所有菜单节点数据
+    getMenuAllCheckedKeys() {
+      // 目前被选中的菜单节点
+      let checkedKeys = this.$refs.menu.getHalfCheckedKeys();
+      // 半选中的菜单节点
+      let halfCheckedKeys = this.$refs.menu.getCheckedKeys();
+      checkedKeys.unshift.apply(checkedKeys, halfCheckedKeys);
+      return checkedKeys;
+    },
+    /** 清理缓存按钮操作 */
+    handleClearCache() {
+      clearCache().then(response => {
+        if (response.code === 200) {
+          this.msgSuccess("清理成功");
+        }
+      });
+    },
+  }
+};
+</script>
+<style scoped>
+.footer{
+  width: 100%;
+  display: flex;
+  align-items: flex-end;
+  justify-content: flex-end;
+}
+</style>

+ 4 - 87
src/views/system/config/config.vue

@@ -16,7 +16,7 @@
             </el-form-item>
             <el-form-item  label="默认自定义金额" prop="payAmount">
               <el-tooltip class="item" effect="dark" content="货到付款默认自定义金额(元)" placement="top-end">
-                <el-input-number  v-model="form1.payAmount"  min="10" ></el-input-number>
+                <el-input-number  v-model="form1.payAmount"  :min="10" ></el-input-number>
               </el-tooltip>
             </el-form-item>
             <el-form-item  label="待支付订单取消时间" prop="unPayTime">
@@ -640,28 +640,7 @@
       </el-form>
     </el-tab-pane>
        <el-tab-pane label="公司销售角色默认生成配置" name="companymenu.config">
-         <el-form ref="form14" :model="form14" :rules="rules14" label-width="180px">
-
-           <el-form-item label="菜单权限">
-             <el-checkbox v-model="menuExpand" @change="handleCheckedTreeExpand($event, 'menu')">展开/折叠</el-checkbox>
-             <el-checkbox v-model="menuNodeAll" @change="handleCheckedTreeNodeAll($event, 'menu')">全选/全不选</el-checkbox>
-             <el-checkbox v-model="menuCheckStrictly" @change="handleCheckedTreeConnect($event, 'menu')">父子联动</el-checkbox>
-             <el-tree
-               class="tree-border"
-               :data="menuOptions"
-               show-checkbox
-               ref="menu"
-               node-key="id"
-               :check-strictly="!menuCheckStrictly"
-               empty-text="加载中,请稍后"
-               :props="defaultProps"
-             ></el-tree>
-           </el-form-item>
-
-           <div   class="footer">
-             <el-button type="primary" @click="submitForm14">提  交</el-button>
-           </div>
-         </el-form>
+         <companyMenuConfig></companyMenuConfig>
        </el-tab-pane>
     </el-tabs>
      <el-dialog :title="sign.title" :visible.sync="sign.open" width="500px" append-to-body>
@@ -689,10 +668,12 @@ import {   getConfigByKey,updateConfigByKey, clearCache } from "@/api/system/con
 import {   listCompany } from "@/api/company/company";
 import Material from '@/components/Material'
 import {treeselect as menuTreeselect} from "@/api/system/menu";
+import companyMenuConfig from "./companyMenuConfig";
 export default {
   name: "Config",
   components: {
     Material,
+    companyMenuConfig,
     Editor
   },
    watch: {
@@ -705,15 +686,6 @@ export default {
   },
   data() {
     return {
-      menuCheckStrictly: true,
-      defaultProps: {
-        children: "children",
-        label: "label"
-      },
-      // 菜单列表
-      menuOptions: [],
-      menuExpand: false,
-      menuNodeAll: false,
       companyOptions:[],
       uploadUrl:process.env.VUE_APP_BASE_API+"/common/uploadOSS",
       videoAccept:"video/*",
@@ -795,52 +767,13 @@ export default {
 
       },
       form13:{},
-      form14:{},
       rules13:{},
-      rules14:{}
     };
   },
   created() {
     this.getConfigByKey(this.activeName);
-    this.getMenuTreeselect();
   },
   methods: {
-    /** 查询菜单树结构 */
-    getMenuTreeselect() {
-      menuTreeselect().then(response => {
-        this.menuOptions = response.data;
-      });
-    },
-    // 树权限(展开/折叠)
-    handleCheckedTreeExpand(value, type) {
-      if (type == 'menu') {
-        let treeList = this.menuOptions;
-        for (let i = 0; i < treeList.length; i++) {
-          this.$refs.menu.store.nodesMap[treeList[i].id].expanded = value;
-        }
-      } else if (type == 'dept') {
-        let treeList = this.deptOptions;
-        for (let i = 0; i < treeList.length; i++) {
-          this.$refs.dept.store.nodesMap[treeList[i].id].expanded = value;
-        }
-      }
-    },
-    // 树权限(全选/全不选)
-    handleCheckedTreeNodeAll(value, type) {
-      if (type == 'menu') {
-        this.$refs.menu.setCheckedNodes(value ? this.menuOptions: []);
-      } else if (type == 'dept') {
-        this.$refs.dept.setCheckedNodes(value ? this.deptOptions: []);
-      }
-    },
-    // 树权限(父子联动)
-    handleCheckedTreeConnect(value, type) {
-      if (type == 'menu') {
-        this.menuCheckStrictly = value ? true: false;
-      } else if (type == 'dept') {
-        this.deptCheckStrictly = value ? true: false;
-      }
-    },
     getCompanyOptions() {
         listCompany().then(response=>{
           this.companyOptions = response.rows
@@ -972,14 +905,6 @@ export default {
                this.form13 =JSON.parse(response.data.configValue);
              }
 
-          }else if(key == "companymenu.config"){
-            this.getCompanyOptions();
-             this.configId=response.data.configId;
-             this.configKey=response.data.configKey;
-             if(response.data.configValue != null) {
-               this.form14 =JSON.parse(response.data.configValue);
-             }
-
           }
         });
      },
@@ -1113,14 +1038,6 @@ export default {
         }
       });
     },
-    submitForm14(){
-      var param={configId:this.configId,configKey:this.configKey,configValue:JSON.stringify(this.form14)}
-      updateConfigByKey(param).then(response => {
-        if (response.code === 200) {
-          this.msgSuccess("修改成功");
-        }
-      });
-    },
     /** 清理缓存按钮操作 */
     handleClearCache() {
       clearCache().then(response => {