warehouse.js
4.37 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
/**
* 网点管理
*/
var Warehouse = function(){
return {
search : function(){
$('#data-grid').datagrid({
url : '/user/warehouse/search',
queryParams : App.dataGridQueryParams('search-form')
});
},
formatInventory : function(value, row, index){
return '<a href="javascript:Warehouse.queryInventory(\'' + row.code + '\')">查看</a>';
},
queryInventory : function(code){
$("#inventory-detail-dialog").dialog('open');
$("#inventory-detail-data-grid").datagrid({
url : '/user/warehouse/inventory',
queryParams : {
warehouseCode : code
}
});
},
formatStatus : function(value, row, index){
switch (value) {
case '0':
return '禁用';
case '1':
return '可用';
}
},
/**加载新增网点信息窗口*/
addDailog : function(){
$("#add-form").form('clear');
$("#code").textbox("readonly", false);
$.getJSON("/user/warehouse/otcCodeList", function(data){
var text = new Array();
text.push("<table>");
for (var i = 0; i < data.length; i++) {
var otc = data[i];
if(i%2 == 0){
text.push("<tr>");
}
text.push("<td><input type='checkbox' name='list["+i+"].otcCode' value='"+otc.OTC_CODE+"'>"+otc.OTC_CODE+" ("+otc.OTC_NAME+")</td>");
if(i%2 == 1){
text.push("</tr>");
}
}
text.push("</table>");
$("#otcBox").html(text.join(''));
$("#status").val("1");
$("#address").textbox("setValue", "请填写详细地址");
$('#add-warehouse-dialog').dialog('open');
});
},
/**网点信息提交*/
formSubmit : function(){
$('#add-form').form('submit', {
onSubmit : function(param) {
return $(this).form('validate');
},
success : function(data) {
var result = $.parseJSON(data);
if(result.success == true){
$('#add-warehouse-dialog').dialog('close');
$('#data-grid').datagrid("reload");
}
$.messager.alert('操作结果', result.data);
},
error : function() {
}
});
},
address : function(){
if($("#address").textbox('getText') == '请填写详细地址'){
$("#address").textbox('setText', '');
$("#address").textbox('setValue', '');
}
},
/**作废网点*/
cancleWarehouse : function(){
var row = $('#data-grid').datagrid('getSelected');
if(row){
$.messager.confirm('Confirm', '你确定要作废该网点么?', function(ok) {
if (ok) {
$.post('/user/warehouse/cancel', {code : row.code}, function(data){
if(data.success == true){
$('#data-grid').datagrid("reload");
}
$.messager.alert('提示', data.data);
}, 'json');
}
});
}else{
$.messager.alert('Warning', '请选择要作废的数据');
}
},
/**加载修改网点信息窗口*/
updateDialog : function(){
var row = $('#data-grid').datagrid('getSelected');
if(row){
$.getJSON("/user/warehouse/info", {code : row.code}, function(data){
var text = new Array();
text.push("<table>");
for (var i = 0; i < data.list.length; i++) {
var otc = data.list[i];
if(i%2 == 0){
text.push("<tr>");
}
text.push("<td><input type='checkbox' name='list["+i+"].otcCode' id='"+otc.OTC_CODE+"' value='"+otc.OTC_CODE+"'>"+otc.OTC_CODE+" ("+otc.OTC_NAME+")</td>");
if(i%2 == 1){
text.push("</tr>");
}
}
text.push("</table>");
$("#otcBox").html(text.join(''));
$("#code").textbox("readonly", true);
$("#add-form").form('load', data.info);
$("#combobox-province").combobox("setValue", data.info.provinceId);
$("#combobox-province").combobox("setText", data.info.province);
$("#combobox-city").combobox("setValue", data.info.cityId);
$("#combobox-city").combobox("setText", data.info.city);
$("#combobox-area").combobox("setValue", data.info.areaId);
$("#combobox-area").combobox("setText", data.info.area);
$("#businessStartTime").timespinner("setValue", data.info.businessStartTime);
$("#businessEndTime").timespinner("setValue", data.info.businessEndTime);
$("#status").val("2");
for (var i = 0; i < data.info.list.length; i++) {
var inventory = data.info.list[i];
$("#"+ inventory.otcCode).attr("checked", true);
}
$("#add-warehouse-dialog").dialog('open');
});
}else{
$.messager.alert('Warning', '请选择要修改的数据');
}
}
}
}();
$(function(){
Address.initAddress();
});