提交 | 用户 | 时间
|
8286c6
|
1 |
/** |
懒 |
2 |
* 添加或者修改页面 |
|
3 |
*/ |
|
4 |
var SysConfigInfoDlg = { |
|
5 |
data: { |
|
6 |
name: "", |
|
7 |
dictFlag: "", |
|
8 |
code: "", |
|
9 |
value: "", |
|
10 |
remark: "", |
|
11 |
createTime: "", |
|
12 |
createUser: "", |
|
13 |
updateTime: "", |
|
14 |
updateUser: "" |
|
15 |
} |
|
16 |
}; |
|
17 |
|
|
18 |
layui.use(['form', 'admin', 'ax'], function () { |
|
19 |
var $ = layui.jquery; |
|
20 |
var $ax = layui.ax; |
|
21 |
var form = layui.form; |
|
22 |
var admin = layui.admin; |
|
23 |
|
|
24 |
//默认的激活状态 dict 或者 custom |
|
25 |
var status = "dict"; |
|
26 |
|
|
27 |
//初始化字典选择框 |
|
28 |
var activeDictSelect = function () { |
|
29 |
$("#dictCodeDiv").show(); |
|
30 |
$("#customCodeDiv").hide(); |
|
31 |
status = "dict"; |
|
32 |
|
|
33 |
//初始化所有字典类型 |
|
34 |
$("#dictTypeId").html('<option value="">请选择系统字典类型</option>'); |
|
35 |
var ajax = new $ax(Feng.ctxPath + "/dictType/listTypes", function (data) { |
|
36 |
|
|
37 |
for (var i = 0; i < data.data.length; i++) { |
|
38 |
var dictTypeId = data.data[i].dictTypeId; |
|
39 |
var name = data.data[i].name; |
|
40 |
var code = data.data[i].code; |
|
41 |
$("#dictTypeId").append('<option value="' + dictTypeId + '">' + code + '--' + name + '</option>'); |
|
42 |
} |
|
43 |
form.render(); |
|
44 |
|
|
45 |
}, function (data) { |
|
46 |
}); |
|
47 |
ajax.start(); |
|
48 |
}; |
|
49 |
|
|
50 |
//初始化非字典选择 |
|
51 |
var activeCustomSelect = function () { |
|
52 |
$("#dictCodeDiv").hide(); |
|
53 |
$("#customCodeDiv").show(); |
|
54 |
status = "custom"; |
|
55 |
}; |
|
56 |
|
|
57 |
//表单提交事件 |
|
58 |
form.on('submit(btnSubmit)', function (data) { |
|
59 |
|
|
60 |
//如果是选择字典 |
|
61 |
if (status === "dict") { |
|
62 |
|
|
63 |
var radio = $('input:radio[name="dictValue"]:checked').val(); |
|
64 |
|
|
65 |
if (!$("#dictTypeId").val() || !radio) { |
|
66 |
Feng.error("请选择具体字典!"); |
|
67 |
return false; |
|
68 |
} |
|
69 |
} else { |
|
70 |
if (!$("#value").val()) { |
|
71 |
Feng.error("请填写参数值!"); |
|
72 |
return false; |
|
73 |
} |
|
74 |
} |
|
75 |
|
|
76 |
var ajax = new $ax(Feng.ctxPath + "/sysConfig/addItem", function (data) { |
|
77 |
Feng.success("添加成功!"); |
|
78 |
window.location.href = Feng.ctxPath + '/sysConfig' |
|
79 |
}, function (data) { |
|
80 |
Feng.error("添加失败!" + data.responseJSON.message) |
|
81 |
}); |
|
82 |
ajax.set(data.field); |
|
83 |
ajax.start(); |
|
84 |
|
|
85 |
return false; |
|
86 |
}); |
|
87 |
|
|
88 |
//监听单选切换 |
|
89 |
form.on('radio(dictChecked)', function (data) { |
|
90 |
if (data.value === "Y") { |
|
91 |
activeDictSelect(); |
|
92 |
} else { |
|
93 |
activeCustomSelect(); |
|
94 |
} |
|
95 |
}); |
|
96 |
|
|
97 |
//监听字典选择 |
|
98 |
form.on('select(dictTypeId)', function (data) { |
|
99 |
|
|
100 |
var dictTypeId = data.value; |
|
101 |
|
|
102 |
//初始化字典详细列表 |
|
103 |
$("#dictDetails").html(''); |
|
104 |
var ajax = new $ax(Feng.ctxPath + "/dict/listDicts", function (data) { |
|
105 |
|
|
106 |
for (var i = 0; i < data.data.length; i++) { |
|
107 |
var name = data.data[i].name; |
|
108 |
var code = data.data[i].code; |
|
109 |
$("#dictDetails").append('<input type="radio" name="dictValue" value="' + code + '" title="' + name + '">'); |
|
110 |
} |
|
111 |
form.render(); |
|
112 |
|
|
113 |
}, function (data) { |
|
114 |
}); |
|
115 |
ajax.set("dictTypeId", dictTypeId); |
|
116 |
ajax.start(); |
|
117 |
|
|
118 |
}); |
|
119 |
|
|
120 |
//返回按钮 |
|
121 |
$("#backupPage").click(function () { |
|
122 |
window.location.href = Feng.ctxPath + '/sysConfig' |
|
123 |
}); |
|
124 |
|
|
125 |
//显示字典编码选择 |
|
126 |
activeDictSelect(); |
|
127 |
|
|
128 |
}); |