tryModel.js
6.18 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
/**
* Created by JiangMin on 2016/3/17.
* 模特管理
*/
var $ = require('jquery');
var common = require('../common/common');
//日期插件
$('.hasDatepicker').fdatepicker({
format: 'yyyy-mm-dd'
});
/**
* 列表显示数据
* @type {common.grid}
*/
var g = new common.grid({
el: '#content-list',
hash: false,
//查询参数
parms: function () {
return {
modelName: common.util.__input('content-filter1'),
beginTime:((new Date($('#beginTime').val())).getTime())/1000||"",
endTime: ((new Date($('#endTime').val())).getTime())/1000||"",
modelType:parseInt($("#aa").val())
// status: $("#bb").val()?parseInt($("#bb").val()):undefined
};
},
//列表显示
columns: [
{display: "ID", name: "id"},
{display: "姓名", name: "modelName"},
{
display: "头像", name: "avatar", render: function (item) {
return '<img src="' + item.avatar + '?imageView/0/w/78/h/78" width="100" height="60"/>'
}
},//图片显示
{display: "身高", name: "height"},
{display: "体重", name: "weight"},
{
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: "createTime",
render: function (item) {
var t = new Date(item.createTime * 1000);
var formatted = common.util.__dateFormat(t, "yyyy-MM-dd hh:mm:ss");
return "<p>" + formatted + "</p>";
}
},
{
display: "操作", name: "", render: function (item) {
var arr = [];
arr.push('<a class="btn btn-info update" data-index="' + item.__index + '">修改</a>');
arr.push('<a class="btn btn-danger delete" data-index="' + item.__index + '">删除</a>');
return arr.join('');
}
}
]
});
g.init("/meterManage/tryModel/index1");
var Bll = {
toast: function (url, item, hint) {
var e = new common.edit("#baseform", {
bucket: "modelCard"//真实的
});
//验证身高
e.on("validate", function () {
var height = $.trim($("#height").val());
if (height>250||height<100) {
return "身高值范围为100~250"
}
return true;
});
//验证体重
e.on("validate", function () {
var weight = $.trim($("#weight").val());
if (weight>200||weight<10) {
return "体重值范围为10~200"
}
return true;
});
//验证胸围
e.on("validate", function () {
var Bust = $.trim($("#Bust").val());
if (Bust>200) {
return "胸围值应小于200"
}
return true;
});
//验证腰围
e.on("validate", function () {
var waist = $.trim($("#waist").val());
if (waist>200) {
return "腰围值应小于200"
}
return true;
});
//验证臀围
e.on("validate", function () {
var hips = $.trim($("#hips").val());
if (hips>200) {
return "臀围值应小于200"
}
return true;
});
var a = common.dialog.confirm(hint,
common.util.__template2($("#template").html(), item),
function () {
e.submit(url, function (option) {
option.data.modelType = parseInt($("#aa").val());//模特类型,1拍摄模特,2试穿模特
option.data.status =1;//模特状态,默认启用
option.data.height = parseInt($("#height").val());//模特身高
option.data.weight = parseInt($("#weight").val());//模特体重
option.data.vitalStatistics = $("#Bust").val() + '|' + $("#waist").val() + "|" + $("#hips").val();//模特三围,拼接字符串
//console.log("option.data", option.data);
//option.debug = true;//调试状态
option.success = function (res) {
//判断接口请求状态
if (res.data.code == '200') {
g.reload();//重新加载界面
a.close();//关闭模态框
}
else {
//提示出错信息
e.$tip(res.data.message);
}
};
option.error = function () {
};
});
return false;
});
e.init();
}
};
//添加模特--点击事件
$('#add-content').on('click', function () {
var item = {
"__state": "add"
};
Bll.toast('/meterManage/tryModel/addModel', item, "添加模特");
});
//修改模特--点击事件
$(document).on('click', '.update', function () {
var item = g.rows[$(this).data("index")];
var a = item.vitalStatistics.split(/[,|/]/g);
item.Bust = a[0];
item.waist = a[1];
item.hips = a[2];
Bll.toast('/meterManage/tryModel/updateModel', item, "修改模特");
});
//删除--点击事件
$(document).on('click', '.delete', function () {
var item = g.rows[$(this).data("index")];
common.dialog.confirm("警告",
"确认删除?",
function () {
item.status = 0;
common.util.__ajax({
url: '/meterManage/tryModel/updateModel',
data: item
}, function () {
g.reload(1);
});
});
});
//查询按钮--点击事件
$(document).on('click', '#filter-btn', function () {
g.reload(1);
});