代码调试
This commit is contained in:
parent
7e678c83d9
commit
8f0a0dccee
|
|
@ -110,12 +110,14 @@
|
||||||
, { field: 'name', align: 'center', title: '模板名称' }
|
, { field: 'name', align: 'center', title: '模板名称' }
|
||||||
, { field: 'createUser', align: 'center', title: '创建人' }
|
, { field: 'createUser', align: 'center', title: '创建人' }
|
||||||
, { field: 'createTime', align: 'center', title: '创建时间' }
|
, { field: 'createTime', align: 'center', title: '创建时间' }
|
||||||
, { field: 'version', align: 'center', title: '版本' },
|
, { field: 'version', align: 'center', title: '版本', width: 120, },
|
||||||
, {
|
, {
|
||||||
field: 'isEnable', align: 'center', title: '启用状态',
|
field: 'isEnable', align: 'center', title: '启用状态',
|
||||||
templet: function (d) {
|
templet: function (d) {
|
||||||
// 根据 isUse 字段的值决定开关的状态
|
// 根据 isUse 字段的值决定开关的状态
|
||||||
return '<input type="checkbox" lay-filter="switchTest" lay-skin="switch" lay-text="启用|禁用" ' + (d.isEnable == '0' ? 'checked' : '') + '>';
|
return '<input type="checkbox" lay-filter="switchTest" lay-skin="switch" lay-text="启用|禁用" ' +
|
||||||
|
(d.isEnable == '0' ? 'checked' : '') +
|
||||||
|
' data-configId="' + d.configId + '">';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -166,10 +168,26 @@
|
||||||
// 监听开关事件
|
// 监听开关事件
|
||||||
done: function () {
|
done: function () {
|
||||||
layui.form.on('switch(switchTest)', function (obj) {
|
layui.form.on('switch(switchTest)', function (obj) {
|
||||||
var status = obj.elem.checked ? '开' : '关';
|
const configId = obj.elem.getAttribute('data-configId')
|
||||||
// 这里可以添加你更新启用状态的逻辑,向服务器发送修改请求
|
// 如果为 true 则打开状态 调后台接口
|
||||||
// console.log('状态更新为:' + status);
|
if (obj.elem.checked) {
|
||||||
alert('状态更新为:' + status)
|
$.ajax({
|
||||||
|
type: "POST",
|
||||||
|
url: ctxPath + '/setTemplate/changeEnable',
|
||||||
|
data: { configId },
|
||||||
|
success: function (data) {
|
||||||
|
layer.close(index);
|
||||||
|
|
||||||
|
console.log('状态修改结果', data)
|
||||||
|
// if (data.res === 1) {
|
||||||
|
// layer.msg(data.resMsg, { icon: 1, time: 2000 });
|
||||||
|
// search(1);
|
||||||
|
// } else {
|
||||||
|
// layer.msg(data.resMsg, { icon: 2, time: 2000 });
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue