import axios from "axios"; const components = {} const data = function () { return { tableData: [], dialogVisible: false, dialogVisible1: false, form: { user_name: "", user_number: "" }, user_group: [], now_select_group: [], selections: [], ids: [], dialogVisible3: false, add_form: { user_name: "", user_password: "", repass_password: "" } } } function mounted() { this.fetch_role_data() this.fetch_user_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_user_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) }) }, add_user() { // 解构数据 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() { // 解构数据 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() { this.dialogVisible1 = false this.form.grope = {} this.selections.forEach(item => { this.form.grope[item.user_group_number] = item.user_group_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() { this.dialogVisible1 = true // 表格勾选项目回显 this.$nextTick(() => { for (let i = 0; i < this.user_group.length; i++) { for (let l in this.form.grope) { if (this.form.grope[l] == this.user_group[i]["user_group_name"]) { this.$refs.user_group_table.toggleRowSelection(this.user_group[i], true); //回显打勾 } } } }); }, select_group(val) { this.now_select_group = 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, }