organizManage.vue 54 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714
  1. <template>
  2. <div class="organizManage-main">
  3. <div class="organizManage-mainLeft">
  4. <div class="public-function-div">
  5. 机构树
  6. <el-button
  7. @click="orgShowHidden"
  8. type="success"
  9. size="small"
  10. class="orgShowHidden"
  11. >{{ isAllDataShow ? "显示停用组织" : "隐藏停用组织" }}</el-button
  12. >
  13. <el-button
  14. @click="controllNode()"
  15. type="success"
  16. size="small"
  17. class="refresh"
  18. >{{ isSpread ? "展开" : "收起" }}</el-button
  19. >
  20. <el-button
  21. @click="handleReset('formItem')"
  22. type="primary"
  23. size="small"
  24. class="_refresh3"
  25. v-privilege="activeMenu + 'ADD'"
  26. >新增顶级</el-button
  27. >
  28. </div>
  29. <el-input
  30. placeholder="输入关键字进行过滤"
  31. class="filterTree"
  32. v-model="filterText"
  33. >
  34. </el-input>
  35. <el-tree
  36. ref="orgTree"
  37. :data="orgTree"
  38. :props="defaultProps"
  39. node-key="orgId"
  40. @node-expand="nodeExpand"
  41. @node-click="nodeClick"
  42. :expand-on-click-node="true"
  43. :style="{ height: treeHeight + 'px' }"
  44. :filter-node-method="filterOrgTree"
  45. v-loading="treeLoading"
  46. >
  47. <span class="custom-tree-node" slot-scope="{ node, data }">
  48. <span>{{ node.label }}</span>
  49. <span class="nodeOperate">
  50. <el-dropdown @command="handleCommand">
  51. <span class="el-dropdown-link">
  52. <i
  53. class="el-icon-arrow-down icore-icon-size"
  54. style="color: #111; background-color: #61f06e"
  55. ></i>
  56. </span>
  57. <el-dropdown-menu slot="dropdown">
  58. <el-row>
  59. <el-dropdown-item
  60. :command="{ str: 'add', node: node, data: data }"
  61. class="el-icon-plus addMenuPr"
  62. >添加</el-dropdown-item
  63. >
  64. </el-row>
  65. <el-row>
  66. <el-dropdown-item
  67. :command="{ str: 'delete', node: node, data: data }"
  68. class="el-icon-delete delMenuPr"
  69. >删除</el-dropdown-item
  70. >
  71. </el-row>
  72. <el-row v-show="data.status === '0'">
  73. <el-dropdown-item
  74. :command="{ str: 'enable', node: node, data: data }"
  75. class="el-icon-share unlockMenuPr"
  76. >启用</el-dropdown-item
  77. >
  78. </el-row>
  79. <el-row v-show="data.status === '1'">
  80. <el-dropdown-item
  81. :command="{ str: 'disable', node: node, data: data }"
  82. class="el-icon-remove lockMenuPr"
  83. >停用</el-dropdown-item
  84. >
  85. </el-row>
  86. <el-row>
  87. <el-dropdown-item
  88. :command="{ str: 'up', node: node, data: data }"
  89. class="el-icon-upload2 upMenuPr"
  90. >上移</el-dropdown-item
  91. >
  92. </el-row>
  93. <el-row>
  94. <el-dropdown-item
  95. :command="{ str: 'down', node: node, data: data }"
  96. class="el-icon-download downMenuPr"
  97. >下移</el-dropdown-item
  98. >
  99. </el-row>
  100. <el-row>
  101. <el-dropdown-item
  102. :command="{ str: 'left', node: node, data: data }"
  103. v-if="node.level > 1"
  104. class="el-icon-d-arrow-left leftMenuPr"
  105. >左移</el-dropdown-item
  106. >
  107. </el-row>
  108. <el-row>
  109. <el-dropdown-item
  110. :command="{ str: 'right', node: node, data: data }"
  111. v-if="
  112. node.level === 1 && node === node.parent.childNodes[0]
  113. ? false
  114. : true
  115. "
  116. class="el-icon-d-arrow-right rightMenuPr"
  117. >右移</el-dropdown-item
  118. >
  119. </el-row>
  120. </el-dropdown-menu>
  121. </el-dropdown>
  122. </span>
  123. </span>
  124. </el-tree>
  125. </div>
  126. <div class="organizManage-mainRight">
  127. <div class="public-function-div">编辑区</div>
  128. <el-form
  129. ref="formItem"
  130. :model="formItem"
  131. :rules="ruleValidate"
  132. label-width="80px"
  133. class="FormorganizManage-main"
  134. >
  135. <el-row>
  136. <el-col :span="12">
  137. <el-form-item label="父机构" prop="pName">
  138. <el-input
  139. v-model="formItem.pName"
  140. disabled
  141. size="small"
  142. style="vertical-align: top"
  143. >
  144. <el-button slot="append" @click="handleReset('formItem')"
  145. >清空</el-button
  146. >
  147. </el-input>
  148. </el-form-item>
  149. <el-form-item label="机构id" prop="orgId" style="display: none">
  150. <el-input
  151. v-model="formItem.orgId"
  152. placeholder="请输入"
  153. disabled
  154. size="small"
  155. ></el-input>
  156. </el-form-item>
  157. </el-col>
  158. <el-col :span="12">
  159. <el-form-item label="机构编码" prop="orgCode">
  160. <el-input
  161. v-model="formItem.orgCode"
  162. placeholder="请输入"
  163. :disabled="!(operateStatus === 'add')"
  164. size="small"
  165. ></el-input>
  166. </el-form-item>
  167. </el-col>
  168. <el-col :span="12">
  169. <el-form-item label="机构名称" prop="orgName">
  170. <el-input
  171. v-model="formItem.orgName"
  172. placeholder="请输入"
  173. size="small"
  174. ></el-input>
  175. </el-form-item>
  176. </el-col>
  177. <el-col :span="12">
  178. <el-form-item label="岗位(负责)" prop="dutys">
  179. <el-select
  180. v-model="formItem.dutys"
  181. placeholder="请选择职务"
  182. size="small"
  183. multiple
  184. clearable
  185. style="width: 100%"
  186. >
  187. <el-option
  188. v-for="item in dutyList"
  189. :key="item.dutyId"
  190. :label="item.dutyName"
  191. :value="item.dutyId"
  192. >
  193. </el-option>
  194. </el-select>
  195. </el-form-item>
  196. </el-col>
  197. <el-col :span="12">
  198. <el-form-item label="部门分类" prop="depType">
  199. <el-select
  200. v-model="formItem.depType"
  201. placeholder="请选择部门分类"
  202. size="small"
  203. clearable
  204. style="width: 100%"
  205. >
  206. <el-option
  207. v-for="(item, index) in depTypeList"
  208. :key="item.dictCode + index"
  209. :label="item.dictName"
  210. :value="item.dictCode"
  211. >
  212. </el-option>
  213. </el-select>
  214. </el-form-item>
  215. </el-col>
  216. <el-col :span="24">
  217. <el-form-item label="备注" prop="remark">
  218. <el-input
  219. v-model="formItem.remark"
  220. placeholder="请输入"
  221. type="textarea"
  222. :autosize="{ minRows: 3, maxRows: 5 }"
  223. style="width: 100%"
  224. ></el-input>
  225. </el-form-item>
  226. </el-col>
  227. </el-row>
  228. <el-form-item>
  229. <el-button
  230. size="small"
  231. v-show="operateStatus === 'edit'"
  232. style="float: right"
  233. type="primary"
  234. @click="handleSubmit('formItem')"
  235. v-privilege="activeMenu + 'EDIT'"
  236. :loading="addLoading1"
  237. >保存
  238. </el-button>
  239. <el-button
  240. size="small"
  241. v-show="operateStatus === 'add'"
  242. style="float: right"
  243. type="primary"
  244. @click="handleSubmit('formItem')"
  245. v-privilege="activeMenu + 'ADD'"
  246. :loading="addLoading2"
  247. >添加
  248. </el-button>
  249. </el-form-item>
  250. </el-form>
  251. </div>
  252. </div>
  253. </template>
  254. <script>
  255. import store from "@/store/index.js";
  256. import dataDictionary from "@/store/dataDictionary.js";
  257. import {
  258. checkCharLength,
  259. checkCharLength2,
  260. checkCharNoChinese,
  261. checkTel,
  262. checkEmail,
  263. checkNumber,
  264. checkChar,
  265. } from "@/utils/validator.js";
  266. import { objAssign, dgTree } from "@/utils/util.js";
  267. import { proPath } from "@/config/config.js";
  268. export default {
  269. data() {
  270. return {
  271. companys: [], // 用户公司列表
  272. companyId: "", // 选择公司Id
  273. companyName: "", // 选择公司名称
  274. filterText: "",
  275. store,
  276. dataDictionary,
  277. addLoading1: false,
  278. addLoading2: false,
  279. treeLoading: false,
  280. operateStatus: "add",
  281. treeHeight: 600,
  282. formItem: {
  283. orgId: "",
  284. pId: "",
  285. pName: "",
  286. pCode: "",
  287. pDeptId: "",
  288. pDeptCode: "",
  289. cate: "",
  290. orgCode: "",
  291. dutys: [],
  292. orgName: "",
  293. qrCode: "",
  294. orgBrief: "",
  295. contact: "",
  296. pathName: "",
  297. tel: "",
  298. citycode: "",
  299. officeAddr: "",
  300. country: "",
  301. email: "",
  302. remark: "",
  303. post: "",
  304. status: "1",
  305. isVirtual: "",
  306. companyId: "",
  307. depType: "",
  308. },
  309. activeMenu: "",
  310. ruleValidate: {
  311. orgCode: [
  312. { required: true, message: "机构编码不能为空", trigger: "change" },
  313. { validator: checkCharLength, max: 32, trigger: "change" },
  314. { validator: checkCharNoChinese, trigger: "change" },
  315. ],
  316. orgName: [
  317. { required: true, message: "机构名称不能为空", trigger: "change" },
  318. { validator: checkChar, trigger: "change" },
  319. { validator: checkCharLength, max: 240, trigger: "change" },
  320. ],
  321. cate: [
  322. { required: true, message: "机构类别不能为空", trigger: "change" },
  323. ],
  324. remark: [
  325. { validator: checkCharLength2, max: 300, trigger: "change" },
  326. { validator: checkChar, trigger: "change" },
  327. ],
  328. tel: [
  329. { validator: checkNumber, trigger: "change" },
  330. { validator: checkTel, trigger: "change" },
  331. { validator: checkCharLength2, max: 11, trigger: "change" },
  332. ],
  333. email: [
  334. { validator: checkEmail, trigger: "change" },
  335. { validator: checkCharLength2, max: 100, trigger: "change" },
  336. ],
  337. contact: [{ validator: checkCharLength2, max: 100, trigger: "change" }],
  338. orgBrief: [
  339. { validator: checkCharLength2, max: 100, trigger: "change" },
  340. ],
  341. officeAddr: [
  342. { validator: checkCharLength2, max: 100, trigger: "change" },
  343. ],
  344. post: [
  345. { validator: checkNumber, trigger: "change" },
  346. {
  347. validator: checkCharLength2,
  348. max: 6,
  349. message: "请输入正确的邮政编码",
  350. trigger: "change",
  351. },
  352. ],
  353. depType: [
  354. { required: true, message: "机构分类不能为空", trigger: "change" },
  355. ],
  356. },
  357. dutyList: [], // 机构关联职级
  358. oldDutyList: [], // 原有职务信息
  359. isSpread: true,
  360. isAllDataShow: true,
  361. depTypeList: [],
  362. };
  363. },
  364. watch: {
  365. filterText(val) {
  366. this.$refs.orgTree.filter(val);
  367. },
  368. },
  369. computed: {
  370. // 菜单树数据
  371. orgTree() {
  372. let orgTree = this.store.state.system.organizManage.tree;
  373. // 页面筛选注释掉
  374. // let orgTree = this.companyId !== '' ? this.getTreeAll(_orgTree, this.companyId) : _orgTree;
  375. return orgTree;
  376. },
  377. // 树配置
  378. defaultProps() {
  379. return this.store.state.system.organizManage.defaultProps;
  380. },
  381. // 展开数组
  382. expandedKeys: {
  383. get: function () {
  384. return this.store.state.system.organizManage.expandedKeys;
  385. },
  386. set: function (data) {
  387. this.store.commit("system/organizManage/expandedKeys", data);
  388. },
  389. },
  390. // 选中节点数据
  391. orgItem() {
  392. return this.store.state.system.organizManage.item;
  393. },
  394. // 树配置
  395. formItemCate() {
  396. return this.store.state.system.organizManage.formItemCate;
  397. },
  398. // 是否虚机构
  399. formItemIsVirtual() {
  400. return this.store.state.system.organizManage.formItemIsVirtual;
  401. },
  402. },
  403. created() {
  404. this.activeMenu = window.top.localStorage.getItem("activeMenu");
  405. },
  406. mounted() {
  407. //移除表单自动校验
  408. this.$nextTick(() => {
  409. this.$refs["formItem"].clearValidate();
  410. });
  411. // 获取公司信息
  412. this.companys = JSON.parse(window.top.localStorage.getItem("companys"));
  413. this.companyId = window.top.localStorage.getItem("companyId");
  414. if (this.companyId !== "" && this.companyId !== null) {
  415. this.companyName = this.companys.find(
  416. (x) => x.id === this.companyId
  417. ).companyName;
  418. }
  419. this.initData();
  420. this.getDepType();
  421. // 设置树区域高度
  422. this.treeHeight = this.getTreeHeight(this.$refs["orgTree"].$el);
  423. },
  424. methods: {
  425. initData() {
  426. // 查询列表
  427. this.treeLoading = true;
  428. this.store
  429. .dispatch("system/organizManage/tree", this.companyId)
  430. .then((res) => {
  431. if (res.code === "0") {
  432. this.store.commit("system/organizManage/tree", res.data);
  433. this.$nextTick(() => {
  434. console.log('this.checkPrivilege(this.activeMenu + "UNLOCK")');
  435. console.log(this.activeMenu);
  436. console.log(this.checkPrivilege(this.activeMenu + "UNLOCK"));
  437. $(".delMenuPr").css(
  438. "display",
  439. this.checkPrivilege(this.activeMenu + "DELET")
  440. ? "inline-block"
  441. : "none"
  442. );
  443. $(".addMenuPr").css(
  444. "display",
  445. this.checkPrivilege(this.activeMenu + "ADD")
  446. ? "inline-block"
  447. : "none"
  448. );
  449. $(".unlockMenuPr").css(
  450. "display",
  451. this.checkPrivilege(this.activeMenu + "UNLOCK")
  452. ? "inline-block"
  453. : "none"
  454. );
  455. $(".lockMenuPr").css(
  456. "display",
  457. this.checkPrivilege(this.activeMenu + "LOCK")
  458. ? "inline-block"
  459. : "none"
  460. );
  461. $(".upMenuPr").css(
  462. "display",
  463. this.checkPrivilege(this.activeMenu + "EDIT")
  464. ? "inline-block"
  465. : "none"
  466. );
  467. $(".downMenuPr").css(
  468. "display",
  469. this.checkPrivilege(this.activeMenu + "EDIT")
  470. ? "inline-block"
  471. : "none"
  472. );
  473. $(".rightMenuPr").css(
  474. "display",
  475. this.checkPrivilege(this.activeMenu + "EDIT")
  476. ? "inline-block"
  477. : "none"
  478. );
  479. $(".leftMenuPr").css(
  480. "display",
  481. this.checkPrivilege(this.activeMenu + "EDIT")
  482. ? "inline-block"
  483. : "none"
  484. );
  485. $(".nodeOperate").css(
  486. "display",
  487. this.checkPrivilege(this.activeMenu + "MENUDELET") ||
  488. this.checkPrivilege(this.activeMenu + "MENUADD") ||
  489. this.checkPrivilege(this.activeMenu + "EDIT")
  490. ? "inline-block"
  491. : "none"
  492. );
  493. });
  494. this.treeLoading = false;
  495. } else {
  496. this.$message.error(res.message);
  497. this.treeLoading = false;
  498. }
  499. });
  500. this.getDutyList();
  501. },
  502. // 下拉选择公司
  503. selectComPany(command) {
  504. this.companyId = command.id;
  505. this.companyName = command.companyName;
  506. this.initData();
  507. },
  508. // 获取职务
  509. getDutyList() {
  510. let form = {
  511. pageNum: 1,
  512. pageSize: 100000,
  513. companyId: this.companyId,
  514. };
  515. this.axios
  516. .get("pass/v1/sysdutys/", { params: form })
  517. .then((res) => {
  518. if (res.code === "0") {
  519. this.dutyList = res.data.list;
  520. } else {
  521. this.$message.error(res.message);
  522. }
  523. })
  524. .catch((err) => {
  525. console.log(err);
  526. });
  527. },
  528. getUserOldDuty(val) {
  529. let form = {
  530. pageNum: 1,
  531. pageSize: 100000,
  532. companyId: this.companyId,
  533. resourceId: this.formItem.orgId,
  534. resourceType: "2",
  535. };
  536. this.axios
  537. .get("pass/v1/sysuserdutys/", { params: form })
  538. .then((res) => {
  539. if (res.code === "0") {
  540. this.oldDutyList = res.data.list;
  541. } else {
  542. this.$message.error(res.message);
  543. }
  544. })
  545. .catch((err) => {
  546. console.log(err);
  547. });
  548. },
  549. // 遍历树获取相应公司菜单
  550. getTreeAll(tree, id) {
  551. let arr = [];
  552. if (!!tree && tree.length !== 0) {
  553. tree.forEach((item) => {
  554. let obj = {};
  555. obj = { ...item };
  556. if (obj.hasOwnProperty("companyId") && obj.companyId === id) {
  557. obj.children = this.getTreeAll(item.children);
  558. arr.push(obj);
  559. }
  560. });
  561. }
  562. return arr;
  563. },
  564. nodeExpand() {
  565. this.$nextTick(() => {
  566. $(".delMenuPr").css(
  567. "display",
  568. this.checkPrivilege(this.activeMenu + "DELET")
  569. ? "inline-block"
  570. : "none"
  571. );
  572. $(".addMenuPr").css(
  573. "display",
  574. this.checkPrivilege(this.activeMenu + "ADD") ? "inline-block" : "none"
  575. );
  576. $(".unlockMenuPr").css(
  577. "display",
  578. this.checkPrivilege(this.activeMenu + "UNLOCK")
  579. ? "inline-block"
  580. : "none"
  581. );
  582. $(".lockMenuPr").css(
  583. "display",
  584. this.checkPrivilege(this.activeMenu + "LOCK")
  585. ? "inline-block"
  586. : "none"
  587. );
  588. $(".upMenuPr").css(
  589. "display",
  590. this.checkPrivilege(this.activeMenu + "EDIT")
  591. ? "inline-block"
  592. : "none"
  593. );
  594. $(".downMenuPr").css(
  595. "display",
  596. this.checkPrivilege(this.activeMenu + "EDIT")
  597. ? "inline-block"
  598. : "none"
  599. );
  600. $(".rightMenuPr").css(
  601. "display",
  602. this.checkPrivilege(this.activeMenu + "EDIT")
  603. ? "inline-block"
  604. : "none"
  605. );
  606. $(".leftMenuPr").css(
  607. "display",
  608. this.checkPrivilege(this.activeMenu + "EDIT")
  609. ? "inline-block"
  610. : "none"
  611. );
  612. $(".nodeOperate").css(
  613. "display",
  614. this.checkPrivilege(this.activeMenu + "MENUDELET") ||
  615. this.checkPrivilege(this.activeMenu + "MENUADD") ||
  616. this.checkPrivilege(this.activeMenu + "EDIT")
  617. ? "inline-block"
  618. : "none"
  619. );
  620. });
  621. },
  622. // 点击树事件
  623. nodeClick(item, el) {
  624. // 放入
  625. this.store.commit("system/organizManage/item", item);
  626. // 清空
  627. this.$refs["formItem"].resetFields();
  628. this.getOrgInfo(item.id, el);
  629. this.getOrgOldDuty(item.id);
  630. // 点击时为编辑状态
  631. this.operateStatus = "edit";
  632. this.$nextTick(() => {
  633. $(".delMenuPr").css(
  634. "display",
  635. this.checkPrivilege(this.activeMenu + "DELET")
  636. ? "inline-block"
  637. : "none"
  638. );
  639. $(".addMenuPr").css(
  640. "display",
  641. this.checkPrivilege(this.activeMenu + "ADD") ? "inline-block" : "none"
  642. );
  643. $(".unlockMenuPr").css(
  644. "display",
  645. this.checkPrivilege(this.activeMenu + "UNLOCK")
  646. ? "inline-block"
  647. : "none"
  648. );
  649. $(".lockMenuPr").css(
  650. "display",
  651. this.checkPrivilege(this.activeMenu + "LOCK")
  652. ? "inline-block"
  653. : "none"
  654. );
  655. $(".upMenuPr").css(
  656. "display",
  657. this.checkPrivilege(this.activeMenu + "EDIT")
  658. ? "inline-block"
  659. : "none"
  660. );
  661. $(".downMenuPr").css(
  662. "display",
  663. this.checkPrivilege(this.activeMenu + "EDIT")
  664. ? "inline-block"
  665. : "none"
  666. );
  667. $(".rightMenuPr").css(
  668. "display",
  669. this.checkPrivilege(this.activeMenu + "EDIT")
  670. ? "inline-block"
  671. : "none"
  672. );
  673. $(".leftMenuPr").css(
  674. "display",
  675. this.checkPrivilege(this.activeMenu + "EDIT")
  676. ? "inline-block"
  677. : "none"
  678. );
  679. $(".nodeOperate").css(
  680. "display",
  681. this.checkPrivilege(this.activeMenu + "MENUDELET") ||
  682. this.checkPrivilege(this.activeMenu + "MENUADD") ||
  683. this.checkPrivilege(this.activeMenu + "EDIT")
  684. ? "inline-block"
  685. : "none"
  686. );
  687. });
  688. },
  689. getOrgInfo(orgId, el) {
  690. this.axios
  691. .get("pass/v1/sysorgs/" + orgId)
  692. .then((res) => {
  693. if (res.code === "0") {
  694. // 加入
  695. this.formItem = objAssign(this.formItem, res.data);
  696. if (
  697. this.formItem.dutys !== null &&
  698. this.formItem.dutys.length > 0
  699. ) {
  700. let list = [];
  701. for (let duty of this.formItem.dutys) {
  702. list.push(duty.dutyId);
  703. }
  704. this.formItem.dutys = list;
  705. } else {
  706. this.formItem.dutys = [];
  707. }
  708. this.formItem.pName = el.parent.label;
  709. } else {
  710. this.$message.error(res.message);
  711. }
  712. })
  713. .catch((err) => {
  714. console.log(err);
  715. });
  716. },
  717. // 获取机构关联职务
  718. getOrgOldDuty(orgId) {
  719. let form = {
  720. pageNum: 1,
  721. pageSize: 100000,
  722. companyId: this.companyId,
  723. resourceId: orgId,
  724. resourceType: "2",
  725. };
  726. this.axios
  727. .get("pass/v1/sysuserdutys/", { params: form })
  728. .then((res) => {
  729. if (res.code === "0") {
  730. this.oldDutyList = res.data.list;
  731. } else {
  732. this.$message.error(res.message);
  733. }
  734. })
  735. .catch((err) => {
  736. console.log(err);
  737. });
  738. },
  739. addOrgDutys(orgId, list) {
  740. for (let item of list) {
  741. let form = {
  742. dutyId: item,
  743. resourceId: orgId,
  744. resourceType: "2",
  745. companyId: this.companyId,
  746. };
  747. this.axios
  748. .post("pass/v1/sysuserdutys/", form)
  749. .then((res) => {
  750. if (res.code === "0") {
  751. // do
  752. } else {
  753. this.$message.error("职务添加失败");
  754. }
  755. })
  756. .catch((err) => {
  757. console.log(err);
  758. });
  759. }
  760. },
  761. // 删除
  762. deleteOldDuty() {
  763. for (let item of this.oldDutyList) {
  764. this.axios
  765. .delete("pass/v1/sysuserdutys/" + item.id)
  766. .then((res) => {
  767. if (res.code === "0") {
  768. // do
  769. } else {
  770. this.$message.error(res.message);
  771. }
  772. })
  773. .catch((err) => {
  774. console.log(err);
  775. });
  776. }
  777. },
  778. // 清空 清空为添加,添加直接添加顶级目录
  779. handleReset(name) {
  780. this.$refs[name].resetFields();
  781. this.formItem.pName = "";
  782. this.operateStatus = "add";
  783. },
  784. // 添加点击
  785. addTreeNode(node, item) {
  786. this.operateStatus = "add";
  787. this.$refs["formItem"].resetFields();
  788. // 设置pId为当前ID
  789. this.formItem.pId = item.orgId;
  790. this.formItem.pName = item.orgName;
  791. // 机构类别:1-机构 0-部门
  792. if (item.cate === "1") {
  793. this.formItem.pId = item.orgId;
  794. this.formItem.pCode = item.orgCode;
  795. } else if (item.cate === "0") {
  796. this.formItem.pDeptId = item.orgId;
  797. this.formItem.pDeptCode = item.orgCode;
  798. }
  799. // 清空ID
  800. this.formItem.orgId = "";
  801. },
  802. // 计算树区域高度
  803. getTreeHeight(dom) {
  804. return window.innerHeight - dom.offsetTop;
  805. },
  806. // 节点上移
  807. nodeUp(node, data) {
  808. let that = this;
  809. console.log(node);
  810. console.log(data);
  811. let children = node.parent.childNodes;
  812. console.log(children);
  813. if (node === children[0]) {
  814. that.$message.error("已移至当前顶级,无法继续上移");
  815. } else {
  816. let node2 = {};
  817. for (let i = 0; i < children.length; i++) {
  818. if (node === children[i]) {
  819. node2 = children[i - 1];
  820. }
  821. }
  822. let changeList = [node.data, node2.data];
  823. console.log(changeList);
  824. this.store
  825. .dispatch("system/organizManage/dragOrg", {
  826. dropType: "before",
  827. changeList: changeList,
  828. })
  829. .then((res) => {
  830. console.log(res);
  831. if (res.code === "0") {
  832. this.$refs["orgTree"].remove(node.data.id);
  833. this.$refs["orgTree"].insertBefore(node.data, node2.data);
  834. this.$message.success("上移成功");
  835. } else {
  836. this.$message({ message: res.message, type: "error" });
  837. }
  838. });
  839. }
  840. },
  841. // 节点下移
  842. nodeDown(node, data) {
  843. let that = this;
  844. console.log(node);
  845. console.log(data);
  846. let children = node.parent.childNodes;
  847. console.log(children);
  848. let index = children.length;
  849. if (node === children[index - 1]) {
  850. that.$message.error("已移至当前底级,无法继续下移");
  851. } else {
  852. let node2 = {};
  853. for (let i = 0; i < children.length; i++) {
  854. if (node === children[i]) {
  855. node2 = children[i + 1];
  856. }
  857. }
  858. let changeList = [node.data, node2.data];
  859. console.log(changeList);
  860. this.store
  861. .dispatch("system/organizManage/dragOrg", {
  862. dropType: "after",
  863. changeList: changeList,
  864. })
  865. .then((res) => {
  866. if (res.code === "0") {
  867. this.$refs["orgTree"].remove(node.data.id);
  868. this.$refs["orgTree"].insertAfter(node.data, node2.data);
  869. this.$message.success("下移成功");
  870. } else {
  871. this.$message({ message: res.message, type: "error" });
  872. }
  873. });
  874. }
  875. },
  876. // 节点右移
  877. nodeRight(node, data) {
  878. let that = this;
  879. console.log(node);
  880. console.log(data);
  881. let children = node.parent.childNodes;
  882. console.log(children);
  883. if (node.level === 1 && node === children[0]) {
  884. that.$message.error("顶级第一个菜单不可降级!");
  885. } else if (children.length <= 1) {
  886. that.$message.error("此节点无同级节点以供降级!");
  887. } else if (children.length > 1) {
  888. let node2 = {};
  889. if (node === children[0]) {
  890. that.$message.error(
  891. "此节点位于同级中第一个,若要降级请先调整此节点顺序!"
  892. );
  893. } else {
  894. for (let i = 0; i < children.length; i++) {
  895. if (node === children[i]) {
  896. node2 = children[i - 1];
  897. if (node2.hasOwnProperty("data")) {
  898. // for (let j = 0; j < node2.data.children.length; j++){
  899. // if (node.data.orgName === node2.data.children[j].orgName) {
  900. // that.$message.error(node2.data.orgName + '中已有同名机构!');
  901. // } else if (node.data.orgCode === node2.data.children[j].orgCode) {
  902. // that.$message.error(node2.data.orgName + '中已有相同编码机构!')
  903. // }else {
  904. let changeList = [node.data, node2.data];
  905. console.log(changeList);
  906. this.store
  907. .dispatch("system/organizManage/dragOrg", {
  908. dropType: "right",
  909. changeList: changeList,
  910. })
  911. .then((res) => {
  912. if (res.code === "0") {
  913. this.$refs["orgTree"].remove(node.data.id);
  914. this.$refs["orgTree"].append(node.data, node2.data);
  915. this.$message.success("已降至前一个同级菜单中");
  916. } else {
  917. this.$message({ message: res.message, type: "error" });
  918. }
  919. });
  920. // }
  921. // }
  922. } else {
  923. that.$message.error(
  924. "未定义情景,请联系管理员添加前端右移逻辑代码!"
  925. );
  926. }
  927. }
  928. }
  929. }
  930. }
  931. },
  932. // 节点左移
  933. nodeLeft(node, data) {
  934. let that = this;
  935. console.log(node);
  936. console.log(data);
  937. let node2 = {};
  938. node2 = node.parent;
  939. if (node2.hasOwnProperty("data")) {
  940. // for (let i = 0; i < node2.parent.childNodes.length; i++) {
  941. // if (node.data.orgCode === node2.parent.childNodes[i].data.orgCode) {
  942. // that.$message.error(node.data.orgName + '同级中已有相同编码机构存在');
  943. // } else if (node.data.orgName === node2.parent.childNodes[i].data.orgName) {
  944. // that.$message.error(node.data.orgName + '同级中已有相同名称机构存在');
  945. // } else {
  946. let changeList = [node.data, node2.data];
  947. console.log(changeList);
  948. this.store
  949. .dispatch("system/organizManage/dragOrg", {
  950. dropType: "left",
  951. changeList: changeList,
  952. })
  953. .then((res) => {
  954. if (res.code === "0") {
  955. this.$refs["orgTree"].remove(node.data.id);
  956. this.$refs["orgTree"].insertAfter(node.data, node2.data);
  957. this.$message.success("已升至当前父菜单同级");
  958. } else {
  959. this.$message({ message: res.message, type: "error" });
  960. }
  961. });
  962. // }
  963. // }
  964. } else {
  965. that.$message.error("未定义情景,请联系管理员添加前端左移逻辑代码!");
  966. }
  967. },
  968. handleCommand(command) {
  969. let that = this,
  970. str = command.str,
  971. node = command.node,
  972. data = command.data;
  973. switch (str) {
  974. case "add":
  975. that.addTreeNode(node, data);
  976. break;
  977. case "delete":
  978. that.delTreeNode(node, data);
  979. break;
  980. case "up":
  981. that.nodeUp(node, data);
  982. break;
  983. case "down":
  984. that.nodeDown(node, data);
  985. break;
  986. case "left":
  987. that.nodeLeft(node, data);
  988. break;
  989. case "right":
  990. that.nodeRight(node, data);
  991. break;
  992. case "enable":
  993. that.updateMenuStatus(node, data, "enable");
  994. break;
  995. case "disable":
  996. that.updateMenuStatus(node, data, "disable");
  997. break;
  998. }
  999. },
  1000. // renderContent (h, { node, data, store }) {
  1001. // let render = [];
  1002. // render = [
  1003. // h('span', {
  1004. // class: 'el-icon-delete icore-icon-size delMenuPr',
  1005. // attrs: {
  1006. // title: '删除'
  1007. // },
  1008. // on: {
  1009. // click: (event) => {
  1010. // this.delTreeNode(node, data);
  1011. // event.stopPropagation();
  1012. // }
  1013. // }
  1014. // })
  1015. // ];
  1016. // // 如果是机构增加 添加按钮
  1017. // render = [h('span', {
  1018. // class: 'el-icon-plus icore-icon-size addMenuPr',
  1019. // attrs: {
  1020. // title: '添加'
  1021. // },
  1022. // on: {
  1023. // click: (event) => {
  1024. // this.addTreeNode(node, data);
  1025. // event.stopPropagation();
  1026. // }
  1027. // }
  1028. // })].concat(render);
  1029. // //下拉菜单
  1030. // // render = [h('span',{
  1031. // // label: '其他',
  1032. // // class: 'el-icon-arrow-down icore-icon-size',
  1033. // // attrs: {
  1034. // // title: '树节点上下左右移动操作'
  1035. // // },
  1036. // // })
  1037. // // ].concat(render)
  1038. // // 机构下移 下箭头按钮
  1039. // render = [h('span', {
  1040. // class: 'el-icon-download icore-icon-size downMenuPr',
  1041. // attrs: {
  1042. // title: '下移'
  1043. // },
  1044. // on: {
  1045. // click: (event) => {
  1046. // this.nodeDown(node, data);
  1047. // event.stopPropagation();
  1048. // }
  1049. // }
  1050. // })].concat(render);
  1051. // // 机构上移 上箭头按钮
  1052. // render = [h('span', {
  1053. // class: 'el-icon-upload2 icore-icon-size upMenuPr',
  1054. // attrs: {
  1055. // title: '上移'
  1056. // },
  1057. // on: {
  1058. // click: (event) => {
  1059. // this.nodeUp(node, data);
  1060. // event.stopPropagation();
  1061. // }
  1062. // }
  1063. // })].concat(render);
  1064. // if (node.level > 1) {
  1065. // // 降到下一级
  1066. // render = [h('span', {
  1067. // class: 'el-icon-right icore-icon-size rightMenuPr',
  1068. // attrs: {
  1069. // title: '降至后一级菜单'
  1070. // },
  1071. // on: {
  1072. // click: (event) => {
  1073. // this.nodeRight(node, data);
  1074. // event.stopPropagation();
  1075. // }
  1076. // }
  1077. // })].concat(render);
  1078. // // 升到上一级
  1079. // render = [h('span', {
  1080. // class: 'el-icon-back icore-icon-size leftMenuPr',
  1081. // style: "font-size: 16px;",
  1082. // attrs: {
  1083. // title: '升至前一级菜单'
  1084. // },
  1085. // on: {
  1086. // click: (event) => {
  1087. // this.nodeLeft(node, data);
  1088. // event.stopPropagation();
  1089. // }
  1090. // }
  1091. // })].concat(render);
  1092. // }
  1093. // return h('span',
  1094. // {
  1095. // style: {
  1096. // position: 'relative',
  1097. // width: '100%',
  1098. // fontSize: '12px'
  1099. // },
  1100. // class: 'og-st-ellipsis'
  1101. // },
  1102. // [
  1103. // h('span', node.label),
  1104. // h('span', {
  1105. // style: {
  1106. // position: 'absolute',
  1107. // right: '0px'
  1108. // }
  1109. // }, render)
  1110. // ]);
  1111. // },
  1112. /**
  1113. * 保存数据
  1114. * */
  1115. handleSubmit(name) {
  1116. this.$refs[name].validate((valid) => {
  1117. if (valid) {
  1118. if (this.operateStatus === "edit") {
  1119. if (!this.formItem.orgId) {
  1120. this.$message.error("请选择数据再来操作");
  1121. return;
  1122. }
  1123. this.$confirm("确定要修改已选择的记录吗?", "提示", {
  1124. confirmButtonText: "确定",
  1125. cancelButtonText: "取消",
  1126. type: "warning",
  1127. })
  1128. .then(() => {
  1129. // 修改数据
  1130. this.addLoading1 = true;
  1131. this.formItem.cate = 1;
  1132. this.formItem.companyId = this.companyId;
  1133. // 原有职务删除后重建
  1134. if (
  1135. this.formItem.dutys !== null &&
  1136. this.oldDutyList.length > 0
  1137. ) {
  1138. this.deleteOldDuty();
  1139. }
  1140. if (
  1141. this.formItem.dutys !== null &&
  1142. this.formItem.dutys.length > 0
  1143. ) {
  1144. this.addOrgDutys(this.formItem.orgId, this.formItem.dutys);
  1145. }
  1146. let data = JSON.parse(JSON.stringify(this.formItem));
  1147. for (let key in data) {
  1148. if (key === "dutys") {
  1149. delete data[key];
  1150. }
  1151. }
  1152. this.store
  1153. .dispatch("system/organizManage/editOrg", {
  1154. id: this.orgItem.id,
  1155. form: data,
  1156. })
  1157. .then((res) => {
  1158. this.addLoading1 = false;
  1159. //
  1160. if (res.code === "0") {
  1161. let pId = null;
  1162. if (res.data.pId) {
  1163. pId = res.data.pId;
  1164. }
  1165. let map = {
  1166. orgId: res.data.orgId,
  1167. depType: res.data.depType,
  1168. orgName: res.data.orgName,
  1169. pId: pId,
  1170. };
  1171. //调用物流系统的资源管理模块的接口,修改组织机构。
  1172. this.axios
  1173. .post("/api/v1/rms/updateShipperResult", map)
  1174. .then((res) => {
  1175. console.log(res, "物流修改成功");
  1176. if (res.data.code == "200") {
  1177. this.$message.success("保存成功");
  1178. } else {
  1179. this.store
  1180. .dispatch(
  1181. "system/organizManage/delOrg",
  1182. map.orgId
  1183. )
  1184. .then((res) => {
  1185. if (res.code === "0") {
  1186. this.$message.error("保存失败");
  1187. this.$router.go(0);
  1188. }
  1189. });
  1190. }
  1191. })
  1192. .catch((err) => {
  1193. this.store
  1194. .dispatch("system/organizManage/delOrg", map.orgId)
  1195. .then((res) => {
  1196. if (res.code === "0") {
  1197. this.$message.error("保存失败");
  1198. this.$router.go(0);
  1199. }
  1200. });
  1201. });
  1202. // // 更新菜单项
  1203. let tempItem = null;
  1204. dgTree(this.orgTree, "children", (item) => {
  1205. if (item.orgId === this.formItem.orgId) {
  1206. tempItem = item;
  1207. }
  1208. });
  1209. tempItem = Object.assign(tempItem, this.formItem);
  1210. this.store.commit(
  1211. "system/organizManage/tree",
  1212. this.orgTree
  1213. );
  1214. } else {
  1215. this.$message.error(res.message);
  1216. }
  1217. })
  1218. .catch((err) => {
  1219. console.log(err);
  1220. this.addLoading1 = false;
  1221. });
  1222. })
  1223. .catch((err) => {
  1224. console.log(err);
  1225. this.$message.info("已取消操作");
  1226. });
  1227. } else if (this.operateStatus === "add") {
  1228. // 添加
  1229. this.addLoading2 = true;
  1230. this.formItem.cate = 1;
  1231. this.formItem.companyId = this.companyId;
  1232. //
  1233. let data = JSON.parse(JSON.stringify(this.formItem));
  1234. for (let key in data) {
  1235. if (key === "dutys") {
  1236. delete data[key];
  1237. }
  1238. }
  1239. this.store
  1240. .dispatch("system/organizManage/addOrg", data)
  1241. .then((res) => {
  1242. //
  1243. this.addLoading2 = false;
  1244. //
  1245. if (res.code === "0") {
  1246. if (
  1247. this.formItem.dutys !== null &&
  1248. this.formItem.dutys.length > 0
  1249. ) {
  1250. this.addOrgDutys(res.data.orgId, this.formItem.dutys);
  1251. }
  1252. console.log(res, "sso添加成功");
  1253. let pId = null;
  1254. if (res.data.pId) {
  1255. pId = res.data.pId;
  1256. }
  1257. let map = {
  1258. orgId: res.data.orgId,
  1259. depType: res.data.depType,
  1260. orgName: res.data.orgName,
  1261. pId: pId,
  1262. orgCode:res.data.orgCode,
  1263. };
  1264. //调用物流系统的资源管理模块的接口,新增组织机构。
  1265. this.axios
  1266. .post("/api/v1/rms/addShipperResult", map)
  1267. .then((res) => {
  1268. console.log(res, "物流添加成功");
  1269. if (res.data.code == "200") {
  1270. this.$message.success("添加成功");
  1271. } else {
  1272. this.store
  1273. .dispatch("system/organizManage/delOrg", map.orgId)
  1274. .then((res) => {
  1275. if (res.code === "0") {
  1276. this.$message.error("新增失败");
  1277. this.$router.go(0);
  1278. }
  1279. });
  1280. }
  1281. })
  1282. .catch((err) => {
  1283. this.store
  1284. .dispatch("system/organizManage/delOrg", map.orgId)
  1285. .then((res) => {
  1286. if (res.code === "0") {
  1287. this.$message.error("新增失败");
  1288. this.$router.go(0);
  1289. }
  1290. });
  1291. });
  1292. // 更新树
  1293. this.$refs["orgTree"].append(res.data, this.formItem.pId);
  1294. this.$refs["orgTree"].setCurrentKey(res.data.id);
  1295. this.$nextTick(() => {
  1296. $(".delMenuPr").css(
  1297. "display",
  1298. this.checkPrivilege(this.activeMenu + "DELET")
  1299. ? "inline-block"
  1300. : "none"
  1301. );
  1302. $(".addMenuPr").css(
  1303. "display",
  1304. this.checkPrivilege(this.activeMenu + "ADD")
  1305. ? "inline-block"
  1306. : "none"
  1307. );
  1308. $(".unlockMenuPr").css(
  1309. "display",
  1310. this.checkPrivilege(this.activeMenu + "UNLOCK")
  1311. ? "inline-block"
  1312. : "none"
  1313. );
  1314. $(".lockMenuPr").css(
  1315. "display",
  1316. this.checkPrivilege(this.activeMenu + "LOCK")
  1317. ? "inline-block"
  1318. : "none"
  1319. );
  1320. $(".upMenuPr").css(
  1321. "display",
  1322. this.checkPrivilege(this.activeMenu + "EDIT")
  1323. ? "inline-block"
  1324. : "none"
  1325. );
  1326. $(".downMenuPr").css(
  1327. "display",
  1328. this.checkPrivilege(this.activeMenu + "EDIT")
  1329. ? "inline-block"
  1330. : "none"
  1331. );
  1332. $(".rightMenuPr").css(
  1333. "display",
  1334. this.checkPrivilege(this.activeMenu + "EDIT")
  1335. ? "inline-block"
  1336. : "none"
  1337. );
  1338. $(".leftMenuPr").css(
  1339. "display",
  1340. this.checkPrivilege(this.activeMenu + "EDIT")
  1341. ? "inline-block"
  1342. : "none"
  1343. );
  1344. $(".nodeOperate").css(
  1345. "display",
  1346. this.checkPrivilege(this.activeMenu + "MENUDELET") ||
  1347. this.checkPrivilege(this.activeMenu + "MENUADD") ||
  1348. this.checkPrivilege(this.activeMenu + "EDIT")
  1349. ? "inline-block"
  1350. : "none"
  1351. );
  1352. });
  1353. this.handleReset("formItem");
  1354. } else {
  1355. this.$message({ message: res.message, type: "error" });
  1356. }
  1357. })
  1358. .catch((err) => {
  1359. console.log(err);
  1360. this.addLoading2 = false;
  1361. });
  1362. }
  1363. }
  1364. });
  1365. },
  1366. /**
  1367. * 删除树节点元素
  1368. */
  1369. delTreeNode(node, data) {
  1370. if (data.orgId !== "924126339513061376" && data.orgId !== "924126716337721344") {
  1371. if (
  1372. (data.children && data.children.length > 0) ||
  1373. (node.childNodes && node.childNodes.length > 0)
  1374. ) {
  1375. this.$message.error("此节点有子节点,不允许删除");
  1376. return false;
  1377. }
  1378. //
  1379. this.$confirm("确定要删除已选择的记录吗?", "提示", {
  1380. customClass: "org-Manage-changeprimaryforbutton",
  1381. confirmButtonText: "确定",
  1382. cancelButtonText: "取消",
  1383. type: "warning",
  1384. })
  1385. .then(() => {
  1386. this.store
  1387. .dispatch("system/organizManage/delOrg", data.orgId)
  1388. .then((res) => {
  1389. if (res.code === "0") {
  1390. this.axios
  1391. .post("/api/v1/rms/deleteShipperResult", {
  1392. orgId: data.orgId,
  1393. })
  1394. .then((res) => {
  1395. console.log(res);
  1396. this.$message.success("删除成功");
  1397. });
  1398. // 更新树
  1399. this.handleReset("formItem");
  1400. console.log(node, node);
  1401. this.$refs["orgTree"].remove(node);
  1402. } else {
  1403. this.$message.error(res.message);
  1404. }
  1405. });
  1406. })
  1407. .catch(() => {
  1408. this.$message.info("已取消操作");
  1409. });
  1410. this.$nextTick(() => {
  1411. document
  1412. .getElementsByClassName("org-Manage-changeprimaryforbutton")[0]
  1413. .getElementsByClassName("el-message-box__btns")[0]
  1414. .getElementsByTagName("button")[0]
  1415. .classList.add("el-button--primary");
  1416. document
  1417. .getElementsByClassName("org-Manage-changeprimaryforbutton")[0]
  1418. .getElementsByClassName("el-message-box__btns")[0]
  1419. .getElementsByTagName("button")[1]
  1420. .classList.remove("el-button--primary");
  1421. });
  1422. }else{
  1423. this.$message.error("此组织为基础数据不能进行删除");
  1424. }
  1425. },
  1426. // 树形控件过滤数据
  1427. filterOrgTree(value, data) {
  1428. if (!value) return true;
  1429. return data.orgName.indexOf(value) !== -1;
  1430. },
  1431. setCheckedKeys() {
  1432. this.defaultExpand = false;
  1433. for (var i = 0; i < this.$refs.orgTree.store._getAllNodes().length; i++) {
  1434. this.$refs.orgTree.store._getAllNodes()[i].expanded =
  1435. this.defaultExpand;
  1436. }
  1437. },
  1438. setCheckedNodes() {
  1439. this.defaultExpand = true; // 展开所有节点
  1440. for (var i = 0; i < this.$refs.orgTree.store._getAllNodes().length; i++) {
  1441. this.$refs.orgTree.store._getAllNodes()[i].expanded =
  1442. this.defaultExpand;
  1443. }
  1444. },
  1445. orgShowHidden() {
  1446. this.treeLoading = true;
  1447. let status = this.isAllDataShow ? "0" : "1";
  1448. //console.log(status);
  1449. this.axios
  1450. .get(
  1451. proPath +
  1452. "v1/sysorgs/listtree?companyId=" +
  1453. this.companyId +
  1454. "&status=" +
  1455. status
  1456. )
  1457. .then((res) => {
  1458. if (res.code === "0") {
  1459. this.store.commit("system/organizManage/tree", res.data);
  1460. this.$nextTick(() => {
  1461. $(".delMenuPr").css(
  1462. "display",
  1463. this.checkPrivilege(this.activeMenu + "DELET")
  1464. ? "inline-block"
  1465. : "none"
  1466. );
  1467. $(".addMenuPr").css(
  1468. "display",
  1469. this.checkPrivilege(this.activeMenu + "ADD")
  1470. ? "inline-block"
  1471. : "none"
  1472. );
  1473. $(".unlockMenuPr").css(
  1474. "display",
  1475. this.checkPrivilege(this.activeMenu + "UNLOCK")
  1476. ? "inline-block"
  1477. : "none"
  1478. );
  1479. $(".lockMenuPr").css(
  1480. "display",
  1481. this.checkPrivilege(this.activeMenu + "LOCK")
  1482. ? "inline-block"
  1483. : "none"
  1484. );
  1485. $(".upMenuPr").css(
  1486. "display",
  1487. this.checkPrivilege(this.activeMenu + "EDIT")
  1488. ? "inline-block"
  1489. : "none"
  1490. );
  1491. $(".downMenuPr").css(
  1492. "display",
  1493. this.checkPrivilege(this.activeMenu + "EDIT")
  1494. ? "inline-block"
  1495. : "none"
  1496. );
  1497. $(".rightMenuPr").css(
  1498. "display",
  1499. this.checkPrivilege(this.activeMenu + "EDIT")
  1500. ? "inline-block"
  1501. : "none"
  1502. );
  1503. $(".leftMenuPr").css(
  1504. "display",
  1505. this.checkPrivilege(this.activeMenu + "EDIT")
  1506. ? "inline-block"
  1507. : "none"
  1508. );
  1509. $(".nodeOperate").css(
  1510. "display",
  1511. this.checkPrivilege(this.activeMenu + "MENUDELET") ||
  1512. this.checkPrivilege(this.activeMenu + "MENUADD") ||
  1513. this.checkPrivilege(this.activeMenu + "EDIT")
  1514. ? "inline-block"
  1515. : "none"
  1516. );
  1517. });
  1518. this.treeLoading = false;
  1519. } else {
  1520. this.$message.error(res.message);
  1521. this.treeLoading = false;
  1522. }
  1523. });
  1524. this.getDutyList();
  1525. this.isAllDataShow = !this.isAllDataShow;
  1526. },
  1527. controllNode() {
  1528. this.isSpread = !this.isSpread;
  1529. if (!this.isSpread) {
  1530. this.setCheckedNodes();
  1531. } else {
  1532. this.setCheckedKeys();
  1533. }
  1534. },
  1535. updateMenuStatus(node, data, status) {
  1536. this.$confirm("确定要修改已选择的记录吗?", "提示", {
  1537. confirmButtonText: "确定",
  1538. cancelButtonText: "取消",
  1539. type: "warning",
  1540. })
  1541. .then(() => {
  1542. // 修改数据
  1543. this.addLoading1 = true;
  1544. //
  1545. this.store
  1546. .dispatch("system/organizManage/editOrg", {
  1547. id: data.id,
  1548. form: {
  1549. orgName: data.orgName,
  1550. orgId: data.orgId,
  1551. orgCode: data.orgCode,
  1552. companyId: data.companyId,
  1553. status: status === "enable" ? "1" : "0",
  1554. },
  1555. })
  1556. .then((res) => {
  1557. this.addLoading1 = false;
  1558. if (res.code === "0") {
  1559. this.$message.success("修改成功");
  1560. this.isAllDataShow = true;
  1561. this.orgShowHidden();
  1562. // this.$refs["menuTree"].setCurrentKey(res.data.id);
  1563. } else {
  1564. this.$message({ message: res.message, type: "error" });
  1565. }
  1566. });
  1567. })
  1568. .catch(() => {
  1569. this.$message({
  1570. type: "info",
  1571. message: "已取消操作",
  1572. });
  1573. });
  1574. },
  1575. getDepType() {
  1576. this.axios
  1577. .get(proPath + "v1/sysdicts/dicttype/DEP_TYPE", {
  1578. params: {
  1579. companyId: this.companyId,
  1580. },
  1581. })
  1582. .then((res) => {
  1583. this.depTypeList = res.data || [];
  1584. });
  1585. },
  1586. },
  1587. };
  1588. </script>
  1589. <style scoped>
  1590. .og-st-ellipsis {
  1591. overflow: hidden;
  1592. text-overflow: ellipsis;
  1593. white-space: nowrap;
  1594. word-break: keep-all;
  1595. padding-right: 60px;
  1596. }
  1597. .organizManage-main {
  1598. position: relative;
  1599. min-width: 1000px;
  1600. /* height: 600px; */
  1601. }
  1602. .public-function-div {
  1603. font-size: 16px;
  1604. padding: 10px 20px;
  1605. border-bottom: 1px solid #d5d5d5;
  1606. position: relative;
  1607. }
  1608. .organizManage-mainLeft {
  1609. width: 30%;
  1610. border-right: 1px solid #e0e0e0;
  1611. float: left;
  1612. overflow: hidden;
  1613. height: inherit;
  1614. }
  1615. ._company-select {
  1616. padding: 10px 15px 9px 15px;
  1617. border-bottom: 1px solid #d5d5d5;
  1618. }
  1619. .el-dropdown {
  1620. font-weight: bold;
  1621. font-size: 14px;
  1622. cursor: pointer;
  1623. }
  1624. .el-dropdown-menu {
  1625. overflow-y: scroll;
  1626. max-height: 200px;
  1627. }
  1628. .el-tree {
  1629. overflow-x: hidden !important;
  1630. }
  1631. .el-icon-back:before {
  1632. content: "\E6EA";
  1633. }
  1634. .custom-tree-node {
  1635. flex: 1;
  1636. display: flex;
  1637. align-items: center;
  1638. justify-content: space-between;
  1639. font-size: 14px;
  1640. padding-right: 8px;
  1641. }
  1642. .organizManage-mainRight {
  1643. width: 70%;
  1644. float: left;
  1645. }
  1646. .FormorganizManage-main {
  1647. margin: 20px 20px;
  1648. }
  1649. .filterTree {
  1650. width: 95%;
  1651. margin: 10px 2.5%;
  1652. }
  1653. .el-tree-node__content .el-icon-plus {
  1654. margin-right: 20px;
  1655. }
  1656. .postionTop {
  1657. position: absolute;
  1658. top: 0px;
  1659. }
  1660. .public-function-div .refresh {
  1661. position: absolute;
  1662. right: 15px;
  1663. top: 10px;
  1664. }
  1665. .public-function-div .refresh2 {
  1666. position: absolute;
  1667. right: 80px;
  1668. top: 10px;
  1669. }
  1670. .public-function-div ._refresh3 {
  1671. position: absolute;
  1672. right: 80px;
  1673. top: 10px;
  1674. }
  1675. .orgShowHidden {
  1676. position: absolute;
  1677. right: 170px;
  1678. top: 10px;
  1679. }
  1680. .delMenuPr,
  1681. .upMenuPr,
  1682. .downMenuPr,
  1683. .rightMenuPr,
  1684. .leftMenuPr,
  1685. .addMenuPr,
  1686. .unlockMenuPr,
  1687. .lockMenuPr {
  1688. display: none;
  1689. }
  1690. .el-tree-node__content:hover {
  1691. background-color: #bbdffb;
  1692. }
  1693. .el-tree-node:focus .el-tree-node__content {
  1694. background-color: #bbdffb;
  1695. }
  1696. .el-tree .is-current .el-tree-node__content {
  1697. background-color: #bbdffb;
  1698. }
  1699. .is-current .el-tree-node__children .el-tree-node .el-tree-node__content {
  1700. background-color: #fff;
  1701. }
  1702. </style>