CommonSet.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <script setup>
  2. import {apiSystemCommon,apiSystemSet} from '@/api/system'
  3. const chartWaterImgs=ref([])
  4. async function handleUploadImg(e){
  5. const file=e.raw
  6. const res=await apiSystemCommon.uploadImg({
  7. file:file
  8. })
  9. const resObj={
  10. status:'',
  11. error:'',
  12. response:{
  13. url:''
  14. }
  15. }
  16. if(res.Ret!==200){
  17. resObj.status='fail'
  18. resObj.error='上传失败'
  19. }else{
  20. resObj.status='success'
  21. resObj.response.url=res.Data.ResourceUrl
  22. chartWaterImgs.value=[{url:res.Data.ResourceUrl}]
  23. }
  24. return resObj
  25. }
  26. // 获取配置
  27. async function getConfigData(){
  28. const res=await apiSystemSet.getConfigData()
  29. if(res.Ret!==200) return
  30. if(res.Data.CompanyWatermark){
  31. chartWaterImgs.value=[{url:res.Data.CompanyWatermark}]
  32. }
  33. }
  34. getConfigData()
  35. // 保存配置
  36. async function handleSaveConfig(){
  37. const res=await apiSystemSet.updateConfigData({
  38. CompanyWatermark:chartWaterImgs.value[0]?.url||''
  39. })
  40. if(res.Ret!==200) return
  41. MessagePlugin.success('保存成功')
  42. }
  43. </script>
  44. <template>
  45. <div class="bg-white common-set-page">
  46. <h3>设置图表水印</h3>
  47. <t-upload
  48. v-model="chartWaterImgs"
  49. theme="image"
  50. tips="上传格式:png、jpg"
  51. accept="image/png,image/jpeg"
  52. :showImageFileName="false"
  53. :request-method="handleUploadImg"
  54. :locale="{
  55. triggerUploadText: {
  56. image: '点击上传图片',
  57. },
  58. }"
  59. />
  60. <t-button style="margin-top:30px" @click="handleSaveConfig">应用到全部社区图表</t-button>
  61. </div>
  62. </template>
  63. <style lang="scss" scoped>
  64. .common-set-page{
  65. padding: 20px;
  66. border-radius: 4px;
  67. height: calc(100vh - 160px);
  68. }
  69. </style>