优化完成数据权限 功能

This commit is contained in:
wuxw 2022-09-29 09:08:40 +08:00
parent b59aba2889
commit ad7b233404
7 changed files with 304 additions and 6 deletions

View File

@ -41,7 +41,7 @@
</table>
<!-- 分页 -->
<vc:create path="frame/paginationPlus" namespace="dataPrivilegeUnitInfo"></vc:create>
<!-- <vc:create path="frame/addDataPrivilegeUnit" emitListener="dataPrivilegeUnitInfo" emitFunction="listDataPrivilegeUnit">
<vc:create path="property/addDataPrivilegeUnit" emitListener="dataPrivilegeUnitInfo" emitFunction="listDataPrivilegeUnit">
</vc:create>
<vc:create path="frame/deleteDataPrivilegeUnit"></vc:create> -->
<vc:create path="property/deleteDataPrivilegeUnit"></vc:create>
</div>

View File

@ -12,7 +12,7 @@
total: 0,
records: 1,
moreCondition: false,
pgId: ''
dpId: ''
}
},
_initMethod: function () {
@ -59,8 +59,7 @@
},
_openAddDataPrivilegeUnitModal: function () {
vc.emit('addDataPrivilegeUnit', 'openAddDataPrivilegeUnitModal', {
roleId: vc.component.dataPrivilegeUnitInfo.pgId,
orgName: vc.component.dataPrivilegeUnitInfo.orgName
dpId: vc.component.dataPrivilegeUnitInfo.dpId,
});
},
_openDeleteDataPrivilegeUnitModel: function (_dataPrivilegeUnit) {

View File

@ -0,0 +1,78 @@
<div id="addDataPrivilegeUnitModel" class="modal fade" role="dialog" aria-labelledby="addDataPrivilegeUnitModelLabel"
aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title" id="addDataPrivilegeUnitModelLabel">
<span><vc:i18n name="楼栋单元" namespace="addDataPrivilegeUnit"></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('输入单元编号','addDataPrivilegeUnit')" type="text"
v-model="addDataPrivilegeUnitInfo.unitNum"
class="form-control form-control-sm">
<span class="input-group-append">
<button type="button" class="btn btn-sm btn-primary"
v-on:click="queryUnits()">
<span><vc:i18n name="查询" namespace="addDataPrivilegeUnit"></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="addDataPrivilegeUnit"></vc:i18n></span></th>
<th class="text-center">
<span><vc:i18n name="单元编号" namespace="addDataPrivilegeUnit"></vc:i18n></span>
</th>
</tr>
</thead>
<tbody>
<tr v-for="unit in addDataPrivilegeUnitInfo.units">
<td class="text-center">
<input type="checkbox" class="i-checks checkItem"
v-bind:value="unit.unitId" v-model="addDataPrivilegeUnitInfo.selectUnits">
</td>
<td class="text-center">{{unit.floorNum}}</td>
<td class="text-center">{{unit.unitNum}}</td>
</tr>
</tbody>
</table>
<!-- 分页 -->
<vc:create namespace="addDataPrivilegeUnit" path="frame/paginationPlus"></vc:create>
<div class="ibox-content" v-if="addDataPrivilegeUnitInfo.units.length > 0">
<button class="btn btn-primary float-right" type="button"
v-on:click="addDataPrivilegeUnit()">
<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="addDataPrivilegeUnit"></vc:i18n></span>
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,147 @@
(function (vc) {
var DEFAULT_ROWS = 10;
vc.extends({
propTypes: {
emitListener: vc.propTypes.string,
emitFunction: vc.propTypes.string
},
data: {
addDataPrivilegeUnitInfo: {
total: 0,
records: 1,
units: [],
staffName: '',
dpId: '',
orgName: '',
selectUnits: []
}
},
watch: { // 监视双向绑定的数据数组
checkData: {
handler() { // 数据数组有变化将触发此函数
if (vc.component.addDataPrivilegeUnitInfo.selectUnits.length == vc.component.addDataPrivilegeUnitInfo.units.length) {
document.querySelector('#quan').checked = true;
} else {
document.querySelector('#quan').checked = false;
}
},
deep: true // 深度监视
}
},
_initMethod: function () {
},
_initEvent: function () {
vc.on('addDataPrivilegeUnit', 'openAddDataPrivilegeUnitModal', function (_param) {
vc.component._refreshChooseUnitInfo();
$('#addDataPrivilegeUnitModel').modal('show');
vc.copyObject(_param, vc.component.addDataPrivilegeUnitInfo);
vc.component._loadAllUnitsInfo(1, 10, '');
});
vc.on('addDataPrivilegeUnit', 'paginationPlus', 'page_event', function (_currentPage) {
vc.component._loadAllUnitsInfo(_currentPage, DEFAULT_ROWS);
});
},
methods: {
_loadAllUnitsInfo: function (_page, _row, _name) {
let param = {
params: {
page: _page,
row: _row,
unitNum: _name,
dpId: vc.component.addDataPrivilegeUnitInfo.dpId,
communityId:vc.getCurrentCommunity().communityId
}
};
//发送get请求
vc.http.apiGet('/dataPrivilegeUnit.listUnitsNotInDataPrivilege',
param,
function (json) {
var _staffInfo = JSON.parse(json);
vc.component.addDataPrivilegeUnitInfo.total = _staffInfo.total;
vc.component.addDataPrivilegeUnitInfo.records = _staffInfo.records;
vc.component.addDataPrivilegeUnitInfo.units = _staffInfo.data;
vc.emit('addDataPrivilegeUnit', 'paginationPlus', 'init', {
total: vc.component.addDataPrivilegeUnitInfo.records,
dataCount: vc.component.addDataPrivilegeUnitInfo.total,
currentPage: _page
});
},
function () {
console.log('请求失败处理');
}
);
},
addDataPrivilegeUnit: function (_org) {
var _selectUnits = vc.component.addDataPrivilegeUnitInfo.selectUnits;
var _tmpUnits = vc.component.addDataPrivilegeUnitInfo.units;
if (_selectUnits.length < 1) {
vc.toast("请选择员工");
return;
}
let _units = [];
for (var _selectIndex = 0; _selectIndex < _selectUnits.length; _selectIndex++) {
for (var _staffIndex = 0; _staffIndex < _tmpUnits.length; _staffIndex++) {
if (_selectUnits[_selectIndex] == _tmpUnits[_staffIndex].unitId) {
_units.push({
unitId: _tmpUnits[_staffIndex].unitId,
unitNum: _tmpUnits[_staffIndex].unitNum,
floorId: _tmpUnits[_staffIndex].floorId,
floorNum: _tmpUnits[_staffIndex].floorNum,
});
}
}
}
let _objData = {
dpId: vc.component.addDataPrivilegeUnitInfo.dpId,
units: _units,
communityId: vc.getCurrentCommunity().communityId
}
vc.http.apiPost('/dataPrivilegeUnit.saveDataPrivilegeUnit',
JSON.stringify(_objData), {
emulateJSON: true
},
function (json, res) {
$('#addDataPrivilegeUnitModel').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('请求失败处理');
}
);
$('#addDataPrivilegeUnitModel').modal('hide');
},
queryUnits: function () {
vc.component._loadAllStaffInfo(1, 10, vc.component.addDataPrivilegeUnitInfo.staffName);
},
_refreshChooseUnitInfo: function () {
vc.component.addDataPrivilegeUnitInfo = {
units: [],
staffName: '',
dpId: '',
orgName: '',
selectUnits: []
};
},
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.addDataPrivilegeUnitInfo.selectUnits.push(checkObj[i].value);
}
}
} else { // 如果是去掉全选则清空checkbox选项绑定数组
vc.component.addDataPrivilegeUnitInfo.selectUnits = [];
}
}
}
});
})(window.vc);

View File

@ -0,0 +1,31 @@
<div class="modal fade" id="deleteDataPrivilegeUnitModel" 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="deleteDataPrivilegeUnit"></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="deleteDataPrivilegeUnit"></vc:i18n></span>
</th>
</tr>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal"
v-on:click="closeDeleteDataPrivilegeUnitModel()">
<span><vc:i18n name="点错了" namespace="deleteDataPrivilegeUnit"></vc:i18n></span>
</button>
<button type="button" class="btn btn-primary" v-on:click="deleteDataPrivilegeUnit()">
<span><vc:i18n name="确认删除" namespace="deleteDataPrivilegeUnit"></vc:i18n></span>
</button>
</div>
</div>
</div>
</div>

View File

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

View File

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