优化 数据权限关联员工

This commit is contained in:
wuxw 2022-09-28 18:39:17 +08:00
parent 5fbac9e71b
commit b59aba2889
8 changed files with 315 additions and 18 deletions

View File

@ -0,0 +1,82 @@
<div id="addDataPrivilegeStaffModel" class="modal fade" role="dialog" aria-labelledby="addDataPrivilegeStaffModelLabel"
aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title" id="addDataPrivilegeStaffModelLabel">
<span><vc:i18n name="员工" namespace="addDataPrivilegeStaff"></vc:i18n></span>
</h3>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div class="row">
<div class="col-lg-12">
<div class="ibox ">
<div class="row">
<div class="col-sm-7 m-b-xs"></div>
<div class="col-sm-5">
<div class="input-group">
<input :placeholder="vc.i18n('输入员工名称','addDataPrivilegeStaff')" type="text"
v-model="addDataPrivilegeStaffInfo.staffName"
class="form-control form-control-sm">
<span class="input-group-append">
<button type="button" class="btn btn-sm btn-primary"
v-on:click="queryStaffs()">
<span><vc:i18n name="查询" namespace="addDataPrivilegeStaff"></vc:i18n></span>
</button>
</span>
</div>
</div>
</div>
<div class="table-responsive" style="margin-top:15px">
<table class="table table-striped">
<thead>
<tr>
<th class="text-center">
<input type="checkbox" class="i-checks " @click="checkAll($event)"
id="quan">
</th>
<th class="text-center">
<span><vc:i18n name="员工编号" namespace="addDataPrivilegeStaff"></vc:i18n></span></th>
<th class="text-center">
<span><vc:i18n name="员工名称" namespace="addDataPrivilegeStaff"></vc:i18n></span>
</th>
<th class="text-center">
<span><vc:i18n name="员工地址" namespace="addDataPrivilegeStaff"></vc:i18n></span>
</th>
</tr>
</thead>
<tbody>
<tr v-for="staff in addDataPrivilegeStaffInfo.staffs">
<td class="text-center">
<input type="checkbox" class="i-checks checkItem"
v-bind:value="staff.userId" v-model="addDataPrivilegeStaffInfo.selectStaffs">
</td>
<td class="text-center">{{staff.userId}}</td>
<td class="text-center">{{staff.name}}</td>
<td class="text-center">{{staff.address}}</td>
</tr>
</tbody>
</table>
<!-- 分页 -->
<vc:create namespace="addDataPrivilegeStaff" path="frame/paginationPlus"></vc:create>
<div class="ibox-content" v-if="addDataPrivilegeStaffInfo.staffs.length > 0">
<button class="btn btn-primary float-right" type="button"
v-on:click="addDataPrivilegeStaff()">
<i class="fa fa-check"></i>&nbsp;提交
</button>
<button type="button" class="btn btn-warning float-right" style="margin-right:20px;"
data-dismiss="modal">
<span><vc:i18n name="取消" namespace="addDataPrivilegeStaff"></vc:i18n></span>
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,143 @@
(function (vc) {
var DEFAULT_ROWS = 10;
vc.extends({
propTypes: {
emitListener: vc.propTypes.string,
emitFunction: vc.propTypes.string
},
data: {
addDataPrivilegeStaffInfo: {
total: 0,
records: 1,
staffs: [],
staffName: '',
dpId: '',
orgName: '',
selectStaffs: []
}
},
watch: { // 监视双向绑定的数据数组
checkData: {
handler() { // 数据数组有变化将触发此函数
if (vc.component.addDataPrivilegeStaffInfo.selectStaffs.length == vc.component.addDataPrivilegeStaffInfo.staffs.length) {
document.querySelector('#quan').checked = true;
} else {
document.querySelector('#quan').checked = false;
}
},
deep: true // 深度监视
}
},
_initMethod: function () {
},
_initEvent: function () {
vc.on('addDataPrivilegeStaff', 'openAddDataPrivilegeStaffModal', function (_param) {
vc.component._refreshChooseOrgInfo();
$('#addDataPrivilegeStaffModel').modal('show');
vc.copyObject(_param, vc.component.addDataPrivilegeStaffInfo);
vc.component._loadAllStaffInfo(1, 10, '');
});
vc.on('addDataPrivilegeStaff', 'paginationPlus', 'page_event', function (_currentPage) {
vc.component._loadAllStaffInfo(_currentPage, DEFAULT_ROWS);
});
},
methods: {
_loadAllStaffInfo: function (_page, _row, _name) {
let param = {
params: {
page: _page,
row: _row,
userName: _name,
dpId: vc.component.addDataPrivilegeStaffInfo.dpId
}
};
//发送get请求
vc.http.apiGet('/dataPrivilegeStaff.listStaffNotInDataPrivilege',
param,
function (json) {
var _staffInfo = JSON.parse(json);
vc.component.addDataPrivilegeStaffInfo.total = _staffInfo.total;
vc.component.addDataPrivilegeStaffInfo.records = _staffInfo.records;
vc.component.addDataPrivilegeStaffInfo.staffs = _staffInfo.data;
vc.emit('addDataPrivilegeStaff', 'paginationPlus', 'init', {
total: vc.component.addDataPrivilegeStaffInfo.records,
dataCount: vc.component.addDataPrivilegeStaffInfo.total,
currentPage: _page
});
},
function () {
console.log('请求失败处理');
}
);
},
addDataPrivilegeStaff: function (_org) {
var _selectStaffs = vc.component.addDataPrivilegeStaffInfo.selectStaffs;
var _tmpStaffs = vc.component.addDataPrivilegeStaffInfo.staffs;
if (_selectStaffs.length < 1) {
vc.toast("请选择员工");
return;
}
let _staffs = [];
for (var _selectIndex = 0; _selectIndex < _selectStaffs.length; _selectIndex++) {
for (var _staffIndex = 0; _staffIndex < _tmpStaffs.length; _staffIndex++) {
if (_selectStaffs[_selectIndex] == _tmpStaffs[_staffIndex].userId) {
_staffs.push({
staffId: _tmpStaffs[_staffIndex].userId,
staffName: _tmpStaffs[_staffIndex].name
});
}
}
}
let _objData = {
dpId: vc.component.addDataPrivilegeStaffInfo.dpId,
staffs: _staffs,
communityId: vc.getCurrentCommunity().communityId
}
vc.http.apiPost('/dataPrivilegeStaff.saveDataPrivilegeStaff',
JSON.stringify(_objData), {
emulateJSON: true
},
function (json, res) {
$('#addDataPrivilegeStaffModel').modal('hide');
let _json = JSON.parse(json)
if (_json.code == 0) {
vc.emit($props.emitListener, $props.emitFunction, {});
vc.toast("操作成功");
return;
} else {
vc.toast(_json.msg);
}
},
function () {
console.log('请求失败处理');
}
);
$('#addDataPrivilegeStaffModel').modal('hide');
},
queryStaffs: function () {
vc.component._loadAllStaffInfo(1, 10, vc.component.addDataPrivilegeStaffInfo.staffName);
},
_refreshChooseOrgInfo: function () {
vc.component.addDataPrivilegeStaffInfo = {
staffs: [],
staffName: '',
dpId: '',
orgName: '',
selectStaffs: []
};
},
checkAll: function (e) {
var checkObj = document.querySelectorAll('.checkItem'); // 获取所有checkbox项
if (e.target.checked) { // 判定全选checkbox的勾选状态
for (var i = 0; i < checkObj.length; i++) {
if (!checkObj[i].checked) { // 将未勾选的checkbox选项push到绑定数组中
vc.component.addDataPrivilegeStaffInfo.selectStaffs.push(checkObj[i].value);
}
}
} else { // 如果是去掉全选则清空checkbox选项绑定数组
vc.component.addDataPrivilegeStaffInfo.selectStaffs = [];
}
}
}
});
})(window.vc);

