11-wms/src/views/wmsSystemSettings/roleManagement.vue
2022-10-21 16:40:09 +08:00

191 lines
4.6 KiB
Vue

<!--
* @Date: 2020-12-15 15:36:52
* @LastEditors: zwq
* @LastEditTime: 2022-10-20 13:57:32
* @FilePath: \mt-bus-fe\src\views\RoleManager\index.vue
* @Description:
-->
<template>
<div class="app-container">
<head-form
:form-config="headFormConfig"
@headBtnClick="btnClick"
/>
<base-table
:top-btn-config="topBtnConfig"
:table-config="tableProps"
:table-data="list"
:is-loading="listLoading"
:page="listQuery.current"
:limit="listQuery.size"
@clickTopBtn="clickTopBtn"
>
<method-btn
slot="handleBtn"
:width="trueWidth"
:method-list="tableBtn"
@clickBtn="handleClick"
/>
</base-table>
<pagination v-show="total > 0" :total="total" :page.sync="listQuery.current" :limit.sync="listQuery.size" @pagination="getList" />
<add-form :visible.sync="showDialog" @done="getList" />
<edit-form :visible.sync="showEditDialog" :target-info="curEditId" @done="getList" />
<menu-empower ref="empowerRef" :visible.sync="empowerDialog" @done="getList" />
</div>
</template>
<script>
import HeadForm from '@/components/basicData/HeadForm'
import i18n from '@/lang'
const topBtnConfig = [
{
type: 'add',
btnName: 'btn.add'
}
]
// edit here
const tableBtn = [{
type: 'edit',
btnName: 'btn.edit'
}, {
type: 'EmPower',
btnName: i18n.t('roleManage.roleEmPower')
}, {
type: 'delete',
btnName: 'btn.delete'
}
]
const tableProps = [{
prop: 'code',
label: i18n.t('roleManage.roleCode'),
align: 'center'
}, {
prop: 'name',
label: i18n.t('roleManage.roleName'),
align: 'center'
}, {
prop: 'enabled',
label: i18n.t('roleManage.status'),
align: 'center'
},
// {
// prop: 'category',
// label: i18n.t('roleManage.roleType'),
// align: 'center',
// filter: basicData('roleType')
// },
{
prop: 'remark',
label: i18n.t('roleManage.remark'),
align: 'center'
}]
import AddForm from './AddForm'
import EditForm from './EditForm'
import menuEmpower from './menuEmpower'
import BaseTable from '@/components/BaseTable'
import Pagination from '@/components/Pagination'
import MethodBtn from '@/components/BaseTable/subcomponents/MethodBtn'
import { getRoleCodeList, getRoleNameList } from '@/utils/wmsDic'
export default {
name: 'RoleManagement',
components: { Pagination, BaseTable, MethodBtn, AddForm, EditForm, HeadForm, menuEmpower },
props: {},
data() {
return {
topBtnConfig,
tableBtn,
tableProps,
list: [],
total: 0,
trueWidth: 120,
listLoading: false,
showDialog: false,
curEditId: null,
showEditDialog: false,
empowerDialog: false,
listQuery: {
current: 1,
size: 20
},
headFormConfig: [
{
type: 'input',
label: i18n.t('module.basicData.visual.keyword'),
placeholder: this.$t('roleManage.roleName'),
param: 'keyName'
},
{
type: 'button',
btnName: 'btn.search',
name: 'search',
color: 'primary'
}
],
headFormValue: {}
}
},
created() {
this.getList()
},
mounted() {},
methods: {
handleClick(raw) {
switch (raw.type) {
case 'delete':
this.$confirm(i18n.t('deleteMsgBox.content'), i18n.t('deleteMsgBox.hint'), {
confirmButtonText: i18n.t('btn.confirm'),
cancelButtonText: i18n.t('btn.cancel'),
type: 'warning'
}).then(async() => {
})
break
case 'edit':
this.showEditDialog = true
this.curEditId = raw.data
break
case 'EmPower':
this.empowerRole(raw.data.id)
break
}
},
async getList() {
const temp = []
const num = 10
for (let i = 0; i < num; i++) {
const obj = {}
obj.code = getRoleCodeList()
obj.name = getRoleNameList()[i]
obj.enabled = parseInt(Math.random() * 2) ? '启用' : '禁用'
obj.remark = '无'
temp.push(obj)
}
this.list = temp
this.total = num
},
// 新增 / 修改
addNew() {
this.showDialog = true
},
empowerRole(id) {
this.empowerDialog = true
this.$nextTick(() => {
this.$refs.empowerRef.init(id)
})
},
btnClick(val) {
this.headFormValue = val
// 如果点击的是搜索栏的其他按钮在这里继续写判断
if (this.headFormValue.btnName === 'search') {
this.getList()
}
},
clickTopBtn(val) {
if (val === 'add') {
this.addNew()// 新增
}
}
}
}
</script>