Jelajahi Sumber

1.销售公司新增时增加角色菜单信息
2、调整菜单树接口信息

yfh 3 hari lalu
induk
melakukan
c0bdfd343d

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

@@ -50,4 +50,14 @@ 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>

+ 7 - 2
src/views/system/config/config.vue

@@ -1025,7 +1025,7 @@
           :rules="rulesDelay"
               >
   <el-tooltip class="item" effect="dark" content="请输入延时时间,范围在1000毫秒-2000毫秒之间" placement="top-end">
-    <el-input 
+    <el-input
       v-model.number="form18.sendDelayTime"
       type="number"
       :min="1000"
@@ -1272,6 +1272,9 @@
            </div>
          </el-form>
        </el-tab-pane>
+       <el-tab-pane label="公司销售角色默认生成配置" name="companymenu.config">
+         <companyMenuConfig></companyMenuConfig>
+       </el-tab-pane>
     </el-tabs>
 
 
@@ -1297,9 +1300,11 @@ import productAttrValueSelect from "../../components/his/productGiftValueSelect.
 import productDeliveryGiftValueSelect from "../../components/his/productDeliveryGiftValueSelect.vue";
 import { Col } from "element-ui";
 import Editor from '@/components/Editor/wang';
+import companyMenuConfig from "./companyMenuConfig";
 export default {
   name: "Config",
   components: {
+    companyMenuConfig,
     Material,productAttrValueSelect,productDeliveryGiftValueSelect,Editor
   },
   data() {
@@ -1382,7 +1387,7 @@ export default {
       rules3: {
       },
       rulesDelay:[
-                { 
+                {
                   validator: (rule, value, callback) => {
                     if (value === '' || value == null) {
                       callback(); // 允许为空,不校验范围