basic-info.js
2.43 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
var $ = require('jquery'),
common = require('../../common/common');
var basicInfohtml = '',
convertObj = {
ageLevel: {
'1': '成人',
'2': '大童',
'3': '小童'
},
gender: {
1: '男',
2: '女',
3: '通用'
},
grade: {
'1': '是',
'null': '否'
},
isOutLets: {
'Y': '是',
'N': '否'
},
isLimited: {
'Y': '是',
'N': '否'
},
isPromotionalGifts: {
'Y': '是',
'N': '否'
},
isAdvance: {
'Y': '是',
'N': '否'
},
isLimitbuy: {
'Y': '是',
'N': '否'
},
attribute: {
1: '普通',
2: '赠品'
}
},
basicInfo = NETSALEDATA.baseProductInfo.baseProduct || '',
productExtBo = NETSALEDATA.productExtBo || '';
/*
* 基本信息value值转换
* @param: basicInfo(请求的要渲染的数据), obj(转换的对象)
*/
function convert(basicInfo, obj) {
$.each(basicInfo, function(key, value) {
if (convertObj[key]) {
basicInfo[key] = convertObj[key][value];
}
});
return basicInfo;
}
var basicInfoData = convert(basicInfo, convertObj);
//基本信息
basicInfoData.renderType = $('.contentpanel').data('type');
basicInfohtml = common.util.__template2($('#basicInfo').html(), basicInfoData);
$('#basic-info').html(basicInfohtml);
//能否补货
$('#goods-table').html(common.util.__template2($('#goodsList').html(), {
goodsList: NETSALEDATA.goodsList
}));
//上架必填
productExtBo.renderType = $('.contentpanel').data('type');
productExtBo.sellChannels = productExtBo.sellChannels ? productExtBo.sellChannels.replace(/,/g, "|") : '';
$('#product-ext').html(common.util.__template2($('#productExtBoTemp').html(), productExtBo));
if ($('.contentpanel').data('type') == 'info') {
$('.mainpanel').find('input').prop('disabled', true);
$('.mainpanel').find('.btn').addClass('disabled');
}
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.data;
if (res.code == '200') {
e.$tip(res.message, function() {}, 'growl-success');
} else {
e.$tip(res.message);
}
return false;
}
});
});
GOLABDATA.on("LYbasicInfo", function() {
return e.submit('', function(option) {
var list = option.data.sellChannels.split('|').join(',');
option.data.productSkn = $('#productSkn').val();
option.data.sellChannels = list;
option.debug = true;
});
});