<template>
|
<div style="padding: 10px;">
|
<el-row>
|
<el-button type="primary" @click="handleSaver">保存</el-button>
|
<el-button type="primary" @click="close">退出</el-button>
|
</el-row>
|
<el-row>
|
<el-col :span="8" style="padding-right:10px ;">
|
<el-tree :data="treeOptions" :props="defaultProps" :expand-on-click-node="false"
|
:default-checked-keys="['权限管理-用户']" :filter-node-method="filterNode" ref="tree" node-key="id"
|
:default-expand-all="false" highlight-current @node-click="handleNodeClick" />
|
</el-col>
|
<el-col :span="16">
|
<el-table :data="queryData" ref="queryMultipleTable" max-height="800" @selection-change="handleQueryChange"
|
border v-if="tableQueryShow">
|
<el-table-column type="selection" width="55" prop="AuthorityID" align="center" />
|
<el-table-column align="center" prop="AuthorityID" label="是否权限" show-overflow-tooltip>
|
<template slot-scope="scope">
|
<span style="color: green;" v-if="scope.row.AuthorityID == 1">是</span>
|
<span v-else-if="scope.row.AuthorityID == 0">否</span>
|
</template>
|
</el-table-column>
|
<el-table-column align="center" prop="gnms" label="功能说明" show-overflow-tooltip />
|
</el-table>
|
</el-col>
|
</el-row>
|
</div>
|
</template>
|
|
<script>
|
import axios from 'axios'
|
export default {
|
name: 'PowerInformation',
|
components: {},
|
props: {
|
HSouceBillType: { type: String, },
|
linterid: {},
|
},
|
data() {
|
return {
|
powerShow: false,
|
HModName: 'Xt_UserRightQuery',
|
selQueryRows: [],
|
nodeData: {},
|
queryData: [],
|
tableQueryShow: false,
|
//树结构
|
treeOptions: [],
|
defaultProps: {
|
children: "children",
|
label: "title"
|
},
|
tableShow: true,
|
sGnbm: '',
|
organizationList: JSON.parse(sessionStorage.getItem('organizationList')),//组织列表
|
baseURL: process.env.VUE_APP_BASE_API,
|
rowForm: {},
|
// 弹出层标题
|
title: "",
|
// 选中数组
|
ids: [],
|
// 遮罩层
|
loading: true,
|
tyResList: [],//列表(接口数据)
|
btList: [],//表头列表显示
|
btResList: [],
|
tableData: [],//列表(分页显示)
|
allTableData: [],
|
pageSizes: [50, 100, 500, 5000, 50000],
|
page: 1,
|
pageSize: 0,
|
total: 0,
|
};
|
},
|
created() {
|
this.getTreeselect()
|
},
|
methods: {
|
getTreeselect() {
|
console.log(1)
|
axios.get(this.baseURL + 'Gy_MaintenanceMode/PowerLoadTree').then(response => {
|
let data1 = response.data
|
if (data1.count == 1) {
|
let map = {};
|
let treeData = [];
|
data1.data.forEach(it => {
|
map[it.id.toUpperCase()] = it; //ID为每个节点的id
|
})
|
//生成结果集
|
data1.data.forEach(it => {
|
const parent = map[it.ParentID.toUpperCase()]; //ParentID为父节点的id
|
if (parent) {
|
if (!Array.isArray(parent.children)) parent.children = [];
|
parent.children.push(it);
|
} else {
|
treeData.push(it)
|
}
|
})
|
this.treeOptions = treeData
|
this.powerShow = true
|
this.handleNodeClick()
|
}
|
}).catch(error => {
|
console.log(error)
|
this.$modal.msgError("接口请求失败!");
|
});
|
},
|
// 筛选节点
|
filterNode(value, data) {
|
if (!value) return true
|
return data.label.indexOf(value) !== -1
|
},
|
// 节点单击事件
|
handleNodeClick(data) {
|
this.nodeData = data
|
if (!data) {
|
this.sGnbm = '权限管理-用户'
|
} else {
|
this.sGnbm = data.id
|
}
|
this.queryData = []
|
let text = ''
|
axios.get(this.baseURL + '/PublicPageMethod/PowerList', {
|
params: {
|
czybm: this.linterid,
|
sGnbm: this.sGnbm,
|
HSouceBillType: this.HSouceBillType,
|
},
|
}).then(response => {
|
this.queryData = response.data.data
|
this.tableQueryShow = true
|
this.$nextTick(() => {
|
if (this.queryData.length > 0) {
|
this.queryData.forEach(row => {
|
if (row.AuthorityID) {
|
this.$refs.queryMultipleTable.toggleRowSelection(row);
|
}
|
});
|
} else {
|
this.$refs.queryMultipleTable.clearSelection();
|
}
|
|
})
|
}).catch(error => {
|
console.log(error)
|
this.$modal.msgError("接口请求失败!");
|
});
|
},
|
handleQueryChange(selection) {
|
this.selQueryRows = selection
|
this.queryData.forEach(row => {
|
row.AuthorityHID = this.selQueryRows.some(selectedRow => selectedRow.hgnbm === row.hgnbm) ? 1 : 0;
|
});
|
},
|
//退出
|
close() {
|
// const obj = { fullPath: this.$route.path, path: this.$route.path, name: this.$route.name, };
|
// this.$tab.closePage(obj).then(res => {
|
// const latestView = res.visitedViews.slice(-1)[0]
|
// if (latestView) {
|
// this.$router.push(latestView.fullPath)
|
// } else {
|
// if (obj.name === 'Dashboard') {
|
// this.$router.replace({ path: '/redirect' + obj.fullPath })
|
// } else {
|
// this.$router.push('/')
|
// }
|
// }
|
// });
|
this.powerShow = false
|
this.$emit('editQueryClose', false)
|
},
|
handleSaver() {
|
var sSubStr = JSON.stringify(this.queryData);
|
var sMainSub = this.sGnbm + ';' + sSubStr + ';' + this.linterid + ";" + this.HSouceBillType;
|
axios({
|
method: 'post',
|
url: this.baseURL + "/Gy_MaintenanceMode/SaverPower",
|
data: {
|
'msg': sMainSub
|
},
|
}).then(response => {
|
if (response.data.count == 1) {
|
this.subDisabled = true//设置保存按钮不可用
|
this.$modal.msgSuccess(response.data.Message);
|
this.handleNodeClick(this.nodeData)
|
}
|
}).catch(error => {
|
this.$modal.msgError("接口请求失败!");
|
});
|
},
|
//导出
|
handleExport() {
|
const ws = this.$XLSX.utils.json_to_sheet(this.tyResList); // 将数据转换为工作表
|
const wb = this.$XLSX.utils.book_new(); // 创建一个新的工作簿
|
this.$XLSX.utils.book_append_sheet(wb, ws, "Sheet1"); // 将工作表添加到工作簿中,并命名为"Sheet1"
|
this.$XLSX.writeFile(wb, this.HSouceBillType + `_${new Date().getTime()}.xlsx`); // 导出文件
|
},
|
}
|
};
|
</script>
|
<style>
|
.xsckdBox .el-date-editor.el-input {
|
width: 100%;
|
}
|
|
.btnQueryBox {
|
margin-top: 10px;
|
padding: 5px;
|
border-top: 1px solid #ebebeb;
|
display: flex;
|
justify-content: right;
|
}
|
</style>
|