Skip to content

Commit 56cc7ef

Browse files
committed
支持员工小区功能
1 parent cdef24f commit 56cc7ef

File tree

13 files changed

+666
-34
lines changed

13 files changed

+666
-34
lines changed

public/components/common/deleteOrgCommunity/deleteOrgCommunity.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@
1212
_initEvent:function(){
1313
vc.on('deleteOrgCommunity','openDeleteOrgCommunityModal',function(_params){
1414

15-
vc.component.deleteOrgCommunityInfo = _params;
15+
$that.deleteOrgCommunityInfo = _params;
1616
$('#deleteOrgCommunityModel').modal('show');
1717

1818
});
1919
},
2020
methods:{
2121
deleteOrgCommunity:function(){
22-
vc.component.deleteOrgCommunityInfo.communityId=vc.getCurrentCommunity().communityId;
22+
$that.deleteOrgCommunityInfo.communityId=vc.getCurrentCommunity().communityId;
2323
vc.http.apiPost(
2424
'/org.deleteOrgCommunity',
25-
JSON.stringify(vc.component.deleteOrgCommunityInfo),
25+
JSON.stringify($that.deleteOrgCommunityInfo),
2626
{
2727
emulateJSON:true
2828
},
@@ -48,4 +48,4 @@
4848
}
4949
});
5050

51-
})(window.vc,window.vc.component);
51+
})(window.vc,window.$that);

public/components/frame/roleCommunity/roleCommunity.html

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,13 @@
1111
<thead>
1212
<tr>
1313
<th class="text-center">
14-
<span>
1514
<vc:i18n name="小区编号" namespace="roleCommunity"></vc:i18n>
16-
</span>
1715
</th>
1816
<th class="text-center">
19-
<span>
2017
<vc:i18n name="小区名称" namespace="roleCommunity"></vc:i18n>
21-
</span>
2218
</th>
2319
<th class="text-center">
24-
<span>
2520
<vc:i18n name="操作" namespace="roleCommunity"></vc:i18n>
26-
</span>
2721
</th>
2822
</tr>
2923
</thead>

