shootMeter.TryInfo.Index.js
6.25 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
webpackJsonp([158],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {
/**
* Created by JiangMin on 2016/3/22.
* 试穿信息管理
*/
var $ = __webpack_require__(1);
var common = __webpack_require__(2);
/**
* 列表显示数据
* @type {common.grid}
*/
var g = new common.grid({
el: '#content-list',
hash: false,
//查询参数
parms: function () {
return {
productSku: common.util.__input('content-filter1'),
productSkn: common.util.__input('content-filter2'),
productName: common.util.__input('content-filter3')
};
},
//列表显示
columns: [
{
display: "图片", name: "defaultImg", render: function (item) {
if (item.defaultImg) {
return '<img src="' + item.defaultImg + '?imageView/0/w/78/h/78" width="100" height="60"/>'
}
return ""
}
},//图片显示
{display: "skn", name: "productSkn"},
{display: "产品名称", name: "productName"},
{display: "品牌", name: "brandName"},
{
display: "操作", name: "", render: function (item) {
var arr = [];
arr.push('<a class="btn btn-xs btn-info info" data-index="' + item.__index + '">详情</a>');
return arr.join('');
}
}
]
});
g.init("/meterManage/tryInfo/index2");
var modelLists = [];
//根据productSkn获取所有试穿信息并拼接返回
var getAllInfo = function (item, callback) {
common.util.__ajax({url: '/meterManage/tryInfo/info1', data: {productSkn: item.productSkn}}, function (data) {
var feelIds = {
1: "合适",
2: "偏大",
3: "偏小"
};
var infoLists = data.data || {};
modelLists = infoLists.tryModelList || [];
//如果存在试穿信息
if (infoLists.tryInfoBoMap) {
var tryInfo = infoLists.tryInfoBoMap;
for (var i = 0; i < modelLists.length; i++) {
if (tryInfo[modelLists[i].id]) {
modelLists[i].tryInfo = {};
modelLists[i].tryInfo = tryInfo[modelLists[i].id];
modelLists[i].tryInfo.fell_name = feelIds[tryInfo[modelLists[i].id].feel_id];
}
else {
modelLists[i].tryInfo = {};
modelLists[i].tryInfo.fit_size = "";
modelLists[i].tryInfo.fit_remark = "";
}
}
}
//不存在
else {
for (var j = 0; j < modelLists.length; j++) {
modelLists[j].tryInfo = {};
}
}
callback(modelLists);
var e = new common.edit("#baseInfo");
e.init();
var skn= item.productSkn;
new common.dropDown({
el: '.fit_size',
ajax: 'sortsize3',
params: function () {
return {
"productSkn": skn
};
}
});
new common.dropDown({el: '.feel_id'});
}, true);
};
//整合修改后的所有试穿信息
var newList = [];
var getNewLists = function (modelLists, callback) {
for (var i = 0; i < modelLists.length; i++) {
newList[i] = {};
newList[i].model_id = modelLists[i].id;
if (modelLists[i].tryInfo.feel_id || modelLists[i].tryInfo.fit_size || modelLists[i].tryInfo.fit_remark) {
newList[i].feel_id = modelLists[i].tryInfo.feel_id || "";
newList[i].fit_size = modelLists[i].tryInfo.fit_size || "";
newList[i].fit_remark = modelLists[i].tryInfo.fit_remark || "";
}
else {
newList[i].feel_id = "";
newList[i].fit_size = "";
newList[i].fit_remark = "";
}
}
var postDoc = [];
for (var j = 0; j < newList.length; j++) {
if (newList[j].feel_id || newList[j].fit_size || newList[j].fit_remark) {
postDoc.push(newList[j]);
}
}
callback(postDoc);
};
//详情模态
var Bll = {
toast: function (url, item) {
getAllInfo(item, function (data) {
var a = new common.dialog({
title: "试穿信息",
width: '80%',
content: common.util.__template2($("#template").html(), {
productSkn: item.productSkn,
productName: item.productName,
modelLists: data
}),
button: [
{
value: "提交", callback: function () {
getNewLists(data, function (newList1) {
common.util.__ajax({
url: url,
data: {
productSkn: item.productSkn,
productModelTry: JSON.stringify(newList1)
}
}, function (res) {
if (res.code == '200') {
g.reload();
a.close();
}
});
return false;
})
}, css: "btn-info"
},
{
value: "取消",
css: "btn btn-primary"
}
]
});
})
}
};
//编辑按钮
$(document).on('click', '.info', function () {
var item = g.rows[$(this).data("index")];
Bll.toast('/meterManage/tryInfo/add', item);
});
//输入变化时触发
$(document).on("change", ".tryInfo1", function () {
var _index = $(this).data("index");
var item = modelLists[_index].tryInfo;
var name = $(this).data('name');
if (name == 'fit_size') {
item[name] = $(this).find("option[value='" + $(this).val() + "']").text();
}
else {
item[name] = $(this).val();
}
});
//查询按钮--点击事件
$(document).on('click', '#filter-btn', function () {
g.reload(1);
});
/***/ }
]);