123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794 |
- <!--
- * @Author: your name
- * @Date: 2022-01-08 09:27:43
- * @LastEditTime: 2022-03-10 21:34:47
- * @LastEditors: your name
- * @Description: 用户组管理
- * @FilePath: \Foshan4A2.0\src\views\accountGroupManagement\components\home.vue
- -->
- <template>
- <div class="accountGroup-home">
- <!--状态和搜索-->
- <div class="accountGroup-head flex">
- <div class="status flex-wrap"></div>
- <Search
- @getSearchData="getSearchData"
- @clearSearchData="clearSearchData"
- />
- </div>
- <!--账号树-->
- <div class="accountGroup-content">
- <!-- <OrgTree :dataList="dataList" :renderContent="renderContent" /> -->
- <el-row
- :gutter="24"
- class="bodyContent"
- >
- <el-col
- :span="6"
- class="bodyPart"
- >
- <div class="grid-content">
- <div class="title">岗位树</div>
- <div class="contentTree">
- <el-tree
- ref="tree"
- :data="dataListTree"
- :props="defaultProps"
- node-key="GroupId"
- :filter-node-method="filterNode"
- highlight-current
- :default-expanded-keys="[currentKey]"
- @node-click="handleNodeClick"
- >
- </el-tree>
- </div>
- </div>
- </el-col>
- <el-col
- :span="18"
- class="bodyPart"
- >
- <div class="grid-contentTop">
- <div
- class="title"
- style="margin-bottom: 15px"
- >当前岗位</div>
- <div class="content">
- <el-empty
- :image-size="100"
- style="padding: 0"
- v-if="currDataArr.length < 1"
- ></el-empty>
- <el-row>
- <el-col
- :span="8"
- v-for="data in currDataArr"
- :key="data.GroupId"
- >
- <div class="itemBox">
- <el-row :gutter="24">
- <el-col :span="12">
- <div class="itemTitle">{{ data.GroupName }}</div>
- </el-col>
- <el-col :span="12">
- <div class="flex info">
- <div class="icon">
- <el-tooltip
- v-is="['grouptree_btn_update_group']"
- effect="dark"
- content="编辑岗位"
- placement="bottom"
- >
- <span
- title="编辑岗位"
- class="cap cap-edit"
- @click="renderEdit(data)"
- v-if="data.GroupId != -1"
- ></span>
- </el-tooltip>
- <el-tooltip
- v-is="['grouptree_btn_add_group']"
- effect="dark"
- content="新增岗位"
- placement="bottom"
- >
- <span
- title="新增岗位"
- class="cap cap-sub"
- @click="renderAdd(data)"
- ></span>
- </el-tooltip>
- </div>
- </div>
- </el-col>
- <!-- <el-col :span="8" v-if="data.GroupId != -1">
- <span class="msg">岗位:</span>
- <span>{{ data.JobCount }}</span>
- </el-col> -->
- <!-- <el-col :span="8" v-if="data.GroupId != -1">
- <span class="msg">职员:</span>
- <span>{{ data.OfficerCount }}</span>
- </el-col> -->
- <el-col
- :span="24"
- v-if="data.GroupId != -1"
- >
- <el-row>
- <el-col :span="12">
- <span class="msg">账号数:</span>
- <span>{{ data.UserCount }}</span>
- </el-col>
- <el-col :span="12">
- <span class="msg">权限数:</span>
- <span>{{ data.AuthCount }}</span>
- </el-col>
- </el-row>
- </el-col>
- <el-col
- :span="12"
- v-if="data.GroupId != -1"
- >
- <span class="msg">状态:</span>
- <span
- class="use"
- v-if="data.Status == '1'"
- >启用</span>
- <span
- class="unUse"
- v-if="data.Status != '1'"
- >禁用</span>
- </el-col>
- <el-col
- v-is="['grouptree_btn_state_swatch']"
- :span="12"
- v-if="data.GroupId != -1"
- >
- <el-switch
- active-color="#6F81BC"
- v-model="data.flag"
- @change="renderChange(data)"
- ></el-switch>
- </el-col>
- </el-row>
- </div>
- </el-col>
- </el-row>
- </div>
- </div>
- <div class="grid-contentBottom">
- <div class="title">下级岗位</div>
- <div class="content">
- <el-empty
- :image-size="150"
- v-if="childrenData.length < 1"
- ></el-empty>
- <el-row :gutter="24">
- <el-col
- :span="6"
- v-for="(data, index) in childrenData"
- :key="data.GroupId"
- >
- <div
- v-is="['grouptree_btn_del_group']"
- class="info-close"
- @click="onNodeClick(data, index)"
- >
- <i class="el-icon-close"></i>
- </div>
- <div
- class="itemBox"
- @click.stop="childrenClick(data)"
- >
- <!-- <div class="status" v-if="data.OrganType == 1"></div>
- <div class="status2" v-if="data.OrganType != 1"></div> -->
- <el-row>
- <el-col :span="12">
- <div class="itemTitle">{{ data.GroupName }}</div>
- </el-col>
- <el-col :span="12">
- <div class="flex info">
- <div class="icon">
- <!-- <el-tooltip
- effect="dark"
- content="新增岗位"
- placement="bottom"
- >
- <span
- title="新增岗位"
- class="cap cap-job"
- @click.stop="renderJob(data)"
- v-if="data.GroupId != -1"
- ></span
- ></el-tooltip> -->
- <!-- <el-tooltip
- effect="dark"
- content="新增职员"
- placement="bottom"
- >
- <span
- title="新增职员"
- v-if="data.GroupId != -1"
- class="cap cap-member"
- @click.stop="renderMember(data)"
- ></span
- ></el-tooltip> -->
- <el-tooltip
- v-is="['grouptree_btn_update_group']"
- effect="dark"
- content="编辑岗位"
- placement="bottom"
- >
- <span
- title="编辑岗位"
- class="cap cap-edit"
- @click.stop="renderEdit(data)"
- v-if="data.GroupId != -1"
- ></span>
- </el-tooltip>
- <el-tooltip
- v-is="['grouptree_btn_add_group']"
- effect="dark"
- content="新增岗位"
- placement="bottom"
- >
- <span
- title="新增岗位"
- class="cap cap-sub"
- @click.stop="renderAdd(data)"
- ></span>
- </el-tooltip>
- </div>
- </div>
- </el-col>
- <el-col
- :span="24"
- v-if="data.GroupId != -1"
- >
- <el-row>
- <el-col :span="12">
- <span class="msg">账号数:</span>
- <span>{{ data.UserCount }}</span>
- </el-col>
- <el-col :span="12">
- <span class="msg">权限数:</span>
- <span>{{ data.AuthCount }}</span>
- </el-col>
- </el-row>
- </el-col>
- <el-col
- :span="12"
- v-if="data.GroupId != -1"
- >
- <span class="msg">状态:</span>
- <span
- class="use"
- v-if="data.Status == '1'"
- >启用</span>
- <span
- class="unUse"
- v-if="data.Status != '1'"
- >禁用</span>
- </el-col>
- <el-col
- v-is="['grouptree_btn_state_swatch']"
- :span="12"
- v-if="data.GroupId != -1"
- >
- <el-switch
- active-color="#6F81BC"
- v-model="data.flag"
- @click.stop.native
- @change="childrenRenderChange(data, index)"
- ></el-switch>
- </el-col>
- </el-row>
- </div>
- </el-col>
- </el-row>
- </div>
- </div>
- </el-col>
- </el-row>
- </div>
- <!--删除弹框-->
- <Dialog :flag="flag">
- <div class="airportInfoDialog">
- <div class="title">删除{{ title }}</div>
- <div class="content">是否确认删除{{ title }}?</div>
- <div class="foot right t30">
- <el-button
- size="medium"
- class="r24"
- @click="remove"
- type="danger"
- >删除</el-button>
- <el-button
- size="medium"
- @click="flag = false"
- >取消</el-button>
- </div>
- </div>
- </Dialog>
- </div>
- </template>
- <script>
- // import OrgTree from '@/layout/components/OrgTree'
- import Search from '@/layout/components/Search'
- import Dialog from '@/layout/components/Dialog'
- import { DeleteGroup, ChangeGroupStatus } from '@/api/AccountGroup'
- import treeData from '../minixs/treeData'
- export default {
- name: 'accountGroup',
- components: { Search, Dialog },
- mixins: [treeData],
- data() {
- return {
- dataIndex: 1,
- dataNum: 0,
- dataArr: [],
- type: null,
- title: '', // 弹框title
- flag: false, // 弹框开关
- dataId: null, // tree数据id
- defaultProps: {
- children: 'children',
- label: 'GroupName'
- },
- currDataArr: [],
- currDataArrId: 0,
- childrenData: [],
- dataListTree: [],
- currentKey: -1,
- delIndex: 0
- }
- },
- created: function () {
- let keyWords = ''
- if (this.$route.query.keyWords) {
- keyWords = this.$route.query.keyWords
- }
- this.getGroupTree(keyWords)
- },
- watch: {
- dataList: {
- handler: function (val) {
- this.dataListTree = []
- this.dataListTree.push(_.cloneDeep(val))
- },
- deep: true
- }
- },
- methods: {
- filterNode(value, data) {
- if (!value) return true
- return data.GroupName.indexOf(value) !== -1
- },
- // 添加组织
- renderAdd(data) {
- this.$router.push({
- path: '/accountGroup/Add',
- query: { GroupUpId: data.GroupId }
- })
- },
- // 修改组织
- renderEdit(data) {
- this.$router.push({
- path: '/accountGroup/Edit',
- query: { GroupUpId: data.GroupUpid, GroupId: data.GroupId }
- })
- },
- // 新增职员
- renderMember(data) {
- this.$message.warning('功能开发中')
- },
- // 关闭开启
- renderChange(data) {
- const { GroupId, flag } = data
- const Status = flag ? 1 : 0
- this.handleChange(GroupId, Status)
- },
- // 下级关闭
- async childrenRenderChange(data, index) {
- const { GroupId, flag } = data
- const Status = flag ? 1 : 0
- try {
- const res = await ChangeGroupStatus({
- GroupId: GroupId,
- Status: Status
- })
- if (res.code === 0) {
- this.$message.success(res.message)
- this.childrenData[index].Status = Status
- // this.getOrganTree();
- } else {
- this.$message.error(res.message)
- this.childrenData[index].flag = !flag
- }
- } catch (error) {
- console.log('出错了', error)
- this.childrenData[index].flag = !flag
- }
- },
- // 删除组织
- remove() {
- this.deleteOrg(this.dataId)
- },
- // 查询
- getSearchData(val) {
- this.$refs.tree.filter(val)
- },
- // 清除查询
- clearSearchData() {
- this.getGroupTree()
- },
- // 节点关闭按钮点击
- onNodeClick(data, index) {
- this.delIndex = index
- this.flag = true
- this.dataId = data.GroupId
- this.title = data.GroupName
- },
- // 获取指定数据
- decompose(value, key, id) {
- let data = _.cloneDeep(value)
- let arr = []
- for (let i = 0; i < data.length; i++) {
- if (data[i][key] == id) {
- arr.push(data[i])
- }
- }
- return arr
- },
- // -----------获取数据------------
- // 状态变更
- async handleChange(id, val) {
- try {
- const res = await ChangeGroupStatus({
- GroupId: id,
- Status: val
- })
- if (res.code === 0) {
- this.$message.success(res.message)
- this.currDataArr[0].Status = val
- if (!val) {
- this.childrenData.forEach(data => {
- data.Status = '2'
- data.flag = false
- })
- }
- this.dataArr.forEach(data => {
- if (data.GroupUpid === id) {
- data.Status = '2'
- }
- })
- } else {
- this.$message.error(res.message)
- this.currDataArr[0].flag = !val
- }
- } catch (error) {
- console.log('出错了', error)
- this.currDataArr[0].flag = !val
- }
- },
- // 删除
- async deleteOrg(id) {
- try {
- const res = await DeleteGroup({
- GroupId: id
- })
- if (res.code === 0) {
- this.$message.success(res.message)
- this.flag = false
- this.getGroupTree()
- this.childrenData.splice(this.delIndex, 1)
- this.$refs.tree.setCurrentKey(this.currDataArr[0].GroupId)
- this.currentKey = this.currDataArr[0].GroupId
- } else {
- this.flag = false
- this.$message.error(res.message)
- }
- } catch (error) {
- this.flag = false
- console.log('DeleteGroup')
- console.log('error')
- }
- },
- // 树点击
- handleNodeClick(data) {
- const dataNew = _.cloneDeep(data)
- this.currDataArrId = dataNew.GroupId
- this.currDataArr = []
- this.childrenData = []
- this.currDataArr = this.decompose(this.dataArr, 'GroupId', dataNew.GroupId)
- this.childrenData = this.decompose(this.dataArr, 'GroupUpid', dataNew.GroupId)
- },
- // 下级卡片点击
- childrenClick(data) {
- const dataNew = _.cloneDeep(data)
- this.currDataArrId = dataNew.GroupId
- this.currDataArr = []
- this.childrenData = []
- this.currDataArr = this.decompose(this.dataArr, 'GroupId', dataNew.GroupId)
- this.childrenData = this.decompose(this.dataArr, 'GroupUpid', dataNew.GroupId)
- this.$refs.tree.setCurrentKey(dataNew.GroupId)
- this.currentKey = dataNew.GroupId
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .accountGroup-home {
- padding: 0 64px;
- // .accountGroup-head {
- // line-height: 48px;
- // display: flex;
- // justify-content: flex-end;
- // }
- .accountGroup-head {
- position: fixed;
- width: 100%;
- padding: 30px 64px;
- padding-left: 156px;
- left: 0;
- display: flex;
- flex-direction: row;
- justify-content: space-between;
- background: #f5f7fa;
- z-index: 100;
- .status {
- & > div {
- margin-right: 28px;
- .icon {
- width: 16px;
- height: 16px;
- background: #6f81bc;
- border-radius: 2px;
- display: inline-block;
- vertical-align: middle;
- margin-right: 10px;
- position: relative;
- top: -2px;
- }
- &:last-child {
- margin-right: 0;
- }
- }
- .status2 {
- .icon {
- background: #de4799;
- }
- }
- }
- }
- .accountGroup-content {
- padding-top: 110px;
- height: calc(100vh - 166px);
- box-sizing: border-box;
- .bodyContent {
- height: 100%;
- .bodyPart {
- height: 100%;
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- }
- }
- .grid-content {
- width: 100%;
- height: 100%;
- background: #ffffff;
- border-radius: 16px;
- .title {
- font-size: 18px;
- font-family: Microsoft YaHei;
- font-weight: bold;
- color: #303133;
- height: 40px;
- padding: 30px;
- }
- .contentTree {
- height: calc(100% - 60px);
- overflow: auto;
- padding: 20px;
- }
- }
- .grid-contentTop {
- width: 100%;
- height: 240px;
- background: #ffffff;
- border-radius: 16px;
- .title {
- font-size: 18px;
- font-family: Microsoft YaHei;
- font-weight: bold;
- color: #303133;
- height: 40px;
- padding: 30px;
- }
- .content {
- width: 100%;
- height: calc(100% - 60px);
- padding: 0 20px;
- }
- }
- .grid-contentBottom {
- width: 100%;
- height: calc(100% - 240px - 24px);
- background: #ffffff;
- border-radius: 16px;
- .title {
- font-size: 18px;
- font-family: Microsoft YaHei;
- font-weight: bold;
- color: #303133;
- height: 40px;
- padding: 30px;
- }
- .content {
- width: 100%;
- height: calc(100% - 60px);
- padding: 20px 20px;
- overflow-y: auto;
- }
- }
- .el-col {
- position: relative;
- .info-close {
- position: absolute;
- width: 24px;
- height: 24px;
- line-height: 24px;
- text-align: center;
- background: #000000;
- border-radius: 50%;
- top: -10px;
- right: 23px;
- z-index: 15;
- color: #fff;
- cursor: pointer;
- .icon {
- color: #fff;
- font-weight: 600;
- }
- }
- }
- .itemBox {
- width: 292px;
- padding: 24px;
- position: relative;
- background: #f5f7fa;
- box-shadow: 0px 6px 7px 0px rgba(0, 0, 0, 0.06);
- border-radius: 16px;
- padding: 10px 20px;
- overflow: hidden;
- min-height: 130px;
- margin-bottom: 24px;
- .status {
- width: 100%;
- height: 4px;
- background: #6f80bc;
- position: absolute;
- top: 0;
- left: 0;
- z-index: 1;
- border-radius: 80px;
- }
- .status2 {
- width: 100%;
- height: 4px;
- position: absolute;
- top: 0;
- left: 0;
- z-index: 1;
- background: #de4799;
- }
- .el-col {
- padding: 10px 0;
- > .el-row > .el-col {
- padding: 0;
- }
- }
- .itemTitle {
- font-size: 16px;
- font-family: Microsoft YaHei;
- font-weight: bold;
- color: #303133;
- overflow: hidden;
- white-space: nowrap;
- text-overflow: ellipsis;
- }
- .info {
- line-height: normal;
- justify-content: flex-end;
- .name {
- font-size: 16px;
- font-weight: bold;
- }
- .cap {
- width: 24px;
- height: 24px;
- display: inline-block;
- background-repeat: no-repeat;
- background-size: cover;
- transition: all 0.3s;
- margin-left: 10px;
- &:first-child {
- margin-right: 0;
- }
- }
- .cap-plus {
- background-image: url('../../../assets/status/ic_plus.png');
- &:hover {
- background-image: url('../../../assets/status/ic_plus_hovar.png');
- }
- }
- .cap-edit {
- background-image: url('../../../assets/status/ic_edit.png');
- &:hover {
- background-image: url('../../../assets/status/ic_edit_hovar.png');
- }
- }
- .cap-sub {
- background-image: url('../../../assets/status/ic_subordinate.png');
- &:hover {
- background-image: url('../../../assets/status/ic_subordinate_hovar.png');
- }
- }
- .cap-job {
- background-image: url('../../../assets/status/ic_jobs.png');
- &:hover {
- background-image: url('../../../assets/status/ic_jobs_hovar.png');
- }
- }
- .cap-member {
- background-image: url('../../../assets/status/ic_member.png');
- &:hover {
- background-image: url('../../../assets/status/ic_member_hovar.png');
- }
- }
- }
- span {
- font-size: 16px;
- font-family: Microsoft YaHei;
- font-weight: 400;
- color: #909399;
- display: inline-block;
- }
- .msg {
- color: #303133;
- }
- .use {
- color: #6f80bc;
- }
- .unUse {
- color: #f56c6c;
- }
- .el-switch {
- float: right;
- }
- }
- }
- }
- ::-webkit-scrollbar-track-piece {
- background: #d3dce6;
- }
- ::-webkit-scrollbar {
- width: 6px;
- }
- ::-webkit-scrollbar-thumb {
- background: #99a9bf;
- border-radius: 20px;
- }
- </style>
|