调整代码生成器模板
This commit is contained in:
parent
e36568372e
commit
6157258b2c
|
|
@ -204,10 +204,7 @@ const open = (type = 'add') => {
|
||||||
popupRef.value?.open()
|
popupRef.value?.open()
|
||||||
}
|
}
|
||||||
|
|
||||||
const setFormData = async (row: Record<string, any>) => {
|
const setFormData = async (data: Record<string, any>) => {
|
||||||
const data = await ${moduleName}Detail({
|
|
||||||
${primaryKey}: row.${primaryKey}
|
|
||||||
})
|
|
||||||
for (const key in formData) {
|
for (const key in formData) {
|
||||||
if (data[key] != null && data[key] != undefined) {
|
if (data[key] != null && data[key] != undefined) {
|
||||||
//@ts-ignore
|
//@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 = () => {
|
const handleClose = () => {
|
||||||
emit('close')
|
emit('close')
|
||||||
}
|
}
|
||||||
|
|
@ -239,6 +244,7 @@ getLists()
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
open,
|
open,
|
||||||
setFormData
|
setFormData,
|
||||||
|
getDetail
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -194,7 +194,7 @@ const handleEdit = async (data: any) => {
|
||||||
showEdit.value = true
|
showEdit.value = true
|
||||||
await nextTick()
|
await nextTick()
|
||||||
editRef.value?.open('edit')
|
editRef.value?.open('edit')
|
||||||
editRef.value?.setFormData(data)
|
editRef.value?.getDetail(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleDelete = async (${primaryKey}: number) => {
|
const handleDelete = async (${primaryKey}: number) => {
|
||||||
|
|
|
||||||
|
|
@ -180,7 +180,7 @@ const handleEdit = async (data: any) => {
|
||||||
showEdit.value = true
|
showEdit.value = true
|
||||||
await nextTick()
|
await nextTick()
|
||||||
editRef.value?.open('edit')
|
editRef.value?.open('edit')
|
||||||
editRef.value?.setFormData(data)
|
editRef.value?.getDetail(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleDelete = async (${primaryKey}: number) => {
|
const handleDelete = async (${primaryKey}: number) => {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue