<template>
|
<div class="user-level">
|
<div class="top-card">
|
<CommonSearch
|
:add-title="'新增等级'"
|
:total-object="totalObject"
|
:other-options="otherOptions"
|
:placeholder="'请输入等级名称'"
|
@addCommonClick="addBtnClick"
|
@searchClick="searchClick"
|
></CommonSearch>
|
</div>
|
|
<div class="body">
|
<div class="content-top">
|
<div class="list-view">
|
<TableCommonView
|
ref="tableListRef"
|
:table-list="tableList"
|
@selTableCol="selTableCol"
|
@tableRowClick="tableRowClick"
|
:selectClassRow="selectRow"
|
>
|
<template slot="tableButton">
|
<el-table-column label="操作" width="120">
|
<template slot-scope="scope">
|
<el-button v-if="scope.row.status" type="text" size="small" @click.stop="changeStatusClick(scope.row)"
|
>停用</el-button
|
>
|
<el-button v-else @click.stop="getRoleChange(scope.row)" type="text" size="small">启用</el-button>
|
<el-button @click.stop="handleClick(scope.row)" type="text" size="small">编辑</el-button>
|
<el-button @click.stop="delClick(scope.row)" type="text" size="small">删除</el-button>
|
</template>
|
</el-table-column>
|
</template>
|
</TableCommonView>
|
</div>
|
|
<div class="btn-pager">
|
<PagerView class="page" :pager-options="pagerOptions" v-on="pagerEvents" />
|
</div>
|
</div>
|
<div class="content-bottom">
|
<div class="bottom-tabs bgcGrey">
|
<div
|
class="tab-pane"
|
@click="getTab(0)"
|
:style="{
|
background: TabsIndex == 0 ? '#2a78fb' : '#F1F3F8',
|
color: TabsIndex == 0 ? '#fff' : '#666'
|
}"
|
>
|
管理员
|
</div>
|
</div>
|
<div class="list-view">
|
<TableCommonView :loading="loading" :table-list="bottomTableList" @selTableCol="selBottomTableCol">
|
</TableCommonView>
|
</div>
|
</div>
|
</div>
|
<!-- 添加/编辑 -->
|
<AddUserLevel v-if="editConfig.visible" :edit-common-config="editConfig" />
|
</div>
|
</template>
|
|
<script>
|
import pageMixin from "@/components/makepager/pager/mixin/pageMixin"
|
import AddUserLevel from "@/views/unifiedManage/userLevel/components/AddUserLevel"
|
import { getListRole, getUserList, roleChange, deleteRole } from "@/api/unifiedManage/userLevel"
|
export default {
|
name: "UserLevel",
|
props: {
|
isDetail: {
|
type: Boolean,
|
default: false
|
},
|
addConfig: {
|
type: Object,
|
default: () => {
|
return {}
|
}
|
}
|
},
|
mixins: [pageMixin],
|
components: { AddUserLevel },
|
computed: {},
|
data() {
|
return {
|
totalObject: {
|
value: 0,
|
label: "全部"
|
},
|
otherOptions: [
|
{
|
value: 0,
|
label: "启用",
|
status: "success"
|
},
|
{
|
value: 0,
|
label: "停用",
|
status: "error"
|
}
|
],
|
tableList: {},
|
tableColumn: [
|
{ label: "等级名称", prop: "name", default: true },
|
{ label: "等级描述", prop: "comment", default: true },
|
{ label: "员工数", prop: "count" },
|
{ label: "状态", prop: "status", isCallMethod: true, getCallMethod: this.getRoleStatus }
|
],
|
showCol: ["等级名称", "等级描述", "员工数", "状态"],
|
selectRow: {},
|
TabsIndex: 0,
|
bottomTableList: {},
|
loading: false,
|
tableBottomColumn: [
|
{ label: "用户名", prop: "username", default: true },
|
{ label: "姓名", prop: "nickName", default: true },
|
{ label: "手机号", prop: "phone" },
|
{ label: "岗位职务", prop: "dutyNames" },
|
{ label: "状态", prop: "status", isCallMethod: true, getCallMethod: this.getUserStatus }
|
],
|
showBottomCol: ["用户名", "姓名", "手机号", "岗位职务", "状态"],
|
isopen: false,
|
editConfig: {
|
visible: false,
|
title: "新建",
|
infomation: {}
|
},
|
data: {
|
keyword: "",
|
page: 1,
|
pageSize: 15,
|
useType: 1
|
}
|
}
|
},
|
created() {
|
this.setTable()
|
this.getData()
|
},
|
methods: {
|
// 角色列表
|
async getData(val) {
|
this.data.page = this.pagerOptions.currPage
|
this.data.pageSize = this.pagerOptions.pageSize
|
const res = await getListRole(this.data)
|
console.log(res)
|
this.tableList.tableInfomation = res.data.list
|
this.pagerOptions.totalCount = res.data.total
|
|
if (this.pagerOptions.totalCount > 0) {
|
let row = this.tableList.tableInfomation[0]
|
this.selectRow = this.tableList.tableInfomation.length > 0 ? this.tableList.tableInfomation[0] : {}
|
this.getUserList(row.id)
|
}
|
if (val !== "search") {
|
// this.overview();
|
}
|
},
|
// 用户列表
|
async getUserList(id) {
|
let params = {
|
page: 0,
|
pageSize: 0,
|
id: id
|
}
|
const res = await getUserList(params)
|
if (res.data.list && res.data.list.length > 0) {
|
const list = res.data.list.map((item) => {
|
let dutyList = []
|
item.dutyIDs.forEach((val) => {
|
dutyList.push(val.dutyName)
|
})
|
return {
|
...item,
|
dutyNames: dutyList.join(", ")
|
}
|
})
|
this.bottomTableList.tableInfomation = list || []
|
} else {
|
this.bottomTableList.tableInfomation = []
|
}
|
},
|
// 新建
|
addBtnClick() {
|
this.editConfig.title = "新建"
|
this.editConfig.visible = true
|
this.editConfig.infomation = {}
|
},
|
// 搜索
|
searchClick(val) {
|
this.data.keyword = val
|
this.pagerOptions.currPage = 1
|
// this.getData();
|
},
|
// 停用
|
changeStatusClick(row) {
|
this.$confirm("是否停用此等级?", "提示", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning"
|
})
|
.then(() => {
|
this.getRoleChange(row)
|
})
|
.catch(() => {})
|
},
|
// 启用 停用请求
|
async getRoleChange(row) {
|
console.log(row)
|
await roleChange({
|
id: row.id,
|
status: !row.status
|
}).then((reply) => {
|
if (reply && reply.code == 200) {
|
let tips = row.status ? "停用成功" : "启用成功"
|
this.getData()
|
this.$message({
|
type: "success",
|
message: tips
|
})
|
}
|
})
|
},
|
// 编辑
|
handleClick(val) {
|
console.log(val)
|
this.editConfig.title = "编辑"
|
this.editConfig.infomation = { ...val }
|
this.editConfig.visible = true
|
},
|
// 删除等级
|
delClick(row) {
|
console.log(row)
|
this.$confirm("删除后数据不能恢复,确定是否删除?", "提示", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning"
|
})
|
.then(() => {
|
deleteRole(row.id).then((reply) => {
|
if (reply && reply.code == 200) {
|
this.getData()
|
this.$message({
|
type: "success",
|
message: "删除成功"
|
})
|
}
|
})
|
})
|
.catch(() => {})
|
},
|
// 行点击
|
tableRowClick(row) {
|
console.log(row)
|
this.selectRow = row
|
// this.getUserList(row.id);
|
},
|
// 等级状态
|
getRoleStatus(val) {
|
return val ? "启用" : "停用"
|
},
|
//获取当前选中等级的id
|
getTab(tab) {
|
this.TabsIndex = tab
|
if (this.TabsIndex == 0) {
|
// 产品信息列表
|
this.showBottomCol = this.showProductCol
|
this.setBottomList()
|
this.getProductInventoryInfo(this.selectRow)
|
}
|
},
|
// 用户状态
|
getUserStatus(val) {
|
return val === 0 ? "禁用" : val === 1 ? "正常" : "审核中"
|
},
|
// 初始化列表
|
setTable() {
|
this.tableList = {
|
selectIndex: true,
|
tableInfomation: [],
|
allcol: [],
|
showcol: this.showCol,
|
tableColumn: this.setColumnVisible(this.showCol, this.tableColumn)
|
}
|
this.setTableList(this.tableList)
|
// bottom
|
this.setBottomList()
|
},
|
// 列表
|
setTableList(tableList) {
|
tableList.allcol = tableList.tableColumn.filter((ele) => !ele.default).map((ele) => ele.label)
|
},
|
// bom 列表
|
setBottomList() {
|
this.bottomTableList = {
|
selectIndex: true,
|
tableInfomation: [],
|
allcol: [],
|
showcol: this.showBottomCol,
|
tableColumn: this.setColumnVisible(this.showBottomCol, this.tableBottomColumn)
|
}
|
this.setTableList(this.bottomTableList)
|
},
|
// 等级
|
selTableCol(val) {
|
this.showcol = val
|
this.tableList.tableColumn = this.setColumnVisible(val)
|
},
|
// bottom
|
selBottomTableCol(val) {
|
this.showcol = val
|
this.bottomTableList.tableColumn = this.setColumnVisible(val, this.tableBottomColumn)
|
},
|
setColumnVisible(showCol, tableColumn) {
|
return tableColumn.map((ele) => {
|
return {
|
...ele,
|
isShowColumn: showCol.includes(ele.label)
|
}
|
})
|
}
|
}
|
}
|
</script>
|
|
<!-- Add "scoped" attribute to limit CSS to this component only -->
|
<style lang="scss" scoped>
|
.user-level {
|
height: 100%;
|
.top-card {
|
height: 80px;
|
display: flex;
|
align-items: center;
|
margin: 12px 20px 0 20px;
|
border-radius: 12px;
|
background-color: #fff;
|
padding-left: 20px;
|
}
|
.body {
|
box-sizing: border-box;
|
padding: 10px 20px;
|
border-radius: 12px;
|
height: calc(100% - 92px);
|
.body-card {
|
background-color: #fff;
|
border-radius: 12px;
|
height: 100%;
|
overflow: hidden;
|
}
|
.content-top {
|
background-color: #fff;
|
border-radius: 12px;
|
min-height: 70px;
|
height: 48%;
|
position: relative;
|
.list-view {
|
height: calc(100% - 60px);
|
}
|
}
|
.content-bottom {
|
.bottom-tabs {
|
height: 40px;
|
line-height: 40px;
|
background: #e6ecf2;
|
display: flex;
|
.tab-pane {
|
width: 100px;
|
margin-right: 20px;
|
font-size: 14px !important;
|
text-align: center;
|
cursor: pointer;
|
background: #2a78fb;
|
border-top-left-radius: 20px;
|
border-top-right-radius: 20px;
|
}
|
}
|
.lable-view {
|
background: #e6ecf2;
|
height: 40px;
|
line-height: 40px;
|
.name {
|
border-left: 4px solid #2a78fb;
|
padding-left: 10px;
|
}
|
}
|
background-color: #fff;
|
border-radius: 12px;
|
min-height: 70px;
|
height: calc(52% - 50px);
|
margin-top: 10px;
|
// padding: 10px 20px;
|
.list-view {
|
height: calc(100% - 10px);
|
}
|
}
|
.btn-pager {
|
display: flex;
|
margin-top: 10px;
|
.page {
|
margin-left: auto;
|
}
|
}
|
}
|
}
|
::v-deep {
|
}
|
</style>
|