ソースを参照

Merge branch 'dev' of https://git.citupro.com/zhengnaiwen_citu/menduner into dev

lifanagju_citu 11 ヶ月 前
コミット
064108c47a

+ 3 - 1
src/views/Home/personal/components/popularEnterprises.vue

@@ -42,7 +42,9 @@ const getHotEnterpriseList = async () => {
       if (item.isEnter) {
         const valueKey = item.nameKey ? item.nameKey : 'label'
         const idKey = item.valueKey ? item.valueKey : 'value'
-        e[item.label] = dictObj[item.value].find(k => k[idKey] === e.enterprise[item.key])[valueKey]
+        const obj = dictObj[item.value].find(k => k[idKey] === e.enterprise[item.key])
+        if (!obj) return
+        e[item.label] = obj[valueKey]
       }
       const list = e.jobList
       if (!item.isEnter) {

+ 2 - 2
src/views/PersonalCenter/dynamic/left.vue

@@ -5,8 +5,8 @@
         bordered 
         offset-x="10" 
         offset-y="50" 
-        :color="baseInfo?.sex ? (baseInfo?.sex === '0' ? '#1867c0' : 'error') : 'error'" 
-        :icon="baseInfo?.sex ? (baseInfo?.sex === '0' ? 'mdi-gender-male' : 'mdi-gender-female') : 'mdi-gender-female'">
+        :color="baseInfo?.sex ? (baseInfo?.sex === '1' ? '#1867c0' : 'error') : 'error'" 
+        :icon="baseInfo?.sex ? (baseInfo?.sex === '1' ? 'mdi-gender-male' : 'mdi-gender-female') : 'mdi-gender-female'">
         <v-avatar size="x-large" :image="baseInfo?.avatar || 'https://minio.citupro.com/dev/menduner/7.png'"></v-avatar>
       </v-badge>
       <div class="ml-5 content">

+ 27 - 10
src/views/PersonalCenter/dynamic/right.vue

@@ -27,8 +27,8 @@
       <div class="d-flex attachment-item my-2 cursor-pointer" v-for="k in attachmentList" :key="k.id">
         <v-icon color="primary">mdi-file-account</v-icon>
         <div class="file-name ellipsis ml-2">{{ k.title }}</div>
-        <!-- <v-icon class="ml-8 mr-2" color="primary" @click="handleDownload(k)">mdi-download-box-outline</v-icon> -->
-        <v-icon class="ml-8" color="error" @click="handleDelete(k)">mdi-trash-can-outline</v-icon>
+        <v-icon class="mr-2" color="primary" @click="handleDownload(k)">mdi-download-box-outline</v-icon>
+        <v-icon color="error" @click="handleDelete(k)">mdi-trash-can-outline</v-icon>
       </div>
     </div>
   </div>
@@ -100,14 +100,31 @@ const handleDelete = ({ id }) => {
   })
 }
 
-// const handleDownload = (k) => {
-//   const link = document.createElement('a')
-//   link.href = k.url
-//   link.setAttribute('download', '')
-//   document.body.appendChild(link)
-//   link.click()
-//   document.body.removeChild(link)
-// }
+const getBlob = (url) => {
+  return new Promise(resolve => {
+    const xhr = new XMLHttpRequest()
+    xhr.open('GET', url, true)
+    xhr.responseType = 'blob'
+    xhr.onload = () => {
+      if (xhr.status === 200) resolve(xhr.response)
+    }
+    xhr.send()
+  })
+}
+
+const saveAs = (blob, filename) => {
+  var link = document.createElement('a')
+  link.href = window.URL.createObjectURL(blob)
+  link.download = filename
+  link.click()
+}
+
+// 下载附件
+const handleDownload = (k) => {
+  getBlob(k.url).then(blob => {
+    saveAs(blob, k.title)
+  })
+}
 
 </script>