<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:5px ;">
|
<el-tree :data="treeOptions" :props="defaultProps" :expand-on-click-node="false"
|
:filter-node-method="filterNode" ref="tree" node-key="id" :default-expand-all="false" highlight-current
|
@node-click="handleNodeClick" />
|
</el-col>
|
<el-col :span="8" style="box-shadow: 0 2px 4px rgba(0, 0, 0, .12), 0 0 6px rgba(0, 0, 0, .04)">
|
<el-row style="margin-top: 10px;">
|
<el-radio-group v-model="HSouceBillType" @input="typeInput">
|
<el-radio-button label="yh">用户</el-radio-button>
|
<el-radio-button label="js">角色</el-radio-button>
|
</el-radio-group>
|
</el-row>
|
<div class="btnQueryBox">
|
<div style="flex: 1;">
|
<el-button type="success" size="mini" icon="refresh" @click="getList">刷新</el-button>
|
<el-button type="success" size="mini" icon="search" @click="handleNodeClick">查看</el-button>
|
</div>
|
<div>
|
<el-button icon="el-icon-download" size="mini" title="导出" @click="handleExport"></el-button>
|
</div>
|
</div>
|
<div class="tableBox" v-loading="loading">
|
<el-table :data="tableData" ref="tableData" max-height="750" @selection-change="handleSelectionChange" border
|
v-if="tableShow">
|
<template v-for="(item, index) in btList">
|
<el-table-column type="selection" width="55" align="center" :fixed="item.fixed"
|
v-if="item.type == 'checkbox'" :key="index" />
|
<el-table-column :align="item.align" :prop="item.field" :label="item.title" :width="item.width"
|
:key="item.sorderid" v-else-if="!item.hide && item.type != 'checkbox'" :sortable="item.sort"
|
show-overflow-tooltip :fixed="item.fixed">
|
<template slot-scope="{row, column }">
|
<el-checkbox v-model="checked" v-if="item.type == 'checkbox'"></el-checkbox>
|
<div :style="item.style">{{ row[column.label] }}</div>
|
</template>
|
</el-table-column>
|
</template>
|
</el-table>
|
<pagination v-show="total > 0" :total="total" :page.sync="page" :limit.sync="pageSize" :pageSizes="pageSizes"
|
@pagination="currentPage" />
|
</div>
|
</el-col>
|
<el-col :span="8" style="padding-left: 10px;">
|
<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: 'XtUserRightQuery',
|
components: {},
|
props: {
|
openPage: { type: String, },
|
},
|
data() {
|
return {
|
HModName: 'Xt_UserRightQuery',
|
selQueryRows: [],
|
nodeData: {},
|
linterid: '',
|
HSouceBillType: 'yh',
|
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()
|
this.getList()
|
},
|
methods: {
|
typeInput() {
|
this.tableShow = false
|
this.loading = true
|
this.ids = []
|
this.getList()
|
},
|
getTreeselect() {
|
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
|
}
|
}).catch(error => {
|
this.$modal.msgError("接口请求失败!");
|
});
|
},
|
// 筛选节点
|
filterNode(value, data) {
|
if (!value) return true
|
return data.label.indexOf(value) !== -1
|
},
|
// 节点单击事件
|
handleNodeClick(data) {
|
this.nodeData = data
|
if (!data.id) {
|
this.sGnbm = '权限管理-用户'
|
} else {
|
this.sGnbm = data.id
|
}
|
this.queryData = []
|
this.linterid = ''
|
let text = ''
|
if (this.HSouceBillType == 'yh') {
|
this.linterid = this.rowForm.用户编码
|
text = '请选择一位用户!'
|
} else if (this.HSouceBillType == 'js') {
|
this.linterid = this.rowForm.HGroupID
|
text = '请选择一个角色!'
|
}
|
if (this.linterid) {
|
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 => {
|
this.$modal.msgError("接口请求失败!");
|
});
|
} else {
|
this.$modal.msgError(text);
|
}
|
},
|
//列表数据
|
getList() {
|
this.pageSize = 50
|
this.tableShow = false
|
this.loading = true
|
let url = ''
|
if (this.HSouceBillType == 'yh') {
|
url = '/Xt_User/list'
|
this.btList = [{ type: 'checkbox', fixed: 'left' }
|
, { field: 'hmainid', title: '单据ID', hide: true }
|
, { field: '用户编码', title: '用户编码' }
|
, { field: '用户名称', title: '用户名称' }
|
, { field: '用户类型', title: '用户类型' }
|
, { field: '对应班组', title: '对应班组' }
|
, { field: '对应职员', title: '对应职员' }
|
, { field: '对应保管', title: '对应保管' }
|
, { field: '对应验收', title: '对应验收' }
|
, { field: '对应业务员', title: '对应业务员' }
|
, { field: '对应部门', title: '对应部门' }
|
, { field: '对应仓库', title: '对应仓库' }
|
, { field: '对应调入仓库', title: '对应调入仓库' }
|
, { field: '对应供应商', title: '对应供应商' }
|
, { field: '对应CLOUD账号', title: '对应CLOUD账号' }
|
, { field: '对应CLOUD组织', title: '对应CLOUD组织' }]
|
} else if (this.HSouceBillType == 'js') {
|
url = '/Xt_UserGroup/list'
|
this.btList = [{ type: 'checkbox', fixed: 'left' }
|
, { field: 'HGroupID', title: 'HGroupID', sort: true, hide: true }
|
, { field: '角色', title: '角色' }
|
, { field: '级别', title: '级别' }
|
, { field: '说明', title: '说明' }]
|
}
|
//列表
|
axios.get(this.baseURL + url, {
|
params: {
|
"sWhere": '',
|
"user": sessionStorage["HUserName"],
|
},
|
}).then(response => {
|
this.tyResList = response.data.data//总数据
|
let data1 = response.data
|
this.allTableData = data1.data
|
if (data1.code == 1) {
|
this.total = data1.data.length;
|
for (var i = 1; i < this.btList.length; i++) {
|
this.btResList.push({ ColmCols: this.btList[i].field })
|
}
|
this.tableData = this.getPage(this.page, this.allTableData)//无分页接口分页
|
this.tableShow = true
|
this.loading = false
|
}
|
}).catch(error => {
|
this.$modal.msgError("接口请求失败!");
|
});
|
},
|
// 单选框选中数据
|
handleSelectionChange(selection) {
|
if (selection.length > 1) {
|
const del_row = selection.shift()
|
this.$refs.tableData.toggleRowSelection(del_row, false) //设置这一行取消选中
|
}
|
this.rowForm = {}
|
if (this.HSouceBillType == 'yh') {
|
this.ids = selection.map(item => item.用户编码)
|
} else if (this.HSouceBillType == 'js') {
|
this.ids = selection.map(item => item.HGroupID)
|
}
|
this.rowForm = selection[0]
|
},
|
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('/')
|
}
|
}
|
});
|
},
|
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("接口请求失败!");
|
});
|
},
|
getPage(page, list) {
|
let sindex = (parseInt(page) - 1) * this.pageSize
|
let eindex = parseInt(page) * this.pageSize
|
let newList = list.slice(sindex, eindex)
|
return newList
|
},
|
currentPage(val) {
|
this.page = val.page
|
setTimeout(() => {
|
this.tableData = this.getPage(this.page, this.allTableData)
|
}, 100)
|
},
|
//导出
|
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>
|