layui.use(["index", "api", "tpl", "dialog", "laypage"], function () { var $ = layui.$, table = layui.table, element = layui.element, form = layui.form, admin = layui.admin, laypage = layui.laypage; var LIST_TABLE_URL = layui.api.getMockApiUrl("detail", "list"); var DELETE_TABLE_URL = layui.api.getMockApiUrl("detail", "detail"); var where = {}; var FORM_QUERY_ID = "lay-form-submit"; // form seach ElementId var LIST_TABLE_ID = "listTable"; // table ElementId var DETAIL_TABLE_ID = "detailTable"; var LIST_TABLE_COLS = [{ field: "id", title: "id", align: "left", hide: true }, { field: "name", title: "源库", align: "left" }, { field: "ip", title: "源库对象名", align: "left" }, { field: "port", title: "目标库", align: "left" }, { field: "sid", title: "目标库对象名", align: "left" }, { fixed: "right", title: "操作", width: 150, align: "left", toolbar: "#cellOperating" }]; var DETAIL_TABLE_COLS = [{ field: "id", title: "id", align: "left", hide: true }, { field: "name", title: "源库列名", align: "left" }, { field: "ip", title: "类型", align: "left" }, { field: "port", title: "目标库列", align: "left" }, { field: "sid", title: "类型", align: "left" }]; init(); form.on("submit(" + FORM_QUERY_ID + ")", function (data) { console.log("查询:", data.field); getTableData(); }); //单元格 操作列中 操作事件 table.on("tool(" + LIST_TABLE_ID + ")", function (obj) { var data = obj.data; var layEvent = obj.event; if (layEvent === "detail") { detailDialog(data); } }); function init() { getDetail(); getSetting(); getTableData(); } function getDetail() { //api 请求得到结果 var data = { id: '5cb92069c3492', name: 'CRM->SCRM[FUL' }; var html = `
  • 任务ID : ${data.id}任务名称 : ${data.name}
  • 读节点 : ${data.id}写节点 : ${data.name}
  • 创建者 : ${data.id}创建时间 : ${data.name}
  • 更新者 : ${data.id}更新时间 : ${data.name}
  • 状态 : ${data.id}同步架构 : ${data.name}
  • 源库类型 : ${data.id}目标库类型 : ${data.name}
  • 源库端口 : ${data.id}目标库端口 : ${data.name}
  • 源库账号 : ${data.id}目标库账号 : ${data.name}
  • 已发送数据位点 : ${data.id}已删除数据位点 : ${data.name}
  • ` $('.detail-content').html(html); } function getSetting() { //api 请求得到结果 layui.tpl.setPlainTextTpl("settingId", { title: '同步方式设置2 :结构初始化 + 全量数据初始化+增量数据' }) } function getTableData() { var tableRenderOptions = { height: 300, id: LIST_TABLE_ID, elem: "#" + LIST_TABLE_ID, url: LIST_TABLE_URL, even: "false", defaultToolbar: [], page: false, cols: [LIST_TABLE_COLS], where: where }; table.render(tableRenderOptions); } function detailDialog(data) { console.log('查看列:', data); var templet = $("#tableDialogTemplate").html(); layui.laytpl(templet).render({}, function (html) { layer.open({ type: 1, title: "节点任务详情", content: templet, area: ["520px", "640px"], success: function success() { //请求api var tableRenderOptions = { height: 300, id: DETAIL_TABLE_ID, elem: "#" + DETAIL_TABLE_ID, url: DELETE_TABLE_URL, even: "false", defaultToolbar: [], page: false, cols: [DETAIL_TABLE_COLS], where: {} }; table.render(tableRenderOptions); } }); }); } });