shootMeter.Model.Index.js
9.45 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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
webpackJsonp([161],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {
/**
* Created by JiangMin on 2016/3/17.
* 模特管理
*/
var $ = __webpack_require__(1);
var common = __webpack_require__(2);
var STATUS = {
'1': "启用",
'2': "禁用"
};
/**
* 列表显示数据
* @type {common.grid}
*/
var g = new common.grid({
el: '#content-list',
hash: false,
complete: function () {
$('#content-list').poptrox({
usePopupCaption: true
});
},
//查询参数
parms: function () {
return {
modelName: common.util.__input('content-filter1'),
englishName: common.util.__input('content-filter2'),
status: common.util.__input('status-filter'),
modelType: 1
};
},
//列表显示
columns: [
{display: "姓名", name: "modelName"},
{display: "艺名", name: "englishName"},
{
display: "头像", name: "avatar", render: function (item) {
if (item.avatar) {
return '<img src="' + item.avatar + '?imageView/2/w/100/h/100" width="100" height="60"/>'
}
return ""
}
},//图片显示
{display: "国籍", name: "nationality"},
{display: "身高", name: "height"},
{display: "体重", name: "weight"},
{display: "肩宽", name: "shoulderWidth"},
{
display: "胸围", render: function (item) {
var a = item.vitalStatistics.split(/[,|/]/g);
return a[0];
}
},
{
display: "腰围", render: function (item) {
var a = item.vitalStatistics.split(/[,|/]/g);
return a[1];
}
},
{
display: "臀围", render: function (item) {
var a = item.vitalStatistics.split(/[,|/]/g);
return a[2];
}
},
{display: "日常鞋码", name: "shoeSize"},
{display: "日常上衣尺码", name: "dressSize"},
{display: "日常下衣尺码", name: "downDressSize"},
{
display: "状态", name: "status", render: function (item) {
if (item.status == 1) {
return "启用"
}
else {
return "禁用"
}
}
},
{
display: "操作", name: "", render: function (item) {
var arr = [];
arr.push('<a class="btn btn-xs btn-info update" data-index="' + item.__index + '">修改</a>');
arr.push('<a class="btn btn-xs btn-danger delete" data-index="' + item.__index + '">删除</a>');
return arr.join('');
}
}
]
});
g.init("/shotManage/model/getAllModels");
/*验证*/
function checkPicurl(url){
var img = new Image();
img.src = url;
img.onerror = function(){
return "";
};
if(img.complete){
console.log(img.width+" "+img.height);
if(img.width>125||img.height>125){
return '头像尺寸不能大于125*125';
}else {
return "";
}
}else{
img.onload = function(){
if(img.width>125||img.height>125){
return '头像尺寸不能大于125*125';
}else {
return "";
}
img.onload=null;//避免重复加载
}
}
}
var e = new common.edit2(".modal-body");
var Bll = {
module: null,
__render: function (selecter, templater, data) {
$(selecter).html(common.util.__template2($("#" + templater).html(), data));
},
edit: function () {
var avatar = $.trim($("#avatarpic").attr("src"));
if (avatar == "" || undefined || null) {
return "头像必传"
}
var temp=avatar.substring(0,avatar.indexOf('?'));
var res=checkPicurl(temp);
if(res!=""){
return res;
}
//验证英文名
var englishName = $.trim($("#englishName").val());
if (englishName == "" || undefined || null) {
return "艺名必填"
}
var modelName = $.trim($("#modelName").val());
if (modelName == "" || undefined || null) {
return "姓名必填"
}
//验证身高
var height = $.trim($("#height").val());
if (height == null || height == "" || height == undefined||height<1) {
return "身高必填"
}
//验证体重
var weight = $.trim($("#weight").val());
if (weight == null || weight == "" || weight == undefined||weight<1) {
return "体重必填"
}
var shoulderWidth = $.trim($("#shoulderWidth").val());
if (shoulderWidth == null || shoulderWidth == "" || shoulderWidth == undefined||shoulderWidth<1) {
return "肩宽必填"
}
//验证胸围
var Bust = $.trim($("#Bust").val());
if (Bust == null || Bust == "" || Bust == undefined) {
return "胸围必填"
}
//验证腰围
var waist = $.trim($("#waist").val());
if (waist == null || waist == "" || waist == undefined) {
return "腰围必填"
}
//验证臀围
var hips = $.trim($("#hips").val());
if (hips == null || hips == "" || hips == undefined) {
return "臀围必填"
}
},
toast: function (url, item, hint) {
// Bll.edit();
Bll.module = item;
var a = common.dialog({
title: hint,
content: common.util.__template2($("#template").html(), Bll.module),
width: "40%",
button: [{
value: "确认",
css: "btn btn-primary",
callback: function () {
Bll.module.vitalStatistics = [Bll.module.Bust, Bll.module.waist, Bll.module.hips].join("|");
var msg = Bll.edit();
if (!msg) {
common.util.__ajax({
url: url,
data: Bll.module
}, function () {
g.reload(1);//重新加载界面
a.close();//关闭模态框
})
} else {
common.util.__tip(msg, "warning");
}
return false;
}
}, {
value: "取消",
css: "btn",
callback: function () {
g.reload(1);//重新加载界面
}
}]
});
Bll.__editRender();
},
renderDialog: function (templater) {
Bll.__render(".modal-body", templater, Bll.module);
Bll.__editRender();
},
__editRender: function () {
e.init();
e.on("file_onComplete", function (obj) {
var names = obj.field;
Bll.module = common.util.__buildobj(names, '.', Bll.module, function (o, name) {
o[name] = obj.data;
});
Bll.renderDialog("template");
});
}
};
/**
* 监听输入框变化
*/
$(document).on("change", ".observe", function () {
var $this = $(this);
var name = $this.data("field");
Bll.module = common.util.__buildobj(name, '.', Bll.module, function (obj, name1) {
obj[name1] = $this.val();
});
});
//添加模特--点击事件
$('#add-content').on('click', function () {
var item = {
"__state": "add",
'englishName': "",//英文名
'height': "",//身高
'dressSize': "",//日常上衣尺码
'downDressSize': "",//日常下衣尺码
'shoulderWidth': "",//jiankuan
'modelName': "",//名称
'modelType': 1,//模特类型:1 拍摄模特 2 试穿模特
'nationality': "",//国籍
'status': 1,//模特状态:0 禁用 1 启用
'shoeSize': "",//鞋尺码
'vitalStatistics': "",//三围
"Bust": "",//胸围
"waist": "",//腰围
"hips": "",//臀围
'weight': "",//体重
'avatar': "",//头像
'modelCard': ""//模特卡
};
Bll.toast('/shotManage/model/addModel', item, "添加模特");
});
//删除图片
$(document).on('click', '.remove1', function () {
var title = $(this).data("link");
Bll.module[title] = "";
Bll.renderDialog("template");
});
//修改模特--点击事件
$(document).on('click', '.update', function () {
var item = g.rows[$(this).data("index")];
item.__state = "update";
var a = item.vitalStatistics.split(/[,|/]/g);
item.Bust = a[0];
item.waist = a[1];
item.hips = a[2];
Bll.toast('/shotManage/model/updateModel', item, "修改模特");
});
//删除--点击事件
$(document).on('click', '.delete', function () {
var item = g.rows[$(this).data("index")];
common.dialog.confirm("警告",
"确认删除?",
function () {
common.util.__ajax({
url: '/shotManage/model/delModel',
data: {
id: item.id
}
}, function () {
g.reload(1);
}, true);
});
});
//查询按钮--点击事件
$(document).on('click', '#filter-btn', function () {
g.reload(1);
});
/***/ }
]);