Commit 6dceac3d by liimin

权限按钮修改

2 parents f73b3e42 283f9383
...@@ -3,15 +3,19 @@ export default { ...@@ -3,15 +3,19 @@ export default {
props: { props: {
label: { label: {
type: String, type: String,
default: 'Button' default: ''
}, },
size: { size: {
type: String, type: String,
default: 'mini' default: 'mini'
}, },
type: { // type: {
// type: String,
// default: 'text'
// },
category:{
type: String, type: String,
default: 'text' default: 'operation'
}, },
loading: { loading: {
type: Boolean, type: Boolean,
...@@ -35,30 +39,40 @@ export default { ...@@ -35,30 +39,40 @@ export default {
}, },
data: Object, data: Object,
}, },
functional: true, // 开启函数化组件 functional: true , // 开启函数化组件
render: (h, ctx) => { render: (h, ctx) => {
const _this = ctx.parent //获取 vue this 实例 const _this = ctx.parent //获取 vue this 实例
// console.log(ctx);
/** /**
* 获取传入参数 * 获取传入参数
* type 非必填 button 类型 默认 text ----- route 中不标明 视为默认值 text * category 非必填 button 类别 暂时两种 1 表格操作:operation ,2 Button 按钮: action 默认 operation ----- route 中不标明 视为默认值 operation
* data 点击按钮时 需要得到的参数 比如 table 中的 当前行数据 row * data 点击按钮时 需要得到的参数 比如 table 中的 当前行数据 row
* mapping 非必填 但: 当列表中的操作选项 根据 某个字段 变化的话 必填 且 必须 注明 field: 字段名 * mapping 非必填 但: 当列表中的操作选项 根据 某个字段 变化的话 必填 且 必须 注明 field: 字段名
* label 当传入label 字段时 标识明确指定渲染该label 的按钮
*/ */
const { type , data , mapping } = ctx.props const { category , data , mapping, label } = ctx.props
let curBtns = []
/** /**
* 判断一个按钮(btn)是否存在与当前行(data) 的映射关系(mapping)中 * 判断一个按钮(btn)是否存在与当前行(data) 的映射关系(mapping)中
* @param {*} btn * @param {*} btn
*/ */
const filter = btn => mapping ? mapping[data[mapping['field']]].includes(btn.label):true const filter = btn => mapping ? mapping[data[mapping['field']]].includes(btn.label):true
/** const $store = _this.$store.getters['d2admin/auth/curBtns']
* 拿到当前模块(页面) 所拥有按钮列表 过滤type属性 与 映射关系 返回需要显示的按钮列表 if(label){ //指定label
*/ const __item = $store.find(btn => (btn.label === label) && filter(btn))
const curBtns = _this.$store.getters['d2admin/auth/curBtns'].filter(btn => { __item && curBtns.push(__item)
if(type === 'text' || !type){ }else {
return (btn.type === 'text' || !btn.type) && filter(btn) /**
} * 拿到当前模块(页面) 所拥有按钮列表 过滤type属性 与 映射关系 返回需要显示的按钮列表
return btn.type === type && filter(btn) */
}) curBtns = $store.filter(btn => {
if(category === 'operation'){
return (btn.category === 'operation' || !btn.category) && filter(btn)
}
return (btn.category === category) && filter(btn)
})
}
if(curBtns.length===0) return ''
const __aBtns = [] const __aBtns = []
/** /**
* 循环最终显示的按钮列表 * 循环最终显示的按钮列表
...@@ -67,12 +81,15 @@ export default { ...@@ -67,12 +81,15 @@ export default {
curBtns.forEach(btn => curBtns.forEach(btn =>
__aBtns.push(h('el-button', { __aBtns.push(h('el-button', {
props: { props: {
type type:btn.type||'text',
},
style:{
color:btn.color
}, },
on: { on: {
click: ()=>_this[btn.handle](data) click: ()=>btn.handle && _this[btn.handle](data)
} }
}, [btn.label]))) }, [btn.label])))
return h('div', {}, __aBtns) return h('div', {}, [...__aBtns,ctx.children])
} }
} }
\ No newline at end of file \ No newline at end of file
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: limin * @Author: limin
* @Date: 2019-08-27 19:16:26 * @Date: 2019-08-27 19:16:26
* @Last Modified by: limin * @Last Modified by: limin
* @Last Modified time: 2019-09-02 16:20:21 * @Last Modified time: 2019-09-03 09:07:46
*/ */
const permision = {} const permision = {}
/** /**
......
...@@ -65,99 +65,96 @@ export const sys = [ ...@@ -65,99 +65,96 @@ export const sys = [
* 所有需动态过滤的资源点 * 所有需动态过滤的资源点
*/ */
export const resources = { export const resources = {
'102': {
path: '/page',
icon: 'folder-o',
name: '页面',
meta: {
auth: true,
title: '页面',
id: '102',
pid: '0',
cache: true
}
},
'10201': {
path: '/page1',
name: 'page1',
meta: {
auth: true,
title: '页面 1',
id: '10201',
pid: '102',
cache: true
},
component: _import('demo/page1')
},
'10202': {
path: '/page2',
name: 'page2',
meta: {
auth: true,
title: '页面 2',
id: '10202',
pid: '102',
cache: true
},
component: _import('demo/page2'),
auth: [{ // 列表操作
id: '1020201',
pid: '10202',
label: '查看'
}, { //
id: '1020202',
pid: '10202',
label: '编辑'
}],
},
'10203': {
path: '/page3',
name: '页面 3',
meta: {
auth: true,
title: '页面 3',
id: '10203',
pid: '102'
},
auth: [{ // 列表操作
id: '1020301',
pid: '10203',
label: '查看'
}, { //
id: '1020302',
pid: '10203',
label: '编辑'
}],
component: _import('demo/page3')
},
// '102': { // '102': {
// path: 'trafficManagement', // path: '/page',
// icon: 'train', // icon: 'folder-o',
// name: '车辆管理', // name: '页面',
// meta: { // meta: {
// auth: true, // auth: true,
// title: '车辆管理', // title: '页面',
// id: '102', // id: '102',
// pid: '0' // pid: '0',
// cache: true
// }
// },
// '10201': {
// path: '/page1',
// name: 'page1',
// meta: {
// auth: true,
// title: '页面 1',
// id: '10201',
// pid: '102',
// cache: true
// },
// component: _import('demo/page1')
// },
// '10202': {
// path: '/page2',
// name: 'page2',
// meta: {
// auth: true,
// title: '页面 2',
// id: '10202',
// pid: '102',
// cache: true
// }, // },
// component: _import('trafficManagement'), // component: _import('demo/page2'),
// auth: { // auth: [{ // 列表操作
// 'operation': [{ // id: '1020201',
// id: '10201', // pid: '10202',
// pid: '102', // label: '查看'
// label: '编辑' // }, { //
// }, { // id: '1020202',
// id: '10202', // pid: '10202',
// pid: '102', // label: '编辑'
// label: '删除' // }],
// }],
// 'action': [{
// id: '10203',
// pid: '102',
// label: '添加车辆'
// }]
// }
// }, // },
// '10203': {
// path: '/page3',
// name: '页面 3',
// meta: {
// auth: true,
// title: '页面 3',
// id: '10203',
// pid: '102'
// },
// auth: [{ // 列表操作
// id: '1020301',
// pid: '10203',
// label: '查看'
// }, { //
// id: '1020302',
// pid: '10203',
// label: '编辑'
// }],
// component: _import('demo/page3')
// },
'102': {
path: 'trafficManagement',
icon: 'train',
name: '车辆管理',
meta: {
auth: true,
title: '车辆管理',
id: '102',
pid: '0'
},
component: _import('trafficManagement'),
auth: [{
id: '10201',
pid: '102',
label: '编辑'
}, {
id: '10202',
pid: '102',
label: '删除'
}, {
id: '10203',
pid: '102',
label: '添加车辆'
}]
},
'103': { '103': {
path: '/subSysManagement', path: '/subSysManagement',
icon: 'th-list', icon: 'th-list',
...@@ -184,7 +181,7 @@ export const resources = { ...@@ -184,7 +181,7 @@ export const resources = {
}] }]
}, },
'104': { '104': {
path: '/trafficManagement', path: '/deviceManagement',
icon: 'train', icon: 'train',
name: '物料管理', name: '物料管理',
meta: { meta: {
...@@ -323,7 +320,8 @@ export const resources = { ...@@ -323,7 +320,8 @@ export const resources = {
}, { // }, { //
id: '1070105', id: '1070105',
pid: '10701', pid: '10701',
label: '禁用' label: '禁用',
color:'#FF0000'
}, { // }, { //
id: '1070106', id: '1070106',
pid: '10701', pid: '10701',
...@@ -332,8 +330,9 @@ export const resources = { ...@@ -332,8 +330,9 @@ export const resources = {
id: '1070107', id: '1070107',
pid: '10701', pid: '10701',
label: '创建用户', label: '创建用户',
category:'action',
type:'button', type:'button',
handle:'handleEdit' handle:'handleRegister'
}], }],
component: _import('userManage/user') component: _import('userManage/user')
}, },
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: limin * @Author: limin
* @Date: 2019-08-27 17:25:12 * @Date: 2019-08-27 17:25:12
* @Last Modified by: limin * @Last Modified by: limin
* @Last Modified time: 2019-09-02 16:57:35 * @Last Modified time: 2019-09-03 09:03:37
*/ */
import util from '@/libs/util.js' import util from '@/libs/util.js'
import router from '@/router' import router from '@/router'
......
...@@ -32,14 +32,12 @@ ...@@ -32,14 +32,12 @@
label="导入" label="导入"
class="import-button" class="import-button"
type="" type=""
accept=".csv, application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
@import-file="importFile"
> >
<!-- <input <input
type="file" type="file"
class="import-input" class="import-input"
accept=".csv, application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" accept=".csv, application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
@change="importFile($event)" /> --> @change="importFile($event)" />
</auth-button> </auth-button>
<auth-button label="导出" type=""></auth-button> <auth-button label="导出" type=""></auth-button>
</el-col> </el-col>
...@@ -278,11 +276,16 @@ export default { ...@@ -278,11 +276,16 @@ export default {
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
console.log(index) // // console.log(index)
console.log(row) // console.log(row)
this.$message({ // this.$message({
type: 'success', // type: 'success',
message: '删除成功' // message: '删除成功'
// })
removeApi(row).then(res => {
notice.okTips()
}).catch(err => {
notice.errorTips()
}) })
}).catch(err => {}) }).catch(err => {})
} }
...@@ -296,7 +299,7 @@ export default { ...@@ -296,7 +299,7 @@ export default {
position: relative; position: relative;
cursor: pointer; cursor: pointer;
} }
/* .import-input { .import-input {
opacity: 0; opacity: 0;
position: absolute; position: absolute;
left: 0; left: 0;
...@@ -305,5 +308,5 @@ export default { ...@@ -305,5 +308,5 @@ export default {
height: 100%; height: 100%;
cursor: pointer; cursor: pointer;
font-size:0 font-size:0
} */ }
</style> </style>
...@@ -312,11 +312,16 @@ export default { ...@@ -312,11 +312,16 @@ export default {
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
console.log(index) // console.log(index)
console.log(row) // console.log(row)
this.$message({ // this.$message({
type: 'success', // type: 'success',
message: '删除成功' // message: '删除成功'
// })
removeApi(row).then(res => {
notice.okTips()
}).catch(err => {
notice.errorTips()
}) })
}).catch(err => {}) }).catch(err => {})
} }
......
...@@ -248,11 +248,16 @@ export default { ...@@ -248,11 +248,16 @@ export default {
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
console.log(index) // console.log(index)
console.log(row) // console.log(row)
this.$message({ // this.$message({
type: 'success', // type: 'success',
message: '删除成功' // message: '删除成功'
// })
removeApi(row).then(res => {
notice.okTips()
}).catch(err => {
notice.errorTips()
}) })
}).catch(err => {}) }).catch(err => {})
} }
......
...@@ -156,21 +156,6 @@ export default { ...@@ -156,21 +156,6 @@ export default {
this.currentPage = value this.currentPage = value
// 调接口 // 调接口
this.loadingGetList() this.loadingGetList()
},
handleDelete (index, row) {
this.$confirm('确认删除?', '删除', {
comfirmButtonText: '确认',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
console.log(index)
console.log(row)
this.$message({
type: 'success',
message: '删除成功'
})
}).catch(err => {})
} }
} }
} }
......
...@@ -265,11 +265,16 @@ export default { ...@@ -265,11 +265,16 @@ export default {
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
console.log(index) // console.log(index)
console.log(row) // console.log(row)
this.$message({ // this.$message({
type: 'success', // type: 'success',
message: '删除成功' // message: '删除成功'
// })
removeApi(row).then(res => {
notice.okTips()
}).catch(err => {
notice.errorTips()
}) })
}).catch(err => {}) }).catch(err => {})
} }
......
...@@ -261,11 +261,16 @@ export default { ...@@ -261,11 +261,16 @@ export default {
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
console.log(index) // console.log(index)
console.log(row) // console.log(row)
this.$message({ // this.$message({
type: 'success', // type: 'success',
message: '删除成功' // message: '删除成功'
// })
removeApi(row).then(res => {
notice.okTips()
}).catch(err => {
notice.errorTips()
}) })
}).catch(err => {}) }).catch(err => {})
} }
......
...@@ -67,8 +67,7 @@ ...@@ -67,8 +67,7 @@
<el-row style="height: 40px; line-height: 40px"> <el-row style="height: 40px; line-height: 40px">
<el-col :span="12">用户列表</el-col> <el-col :span="12">用户列表</el-col>
<el-col :span="12" style="text-align: right"> <el-col :span="12" style="text-align: right">
<!-- <el-button @click="register()">创建用户</el-button> --> <auth-button category="action" label="创建用户"></auth-button>
<auth-button type="button" ></auth-button>
</el-col> </el-col>
</el-row> </el-row>
<el-table :data="tableData" v-loading="tableLoading" border style="margin: 20px 0;"> <el-table :data="tableData" v-loading="tableLoading" border style="margin: 20px 0;">
...@@ -89,11 +88,6 @@ ...@@ -89,11 +88,6 @@
<el-table-column align="center" label="操作"> <el-table-column align="center" label="操作">
<template slot-scope="scope"> <template slot-scope="scope">
<auth-button :mapping="mapping" :data="scope.row"></auth-button> <auth-button :mapping="mapping" :data="scope.row"></auth-button>
<!-- <auth-button type="text" label="审核" :mapping="mapping" @click="handleEdit(scope.row, scope.$index)"></auth-button>
<auth-button type="text" label="编辑" :mapping="mapping" @click="handleEdit(scope.row, scope.$index)"></auth-button>
<auth-button type="text" label="延期" :mapping="mapping" @click="handleEdit(scope.row, scope.$index)"></auth-button>
<auth-button type="text" label="禁用" :mapping="mapping" @click="handleEdit(scope.row, scope.$index)"></auth-button>
<auth-button type="text" label="激活" :mapping="mapping" @click="handleEdit(scope.row, scope.$index)"></auth-button> -->
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
...@@ -273,7 +267,9 @@ export default { ...@@ -273,7 +267,9 @@ export default {
this.tableLoading = false; this.tableLoading = false;
}); });
}, },
handleRegister(){
console.log(this.searchForm);
},
// 页码 // 页码
handleSizeChange(value) { handleSizeChange(value) {
this.page.pageSize = value; this.page.pageSize = value;
...@@ -296,12 +292,17 @@ export default { ...@@ -296,12 +292,17 @@ export default {
type: "warning" type: "warning"
}) })
.then(() => { .then(() => {
console.log(index); // console.log(index)
console.log(row); // console.log(row)
this.$message({ // this.$message({
type: "success", // type: 'success',
message: "删除成功" // message: '删除成功'
}); // })
removeApi(row).then(res => {
notice.okTips()
}).catch(err => {
notice.errorTips()
})
}) })
.catch(err => {}); .catch(err => {});
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!