Bläddra i källkod

个性化设置

yujinwen 3 veckor sedan
förälder
incheckning
9cc62ca15b
4 ändrade filer med 62 tillägg och 7 borttagningar
  1. 10 0
      src/api/system/common.js
  2. 8 4
      src/api/system/set.js
  3. 2 2
      src/views/AutoLogin.vue
  4. 42 1
      src/views/system/CommonSet.vue

+ 10 - 0
src/api/system/common.js

@@ -1,6 +1,16 @@
 import {get,post} from '@/api/index'
 
 export default{
+	// 上传图片
+	uploadImg:params=>{
+		const formData=new FormData()
+		formData.append('file',params.file)
+		return post('/resource/image/upload',formData)
+	},
+	//登录(根据code)
+	loginWithCode:params=>{
+		return post('/login/auth_code_login',params)
+	},
 	//机构用户
 	companyUserList:()=>{
 		return get('/admin/business/admin',{})

+ 8 - 4
src/api/system/set.js

@@ -1,8 +1,12 @@
 import {get,post} from '@/api/index'
 
 export default{
-    //登录(根据code)
-    loginWithCode:params=>{
-        return post('/login/auth_code_login',params)
-    }
+  // 获取系统配置信息
+	getConfigData:()=>{
+		return get('/config/fetch',{})
+	},
+	// 修改系统配置信息
+	updateConfigData:params=>{
+		return post('/config/save',params)
+	},
 }

+ 2 - 2
src/views/AutoLogin.vue

@@ -1,5 +1,5 @@
 <script setup>
-import {apiSystemSet,apiSystemCommon} from '@/api/system'
+import {apiSystemCommon} from '@/api/system'
 import { useRoute, useRouter } from 'vue-router'
 
 const route=useRoute()
@@ -21,7 +21,7 @@ async function handleNavigation(){
 function init(){
     const code=route.query.code
     if(!code) return
-    apiSystemSet.loginWithCode({
+    apiSystemCommon.loginWithCode({
         AuthCode:code
     }).then(res=>{
         if(res.Ret===200){

+ 42 - 1
src/views/system/CommonSet.vue

@@ -1,8 +1,48 @@
 <script setup>
+import {apiSystemCommon,apiSystemSet} from '@/api/system'
 
 const chartWaterImgs=ref([])
 async function handleUploadImg(e){
   const file=e.raw
+  const res=await apiSystemCommon.uploadImg({
+    file:file
+  })
+  const resObj={
+    status:'',
+    error:'',
+    response:{
+      url:''
+    }
+  }
+  if(res.Ret!==200){
+    resObj.status='fail'
+    resObj.error='上传失败'
+  }else{
+    resObj.status='success'
+    resObj.response.url=res.Data.ResourceUrl
+    chartWaterImgs.value=[{url:res.Data.ResourceUrl}]
+  }
+
+  return resObj
+}
+
+// 获取配置
+async function getConfigData(){
+  const res=await apiSystemSet.getConfigData()
+  if(res.Ret!==200) return
+  if(res.Data.CompanyWatermark){
+    chartWaterImgs.value=[{url:res.Data.CompanyWatermark}]
+  }
+}
+getConfigData()
+
+// 保存配置
+async function handleSaveConfig(){
+  const res=await apiSystemSet.updateConfigData({
+    CompanyWatermark:chartWaterImgs.value[0]?.url||''
+  })
+  if(res.Ret!==200) return
+  MessagePlugin.success('保存成功')
 }
 
 </script>
@@ -15,6 +55,7 @@ async function handleUploadImg(e){
       theme="image"
       tips="上传格式:png、jpg"
       accept="image/png,image/jpeg"
+      :showImageFileName="false"
       :request-method="handleUploadImg"
       :locale="{
         triggerUploadText: {
@@ -22,7 +63,7 @@ async function handleUploadImg(e){
         },
       }"
     />
-    <t-button style="margin-top:30px">应用到全部社区图表</t-button>
+    <t-button style="margin-top:30px" @click="handleSaveConfig">应用到全部社区图表</t-button>
   </div>
 </template>