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.

552 lines
16 KiB
Vue

3 years ago
<template>
<div class>
<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
<!-- <div v-if="secondBreadcrumb">
/
{{secondBreadcrumb}}
</div>-->
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')" >
<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" :locale="tablenodata">
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">
<a @click="secondBreadcrumb = '角色详情'">详情</a>
3 years ago
<a class="delete" @click="addRole('edit')"></a>
<a @click="delRole('del')"></a>
3 years ago
</div>
</a-table>
<div class="pagecontainer mt16 fss">
3 years ago
<a-pagination :current="pagination.pageNum" :page-size-options="pagination.pageSizeOptions" :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>
3 years ago
</div>
<div v-else-if="secondBreadcrumb == '' || secondBreadcrumb == ''">
<div>
<a-form :form="roleForm" :label-col="{ span: 4 }" :wrapper-col="{ span: 20 }" @submit.event="addSubmit">
<!-- 角色信息 -->
<div class="fw500 mb16 f16">角色信息</div>
<a-form-item class="addItem" label="角色名称:">
<a-input placeholder="请输入角色名称" v-decorator="[ 'aliasName', { rules: [{ required: true, message: '' }] }, ]" />
</a-form-item>
<a-form-item class="addItem" label="角色描述:">
<a-input placeholder="请输入角色描述" v-decorator="[ 'desp', { rules: [{ required: true, message: '' }] }, ]" />
</a-form-item>
<a-divider />
<!-- 功能权限 -->
<div class="fw500 mb16 f16">功能权限</div>
<a-form-item>
<div class>
3 years ago
<a-select default-value="lucy" class="mr8 ml8" style="width:360px" placeholder=" 请在已有的角色选择" v-decorator="['agencyTeamId',{ rules: [{ required: false, message: ' 请在已有的角色选择' }] },]" dropdownClassName="groupSelectDrop">
3 years ago
<a-select-option :value="item.roleName" v-for="(item,index) in roleList">{{item.roleName}}</a-select-option>
<!-- <div slot="dropdownRender" slot-scope="menu">
<div v-for="(item,index) in roleList" @click="choiceGroup(item)" class="groupSelectSub fsa" :key="index">
<div>{{item.roleName}}</div>
</div>
</div>-->
</a-select>
</div>
</a-form-item>
<div v-for="(item, key) in authorityList">
<a-checkbox :checked="item.checked" @change="checkboxChange(item,key)">{{item.label}}</a-checkbox>
<br />
<div class="ml24 mt16">
<a-checkbox v-for="(subItem, subIndex) in item.children" :checked="subItem.checked" :disabled="!item.checked" @change="checkboxChange(subItem,key,subIndex)">{{subItem.label}}</a-checkbox>
</div>
<a-divider />
</div>
<a-form-item>
<a-button type class="mr16" @click="cancelAdd"></a-button>
<a-button type="primary" html-type="submit">保存</a-button>
</a-form-item>
</a-form>
3 years ago
</div>
</div>
3 years ago
<div v-if="secondBreadcrumb == '角色详情' "></div>
3 years ago
</div>
</div>
</template>
<script>
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: '',
roleForm: this.$form.createForm(this),
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,
3 years ago
roleList: [
{
roleDesp: '',
roleCreateTime: '2023-10-20 14:27:17',
classify: 0,
aliasName: '',
userNum: 21,
labelId: 672,
pName: '稻田内测备注',
roleId: 145,
roleName: '稻田内测用户',
sort: 1,
roleType: 1,
labelName: '稻田内测用户',
},
{
roleDesp: '',
roleCreateTime: '2023-10-12 09:34:33',
classify: 0,
aliasName: '',
userNum: 2,
labelId: 670,
pName: '稻田内测备注',
roleId: 144,
roleName: '稻田内测用户1',
sort: 2,
roleType: 1,
labelName: '稻田内测用户1',
},
{
roleDesp: '',
roleCreateTime: '2023-10-12 09:34:33',
classify: 0,
aliasName: '',
userNum: 2,
labelId: 670,
pName: '稻田内测备注',
roleId: 144,
roleName: '稻田内测用户2',
sort: 2,
roleType: 1,
labelName: '稻田内测用户2',
},
],
3 years ago
middleauthor: null,
authorityList: {
dtzw: {
id: 1,
label: '稻田职位',
checked: false,
children: [
{
id: 1,
label: '查看职位列表',
checked: false,
},
{
id: 2,
label: '职位详情页',
checked: false,
},
{
id: 3,
label: '报名',
checked: false,
},
],
},
wdbm: {
id: 2,
label: '我的报名',
checked: false,
children: [
{
id: 1,
label: '查看报名信息',
checked: false,
},
{
id: 2,
label: '修改报名详情',
checked: false,
},
],
},
wdlx: {
id: 3,
label: '我的老乡',
checked: false,
children: [
{
id: 1,
label: '查看老乡信息',
checked: false,
},
{
id: 2,
label: '修改老乡详情',
checked: false,
},
],
},
tdsj: {
id: 4,
label: '团队数据',
checked: false,
children: [
{
id: 1,
label: '查看数据',
checked: false,
},
],
},
xx: {
id: 5,
label: '消息',
checked: false,
children: [
{
id: 1,
label: '系统消息',
checked: false,
},
{
id: 2,
label: '团队消息',
checked: false,
},
],
},
sjht: {
id: 6,
label: '商家后台',
checked: false,
children: [
{
id: 1,
label: '我的团队',
checked: false,
},
{
id: 2,
label: '新增成员',
checked: false,
},
{
id: 3,
label: '修改成员信息',
checked: false,
},
{
id: 4,
label: '删除成员',
checked: false,
},
{
id: 5,
label: '伯才TV',
checked: false,
},
{
id: 6,
label: '数据大屏',
checked: false,
},
],
},
3 years ago
gzt: {
id: 7,
label: '工作台',
checked: false,
children: [],
},
3 years ago
},
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: 'pName',
key: 'pName',
// 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.middleauthor = JSON.parse(JSON.stringify(this.authorityList))
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
addRole(type) {
if (type == 'add') {
this.secondBreadcrumb = '添加角色'
} else {
this.secondBreadcrumb = '编辑角色'
}
3 years ago
this.$forceUpdate()
},
3 years ago
delRole() {
this.$confirm({
title: '删除',
content: '确定要删除该角色吗?',
centered: true,
onOk(e1, e2) {
console.log(e1)
console.log(e2)
return new Promise((res) => {
setTimeout(() => {
res()
}, 2000)
})
},
onCancel() {},
})
},
3 years ago
/**
* 角色信息表单提交
*/
addSubmit() {
this.roleForm.validateFields(async (err) => {
console.log(err)
})
},
/**
* 取消编辑或者新增角色
*/
cancelAdd() {
this.secondBreadcrumb = ''
this.authorityList = JSON.parse(JSON.stringify(this.middleauthor))
},
},
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
.addItem {
width: 468px;
}
.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
</style>