调整代码生成器模板

This commit is contained in:
Jason 2022-08-17 11:23:12 +08:00
parent e36568372e
commit 6157258b2c
3 changed files with 13 additions and 7 deletions

View File

@ -204,10 +204,7 @@ const open = (type = 'add') => {
popupRef.value?.open()
}
const setFormData = async (row: Record<string, any>) => {
const data = await ${moduleName}Detail({
${primaryKey}: row.${primaryKey}
})
const setFormData = async (data: Record<string, any>) => {
for (const key in formData) {
if (data[key] != null && data[key] != undefined) {
//@ts-ignore
@ -222,6 +219,14 @@ const setFormData = async (row: Record<string, any>) => {
}
}
const getDetail = (row: Record<string, any>) => {
const data = await ${moduleName}Detail({
${primaryKey}: row.${primaryKey}
})
setFormData(data)
}
const handleClose = () => {
emit('close')
}
@ -239,6 +244,7 @@ getLists()
defineExpose({
open,
setFormData
setFormData,
getDetail
})
</script>

View File

@ -194,7 +194,7 @@ const handleEdit = async (data: any) => {
showEdit.value = true
await nextTick()
editRef.value?.open('edit')
editRef.value?.setFormData(data)
editRef.value?.getDetail(data)
}
const handleDelete = async (${primaryKey}: number) => {

View File

@ -180,7 +180,7 @@ const handleEdit = async (data: any) => {
showEdit.value = true
await nextTick()
editRef.value?.open('edit')
editRef.value?.setFormData(data)
editRef.value?.getDetail(data)
}
const handleDelete = async (${primaryKey}: number) => {