Commit 2187e8b837d6e24fdb955dae1416fcdb7e24c34a
Merge branch 'ft' into 'main_dev'
fix: 修复产品编辑上传图片时,第一次编辑显示出图片,再去点编辑,图片消失,编辑确定后没有图片显示了(新增也是一样) See merge request yunteng/thingskit-front!1199
Showing
2 changed files
with
12 additions
and
8 deletions
| ... | ... | @@ -69,6 +69,7 @@ | 
| 69 | 69 | const streamConfigOptions: any = ref([]); | 
| 70 | 70 | const isUpdate = ref(true); | 
| 71 | 71 | const editId = ref(''); | 
| 72 | + const avatarStr = ref(''); | |
| 72 | 73 | const [registerForm, { validate, setFieldsValue, resetFields }] = useForm({ | 
| 73 | 74 | labelWidth: 120, | 
| 74 | 75 | schemas: formSchema, | 
| ... | ... | @@ -111,11 +112,12 @@ | 
| 111 | 112 | editId.value = data.record.id; | 
| 112 | 113 | |
| 113 | 114 | if (data.record.avatar) { | 
| 114 | - Object.assign(record, { | |
| 115 | - avatar: [{ uid: buildUUID(), name: 'name', url: record.avatar } as FileItem], | |
| 115 | + setFieldsValue({ | |
| 116 | + avatar: [{ uid: buildUUID(), name: 'name', url: data.record.avatar } as FileItem], | |
| 116 | 117 | }); | 
| 117 | 118 | } | 
| 118 | - | |
| 119 | + const { avatar, ...params } = data.record; | |
| 120 | + avatarStr.value = avatar; | |
| 119 | 121 | if ( | 
| 120 | 122 | record?.accessMode === AccessMode.Streaming && | 
| 121 | 123 | record.videoPlatformDTO?.type === VideoPlatformEnum.FLUORITE | 
| ... | ... | @@ -125,11 +127,10 @@ | 
| 125 | 127 | videoFormat: record.playProtocol, | 
| 126 | 128 | }); | 
| 127 | 129 | } | 
| 128 | - | |
| 129 | - setFieldsValue({ | |
| 130 | - ...record, | |
| 130 | + // 不能把avatar字段回显进去,页面会显示大量警告 | |
| 131 | + await setFieldsValue({ | |
| 131 | 132 | videoType: record.videoPlatformDTO?.type, | 
| 132 | - ...(record?.params || {}), | |
| 133 | + ...params, | |
| 133 | 134 | }); | 
| 134 | 135 | } else { | 
| 135 | 136 | editId.value = ''; | ... | ... | 
| ... | ... | @@ -79,6 +79,7 @@ | 
| 79 | 79 | emits('next', true, null); | 
| 80 | 80 | emits('emitDeviceType', values?.deviceType); | 
| 81 | 81 | } | 
| 82 | + const imageUrl = ref(''); | |
| 82 | 83 | //回显数据 | 
| 83 | 84 | const setFormData = async (v) => { | 
| 84 | 85 | if (v.image) { | 
| ... | ... | @@ -86,7 +87,9 @@ | 
| 86 | 87 | image: [{ uid: buildUUID(), name: 'name', url: v.image } as FileItem], | 
| 87 | 88 | }); | 
| 88 | 89 | } | 
| 89 | - const { ...params } = v; | |
| 90 | + // 不能把image字段回显进去,页面会显示大量警告 | |
| 91 | + const { image, ...params } = v; | |
| 92 | + imageUrl.value = image; | |
| 90 | 93 | setFieldsValue({ ...params, category: params?.categoryId ? 1 : 2 }); | 
| 91 | 94 | }; | 
| 92 | 95 | //获取数据 | ... | ... |