소스 검색

企业微信查看权限设置

yjwang 1 일 전
부모
커밋
37a8c36a0e
1개의 변경된 파일51개의 추가작업 그리고 2개의 파일을 삭제
  1. 51 2
      src/views/qw/qwCompany/index.vue

+ 51 - 2
src/views/qw/qwCompany/index.vue

@@ -212,6 +212,9 @@
           </el-select>
 
 
+        </el-form-item>
+        <el-form-item label="所属部门" prop="createDeptId">
+          <treeselect v-model="form.createDeptId" :options="deptOptions" :normalizer="normalizer"  placeholder="选择上级部门"   :disabled="(username !== 'admin' && title === '修改小程序配置')"  />
         </el-form-item>
         <el-form-item label="状态">
           <el-radio-group v-model="form.status">
@@ -235,8 +238,13 @@
 import { listQwCompany, getQwCompany, delQwCompany, addQwCompany, updateQwCompany, exportQwCompany } from "@/api/qw/qwCompany";
 import { getCompanyList } from "@/api/company/company";
 import { listAll } from '@/api/course/coursePlaySourceConfig'
+import Treeselect from "@riophae/vue-treeselect";
+import "@riophae/vue-treeselect/dist/vue-treeselect.css";
+import { getUserProfile } from '@/api/system/user'
+import { listDept } from '@/api/system/dept'
 export default {
   name: "QwCompany",
+  components: {Treeselect},
   watch: {
       'form.realmNameUrl': function(newVal) {
         if(newVal==null){
@@ -254,6 +262,9 @@ export default {
     },
   data() {
     return {
+      // 部门树选项
+      deptOptions: [],
+      username:null,
       // 遮罩层
       loading: true,
       // 导出遮罩层
@@ -319,7 +330,13 @@ export default {
     });
     getCompanyList().then(response => {
         this.companys = response.data;
-
+    });
+    listDept().then(response => {
+      this.deptOptions = this.handleTree(response.data, "deptId");
+    });
+    getUserProfile().then(response => {
+      const data = response.data;
+      this.username = data.userName;
     });
   },
   methods: {
@@ -471,7 +488,39 @@ export default {
           this.download(response.msg);
           this.exportLoading = false;
         }).catch(() => {});
-    }
+    },
+    /** 转换部门数据结构 */
+    normalizer(node) {
+      if (node.hasOwnProperty('id') && !node.hasOwnProperty('deptId')) {
+        return {
+          id: node.id,
+          label: this.getDeptNameById(node.id) || '未知部门',
+          children: node.children || []
+        };
+      }
+      if (node.children && !node.children.length) {
+        delete node.children;
+      }
+      return {
+        id: node.deptId,
+        label: node.deptName,
+        children: node.children
+      };
+    },
+    getDeptNameById(targetId) {
+      const deptOptions =this.deptOptions
+      console.log("text:"+JSON.stringify(deptOptions))
+      for (let i = 0; i < deptOptions.length; i++) {
+        const dept = deptOptions[i];
+        if (dept.deptId === targetId) {
+          return dept.deptName;
+        }
+      }
+      return '未知部门';
+    },
   }
 };
 </script>
+<style scoped>
+
+</style>