View File

@ -43,15 +43,14 @@
</thead>
<tbody>
<tr v-for="staff in dataPrivilegeStaffInfo.staffs">
<td class="text-center">{{staff.name}}</td>
<td class="text-center">{{staff.staffName}}</td>
<td class="text-center">{{staff.tel}}</td>
<td class="text-center">{{staff.email}}</td>
<td class="text-center">{{staff.address}}</td>
<td class="text-center">{{staff.sex == 0 ? '男' : '女'}}</td>
<td class="text-center">
<div class="btn-group">
<button class="btn-white btn btn-xs" v-on:click="_openDeleteDataPrivilegeStaffModel(staff)"
v-if="vc.hasPrivilege('502022082920040010')">
<button class="btn-white btn btn-xs" v-on:click="_openDeleteDataPrivilegeStaffModel(staff)">
<span><vc:i18n name="删除"></vc:i18n></span>
</button>
</div>
@ -74,6 +73,6 @@
<!-- 分页 -->
<!-- <vc:create path="frame/pagination"></vc:create> -->
<vc:create path="frame/paginationPlus" namespace="dataPrivilegeStaffInfo"></vc:create>
<!-- <vc:create path="frame/addDataPrivilegeStaff" emitListener="dataPrivilegeStaffInfo" emitFunction="listDataPrivilegeStaff"></vc:create>
<vc:create path="frame/deleteDataPrivilegeStaff"></vc:create> -->
<vc:create path="frame/addDataPrivilegeStaff" emitListener="dataPrivilegeStaffInfo" emitFunction="listDataPrivilegeStaff"></vc:create>
<vc:create path="frame/deleteDataPrivilegeStaff"></vc:create>
</div>

