调整代码生成器模板
This commit is contained in:
parent
e36568372e
commit
6157258b2c
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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) => {
|
||||
|
|
|
|||
|
|
@ -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) => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue