basic-info.js
5.19 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
var $ = require('jquery'),
common = require('../../../../common/common');
var basicInfohtml = '',
ENUM = {
isSuppled: {
'Y': '是',
'N': '否'
}
},
convertObj = {
ageLevel: {
'1': '成人',
'2': '大童',
'3': '小童',
'2|3': "大小童",
'3|2': "大小童"
},
gender: {
1: '男',
2: '女',
3: '通用'
},
grade: {
'1': '是',
'0': '否'
},
isOutLets: {
'Y': '是',
'N': '否',
'B': '品牌设置'
},
isLimited: {
'Y': '是',
'N': '否'
},
isPromotionalGifts: {
'Y': '是',
'N': '否'
},
isAdvance: {
'Y': '是',
'N': '否'
},
isLimitbuy: {
'Y': '是',
'N': '否'
},
attribute: {
1: '普通',
2: '赠品'
},
goodsSeason: {
0: '四季',
1: '春',
2: '夏',
3: '秋',
4: '冬',
5: '春夏',
6: '秋冬'
},
seasons: {
'seasons': '四季',
'spring': '春',
'summer': '夏',
'autumn': '秋',
'winter': '冬'
},
isVip: {
'Y': '是',
'N': '否',
'B': '品牌设置'
}
},
basicInfo = NETSALEDATA.baseProductInfo.baseProduct || '',
productExtBo = NETSALEDATA.productExtBo || '';
/*
* 基本信息value值转换
* @param: basicInfo(请求的要渲染的数据), obj(转换的对象)
*/
function convert(basicInfo, obj) {
$.each(basicInfo, function(key, value) {
if (convertObj[key]) {
if(key==="ageLevel"){
basicInfo[key] = common.config.__ageLevel(value);
}else if(key == "seasons") {
basicInfo[key] = basicInfo[key].replace(/seasons/g, "四季")
.replace(/spring/g, "春")
.replace(/summer/g, "夏")
.replace(/autumn/g, "秋")
.replace(/winter/g, "冬");
}else{
basicInfo[key] = convertObj[key][value];
}
}
});
return basicInfo;
}
var basicInfoData = convert(basicInfo, convertObj);
basicInfoData.expectArrivalTime =basicInfoData.expectArrivalTime? common.util.__dateFormat(new Date(basicInfoData.expectArrivalTime * 1000), "yyyy-MM-dd hh:mm:ss"):"";
basicInfoData.expectShelfTime =basicInfoData.expectShelfTime? common.util.__dateFormat(new Date(basicInfoData.expectShelfTime * 1000), "yyyy-MM-dd hh:mm:ss"):"";
basicInfoData.renderType = $('.contentpanel').data('type');
console.log('basic:' + JSON.stringify(basicInfoData));
//基本信息
basicInfohtml = common.util.__template2($('#basicInfo').html(), basicInfoData);
$('#basic-info').html(basicInfohtml);
//能否补货
var suppledTable = new common.grid({
el: '#suppled-table',
hash: false,
secondIndex: 1,
columns: [{
display: 'SKC(色系颜色)',
render: function(item) {
return item.productSkc + '(' + item.goodsName + ')';
}
}, {
display: 'SKU(尺码)',
render: function(item) {
return item.productSku + '(' + item.sizeName + ')';
}
}, {
display: '条码',
render: function(item) {
return item.factoryCode;
}
},{
display: '能否补货',
render: function(item) {
return ENUM.isSuppled[item.isSuppled];
}
}, {
display: '尾款支付时间',
render: function(item) {
var balanceTimeStr = '';
if(item.balanceTime && item.balanceTime != 0) {
balanceTimeStr = new Date(item.balanceTime * 1000).toLocaleString();
}
return balanceTimeStr;
}
}]
});
suppledTable.init(NETSALEDATA.goodsList, 'goodsSizeList')
//上架必填
productExtBo.renderType = $('.contentpanel').data('type');
productExtBo.sellChannels = productExtBo.sellChannels ? productExtBo.sellChannels.replace(/,/g, "|") : '';
common.util.__ajax({
url: '/goods/ShopsRest/queryShopsByBrandId',
data: {
brandId: basicInfo.brandId
}
}, function(res) {
productExtBo.shopList = res.data;
productExtBo.shopIds = productExtBo.shopIdList&&productExtBo.shopIdList.length?productExtBo.shopIdList.join('|'):NETSALEDATA.baseProductInfo.baseProduct.shopId;
$('#product-ext').html(common.util.__template2($('#productExtBoTemp').html(), productExtBo));
}, true);
$('#saveBasicInfo').on('click', function() {
common.util.__ajax({
url:'/goods/product/saveNetSaleBaseInfo',
data:{
productSkn:basicInfo.productSkn,
productName:common.util.__input('productName'),
isNew:common.util.__input('[name=isNew]:checked'),
sellChannels:common.util.__input('[name=sellChannels]:checked'),
phrase:common.util.__input('phrase'),
outSaleTime:common.util.__input('outSaleTime'),
shopIds:common.util.__input('[name=shopIds]:checked'),
delayArrivalNotice:common.util.__input('delayArrivalNotice')
}
})
})
// var e = new common.edit('#basicInfoWrap');
// e.init();
// //保存基本信息
// $('#saveBasicInfo').on('click', function() {
// e.submit('/goods/product/saveNetSaleBaseInfo', function(option) {
// option.data = GOLABDATA.fire("LYbasicInfo");;
// option.success = function(res) {
// res = res;
// if (res.code == '200') {
// e.$tip(res.message, function() {}, 'growl-success');
// } else {
// e.$tip(res.message);
// }
// return false;
// }
// });
// });
// GOLABDATA.on("LYbasicInfo", function() {
// var data = null;
// if (!e.validate(true)) {
// return e.errMessage;
// } else {
// data = e.getSubmitData();
// data.productSkn = $('#productSkn').val();
// data.sellChannels = data.sellChannels.split('|').join(',');
// data.shopIds = data.shopIds ? data.shopIds.split('|').join(',') : '';
// return data;
// }
// });