247 lines
7.8 KiB
JavaScript
247 lines
7.8 KiB
JavaScript
|
|
import {ZeroCodeAxios} from "@/request/request.js";
|
|||
|
|
|
|||
|
|
const components = {}
|
|||
|
|
|
|||
|
|
const data = function () {
|
|||
|
|
return {
|
|||
|
|
tableData: [],
|
|||
|
|
dialogVisible: false,
|
|||
|
|
dialogVisible1: false,
|
|||
|
|
dialogVisible2: false,
|
|||
|
|
form: {},
|
|||
|
|
user_permission: [],
|
|||
|
|
all_user_permission: [],
|
|||
|
|
now_select_permission: [],
|
|||
|
|
now_select_access: [],
|
|||
|
|
user_access: [],
|
|||
|
|
all_user_access: [],
|
|||
|
|
selections: [],
|
|||
|
|
ids: [],
|
|||
|
|
loading: true,
|
|||
|
|
dialogVisible3: false,
|
|||
|
|
add_form: {
|
|||
|
|
user_group_name: "",
|
|||
|
|
},
|
|||
|
|
data_objects: [],
|
|||
|
|
filter_obj: "",
|
|||
|
|
filter_access: ""
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function mounted() {
|
|||
|
|
this.fetch_role_data()
|
|||
|
|
this.fetch_access_control_data()
|
|||
|
|
this.fetch_permission_data()
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
const methods = {
|
|||
|
|
fetch_role_data(){
|
|||
|
|
// 解构数据
|
|||
|
|
const {url, method, data: originalData, then} = axios_config.mounted.axios;
|
|||
|
|
const data = JSON.parse(JSON.stringify(originalData));
|
|||
|
|
let new_data = this.get_config_data(data)
|
|||
|
|
new_data["submit_data"]["data"]["user_token"] = sessionStorage.getItem("user")
|
|||
|
|
// 发起请求
|
|||
|
|
ZeroCodeAxios({
|
|||
|
|
method,
|
|||
|
|
url,
|
|||
|
|
data: new_data,
|
|||
|
|
}).then(res => {
|
|||
|
|
// 执行回调函数(then回调)
|
|||
|
|
eval(then)
|
|||
|
|
})
|
|||
|
|
},
|
|||
|
|
fetch_access_control_data(){
|
|||
|
|
// 解构数据
|
|||
|
|
const {url, method, data: originalData, then} = axios_config.mounted.axios;
|
|||
|
|
const data = JSON.parse(JSON.stringify(originalData));
|
|||
|
|
let new_data = this.get_config_data(data)
|
|||
|
|
new_data["submit_data"]["data"]["user_token"] = sessionStorage.getItem("user")
|
|||
|
|
// 发起请求
|
|||
|
|
ZeroCodeAxios({
|
|||
|
|
method,
|
|||
|
|
url,
|
|||
|
|
data: new_data,
|
|||
|
|
}).then(res => {
|
|||
|
|
// 执行回调函数(then回调)
|
|||
|
|
eval(then)
|
|||
|
|
})
|
|||
|
|
},
|
|||
|
|
fetch_permission_data(){
|
|||
|
|
// 解构数据
|
|||
|
|
const {url, method, data: originalData, then} = axios_config.mounted.axios;
|
|||
|
|
const data = JSON.parse(JSON.stringify(originalData));
|
|||
|
|
let new_data = this.get_config_data(data)
|
|||
|
|
new_data["submit_data"]["data"]["user_token"] = sessionStorage.getItem("user")
|
|||
|
|
// 发起请求
|
|||
|
|
ZeroCodeAxios({
|
|||
|
|
method,
|
|||
|
|
url,
|
|||
|
|
data: new_data,
|
|||
|
|
}).then(res => {
|
|||
|
|
// 执行回调函数(then回调)
|
|||
|
|
eval(then)
|
|||
|
|
})
|
|||
|
|
},
|
|||
|
|
filter_premission() {
|
|||
|
|
this.user_permission = this.all_user_permission.filter(item => item.permissions_name.split(' | ')[0] === this.filter_obj)
|
|||
|
|
},
|
|||
|
|
filter_accesss() {
|
|||
|
|
this.user_access = this.all_user_access.filter(item => item.access_control_name.includes(this.filter_access))
|
|||
|
|
},
|
|||
|
|
get_all() {
|
|||
|
|
this.user_permission = this.all_user_permission
|
|||
|
|
},
|
|||
|
|
add_role() {
|
|||
|
|
this.loading = true
|
|||
|
|
// 解构数据
|
|||
|
|
const {url, method, data: originalData, then} = axios_config.mounted.axios;
|
|||
|
|
const data = JSON.parse(JSON.stringify(originalData));
|
|||
|
|
let new_data = this.get_config_data(data)
|
|||
|
|
new_data["submit_data"]["data"]["user_token"] = sessionStorage.getItem("user")
|
|||
|
|
// 发起请求
|
|||
|
|
ZeroCodeAxios({
|
|||
|
|
method,
|
|||
|
|
url,
|
|||
|
|
data: new_data,
|
|||
|
|
}).then(res => {
|
|||
|
|
// 执行回调函数(then回调)
|
|||
|
|
eval(then)
|
|||
|
|
})
|
|||
|
|
},
|
|||
|
|
handleClick(row) {
|
|||
|
|
this.dialogVisible = true
|
|||
|
|
this.form = row
|
|||
|
|
},
|
|||
|
|
Edit_Submit() {
|
|||
|
|
console.log(this.form)
|
|||
|
|
// 解构数据
|
|||
|
|
const {url, method, data: originalData, then} = axios_config.mounted.axios;
|
|||
|
|
const data = JSON.parse(JSON.stringify(originalData));
|
|||
|
|
let new_data = this.get_config_data(data)
|
|||
|
|
new_data["submit_data"]["data"]["user_token"] = sessionStorage.getItem("user")
|
|||
|
|
// 发起请求
|
|||
|
|
ZeroCodeAxios({
|
|||
|
|
method,
|
|||
|
|
url,
|
|||
|
|
data: new_data,
|
|||
|
|
}).then(res => {
|
|||
|
|
// 执行回调函数(then回调)
|
|||
|
|
eval(then)
|
|||
|
|
})
|
|||
|
|
},
|
|||
|
|
conform_add_permission() {
|
|||
|
|
this.dialogVisible1 = false
|
|||
|
|
|
|||
|
|
if (this.now_select_permission.length == 0) {
|
|||
|
|
this.form.permission = {}
|
|||
|
|
} else {
|
|||
|
|
this.form.permission = {}
|
|||
|
|
this.now_select_permission.forEach(item => {
|
|||
|
|
this.form.permission[item.uuid] = item.permissions_name
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
// 解构数据
|
|||
|
|
const {url, method, data: originalData, then} = axios_config.mounted.axios;
|
|||
|
|
const data = JSON.parse(JSON.stringify(originalData));
|
|||
|
|
let new_data = this.get_config_data(data)
|
|||
|
|
new_data["submit_data"]["data"]["user_token"] = sessionStorage.getItem("user")
|
|||
|
|
// 发起请求
|
|||
|
|
ZeroCodeAxios({
|
|||
|
|
method,
|
|||
|
|
url,
|
|||
|
|
data: new_data,
|
|||
|
|
}).then(res => {
|
|||
|
|
// 执行回调函数(then回调)
|
|||
|
|
eval(then)
|
|||
|
|
})
|
|||
|
|
},
|
|||
|
|
conform_add_access() {
|
|||
|
|
this.dialogVisible2 = false
|
|||
|
|
if (this.now_select_access.length == 0) {
|
|||
|
|
this.form.accesses = {}
|
|||
|
|
} else {
|
|||
|
|
this.form.accesses = {}
|
|||
|
|
this.now_select_access.forEach(item => {
|
|||
|
|
this.form.accesses[item.uuid] = item.access_control_name
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
// 解构数据
|
|||
|
|
const {url, method, data: originalData, then} = axios_config.mounted.axios;
|
|||
|
|
const data = JSON.parse(JSON.stringify(originalData));
|
|||
|
|
let new_data = this.get_config_data(data)
|
|||
|
|
new_data["submit_data"]["data"]["user_token"] = sessionStorage.getItem("user")
|
|||
|
|
// 发起请求
|
|||
|
|
ZeroCodeAxios({
|
|||
|
|
method,
|
|||
|
|
url,
|
|||
|
|
data: new_data,
|
|||
|
|
}).then(res => {
|
|||
|
|
// 执行回调函数(then回调)
|
|||
|
|
eval(then)
|
|||
|
|
})
|
|||
|
|
},
|
|||
|
|
Add_group_permission() {
|
|||
|
|
this.dialogVisible1 = true
|
|||
|
|
// 表格勾选项目回显
|
|||
|
|
this.$nextTick(() => {
|
|||
|
|
for (let i = 0; i < this.user_permission.length; i++) {
|
|||
|
|
for (let l in this.form.permission) {
|
|||
|
|
if (this.form.permission[l] == this.user_permission[i]["permissions_name"]) {
|
|||
|
|
this.$refs.user_group_table.toggleRowSelection(this.user_permission[i], true); //回显打勾
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
Add_group_access() {
|
|||
|
|
this.dialogVisible2 = true
|
|||
|
|
// 表格勾选项目回显
|
|||
|
|
this.$nextTick(() => {
|
|||
|
|
for (let i = 0; i < this.user_access.length; i++) {
|
|||
|
|
for (let l in this.form.accesses) {
|
|||
|
|
if (this.form.accesses[l] == this.user_access[i]["access_control_name"]) {
|
|||
|
|
this.$refs.user_group_table.toggleRowSelection(this.user_access[i], true); //回显打勾
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
select_group_permission(val) {
|
|||
|
|
this.now_select_permission = val
|
|||
|
|
},
|
|||
|
|
select_group_access(val) {
|
|||
|
|
this.now_select_access = val
|
|||
|
|
},
|
|||
|
|
handleSelectionChange(selection) {
|
|||
|
|
this.ids = selection.map(item => item.uuid);
|
|||
|
|
},
|
|||
|
|
handleSelection(val) {
|
|||
|
|
this.selections = val
|
|||
|
|
},
|
|||
|
|
tableRowClassName(row) {
|
|||
|
|
var arr = this.ids;
|
|||
|
|
for (let i = 0; i < arr.length; i++) {
|
|||
|
|
if (row.row.uuid === arr[i]) {
|
|||
|
|
return 'rowStyle'
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
cellStyle(cell) {
|
|||
|
|
if (cell.columnIndex == 0 || cell.columnIndex == 1) {
|
|||
|
|
var arr = this.ids;
|
|||
|
|
for (let i = 0; i < arr.length; i++) {
|
|||
|
|
if (cell.row.uuid === arr[i]) {
|
|||
|
|
return 'cell_new'
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
export default {
|
|||
|
|
data: data,
|
|||
|
|
methods: methods,
|
|||
|
|
mounted: mounted,
|
|||
|
|
components: components,
|
|||
|
|
}
|