Showing
2 changed files
with
65 additions
and
5 deletions
@@ -87,6 +87,9 @@ | @@ -87,6 +87,9 @@ | ||
87 | <Authority value="api:yt:appDesign:update:update"> | 87 | <Authority value="api:yt:appDesign:update:update"> |
88 | <a-button @click="handleUpdateInfo" type="primary" class="mt-4">保存信息</a-button> | 88 | <a-button @click="handleUpdateInfo" type="primary" class="mt-4">保存信息</a-button> |
89 | </Authority> | 89 | </Authority> |
90 | + <Authority value="api:yt:appDesign:data_reset:reset"> | ||
91 | + <a-button @click="handleResetInfo" type="primary" class="ml-4">恢复默认设置</a-button> | ||
92 | + </Authority> | ||
90 | </div> | 93 | </div> |
91 | </template> | 94 | </template> |
92 | 95 | ||
@@ -98,7 +101,7 @@ | @@ -98,7 +101,7 @@ | ||
98 | import { PlusOutlined, LoadingOutlined } from '@ant-design/icons-vue'; | 101 | import { PlusOutlined, LoadingOutlined } from '@ant-design/icons-vue'; |
99 | import { schemas } from '../config/AppDraw.config'; | 102 | import { schemas } from '../config/AppDraw.config'; |
100 | import { FileItem, FileInfo } from '../types/index'; | 103 | import { FileItem, FileInfo } from '../types/index'; |
101 | - import { logoUpload, bgUpload } from '/@/api/oem/index'; | 104 | + import { logoUpload, bgUpload, resetAppInfo } from '/@/api/oem/index'; |
102 | import { useMessage } from '/@/hooks/web/useMessage'; | 105 | import { useMessage } from '/@/hooks/web/useMessage'; |
103 | import { getAppDesign, updateAppDesign } from '/@/api/oem/index'; | 106 | import { getAppDesign, updateAppDesign } from '/@/api/oem/index'; |
104 | import { Authority } from '/@/components/Authority'; | 107 | import { Authority } from '/@/components/Authority'; |
@@ -124,7 +127,7 @@ | @@ -124,7 +127,7 @@ | ||
124 | tip: '拼命加载中...', | 127 | tip: '拼命加载中...', |
125 | }); | 128 | }); |
126 | const { createMessage } = useMessage(); | 129 | const { createMessage } = useMessage(); |
127 | - const [registerForm, { getFieldsValue, setFieldsValue }] = useForm({ | 130 | + const [registerForm, { getFieldsValue, setFieldsValue, resetFields }] = useForm({ |
128 | schemas, | 131 | schemas, |
129 | showSubmitButton: false, | 132 | showSubmitButton: false, |
130 | showResetButton: false, | 133 | showResetButton: false, |
@@ -286,6 +289,34 @@ | @@ -286,6 +289,34 @@ | ||
286 | if (arr[0]?.url === '') return; | 289 | if (arr[0]?.url === '') return; |
287 | fileList.value = arr; | 290 | fileList.value = arr; |
288 | }); | 291 | }); |
292 | + const handleResetInfo = async () => { | ||
293 | + try { | ||
294 | + compState.value.loading = true; | ||
295 | + await resetAppInfo(); | ||
296 | + compState.value.loading = false; | ||
297 | + createMessage.success('恢复出厂设置成功'); | ||
298 | + resetFields(); | ||
299 | + const res = await getAppDesign(); | ||
300 | + const rotation = res.rotation ? res.rotation.split(',') : []; | ||
301 | + const arr: any[] = []; | ||
302 | + for (let item of rotation) { | ||
303 | + arr.push({ | ||
304 | + uid: -Math.random() + '', | ||
305 | + name: '111', | ||
306 | + url: item, | ||
307 | + status: 'done', | ||
308 | + }); | ||
309 | + } | ||
310 | + setFieldsValue(res); | ||
311 | + logoPic.value = res.logo; | ||
312 | + bgPic.value = res.background; | ||
313 | + if (arr[0]?.url === '') return; | ||
314 | + fileList.value = arr; | ||
315 | + } catch (e) { | ||
316 | + compState.value.loading = false; | ||
317 | + createMessage.error('恢复出厂设置失败'); | ||
318 | + } | ||
319 | + }; | ||
289 | return { | 320 | return { |
290 | compState, | 321 | compState, |
291 | fileList, | 322 | fileList, |
@@ -306,6 +337,7 @@ | @@ -306,6 +337,7 @@ | ||
306 | previewImage, | 337 | previewImage, |
307 | loading, | 338 | loading, |
308 | loading1, | 339 | loading1, |
340 | + handleResetInfo, | ||
309 | }; | 341 | }; |
310 | }, | 342 | }, |
311 | }); | 343 | }); |
@@ -89,6 +89,9 @@ | @@ -89,6 +89,9 @@ | ||
89 | <Authority value="api:yt:platform:update:update"> | 89 | <Authority value="api:yt:platform:update:update"> |
90 | <a-button @click="handleUpdateInfo" type="primary" class="mt-4">保存信息</a-button> | 90 | <a-button @click="handleUpdateInfo" type="primary" class="mt-4">保存信息</a-button> |
91 | </Authority> | 91 | </Authority> |
92 | + <Authority value="api:yt:platform:data_reset:reset"> | ||
93 | + <a-button @click="handleResetInfo" type="primary" class="ml-4">恢复默认设置</a-button> | ||
94 | + </Authority> | ||
92 | </div> | 95 | </div> |
93 | </template> | 96 | </template> |
94 | 97 | ||
@@ -100,7 +103,14 @@ | @@ -100,7 +103,14 @@ | ||
100 | import { Loading } from '/@/components/Loading/index'; | 103 | import { Loading } from '/@/components/Loading/index'; |
101 | import { useMessage } from '/@/hooks/web/useMessage'; | 104 | import { useMessage } from '/@/hooks/web/useMessage'; |
102 | import type { FileItem } from '/@/components/Upload/src/typing'; | 105 | import type { FileItem } from '/@/components/Upload/src/typing'; |
103 | - import { logoUpload, iconUpload, bgUpload, getPlatForm, updatePlatForm } from '/@/api/oem/index'; | 106 | + import { |
107 | + logoUpload, | ||
108 | + iconUpload, | ||
109 | + bgUpload, | ||
110 | + getPlatForm, | ||
111 | + updatePlatForm, | ||
112 | + resetPlateInfo, | ||
113 | + } from '/@/api/oem/index'; | ||
104 | import { PlusOutlined, LoadingOutlined } from '@ant-design/icons-vue'; | 114 | import { PlusOutlined, LoadingOutlined } from '@ant-design/icons-vue'; |
105 | import { useUserStore } from '/@/store/modules/user'; | 115 | import { useUserStore } from '/@/store/modules/user'; |
106 | import { createLocalStorage } from '/@/utils/cache/index'; | 116 | import { createLocalStorage } from '/@/utils/cache/index'; |
@@ -120,7 +130,7 @@ | @@ -120,7 +130,7 @@ | ||
120 | setup() { | 130 | setup() { |
121 | const loading = ref(false); | 131 | const loading = ref(false); |
122 | const loading1 = ref(false); | 132 | const loading1 = ref(false); |
123 | - const loading2= ref(false); | 133 | + const loading2 = ref(false); |
124 | const compState = ref({ | 134 | const compState = ref({ |
125 | absolute: false, | 135 | absolute: false, |
126 | loading: false, | 136 | loading: false, |
@@ -129,7 +139,7 @@ | @@ -129,7 +139,7 @@ | ||
129 | const { createMessage } = useMessage(); | 139 | const { createMessage } = useMessage(); |
130 | const userStore = useUserStore(); | 140 | const userStore = useUserStore(); |
131 | const storage = createLocalStorage(); | 141 | const storage = createLocalStorage(); |
132 | - const [registerForm, { getFieldsValue, setFieldsValue }] = useForm({ | 142 | + const [registerForm, { getFieldsValue, setFieldsValue, resetFields }] = useForm({ |
133 | schemas, | 143 | schemas, |
134 | showSubmitButton: false, | 144 | showSubmitButton: false, |
135 | showResetButton: false, | 145 | showResetButton: false, |
@@ -253,6 +263,23 @@ | @@ -253,6 +263,23 @@ | ||
253 | iconPic.value = res.icon; | 263 | iconPic.value = res.icon; |
254 | bgPic.value = res.background; | 264 | bgPic.value = res.background; |
255 | }); | 265 | }); |
266 | + const handleResetInfo = async () => { | ||
267 | + try { | ||
268 | + compState.value.loading = true; | ||
269 | + await resetPlateInfo(); | ||
270 | + compState.value.loading = false; | ||
271 | + createMessage.success('恢复出厂设置成功'); | ||
272 | + resetFields(); | ||
273 | + const res = await getPlatForm(); | ||
274 | + setFieldsValue(res); | ||
275 | + logoPic.value = res.logo; | ||
276 | + iconPic.value = res.icon; | ||
277 | + bgPic.value = res.background; | ||
278 | + } catch (e) { | ||
279 | + compState.value.loading = false; | ||
280 | + createMessage.error('恢复出厂设置失败'); | ||
281 | + } | ||
282 | + }; | ||
256 | return { | 283 | return { |
257 | registerForm, | 284 | registerForm, |
258 | logoPic, | 285 | logoPic, |
@@ -269,6 +296,7 @@ | @@ -269,6 +296,7 @@ | ||
269 | loading, | 296 | loading, |
270 | loading1, | 297 | loading1, |
271 | loading2, | 298 | loading2, |
299 | + handleResetInfo, | ||
272 | }; | 300 | }; |
273 | }, | 301 | }, |
274 | }); | 302 | }); |