懒羊羊
2023-11-14 8286c62256f23bc2367a6729c0f46f84215e380b
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
/**
 * 详情对话框
 */
var ${entity}InfoDlg = {
    data: {
    <% for(item in table.fields!){                      %>
    <%     if(itemLP.last){                             %>
        ${item.propertyName}: ""
    <%     }else{                                       %>
        ${item.propertyName}: "",
    <%     }                                            %>
    <% }                                                %>
    }
};
 
layui.use(['form', 'admin', 'ax','laydate','upload','formSelects'], function () {
    var $ = layui.jquery;
    var $ax = layui.ax;
    var form = layui.form;
    var admin = layui.admin;
 
    <% for(var i=0 ; i < fieldConfigs.~size ; i++){     %>
 
    <%  if(fieldConfigs[i].inputType == 3 ){            %>
    //下拉多选框
    var formSelects = layui.formSelects;
    formSelects.config('sel${fieldConfigs[i].camelFieldName}', {
        searchUrl: Feng.ctxPath + "/selectList",//请更换成您自己的url,可参考项目中的其他接口
        keyName: 'name',//更换成自己的keyName,可参考项目中的其他接口
        keyVal: 'id'//更换成自己的keyVal,可参考项目中的其他接口
    });
    <%     }                                            %>
 
    <%     if(fieldConfigs[i].inputType == 4){          %>
    //渲染时间选择框
    var laydate = layui.laydate;
    laydate.render({
        elem: '#${fieldConfigs[i].camelFieldName}' //指定元素
    });
    <%     }                                            %>
 
    <%     if(fieldConfigs[i].inputType == 5){          %>
    //普通图片上传
    var upload = layui.upload;
    upload.render({
        elem: '#${fieldConfigs[i].camelFieldName}'
        ,url: Feng.ctxPath + '/system/upload' //改成您自己的上传接口
        ,before: function(obj){
            //预读本地文件示例,不支持ie8
            obj.preview(function(index, file, result){
                $('#filePreview').attr('src', result); //图片链接(base64)
            });
        }
        ,done: function(res){
            var ajax = new $ax(Feng.ctxPath + "/system/updateAvatar", function (data) {
                Feng.success(res.message);
            }, function (data) {
                Feng.error("修改失败!" + data.responseJSON.message + "!");
            });
            ajax.set("fileId", res.data.fileId);
            ajax.start();
        }
        ,error: function(){
            Feng.error("上传文件失败!");
        }
    });
    <%     }                                            %>
    <% }                                                %>
 
    //获取详情信息,填充表单
    var ajax = new $ax(Feng.ctxPath + "/${lowerEntity}/detail?${keyPropertyName}=" + Feng.getUrlParam("${keyPropertyName}"));
    var result = ajax.start();
    form.val('${lowerEntity}Form', result.data);
 
    //表单提交事件
    form.on('submit(btnSubmit)', function (data) {
        var ajax = new $ax(Feng.ctxPath + "/${lowerEntity}/editItem", function (data) {
            Feng.success("更新成功!");
    <% if(jumpType){                        %>
            //传给上个页面,刷新table用
            admin.putTempData('formOk', true);
            //关掉对话框
            admin.closeThisDialog();
    <% }else{                               %>
            window.location.href = Feng.ctxPath + '/${lowerEntity}'
    <% }                                    %>
        }, function (data) {
            Feng.error("更新失败!" + data.responseJSON.message)
        });
        ajax.set(data.field);
        ajax.start();
 
        return false;
    });
 
    <% if(!jumpType){               %>
    $('#cancel').click(function(){
        window.location.href = Feng.ctxPath + '/${lowerEntity}'
    });
    <% }                            %>
});