|
|
|
@ -5,6 +5,14 @@ class FormConfigComponent { |
|
|
|
|
this.lay = lay; |
|
|
|
|
this.dataMap = new Map(); |
|
|
|
|
this.renderTable(); |
|
|
|
|
// 文件上传表单按数据类型配置不同的字段属性。
|
|
|
|
|
if(elemId == 'fileUploadFormTable') { |
|
|
|
|
lay.dict.render(); |
|
|
|
|
lay.dict.onchange('dict-dataType', (data) => { |
|
|
|
|
new FormConfigComponent(data.value, 'fileUploadFormTable', layui); |
|
|
|
|
lay.dict.setData('dict-dataType',data.value); |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
renderTable() { |
|
|
|
@ -40,11 +48,13 @@ class FormConfigComponent { |
|
|
|
|
}, |
|
|
|
|
{field: 'sort', title: '显示顺序', edit: 'text'} |
|
|
|
|
]], |
|
|
|
|
done: (res) => this.tableLoadDoneListen(res), |
|
|
|
|
done: (res) => { |
|
|
|
|
this.tableLoadDoneListen(res) |
|
|
|
|
}, |
|
|
|
|
onToolBarTable: ({event, config})=> { |
|
|
|
|
if(event === 'save'){ |
|
|
|
|
const datas = [...this.dataMap.values()]; |
|
|
|
|
Util.post(`/sys/form/config/api/save`, {params: JSON.stringify(datas)}).then(res=>{ |
|
|
|
|
Util.post(`/sys/form/config/api/save`, {params: JSON.stringify(datas),formType: formType}).then(res=>{ |
|
|
|
|
if(res.flag){ |
|
|
|
|
showOkMsg('保存成功') |
|
|
|
|
}else{ |
|
|
|
@ -66,12 +76,14 @@ class FormConfigComponent { |
|
|
|
|
const id = data.id, value = data[fieldName]; |
|
|
|
|
return `<input type="checkbox" id="${id}" name="${fieldName}" value="${value}" title="是|否" lay-skin="switch" lay-filter="${elemId}-switch" ${value ? 'checked' : ''} />` |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
tableLoadDoneListen(res) { |
|
|
|
|
if (res.flag) { |
|
|
|
|
res.records.map(record => this.dataMap.set(record.id + '', record)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
switchChangeListen({elem}) { |
|
|
|
@ -81,7 +93,7 @@ class FormConfigComponent { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
layui.use(['form', 'gtable', 'dropdown', 'element'], function () { |
|
|
|
|
layui.use(['form', 'gtable', 'dropdown', 'element','dict'], function () { |
|
|
|
|
const metadataForm = new FormConfigComponent(1, 'metadataFormTable', layui); |
|
|
|
|
const fileUploadForm = new FormConfigComponent(2, 'fileUploadFormTable', layui); |
|
|
|
|
}); |
|
|
|
|