zhaoke 2 tahun lalu
induk
melakukan
4af42cea15

+ 10 - 9
public/config.js

@@ -1,14 +1,15 @@
 var PLATFROM_CONFIG = {};
 // PLATFROM_CONFIG.baseUrl = "http://106.14.243.117:9001/"
-PLATFROM_CONFIG.baseUrl = "https://authgateway.fsjtkj.cn/" // http请求地址
-PLATFROM_CONFIG.socketUrl = "wss://auth.fsjtkj.cn/websocket" // websocket请求地址
-PLATFROM_CONFIG.appSecret = "40t7vcbi5bc1twyihd2dum82yn1mt1kj" //appSecret
-PLATFROM_CONFIG.appId = "unsk1w37910olf8j" //appid
-PLATFROM_CONFIG.gatewayApiUrl = "106.14.243.117:8089" // 网关测试连接地址
-PLATFROM_CONFIG.gatewayUrl = "http://106.14.243.117:8089" //网关http请求地址
-PLATFROM_CONFIG.dataBaseUrl = "http://192.168.3.74:8093" //数据底座请求地址
+// PLATFROM_CONFIG.baseUrl = "http://192.168.5.35:9001";
+PLATFROM_CONFIG.baseUrl = "https://authgateway.fsjtkj.cn/"; // http请求地址
+PLATFROM_CONFIG.socketUrl = "wss://auth.fsjtkj.cn/websocket"; // websocket请求地址
+PLATFROM_CONFIG.appSecret = "40t7vcbi5bc1twyihd2dum82yn1mt1kj"; //appSecret
+PLATFROM_CONFIG.appId = "unsk1w37910olf8j"; //appid
+PLATFROM_CONFIG.gatewayApiUrl = "106.14.243.117:8089"; // 网关测试连接地址
+PLATFROM_CONFIG.gatewayUrl = "http://106.14.243.117:8089"; //网关http请求地址
+PLATFROM_CONFIG.dataBaseUrl = "http://192.168.3.74:8093"; //数据底座请求地址
 // does job show yes/no 显示/不显示职务
-PLATFROM_CONFIG.doesJobShow = false
+PLATFROM_CONFIG.doesJobShow = false;
 
 // account group accountGroup命名
-PLATFROM_CONFIG.accountGroupType = '用户组'
+PLATFROM_CONFIG.accountGroupType = "用户组";

+ 160 - 114
src/utils/validate.js

@@ -13,26 +13,26 @@
  * @param {string} path
  * @returns {Boolean}
  */
