goodsConfig.js
5.13 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
/**
* 积分商城
*/
var goodsConfig = function() {
return {
search : function() {
$('#data-grid').datagrid({
url : '/user/goods/search',
queryParams : App.dataGridQueryParams('search-form')
});
},
addGoodBefore:function(){
$('#add-form').form('clear');
$('#otcCode').textbox('readonly',false);
$('#otcAccount').textbox('readonly',false);
$("#image").html("");
$('#add-dialog').dialog('open');
},
updateGoodBefore:function(){
var row = $("#data-grid").datagrid("getSelected");
if(row){
$('#add-form').form('load', row);
$('#otcCode').textbox('readonly',true); // 启用只读模式
$('#otcAccount').textbox('readonly',true);
$("#image").html("<img src="+row.image+" style='width:100px;height:80px;'/>");
$('#add-dialog').dialog('open');
var radios = document.getElementsByName("lottery");
for(radio in radios) {
if(radios[radio].checked) {
if(radios[radio].value=="0"){
$("#lottery_param").css("display","none");
}else if(radios[radio].value=="1") {
$("#lottery_param").css("display","block");
}
}
}
}else{
$.messager.alert("提示","请选择修改数据");
}
},
updateOrAddGoods : function(){
$('#add-form').form('submit', {
url : "/user/goods/insertOrUpdate",
onSubmit : function(param) {
return $(this).form('validate');
},
success : function(data) {
var result = $.parseJSON(data);
if (result.resultCode != "1") {
$.messager.alert("提示",result.resultMsg);
} else {
$.messager.show({
title : '提示',
msg : "操作成功"
});
$('#data-grid').datagrid('reload');
$("#add-dialog").dialog("close");
}
},
error : function() {
}
});
},
formatStatus : function(value, row, index) {
var status;
switch (value) {
case '0':
status = '未上架';
break;
case '1':
status = '已上架';
break;
case '2':
status = '已作废';
break;
}
return status;
},
formatType : function(value, row, index) {
var status;
switch (value) {
case '0':
status = '配售';
break;
case '1':
status = '刮奖';
break;
}
return status;
},
formatImage : function(value, row, index) {
if(value!=null){
return "<a href='"+value+"' target='_blank'>查看</a>";
}
},
goodStatus:function(goodStatus){
var row = $("#data-grid").datagrid("getSelected");
var status="";
switch (goodStatus) {
case 0:
status = '下架操作';
break;
case 1:
status = '上架操作';
break;
case 2:
status = '作废操作';
break;
}
if(row){
if(row.goodsStatus==2&&(goodStatus==1 || goodStatus==0)){
$.messager.alert("提示","已作废的商品不允许上下架");
return;
}
$.messager.confirm('确认', '您确定要对藏品 '+row.otcCode+'('+row.otcName+') 进行作'+status+'吗?', function(ok) {
if(ok){
$.ajax({
type: 'POST',
url: '/user/goods/updateStatus',
data: {id:row.id, goodsStatus:goodStatus},
success: function(data) {
if(data==0){
$.messager.show({
title: '信息',
msg: '操作成功'
});
$('#data-grid').datagrid('reload');
}else{
$.messager.alert("提示","操作失败");
}
},
error: function() {
}
});
}
});
}else{
$.messager.alert("提示","请选择数据");
}
},
/** 根据藏品代码查询藏品名称 */
otcCodeChange : function(newValue, oldValue) {
if (newValue.length == 6) {
$.ajax({
url : '/quota/config/getOtcName',
type : 'post',
dataType : 'json',
data : {
otcCode : newValue
},
success : function(data) {
$("#otcName").textbox('setValue', data.otcName);
}
});
}
},
/**库存导出 */
export : function(){
window.open('/user/goods/export?' + $('#search-form').serialize());
},
/**获取方式切换*/
lotteryType : function(){
if($("input[name='lottery']:checked").val() == 0){
//选择配售,处理配售方式的元素
$(".point").each(function(index,element){
if($(this).attr("type") == "radio"){
$(this).removeAttr("checked");
}else{
$(this).textbox("setValue","");
$(this).textbox("setText","");
//禁用验证方式
$(this).textbox("disableValidation");
}
});
$("#lottery_param").css("display","none");
}else if($("input[name='lottery']:checked").val() == 1){
$(".point").each(function(index,element){
if($(this).attr("type") != "radio"){
$(this).textbox("enableValidation");
}
});
$("#lottery_param").css("display","block");
}
},
}
}();