You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

395 lines
11 KiB
Vue

3 years ago
<template>
3 years ago
<div class="rightContainer">
3 years ago
<a-breadcrumb class="newBreadcrumb mt0 mb16">
<a-breadcrumb-item href>
<router-link :to="{name:'merchantBack'}">
<a-icon type="home" />
</router-link>
</a-breadcrumb-item>
3 years ago
<a-breadcrumb-item>
<span @click="cancelAdd" v-if="secondBreadcrumb" style="cursor:pointer"></span>
<span v-else></span>
</a-breadcrumb-item>
<a-breadcrumb-item v-if="secondBreadcrumb">{{secondBreadcrumb}}</a-breadcrumb-item>
3 years ago
</a-breadcrumb>
3 years ago
3 years ago
<div class="contentbody bodyContainer">
3 years ago
<div class="fsa pb16" v-if="secondBreadcrumb == ''">
3 years ago
<div class="f20 fw500">{{secondBreadcrumb || '角色管理'}}</div>
3 years ago
<a-button class="addmemeber f14" @click="addRole('add')">
3 years ago
<i class="iconfont icon-fangda mr4"></i> 添加角色
3 years ago
</a-button>
</div>
3 years ago
<div v-if="secondBreadcrumb == ''">
3 years ago
<a-table :columns="columns" :data-source="roleList" :pagination="false" @change="onChange" :loading="{spinning: isspinning,tip: '加载中',wrapperClassName: 'spinstyle'}" :rowKey="(record) => record.id">
3 years ago
<!-- <a slot="index" slot-scope="record, text, index">{{ index + 1 }}</a> -->
<div slot="setting" class="setting" slot-scope="text, record" style="color: #1890FF">
3 years ago
<a @click="showDetail(record)"></a>
<a :class="record.roleType == 1 ?'':'unclick'" class="delete" @click="record.roleType == 1 ? addRole('edit',record):''">编辑</a>
<a :class="record.roleType == 1 ?'':'unclick'" @click="record.roleType == 1 ? delRole(record):''">删除</a>
3 years ago
</div>
</a-table>
3 years ago
<div class="pagecontainer mt16 fss dn">
<a-pagination :current="pagination.pageNum" :default-current="1" :defaultPageSize="20" :show-total="total => `${total}`" :total="pagination.total" @change="onChange" size="small" show-size-changer show-quick-jumper />
3 years ago
</div>
</div>
3 years ago
</div>
</div>
</template>
<script>
3 years ago
import { getRoleListApi, addRoleApi, updateRoleApi, delRoleApi } from '../../api/merchantConfig'
3 years ago
export default {
// 组件名称
3 years ago
name: 'RoleManagement',
3 years ago
// 局部注册的组件
components: {},
// 组件参数 接收来自父组件的数据
props: {},
// 组件状态值
data() {
return {
3 years ago
tablenodata: {
// 空状态文本内容
emptyText: () => (
<div>
<div>
<img src="https://user-images.githubusercontent.com/507615/54591670-ac0a0180-4a65-11e9-846c-e55ffce0fe7b.png" style="width:105px;height:90px;marginTop:20px" />
</div>
<div style="marginBottom:20px">暂无数据</div>
</div>
),
},
secondBreadcrumb: '',
roleList: [1, 2, 3, 4],
3 years ago
pagination: {
pageNum: 1,
3 years ago
pageSize: 20,
total: 3, //分页配置
3 years ago
status: 0,
keys: null,
3 years ago
size: 'small',
showTotal: function (total, range) {
return `${total}`
},
pageSizeOptions: ['25', '50', '100'],
showSizeChanger: true,
3 years ago
// searchTag: 1,
},
isspinning: false,
roleList: [],
3 years ago
}
},
// 计算属性
computed: {
columns() {
const columns = [
{
title: '排序',
dataIndex: 'index',
key: 'index',
customRender: (text, row, index) => {
if (row.children) {
return ''
} else {
return index + 1
}
},
// ellipsis: true,
width: 60,
},
{
title: '角色',
dataIndex: 'roleName',
key: 'roleName',
scopedSlots: { customRender: 'roleName' },
ellipsis: true,
3 years ago
width: 150,
3 years ago
},
// {
// title: '角色',
// dataIndex: 'role',
// key: 'role',
// width: 100,
// ellipsis: true,
// },
{
3 years ago
title: '角色备注',
3 years ago
dataIndex: 'desp',
key: 'desp',
3 years ago
// width: 100,
// filters: this.groupList,
// customRender: (text, row, index) => {
// let text1
// this.groupList.forEach((item) => {
// if (item.id == text) {
// text1 = item.teamName
// }
// })
// return text1
// },
ellipsis: true,
},
// {
// title: '权限',
// dataIndex: 'permission',
// key: 'permission',
// ellipsis: true,
// },
{
title: '操作',
dataIndex: 'setting',
key: 'setting',
// sorter: (a, b) => a.userApplyOrder.localeCompare(b.userApplyOrder),
scopedSlots: { customRender: 'setting' },
ellipsis: true,
// sortOrder: sortedInfo.columnKey == "userApplyOrder" && sortedInfo.order,
// ellipsis: true,
width: 140,
},
]
return columns
},
},
// 侦听器
watch: {},
// 生命周期钩子 注:没用到的钩子请自行删除
/**
* 组件实例创建完成属性已绑定但DOM还未生成$ el属性还不存在
*/
3 years ago
beforeCreate() {},
3 years ago
created() {
this.$emit('setTitle', '角色管理')
3 years ago
this.getRoleList()
3 years ago
console.log(this.middleauthor)
3 years ago
},
/**
* el 被新创建的 vm.el 替换并挂载到实例上去之后调用该钩子
* 如果 root 实例挂载了一个文档内元素 mounted 被调用时 vm.el 也在文档内
*/
mounted() {},
// 组件方法
3 years ago
methods: {
checkboxChange(e, key, index) {
// console.log(e)
// console.log(key)
// console.log(index)
// console.log(this.authorityList[key]);
// console.log(this.authorityList[key][index]);
if (e.children) {
this.authorityList[key].checked = !this.authorityList[key].checked
} else {
this.authorityList[key].children[index].checked = !this.authorityList[key].children[index].checked
}
console.log(this.authorityList)
},
inputpageChange(e) {
const pagenumcount = this.pagination.total / this.pagination.pageSize
console.log(pagenumcount)
if (e.target.value) {
if (e.target.value > pagenumcount) {
this.pagination.pageNum = Math.ceil(pagenumcount)
} else {
this.pagination.pageNum = e.target.value
}
} else {
this.pagination.pageNum = 1
}
// this.getJobList();
this.getMemberList()
console.log(e)
},
choiceGroup() {},
onChange(e, e1, e2) {
console.log(e)
console.log(e1)
console.log(e2)
if (typeof e == 'number') {
this.pagination.pageNum = e
this.getMemberList()
}
},
3 years ago
showDetail(val) {
let that = this
3 years ago
this.secondBreadcrumb = '角色详情'
console.log(val)
that.$router.push({
name: 'RoleManagementDetail',
query: {
item: JSON.stringify(val),
},
})
3 years ago
},
addRole(type, val) {
let that = this
3 years ago
this.currentRole = val
3 years ago
if (type == 'add') {
this.$confirm({
title: '添加角色',
content: '【添加角色】属高敏感权限,基于账户安全考虑,请再次确认是否创建',
onOk() {
that.$router.push({
name: 'AddRoleManagement',
query: {
// item: val,
type: 'add',
roleList: JSON.stringify(that.roleList),
},
})
},
onCancel() {},
})
// this.secondBreadcrumb = '添加角色'
3 years ago
} else {
this.$router.push({
name: 'AddRoleManagement',
query: {
item: JSON.stringify(val),
roleList: JSON.stringify(this.roleList),
},
})
// this.secondBreadcrumb = '编辑角色'
// setTimeout(() => {
// this.roleForm.setFieldsValue({
// roleName: val.roleName,
// desp: val.desp,
// })
// }, 10)
3 years ago
}
3 years ago
this.$forceUpdate()
},
3 years ago
delRole(val) {
let that = this
that.$confirm({
3 years ago
title: '删除',
content: '确定要删除该角色吗?',
centered: true,
onOk(e1, e2) {
console.log(e1)
console.log(e2)
3 years ago
that.delSubmit(val)
3 years ago
return new Promise((res) => {
setTimeout(() => {
res()
}, 2000)
})
},
onCancel() {},
})
},
3 years ago
getRoleList() {
getRoleListApi().then(({ data }) => {
console.log(data)
if (data.status == 200) {
this.roleList = data.data.list
}
})
},
/**
* 删除角色信息表单提交
*/
delSubmit(val) {
console.log(val)
3 years ago
delRoleApi(val.id).then(({ data }) => {
console.log(data)
if (data.status == 200) {
this.secondBreadcrumb = ''
this.$message.success('删除成功')
this.getRoleList()
} else {
this.$message.fail('删除失败')
}
3 years ago
})
},
/**
* 取消编辑或者新增角色
*/
cancelAdd() {
this.secondBreadcrumb = ''
// this.authorityList = JSON.parse(JSON.stringify(this.middleauthor))
3 years ago
},
},
3 years ago
}
</script>
<style scoped lang="less">
.addmemeber {
border: 0;
padding: 0 12px;
height: 32px;
line-height: 32px;
color: #fff;
background: #1890ff;
border-radius: 4px;
i {
font-size: 12px;
}
3 years ago
&:hover {
background: #40a9ff;
}
3 years ago
}
3 years ago
.ant-divider {
margin: 16px 0 22px 0;
}
.delete {
border-left: 1px solid #979797;
border-right: 1px solid #979797;
padding: 0 9px;
margin: 0 9px;
}
3 years ago
/deep/.ant-table {
.ant-table-content {
.ant-table-body {
.ant-table-thead {
th {
padding: 12px 0;
div {
padding: 0px 8px;
}
&:not(:first-child) {
> span {
// line-height: 22px;
> div {
// line-height: 1;
border-left: 1px solid #ddd;
padding-left: 12px;
}
}
}
}
.ant-table-row-cell-break-word {
font-size: 14px !important;
font-weight: bold;
}
.ant-table-row-cell-ellipsis {
font-size: 14px !important;
font-weight: bold;
}
}
.ant-table-tbody {
.ant-table-row-cell-ellipsis {
font-size: 14px !important;
padding: 12px 14px;
}
.ant-table-row-expand-icon {
// color: #000;
padding: 0;
}
.ant-table-row-indent {
display: none !important;
}
}
}
}
}
3 years ago
.unclick {
color: #ccc;
cursor: not-allowed;
}
3 years ago
</style>