View File

@ -12,7 +12,7 @@
total: 0,
records: 1,
moreCondition: false,
pgId: '',
dpId: '',
staffName: ''
}
},
@ -37,12 +37,12 @@
params: {
page: _page,
row: _rows,
roleId: vc.component.dataPrivilegeStaffInfo.pgId,
userName: $that.dataPrivilegeStaffInfo.staffName
dpId: vc.component.dataPrivilegeStaffInfo.dpId,
staffName: $that.dataPrivilegeStaffInfo.staffName
}
};
//发送get请求
vc.http.apiGet('/role.listDataPrivilegeStaff',
vc.http.apiGet('/dataPrivilegeStaff.listDataPrivilegeStaff',
param,
function (json, res) {
var _dataPrivilegeStaffInfo = JSON.parse(json);
@ -62,19 +62,18 @@
},
_openAddDataPrivilegeStaffModal: function () {
vc.emit('addDataPrivilegeStaff', 'openAddDataPrivilegeStaffModal', {
roleId: vc.component.dataPrivilegeStaffInfo.pgId,
orgName: vc.component.dataPrivilegeStaffInfo.orgName
dpId: vc.component.dataPrivilegeStaffInfo.dpId,
});
},
_openDeleteDataPrivilegeStaffModel: function (_dataPrivilegeStaff) {
_dataPrivilegeStaff.roleId = $that.dataPrivilegeStaffInfo.pgId;
_dataPrivilegeStaff.dpId = $that.dataPrivilegeStaffInfo.dpId;
vc.emit('deleteDataPrivilegeStaff', 'openDeleteDataPrivilegeStaffModal', _dataPrivilegeStaff);
},
_queryDataPrivilegeStaffMethod: function () {
vc.component._listDataPrivilegeStaffs(DEFAULT_PAGE, DEFAULT_ROWS);
},
_toStaffDetail: function (_dataPrivilegeStaff) {
vc.jumpToPage('/#/pages/frame/staffDetail?staffId=' + _dataPrivilegeStaff.userId)
vc.jumpToPage('/#/pages/frame/staffDetail?staffId=' + _dataPrivilegeStaff.staffId)
}
}
});

View File

