提交 | 用户 | 时间
|
1ac2bc
|
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 |
//获取详情信息,填充表单 |
|
25 |
var ajax = new $ax(Feng.ctxPath + "/sysConfig/detail?id=" + Feng.getUrlParam("id")); |
|
26 |
var result = ajax.start(); |
|
27 |
form.val('sysConfigForm', result.data); |
|
28 |
|
|
29 |
//初始化字典选择框 |
|
30 |
var activeDictSelect = function () { |
|
31 |
$("#dictCodeDiv").show(); |
|
32 |
$("#customCodeDiv").hide(); |
|
33 |
status = "dict"; |
|
34 |
|
|
35 |
//初始化所有字典类型 |
|
36 |
$("#dictTypeId").html('<option value="">请选择系统字典类型</option>'); |
|
37 |
var ajax = new $ax(Feng.ctxPath + "/dictType/listTypes", function (data) { |
|
38 |
|
|
39 |
for (var i = 0; i < data.data.length; i++) { |
|
40 |
var dictTypeId = data.data[i].dictTypeId; |
|
41 |
var name = data.data[i].name; |
|
42 |
var code = data.data[i].code; |
|
43 |
$("#dictTypeId").append('<option value="' + dictTypeId + '">' + code + '--' + name + '</option>'); |
|
44 |
} |
|
45 |
form.render(); |
|
46 |
|
|
47 |
}, function (data) { |
|
48 |
}); |
|
49 |
ajax.start(); |
|
50 |
}; |
|
51 |
|
|
52 |
//初始化非字典选择 |
|
53 |
var activeCustomSelect = function () { |
|
54 |
$("#dictCodeDiv").hide(); |
|
55 |
$("#customCodeDiv").show(); |
|
56 |
status = "custom"; |
|
57 |
}; |
|
58 |
|
|
59 |
//更新字典详情列表 |
|
60 |
var updateDictDetail = function (dictTypeId, activeCode) { |
|
61 |
$("#dictDetails").html(''); |
|
62 |
var ajax = new $ax(Feng.ctxPath + "/dict/listDicts", function (data) { |
|
63 |
|
|
64 |
for (var i = 0; i < data.data.length; i++) { |
|
65 |
var name = data.data[i].name; |
|
66 |
var code = data.data[i].code; |
|
67 |
|
|
68 |
if (activeCode === code) { |
|
69 |
$("#dictDetails").append('<input type="radio" name="dictValue" value="' + code + '" title="' + name + '" checked="checked">'); |
|
70 |
} else { |
|
71 |
$("#dictDetails").append('<input type="radio" name="dictValue" value="' + code + '" title="' + name + '">'); |
|
72 |
} |
|
73 |
|
|
74 |
} |
|
75 |
form.render(); |
|
76 |
|
|
77 |
}, function (data) { |
|
78 |
}); |
|
79 |
ajax.set("dictTypeId", dictTypeId); |
|
80 |
ajax.start(); |
|
81 |
}; |
|
82 |
|
|
83 |
//监听单选切换 |
|
84 |
form.on('radio(dictChecked)', function (data) { |
|
85 |
if (data.value === "Y") { |
|
86 |
activeDictSelect(); |
|
87 |
} else { |
|
88 |
activeCustomSelect(); |
|
89 |
} |
|
90 |
}); |
|
91 |
|
|
92 |
//表单提交事件 |
|
93 |
form.on('submit(btnSubmit)', function (data) { |
|
94 |
|
|
95 |
//如果是选择字典 |
|
96 |
if (status === "dict") { |
|
97 |
|
|
98 |
var radio = $('input:radio[name="dictValue"]:checked').val(); |
|
99 |
|
|
100 |
if (!$("#dictTypeId").val() || !radio) { |
|
101 |
Feng.error("请选择具体字典!"); |
|
102 |
return false; |
|
103 |
} |
|
104 |
} else { |
|
105 |
if (!$("#value").val()) { |
|
106 |
Feng.error("请填写参数值!"); |
|
107 |
return false; |
|
108 |
} |
|
109 |
} |
|
110 |
|
|
111 |
var ajax = new $ax(Feng.ctxPath + "/sysConfig/editItem", function (data) { |
|
112 |
Feng.success("更新成功!"); |
|
113 |
window.location.href = Feng.ctxPath + '/sysConfig' |
|
114 |
}, function (data) { |
|
115 |
Feng.error("更新失败!" + data.responseJSON.message) |
|
116 |
}); |
|
117 |
ajax.set(data.field); |
|
118 |
ajax.start(); |
|
119 |
|
|
120 |
return false; |
|
121 |
}); |
|
122 |
|
|
123 |
//监听字典选择 |
|
124 |
form.on('select(dictTypeId)', function (data) { |
|
125 |
|
|
126 |
var dictTypeId = data.value; |
|
127 |
|
|
128 |
//初始化字典详细列表 |
|
129 |
updateDictDetail(dictTypeId); |
|
130 |
|
|
131 |
}); |
|
132 |
|
|
133 |
//返回按钮 |
|
134 |
$("#backupPage").click(function () { |
|
135 |
window.location.href = Feng.ctxPath + '/sysConfig' |
|
136 |
}); |
|
137 |
|
|
138 |
//如果当前配置是带字典类型,则初始化字典类型选择 |
|
139 |
if (result.data.dictFlag === 'Y') { |
|
140 |
activeDictSelect(); |
|
141 |
|
|
142 |
//更新选项 |
|
143 |
$("#dictTypeId").val(result.data.dictTypeId); |
|
144 |
form.render(); |
|
145 |
|
|
146 |
//更新字典类型的详情 |
|
147 |
updateDictDetail(result.data.dictTypeId, result.data.value); |
|
148 |
} else { |
|
149 |
activeCustomSelect(); |
|
150 |
} |
|
151 |
|
|
152 |
//如果是系统类型,则不能改变取值范围和字典类型 |
|
153 |
if(result.data.code.indexOf('GUNS_') === 0){ |
|
154 |
$("[name='dictFlag']").attr("disabled","disabled"); |
|
155 |
$("#dictTypeId").attr("disabled","disabled"); |
|
156 |
form.render(); |
|
157 |
} |
|
158 |
|
|
159 |
}); |