Commit 3443f0554edbd9a2ae0b216875c3a3ba09181379

Authored by xp.Huang
2 parents f16e723b 4e2e426f

Merge branch 'sqy_dev' into 'main'

oem内容定制修改中

See merge request huang/yun-teng-iot-front!17
@@ -2,9 +2,10 @@ @@ -2,9 +2,10 @@
2 * @Author: Vben 2 * @Author: Vben
3 * @Description: logo component 3 * @Description: logo component
4 --> 4 -->
  5 +<!-- TODO: appLogo -->
5 <template> 6 <template>
6 <div class="anticon" :class="getAppLogoClass" @click="goHome"> 7 <div class="anticon" :class="getAppLogoClass" @click="goHome">
7 - <img src="../../../assets/images/logo.png" /> 8 + <img :src="getLogoUrl" />
8 <div class="ml-2 md:opacity-100" :class="getTitleClass" v-show="showTitle"> 9 <div class="ml-2 md:opacity-100" :class="getTitleClass" v-show="showTitle">
9 {{ title }} 10 {{ title }}
10 </div> 11 </div>
@@ -18,7 +19,7 @@ @@ -18,7 +19,7 @@
18 import { useDesign } from '/@/hooks/web/useDesign'; 19 import { useDesign } from '/@/hooks/web/useDesign';
19 import { PageEnum } from '/@/enums/pageEnum'; 20 import { PageEnum } from '/@/enums/pageEnum';
20 import { useUserStore } from '/@/store/modules/user'; 21 import { useUserStore } from '/@/store/modules/user';
21 - 22 + import { createLocalStorage } from '/@/utils/cache/index';
22 const props = defineProps({ 23 const props = defineProps({
23 /** 24 /**
24 * The theme of the current parent component 25 * The theme of the current parent component
@@ -46,6 +47,14 @@ @@ -46,6 +47,14 @@
46 { 'collapsed-show-title': unref(getCollapsedShowTitle) }, 47 { 'collapsed-show-title': unref(getCollapsedShowTitle) },
47 ]); 48 ]);
48 49
  50 + const storage = createLocalStorage();
  51 + // 获取AppLogo
  52 + const getLogoUrl = computed(() => {
  53 + return storage.get('platformInfo')
  54 + ? storage.get('platformInfo').logo
  55 + : '/src/assets/images/logo.png';
  56 + });
  57 +
49 const getTitleClass = computed(() => [ 58 const getTitleClass = computed(() => [
50 `${prefixCls}__title`, 59 `${prefixCls}__title`,
51 { 60 {
@@ -35,8 +35,8 @@ @@ -35,8 +35,8 @@
35 :before-upload="beforeUploadIconPic" 35 :before-upload="beforeUploadIconPic"
36 > 36 >
37 <div v-if="iconPic"> 37 <div v-if="iconPic">
38 - <img :src="iconPic" />  
39 - <div style="background-color: #ccc">重新上传</div> 38 + <img :src="iconPic" class="m-auto" />
  39 + <div style="background-color: #ccc; margin-top: 20px">重新上传</div>
40 </div> 40 </div>
41 <div v-else> 41 <div v-else>
42 <PlusOutlined style="font-size: 30px" /> 42 <PlusOutlined style="font-size: 30px" />
@@ -95,6 +95,7 @@ @@ -95,6 +95,7 @@
95 import type { FileItem } from '/@/components/Upload/src/typing'; 95 import type { FileItem } from '/@/components/Upload/src/typing';
96 import { logoUpload, iconUpload, bgUpload, getPlatForm, updatePlatForm } from '/@/api/oem/index'; 96 import { logoUpload, iconUpload, bgUpload, getPlatForm, updatePlatForm } from '/@/api/oem/index';
97 import { PlusOutlined } from '@ant-design/icons-vue'; 97 import { PlusOutlined } from '@ant-design/icons-vue';
  98 + import { createLocalStorage } from '/@/utils/cache/index';
98 export default defineComponent({ 99 export default defineComponent({
99 components: { 100 components: {
100 BasicForm, 101 BasicForm,
@@ -146,7 +147,7 @@ @@ -146,7 +147,7 @@
146 } 147 }
147 return isJpgOrPng && isLt2M; 148 return isJpgOrPng && isLt2M;
148 }; 149 };
149 - 150 + // Icon上传
150 async function customUploadIconPic({ file }) { 151 async function customUploadIconPic({ file }) {
151 if (beforeUploadIconPic(file)) { 152 if (beforeUploadIconPic(file)) {
152 const formData = new FormData(); 153 const formData = new FormData();
@@ -158,9 +159,9 @@ @@ -158,9 +159,9 @@
158 } 159 }
159 } 160 }
160 const beforeUploadIconPic = (file: FileItem) => { 161 const beforeUploadIconPic = (file: FileItem) => {
161 - const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png'; 162 + const isJpgOrPng = file.type === 'image/x-icon';
162 if (!isJpgOrPng) { 163 if (!isJpgOrPng) {
163 - createMessage.error('只能上传图片文件!'); 164 + createMessage.error('只能上传.icon图片文件!');
164 } 165 }
165 const isLt2M = (file.size as number) / 1024 < 500; 166 const isLt2M = (file.size as number) / 1024 < 500;
166 if (!isLt2M) { 167 if (!isLt2M) {
@@ -198,12 +199,16 @@ @@ -198,12 +199,16 @@
198 compState.value.loading = true; 199 compState.value.loading = true;
199 await updatePlatForm({ 200 await updatePlatForm({
200 ...fieldValue, 201 ...fieldValue,
201 - background: unref(bgPic),  
202 - icon: unref(bgPic),  
203 logo: unref(logoPic), 202 logo: unref(logoPic),
  203 + icon: unref(iconPic),
  204 + background: unref(bgPic),
204 }); 205 });
205 compState.value.loading = false; 206 compState.value.loading = false;
206 createMessage.success('保存信息成功'); 207 createMessage.success('保存信息成功');
  208 +
  209 + // 保存一份数据到本地缓存中.
  210 + const storage = createLocalStorage();
  211 + storage.set('PlatformInfo', fieldValue);
207 } catch (e) { 212 } catch (e) {
208 createMessage.error('保存信息失败'); 213 createMessage.error('保存信息失败');
209 } 214 }
@@ -61,13 +61,6 @@ @@ -61,13 +61,6 @@
61 } 61 }
62 }; 62 };
63 63
64 - onMounted(async () => {  
65 - const res = await getEnterPriseDetail();  
66 - console.log(res);  
67 - updateCityData(res.codeProv, res.codeCity, res.codeCoun);  
68 - setFieldsValue(res);  
69 - });  
70 -  
71 async function updateCityData(codeProv: string, codeCity: string, codeCoun: string) { 64 async function updateCityData(codeProv: string, codeCity: string, codeCoun: string) {
72 const nameCity = await getTownChild('codeProv', codeProv); 65 const nameCity = await getTownChild('codeProv', codeProv);
73 const nameCoun = await getTownChild('codeCity', codeCity); 66 const nameCoun = await getTownChild('codeCity', codeCity);
@@ -182,6 +175,12 @@ @@ -182,6 +175,12 @@
182 }); 175 });
183 } 176 }
184 177
  178 + onMounted(async () => {
  179 + const res = await getEnterPriseDetail();
  180 + updateCityData(res.codeProv, res.codeCity, res.codeCoun);
  181 + setFieldsValue(res);
  182 + });
  183 +
185 return { 184 return {
186 registerForm, 185 registerForm,
187 compState, 186 compState,