提交 | 用户 | 时间
|
1ac2bc
|
1 |
/** |
懒 |
2 |
* 详情对话框 |
|
3 |
*/ |
|
4 |
var ${entity}InfoDlg = { |
|
5 |
data: { |
|
6 |
<% for(item in table.fields!){ %> |
|
7 |
<% if(itemLP.last){ %> |
|
8 |
${item.propertyName}: "" |
|
9 |
<% }else{ %> |
|
10 |
${item.propertyName}: "", |
|
11 |
<% } %> |
|
12 |
<% } %> |
|
13 |
} |
|
14 |
}; |
|
15 |
|
|
16 |
layui.use(['form', 'admin', 'ax','laydate','upload','formSelects'], function () { |
|
17 |
var $ = layui.jquery; |
|
18 |
var $ax = layui.ax; |
|
19 |
var form = layui.form; |
|
20 |
var admin = layui.admin; |
|
21 |
|
|
22 |
<% for(var i=0 ; i < fieldConfigs.~size ; i++){ %> |
|
23 |
|
|
24 |
<% if(fieldConfigs[i].inputType == 3 ){ %> |
|
25 |
//下拉多选框 |
|
26 |
var formSelects = layui.formSelects; |
|
27 |
formSelects.config('sel${fieldConfigs[i].camelFieldName}', { |
|
28 |
searchUrl: Feng.ctxPath + "/selectList",//请更换成您自己的url,可参考项目中的其他接口 |
|
29 |
keyName: 'name',//更换成自己的keyName,可参考项目中的其他接口 |
|
30 |
keyVal: 'id'//更换成自己的keyVal,可参考项目中的其他接口 |
|
31 |
}); |
|
32 |
<% } %> |
|
33 |
|
|
34 |
<% if(fieldConfigs[i].inputType == 4){ %> |
|
35 |
//渲染时间选择框 |
|
36 |
var laydate = layui.laydate; |
|
37 |
laydate.render({ |
|
38 |
elem: '#${fieldConfigs[i].camelFieldName}' //指定元素 |
|
39 |
}); |
|
40 |
<% } %> |
|
41 |
|
|
42 |
<% if(fieldConfigs[i].inputType == 5){ %> |
|
43 |
//普通图片上传 |
|
44 |
var upload = layui.upload; |
|
45 |
upload.render({ |
|
46 |
elem: '#${fieldConfigs[i].camelFieldName}' |
|
47 |
,url: Feng.ctxPath + '/system/upload' //改成您自己的上传接口 |
|
48 |
,before: function(obj){ |
|
49 |
//预读本地文件示例,不支持ie8 |
|
50 |
obj.preview(function(index, file, result){ |
|
51 |
$('#filePreview').attr('src', result); //图片链接(base64) |
|
52 |
}); |
|
53 |
} |
|
54 |
,done: function(res){ |
|
55 |
var ajax = new $ax(Feng.ctxPath + "/system/updateAvatar", function (data) { |
|
56 |
Feng.success(res.message); |
|
57 |
}, function (data) { |
|
58 |
Feng.error("修改失败!" + data.responseJSON.message + "!"); |
|
59 |
}); |
|
60 |
ajax.set("fileId", res.data.fileId); |
|
61 |
ajax.start(); |
|
62 |
} |
|
63 |
,error: function(){ |
|
64 |
Feng.error("上传文件失败!"); |
|
65 |
} |
|
66 |
}); |
|
67 |
<% } %> |
|
68 |
<% } %> |
|
69 |
|
|
70 |
//获取详情信息,填充表单 |
|
71 |
var ajax = new $ax(Feng.ctxPath + "/${lowerEntity}/detail?${keyPropertyName}=" + Feng.getUrlParam("${keyPropertyName}")); |
|
72 |
var result = ajax.start(); |
|
73 |
form.val('${lowerEntity}Form', result.data); |
|
74 |
|
|
75 |
//表单提交事件 |
|
76 |
form.on('submit(btnSubmit)', function (data) { |
|
77 |
var ajax = new $ax(Feng.ctxPath + "/${lowerEntity}/editItem", function (data) { |
|
78 |
Feng.success("更新成功!"); |
|
79 |
<% if(jumpType){ %> |
|
80 |
//传给上个页面,刷新table用 |
|
81 |
admin.putTempData('formOk', true); |
|
82 |
//关掉对话框 |
|
83 |
admin.closeThisDialog(); |
|
84 |
<% }else{ %> |
|
85 |
window.location.href = Feng.ctxPath + '/${lowerEntity}' |
|
86 |
<% } %> |
|
87 |
}, function (data) { |
|
88 |
Feng.error("更新失败!" + data.responseJSON.message) |
|
89 |
}); |
|
90 |
ajax.set(data.field); |
|
91 |
ajax.start(); |
|
92 |
|
|
93 |
return false; |
|
94 |
}); |
|
95 |
|
|
96 |
<% if(!jumpType){ %> |
|
97 |
$('#cancel').click(function(){ |
|
98 |
window.location.href = Feng.ctxPath + '/${lowerEntity}' |
|
99 |
}); |
|
100 |
<% } %> |
|
101 |
}); |