|
@@ -64,26 +64,28 @@ const ProjectModal: React.FC<ProjectModalProps> = ({
|
|
|
})
|
|
|
|
|
|
const onMount = async () => {
|
|
|
- const { code = -1, data = {} } = await getProject({ ID: defaultFormData.dataID })
|
|
|
- if (code === consts.RET_CODE.SUCCESS) {
|
|
|
- const currentFormData = { ...data }
|
|
|
- const keys = Object.keys(currentFormData)
|
|
|
- keys.forEach(key => {
|
|
|
- if (currentFormData[key] instanceof Object) {
|
|
|
- const targetMap = currentFormData[key]
|
|
|
- delete currentFormData[key]
|
|
|
- currentFormData[`${key}ID`] = targetMap.ID
|
|
|
- }
|
|
|
- })
|
|
|
- form.setValues(type === ModalType.ADD ? {} : { ...currentFormData })
|
|
|
- delay(80).then(() => {
|
|
|
- // console.log(pTypeList)
|
|
|
+ if (defaultFormData?.dataID) {
|
|
|
+ const { code = -1, data = {} } = await getProject({ ID: defaultFormData.dataID })
|
|
|
+ if (code === consts.RET_CODE.SUCCESS) {
|
|
|
+ const currentFormData = { ...data }
|
|
|
+ const keys = Object.keys(currentFormData)
|
|
|
+ keys.forEach(key => {
|
|
|
+ if (currentFormData[key] instanceof Object) {
|
|
|
+ const targetMap = currentFormData[key]
|
|
|
+ delete currentFormData[key]
|
|
|
+ currentFormData[`${key}ID`] = targetMap.ID
|
|
|
+ }
|
|
|
+ })
|
|
|
+ form.setValues(type === ModalType.ADD ? {} : { ...currentFormData })
|
|
|
+ delay(80).then(() => {
|
|
|
+ // console.log(pTypeList)
|
|
|
|
|
|
- form.setSchemaByPath('projectTypeID', {
|
|
|
- enum: pTypeList.map(item => item.value),
|
|
|
- enumNames: pTypeList.map(item => item.label)
|
|
|
+ form.setSchemaByPath('projectTypeID', {
|
|
|
+ enum: pTypeList.map(item => item.value),
|
|
|
+ enumNames: pTypeList.map(item => item.label)
|
|
|
+ })
|
|
|
})
|
|
|
- })
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|