懒羊羊
2024-01-10 a556270e96bc6e7fa4202c466d57cc75f778c614
提交 | 用户 | 时间
71e81e 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     form.on('submit(btnSubmit)', function (data) {
72         var ajax = new $ax(Feng.ctxPath + "/${lowerEntity}/addItem", function (data) {
73             Feng.success("添加成功!");
74     <% if(jumpType){                        %>
75             //传给上个页面,刷新table用
76             admin.putTempData('formOk', true);
77             //关掉对话框
78             admin.closeThisDialog();
79     <% }else{                               %>
80             window.location.href = Feng.ctxPath + '/${lowerEntity}'
81     <% }                                    %>
82         }, function (data) {
83             Feng.error("添加失败!" + data.responseJSON.message)
84         });
85         ajax.set(data.field);
86         ajax.start();
87
88         return false;
89     });
90
91     <% if(!jumpType){                       %>
92     $('#cancel').click(function(){
93         window.location.href = Feng.ctxPath + '/${lowerEntity}'
94     });
95     <% }                                    %>
96
97 });