accountGroupHome.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  1. <!--
  2. * @Author: your name
  3. * @Date: 2022-01-08 09:27:43
  4. * @LastEditTime: 2022-03-01 10:27:23
  5. * @LastEditors: Please set LastEditors
  6. * @Description: 用户组管理
  7. * @FilePath: \Foshan4A2.0\src\views\accountGroupManagement\components\home.vue
  8. -->
  9. <template>
  10. <div class="accountGroup-home">
  11. <!--状态和搜索-->
  12. <div class="accountGroup-head flex">
  13. <div class="status flex-wrap"></div>
  14. <Search @getSearchData="getSearchData" @clearSearchData="clearSearchData" />
  15. </div>
  16. <!--账号树-->
  17. <div class="accountGroup-content">
  18. <!-- <OrgTree :dataList="dataList" :renderContent="renderContent" /> -->
  19. <el-row :gutter="24" class="bodyContent">
  20. <el-col :span="6" class="bodyPart">
  21. <div class="grid-content">
  22. <div class="title">岗位树</div>
  23. <div class="contentTree">
  24. <el-tree ref="tree" :data="dataListTree" :props="defaultProps" node-key="GroupId" :filter-node-method="filterNode" highlight-current :default-expanded-keys="[currentKey]" @node-click="handleNodeClick">
  25. </el-tree>
  26. </div>
  27. </div>
  28. </el-col>
  29. <el-col :span="18" class="bodyPart">
  30. <div class="grid-contentTop">
  31. <div class="title" style="margin-bottom: 15px">当前岗位</div>
  32. <div class="content">
  33. <el-empty :image-size="100" style="padding: 0" v-if="currDataArr.length < 1"></el-empty>
  34. <el-row>
  35. <el-col :span="8" v-for="data in currDataArr" :key="data.GroupId">
  36. <div class="itemBox">
  37. <el-row :gutter="24">
  38. <el-col :span="12">
  39. <div class="itemTitle">{{ data.GroupName }}</div>
  40. </el-col>
  41. <el-col :span="12">
  42. <div class="flex info">
  43. <div class="icon">
  44. <el-tooltip v-is="['grouptree_btn_update_group']" effect="dark" content="编辑岗位" placement="bottom">
  45. <span title="编辑岗位" class="cap cap-edit" @click="renderEdit(data)" v-if="data.GroupId != -1"></span>
  46. </el-tooltip>
  47. <el-tooltip v-is="['grouptree_btn_add_group']" effect="dark" content="新增岗位" placement="bottom">
  48. <span title="新增岗位" class="cap cap-sub" @click="renderAdd(data)"></span>
  49. </el-tooltip>
  50. </div>
  51. </div>
  52. </el-col>
  53. <!-- <el-col :span="8" v-if="data.GroupId != -1">
  54. <span class="msg">岗位:</span>
  55. <span>{{ data.JobCount }}</span>
  56. </el-col> -->
  57. <!-- <el-col :span="8" v-if="data.GroupId != -1">
  58. <span class="msg">职员:</span>
  59. <span>{{ data.OfficerCount }}</span>
  60. </el-col> -->
  61. <el-col :span="24" v-if="data.GroupId != -1">
  62. <span class="msg">账号数:</span>
  63. <span style="margin-right: 90px">{{
  64. data.UserCount
  65. }}</span>
  66. <span class="msg">权限数:</span>
  67. <span>{{ data.AuthCount }}</span>
  68. </el-col>
  69. <el-col :span="12" v-if="data.GroupId != -1">
  70. <span class="msg">状态:</span>
  71. <span class="use" v-if="data.Status == '1'">启用</span>
  72. <span class="unUse" v-if="data.Status != '1'">禁用</span>
  73. </el-col>
  74. <el-col v-is="['grouptree_btn_state_swatch']" :span="12" v-if="data.GroupId != -1">
  75. <el-switch active-color="#6F81BC" v-model="data.flag" @change="renderChange(data)"></el-switch>
  76. </el-col>
  77. </el-row>
  78. </div>
  79. </el-col>
  80. </el-row>
  81. </div>
  82. </div>
  83. <div class="grid-contentBottom">
  84. <div class="title">下级岗位</div>
  85. <div class="content">
  86. <el-empty :image-size="150" v-if="childrenData.length < 1"></el-empty>
  87. <el-row :gutter="24">
  88. <el-col :span="6" v-for="(data, index) in childrenData" :key="data.GroupId">
  89. <div v-is="['grouptree_btn_del_group']" class="info-close" @click="onNodeClick(data, index)">
  90. <i class="el-icon-close"></i>
  91. </div>
  92. <div class="itemBox" @click.stop="childrenClick(data)">
  93. <!-- <div class="status" v-if="data.OrganType == 1"></div>
  94. <div class="status2" v-if="data.OrganType != 1"></div> -->
  95. <el-row>
  96. <el-col :span="12">
  97. <div class="itemTitle">{{ data.GroupName }}</div>
  98. </el-col>
  99. <el-col :span="12">
  100. <div class="flex info">
  101. <div class="icon">
  102. <!-- <el-tooltip
  103. effect="dark"
  104. content="新增岗位"
  105. placement="bottom"
  106. >
  107. <span
  108. title="新增岗位"
  109. class="cap cap-job"
  110. @click.stop="renderJob(data)"
  111. v-if="data.GroupId != -1"
  112. ></span
  113. ></el-tooltip> -->
  114. <!-- <el-tooltip
  115. effect="dark"
  116. content="新增职员"
  117. placement="bottom"
  118. >
  119. <span
  120. title="新增职员"
  121. v-if="data.GroupId != -1"
  122. class="cap cap-member"
  123. @click.stop="renderMember(data)"
  124. ></span
  125. ></el-tooltip> -->
  126. <el-tooltip v-is="['grouptree_btn_update_group']" effect="dark" content="编辑岗位" placement="bottom">
  127. <span title="编辑岗位" class="cap cap-edit" @click.stop="renderEdit(data)" v-if="data.GroupId != -1"></span>
  128. </el-tooltip>
  129. <el-tooltip v-is="['grouptree_btn_add_group']" effect="dark" content="新增岗位" placement="bottom">
  130. <span title="新增岗位" class="cap cap-sub" @click.stop="renderAdd(data)"></span>
  131. </el-tooltip>
  132. </div>
  133. </div>
  134. </el-col>
  135. <el-col :span="24" v-if="data.GroupId != -1">
  136. <span class="msg">账号数:</span>
  137. <span style="margin-right: 90px">{{
  138. data.UserCount
  139. }}</span>
  140. <span class="msg">权限数:</span>
  141. <span>{{ data.AuthCount }}</span>
  142. </el-col>
  143. <el-col :span="12" v-if="data.GroupId != -1">
  144. <span class="msg">状态:</span>
  145. <span class="use" v-if="data.Status == '1'">启用</span>
  146. <span class="unUse" v-if="data.Status != '1'">禁用</span>
  147. </el-col>
  148. <el-col v-is="['grouptree_btn_state_swatch']" :span="12" v-if="data.GroupId != -1">
  149. <el-switch active-color="#6F81BC" v-model="data.flag" @click.stop.native @change="childrenRenderChange(data, index)"></el-switch>
  150. </el-col>
  151. </el-row>
  152. </div>
  153. </el-col>
  154. </el-row>
  155. </div>
  156. </div>
  157. </el-col>
  158. </el-row>
  159. </div>
  160. <!--删除弹框-->
  161. <Dialog :flag="flag">
  162. <div class="airportInfoDialog">
  163. <div class="title">删除{{ title }}</div>
  164. <div class="content">是否确认删除{{ title }}?</div>
  165. <div class="foot right t30">
  166. <el-button size="medium" class="r24" @click="remove" type="danger">删除</el-button>
  167. <el-button size="medium" @click="flag = false">取消</el-button>
  168. </div>
  169. </div>
  170. </Dialog>
  171. </div>
  172. </template>
  173. <script>
  174. // import OrgTree from '@/layout/components/OrgTree'
  175. import Search from "@/layout/components/Search";
  176. import Dialog from "@/layout/components/Dialog";
  177. import { DeleteGroup, ChangeGroupStatus } from "@/api/AccountGroup";
  178. import treeData from "../minixs/treeData";
  179. export default {
  180. name: "accountGroup",
  181. components: { Search, Dialog },
  182. mixins: [treeData],
  183. data () {
  184. return {
  185. dataIndex: 1,
  186. dataNum: 0,
  187. dataArr: [],
  188. type: null,
  189. title: "", //弹框title
  190. flag: false, //弹框开关
  191. dataId: null, //tree数据id
  192. defaultProps: {
  193. children: "children",
  194. label: "GroupName",
  195. },
  196. currDataArr: [],
  197. currDataArrId: 0,
  198. childrenData: [],
  199. dataListTree: [],
  200. currentKey: -1,
  201. delIndex: 0,
  202. };
  203. },
  204. created: function () {
  205. let keyWords = "";
  206. if (this.$route.query.keyWords) {
  207. keyWords = this.$route.query.keyWords;
  208. }
  209. this.getGroupTree(keyWords);
  210. },
  211. watch: {
  212. dataList: {
  213. handler: function (val) {
  214. this.dataListTree = [];
  215. this.dataListTree.push(_.cloneDeep(val));
  216. },
  217. deep: true,
  218. },
  219. },
  220. methods: {
  221. filterNode (value, data) {
  222. if (!value) return true;
  223. return data.GroupName.indexOf(value) !== -1;
  224. },
  225. // 添加组织
  226. renderAdd (data) {
  227. this.$router.push({
  228. path: "/accountGroup/Add",
  229. query: { GroupUpId: data.GroupId },
  230. });
  231. },
  232. // 修改组织
  233. renderEdit (data) {
  234. this.$router.push({
  235. path: "/accountGroup/Edit",
  236. query: { GroupUpId: data.GroupUpid, GroupId: data.GroupId },
  237. });
  238. },
  239. // 新增职员
  240. renderMember (data) {
  241. this.$message.warning("功能开发中");
  242. },
  243. // 关闭开启
  244. renderChange (data) {
  245. const { GroupId, flag } = data;
  246. const Status = flag ? 1 : 0;
  247. this.handleChange(GroupId, Status);
  248. },
  249. //下级关闭
  250. childrenRenderChange (data, index) {
  251. try {
  252. const { GroupId, flag } = data;
  253. const Status = flag ? 1 : 0;
  254. ChangeGroupStatus({
  255. GroupId: GroupId,
  256. Status: Status,
  257. }).then((res) => {
  258. if (res.code === 0) {
  259. this.$message.success(res.message);
  260. this.childrenData[index].Status = Status;
  261. // this.getOrganTree();
  262. } else {
  263. this.$message.error(res.message);
  264. this.childrenData[index].flag = !flag;
  265. }
  266. });
  267. } catch (error) {
  268. console.log("出错了", error);
  269. this.childrenData[index].flag = !flag;
  270. }
  271. },
  272. //删除组织
  273. remove () {
  274. this.deleteOrg(this.dataId);
  275. },
  276. //查询
  277. getSearchData (val) {
  278. this.$refs.tree.filter(val);
  279. },
  280. //清除查询
  281. clearSearchData () {
  282. this.getGroupTree();
  283. },
  284. //节点关闭按钮点击
  285. onNodeClick (data, index) {
  286. this.delIndex = index;
  287. this.flag = true;
  288. this.dataId = data.GroupId;
  289. this.title = data.GroupName;
  290. },
  291. //获取指定数据
  292. decompose (value, key, id) {
  293. let data = _.cloneDeep(value);
  294. let arr = [];
  295. for (let i = 0; i < data.length; i++) {
  296. if (data[i][key] == id) {
  297. arr.push(data[i]);
  298. }
  299. }
  300. return arr;
  301. },
  302. //-----------获取数据------------
  303. //状态变更
  304. async handleChange (id, val) {
  305. try {
  306. const res = await ChangeGroupStatus({
  307. GroupId: id,
  308. Status: val,
  309. });
  310. if (res.code === 0) {
  311. this.$message.success(res.message);
  312. this.currDataArr[0].Status = val;
  313. } else {
  314. this.$message.error(res.message);
  315. this.currDataArr[0].flag = !flag;
  316. }
  317. } catch (error) {
  318. console.log("出错了", error);
  319. }
  320. },
  321. //删除
  322. async deleteOrg (id) {
  323. try {
  324. const res = await DeleteGroup({
  325. GroupId: id,
  326. });
  327. if (res.code === 0) {
  328. this.$message.success(res.message);
  329. this.flag = false;
  330. this.getGroupTree();
  331. this.childrenData.splice(this.delIndex, 1);
  332. this.$refs.tree.setCurrentKey(this.currDataArr[0].GroupId);
  333. this.currentKey = this.currDataArr[0].GroupId;
  334. } else {
  335. this.flag = false;
  336. this.$message.error(res.message);
  337. }
  338. } catch (error) {
  339. this.flag = false;
  340. console.log("DeleteGroup");
  341. console.log("error");
  342. }
  343. },
  344. //树点击
  345. handleNodeClick (data) {
  346. const dataNew = _.cloneDeep(data);
  347. this.currDataArrId = dataNew.GroupId;
  348. this.currDataArr = [];
  349. this.childrenData = [];
  350. this.currDataArr = this.decompose(
  351. this.dataArr,
  352. "GroupId",
  353. dataNew.GroupId
  354. );
  355. this.childrenData = this.decompose(
  356. this.dataArr,
  357. "GroupUpid",
  358. dataNew.GroupId
  359. );
  360. },
  361. //下级卡片点击
  362. childrenClick (data) {
  363. const dataNew = _.cloneDeep(data);
  364. this.currDataArrId = dataNew.GroupId;
  365. this.currDataArr = [];
  366. this.childrenData = [];
  367. this.currDataArr = this.decompose(
  368. this.dataArr,
  369. "GroupId",
  370. dataNew.GroupId
  371. );
  372. this.childrenData = this.decompose(
  373. this.dataArr,
  374. "GroupUpid",
  375. dataNew.GroupId
  376. );
  377. this.$refs.tree.setCurrentKey(dataNew.GroupId);
  378. this.currentKey = dataNew.GroupId;
  379. },
  380. },
  381. };
  382. </script>
  383. <style lang="scss" scoped>
  384. .accountGroup-home {
  385. padding: 0 64px;
  386. // .accountGroup-head {
  387. // line-height: 48px;
  388. // display: flex;
  389. // justify-content: flex-end;
  390. // }
  391. .accountGroup-head {
  392. position: fixed;
  393. width: 100%;
  394. padding: 30px 64px;
  395. padding-left: 156px;
  396. left: 0;
  397. display: flex;
  398. flex-direction: row;
  399. justify-content: space-between;
  400. background: #f5f7fa;
  401. z-index: 100;
  402. .status {
  403. & > div {
  404. margin-right: 28px;
  405. .icon {
  406. width: 16px;
  407. height: 16px;
  408. background: #6f81bc;
  409. border-radius: 2px;
  410. display: inline-block;
  411. vertical-align: middle;
  412. margin-right: 10px;
  413. position: relative;
  414. top: -2px;
  415. }
  416. &:last-child {
  417. margin-right: 0;
  418. }
  419. }
  420. .status2 {
  421. .icon {
  422. background: #de4799;
  423. }
  424. }
  425. }
  426. }
  427. .accountGroup-content {
  428. padding-top: 110px;
  429. height: calc(100vh - 166px);
  430. box-sizing: border-box;
  431. .bodyContent {
  432. height: 100%;
  433. .bodyPart {
  434. height: 100%;
  435. display: flex;
  436. flex-direction: column;
  437. justify-content: space-between;
  438. }
  439. }
  440. .grid-content {
  441. width: 100%;
  442. height: 100%;
  443. background: #ffffff;
  444. border-radius: 16px;
  445. .title {
  446. font-size: 18px;
  447. font-family: Microsoft YaHei;
  448. font-weight: bold;
  449. color: #303133;
  450. height: 40px;
  451. padding: 30px;
  452. }
  453. .contentTree {
  454. height: calc(100% - 60px);
  455. overflow: auto;
  456. padding: 20px;
  457. }
  458. }
  459. .grid-contentTop {
  460. width: 100%;
  461. height: 240px;
  462. background: #ffffff;
  463. border-radius: 16px;
  464. .title {
  465. font-size: 18px;
  466. font-family: Microsoft YaHei;
  467. font-weight: bold;
  468. color: #303133;
  469. height: 40px;
  470. padding: 30px;
  471. }
  472. .content {
  473. width: 100%;
  474. height: calc(100% - 60px);
  475. padding: 0 20px;
  476. }
  477. }
  478. .grid-contentBottom {
  479. width: 100%;
  480. height: calc(100% - 240px - 24px);
  481. background: #ffffff;
  482. border-radius: 16px;
  483. .title {
  484. font-size: 18px;
  485. font-family: Microsoft YaHei;
  486. font-weight: bold;
  487. color: #303133;
  488. height: 40px;
  489. padding: 30px;
  490. }
  491. .content {
  492. width: 100%;
  493. height: calc(100% - 60px);
  494. padding: 20px 20px;
  495. overflow-y: auto;
  496. }
  497. }
  498. .el-col {
  499. position: relative;
  500. .info-close {
  501. position: absolute;
  502. width: 24px;
  503. height: 24px;
  504. line-height: 24px;
  505. text-align: center;
  506. background: #000000;
  507. border-radius: 50%;
  508. top: -10px;
  509. right: 23px;
  510. z-index: 15;
  511. color: #fff;
  512. cursor: pointer;
  513. .icon {
  514. color: #fff;
  515. font-weight: 600;
  516. }
  517. }
  518. }
  519. .itemBox {
  520. width: 292px;
  521. padding: 24px;
  522. position: relative;
  523. background: #f5f7fa;
  524. box-shadow: 0px 6px 7px 0px rgba(0, 0, 0, 0.06);
  525. border-radius: 16px;
  526. padding: 10px 20px;
  527. overflow: hidden;
  528. min-height: 130px;
  529. margin-bottom: 24px;
  530. .status {
  531. width: 100%;
  532. height: 4px;
  533. background: #6f80bc;
  534. position: absolute;
  535. top: 0;
  536. left: 0;
  537. z-index: 1;
  538. border-radius: 80px;
  539. }
  540. .status2 {
  541. width: 100%;
  542. height: 4px;
  543. position: absolute;
  544. top: 0;
  545. left: 0;
  546. z-index: 1;
  547. background: #de4799;
  548. }
  549. .el-col {
  550. padding: 10px 0;
  551. }
  552. .itemTitle {
  553. font-size: 16px;
  554. font-family: Microsoft YaHei;
  555. font-weight: bold;
  556. color: #303133;
  557. overflow: hidden;
  558. white-space: nowrap;
  559. text-overflow: ellipsis;
  560. }
  561. .info {
  562. line-height: normal;
  563. justify-content: flex-end;
  564. .name {
  565. font-size: 16px;
  566. font-weight: bold;
  567. }
  568. .cap {
  569. width: 24px;
  570. height: 24px;
  571. display: inline-block;
  572. background-repeat: no-repeat;
  573. background-size: cover;
  574. transition: all 0.3s;
  575. margin-left: 10px;
  576. &:first-child {
  577. margin-right: 0;
  578. }
  579. }
  580. .cap-plus {
  581. background-image: url("../../../assets/status/ic_plus.png");
  582. &:hover {
  583. background-image: url("../../../assets/status/ic_plus_hovar.png");
  584. }
  585. }
  586. .cap-edit {
  587. background-image: url("../../../assets/status/ic_edit.png");
  588. &:hover {
  589. background-image: url("../../../assets/status/ic_edit_hovar.png");
  590. }
  591. }
  592. .cap-sub {
  593. background-image: url("../../../assets/status/ic_subordinate.png");
  594. &:hover {
  595. background-image: url("../../../assets/status/ic_subordinate_hovar.png");
  596. }
  597. }
  598. .cap-job {
  599. background-image: url("../../../assets/status/ic_jobs.png");
  600. &:hover {
  601. background-image: url("../../../assets/status/ic_jobs_hovar.png");
  602. }
  603. }
  604. .cap-member {
  605. background-image: url("../../../assets/status/ic_member.png");
  606. &:hover {
  607. background-image: url("../../../assets/status/ic_member_hovar.png");
  608. }
  609. }
  610. }
  611. span {
  612. font-size: 16px;
  613. font-family: Microsoft YaHei;
  614. font-weight: 400;
  615. color: #909399;
  616. display: inline-block;
  617. }
  618. .msg {
  619. color: #303133;
  620. }
  621. .use {
  622. color: #6f80bc;
  623. }
  624. .unUse {
  625. color: #f56c6c;
  626. }
  627. .el-switch {
  628. float: right;
  629. }
  630. }
  631. }
  632. }
  633. ::-webkit-scrollbar-track-piece {
  634. background: #d3dce6;
  635. }
  636. ::-webkit-scrollbar {
  637. width: 6px;
  638. }
  639. ::-webkit-scrollbar-thumb {
  640. background: #99a9bf;
  641. border-radius: 20px;
  642. }
  643. </style>