quotaConfig.js
3.76 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
/**
* 权益分配
*/
var quotaConfig = function() {
return {
search : function() {
$("#data-grid").datagrid({
url : "/quota/config/list?" + $('#search-form').serialize(),
});
},
beforeAdd : function() {
$("#add-form").form("clear");
$("#add-dialog").dialog('open');
},
add : function() {
$("#add-form").form('submit', {
url : "/quota/config/add",
onSubmit : function(param) {
return $(this).form('validate');
},
success : function(data) {
var result = $.parseJSON(data);
if (result.success == true) {
$.messager.show({
title : '信息',
msg : '设置成功'
});
$('#data-grid').datagrid('reload');
$("#add-dialog").dialog("close");
} else {
$.messager.alert("错误", result.data);
}
}
});
},
beforeUpdate : function() {
var row = $('#data-grid').datagrid('getSelected');
if (row) {
if (row.allot == "0") {
$('#add-dialog').dialog('open')
.dialog('setTitle', '编辑权益分配');
$('#add-form').form('load',
"/quota/config/queryById?id=" + row.id);
} else {
$.messager.alert("错误提示", "仅未分配设置可以修改");
}
} else {
$.messager.alert("错误提示", "请选择数据");
}
},
/** 分配权益 */
allot : function() {
var row = $('#data-grid').datagrid('getSelected');
if (!row) {
$.messager.alert("错误提示", "请选择数据");
return;
}
if (row.allot != '0') {
$.messager.alert("错误提示", "只能分配状态为未分配的任务");
return;
}
$.messager.confirm("提示框", "确认要开始分配吗?", function(ok) {
if (ok) {
$.ajax({
url : "/quota/config/allot",
dataType : "json",
type : "POST",
data : {
id : row.id
},
success : function(data) {
if (data.success == true) {
$.messager.show({
title : '信息',
msg : '操作完毕'
});
$('#data-grid').datagrid('reload');
} else {
$.messager.alert("错误提示", data.data);
}
}
});
}
});
},
/** 作废 */
invalid : function(actId) {
var row = $('#data-grid').datagrid('getSelected');
if (!row) {
$.messager.alert("错误提示", "请选择数据");
return;
}
if (row.allot != '0') {
$.messager.alert("错误提示", "只能作废状态为未分配的任务");
return;
}
$.messager.confirm("提示框", "确认要作废此记录吗?", function(ok) {
if (ok) {
$.ajax({
url : "/quota/config/invalid",
dataType : "json",
type : "POST",
data : {
id : row.id
},
success : function(data) {
$.messager.show({
title : '信息',
msg : '操作完毕'
});
$('#data-grid').datagrid('reload');
}
});
}
});
},
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);
}
});
}
},
trustOtcCodeChange : function(newValue, oldValue) {
if (newValue.length == 6) {
$.ajax({
url : '/quota/config/getOtcName',
type : 'post',
dataType : 'json',
data : {
otcCode : newValue
},
success : function(data) {
$("#trustOtcName").textbox('setValue', data.otcName);
}
});
}
},
formatStatus : function(value, row, index) {
var status;
switch (value) {
case 0:
status = '未分配';
break;
case 1:
status = '已分配';
break;
case 2:
status = '作废';
break;
}
return status;
}
}
}();