diff --git a/src/main/resources/static/pages/evaluate/template/evaluateTemplate.html b/src/main/resources/static/pages/evaluate/template/evaluateTemplate.html index ec262a1..22bd9ea 100644 --- a/src/main/resources/static/pages/evaluate/template/evaluateTemplate.html +++ b/src/main/resources/static/pages/evaluate/template/evaluateTemplate.html @@ -110,12 +110,14 @@ , { field: 'name', align: 'center', title: '模板名称' } , { field: 'createUser', 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: '启用状态', templet: function (d) { // 根据 isUse 字段的值决定开关的状态 - return ''; + return ''; } }, { @@ -166,10 +168,26 @@ // 监听开关事件 done: function () { layui.form.on('switch(switchTest)', function (obj) { - var status = obj.elem.checked ? '开' : '关'; - // 这里可以添加你更新启用状态的逻辑,向服务器发送修改请求 - // console.log('状态更新为:' + status); - alert('状态更新为:' + status) + const configId = obj.elem.getAttribute('data-configId') + // 如果为 true 则打开状态 调后台接口 + if (obj.elem.checked) { + $.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 }); + // } + } + }); + } }); } });