@ -0,0 +1,31 @@
<div class="modal fade" id="deleteDataPrivilegeStaffModel" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">
<span><vc:i18n name="请确认您的操作" namespace="deleteDataPrivilegeStaff"></vc:i18n></span>!
</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<tr align="center">
<th>
<span><vc:i18n name="确定取消授权" namespace="deleteDataPrivilegeStaff"></vc:i18n></span>
</th>
</tr>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal"
v-on:click="closeDeleteDataPrivilegeStaffModel()">
<span><vc:i18n name="点错了" namespace="deleteDataPrivilegeStaff"></vc:i18n></span>
</button>
<button type="button" class="btn btn-primary" v-on:click="deleteDataPrivilegeStaff()">
<span><vc:i18n name="确认删除" namespace="deleteDataPrivilegeStaff"></vc:i18n></span>
</button>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,43 @@
(function (vc, vm) {
vc.extends({
data: {
deleteDataPrivilegeStaffInfo: {}
},
_initMethod: function () {
},
_initEvent: function () {
vc.on('deleteDataPrivilegeStaff', 'openDeleteDataPrivilegeStaffModal', function (_params) {
vc.component.deleteDataPrivilegeStaffInfo = _params;
$('#deleteDataPrivilegeStaffModel').modal('show');
});
},
methods: {
deleteDataPrivilegeStaff: function () {
vc.http.apiPost(
'/dataPrivilegeStaff.deleteDataPrivilegeStaff',
JSON.stringify(vc.component.deleteDataPrivilegeStaffInfo), {
emulateJSON: true
},
function (json, res) {
let _json = JSON.parse(json);
if (_json.code == 0) {
//关闭model
$('#deleteDataPrivilegeStaffModel').modal('hide');
vc.emit('dataPrivilegeStaffInfo', 'listDataPrivilegeStaff', {});
vc.toast("删除成功")
return;
} else {
vc.toast(_json.msg);
}
},
function (errInfo, error) {
console.log('请求失败处理');
vc.toast(json);
});
},
closeDeleteDataPrivilegeStaffModel: function () {
$('#deleteDataPrivilegeStaffModel').modal('hide');
}
}
});
})(window.vc, window.vc.component);

View File

@ -5,10 +5,10 @@
</div>
<div class="col-md-10 margin-top-xs vc-org-page">
<div class="bg-white border-radius padding">
<h5 class="dataPrivilege-title">{{dataPrivilegeManageInfo.curDataPrivilege.name}}</h5>
<div class="dataPrivilege-context ">{{dataPrivilegeManageInfo.curDataPrivilege.description}}</div>
<h5 class="role-title">{{dataPrivilegeManageInfo.curDataPrivilege.name}}</h5>
<div class="role-context ">{{dataPrivilegeManageInfo.curDataPrivilege.description}}</div>
<div class="line-x margin-top"></div>
<div class="dataPrivilege-menu flex justify-start">
<div class="role-menu flex justify-start">
<div class="item margin-right" :class="{'active':dataPrivilegeManageInfo.tabName == 'unit'}"
@click="_changeDataPrivilegeTab('unit')">单元授权
</div>

View File

@ -24,10 +24,10 @@
_changeDataPrivilegeTab: function (_tabName) {
$that.dataPrivilegeManageInfo.tabName = _tabName;
if (_tabName == 'unit') {
vc.emit('privilegeTree', 'loadPrivilege', $that.dataPrivilegeManageInfo.curDataPrivilege.pgId);
vc.emit('privilegeTree', 'loadPrivilege', $that.dataPrivilegeManageInfo.curDataPrivilege.dpId);
}
if (_tabName == 'staff') {
vc.emit('dataPrivilegeStaffInfo', 'openDataPrivilegeStaff', {pgId: $that.dataPrivilegeManageInfo.curDataPrivilege.pgId});
vc.emit('dataPrivilegeStaffInfo', 'openDataPrivilegeStaff', {dpId: $that.dataPrivilegeManageInfo.curDataPrivilege.dpId});
}
}