Commit 87072cca authored by 李苏's avatar 李苏 💬

定制路由

parent 817ba19c
This diff is collapsed.
......@@ -20,7 +20,7 @@ import {
} from 'common/src/utils/router/dynamic.js'
/* 过滤mkid相同的定制路由 */
commonList.list=[]
const permission = {
state: {
routes: [],
......
<template>
<DefaultDialog :app='app'>
<div slot="form" style="display: flex;height: 70vh;">
<!-- 树型图-->
<!-- 表格 -->
<div style="width: 100%;overflow: auto;">
<TablePager @getData='getData' :delButton='false' :ref="'TablePager'" :app='this' :query='query' @selectItem='selectItem'
@getRow='getRow'>
</TablePager>
</div>
</div>
<div slot="reFooter" class="refooter" >
<span slot="footer" class="dialog-footer" >
<el-button @click="app.showDialog=false">取 消</el-button>
<el-button type="primary" @click="save()">保 存</el-button>
</span>
</div>
</DefaultDialog>
</template>
<script>
import {
tableMixin_noapp
} from 'common'
import {
QueryUserOperate,
SaveYhqx,
usrcopyyhqx,
usrcopyyhqxset
} from "common/src/api/system/dmgSystem.js";
export default {
mixins: [tableMixin_noapp],
props: {
app: {
type: Object,
default: {}
}
},
async mounted() {
this.$nextTick(()=>{
debugger
this.queryParams.sourceuserid=this.app.singleItem.userid
this.$refs.TablePager.pageQuery()
})
},
data() {
return {
baseUrl: 'kzzx/user',
queryParams: {
sourceuserid:''
},
tableTitle: [{
prop: 'userid',
label: '用户编码',
width: '250',
},
{
prop: 'username',
label: '姓名',
},
{
prop: 'bmmc',
label: '所属组织',
},
],
}
},
methods: {
query:usrcopyyhqx,
handleNodeClick(item) {
this.mkqxList = item.mkqxList || []
},
save(){
if(this.singleItem.id){
let params={
sourceuserid: this.singleItem.userid,
targetuserid: this.queryParams.sourceuserid
}
console.log(params)
usrcopyyhqxset(params).then(e=>{
if(e.success){
this.$success('保存成功')
this.app.showDialog=false
}
})
}else{
this.$warning('请选中一条数据')
}
},
}
}
</script>
<style scoped>
</style>
<template>
<RelDialog :type='type' :editApp='editApp' :app='app' :buttonApp='buttonApp'>
<!-- 填写表单内容,slot=form必写-->
<el-form slot="form" ref="form" :model="form" label-width="80px" :rules="rules">
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="用户编码"
v-rule="{
type:'upper',
required: true,
rules:rules
}"
ref="userid" prop="userid">
<el-input :readonly="readonly" v-model="form.userid"></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item v-rule="{
rules:rules
}" label="用户名称" ref="username" prop="username">
<el-input :readonly="readonly" v-model="form.username"></el-input>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item :span="24" label="部门">
<RelSelect style="width: 100%;" :readonly="readonly" src='kzzx/bm/query' :match="{value:'id',label:'bmmc'}" v-model='form.bmid' ></RelSelect>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="电话">
<el-input :readonly="readonly" v-model="form.phone"></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="邮箱"
prop="email"
>
<el-input :readonly="readonly" v-model="form.email"></el-input>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="备注">
<el-input :readonly="readonly" v-model="form.bz"></el-input>
</el-form-item>
</el-col>
</el-row>
</el-form>
<!-- 按钮重写, -->
<!-- <div slot="reFooter">
<span slot="footer">
重写按钮写在这里,根据需要重写 slot(reFooter,foorer) 节点样式 重写方法需要在此页重新定义
</span>
</div> -->
</RelDialog>
</template>
<script>
import {editMixin} from 'common'
export default {
mixins: [editMixin],
/* 存放index页面传递的额外参数*/
mounted() {
this.form.bmid=this.app.queryParams.bmid
if(this.form.bmid=='root'){
this.form.bmid=''
}
this.app.apiTreeQuery({}).then(res=>{
this.bmList=res.data.records
/* 默认选中 */
})
setTimeout(()=>{
console.log(this.rules.userid)
})
},
/* 组件名称*/
name: 'roleManagementEdit',
/* 传递props模式一样必填,用于index,button,REdialog之间的组件通信*/
data() {
return {
/* 额外初始化,根据需求*/
bmList: [],
/* 当前表单初始值,默认由RelDialog查询indexQuery赋值,copy时不赋值id,初始化时所有query的值都会赋值给form*/
form: {
bmid:'',
userid: '',
username: '',
phone:'',
email:'',
bz: "",
},
/* form提交时的规则,具体规则参考官网*/
rules: {
username: [{
required: true,
trigger: 'blur'
}, ]
}
}
},
methods: {
}
}
</script>
<style scoped lang="scss">
</style>
<template>
<div style="display: flex;">
<Power :app='app' v-if="(showDialog&&DialogName=='doPower')"></Power>
<SetRole :app='app' v-if="(showDialog&&DialogName=='SetRole')"></SetRole>
<CopyPower :app='app' v-if="(showDialog&&DialogName=='copyPower')" ></CopyPower>
<div class="min_full" style="width: 200px;border-right: 0px;">
<TreeBase :app='app' @selected='selectedTree'></TreeBase>
</div>
<div class="min_full" style="width: calc(100% - 200px)">
<!-- 查询条件-->
<div class="search" v-condition >
<SearchButton :app='app'></SearchButton>
<el-row :gutter="20" class="search-row-1">
<el-col :span="6" class="search-col">
<div class="search-item">
<span class="search-span">用户:</span>
<el-input v-model="queryParams.usercx" size="small" class="search-input"></el-input>
</div>
</el-col>
<el-col :span="6" class="search-col">
<div class="search-item">
<span class="search-span">电话:</span>
<el-input v-model="queryParams.phone" size="small" class="search-input"></el-input>
</div>
</el-col>
<el-col :span="4" class="search-col">
<div class="search-item">
<el-checkbox true-label='Y' false-label='' v-model="queryParams.login">显示登录用户</el-checkbox>
</div>
</el-col>
<el-col :span="4" class="search-col">
<div class="search-item">
<el-checkbox true-label='' false-label='N' v-model="queryParams.tybz">显示所有用户</el-checkbox>
</div>
</el-col>
</el-row>
</div>
<!-- 按钮操作-->
<el-row class="tool-bar">
<ViewButton ref="view" :app='app'></ViewButton>
<AddButton ref="add" :app='app'></AddButton>
<CopyButton ref="copy" :app='app'></CopyButton>
<EditButton ref="edit" :app='app'></EditButton>
<DeleteButton :app='app'></DeleteButton>
<ToolButton :app='app'></ToolButton>
<!-- 权限-->
<el-dropdown class="margin-right-10" v-if="powerObj['22']" >
<el-button type="primary" size='mini'>
权限<i class="el-icon-arrow-down el-icon--right"></i>
</el-button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item @click.native="doPower(item)" v-for="(item,index) in powerList" :key="index">
{{item.name}}</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
<el-button v-if="powerObj['24']" size='mini' @click.native="setLogin" class="margin-right-10" type="primary">切换登录状态</el-button>
<el-button v-if="powerObj['21']" size='mini' @click.native="resetPassWord" style="margin-left: 0px;" type="primary">重置密码</el-button>
<el-button v-if="powerObj['23']" size='mini' @click.native="setRole" style="margin-left: 10px;" type="primary">分配角色</el-button>
<ImportButton style="margin-left: 10px;" @success="()=>{
$refs['TablePager'].pageQuery()
}" :url="'xtgl/user/import'" />
</el-row>
<!-- 表格-->
<div class="tablePagers">
<TablePager @getData='getData' :ref="'TablePager'" :app='app' :query='query' @selectItem='selectItem'
@getRow='getRow'>
<template slot="tabCustom">
<el-table-column label="启用/停用" width="90" header-align="center" >
<template slot-scope="scope">
<el-switch @click.native="setEnable(scope.row.id)" :value='tybz(scope)' style="width: 80px;justify-content: center;"
active-color="#13ce66" inactive-color="#eee">
</el-switch>
</template>
</el-table-column>
</template>
</TablePager>
</div>
</div>
</div>
</template>
<script>
/* 引入需要的接口*/
import {
QueryUser,
QueryApptype,
AddUser,
DeleteUser,
UpdateUser,
QtUser,
QueryBm,
Setcanlogin,
ResetPassword
} from "common/src/api/system/dmgSystem.js";
/* edit页面*/
import Edit from './edit'
import Power from './power'
import SetRole from './setRole'
import CopyPower from './copyPower'
import {
tableMixin
} from 'common'
export default {
mixins: [tableMixin],
name: 'appVersion',
/* 初始额外赋值*/
async mounted() {
},
data() {
return {
/*需要的额外参数 */
showDialog: false,
DialogName: '',
type: '',
DialogTitle: '',
powerList: [{
name: '分配'
}, {
name: '复制'
}, {
name: '查看'
}],
/* 基础url*/
baseUrl: 'kzzx/user',
/* 查询参数*/
queryParams: {
bmid:'',
usercx: '',
phone:'',
login:'Y',
tybz:''
},
/* 树的标题 */
treeTitle: '部门列表',
treeDefaultProps: {
children: 'children',
label: 'bmmc'
},
/* 表格标题对应参数*/
tableTitle: [{
prop: 'userid',
label: '用户编码',
width: '120'
},
{
prop: 'username',
label: '姓名',
width: '160'
},
{
prop: 'bmmc',
label: '所属部门',
width: '160'
},
{
prop: 'phone',
label: '电话',
width: '160'
},
{
prop: 'email',
label: '邮箱',
width: '160'
},
// {
// prop: 'zt',
// label: '状态',
// width: '160'
// },
{
prop: 'login',
label: '登录用户',
width: '160',
formatter(row, column, cellValue, index) {
let value=''
if(cellValue=='Y'){
value='登录用户'
}else{
value='非登录用户'
}
return value
},
},
{
prop: 'tyrq',
label: '停用日期',
width: '120',
...this.$common('ftDate')
},
{
prop: 'whr',
label: '维护人',
width: '100'
},
{
prop: 'whsj',
label: '维护时间',
...this.$common('ftDateTime')
},
{
prop: 'bz',
label: '备注',
},
]
}
},
methods: {
selectedTree(e){
this.queryParams.bmid=e.id||'root'
this.$refs['TablePager'].pageQuery()
},
tybz(a) {
let nTy = false
nTy = (a.row.tybz == 'N' ? true : false)
return nTy
},
resetPassWord(){
if (this.app.selectOne || this.app.clickOne) {
this.$confirm('此操作将重置用户密码, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
let params = {
userid:this.singleItem.id
}
ResetPassword(params).then(res => {
if (res.success) {
this.$success('操作成功')
this.$refs['TablePager'].pageQuery()
} else {
this.$error(res.message || '操作失败')
}
})
})
} else {
this.$warning('请选中一行操作');
}
},
setLogin(){
if (this.app.selectOne || this.app.clickOne) {
this.$confirm('此操作将改变用户登录状态, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
let params = {
id:this.singleItem.id
}
Setcanlogin(params).then(res => {
if (res.success) {
this.$success('操作成功')
this.$refs['TablePager'].pageQuery()
} else {
this.$error(res.message || '操作失败')
}
})
})
} else {
this.$warning('请选中一行操作');
}
},
setRole(){
if (this.app.selectOne || this.app.clickOne) {
this.DialogName = 'SetRole'
this.DialogWidth = '700px'
this.DialogTitle = '设置角色'
this.showDialog = true
} else {
this.$warning('请选中一行操作');
}
},
doPower(item) {
if (this.app.selectOne || this.app.clickOne) {
if(item.name=='复制'){
this.DialogName = 'copyPower'
this.DialogWidth = '70%'
this.DialogTitle = '权限:' + item.name
this.showDialog = true
return
}
this.DialogName = 'doPower'
this.DialogWidth = '70%'
this.DialogTitle = '权限:' + item.name
this.type = item.name
this.showDialog = true
} else {
this.$warning('请选中一行操作');
}
},
doRole() {
if (this.app.selectOne || this.app.clickOne) {
this.DialogName = 'doRole'
this.DialogWidth = '70%'
this.DialogTitle = '角色人员'
this.showDialog = true
} else {
this.$warning('请选中一行操作');
}
},
doAdjust() {
if (this.app.selectOne || this.app.clickOne) {
this.DialogName = 'adjust'
this.DialogWidth = '50%'
this.DialogTitle = '调整人员顺序'
this.showDialog = true
} else {
this.$warning('请选中一行操作');
}
},
/* 基础查询*/
query: QueryUser,
/* 基础增*/
apiAdd: AddUser,
/* 基础更新*/
apiUpdate: UpdateUser,
/* 删除操作*/
apiDelete: DeleteUser,
/* treeQuery */
apiTreeQuery: QueryBm,
/* 初始化赋值操作*/
init() {
},
/* 启用停用*/
setEnable(id) {
this.$confirm('是否启用/停用该角色, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
let params = {
id: id
}
QtUser(params).then(res => {
if (res.success) {
this.$success('操作成功')
this.app.$refs['TablePager'].refresh()
} else {
this.$error(res.message || '操作失败')
}
})
})
}
},
components:{
Edit,Power,SetRole,
CopyPower
}
}
</script>
<style scoped>
</style>
<template>
<DefaultDialog :app='app'>
<div slot="form" style="display: flex;height: 70vh;">
<!-- 树型图-->
<div style="width: 30%;border-right: 1px solid #eee;overflow: auto;">
<el-tree :highlight-current='true' @node-click="handleNodeClick" :data="treeData" show-checkbox node-key="mkid" ref="tree"
:default-checked-keys="defaultChecked" :default-expanded-keys="defaultExpanded" :props="defaultProps">
</el-tree>
</div>
<!-- 表格 -->
<div style="width: 70%;overflow: auto;">
<el-table
:data="mkqxList"
border
style="width: 100%;height: 100%;">
<el-table-column v-for="(item,index) in tableTitle " :key='index'
:prop="item.prop"
:label="item.label"
:width="item.width"
:formatter="item.formatter||null"
header-align="center"
>
</el-table-column>
<el-table-column
header-align="center"
label="操作"
width="100">
<template slot-scope="scope">
<el-button @click="handleClick(scope.row)" style="width: 100%;text-align: center;" type="text" size="mini">赋权/<span style="color:red">取消</span></el-button>
</template>
</el-table-column>
</el-table>
</div>
</div>
<div slot="reFooter" class="refooter" >
<span slot="footer" class="dialog-footer" >
<el-button @click="app.showDialog=false">取 消</el-button>
<el-button v-if="app.type=='分配'" type="primary" @click="save()">保 存</el-button>
</span>
</div>
</DefaultDialog>
</template>
<script>
import {
QueryUserOperate,
SaveYhqx
} from "common/src/api/system/dmgSystem.js";
export default {
props: {
app: {
type: Object,
default: {}
}
},
async mounted() {
let res = await QueryUserOperate({
userid: this.app.singleItem.userid
})
let treeData = res.data.records
treeData.forEach(e => {
this.defaultExpanded.push(e.mkid)
if (e.userRight != 'N') {
this.defaultChecked.push(e.mkid)
console.log(this.defaultChecked)
}
})
this.treeData=this.dgData(treeData, '0')
this.treeData = [
{
mkid:'root',
mkmc:localStorage.getItem('appName'),
children: this.dgData(treeData, '0')
}
]
},
name: 'role',
data() {
return {
tableTitle: [{
prop: 'czid',
label: '编号',
width: '50',
},
{
prop: 'czmc',
label: '授权功能',
},
{
prop: 'value',
label: '授权状态',
formatter:(a,b,c)=>{
let map={
Y:"已授权",
N:"未授权"
}
let value =map[c]
return value
}
},
],
treeData: [],
defaultChecked: [],
defaultExpanded:[],
defaultProps: {
children: 'children',
label: 'mkmc'
},
mkqxList: [],
}
},
methods: {
handleClick(item){
this.mkqxList.forEach((e,index)=>{
if(e.czid==item.czid){
if(item.value=='Y'){
this.mkqxList[index].value='N'
}else{
this.mkqxList[index].value='Y'
}
}
})
},
handleNodeClick(item) {
this.mkqxList = item.mkqxList || []
},
dgData(arr, pid) {
let oldarr = JSON.parse(JSON.stringify(arr))
let outarr = []
oldarr.forEach((e, index) => {
if (e.fmkid == pid) {
outarr.push(e)
e.children = this.dgData(oldarr, e.mkid)
}
})
return outarr
},
save(){
let params={
modules:[...this.$refs.tree.getCheckedNodes()],
userid: this.app.singleItem.userid
}
SaveYhqx(params).then(e=>{
if(e.success){
this.$success('保存成功')
this.app.showDialog=false
}
})
},
}
}
</script>
<style scoped>
</style>
<template>
<DefaultDialog :app='app'>
<div slot="form" style="display: flex;height: 500px;padding-left: 35px;;">
<el-transfer
:titles="['未添加角色表', '已有角色表']"
style="height: 100%;width: 100%;transform: scale(1,1)"
filterable
:filter-method="filterMethod"
filter-placeholder="请输入搜索字段"
v-model="value"
:data="data">
</el-transfer>
</div>
<div slot="reFooter" class="refooter" >
<span slot="footer" class="dialog-footer" >
<el-button @click="app.showDialog=false">取 消</el-button>
<el-button type="primary" @click="save()">保 存</el-button>
</span>
</div>
</DefaultDialog>
</template>
<script>
import {
QueryRoleNotInUser,
QueryRoleByUser,
QueryKzzxRole,
SaveUserRoles
} from "common/src/api/system/dmgSystem.js";
export default {
props: {
app: {
type: Object,
default: {}
}
},
async mounted() {
let data=[]
let value=[]
QueryRoleByUser({
userid:this.app.singleItem.userid
}).then(res=>{
res.data.records.forEach(e=>{
value.push(e.roleid)
})
this.value=value
this.oldValue=value
})
QueryKzzxRole({
}).then(res=>{
res.data.records.forEach(e=>{
let item={
label:e.rolename,
key:e.roleid,
pinyin:e.rolename,
}
data.push(item)
})
this.data=data
})
},
name: 'setRole',
data() {
return {
data: [],
value: [],
oldValue:[],
filterMethod(query, item) {
return item.pinyin.indexOf(query) > -1;
}
};
},
watch:{
value:function(val){
console.log(val)
}
},
methods: {
save(){
let list=[]
this.value.forEach(e=>{
if(this.oldValue.indexOf(e)==-1){
let item={
roleid:e,
flag:'I'
}
list.push(item)
}
})
this.oldValue.forEach(e=>{
if(this.value.indexOf(e)==-1){
let item={
roleid:e,
flag:'D'
}
list.push(item)
}
})
let params={
userid:this.app.singleItem.userid,
list:list
}
SaveUserRoles(params).then(res=>{
if(res.success){
this.$success('保存成功')
this.app.showDialog = false
}
})
}
}
}
</script>
<style scoped>
/deep/.el-transfer-panel__body{
height: 400px;
}
/deep/.el-checkbox-group .el-transfer-panel__list .is-filterable{
height: 100%;
}
/deep/.el-transfer-panel__list.is-filterable{
height: 100%;
}
</style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment