Commit 2187e8b837d6e24fdb955dae1416fcdb7e24c34a

Authored by xp.Huang
2 parents d45566e6 f14faf65

Merge branch 'ft' into 'main_dev'

fix: 修复产品编辑上传图片时,第一次编辑显示出图片,再去点编辑,图片消失,编辑确定后没有图片显示了(新增也是一样)

See merge request yunteng/thingskit-front!1199
@@ -69,6 +69,7 @@ @@ -69,6 +69,7 @@
69 const streamConfigOptions: any = ref([]); 69 const streamConfigOptions: any = ref([]);
70 const isUpdate = ref(true); 70 const isUpdate = ref(true);
71 const editId = ref(''); 71 const editId = ref('');
  72 + const avatarStr = ref('');
72 const [registerForm, { validate, setFieldsValue, resetFields }] = useForm({ 73 const [registerForm, { validate, setFieldsValue, resetFields }] = useForm({
73 labelWidth: 120, 74 labelWidth: 120,
74 schemas: formSchema, 75 schemas: formSchema,
@@ -111,11 +112,12 @@ @@ -111,11 +112,12 @@
111 editId.value = data.record.id; 112 editId.value = data.record.id;
112 113
113 if (data.record.avatar) { 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 if ( 121 if (
120 record?.accessMode === AccessMode.Streaming && 122 record?.accessMode === AccessMode.Streaming &&
121 record.videoPlatformDTO?.type === VideoPlatformEnum.FLUORITE 123 record.videoPlatformDTO?.type === VideoPlatformEnum.FLUORITE
@@ -125,11 +127,10 @@ @@ -125,11 +127,10 @@
125 videoFormat: record.playProtocol, 127 videoFormat: record.playProtocol,
126 }); 128 });
127 } 129 }
128 -  
129 - setFieldsValue({  
130 - ...record, 130 + // 不能把avatar字段回显进去,页面会显示大量警告
  131 + await setFieldsValue({
131 videoType: record.videoPlatformDTO?.type, 132 videoType: record.videoPlatformDTO?.type,
132 - ...(record?.params || {}), 133 + ...params,
133 }); 134 });
134 } else { 135 } else {
135 editId.value = ''; 136 editId.value = '';
@@ -79,6 +79,7 @@ @@ -79,6 +79,7 @@
79 emits('next', true, null); 79 emits('next', true, null);
80 emits('emitDeviceType', values?.deviceType); 80 emits('emitDeviceType', values?.deviceType);
81 } 81 }
  82 + const imageUrl = ref('');
82 //回显数据 83 //回显数据
83 const setFormData = async (v) => { 84 const setFormData = async (v) => {
84 if (v.image) { 85 if (v.image) {
@@ -86,7 +87,9 @@ @@ -86,7 +87,9 @@
86 image: [{ uid: buildUUID(), name: 'name', url: v.image } as FileItem], 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 setFieldsValue({ ...params, category: params?.categoryId ? 1 : 2 }); 93 setFieldsValue({ ...params, category: params?.categoryId ? 1 : 2 });
91 }; 94 };
92 //获取数据 95 //获取数据