Commit f6298fedf446d13b97929c98b0d1f14694d60e34
Committed by
xp.Huang
1 parent
4cafa320
fix: 图片删除时先调用接口
Showing
23 changed files
with
517 additions
and
84 deletions
@@ -3,8 +3,15 @@ import { FileUploadResponse } from '/@/api/oss/FileUploadResponse'; | @@ -3,8 +3,15 @@ import { FileUploadResponse } from '/@/api/oss/FileUploadResponse'; | ||
3 | 3 | ||
4 | enum Api { | 4 | enum Api { |
5 | BaseUploadUrl = '/oss/upload', | 5 | BaseUploadUrl = '/oss/upload', |
6 | + BaseDeleteUrl = '/oss', | ||
6 | } | 7 | } |
7 | 8 | ||
8 | export const upload = (file) => { | 9 | export const upload = (file) => { |
9 | return defHttp.post<FileUploadResponse>({ url: Api.BaseUploadUrl, params: file }); | 10 | return defHttp.post<FileUploadResponse>({ url: Api.BaseUploadUrl, params: file }); |
10 | }; | 11 | }; |
12 | + | ||
13 | +export const deleteFilePath = (deleteFilePath?: string) => { | ||
14 | + return defHttp.delete({ | ||
15 | + url: `${Api.BaseDeleteUrl}?deleteFilePath=${deleteFilePath}`, | ||
16 | + }); | ||
17 | +}; |
@@ -21,7 +21,7 @@ | @@ -21,7 +21,7 @@ | ||
21 | } | 21 | } |
22 | 22 | ||
23 | const { prefixCls } = useDesign('api-upload'); | 23 | const { prefixCls } = useDesign('api-upload'); |
24 | - const emit = defineEmits(['update:fileList', 'preview', 'download']); | 24 | + const emit = defineEmits(['update:fileList', 'preview', 'download', 'delete']); |
25 | 25 | ||
26 | const { createMessage } = useMessage(); | 26 | const { createMessage } = useMessage(); |
27 | 27 | ||
@@ -129,6 +129,7 @@ | @@ -129,6 +129,7 @@ | ||
129 | const index = _fileList.findIndex((item) => item.uid === file.uid); | 129 | const index = _fileList.findIndex((item) => item.uid === file.uid); |
130 | ~index && _fileList.splice(index, 1); | 130 | ~index && _fileList.splice(index, 1); |
131 | emit('update:fileList', _fileList); | 131 | emit('update:fileList', _fileList); |
132 | + emit('delete', file.url); | ||
132 | }; | 133 | }; |
133 | 134 | ||
134 | const handlePreview = (file: FileItem) => { | 135 | const handlePreview = (file: FileItem) => { |
@@ -51,6 +51,7 @@ | @@ -51,6 +51,7 @@ | ||
51 | import { useDrawer } from '/@/components/Drawer'; | 51 | import { useDrawer } from '/@/components/Drawer'; |
52 | import { FileItem } from '/@/components/Form/src/components/ApiUpload.vue'; | 52 | import { FileItem } from '/@/components/Form/src/components/ApiUpload.vue'; |
53 | import { buildUUID } from '/@/utils/uuid'; | 53 | import { buildUUID } from '/@/utils/uuid'; |
54 | + import { deleteFilePath } from '/@/api/oss/ossFileUploader'; | ||
54 | 55 | ||
55 | export default defineComponent({ | 56 | export default defineComponent({ |
56 | name: 'ContactDrawer', | 57 | name: 'ContactDrawer', |
@@ -161,6 +162,11 @@ | @@ -161,6 +162,11 @@ | ||
161 | } else { | 162 | } else { |
162 | delete values.id; | 163 | delete values.id; |
163 | } | 164 | } |
165 | + | ||
166 | + if (Reflect.has(values, 'deleteUrl')) { | ||
167 | + await deleteFilePath(values?.deleteUrl); | ||
168 | + Reflect.deleteProperty(values, 'deleteUrl'); | ||
169 | + } | ||
164 | let saveMessage = '添加成功'; | 170 | let saveMessage = '添加成功'; |
165 | let updateMessage = '修改成功'; | 171 | let updateMessage = '修改成功'; |
166 | 172 |
@@ -192,7 +192,7 @@ export const formSchema: QFormSchema[] = [ | @@ -192,7 +192,7 @@ export const formSchema: QFormSchema[] = [ | ||
192 | component: 'ApiUpload', | 192 | component: 'ApiUpload', |
193 | changeEvent: 'update:fileList', | 193 | changeEvent: 'update:fileList', |
194 | valueField: 'fileList', | 194 | valueField: 'fileList', |
195 | - componentProps: () => { | 195 | + componentProps: ({ formModel }) => { |
196 | return { | 196 | return { |
197 | listType: 'picture-card', | 197 | listType: 'picture-card', |
198 | maxFileLimit: 1, | 198 | maxFileLimit: 1, |
@@ -214,10 +214,19 @@ export const formSchema: QFormSchema[] = [ | @@ -214,10 +214,19 @@ export const formSchema: QFormSchema[] = [ | ||
214 | onPreview: (fileList: FileItem) => { | 214 | onPreview: (fileList: FileItem) => { |
215 | createImgPreview({ imageList: [fileList.url!] }); | 215 | createImgPreview({ imageList: [fileList.url!] }); |
216 | }, | 216 | }, |
217 | + onDelete(url: string) { | ||
218 | + formModel.deleteUrl = url!; | ||
219 | + }, | ||
217 | }; | 220 | }; |
218 | }, | 221 | }, |
219 | }, | 222 | }, |
220 | { | 223 | { |
224 | + field: 'deleteUrl', | ||
225 | + label: '', | ||
226 | + component: 'Input', | ||
227 | + show: false, | ||
228 | + }, | ||
229 | + { | ||
221 | field: 'name', | 230 | field: 'name', |
222 | label: '视频名字', | 231 | label: '视频名字', |
223 | required: true, | 232 | required: true, |
@@ -52,6 +52,7 @@ | @@ -52,6 +52,7 @@ | ||
52 | import { createPickerSearch } from '/@/utils/pickerSearch'; | 52 | import { createPickerSearch } from '/@/utils/pickerSearch'; |
53 | import type { queryPageParams } from '/@/api/configuration/center/model/configurationCenterModal'; | 53 | import type { queryPageParams } from '/@/api/configuration/center/model/configurationCenterModal'; |
54 | import { getDeviceProfile } from '/@/api/alarm/position'; | 54 | import { getDeviceProfile } from '/@/api/alarm/position'; |
55 | + import { deleteFilePath } from '/@/api/oss/ossFileUploader'; | ||
55 | 56 | ||
56 | export default defineComponent({ | 57 | export default defineComponent({ |
57 | name: 'ConfigurationDrawer', | 58 | name: 'ConfigurationDrawer', |
@@ -263,6 +264,11 @@ | @@ -263,6 +264,11 @@ | ||
263 | values.thumbnail = file.url || null; | 264 | values.thumbnail = file.url || null; |
264 | } | 265 | } |
265 | setDrawerProps({ confirmLoading: true }); | 266 | setDrawerProps({ confirmLoading: true }); |
267 | + | ||
268 | + if (Reflect.has(values, 'deleteUrl')) { | ||
269 | + await deleteFilePath(values?.deleteUrl); | ||
270 | + Reflect.deleteProperty(values, 'deleteUrl'); | ||
271 | + } | ||
266 | let saveMessage = '添加成功'; | 272 | let saveMessage = '添加成功'; |
267 | let updateMessage = '修改成功'; | 273 | let updateMessage = '修改成功'; |
268 | values.defaultContent = getDefaultContent(values.platform); | 274 | values.defaultContent = getDefaultContent(values.platform); |
@@ -90,7 +90,7 @@ export const formSchema: FormSchema[] = [ | @@ -90,7 +90,7 @@ export const formSchema: FormSchema[] = [ | ||
90 | component: 'ApiUpload', | 90 | component: 'ApiUpload', |
91 | changeEvent: 'update:fileList', | 91 | changeEvent: 'update:fileList', |
92 | valueField: 'fileList', | 92 | valueField: 'fileList', |
93 | - componentProps: () => { | 93 | + componentProps: ({ formModel }) => { |
94 | return { | 94 | return { |
95 | listType: 'picture-card', | 95 | listType: 'picture-card', |
96 | maxFileLimit: 1, | 96 | maxFileLimit: 1, |
@@ -112,10 +112,19 @@ export const formSchema: FormSchema[] = [ | @@ -112,10 +112,19 @@ export const formSchema: FormSchema[] = [ | ||
112 | onPreview: (fileList: FileItem) => { | 112 | onPreview: (fileList: FileItem) => { |
113 | createImgPreview({ imageList: [fileList.url!] }); | 113 | createImgPreview({ imageList: [fileList.url!] }); |
114 | }, | 114 | }, |
115 | + onDelete(url: string) { | ||
116 | + formModel.deleteUrl = url!; | ||
117 | + }, | ||
115 | }; | 118 | }; |
116 | }, | 119 | }, |
117 | }, | 120 | }, |
118 | { | 121 | { |
122 | + field: 'deleteUrl', | ||
123 | + label: '', | ||
124 | + component: 'Input', | ||
125 | + show: false, | ||
126 | + }, | ||
127 | + { | ||
119 | field: 'name', | 128 | field: 'name', |
120 | label: '组态名称', | 129 | label: '组态名称', |
121 | required: true, | 130 | required: true, |
@@ -21,6 +21,7 @@ | @@ -21,6 +21,7 @@ | ||
21 | import { buildUUID } from '/@/utils/uuid'; | 21 | import { buildUUID } from '/@/utils/uuid'; |
22 | import { getDeviceProfile } from '/@/api/alarm/position'; | 22 | import { getDeviceProfile } from '/@/api/alarm/position'; |
23 | import { PC_DEFAULT_CONTENT, PHONE_DEFAULT_CONTENT, Platform } from '../center/center.data'; | 23 | import { PC_DEFAULT_CONTENT, PHONE_DEFAULT_CONTENT, Platform } from '../center/center.data'; |
24 | + import { deleteFilePath } from '/@/api/oss/ossFileUploader'; | ||
24 | 25 | ||
25 | export default defineComponent({ | 26 | export default defineComponent({ |
26 | name: 'ConfigurationDrawer', | 27 | name: 'ConfigurationDrawer', |
@@ -91,6 +92,10 @@ | @@ -91,6 +92,10 @@ | ||
91 | const file = (values.thumbnail || []).at(0) || {}; | 92 | const file = (values.thumbnail || []).at(0) || {}; |
92 | values.thumbnail = file.url || null; | 93 | values.thumbnail = file.url || null; |
93 | } | 94 | } |
95 | + if (Reflect.has(values, 'deleteUrl')) { | ||
96 | + await deleteFilePath(values?.deleteUrl); | ||
97 | + Reflect.deleteProperty(values, 'deleteUrl'); | ||
98 | + } | ||
94 | setDrawerProps({ confirmLoading: true }); | 99 | setDrawerProps({ confirmLoading: true }); |
95 | let saveMessage = '添加成功'; | 100 | let saveMessage = '添加成功'; |
96 | let updateMessage = '修改成功'; | 101 | let updateMessage = '修改成功'; |
@@ -79,7 +79,7 @@ export const formSchema: FormSchema[] = [ | @@ -79,7 +79,7 @@ export const formSchema: FormSchema[] = [ | ||
79 | component: 'ApiUpload', | 79 | component: 'ApiUpload', |
80 | changeEvent: 'update:fileList', | 80 | changeEvent: 'update:fileList', |
81 | valueField: 'fileList', | 81 | valueField: 'fileList', |
82 | - componentProps: () => { | 82 | + componentProps: ({ formModel }) => { |
83 | return { | 83 | return { |
84 | listType: 'picture-card', | 84 | listType: 'picture-card', |
85 | maxFileLimit: 1, | 85 | maxFileLimit: 1, |
@@ -101,9 +101,18 @@ export const formSchema: FormSchema[] = [ | @@ -101,9 +101,18 @@ export const formSchema: FormSchema[] = [ | ||
101 | onPreview: (fileList: FileItem) => { | 101 | onPreview: (fileList: FileItem) => { |
102 | createImgPreview({ imageList: [fileList.url!] }); | 102 | createImgPreview({ imageList: [fileList.url!] }); |
103 | }, | 103 | }, |
104 | + onDelete(url: string) { | ||
105 | + formModel.deleteUrl = url!; | ||
106 | + }, | ||
104 | }; | 107 | }; |
105 | }, | 108 | }, |
106 | }, | 109 | }, |
110 | + { | ||
111 | + field: 'deleteUrl', | ||
112 | + label: '', | ||
113 | + component: 'Input', | ||
114 | + show: false, | ||
115 | + }, | ||
107 | 116 | ||
108 | { | 117 | { |
109 | field: 'name', | 118 | field: 'name', |
@@ -19,6 +19,7 @@ | @@ -19,6 +19,7 @@ | ||
19 | import { saveOrUpdateBigScreenCenter } from '/@/api/bigscreen/center/bigscreenCenter'; | 19 | import { saveOrUpdateBigScreenCenter } from '/@/api/bigscreen/center/bigscreenCenter'; |
20 | import { FileItem } from '/@/components/Form/src/components/ApiUpload.vue'; | 20 | import { FileItem } from '/@/components/Form/src/components/ApiUpload.vue'; |
21 | import { buildUUID } from '/@/utils/uuid'; | 21 | import { buildUUID } from '/@/utils/uuid'; |
22 | + import { deleteFilePath } from '/@/api/oss/ossFileUploader'; | ||
22 | 23 | ||
23 | export default defineComponent({ | 24 | export default defineComponent({ |
24 | name: 'BigScreenDrawer', | 25 | name: 'BigScreenDrawer', |
@@ -67,6 +68,10 @@ | @@ -67,6 +68,10 @@ | ||
67 | const file = (values.thumbnail || []).at(0) || {}; | 68 | const file = (values.thumbnail || []).at(0) || {}; |
68 | values.thumbnail = file.url || null; | 69 | values.thumbnail = file.url || null; |
69 | } | 70 | } |
71 | + if (Reflect.has(values, 'deleteUrl')) { | ||
72 | + await deleteFilePath(values?.deleteUrl); | ||
73 | + Reflect.deleteProperty(values, 'deleteUrl'); | ||
74 | + } | ||
70 | setDrawerProps({ confirmLoading: true }); | 75 | setDrawerProps({ confirmLoading: true }); |
71 | let saveMessage = '添加成功'; | 76 | let saveMessage = '添加成功'; |
72 | let updateMessage = '修改成功'; | 77 | let updateMessage = '修改成功'; |
@@ -56,7 +56,7 @@ export const formSchema: FormSchema[] = [ | @@ -56,7 +56,7 @@ export const formSchema: FormSchema[] = [ | ||
56 | component: 'ApiUpload', | 56 | component: 'ApiUpload', |
57 | changeEvent: 'update:fileList', | 57 | changeEvent: 'update:fileList', |
58 | valueField: 'fileList', | 58 | valueField: 'fileList', |
59 | - componentProps: () => { | 59 | + componentProps: ({ formModel }) => { |
60 | return { | 60 | return { |
61 | listType: 'picture-card', | 61 | listType: 'picture-card', |
62 | maxFileLimit: 1, | 62 | maxFileLimit: 1, |
@@ -80,9 +80,18 @@ export const formSchema: FormSchema[] = [ | @@ -80,9 +80,18 @@ export const formSchema: FormSchema[] = [ | ||
80 | onPreview: (fileList: FileItem) => { | 80 | onPreview: (fileList: FileItem) => { |
81 | createImgPreview({ imageList: [fileList.url!] }); | 81 | createImgPreview({ imageList: [fileList.url!] }); |
82 | }, | 82 | }, |
83 | + onDelete(url: string) { | ||
84 | + formModel.deleteUrl = url!; | ||
85 | + }, | ||
83 | }; | 86 | }; |
84 | }, | 87 | }, |
85 | }, | 88 | }, |
89 | + { | ||
90 | + field: 'deleteUrl', | ||
91 | + label: '', | ||
92 | + component: 'Input', | ||
93 | + show: false, | ||
94 | + }, | ||
86 | 95 | ||
87 | { | 96 | { |
88 | field: 'name', | 97 | field: 'name', |
@@ -49,7 +49,7 @@ export const step1Schemas: FormSchema[] = [ | @@ -49,7 +49,7 @@ export const step1Schemas: FormSchema[] = [ | ||
49 | component: 'ApiUpload', | 49 | component: 'ApiUpload', |
50 | changeEvent: 'update:fileList', | 50 | changeEvent: 'update:fileList', |
51 | valueField: 'fileList', | 51 | valueField: 'fileList', |
52 | - componentProps: () => { | 52 | + componentProps: ({ formModel }) => { |
53 | return { | 53 | return { |
54 | listType: 'picture-card', | 54 | listType: 'picture-card', |
55 | maxFileLimit: 1, | 55 | maxFileLimit: 1, |
@@ -71,10 +71,19 @@ export const step1Schemas: FormSchema[] = [ | @@ -71,10 +71,19 @@ export const step1Schemas: FormSchema[] = [ | ||
71 | onPreview: (fileList: FileItem) => { | 71 | onPreview: (fileList: FileItem) => { |
72 | createImgPreview({ imageList: [fileList.url!] }); | 72 | createImgPreview({ imageList: [fileList.url!] }); |
73 | }, | 73 | }, |
74 | + onDelete(url: string) { | ||
75 | + formModel.deleteUrl = url!; | ||
76 | + }, | ||
74 | }; | 77 | }; |
75 | }, | 78 | }, |
76 | }, | 79 | }, |
77 | { | 80 | { |
81 | + field: 'deleteUrl', | ||
82 | + label: '', | ||
83 | + component: 'Input', | ||
84 | + show: false, | ||
85 | + }, | ||
86 | + { | ||
78 | field: 'alias', | 87 | field: 'alias', |
79 | label: '别名 ', | 88 | label: '别名 ', |
80 | component: 'Input', | 89 | component: 'Input', |
@@ -41,6 +41,7 @@ | @@ -41,6 +41,7 @@ | ||
41 | import { Steps } from 'ant-design-vue'; | 41 | import { Steps } from 'ant-design-vue'; |
42 | import { useMessage } from '/@/hooks/web/useMessage'; | 42 | import { useMessage } from '/@/hooks/web/useMessage'; |
43 | import { credentialTypeEnum } from '../../config/data'; | 43 | import { credentialTypeEnum } from '../../config/data'; |
44 | + import { deleteFilePath } from '/@/api/oss/ossFileUploader'; | ||
44 | 45 | ||
45 | export default defineComponent({ | 46 | export default defineComponent({ |
46 | name: 'DeviceModal', | 47 | name: 'DeviceModal', |
@@ -163,6 +164,10 @@ | @@ -163,6 +164,10 @@ | ||
163 | }, | 164 | }, |
164 | }; | 165 | }; |
165 | validateNameLength(stepRecord.name); | 166 | validateNameLength(stepRecord.name); |
167 | + if (Reflect.has(editData, 'deleteUrl')) { | ||
168 | + await deleteFilePath(editData?.deleteUrl); | ||
169 | + Reflect.deleteProperty(editData, 'deleteUrl'); | ||
170 | + } | ||
166 | await createOrEditDevice(editData); | 171 | await createOrEditDevice(editData); |
167 | } else { | 172 | } else { |
168 | const stepRecord = unref(stepState); | 173 | const stepRecord = unref(stepState); |
@@ -86,6 +86,7 @@ | @@ -86,6 +86,7 @@ | ||
86 | import TransportConfigurationStep from './step/TransportConfigurationStep.vue'; | 86 | import TransportConfigurationStep from './step/TransportConfigurationStep.vue'; |
87 | import PhysicalModelManagementStep from './step/PhysicalModelManagementStep.vue'; | 87 | import PhysicalModelManagementStep from './step/PhysicalModelManagementStep.vue'; |
88 | import { DeviceProfileDetail } from '/@/api/device/model/deviceConfigModel'; | 88 | import { DeviceProfileDetail } from '/@/api/device/model/deviceConfigModel'; |
89 | + import { deleteFilePath } from '/@/api/oss/ossFileUploader'; | ||
89 | 90 | ||
90 | const emits = defineEmits(['success', 'register']); | 91 | const emits = defineEmits(['success', 'register']); |
91 | const activeKey = ref('1'); | 92 | const activeKey = ref('1'); |
@@ -188,6 +189,10 @@ | @@ -188,6 +189,10 @@ | ||
188 | await getDeviceConfFormData(); | 189 | await getDeviceConfFormData(); |
189 | await getTransConfData(); | 190 | await getTransConfData(); |
190 | const isEmptyObj = isEmpty(transportConfData.profileData.transportConfiguration); | 191 | const isEmptyObj = isEmpty(transportConfData.profileData.transportConfiguration); |
192 | + if (Reflect.has(postSubmitFormData.deviceConfData, 'deleteUrl')) { | ||
193 | + await deleteFilePath(postSubmitFormData.deviceConfData?.deleteUrl); | ||
194 | + Reflect.deleteProperty(postSubmitFormData.deviceConfData, 'deleteUrl'); | ||
195 | + } | ||
191 | await deviceConfigAddOrEdit({ | 196 | await deviceConfigAddOrEdit({ |
192 | ...postSubmitFormData.deviceConfData, | 197 | ...postSubmitFormData.deviceConfData, |
193 | ...{ transportType: !isEmptyObj ? transportTypeStr.value : 'DEFAULT' }, | 198 | ...{ transportType: !isEmptyObj ? transportTypeStr.value : 'DEFAULT' }, |
@@ -182,7 +182,7 @@ export const step1Schemas: FormSchema[] = [ | @@ -182,7 +182,7 @@ export const step1Schemas: FormSchema[] = [ | ||
182 | component: 'ApiUpload', | 182 | component: 'ApiUpload', |
183 | changeEvent: 'update:fileList', | 183 | changeEvent: 'update:fileList', |
184 | valueField: 'fileList', | 184 | valueField: 'fileList', |
185 | - componentProps: () => { | 185 | + componentProps: ({ formModel }) => { |
186 | return { | 186 | return { |
187 | listType: 'picture-card', | 187 | listType: 'picture-card', |
188 | maxFileLimit: 1, | 188 | maxFileLimit: 1, |
@@ -204,10 +204,19 @@ export const step1Schemas: FormSchema[] = [ | @@ -204,10 +204,19 @@ export const step1Schemas: FormSchema[] = [ | ||
204 | onPreview: (fileList: FileItem) => { | 204 | onPreview: (fileList: FileItem) => { |
205 | createImgPreview({ imageList: [fileList.url!] }); | 205 | createImgPreview({ imageList: [fileList.url!] }); |
206 | }, | 206 | }, |
207 | + onDelete(url: string) { | ||
208 | + formModel.deleteUrl = url!; | ||
209 | + }, | ||
207 | }; | 210 | }; |
208 | }, | 211 | }, |
209 | }, | 212 | }, |
210 | { | 213 | { |
214 | + field: 'deleteUrl', | ||
215 | + label: '', | ||
216 | + component: 'Input', | ||
217 | + show: false, | ||
218 | + }, | ||
219 | + { | ||
211 | field: 'deviceType', | 220 | field: 'deviceType', |
212 | component: 'ApiRadioGroup', | 221 | component: 'ApiRadioGroup', |
213 | label: '设备类型', | 222 | label: '设备类型', |
1 | +import { FileItem } from '../types'; | ||
2 | +import { uploadThumbnail } from '/@/api/configuration/center/configurationCenter'; | ||
1 | import type { FormSchema } from '/@/components/Form/index'; | 3 | import type { FormSchema } from '/@/components/Form/index'; |
4 | +import { createImgPreview } from '/@/components/Preview'; | ||
2 | export const schemas: FormSchema[] = [ | 5 | export const schemas: FormSchema[] = [ |
3 | { | 6 | { |
4 | field: 'name', | 7 | field: 'name', |
@@ -27,21 +30,99 @@ export const schemas: FormSchema[] = [ | @@ -27,21 +30,99 @@ export const schemas: FormSchema[] = [ | ||
27 | }, | 30 | }, |
28 | { | 31 | { |
29 | field: 'logo', | 32 | field: 'logo', |
30 | - component: 'Upload', | ||
31 | label: 'APP Logo', | 33 | label: 'APP Logo', |
32 | - colProps: { | ||
33 | - span: 24, | 34 | + // component: 'Upload', |
35 | + // colProps: { | ||
36 | + // span: 24, | ||
37 | + // }, | ||
38 | + // slot: 'logoUpload', | ||
39 | + helpMessage: ['支持.PNG、.JPG格式,建议尺寸为32*32px,大小不超过5M '], | ||
40 | + component: 'ApiUpload', | ||
41 | + changeEvent: 'update:fileList', | ||
42 | + valueField: 'fileList', | ||
43 | + componentProps: ({ formModel }) => { | ||
44 | + return { | ||
45 | + listType: 'picture-card', | ||
46 | + maxFileLimit: 1, | ||
47 | + accept: '.png,.jpg,.jpeg,.gif', | ||
48 | + api: async (file: File) => { | ||
49 | + try { | ||
50 | + const formData = new FormData(); | ||
51 | + formData.set('file', file); | ||
52 | + const { fileStaticUri, fileName } = await uploadThumbnail(formData); | ||
53 | + return { | ||
54 | + uid: fileStaticUri, | ||
55 | + name: fileName, | ||
56 | + url: fileStaticUri, | ||
57 | + } as FileItem; | ||
58 | + } catch (error) { | ||
59 | + return {}; | ||
60 | + } | ||
61 | + }, | ||
62 | + // showUploadList: true, | ||
63 | + onDownload() {}, | ||
64 | + onPreview: (fileList: FileItem) => { | ||
65 | + createImgPreview({ imageList: [fileList.url!] }); | ||
66 | + }, | ||
67 | + onDelete(url: string) { | ||
68 | + formModel.deleteLogoUrl = url!; | ||
69 | + }, | ||
70 | + }; | ||
34 | }, | 71 | }, |
35 | - slot: 'logoUpload', | ||
36 | }, | 72 | }, |
37 | { | 73 | { |
38 | - field: 'background', | 74 | + field: 'deleteLogoUrl', |
75 | + label: '', | ||
39 | component: 'Input', | 76 | component: 'Input', |
77 | + show: false, | ||
78 | + }, | ||
79 | + { | ||
80 | + field: 'background', | ||
40 | label: '登录页背景图片', | 81 | label: '登录页背景图片', |
41 | - colProps: { | ||
42 | - span: 24, | 82 | + // component: 'Input', |
83 | + // colProps: { | ||
84 | + // span: 24, | ||
85 | + // }, | ||
86 | + // slot: 'bgUpload', | ||
87 | + helpMessage: ['支持.PNG、.JPG格式,建议尺寸为1920*1080px,大小不超过5M'], | ||
88 | + component: 'ApiUpload', | ||
89 | + changeEvent: 'update:fileList', | ||
90 | + valueField: 'fileList', | ||
91 | + componentProps: ({ formModel }) => { | ||
92 | + return { | ||
93 | + listType: 'picture-card', | ||
94 | + maxFileLimit: 1, | ||
95 | + accept: '.png,.jpg,.jpeg,.gif,', | ||
96 | + api: async (file: File) => { | ||
97 | + try { | ||
98 | + const formData = new FormData(); | ||
99 | + formData.set('file', file); | ||
100 | + const { fileStaticUri, fileName } = await uploadThumbnail(formData); | ||
101 | + return { | ||
102 | + uid: fileStaticUri, | ||
103 | + name: fileName, | ||
104 | + url: fileStaticUri, | ||
105 | + } as FileItem; | ||
106 | + } catch (error) { | ||
107 | + return {}; | ||
108 | + } | ||
109 | + }, | ||
110 | + // showUploadList: true, | ||
111 | + onDownload() {}, | ||
112 | + onPreview: (fileList: FileItem) => { | ||
113 | + createImgPreview({ imageList: [fileList.url!] }); | ||
114 | + }, | ||
115 | + onDelete(url: string) { | ||
116 | + formModel.deleteBackgroundUrl = url!; | ||
117 | + }, | ||
118 | + }; | ||
43 | }, | 119 | }, |
44 | - slot: 'bgUpload', | 120 | + }, |
121 | + { | ||
122 | + field: 'deleteBackgroundUrl', | ||
123 | + label: '', | ||
124 | + component: 'Input', | ||
125 | + show: false, | ||
45 | }, | 126 | }, |
46 | { | 127 | { |
47 | field: 'backgroundColor', | 128 | field: 'backgroundColor', |
1 | +import { FileItem } from '../types'; | ||
2 | +import { uploadThumbnail } from '/@/api/configuration/center/configurationCenter'; | ||
1 | import type { FormSchema } from '/@/components/Form/index'; | 3 | import type { FormSchema } from '/@/components/Form/index'; |
4 | +import { createImgPreview } from '/@/components/Preview'; | ||
2 | 5 | ||
3 | export const schemas: FormSchema[] = [ | 6 | export const schemas: FormSchema[] = [ |
4 | { | 7 | { |
@@ -28,30 +31,148 @@ export const schemas: FormSchema[] = [ | @@ -28,30 +31,148 @@ export const schemas: FormSchema[] = [ | ||
28 | }, | 31 | }, |
29 | { | 32 | { |
30 | field: 'logo', | 33 | field: 'logo', |
31 | - component: 'Upload', | ||
32 | label: '平台Logo', | 34 | label: '平台Logo', |
33 | - colProps: { | ||
34 | - span: 24, | 35 | + // component: 'Upload', |
36 | + // colProps: { | ||
37 | + // span: 24, | ||
38 | + // }, | ||
39 | + // slot: 'logoUpload', | ||
40 | + helpMessage: ['支持.PNG、.JPG格式,建议尺寸为32*32px,大小不超过5M '], | ||
41 | + component: 'ApiUpload', | ||
42 | + changeEvent: 'update:fileList', | ||
43 | + valueField: 'fileList', | ||
44 | + componentProps: ({ formModel }) => { | ||
45 | + return { | ||
46 | + listType: 'picture-card', | ||
47 | + maxFileLimit: 1, | ||
48 | + accept: '.png,.jpg,.jpeg,.gif', | ||
49 | + api: async (file: File) => { | ||
50 | + try { | ||
51 | + const formData = new FormData(); | ||
52 | + formData.set('file', file); | ||
53 | + const { fileStaticUri, fileName } = await uploadThumbnail(formData); | ||
54 | + return { | ||
55 | + uid: fileStaticUri, | ||
56 | + name: fileName, | ||
57 | + url: fileStaticUri, | ||
58 | + } as FileItem; | ||
59 | + } catch (error) { | ||
60 | + return {}; | ||
61 | + } | ||
62 | + }, | ||
63 | + // showUploadList: true, | ||
64 | + onDownload() {}, | ||
65 | + onPreview: (fileList: FileItem) => { | ||
66 | + createImgPreview({ imageList: [fileList.url!] }); | ||
67 | + }, | ||
68 | + onDelete(url: string) { | ||
69 | + formModel.deleteLogoUrl = url!; | ||
70 | + }, | ||
71 | + }; | ||
35 | }, | 72 | }, |
36 | - slot: 'logoUpload', | 73 | + }, |
74 | + { | ||
75 | + field: 'deleteLogoUrl', | ||
76 | + label: '', | ||
77 | + component: 'Input', | ||
78 | + show: false, | ||
37 | }, | 79 | }, |
38 | { | 80 | { |
39 | field: 'icon', | 81 | field: 'icon', |
40 | - component: 'Upload', | ||
41 | label: '浏览器ico图标', | 82 | label: '浏览器ico图标', |
42 | - colProps: { | ||
43 | - span: 24, | 83 | + // component: 'Upload', |
84 | + // colProps: { | ||
85 | + // span: 24, | ||
86 | + // }, | ||
87 | + // slot: 'iconUpload', | ||
88 | + helpMessage: ['支持.ICO格式,建议尺寸为16*16px '], | ||
89 | + component: 'ApiUpload', | ||
90 | + changeEvent: 'update:fileList', | ||
91 | + valueField: 'fileList', | ||
92 | + componentProps: ({ formModel }) => { | ||
93 | + return { | ||
94 | + listType: 'picture-card', | ||
95 | + maxFileLimit: 1, | ||
96 | + maxSize: 500 * 1024, | ||
97 | + accept: '.icon,.ico', | ||
98 | + api: async (file: File) => { | ||
99 | + try { | ||
100 | + const formData = new FormData(); | ||
101 | + formData.set('file', file); | ||
102 | + const { fileStaticUri, fileName } = await uploadThumbnail(formData); | ||
103 | + return { | ||
104 | + uid: fileStaticUri, | ||
105 | + name: fileName, | ||
106 | + url: fileStaticUri, | ||
107 | + } as FileItem; | ||
108 | + } catch (error) { | ||
109 | + return {}; | ||
110 | + } | ||
111 | + }, | ||
112 | + // showUploadList: true, | ||
113 | + onDownload() {}, | ||
114 | + onPreview: (fileList: FileItem) => { | ||
115 | + createImgPreview({ imageList: [fileList.url!] }); | ||
116 | + }, | ||
117 | + onDelete(url: string) { | ||
118 | + formModel.deleteIconUrl = url!; | ||
119 | + }, | ||
120 | + }; | ||
44 | }, | 121 | }, |
45 | - slot: 'iconUpload', | ||
46 | }, | 122 | }, |
47 | { | 123 | { |
48 | - field: 'background', | 124 | + field: 'deleteIconUrl', |
125 | + label: '', | ||
49 | component: 'Input', | 126 | component: 'Input', |
127 | + show: false, | ||
128 | + }, | ||
129 | + { | ||
130 | + field: 'background', | ||
50 | label: '登录页背景图片', | 131 | label: '登录页背景图片', |
51 | - colProps: { | ||
52 | - span: 24, | 132 | + // component: 'Input', |
133 | + // colProps: { | ||
134 | + // span: 24, | ||
135 | + // }, | ||
136 | + // slot: 'bgUpload', | ||
137 | + helpMessage: ['支持.PNG、.JPG格式,建议尺寸为1920*1080px以上,大小不超过5M'], | ||
138 | + component: 'ApiUpload', | ||
139 | + changeEvent: 'update:fileList', | ||
140 | + valueField: 'fileList', | ||
141 | + componentProps: ({ formModel }) => { | ||
142 | + return { | ||
143 | + listType: 'picture-card', | ||
144 | + maxFileLimit: 1, | ||
145 | + accept: '.png,.jpg,.jpeg,.gif,.jfif', | ||
146 | + api: async (file: File) => { | ||
147 | + try { | ||
148 | + const formData = new FormData(); | ||
149 | + formData.set('file', file); | ||
150 | + const { fileStaticUri, fileName } = await uploadThumbnail(formData); | ||
151 | + return { | ||
152 | + uid: fileStaticUri, | ||
153 | + name: fileName, | ||
154 | + url: fileStaticUri, | ||
155 | + } as FileItem; | ||
156 | + } catch (error) { | ||
157 | + return {}; | ||
158 | + } | ||
159 | + }, | ||
160 | + // showUploadList: true, | ||
161 | + onDownload() {}, | ||
162 | + onPreview: (fileList: FileItem) => { | ||
163 | + createImgPreview({ imageList: [fileList.url!] }); | ||
164 | + }, | ||
165 | + onDelete(url: string) { | ||
166 | + formModel.deleteBackgroundUrl = url!; | ||
167 | + }, | ||
168 | + }; | ||
53 | }, | 169 | }, |
54 | - slot: 'bgUpload', | 170 | + }, |
171 | + { | ||
172 | + field: 'deleteBackgroundUrl', | ||
173 | + label: '', | ||
174 | + component: 'Input', | ||
175 | + show: false, | ||
55 | }, | 176 | }, |
56 | { | 177 | { |
57 | field: 'backgroundColor', | 178 | field: 'backgroundColor', |
1 | import type { FormSchema } from '/@/components/Form/index'; | 1 | import type { FormSchema } from '/@/components/Form/index'; |
2 | import { getAreaList } from '/@/api/oem/index'; | 2 | import { getAreaList } from '/@/api/oem/index'; |
3 | import { emailRule, phoneRule } from '/@/utils/rules'; | 3 | import { emailRule, phoneRule } from '/@/utils/rules'; |
4 | +import { uploadThumbnail } from '/@/api/configuration/center/configurationCenter'; | ||
5 | +import { FileItem } from '../types'; | ||
6 | +import { createImgPreview } from '/@/components/Preview'; | ||
4 | 7 | ||
5 | export enum Level { | 8 | export enum Level { |
6 | PROVINCE = 'PROVINCE', | 9 | PROVINCE = 'PROVINCE', |
@@ -179,14 +182,53 @@ export const schemas: FormSchema[] = [ | @@ -179,14 +182,53 @@ export const schemas: FormSchema[] = [ | ||
179 | rules: phoneRule, | 182 | rules: phoneRule, |
180 | }, | 183 | }, |
181 | { | 184 | { |
182 | - field: 'qrcode', | 185 | + field: 'qrCode', |
183 | label: '联系我们', | 186 | label: '联系我们', |
184 | required: true, | 187 | required: true, |
185 | - component: 'Select', | 188 | + // component: 'Select', |
189 | + // slot: 'qrcode', | ||
190 | + component: 'ApiUpload', | ||
191 | + changeEvent: 'update:fileList', | ||
192 | + valueField: 'fileList', | ||
186 | colProps: { | 193 | colProps: { |
187 | span: 24, | 194 | span: 24, |
188 | }, | 195 | }, |
189 | - slot: 'qrcode', | 196 | + helpMessage: ['支持.PNG、.JPG格式,建议尺寸为300*300px,大小不超过5M '], |
197 | + componentProps: ({ formModel }) => { | ||
198 | + return { | ||
199 | + listType: 'picture-card', | ||
200 | + maxFileLimit: 1, | ||
201 | + accept: '.png,.jpg,.jpeg,.gif', | ||
202 | + api: async (file: File) => { | ||
203 | + try { | ||
204 | + const formData = new FormData(); | ||
205 | + formData.set('file', file); | ||
206 | + const { fileStaticUri, fileName } = await uploadThumbnail(formData); | ||
207 | + return { | ||
208 | + uid: fileStaticUri, | ||
209 | + name: fileName, | ||
210 | + url: fileStaticUri, | ||
211 | + } as FileItem; | ||
212 | + } catch (error) { | ||
213 | + return {}; | ||
214 | + } | ||
215 | + }, | ||
216 | + // showUploadList: true, | ||
217 | + onDownload() {}, | ||
218 | + onPreview: (fileList: FileItem) => { | ||
219 | + createImgPreview({ imageList: [fileList.url!] }); | ||
220 | + }, | ||
221 | + onDelete(url: string) { | ||
222 | + formModel.deleteUrl = url!; | ||
223 | + }, | ||
224 | + }; | ||
225 | + }, | ||
226 | + }, | ||
227 | + { | ||
228 | + field: 'deleteUrl', | ||
229 | + label: '', | ||
230 | + component: 'Input', | ||
231 | + show: false, | ||
190 | }, | 232 | }, |
191 | { | 233 | { |
192 | field: 'id', | 234 | field: 'id', |
@@ -3,7 +3,7 @@ | @@ -3,7 +3,7 @@ | ||
3 | <Card :bordered="false" class="card"> | 3 | <Card :bordered="false" class="card"> |
4 | <div style="margin-left: -40px"> | 4 | <div style="margin-left: -40px"> |
5 | <BasicForm @register="registerForm"> | 5 | <BasicForm @register="registerForm"> |
6 | - <template #logoUpload> | 6 | + <!-- <template #logoUpload> |
7 | <ContentUploadText> | 7 | <ContentUploadText> |
8 | <template #uploadImg> | 8 | <template #uploadImg> |
9 | <CustomUploadComp :imgUrl="logoPic" @setImg="handleSetLogoImgUrl" /> | 9 | <CustomUploadComp :imgUrl="logoPic" @setImg="handleSetLogoImgUrl" /> |
@@ -24,7 +24,7 @@ | @@ -24,7 +24,7 @@ | ||
24 | </div> | 24 | </div> |
25 | </template> | 25 | </template> |
26 | </ContentUploadText> | 26 | </ContentUploadText> |
27 | - </template> | 27 | + </template> --> |
28 | <template #colorInput="{ model, field }" | 28 | <template #colorInput="{ model, field }" |
29 | ><Input disabled v-model:value="model[field]"> | 29 | ><Input disabled v-model:value="model[field]"> |
30 | <template #prefix> <input type="color" v-model="model[field]" /> </template | 30 | <template #prefix> <input type="color" v-model="model[field]" /> </template |
@@ -41,6 +41,7 @@ | @@ -41,6 +41,7 @@ | ||
41 | :customRequest="customUploadHomeSwiper" | 41 | :customRequest="customUploadHomeSwiper" |
42 | :before-upload="beforeUploadHomeSwiper" | 42 | :before-upload="beforeUploadHomeSwiper" |
43 | @change="handleChange" | 43 | @change="handleChange" |
44 | + :remove="handleRemove" | ||
44 | > | 45 | > |
45 | <div v-if="fileList.length < 5"> | 46 | <div v-if="fileList.length < 5"> |
46 | <div> | 47 | <div> |
@@ -74,7 +75,7 @@ | @@ -74,7 +75,7 @@ | ||
74 | </template> | 75 | </template> |
75 | 76 | ||
76 | <script lang="ts"> | 77 | <script lang="ts"> |
77 | - import { defineComponent, ref, unref, onMounted } from 'vue'; | 78 | + import { defineComponent, ref, onMounted, unref } from 'vue'; |
78 | import { BasicForm, useForm } from '/@/components/Form/index'; | 79 | import { BasicForm, useForm } from '/@/components/Form/index'; |
79 | import { Loading } from '/@/components/Loading/index'; | 80 | import { Loading } from '/@/components/Loading/index'; |
80 | import { Card, Upload, Input, Modal } from 'ant-design-vue'; | 81 | import { Card, Upload, Input, Modal } from 'ant-design-vue'; |
@@ -86,7 +87,9 @@ | @@ -86,7 +87,9 @@ | ||
86 | import { getAppDesign, updateAppDesign } from '/@/api/oem/index'; | 87 | import { getAppDesign, updateAppDesign } from '/@/api/oem/index'; |
87 | import { Authority } from '/@/components/Authority'; | 88 | import { Authority } from '/@/components/Authority'; |
88 | import ContentUploadText from './ContentUploadText.vue'; | 89 | import ContentUploadText from './ContentUploadText.vue'; |
89 | - import { CustomUploadComp } from './customUplaod/index'; | 90 | + // import { CustomUploadComp } from './customUplaod/index'; |
91 | + import { buildUUID } from '/@/utils/uuid'; | ||
92 | + import { deleteFilePath } from '/@/api/oss/ossFileUploader'; | ||
90 | 93 | ||
91 | export default defineComponent({ | 94 | export default defineComponent({ |
92 | components: { | 95 | components: { |
@@ -99,7 +102,7 @@ | @@ -99,7 +102,7 @@ | ||
99 | Modal, | 102 | Modal, |
100 | Authority, | 103 | Authority, |
101 | ContentUploadText, | 104 | ContentUploadText, |
102 | - CustomUploadComp, | 105 | + // CustomUploadComp, |
103 | }, | 106 | }, |
104 | setup() { | 107 | setup() { |
105 | const loading = ref(false); | 108 | const loading = ref(false); |
@@ -193,19 +196,42 @@ | @@ -193,19 +196,42 @@ | ||
193 | } | 196 | } |
194 | }; | 197 | }; |
195 | 198 | ||
199 | + const deleteHomeUrl = ref<any[]>([]); | ||
200 | + const handleRemove = (file: FileItem) => { | ||
201 | + deleteHomeUrl.value.push(file.url); | ||
202 | + }; | ||
203 | + | ||
196 | const handleUpdateInfo = async () => { | 204 | const handleUpdateInfo = async () => { |
197 | try { | 205 | try { |
198 | const fieldValue = getFieldsValue(); | 206 | const fieldValue = getFieldsValue(); |
207 | + if (Reflect.has(fieldValue, 'logo')) { | ||
208 | + const file = (fieldValue.logo || []).at(0) || {}; | ||
209 | + fieldValue.logo = file.url || ''; | ||
210 | + } | ||
211 | + if (Reflect.has(fieldValue, 'background')) { | ||
212 | + const file = (fieldValue.background || []).at(0) || {}; | ||
213 | + fieldValue.background = file.url || ''; | ||
214 | + } | ||
199 | // 做换字段 | 215 | // 做换字段 |
200 | const homeSwiper = fileList.value.map((item) => item.url); | 216 | const homeSwiper = fileList.value.map((item) => item.url); |
201 | const rotation = homeSwiper.join(','); | 217 | const rotation = homeSwiper.join(','); |
202 | 218 | ||
203 | compState.value.loading = true; | 219 | compState.value.loading = true; |
220 | + if (Reflect.has(fieldValue, 'deleteLogoUrl')) { | ||
221 | + await deleteFilePath(fieldValue?.deleteLogoUrl); | ||
222 | + Reflect.deleteProperty(fieldValue, 'deleteLogoUrl'); | ||
223 | + } | ||
224 | + if (Reflect.has(fieldValue, 'deleteBackgroundUrl')) { | ||
225 | + await deleteFilePath(fieldValue?.deleteBackgroundUrl); | ||
226 | + Reflect.deleteProperty(fieldValue, 'deleteBackgroundUrl'); | ||
227 | + } | ||
228 | + if (unref(deleteHomeUrl)?.length) { | ||
229 | + await Promise.all(unref(deleteHomeUrl).map((item) => deleteFilePath(item))); | ||
230 | + } | ||
204 | await updateAppDesign({ | 231 | await updateAppDesign({ |
205 | ...fieldValue, | 232 | ...fieldValue, |
206 | - background: unref(bgPic), | ||
207 | - icon: unref(bgPic), | ||
208 | - logo: unref(logoPic), | 233 | + background: fieldValue.background || '', |
234 | + logo: fieldValue.logo || '', | ||
209 | rotation, | 235 | rotation, |
210 | }); | 236 | }); |
211 | compState.value.loading = false; | 237 | compState.value.loading = false; |
@@ -227,9 +253,15 @@ | @@ -227,9 +253,15 @@ | ||
227 | status: 'done', | 253 | status: 'done', |
228 | }); | 254 | }); |
229 | } | 255 | } |
256 | + if (res.logo) { | ||
257 | + res.logo = [{ uid: buildUUID(), name: 'name', url: res.logo } as FileItem]; | ||
258 | + } | ||
259 | + if (res.background) { | ||
260 | + res.background = [{ uid: buildUUID(), name: 'name', url: res.background } as FileItem]; | ||
261 | + } | ||
230 | setFieldsValue(res); | 262 | setFieldsValue(res); |
231 | - logoPic.value = res.logo; | ||
232 | - bgPic.value = res.background; | 263 | + // logoPic.value = res.logo; |
264 | + // bgPic.value = res.background; | ||
233 | if (arr[0]?.url === '') return; | 265 | if (arr[0]?.url === '') return; |
234 | fileList.value = arr; | 266 | fileList.value = arr; |
235 | }); | 267 | }); |
@@ -252,8 +284,8 @@ | @@ -252,8 +284,8 @@ | ||
252 | }); | 284 | }); |
253 | } | 285 | } |
254 | setFieldsValue(res); | 286 | setFieldsValue(res); |
255 | - logoPic.value = res.logo; | ||
256 | - bgPic.value = res.background; | 287 | + // logoPic.value = res.logo; |
288 | + // bgPic.value = res.background; | ||
257 | if (arr[0]?.url === '') return; | 289 | if (arr[0]?.url === '') return; |
258 | fileList.value = arr; | 290 | fileList.value = arr; |
259 | } catch (e) { | 291 | } catch (e) { |
@@ -271,8 +303,8 @@ | @@ -271,8 +303,8 @@ | ||
271 | customUploadHomeSwiper, | 303 | customUploadHomeSwiper, |
272 | beforeUploadHomeSwiper, | 304 | beforeUploadHomeSwiper, |
273 | handleChange, | 305 | handleChange, |
274 | - logoPic, | ||
275 | - bgPic, | 306 | + // logoPic, |
307 | + // bgPic, | ||
276 | previewVisible, | 308 | previewVisible, |
277 | previewImage, | 309 | previewImage, |
278 | loading, | 310 | loading, |
@@ -280,6 +312,7 @@ | @@ -280,6 +312,7 @@ | ||
280 | handleResetInfo, | 312 | handleResetInfo, |
281 | handleSetBgImgUrl, | 313 | handleSetBgImgUrl, |
282 | handleSetLogoImgUrl, | 314 | handleSetLogoImgUrl, |
315 | + handleRemove, | ||
283 | }; | 316 | }; |
284 | }, | 317 | }, |
285 | }); | 318 | }); |
@@ -74,13 +74,13 @@ | @@ -74,13 +74,13 @@ | ||
74 | </template> | 74 | </template> |
75 | 75 | ||
76 | <script lang="ts"> | 76 | <script lang="ts"> |
77 | - import { defineComponent, ref, onMounted, unref } from 'vue'; | 77 | + import { defineComponent, ref, onMounted } from 'vue'; |
78 | import { Card, Upload, Input, Spin } from 'ant-design-vue'; | 78 | import { Card, Upload, Input, Spin } from 'ant-design-vue'; |
79 | import { BasicForm, useForm } from '/@/components/Form/index'; | 79 | import { BasicForm, useForm } from '/@/components/Form/index'; |
80 | import { schemas } from '../config/CVIDraw.config'; | 80 | import { schemas } from '../config/CVIDraw.config'; |
81 | import { Loading } from '/@/components/Loading/index'; | 81 | import { Loading } from '/@/components/Loading/index'; |
82 | import { useMessage } from '/@/hooks/web/useMessage'; | 82 | import { useMessage } from '/@/hooks/web/useMessage'; |
83 | - import type { FileItem } from '/@/components/Upload/src/typing'; | 83 | + // import type { FileItem } from '/@/components/Upload/src/typing'; |
84 | import { iconUpload, getPlatForm, updatePlatForm, resetPlateInfo } from '/@/api/oem/index'; | 84 | import { iconUpload, getPlatForm, updatePlatForm, resetPlateInfo } from '/@/api/oem/index'; |
85 | import { PlusOutlined, CloseCircleOutlined } from '@ant-design/icons-vue'; | 85 | import { PlusOutlined, CloseCircleOutlined } from '@ant-design/icons-vue'; |
86 | import { useUserStore } from '/@/store/modules/user'; | 86 | import { useUserStore } from '/@/store/modules/user'; |
@@ -88,6 +88,9 @@ | @@ -88,6 +88,9 @@ | ||
88 | import { Authority } from '/@/components/Authority'; | 88 | import { Authority } from '/@/components/Authority'; |
89 | import ContentUploadText from './ContentUploadText.vue'; | 89 | import ContentUploadText from './ContentUploadText.vue'; |
90 | import { CustomUploadComp } from './customUplaod/index'; | 90 | import { CustomUploadComp } from './customUplaod/index'; |
91 | + import { buildUUID } from '/@/utils/uuid'; | ||
92 | + import { FileItem } from '../types'; | ||
93 | + import { deleteFilePath } from '/@/api/oss/ossFileUploader'; | ||
91 | 94 | ||
92 | export default defineComponent({ | 95 | export default defineComponent({ |
93 | components: { | 96 | components: { |
@@ -166,18 +169,42 @@ | @@ -166,18 +169,42 @@ | ||
166 | const handleUpdateInfo = async () => { | 169 | const handleUpdateInfo = async () => { |
167 | try { | 170 | try { |
168 | const fieldValue = getFieldsValue(); | 171 | const fieldValue = getFieldsValue(); |
172 | + if (Reflect.has(fieldValue, 'logo')) { | ||
173 | + const file = (fieldValue.logo || []).at(0) || {}; | ||
174 | + fieldValue.logo = file.url || null; | ||
175 | + } | ||
176 | + if (Reflect.has(fieldValue, 'icon')) { | ||
177 | + const file = (fieldValue.icon || []).at(0) || {}; | ||
178 | + fieldValue.icon = file.url || null; | ||
179 | + } | ||
180 | + if (Reflect.has(fieldValue, 'background')) { | ||
181 | + const file = (fieldValue.background || []).at(0) || {}; | ||
182 | + fieldValue.background = file.url || null; | ||
183 | + } | ||
169 | compState.value.loading = true; | 184 | compState.value.loading = true; |
170 | - const newFieldValue = { | 185 | + if (Reflect.has(fieldValue, 'deleteLogoUrl')) { |
186 | + await deleteFilePath(fieldValue?.deleteLogoUrl); | ||
187 | + Reflect.deleteProperty(fieldValue, 'deleteLogoUrl'); | ||
188 | + } | ||
189 | + if (Reflect.has(fieldValue, 'deleteIconUrl')) { | ||
190 | + await deleteFilePath(fieldValue?.deleteIconUrl); | ||
191 | + Reflect.deleteProperty(fieldValue, 'deleteIconUrl'); | ||
192 | + } | ||
193 | + if (Reflect.has(fieldValue, 'deleteBackgroundUrl')) { | ||
194 | + await deleteFilePath(fieldValue?.deleteBackgroundUrl); | ||
195 | + Reflect.deleteProperty(fieldValue, 'deleteBackgroundUrl'); | ||
196 | + } | ||
197 | + | ||
198 | + await updatePlatForm({ | ||
171 | ...fieldValue, | 199 | ...fieldValue, |
172 | - logo: unref(logoPic), | ||
173 | - icon: unref(iconPic), | ||
174 | - background: unref(bgPic), | ||
175 | - }; | ||
176 | - await updatePlatForm(newFieldValue); | 200 | + logo: fieldValue.logo || '', |
201 | + icon: fieldValue.icon || '', | ||
202 | + background: fieldValue.background || '', | ||
203 | + }); | ||
177 | compState.value.loading = false; | 204 | compState.value.loading = false; |
178 | createMessage.success('保存信息成功'); | 205 | createMessage.success('保存信息成功'); |
179 | 206 | ||
180 | - setPlatFormInfo(newFieldValue); | 207 | + setPlatFormInfo(fieldValue); |
181 | } catch (e) { | 208 | } catch (e) { |
182 | createMessage.error('保存信息失败'); | 209 | createMessage.error('保存信息失败'); |
183 | } | 210 | } |
@@ -197,6 +224,15 @@ | @@ -197,6 +224,15 @@ | ||
197 | 224 | ||
198 | onMounted(async () => { | 225 | onMounted(async () => { |
199 | const res = await getPlatForm(); | 226 | const res = await getPlatForm(); |
227 | + if (res.logo) { | ||
228 | + res.logo = [{ uid: buildUUID(), name: 'name', url: res.logo }] as any; | ||
229 | + } | ||
230 | + if (res.icon) { | ||
231 | + res.icon = [{ uid: buildUUID(), name: 'name', url: res.icon }] as any; | ||
232 | + } | ||
233 | + if (res.background) { | ||
234 | + res.background = [{ uid: buildUUID(), name: 'name', url: res.background }] as any; | ||
235 | + } | ||
200 | setFieldsValue(res); | 236 | setFieldsValue(res); |
201 | logoPic.value = res.logo; | 237 | logoPic.value = res.logo; |
202 | iconPic.value = res.icon; | 238 | iconPic.value = res.icon; |
@@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
2 | <div class="card"> | 2 | <div class="card"> |
3 | <Card :bordered="false" class="card"> | 3 | <Card :bordered="false" class="card"> |
4 | <BasicForm @register="registerForm"> | 4 | <BasicForm @register="registerForm"> |
5 | - <template #qrcode> | 5 | + <!-- <template #qrcode> |
6 | <ContentUploadText> | 6 | <ContentUploadText> |
7 | <template #uploadImg> | 7 | <template #uploadImg> |
8 | <CustomUploadComp :imgUrl="qrcodePic" @setImg="handleSetCodeImgUrl" /> | 8 | <CustomUploadComp :imgUrl="qrcodePic" @setImg="handleSetCodeImgUrl" /> |
@@ -11,7 +11,7 @@ | @@ -11,7 +11,7 @@ | ||
11 | <div class="box-outline"> 支持.PNG、.JPG格式,建议尺寸为300*300px,大小不超过5M </div> | 11 | <div class="box-outline"> 支持.PNG、.JPG格式,建议尺寸为300*300px,大小不超过5M </div> |
12 | </template> | 12 | </template> |
13 | </ContentUploadText> | 13 | </ContentUploadText> |
14 | - </template> | 14 | + </template> --> |
15 | <template #customProv> | 15 | <template #customProv> |
16 | <BasicForm @register="registerCustomForm" /> | 16 | <BasicForm @register="registerCustomForm" /> |
17 | </template> | 17 | </template> |
@@ -31,7 +31,7 @@ | @@ -31,7 +31,7 @@ | ||
31 | </template> | 31 | </template> |
32 | 32 | ||
33 | <script lang="ts"> | 33 | <script lang="ts"> |
34 | - import { defineComponent, onMounted, ref, computed, watch } from 'vue'; | 34 | + import { defineComponent, onMounted, ref, computed } from 'vue'; |
35 | import { Card } from 'ant-design-vue'; | 35 | import { Card } from 'ant-design-vue'; |
36 | import { BasicForm, useForm } from '/@/components/Form/index'; | 36 | import { BasicForm, useForm } from '/@/components/Form/index'; |
37 | import { schemas, provSchemas } from '../config/enterPriseInfo.config'; | 37 | import { schemas, provSchemas } from '../config/enterPriseInfo.config'; |
@@ -43,8 +43,11 @@ | @@ -43,8 +43,11 @@ | ||
43 | import { Authority } from '/@/components/Authority'; | 43 | import { Authority } from '/@/components/Authority'; |
44 | import { USER_INFO_KEY } from '/@/enums/cacheEnum'; | 44 | import { USER_INFO_KEY } from '/@/enums/cacheEnum'; |
45 | import { getAuthCache } from '/@/utils/auth'; | 45 | import { getAuthCache } from '/@/utils/auth'; |
46 | - import ContentUploadText from './ContentUploadText.vue'; | ||
47 | - import { CustomUploadComp } from './customUplaod/index'; | 46 | + // import ContentUploadText from './ContentUploadText.vue'; |
47 | + // import { CustomUploadComp } from './customUplaod/index'; | ||
48 | + import { buildUUID } from '/@/utils/uuid'; | ||
49 | + import { FileItem } from '../types'; | ||
50 | + import { deleteFilePath } from '/@/api/oss/ossFileUploader'; | ||
48 | 51 | ||
49 | export default defineComponent({ | 52 | export default defineComponent({ |
50 | components: { | 53 | components: { |
@@ -52,8 +55,8 @@ | @@ -52,8 +55,8 @@ | ||
52 | BasicForm, | 55 | BasicForm, |
53 | Loading, | 56 | Loading, |
54 | Authority, | 57 | Authority, |
55 | - ContentUploadText, | ||
56 | - CustomUploadComp, | 58 | + // ContentUploadText, |
59 | + // CustomUploadComp, | ||
57 | }, | 60 | }, |
58 | setup() { | 61 | setup() { |
59 | const userInfo: any = getAuthCache(USER_INFO_KEY); | 62 | const userInfo: any = getAuthCache(USER_INFO_KEY); |
@@ -73,11 +76,8 @@ | @@ -73,11 +76,8 @@ | ||
73 | loading: false, | 76 | loading: false, |
74 | tip: '拼命加载中...', | 77 | tip: '拼命加载中...', |
75 | }); | 78 | }); |
76 | - const [ | ||
77 | - registerForm, | ||
78 | - { getFieldsValue, setFieldsValue, validate, clearValidate, validateFields }, | ||
79 | - ] = useForm({ | ||
80 | - labelWidth: 80, | 79 | + const [registerForm, { getFieldsValue, setFieldsValue, validate, clearValidate }] = useForm({ |
80 | + labelWidth: 90, | ||
81 | schemas, | 81 | schemas, |
82 | showResetButton: false, | 82 | showResetButton: false, |
83 | showSubmitButton: false, | 83 | showSubmitButton: false, |
@@ -100,26 +100,30 @@ | @@ -100,26 +100,30 @@ | ||
100 | 100 | ||
101 | const { createMessage } = useMessage(); | 101 | const { createMessage } = useMessage(); |
102 | 102 | ||
103 | - const qrcodePic = ref(); | ||
104 | - const handleSetCodeImgUrl = (d) => { | ||
105 | - qrcodePic.value = d; | ||
106 | - }; | ||
107 | - watch( | ||
108 | - () => qrcodePic.value, | ||
109 | - (newValue) => { | ||
110 | - if (!newValue) validateFields(['qrcode']); | ||
111 | - else clearValidate('qrcode'); | ||
112 | - } | ||
113 | - ); | 103 | + // const qrcodePic = ref(); |
104 | + // const handleSetCodeImgUrl = (d) => { | ||
105 | + // qrcodePic.value = d; | ||
106 | + // }; | ||
107 | + // watch( | ||
108 | + // () => qrcodePic.value, | ||
109 | + // (newValue) => { | ||
110 | + // if (!newValue) validateFields(['qrcode']); | ||
111 | + // else clearValidate('qrcode'); | ||
112 | + // } | ||
113 | + // ); | ||
114 | // 更新 | 114 | // 更新 |
115 | const handleUpdateInfo = async () => { | 115 | const handleUpdateInfo = async () => { |
116 | try { | 116 | try { |
117 | const fieldsValue = getFieldsValue(); | 117 | const fieldsValue = getFieldsValue(); |
118 | const { nameTown } = getNameTown(); | 118 | const { nameTown } = getNameTown(); |
119 | + if (Reflect.has(fieldsValue, 'qrCode')) { | ||
120 | + const file = (fieldsValue.qrCode || []).at(0) || {}; | ||
121 | + fieldsValue.qrCode = file.url || null; | ||
122 | + } | ||
119 | const newFieldValue: any = { | 123 | const newFieldValue: any = { |
120 | ...fieldsValue, | 124 | ...fieldsValue, |
121 | codeTown: nameTown, | 125 | codeTown: nameTown, |
122 | - qrCode: qrcodePic.value, | 126 | + // qrCode: qrcodePic.value, |
123 | }; | 127 | }; |
124 | delete newFieldValue.nameProv; | 128 | delete newFieldValue.nameProv; |
125 | delete newFieldValue.nameCity; | 129 | delete newFieldValue.nameCity; |
@@ -139,9 +143,9 @@ | @@ -139,9 +143,9 @@ | ||
139 | 'id', | 143 | 'id', |
140 | ]; | 144 | ]; |
141 | if (newFieldValue.qrCode == undefined || newFieldValue.qrCode == '') { | 145 | if (newFieldValue.qrCode == undefined || newFieldValue.qrCode == '') { |
142 | - validateArray.push('qrcode'); | 146 | + validateArray.push('qrCode'); |
143 | } else { | 147 | } else { |
144 | - const findExistIndex = validateArray.findIndex((o) => o == 'qrcode'); | 148 | + const findExistIndex = validateArray.findIndex((o) => o == 'qrCode'); |
145 | if (findExistIndex !== -1) { | 149 | if (findExistIndex !== -1) { |
146 | validateArray.splice(findExistIndex, 1); | 150 | validateArray.splice(findExistIndex, 1); |
147 | } | 151 | } |
@@ -158,6 +162,10 @@ | @@ -158,6 +162,10 @@ | ||
158 | const values = await validate(validateArray); | 162 | const values = await validate(validateArray); |
159 | if (!values) return; | 163 | if (!values) return; |
160 | compState.value.loading = true; | 164 | compState.value.loading = true; |
165 | + if (Reflect.has(newFieldValue, 'deleteUrl')) { | ||
166 | + await deleteFilePath(newFieldValue?.deleteUrl); | ||
167 | + Reflect.deleteProperty(newFieldValue, 'deleteUrl'); | ||
168 | + } | ||
161 | await updateEnterPriseDetail(newFieldValue); | 169 | await updateEnterPriseDetail(newFieldValue); |
162 | createMessage.success('更新信息成功'); | 170 | createMessage.success('更新信息成功'); |
163 | setEnterPriseInfo(newFieldValue); | 171 | setEnterPriseInfo(newFieldValue); |
@@ -189,19 +197,22 @@ | @@ -189,19 +197,22 @@ | ||
189 | }); | 197 | }); |
190 | setFieldsValue({ nameCountry: codeCountry }); | 198 | setFieldsValue({ nameCountry: codeCountry }); |
191 | } | 199 | } |
192 | - setFieldsValue(res); | ||
193 | - qrcodePic.value = res.qrCode; | 200 | + if (res.qrCode) { |
201 | + res.qrCode = [{ uid: buildUUID(), name: 'name', url: res.qrCode } as FileItem]; | ||
202 | + } | ||
203 | + setFieldsValue({ ...res, qrcode: res.qrCode }); | ||
204 | + // qrcodePic.value = res.qrCode; | ||
194 | }); | 205 | }); |
195 | 206 | ||
196 | return { | 207 | return { |
197 | registerForm, | 208 | registerForm, |
198 | compState, | 209 | compState, |
199 | - qrcodePic, | ||
200 | handleUpdateInfo, | 210 | handleUpdateInfo, |
201 | registerCustomForm, | 211 | registerCustomForm, |
202 | loading, | 212 | loading, |
203 | isWhereAdmin, | 213 | isWhereAdmin, |
204 | - handleSetCodeImgUrl, | 214 | + // qrcodePic, |
215 | + // handleSetCodeImgUrl, | ||
205 | }; | 216 | }; |
206 | }, | 217 | }, |
207 | }); | 218 | }); |
@@ -20,6 +20,7 @@ | @@ -20,6 +20,7 @@ | ||
20 | import { useMessage } from '/@/hooks/web/useMessage'; | 20 | import { useMessage } from '/@/hooks/web/useMessage'; |
21 | import { FileItem } from '/@/components/Form/src/components/ApiUpload.vue'; | 21 | import { FileItem } from '/@/components/Form/src/components/ApiUpload.vue'; |
22 | import { buildUUID } from '/@/utils/uuid'; | 22 | import { buildUUID } from '/@/utils/uuid'; |
23 | + import { deleteFilePath } from '/@/api/oss/ossFileUploader'; | ||
23 | 24 | ||
24 | export default defineComponent({ | 25 | export default defineComponent({ |
25 | name: 'TenantDrawer', | 26 | name: 'TenantDrawer', |
@@ -102,6 +103,10 @@ | @@ -102,6 +103,10 @@ | ||
102 | entityType: 'TENANT_PROFILE', | 103 | entityType: 'TENANT_PROFILE', |
103 | }, | 104 | }, |
104 | }; | 105 | }; |
106 | + if (Reflect.has(values, 'deleteUrl')) { | ||
107 | + await deleteFilePath(values?.deleteUrl); | ||
108 | + Reflect.deleteProperty(values, 'deleteUrl'); | ||
109 | + } | ||
105 | await updateOrCreateTenant(req); | 110 | await updateOrCreateTenant(req); |
106 | emit('success'); | 111 | emit('success'); |
107 | createMessage.success(`${unref(isUpdate) ? '编辑' : '新增'}成功`); | 112 | createMessage.success(`${unref(isUpdate) ? '编辑' : '新增'}成功`); |
@@ -83,7 +83,7 @@ export const tenantFormSchema: FormSchema[] = [ | @@ -83,7 +83,7 @@ export const tenantFormSchema: FormSchema[] = [ | ||
83 | component: 'ApiUpload', | 83 | component: 'ApiUpload', |
84 | changeEvent: 'update:fileList', | 84 | changeEvent: 'update:fileList', |
85 | valueField: 'fileList', | 85 | valueField: 'fileList', |
86 | - componentProps: () => { | 86 | + componentProps: ({ formModel }) => { |
87 | return { | 87 | return { |
88 | listType: 'picture-card', | 88 | listType: 'picture-card', |
89 | maxFileLimit: 1, | 89 | maxFileLimit: 1, |
@@ -105,10 +105,19 @@ export const tenantFormSchema: FormSchema[] = [ | @@ -105,10 +105,19 @@ export const tenantFormSchema: FormSchema[] = [ | ||
105 | onPreview: (fileList: FileItem) => { | 105 | onPreview: (fileList: FileItem) => { |
106 | createImgPreview({ imageList: [fileList.url!] }); | 106 | createImgPreview({ imageList: [fileList.url!] }); |
107 | }, | 107 | }, |
108 | + onDelete(url: string) { | ||
109 | + formModel.deleteUrl = url!; | ||
110 | + }, | ||
108 | }; | 111 | }; |
109 | }, | 112 | }, |
110 | }, | 113 | }, |
111 | { | 114 | { |
115 | + field: 'deleteUrl', | ||
116 | + label: '', | ||
117 | + component: 'Input', | ||
118 | + show: false, | ||
119 | + }, | ||
120 | + { | ||
112 | field: 'name', | 121 | field: 'name', |
113 | label: '租户名称', | 122 | label: '租户名称', |
114 | required: true, | 123 | required: true, |