Commit f6298fedf446d13b97929c98b0d1f14694d60e34

Authored by 张 峰林
Committed by xp.Huang
1 parent 4cafa320

fix: 图片删除时先调用接口

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