Commit 69bc11173f9034d600d8f7937c4a5203115219cf

Authored by fengtao
1 parent 50bc5aed

feat:平台定制新增重置

... ... @@ -87,6 +87,9 @@
87 87 <Authority value="api:yt:appDesign:update:update">
88 88 <a-button @click="handleUpdateInfo" type="primary" class="mt-4">保存信息</a-button>
89 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 93 </div>
91 94 </template>
92 95
... ... @@ -98,7 +101,7 @@
98 101 import { PlusOutlined, LoadingOutlined } from '@ant-design/icons-vue';
99 102 import { schemas } from '../config/AppDraw.config';
100 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 105 import { useMessage } from '/@/hooks/web/useMessage';
103 106 import { getAppDesign, updateAppDesign } from '/@/api/oem/index';
104 107 import { Authority } from '/@/components/Authority';
... ... @@ -124,7 +127,7 @@
124 127 tip: '拼命加载中...',
125 128 });
126 129 const { createMessage } = useMessage();
127   - const [registerForm, { getFieldsValue, setFieldsValue }] = useForm({
  130 + const [registerForm, { getFieldsValue, setFieldsValue, resetFields }] = useForm({
128 131 schemas,
129 132 showSubmitButton: false,
130 133 showResetButton: false,
... ... @@ -286,6 +289,34 @@
286 289 if (arr[0]?.url === '') return;
287 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 320 return {
290 321 compState,
291 322 fileList,
... ... @@ -306,6 +337,7 @@
306 337 previewImage,
307 338 loading,
308 339 loading1,
  340 + handleResetInfo,
309 341 };
310 342 },
311 343 });
... ...
... ... @@ -89,6 +89,9 @@
89 89 <Authority value="api:yt:platform:update:update">
90 90 <a-button @click="handleUpdateInfo" type="primary" class="mt-4">保存信息</a-button>
91 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 95 </div>
93 96 </template>
94 97
... ... @@ -100,7 +103,14 @@
100 103 import { Loading } from '/@/components/Loading/index';
101 104 import { useMessage } from '/@/hooks/web/useMessage';
102 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 114 import { PlusOutlined, LoadingOutlined } from '@ant-design/icons-vue';
105 115 import { useUserStore } from '/@/store/modules/user';
106 116 import { createLocalStorage } from '/@/utils/cache/index';
... ... @@ -120,7 +130,7 @@
120 130 setup() {
121 131 const loading = ref(false);
122 132 const loading1 = ref(false);
123   - const loading2= ref(false);
  133 + const loading2 = ref(false);
124 134 const compState = ref({
125 135 absolute: false,
126 136 loading: false,
... ... @@ -129,7 +139,7 @@
129 139 const { createMessage } = useMessage();
130 140 const userStore = useUserStore();
131 141 const storage = createLocalStorage();
132   - const [registerForm, { getFieldsValue, setFieldsValue }] = useForm({
  142 + const [registerForm, { getFieldsValue, setFieldsValue, resetFields }] = useForm({
133 143 schemas,
134 144 showSubmitButton: false,
135 145 showResetButton: false,
... ... @@ -253,6 +263,23 @@
253 263 iconPic.value = res.icon;
254 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 283 return {
257 284 registerForm,
258 285 logoPic,
... ... @@ -269,6 +296,7 @@
269 296 loading,
270 297 loading1,
271 298 loading2,
  299 + handleResetInfo,
272 300 };
273 301 },
274 302 });
... ...