public/components/frame/roleCommunity/roleCommunity.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,37 +19,37 @@
1919
},
2020
_initEvent: function () {
2121
vc.on('roleCommunityInfo', 'openRoleCommunity', function (_param) {
22-
vc.copyObject(_param, vc.component.roleCommunityInfo);
23-
vc.component._listRoleCommunitys(DEFAULT_PAGE, DEFAULT_ROWS);
22+
vc.copyObject(_param, $that.roleCommunityInfo);
23+
$that._listRoleCommunitys(DEFAULT_PAGE, DEFAULT_ROWS);
2424
});
2525
vc.on('roleCommunityInfo', 'listRoleCommunity', function (_param) {
26-
//vc.copyObject(_param, vc.component.roleCommunityInfo.conditions);
27-
vc.component._listRoleCommunitys(DEFAULT_PAGE, DEFAULT_ROWS);
26+
//vc.copyObject(_param, $that.roleCommunityInfo.conditions);
27+
$that._listRoleCommunitys(DEFAULT_PAGE, DEFAULT_ROWS);
2828
});
2929
vc.on('roleCommunityInfo', 'paginationPlus', 'page_event', function (_currentPage) {
30-
vc.component._listRoleCommunitys(_currentPage, DEFAULT_ROWS);
30+
$that._listRoleCommunitys(_currentPage, DEFAULT_ROWS);
3131
});
3232
},
3333
methods: {
3434
_listRoleCommunitys: function (_page, _rows) {
35-
var param = {
35+
let param = {
3636
params: {
3737
page: _page,
3838
row: _rows,
39-
roleId: vc.component.roleCommunityInfo.pgId
39+
roleId: $that.roleCommunityInfo.pgId
4040
}
4141
};
4242
//发送get请求
4343
vc.http.apiGet('/roleCommunity.listRoleCommunity',
4444
param,
4545
function (json, res) {
4646
var _roleCommunityInfo = JSON.parse(json);
47-
vc.component.roleCommunityInfo.total = _roleCommunityInfo.total;
48-
vc.component.roleCommunityInfo.records = _roleCommunityInfo.records;
49-
vc.component.roleCommunityInfo.roleCommunitys = _roleCommunityInfo.data;
47+
$that.roleCommunityInfo.total = _roleCommunityInfo.total;
48+
$that.roleCommunityInfo.records = _roleCommunityInfo.records;
49+
$that.roleCommunityInfo.roleCommunitys = _roleCommunityInfo.data;
5050
vc.emit('roleCommunityInfo', 'paginationPlus', 'init', {
51-
total: vc.component.roleCommunityInfo.records,
52-
dataCount: vc.component.roleCommunityInfo.total,
51+
total: $that.roleCommunityInfo.records,
52+
dataCount: $that.roleCommunityInfo.total,
5353
currentPage: _page
5454
});
5555
}, function (errInfo, error) {
@@ -59,8 +59,8 @@
5959
},
6060
_openAddRoleCommunityModal: function () {
6161
vc.emit('addRoleCommunity', 'openAddRoleCommunityModal', {
62-
roleId: vc.component.roleCommunityInfo.pgId,
63-
orgName: vc.component.roleCommunityInfo.orgName
62+
roleId: $that.roleCommunityInfo.pgId,
63+
orgName: $that.roleCommunityInfo.orgName
6464
});
6565
},
6666
_openDeleteRoleCommunityModel: function (_roleCommunity) {
@@ -69,13 +69,13 @@
6969
_openBeyondRoleCommunity: function (_roleCommunity) {
7070
},
7171
_queryRoleCommunityMethod: function () {
72-
vc.component._listRoleCommunitys(DEFAULT_PAGE, DEFAULT_ROWS);
72+
$that._listRoleCommunitys(DEFAULT_PAGE, DEFAULT_ROWS);
7373
},
7474
_moreCondition: function () {
75-
if (vc.component.roleCommunityInfo.moreCondition) {
76-
vc.component.roleCommunityInfo.moreCondition = false;
75+
if ($that.roleCommunityInfo.moreCondition) {
76+
$that.roleCommunityInfo.moreCondition = false;
7777
} else {
78-
vc.component.roleCommunityInfo.moreCondition = true;
78+
$that.roleCommunityInfo.moreCondition = true;
7979
}
8080
},
8181
_goBack: function () {
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<div id="addStaffCommunityModel" class="modal fade" role="dialog" aria-labelledby="addStaffCommunityModelLabel"
2+
aria-hidden="true">
3+
<div class="modal-dialog modal-lg">
4+
<div class="modal-content">
5+
<div class="modal-header">
6+
<h3 class="modal-title" id="addStaffCommunityModelLabel">
7+
<vc:i18n name="小区" namespace="addStaffCommunity"></vc:i18n>
8+
</h3>
9+
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
10+
<span aria-hidden="true">&times;</span>
11+
</button>
12+
</div>
13+
<div class="modal-body">
14+
15+
<div class="ibox ">
16+
<div class="row">
17+
<div class="col-sm-4 m-b-xs">
18+
<div class="input-group">
19+
<input :placeholder="vc.i18n('输入小区名称','addStaffCommunity')" type="text"
20+
v-model.trim="addStaffCommunityInfo.communityName"
21+
class="form-control form-control-sm">
22+
</div>
23+
</div>
24+
<div class="col-sm-5">
25+
<button type="button" class="btn btn-sm btn-primary" v-on:click="queryCommunitys()">
26+
<vc:i18n name="查询" namespace="addStaffCommunity"></vc:i18n>
27+
</button>
28+
</div>
29+
</div>
30+
<div class="table-responsive" style="margin-top:15px">
31+
<table class="table table-striped">
32+
<thead>
33+
<tr>
34+
<th class="text-center">
35+
<input type="checkbox" class="i-checks " @click="checkAllCommunity($event)"
36+
id="quan">
37+
</th>
38+
<th class="text-center">
39+
<vc:i18n name="小区ID" namespace="addStaffCommunity"></vc:i18n>
40+
</th>
41+
<th class="text-center">
42+
<vc:i18n name="小区名称" namespace="addStaffCommunity"></vc:i18n>
43+
</th>
44+
<th class="text-center">
45+
<vc:i18n name="小区地址" namespace="addStaffCommunity"></vc:i18n>
46+
</th>
47+
</tr>
48+
</thead>
49+
<tbody>
50+
<tr v-for="community in addStaffCommunityInfo.communitys">
51+
<td class="text-center">
52+
<input type="checkbox" class="i-checks checkItem"
53+
v-bind:value="community.communityId" @click="isCheckAll($event)"
54+
v-model="addStaffCommunityInfo.selectCommunitys">
55+
</td>
56+
<td class="text-center">{{community.communityId}}</td>
57+
<td class="text-center">{{community.name}}</td>
58+
<td class="text-center">{{community.address}}</td>
59+
</tr>
60+
</tbody>
61+
</table>
62+
<!-- 分页 -->
63+
<vc:create namespace="addStaffCommunity" path="frame/paginationPlus"></vc:create>
64+
<div class="ibox-content" v-if="addStaffCommunityInfo.communitys.length > 0">
65+
<button class="btn btn-primary float-right" type="button" v-on:click="addStaffCommunity()">
66+
<i class="fa fa-check"></i>&nbsp;提交
67+
</button>
68+
<button type="button" class="btn btn-warning float-right" style="margin-right:20px;"
69+
data-dismiss="modal">
70+
<vc:i18n name="取消" namespace="addStaffCommunity"></vc:i18n>
71+
</button>
72+
</div>
73+
</div>
74+
</div>
75+
</div>
76+
</div>
77+
</div>
78+
</div>
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
(function (vc) {
2+
var DEFAULT_ROWS = 10
3+
vc.extends({
4+
data: {
5+
addStaffCommunityInfo: {
6+
communitys: [],
7+
communityName: '',
8+
staffId: '',
9+
staffName: '',
10+
selectCommunitys: []
11+
}
12+
},
13+
watch: { // 监视双向绑定的数据数组
14+
checkData: {
15+
handler() { // 数据数组有变化将触发此函数
16+
if ($that.addStaffCommunityInfo.selectCommunitys.length == $that.addStaffCommunityInfo.communitys.length) {
17+
document.querySelector('#quan').checked = true;
18+
} else {
19+
document.querySelector('#quan').checked = false;
20+
}
21+
},
22+
deep: true // 深度监视
23+
}
24+
},
25+
_initMethod: function () {
26+
},
27+
_initEvent: function () {
28+
vc.on('addStaffCommunity', 'openAddStaffCommunityModal', function (_param) {
29+
$that._refreshChooseCommunityInfo();
30+
$('#addStaffCommunityModel').modal('show');
31+
vc.copyObject(_param, $that.addStaffCommunityInfo);
32+
$that._loadAllCommunityInfo(1, 10, '');
33+
});
34+
vc.on('addStaffCommunity', 'paginationPlus', 'page_event', function (_currentPage) {
35+
$that._loadAllCommunityInfo(_currentPage, DEFAULT_ROWS);
36+
});
37+
},
38+
methods: {
39+
_loadAllCommunityInfo: function (_page, _row, _name) {
40+
let param = {
41+
params: {
42+
page: _page,
43+
row: _row,
44+
nameLike: _name,
45+
staffId: $that.addStaffCommunityInfo.staffId
46+
}
47+
};
48+
//发送get请求
49+
vc.http.apiGet('/role.listWaitStaffCommunity',
50+
param,
51+
function (json) {
52+
let _json = JSON.parse(json);
53+
$that.addStaffCommunityInfo.communitys = _json.data;
54+
vc.emit('addStaffCommunity', 'paginationPlus', 'init', {
55+
total: _json.records,
56+
dataCount: _json.total,
57+
currentPage: _page
58+
});
59+
}, function () {
60+
console.log('请求失败处理');
61+
}
62+
);
63+
},
64+
addStaffCommunity: function (_org) {
65+
let _selectCommunitys = $that.addStaffCommunityInfo.selectCommunitys;
66+
let _tmpCommunitys = $that.addStaffCommunityInfo.communitys;
67+
if (_selectCommunitys.length < 1) {
68+
vc.toast("请选择小区");
69+
return;
70+
}
71+
var _communitys = [];
72+
for (var _selectIndex = 0; _selectIndex < _selectCommunitys.length; _selectIndex++) {
73+
for (var _communityIndex = 0; _communityIndex < _tmpCommunitys.length; _communityIndex++) {
74+
if (_selectCommunitys[_selectIndex] == _tmpCommunitys[_communityIndex].communityId) {
75+
_communitys.push({
76+
communityId: _tmpCommunitys[_communityIndex].communityId,
77+
communityName: _tmpCommunitys[_communityIndex].name
78+
});
79+
}
80+
}
81+
}
82+
let _objData = {
83+
staffId: $that.addStaffCommunityInfo.staffId,
84+
staffName: $that.addStaffCommunityInfo.staffName,
85+
communitys: _communitys
86+
}
87+
vc.http.apiPost('/role.saveStaffCommunity',
88+
JSON.stringify(_objData),
89+
{
90+
emulateJSON: true
91+
},
92+
function (json, res) {
93+
$('#addStaffCommunityModel').modal('hide');
94+
let _json = JSON.parse(json)
95+
vc.toast(_json.msg);
96+
97+
if (_json.code == 0) {
98+
$that.addStaffCommunityInfo.selectCommunitys = [];
99+
vc.emit('staffCommunity', 'listStaffCommunity', {});
100+
vc.emit('staffDetailCommunitys', 'notify', {});
101+
102+
return;
103+
}
104+
}, function () {
105+
console.log('请求失败处理');
106+
}
107+
);
108+
// $('#addStaffCommunityModel').modal('hide');
109+
},
110+
//查询
111+
queryCommunitys: function () {
112+
$that._loadAllCommunityInfo(1, 10, $that.addStaffCommunityInfo.communityName);
113+
},
114+
//重置
115+
resetCommunitys: function () {
116+
$that.addStaffCommunityInfo.communityName = "";
117+
$that._loadAllCommunityInfo(1, 10, $that.addStaffCommunityInfo.communityName);
118+
},
119+
_refreshChooseCommunityInfo: function () {
120+
$that.addStaffCommunityInfo = {
121+
communitys: [],
122+
communityName: '',
123+
staffId: '',
124+
staffName: '',
125+
selectCommunitys: []
126+
};
127+
},
128+
checkAllCommunity: function (e) {
129+
var checkObj = document.querySelectorAll('.checkItem'); // 获取所有checkbox项
130+
if (e.target.checked) { // 判定全选checkbox的勾选状态
131+
for (var i = 0; i < checkObj.length; i++) {
132+
if (!checkObj[i].checked) { // 将未勾选的checkbox选项push到绑定数组中
133+
$that.addStaffCommunityInfo.selectCommunitys.push(checkObj[i].value);
134+
}
135+
}
136+
} else { // 如果是去掉全选则清空checkbox选项绑定数组
137+
$that.addStaffCommunityInfo.selectCommunitys = [];
138+
}
139+
},
140+
isCheckAll: function (e) {
141+
let checkObj = document.querySelectorAll('.checkItem');
142+
var count = 0;
143+
for (var i = 0; i < checkObj.length; i++) {
144+
if (checkObj[i].checked) {
145+
count++;
146+
}
147+
}
148+
if (checkObj.length == count) {
149+
document.getElementById("quan").checked = true;
150+
} else {
151+
document.getElementById("quan").checked = false;
152+
}
153+
}
154+
}
155+
});
156+
})(window.vc);
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<div class="modal fade" id="deleteStaffCommunityModel" role="dialog" aria-labelledby="exampleModalLabel"
2+
aria-hidden="true">
3+
<div class="modal-dialog" role="document">
4+
<div class="modal-content">
5+
<div class="modal-header">
6+
<h5 class="modal-title" id="exampleModalLabel">
7+
<vc:i18n name="请确认您的操作!" namespace="deleteStaffCommunity"></vc:i18n>
8+
</h5>
9+
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
10+
<span aria-hidden="true">&times;</span>
11+
</button>
12+
</div>
13+
<div class="modal-body">
14+
<tr align="center">
15+
<th>
16+
<vc:i18n name="确定删除隶属小区" namespace="deleteStaffCommunity"></vc:i18n>
17+
</th>
18+
</tr>
19+
</div>
20+
<div class="modal-footer">
21+
<button type="button" class="btn btn-secondary" data-dismiss="modal"
22+
v-on:click="closeDeleteOrgCommunityModel()">
23+
<vc:i18n name="点错了" namespace="deleteStaffCommunity"></vc:i18n>
24+
</button>
25+
<button type="button" class="btn btn-primary" v-on:click="deleteStaffCommunity()">
26+
<vc:i18n name="确认删除" namespace="deleteStaffCommunity"></vc:i18n>
27+
</button>
28+
</div>
29+
</div>
30+
</div>
31+
</div>

0 commit comments

Comments
 (0)