accountGroupHome.vue 23 KB

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