-
Notifications
You must be signed in to change notification settings - Fork 3
/
list.js
290 lines (290 loc) · 9.74 KB
/
list.js
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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
sax.flash.listModel = new er.Model({
LOADER_LIST: ["getFlashList"],
/**
列表请求发送参数
*/
QUERY_MAP: {
"startDate": "startDate",
"endDate": "endDate"
},
getFlashList: new er.Model.Loader(function() {
var me = this;
if (!me.get("startDate") && !me.get("endDate")) {
var date = sax.util.dateChange("0");
me.set("startDate", date[0]);
me.set("endDate", date[1]);
}
var TABLE_FIELDS = [
{
title: 'Flash文件名称',
field: "fileName",
content: function(item) {
return "<a href='" + item["pageUrl"] + "' target='_blank'>" + item["fileName"] + "</a>";
}
},
{
title: '类型',
align: "center",
width: 100,
content: function(item) {
return ["", "普通flash素材", "对联flash素材"][item["type"]];
}
},
{
title: '是否紧急',
align: "center",
width: 60,
content: function(item) {
if (item["priority"] == 9) {
return "紧急";
} else {
return "不紧急";
}
}
},
{
title: '状态',
align: "center",
width: 80,
content: function(item) {
return ["", "等待处理", "处理中", "完成", "失败"][item["runStatus"]];
}
},
{
title: '报警',
align: "center",
width: 60,
content: function(item) {
return ["", "正常", "<span style='color:red'>报警</span>"][item["resultStatus"]];
}
},
{
title: '最大值',
align: "right",
content: "cpuMax"
},
{
title: '平均值',
align: "right",
content: "cpuAverage"
},
{
title: '提交时间',
align: "center",
content: "creativeTime",
width: 140
},
{
title: "完成时间",
align: "center",
width: 140,
content: "modifyTime"
},
{
title: "操作",
align: "center",
width: 60,
content: function(item) {
return "<a href='#/flash/view~inspectId=" + item["id"] + "'>查看</a>";
}
}
];
var params = me.getQueryString();
me.set("fields", TABLE_FIELDS);
me.set("pageSize", sax.util.getPageSize(30));
me.stop();
sax.flash.dao.getFlashList(params, function(data) {
me.set("datasource", data.list);
me.start();
});
})
});
sax.flash.list = new er.Action({
model: sax.flash.listModel,
STATE_MAP: {
"startDate": "",
"endDate": ""
},
view: new er.View({
template: 'FlashTpl',
UI_PROP: {
'ListTable': {
fields: '*fields',
datasource: '*datasource'
}
}
}),
/**
分页点击事件
*/
_getPageChangeHandler: function() {
var me = this;
return function(v) {
me.model.set('pageNo', v);
me.refresh();
}
},
_getCalendarChangeHandler: function() {
var me = this;
return function(v) {
var start = sax.util.formatDate(v[0]);
var end = sax.util.formatDate(v[1]);
me.model.set("startDate", start);
me.model.set("endDate", end);
me.refresh();
}
},
onShowDetail: function(id) {
var me = this;
if (!me.CREATE_FORM) {
me.CREATE_FORM = ecui.create(
'Form',
{
main: ecui.dom.create('ui-form', 'width:500px'),
parent: document.body,
hideForm: true,
autoCenter: 1
});
}
var body = me.CREATE_FORM.getContent();
var datasource = me.model.get("datasource");
var item;
for (var i = 0, len = datasource.length; i < len; i++) {
if (datasource[i].id == id) {
item = datasource[i];
break;
}
}
if (item) {
item.fileName = "<a href='" + item["pageUrl"] + "' target='_blank'>" + item["fileName"] + "</a>";
item.typeName = ["普通flash素材", "对联flash素材"][item["type"]];
if (item["priority"] == 9) {
item.priorityName = "紧急";
} else {
item.priorityName = "不紧急";
}
item.runStatusName = ["", "等待处理", "处理中", "完成", "失败"][item["runStatus"]];
item.resultStatusName = ["", "正常", "报警"][item["resultStatus"]];
body.innerHTML = T.string.format(
er.template.get("FlashViewTpl"),
item
);
}
me.CREATE_FORM.setTitle("Flash详情");
me.CREATE_FORM.showModal();
},
/**
上传图片
*/
_getUploadPicClickHandler: function() {
var me = this;
return function() {
var type = ecui.get("type").getValue(),
fileInput,
formUpload = T.dom.g("form" + type),
actionUrl = sax.CONFIG.ADMINROOT + "/flash/upload.action",
id = this.id;
for (var i = 1; i <= parseInt(type); i++) {
if (type == "1") {
fileInput = T.dom.g("fileInput" + i);
} else {
fileInput = T.dom.g("fileInput2" + i);
}
if (me.checkUploadFileType(fileInput)=="1") {
if (i == 2) {
ecui.alert("对联广告必须上传2个文件");
} else {
ecui.alert("请检查上传文件!");
}
return false;
}
}
formUpload.action = actionUrl;
//设置提交内容
T.dom.g("hid_priority" + type).value = ecui.get("priority").getValue();
T.dom.g("hid_remarks" + type).value = ecui.get("remarks").getValue();
T.dom.g("hid_type" + type).value = type;
formUpload.submit();
me.checkFileIsUploaded();
}
},
checkUploadFileType: function(fileInput) {
var fileName = fileInput.value,
vIndex = fileName.lastIndexOf("."),
reg = new RegExp(".swf"),
id = this.id;
if (fileName == "") {
return 1;
}
if (vIndex != -1) {
var extFileName = fileName.substr(vIndex).toLowerCase();
if (!reg.test(extFileName.toLowerCase())) {
return 2;
}
}
return 3;
},
/**
检查是否上传完毕
*/
checkFileIsUploaded: function() {
var uploadIframe = T.dom.g("uploadIframe"),
doc,
me = this;
app.loading.show('正在上传文件,请稍后...');
var tm = setInterval(function() {
if (T.browser.ie) {
doc = document.frames["uploadIframe"].document;
} else {
doc = uploadIframe.contentDocument;
}
if (doc.body.innerHTML != "") {
clearInterval(tm);
app.loading.hide();
me.refresh();
ecui.alert("上传成功!");
var data = T.json.parse(T.dom.getText(doc.body));
}
}, 10);
},
_getUploadPicChangeHandler: function() {
var me = this;
return function() {
var fileName = T.dom.g(this.id + "_fileInputName");
if (fileName) {
if (me.checkUploadFileType(this) == "2") {
ecui.alert("必须上传swf文件!");
return;
}
fileName.innerHTML = this.value;
}
}
},
_getTypeChangeHandler: function() {
var me = this;
return function() {
var TR2 = T.dom.g("TR2");
var TR1 = T.dom.g("TR1");
if (this.getValue() == "1") {
TR2.style.display = "none";
TR1.style.display = "block";
} else {
TR2.style.display = "";
TR1.style.display = "none";
}
}
},
onleave: function() {
if (this.CREATEFORM) {
T.dom.remove(this.CREATEFORM.getMain());
}
},
onafterrender: function() {
ecui.get('SelectDate').onchange = this._getCalendarChangeHandler();
ecui.get('BtnUploadPic').onclick = this._getUploadPicClickHandler();
ecui.get('type').onchange = this._getTypeChangeHandler();
T.event.on(T.dom.g('fileInput1'), "change", this._getUploadPicChangeHandler());
T.event.on(T.dom.g('fileInput21'), "change", this._getUploadPicChangeHandler());
T.event.on(T.dom.g('fileInput22'), "change", this._getUploadPicChangeHandler());
}
});