shop.Administrator.js
5.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
webpackJsonp([166],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {
//商家管理
'use strict';
var $ = __webpack_require__(1),
common=__webpack_require__(2);
// 筛选项
new common.dropDown({el:"#shop-name",ajax:"shopsRest"});
selectAllManagerInfo();
var g=new common.grid({
el:'#basicTable',
parms: function() {
return {
'shopsId': common.util.__input('shop-name'),
'adminPid': common.util.__input('admin-name')
}
},
columns:[
{display:"ID",name:"id"},
{display:"店铺名称",name:"shopName"},
{display:"店铺管理员",name:"adminName"},
{display:"部门",name:"deptName"},
{display:"创建时间",name:"createTime"},
{display:"更新时间",name:"updateTime"},
{display:"操作",name:"",render:function(item){
var HtmArr=[];
HtmArr.push('<a href="javascript:void(0);" data-index="'+item.__index+'" class="edit btn btn-info btn-xs">编辑</a>');
HtmArr.push('<a href="javascript:void(0);" data-index="'+item.__index+'" class="delete btn btn-danger btn-xs">删除</button>');
return HtmArr.join('');
}}
]
})
g.init('/supplier/storeadmin/indexPage');
var Bll={
toast:function(content,id){
common.dialog.confirm("温馨提示",content,function(){
common.util.__ajax({
url:'/supplier/storeadmin/delete',
data:{id:id}
},function(){
g.reload();
});
});
},
selectManagerName:function(id,eqid){
if(!~id){
return false;
}
common.util.__ajax({
url:'/supplier/storeadmin/managerName',
data:{
identity:id,//$('#identity-type option:selected').val()
shopsId:$('#store-name option:selected').val()
}
},function(res){
$('#manager-name').html('<option value="">请选择管理员</option>');
if(res.data&&res.data.length>0){
$.each(res.data,function(index,item){
var $option=$("<option></option>");
$option.attr("value",item.pid);
if(+item.pid==eqid){
$option.attr("selected","selected");
}
var content = item.truename;
if(item.deptName) {
content += '(' + item.deptName +')';
}
$option.html(content);
$("#manager-name").append($option);
})
};
new common.dropDown({el:"#manager-name"});
},true);
},
dialog:function(title,url,item){
common.dialog.confirm("创建店铺管理员关系",$("#template").html(),function(){
var data=function(){
var sn=$('#store-name').val();
var obj={
id:item.id,
shopsId:sn?sn:item.shopsId,
identity: $('#identity-type').val(),
adminPid:$('#manager-name').val()
};
console.log(obj);
for(var key in obj){
if(+obj[key]==-1){
return "请选择完所有的必填项!";
}
}
return obj;
}
return common.util.__ajax({
url:url,
async:true,
data:data()
},function(){
g.reload();
});
});
new common.dropDown({el:"#store-name",ajax:"shopsRest"});
new common.dropDown({el:"#manager-name"});
//
$('#identity-type').on('change',function(){
Bll.selectManagerName($(this).val());
});
}
}
$('#basicTable').on('click', '.delete', function() {
var item=g.rows[$(this).data("index")];
Bll.toast("你确定要删除吗?",item.id);
});
$(document).on('click', '.add', function() {
Bll.dialog("创建店铺管理员关系",'/supplier/storeadmin/addguanxi',{});
});
$('#basicTable').on('click', '.edit', function() {
var item=g.rows[$(this).data("index")];
Bll.dialog("修改店铺管理员关系",'/supplier/storeadmin/updateguanxi',item);
//赋值
$("#store-name").val(item.shopsId);
$("#select2-store-name-container").text(item.shopName);
$('#identity-type').val(item.identity);
Bll.selectManagerName($('#identity-type option:selected').val(),item.adminPid);
});
function selectAllManagerInfo() {
common.util.__ajax({
url: '/supplier/storeadmin/adminList'
}, function(res) {
$('#admin-name').html('<option value="">请选择管理员</option>');
if(res.data&&res.data.length>0){
$.each(res.data,function(index,item){
var $option=$("<option></option>");
$option.attr("value",item.pid);
var content = item.truename;
// 将"真实姓名"为空的数据排除
if(content === undefined || content.length === 0) {
return;
}
if(item.deptName) {
content += '(' + item.deptName +')';
}
$option.html(content);
$("#admin-name").append($option);
})
};
new common.dropDown({el:"#admin-name"});
}, true);
}
$(document).on('click', '#filter-btn', function() {
g.reload(1);
});
/***/ }
]);