|
|
@ -5,6 +5,14 @@ class FormConfigComponent { |
|
|
|
this.lay = lay; |
|
|
|
this.lay = lay; |
|
|
|
this.dataMap = new Map(); |
|
|
|
this.dataMap = new Map(); |
|
|
|
this.renderTable(); |
|
|
|
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() { |
|
|
|
renderTable() { |
|
|
@ -40,11 +48,13 @@ class FormConfigComponent { |
|
|
|
}, |
|
|
|
}, |
|
|
|
{field: 'sort', title: '显示顺序', edit: 'text'} |
|
|
|
{field: 'sort', title: '显示顺序', edit: 'text'} |
|
|
|
]], |
|
|
|
]], |
|
|
|
done: (res) => this.tableLoadDoneListen(res), |
|
|
|
done: (res) => { |
|
|
|
|
|
|
|
this.tableLoadDoneListen(res) |
|
|
|
|
|
|
|
}, |
|
|
|
onToolBarTable: ({event, config})=> { |
|
|
|
onToolBarTable: ({event, config})=> { |
|
|
|
if(event === 'save'){ |
|
|
|
if(event === 'save'){ |
|
|
|
const datas = [...this.dataMap.values()]; |
|
|
|
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){ |
|
|
|
if(res.flag){ |
|
|
|
showOkMsg('保存成功') |
|
|
|
showOkMsg('保存成功') |
|
|
|
}else{ |
|
|
|
}else{ |
|
|
@ -66,12 +76,14 @@ class FormConfigComponent { |
|
|
|
const id = data.id, value = data[fieldName]; |
|
|
|
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' : ''} />` |
|
|
|
return `<input type="checkbox" id="${id}" name="${fieldName}" value="${value}" title="是|否" lay-skin="switch" lay-filter="${elemId}-switch" ${value ? 'checked' : ''} />` |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
tableLoadDoneListen(res) { |
|
|
|
tableLoadDoneListen(res) { |
|
|
|
if (res.flag) { |
|
|
|
if (res.flag) { |
|
|
|
res.records.map(record => this.dataMap.set(record.id + '', record)); |
|
|
|
res.records.map(record => this.dataMap.set(record.id + '', record)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
switchChangeListen({elem}) { |
|
|
|
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 metadataForm = new FormConfigComponent(1, 'metadataFormTable', layui); |
|
|
|
const fileUploadForm = new FormConfigComponent(2, 'fileUploadFormTable', layui); |
|
|
|
const fileUploadForm = new FormConfigComponent(2, 'fileUploadFormTable', layui); |
|
|
|
}); |
|
|
|
}); |
|
|
|