-export function isExternal (path) {
-  return /^(https?:|mailto:|tel:)/.test(path)
+export function isExternal(path) {
+  return /^(https?:|mailto:|tel:)/.test(path);
 }
 
 /**
  * @param {string} str
  * @returns {Boolean}
  */
-export function validUsername (str) {
-  const valid_map = ['admin', 'editor']
-  return valid_map.indexOf(str.trim()) >= 0
+export function validUsername(str) {
+  const valid_map = ["admin", "editor"];
+  return valid_map.indexOf(str.trim()) >= 0;
 }
 
 /**
  * @param {string} str
  * @returns {Object}
  */
-export function orgTree (str) {
-  const valid_map = ['admin', 'editor']
-  return valid_map.indexOf(str.trim()) >= 0
+export function orgTree(str) {
+  const valid_map = ["admin", "editor"];
+  return valid_map.indexOf(str.trim()) >= 0;
 }
 
 // 岗位树构造
@@ -60,49 +60,61 @@ export function orgTree (str) {
 //   return parent;
 // }
 
-export function translateDataToTreeAll (arr, parentKey, key) {
-  const map = {}
-  const result = []
-  arr.forEach(element => {
-    const id = element[key]
-    const pid = element[parentKey]
+export function translateDataToTreeAll(arr, parentKey, key) {
+  const map = {};
+  const result = [];
+  arr.forEach((element) => {
+    const id = element[key];
+    const pid = element[parentKey];
     if (map[id]) {
       map[id] = {
         ...element,
-        children: map[id].children
-      }
+        children: map[id].children,
+      };
     } else {
       map[id] = {
         ...element,
-        children: []
-      }
+        children: [],
+      };
     }
-    const item = map[id]
+    const item = map[id];
     if (pid <= 0) {
-      result.push(item)
-      result.sort((a, b) => b.children.length - a.children.length)
+      result.push(item);
+      result.sort((a, b) => b.children.length - a.children.length);
     } else {
       if (map[pid]) {
-        map[pid].children.push(item)
+        map[pid].children.push(item);
       } else {
         map[pid] = {
-          children: [item]
-        }
+          children: [item],
+        };
       }
     }
-  })
-  return result
+  });
+  return disResult(result);
+  //return result;
+}
+
+function disResult(arr) {
+  arr.forEach((item) => {
+    if (item.children) {
+      item.children.sort((a, b) => b.children.length - a.children.length);
+      item.children.sort((a, b) => b.organType - a.organType);
+      disResult(item.children);
+    }
+  });
+  return arr;
 }
 
-export function deteleObject (obj) {
+export function deteleObject(obj) {
   var uniques = [];
   var stringify = {};
   for (var i = 0; i < obj.length; i++) {
     var keys = Object.keys(obj[i]);
     keys.sort(function (a, b) {
-      return (Number(a) - Number(b));
+      return Number(a) - Number(b);
     });
-    var str = '';
+    var str = "";
     for (var j = 0; j < keys.length; j++) {
       str += JSON.stringify(keys[j]);
       str += JSON.stringify(obj[i][keys[j]]);
@@ -117,27 +129,27 @@ export function deteleObject (obj) {
 }
 
 // 随机长度
-function randomNum (start, end) {
-  return Math.floor(Math.random() * (Number(end) - Number(start)) + start)
+function randomNum(start, end) {
+  return Math.floor(Math.random() * (Number(end) - Number(start)) + start);
 }
 
 //字母随机
-function randomAlp (arr, count) {
-
-  let shuffled = arr.slice(0)
-  let i = arr.length
+function randomAlp(arr, count) {
+  let shuffled = arr.slice(0);
+  let i = arr.length;
   if (count > i) {
-    i = count
+    i = count;
   }
-  let min = i - count, temp, index;
+  let min = i - count,
+    temp,
+    index;
   while (i-- > min) {
-    index = Math.floor((arr.length) * Math.random());
+    index = Math.floor(arr.length * Math.random());
     temp = shuffled[index];
     if (shuffled[i]) {
       shuffled[index] = shuffled[i];
-    }
-    else {
-      shuffled[index] = shuffled[index]
+    } else {
+      shuffled[index] = shuffled[index];
     }
     shuffled[i] = temp;
   }
@@ -151,86 +163,121 @@ function randomAlp (arr, count) {
  * @returns {Object}
  * 4位密码规则 1111 = 大写 小写 特殊字符 数字 都开启
  */
-export function pwdProduce (minLen, maxLen, struc) {
+export function pwdProduce(minLen, maxLen, struc) {
   // 密码规则转化
-  const pwdStruc = typeof (struc) === 'string' ? struc.split('') : `${struc}`.split('')
+  const pwdStruc =
+    typeof struc === "string" ? struc.split("") : `${struc}`.split("");
   // 字母
-  const alphabet = 'abcdefghijklmnopqrstuvwxyz'
+  const alphabet = "abcdefghijklmnopqrstuvwxyz";
   // 特殊字符
-  const special = ['`', '~', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '-', '_', '+', '=', '[', '{', ']', '}', '\\', '|', ';', ':', "'", '"', ',', '<', '.', '>', '/', '?']
+  const special = [
+    "`",
+    "~",
+    "!",
+    "@",
+    "#",
+    "$",
+    "%",
+    "^",
+    "&",
+    "*",
+    "(",
+    ")",
+    "-",
+    "_",
+    "+",
+    "=",
+    "[",
+    "{",
+    "]",
+    "}",
+    "\\",
+    "|",
+    ";",
+    ":",
+    "'",
+    '"',
+    ",",
+    "<",
+    ".",
+    ">",
+    "/",
+    "?",
+  ];
   //数字
-  const numbers = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
+  const numbers = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
   // 密码随机长度
   // const pwdLen = randomNum(minLen, maxLen)
-  const pwdLen = maxLen
-  const datas = []
+  const pwdLen = maxLen;
+  const datas = [];
 
   if (pwdStruc.length) {
-    let typeLong = Number(pwdStruc[0]) + Number(pwdStruc[1]) + Number(pwdStruc[2]) + Number(pwdStruc[3]);
+    let typeLong =
+      Number(pwdStruc[0]) +
+      Number(pwdStruc[1]) +
+      Number(pwdStruc[2]) +
+      Number(pwdStruc[3]);
     let passLong = Math.floor(pwdLen / typeLong);
     let dis = "";
     if (pwdStruc[0] == 1) {
-      let arr = alphabet.toLocaleUpperCase().split('');
+      let arr = alphabet.toLocaleUpperCase().split("");
       let v = randomAlp(arr, passLong);
       for (let i = 0; i < passLong; i++) {
-        dis += v[i]
+        dis += v[i];
       }
     }
     if (pwdStruc[1] == 1) {
-      let arr = alphabet.split('');
+      let arr = alphabet.split("");
       let v = randomAlp(arr, passLong);
       for (let i = 0; i < passLong; i++) {
-        dis += v[i]
+        dis += v[i];
       }
     }
     if (pwdStruc[2] == 1) {
-      let arr = special
+      let arr = special;
       let v = randomAlp(arr, passLong);
       for (let i = 0; i < passLong; i++) {
-        dis += v[i]
+        dis += v[i];
       }
     }
     if (pwdStruc[3] == 1) {
-      let arr = numbers
+      let arr = numbers;
       let v = randomAlp(arr, passLong);
       // console.log(v)
 
       for (let i = 0; i < passLong; i++) {
-        dis += v[i]
+        dis += v[i];
       }
     }
-    let strlong = pwdLen - (passLong * typeLong);
+    let strlong = pwdLen - passLong * typeLong;
     if (strlong > 0) {
       if (pwdStruc[0] == 1) {
-        let arr = alphabet.toLocaleUpperCase().split('');
+        let arr = alphabet.toLocaleUpperCase().split("");
         let v = randomAlp(arr, strlong);
         for (let i = 0; i < strlong; i++) {
-          dis += v[i]
+          dis += v[i];
         }
-      }
-      else if (pwdStruc[1] == 1) {
-        let arr = alphabet.split('');
+      } else if (pwdStruc[1] == 1) {
+        let arr = alphabet.split("");
         let v = randomAlp(arr, strlong);
         for (let i = 0; i < strlong; i++) {
-          dis += v[i]
+          dis += v[i];
         }
-      }
-      else if (pwdStruc[2] == 1) {
-        let arr = special
+      } else if (pwdStruc[2] == 1) {
+        let arr = special;
         let v = randomAlp(arr, strlong);
         for (let i = 0; i < strlong; i++) {
-          dis += v[i]
+          dis += v[i];
         }
-      }
-      else if (pwdStruc[3] == 1) {
-        let arr = numbers
+      } else if (pwdStruc[3] == 1) {
+        let arr = numbers;
         let v = randomAlp(arr, strlong);
         for (let i = 0; i < strlong; i++) {
-          dis += v[i]
+          dis += v[i];
         }
       }
     }
-    return dis
+    return dis;
     //缓存当前的密码规则
     // pwdStruc.forEach((item, index) => {
     //   if (item == 1) {
@@ -252,14 +299,13 @@ export function pwdProduce (minLen, maxLen, struc) {
     //       break;
     //   }
     // }
-
   } else {
-    return new Error('密码规则转换失败')
+    return new Error("密码规则转换失败");
   }
 }
 
 //模糊查询
-export function findarrays (ar, feature, v) {
+export function findarrays(ar, feature, v) {
   var arr = [];
   for (var i = 0; i < ar.length; i++) {
     var atxt = ar[i][feature];
@@ -308,71 +354,71 @@ export function findarrays (ar, feature, v) {
 }
 
 // 表单输入长度验证
-function getRealLength (string) {
+function getRealLength(string) {
   let realLength = 0,
     len = string.length,
-    charCode = -1
+    charCode = -1;
   for (let i = 0; i < len; i++) {
-    charCode = string.charCodeAt(i)
+    charCode = string.charCodeAt(i);
     if (charCode >= 0 && charCode <= 128) {
-      realLength += 1
+      realLength += 1;
     } else {
-      realLength += 2
+      realLength += 2;
     }
   }
-  return realLength
+  return realLength;
 }
 
-export function lengthValidator (rule, value, callback) {
-  value = value ?? ''
-  const realLength = getRealLength(value)
+export function lengthValidator(rule, value, callback) {
+  value = value ?? "";
+  const realLength = getRealLength(value);
   if (realLength === 0) {
-    callback()
+    callback();
   } else if (rule.min && realLength < rule.min) {
-    rule.message += `  ${realLength}/${rule.min}`
-    callback(new Error('长度小于最小值'))
+    rule.message += `  ${realLength}/${rule.min}`;
+    callback(new Error("长度小于最小值"));
   } else if (rule.max && realLength > rule.max) {
-    rule.message += `  ${realLength}/${rule.max}`
-    callback(new Error('长度超出最大值'))
+    rule.message += `  ${realLength}/${rule.max}`;
+    callback(new Error("长度超出最大值"));
   } else {
-    callback()
+    callback();
   }
 }
 
 // 表单大写字母验证
-export function checkDx (rule, value, callback) {
-  value = value ?? ''
-  const realLength = getRealLength(value)
+export function checkDx(rule, value, callback) {
+  value = value ?? "";
+  const realLength = getRealLength(value);
   if (realLength === 0) {
-    callback()
-  } else if (!(/^[A-Z]*$/).test(value)) {
-    callback(new Error('请输入大写字母'));
+    callback();
+  } else if (!/^[A-Z]*$/.test(value)) {
+    callback(new Error("请输入大写字母"));
   } else {
-    callback()
+    callback();
   }
 }
 
 // 表单正整数验证
-export function positiveIntegerValidator (rule, value, callback) {
-  const min = rule.min ?? 1
-  const max = rule.max ?? 2147483647
-  value = value ?? ''
+export function positiveIntegerValidator(rule, value, callback) {
+  const min = rule.min ?? 1;
+  const max = rule.max ?? 2147483647;
+  value = value ?? "";
   if (value.length === 0) {
-    callback()
+    callback();
   } else if (/^[1-9][0-9]*$/.test(value)) {
-    value = Number(value)
+    value = Number(value);
     if (value < min) {
-      rule.message = `不能小于${min}`
-      callback(new Error('Size Error'))
+      rule.message = `不能小于${min}`;
+      callback(new Error("Size Error"));
     } else if (value > max) {
-      rule.message = `不能大于${max}`
-      callback(new Error('Size Error'))
+      rule.message = `不能大于${max}`;
+      callback(new Error("Size Error"));
     } else {
-      callback()
+      callback();
     }
   } else {
-    rule.message = '请输入正整数'
-    callback(new Error('Type Error'))
+    rule.message = "请输入正整数";
+    callback(new Error("Type Error"));
   }
 }
 
@@ -380,7 +426,7 @@ export function positiveIntegerValidator (rule, value, callback) {
 export const regular = {
   integer: /^[0-9]*$/,
   name: /^(?!_)(?!.*?_$)[a-zA-Z0-9_\u4e00-\u9fa5]+$/,
-  nameMessage: '只能包含中文、英文、数字和下划线且不能以下划线开头',
+  nameMessage: "只能包含中文、英文、数字和下划线且不能以下划线开头",
   url: /([hH][tT]{2}[pP]:\/\/|[hH][tT]{2}[pP][sS]:\/\/|[wW]{3}.|[wW][aA][pP].|[fF][tT][pP].|[fF][iI][lL][eE].)[-A-Za-z0-9+&@#\/%?=~_|!:,.;]+[-A-Za-z0-9+&@#\/%=~_|]/,
-  urlMessage: '请输入正确地址'
-}
+  urlMessage: "请输入正确地址",
+};

+ 272 - 111
src/views/organizationManagement/components/organizationHome.vue

@@ -14,7 +14,10 @@
         <div class="status1"><span class="icon"></span>集团内</div>
         <div class="status2"><span class="icon"></span>集团外</div>
       </div>
-      <Search @getSearchData="getSearchData" @clearSearchData="clearSearchData" />
+      <Search
+        @getSearchData="getSearchData"
+        @clearSearchData="clearSearchData"
+      />
     </div>
     <!--权限树-->
     <div class="authority-content">
@@ -24,8 +27,23 @@
           <div class="grid-content">
             <div class="title">组织树</div>
             <div class="contentTree">
-              <el-tree ref="tree" :data="dataListTree" :props="defaultProps" node-key="OrganId" :filter-node-method="filterNode" highlight-current :default-expanded-keys="expandedKeys" @node-expand="handleExpand" @node-collapse="handleCollapse" @node-click="handleNodeClick">
-                <span slot-scope="{ node }" :title="node.label" class="custom-tree-node">
+              <el-tree
+                ref="tree"
+                :data="dataListTree"
+                :props="defaultProps"
+                node-key="OrganId"
+                :filter-node-method="filterNode"
+                highlight-current
+                :default-expanded-keys="expandedKeys"
+                @node-expand="handleExpand"
+                @node-collapse="handleCollapse"
+                @node-click="handleNodeClick"
+              >
+                <span
+                  slot-scope="{ node }"
+                  :title="node.label"
+                  class="custom-tree-node"
+                >
                   {{ node.label }}
                 </span>
               </el-tree>
@@ -36,33 +54,79 @@
           <div class="grid-contentTop">
             <div class="title">当前组织</div>
             <div class="content">
-              <el-empty :image-size="100" style="padding:0" v-if="currDataArr.length<1"></el-empty>
+              <el-empty
+                :image-size="100"
+                style="padding: 0"
+                v-if="currDataArr.length < 1"
+              ></el-empty>
               <el-row>
-                <el-col :span="8" v-for="data in currDataArr" :key="data.OrganId">
+                <el-col
+                  :span="8"
+                  v-for="data in currDataArr"
+                  :key="data.OrganId"
+                >
                   <div class="itemBox">
                     <div class="status" v-if="data.OrganType == 1"></div>
                     <div class="status2" v-if="data.OrganType != 1"></div>
                     <el-row :gutter="24">
                       <el-col :span="12">
-                        <div :title="data.OrganName" class="itemTitle">{{ data.OrganName }}</div>
+                        <div :title="data.OrganName" class="itemTitle">
+                          {{ data.OrganName }}
+                        </div>
                       </el-col>
                       <el-col :span="12">
                         <div class="flex info">
                           <div class="icon">
-                            <el-tooltip v-if="doesJobShow" v-is="['organtree_btn_add_job']" effect="dark" content="新增职务" placement="bottom">
-                              <span class="cap cap-job" @click="renderJob(data)" v-if="data.OrganId != -1"></span>
+                            <el-tooltip
+                              v-if="doesJobShow"
+                              v-is="['organtree_btn_add_job']"
+                              effect="dark"
+                              content="新增职务"
+                              placement="bottom"
+                            >
+                              <span
+                                class="cap cap-job"
+                                @click="renderJob(data)"
+                                v-if="data.OrganId != -1"
+                              ></span>
                             </el-tooltip>
 
-                            <el-tooltip v-is="['organtree_btn_add_officer']" effect="dark" content="新增职员" placement="bottom">
-                              <span v-if="data.OrganId != -1" class="cap cap-member" @click="renderMember(data)"></span>
+                            <el-tooltip
+                              v-is="['organtree_btn_add_officer']"
+                              effect="dark"
+                              content="新增职员"
+                              placement="bottom"
+                            >
+                              <span
+                                v-if="data.OrganId != -1"
+                                class="cap cap-member"
+                                @click="renderMember(data)"
+                              ></span>
                             </el-tooltip>
 
-                            <el-tooltip v-is="['organtree_btn_update_organ']" effect="dark" content="编辑组织" placement="bottom">
-                              <span class="cap cap-edit" @click="renderEdit(data)" v-if="data.OrganId != -1"></span>
+                            <el-tooltip
+                              v-is="['organtree_btn_update_organ']"
+                              effect="dark"
+                              content="编辑组织"
+                              placement="bottom"
+                            >
+                              <span
+                                class="cap cap-edit"
+                                @click="renderEdit(data)"
+                                v-if="data.OrganId != -1"
+                              ></span>
                             </el-tooltip>
 
-                            <el-tooltip v-is="['organtree_btn_add_organ']" effect="dark" content="新增组织" placement="bottom">
-                              <span class="cap cap-sub" @click="renderAdd(data)"></span>
+                            <el-tooltip
+                              v-is="['organtree_btn_add_organ']"
+                              effect="dark"
+                              content="新增组织"
+                              placement="bottom"
+                            >
+                              <span
+                                class="cap cap-sub"
+                                @click="renderAdd(data)"
+                              ></span>
                             </el-tooltip>
                           </div>
                         </div>
@@ -96,10 +160,20 @@
                       <el-col :span="12" v-if="data.OrganId != -1">
                         <span class="msg">状态:</span>
                         <span class="use" v-if="data.Status == '1'">启用</span>
-                        <span class="unUse" v-if="data.Status != '1'">禁用</span>
+                        <span class="unUse" v-if="data.Status != '1'"
+                          >禁用</span
+                        >
                       </el-col>
-                      <el-col v-is="['organtree_btn_state_switch']" :span="12" v-if="data.OrganId != -1">
-                        <el-switch active-color="#6F81BC" v-model="data.flag" @change="renderChange(data)"></el-switch>
+                      <el-col
+                        v-is="['organtree_btn_state_switch']"
+                        :span="12"
+                        v-if="data.OrganId != -1"
+                      >
+                        <el-switch
+                          active-color="#6F81BC"
+                          v-model="data.flag"
+                          @change="renderChange(data)"
+                        ></el-switch>
                       </el-col>
                     </el-row>
                   </div>
@@ -110,10 +184,21 @@
           <div class="grid-contentBottom">
             <div class="title">下级组织</div>
             <div class="content">
-              <el-empty :image-size="150" v-if="childrenData.length<1"></el-empty>
+              <el-empty
+                :image-size="150"
+                v-if="childrenData.length < 1"
+              ></el-empty>
               <el-row :gutter="24">
-                <el-col :span="8" v-for="(data, index) in childrenData" :key="data.OrganId">
-                  <div v-is="['organtree_btn_del_organ']" class="info-close" @click="onNodeClick(data)">
+                <el-col
+                  :span="8"
+                  v-for="(data, index) in childrenData"
+                  :key="data.OrganId"
+                >
+                  <div
+                    v-is="['organtree_btn_del_organ']"
+                    class="info-close"
+                    @click="onNodeClick(data)"
+                  >
                     <i class="el-icon-close"></i>
                   </div>
                   <div class="itemBox" @click.stop="childrenClick(data)">
@@ -121,25 +206,63 @@
                     <div class="status2" v-if="data.OrganType != 1"></div>
                     <el-row>
                       <el-col :span="12">
-                        <div :title="data.OrganName" class="itemTitle">{{ data.OrganName }}</div>
+                        <div :title="data.OrganName" class="itemTitle">
+                          {{ data.OrganName }}
+                        </div>
                       </el-col>
                       <el-col :span="12">
                         <div class="flex info">
                           <div class="icon">
-                            <el-tooltip v-if="doesJobShow" v-is="['organtree_btn_add_job']" effect="dark" content="新增职务" placement="bottom">
-                              <span class="cap cap-job" @click.stop="renderJob(data)" v-if="data.OrganId != -1"></span>
+                            <el-tooltip
+                              v-if="doesJobShow"
+                              v-is="['organtree_btn_add_job']"
+                              effect="dark"
+                              content="新增职务"
+                              placement="bottom"
+                            >
+                              <span
+                                class="cap cap-job"
+                                @click.stop="renderJob(data)"
+                                v-if="data.OrganId != -1"
+                              ></span>
                             </el-tooltip>
 
-                            <el-tooltip v-is="['organtree_btn_add_officer']" effect="dark" content="新增职员" placement="bottom">
-                              <span v-if="data.OrganId != -1" class="cap cap-member" @click.stop="renderMember(data)"></span>
+                            <el-tooltip
+                              v-is="['organtree_btn_add_officer']"
+                              effect="dark"
+                              content="新增职员"
+                              placement="bottom"
+                            >
+                              <span
+                                v-if="data.OrganId != -1"
+                                class="cap cap-member"
+                                @click.stop="renderMember(data)"
+                              ></span>
                             </el-tooltip>
 
-                            <el-tooltip v-is="['organtree_btn_update_organ']" effect="dark" content="编辑组织" placement="bottom">
-                              <span class="cap cap-edit" @click.stop="renderEdit(data)" v-if="data.OrganId != -1"></span>
+                            <el-tooltip
+                              v-is="['organtree_btn_update_organ']"
+                              effect="dark"
+                              content="编辑组织"
+                              placement="bottom"
+                            >
+                              <span
+                                class="cap cap-edit"
+                                @click.stop="renderEdit(data)"
+                                v-if="data.OrganId != -1"
+                              ></span>
                             </el-tooltip>
 
-                            <el-tooltip v-is="['organtree_btn_add_organ']" effect="dark" content="新增组织" placement="bottom">
-                              <span class="cap cap-sub" @click.stop="renderAdd(data)"></span>
+                            <el-tooltip
+                              v-is="['organtree_btn_add_organ']"
+                              effect="dark"
+                              content="新增组织"
+                              placement="bottom"
+                            >
+                              <span
+                                class="cap cap-sub"
+                                @click.stop="renderAdd(data)"
+                              ></span>
                             </el-tooltip>
                           </div>
                         </div>
@@ -173,10 +296,21 @@
                       <el-col :span="12" v-if="data.OrganId != -1">
                         <span class="msg">状态:</span>
                         <span class="use" v-if="data.Status == '1'">启用</span>
-                        <span class="unUse" v-if="data.Status != '1'">禁用</span>
+                        <span class="unUse" v-if="data.Status != '1'"
+                          >禁用</span
+                        >
                       </el-col>
-                      <el-col v-is="['organtree_btn_state_switch']" :span="12" v-if="data.OrganId != -1">
-                        <el-switch active-color="#6F81BC" v-model="data.flag" @click.stop.native @change="childrenRenderChange(data, index)"></el-switch>
+                      <el-col
+                        v-is="['organtree_btn_state_switch']"
+                        :span="12"
+                        v-if="data.OrganId != -1"
+                      >
+                        <el-switch
+                          active-color="#6F81BC"
+                          v-model="data.flag"
+                          @click.stop.native
+                          @change="childrenRenderChange(data, index)"
+                        ></el-switch>
                       </el-col>
                     </el-row>
                   </div>
@@ -193,7 +327,9 @@
         <div class="title">删除组织</div>
         <div class="content">是否确认删除{{ title }}?</div>
         <div class="foot right t30">
-          <el-button size="medium" class="r24" @click="remove" type="danger">删除</el-button>
+          <el-button size="medium" class="r24" @click="remove" type="danger"
+            >删除</el-button
+          >
           <el-button size="medium" @click="flag = false">取消</el-button>
         </div>
       </div>
@@ -211,7 +347,7 @@ export default {
   name: "Authority",
   components: { Search, Dialog },
   mixins: [treeData],
-  data () {
+  data() {
     return {
       dataIndex: 1,
       dataNum: 0,
@@ -230,12 +366,12 @@ export default {
       dataListTree: [],
       currentKey: null,
       expandedKeys: [-1],
-      initCurrentKeyStep: [false, false]
+      initCurrentKeyStep: [false, false],
     };
   },
-  created () {
+  created() {
     let keyWords = "";
-    const treeEx = sessionStorage.getItem('orgExpandedKeys');
+    const treeEx = sessionStorage.getItem("orgExpandedKeys");
     if (this.$route.query.keyWords) {
       keyWords = this.$route.query.keyWords;
     }
@@ -244,9 +380,8 @@ export default {
     }
     this.getOrganTree(keyWords);
   },
-  mounted () {
-    this.initCurrentKeyStep.splice(1, 1, true)
-    
+  mounted() {
+    this.initCurrentKeyStep.splice(1, 1, true);
   },
   watch: {
     dataList: {
@@ -257,110 +392,119 @@ export default {
       deep: true,
     },
     currentKey: {
-      handler (val) {
-        if (typeof val === 'object' && !val) {
-          return
+      handler(val) {
+        if (typeof val === "object" && !val) {
+          return;
         }
         this.$nextTick(() => {
-          this.$refs.tree.setCurrentKey(val)
-          sessionStorage.setItem('orgCurrentKey', val)
-          this.setCards()
-        })
-      }
+          this.$refs.tree.setCurrentKey(val);
+          sessionStorage.setItem("orgCurrentKey", val);
+          this.setCards();
+        });
+      },
     },
     expandedKeys: {
       handler(arr) {
-        sessionStorage.setItem('orgExpandedKeys', JSON.stringify(arr))
+        sessionStorage.setItem("orgExpandedKeys", JSON.stringify(arr));
       },
-      deep: true
+      deep: true,
     },
     initCurrentKeyStep: {
       handler(arr) {
-        if (arr.every(item => item)) {
-          this.currentKey = Number(sessionStorage.getItem('orgCurrentKey') ?? -1)
+        if (arr.every((item) => item)) {
+          this.currentKey = Number(
+            sessionStorage.getItem("orgCurrentKey") ?? -1
+          );
         }
       },
-      deep: true
-    }
+      deep: true,
+    },
   },
   methods: {
-    filterNode (value, data) {
+    filterNode(value, data) {
       if (!value) return true;
       return data.OrganName.indexOf(value) !== -1;
     },
     // 添加组织
-    renderAdd (data) {
+    renderAdd(data) {
       this.$router.push({
         path: "/organization/organizationAdd",
         query: { OrganUpid: data.OrganUpid, OrganId: data.OrganId },
       });
     },
     // 新增职务
-    renderJob (data) {
+    renderJob(data) {
       this.$router.push({
         path: "/jobs/add",
         query: { OrganUpid: data.OrganUpid, OrganId: data.OrganId },
       });
     },
     // 新增职员
-    renderMember (data) {
+    renderMember(data) {
       this.$router.push({
         path: "/staff/staffAdd",
-        query: { OrganUpid: data.OrganUpid, OrganId: data.OrganId, orgType: 'org' },
+        query: {
+          OrganUpid: data.OrganUpid,
+          OrganId: data.OrganId,
+          orgType: "org",
+        },
       });
     },
     // 修改组织
-    renderEdit (data) {
+    renderEdit(data) {
       this.$router.push({
         path: "/organization/organizationEdit",
         query: { OrganUpid: data.OrganUpid, OrganId: data.OrganId },
       });
     },
     // 新增组织
-    renderSub (data) {
+    renderSub(data) {
       this.$router.push({
         path: "/organization/organizationAdd",
         query: { OrganUpid: data.OrganUpid, OrganId: data.OrganId },
       });
     },
     // 关闭开启
-    renderChange (data) {
+    renderChange(data) {
       const { OrganId, flag, OrganUpid } = data;
-      this.dataUpId = OrganUpid
+      this.dataUpId = OrganUpid;
       this.handleChange(OrganId, flag);
     },
     //下级关闭
-    childrenRenderChange (data, index) {
+    childrenRenderChange(data, index) {
       const { OrganId, flag, OrganUpid } = data;
-      this.dataUpId = OrganUpid
-      this.handleChange(OrganId, flag, index)
+      this.dataUpId = OrganUpid;
+      this.handleChange(OrganId, flag, index);
     },
     //删除组织
-    remove () {
+    remove() {
       this.deleteOrg(this.dataId);
     },
     //查询
-    getSearchData (val) {
+    getSearchData(val) {
       if (val) {
-        this.$router.replace({ path: '/organization', query: { keyWords: val } })
+        this.$router.replace({
+          path: "/organization",
+          query: { keyWords: val },
+        });
       } else if (this.$route.query) {
-        this.$router.replace('/organization')
+        this.$router.replace("/organization");
       }
       this.$refs.tree.filter(val);
     },
     //清除查询
-    clearSearchData () {
-      this.$router.replace('/organization')
+    clearSearchData() {
+      this.$router.replace("/organization");
       this.getOrganTree();
     },
     //节点关闭按钮点击
-    onNodeClick (data) {
+    onNodeClick(data) {
       this.flag = true;
       this.dataId = data.OrganId;
       this.title = data.OrganName;
     },
     //获取指定数据
-    decompose (value, key, id) {
+    decompose(value, key, id) {
       let data = _.cloneDeep(value);
       let arr = [];
       for (let i = 0; i < data.length; i++) {
@@ -374,41 +518,41 @@ export default {
 
     //-----------获取数据------------
     //应用状态变更
-    async handleChange (id, flag, index = 0, isChildren = false) {
-      const Status = flag ? 1 : 0
+    async handleChange(id, flag, index = 0, isChildren = false) {
+      const Status = flag ? 1 : 0;
       try {
         const res = await tissueTreeStart({
           OrganId: id,
-          Status: Status
+          Status: Status,
         });
         if (res.code === 0) {
           this.$message.success(res.message);
-          this.initCurrentKeyStep.splice(0, 1, false)
+          this.initCurrentKeyStep.splice(0, 1, false);
           if (this.currentKey === id) {
-            sessionStorage.setItem('orgCurrentKey', this.dataUpId)
+            sessionStorage.setItem("orgCurrentKey", this.dataUpId);
           } else {
-            this.currentKey = null
+            this.currentKey = null;
           }
-          this.getOrganTree()
+          this.getOrganTree();
         } else {
           this.$message.error(res.message);
           if (!isChildren) {
             this.currDataArr[index].flag = !flag;
           } else {
-            this.childrenData[index].flag = !flag
+            this.childrenData[index].flag = !flag;
           }
         }
       } catch (error) {
         console.log("出错了", error);
         if (!isChildren) {
-            this.currDataArr[index].flag = !flag;
-          } else {
-            this.childrenData[index].flag = !flag
-          }
+          this.currDataArr[index].flag = !flag;
+        } else {
+          this.childrenData[index].flag = !flag;
+        }
       }
     },
     //组织删除
-    async deleteOrg (id) {
+    async deleteOrg(id) {
       try {
         const res = await organele({
           OrganId: id,
@@ -416,8 +560,8 @@ export default {
         if (res.code === 0) {
           this.$message.success(res.message);
           this.flag = false;
-          this.initCurrentKeyStep.splice(0, 1, false)
-          this.currentKey = null
+          this.initCurrentKeyStep.splice(0, 1, false);
+          this.currentKey = null;
           this.getOrganTree();
         } else {
           this.flag = false;
@@ -428,53 +572,70 @@ export default {
       }
     },
     //树点击
-    handleNodeClick (data) {
+    handleNodeClick(data) {
       this.currentKey = data.OrganId;
     },
     //下级卡片点击
-    childrenClick (data) {
+    childrenClick(data) {
       this.currentKey = data.OrganId;
       if (!this.expandedKeys.includes(this.currentKey)) {
-        this.expandedKeys.push(this.currentKey)
+        this.expandedKeys.push(this.currentKey);
       }
     },
     // 根据选中节点获取卡片
     setCards() {
-      this.currDataArr = this.decompose(this.dataArr, "OrganId", this.currentKey);
-      this.childrenData = this.decompose(this.dataArr, "OrganUpid", this.currentKey);
+      this.currDataArr = this.decompose(
+        this.dataArr,
+        "OrganId",
+        this.currentKey
+      );
+      this.childrenData = this.decompose(
+        this.dataArr,
+        "OrganUpid",
+        this.currentKey
+      );
+      this.childrenData.sort((a, b) => b.organType - a.organType);
     },
     // 节点展开
-    handleExpand (obj) {
-      this.expandedKeys.push(obj.OrganId)
+    handleExpand(obj) {
+      this.expandedKeys.push(obj.OrganId);
     },
     // 节点收起
-    handleCollapse (obj) {
-      const { OrganId, children } = obj
-      children.length && this.collapseChilren(children)
-      this.expandedKeys = this.expandedKeys.filter(key => key !== OrganId)
+    handleCollapse(obj) {
+      const { OrganId, children } = obj;
+      children.length && this.collapseChilren(children);
+      this.expandedKeys = this.expandedKeys.filter((key) => key !== OrganId);
     },
     // 收起子节点
-    collapseChilren (children) {
-      children.forEach(child => {
-        const { OrganId, children } = child
-        children.length && this.collapseChilren(children)
-        this.expandedKeys = this.expandedKeys.filter(key => key !== OrganId)
-      })
+    collapseChilren(children) {
+      children.forEach((child) => {
+        const { OrganId, children } = child;
+        children.length && this.collapseChilren(children);
+        this.expandedKeys = this.expandedKeys.filter((key) => key !== OrganId);
+      });
     },
     //岗位点击
-    toJob (data) {
+    toJob(data) {
       this.$router.push({
         path: "/jobs",
-        query: { OrganUpid: data.OrganUpid, OrganId: data.OrganId, orgType: 'org' },
+        query: {
+          OrganUpid: data.OrganUpid,
+          OrganId: data.OrganId,
+          orgType: "org",
+        },
       });
     },
     //职员点击
-    toOfficer (data) {
+    toOfficer(data) {
       this.$router.push({
         path: "/staff",
-        query: { OrganUpid: data.OrganUpid, OrganId: data.OrganId, orgType: 'org' },
+        query: {
+          OrganUpid: data.OrganUpid,
+          OrganId: data.OrganId,
+          orgType: "org",
+        },
       });
-    }
+    },
   },
 };
 </script>