ソースを参照

导出职位列表

lifanagju_citu 10 ヶ月 前
コミット
ed958a8674

+ 8 - 0
src/api/position.js

@@ -168,6 +168,14 @@ export const getJobAdvertisedList = async (params) => {
   })
 }
 
+// 招聘端-导出招聘职位 Excel
+export const getJobAdvertisedExport = async (params) => {
+  return await request.get({
+    url: '/app-api/menduner/system/recruit/job-advertised/export',
+    params
+  })
+}
+
 // 招聘端-发布职位详情
 export const getJobDetails = async (params) => {
   return await request.get({

+ 1 - 0
src/locales/en.js

@@ -30,6 +30,7 @@ export default {
     refresh: 'Refresh',
     currentlyUnavailable: 'Currently unavailable',
     upload: 'Upload',
+    export: 'Export',
     home: 'Home',
     activation: 'Activation',
     activatePosition: 'Activate position',

+ 1 - 0
src/locales/zh-CN.js

@@ -30,6 +30,7 @@ export default {
     refresh: '刷新',
     currentlyUnavailable: '暂无',
     upload: '上传',
+    export: '导出',
     home: '首页',
     position: '职位',
     company: '公司',

+ 39 - 0
src/utils/download.js

@@ -0,0 +1,39 @@
+const download0 = (data, fileName, mineType) => {
+  if (!data || !fileName) return
+  // 创建 blob
+  const blob = new Blob([data], { type: mineType })
+  // 创建 href 超链接,点击进行下载
+  window.URL = window.URL || window.webkitURL
+  const href = URL.createObjectURL(blob)
+  const downA = document.createElement('a')
+  downA.href = href
+  downA.download = fileName
+  downA.click()
+  // 销毁超连接
+  window.URL.revokeObjectURL(href)
+}
+
+const download = {
+  // 下载 Excel 方法
+  excel: (data, fileName) => {
+    download0(data, fileName, 'application/vnd.ms-excel')
+  },
+  // 下载 Word 方法
+  word: (data, fileName) => {
+    download0(data, fileName, 'application/msword')
+  },
+  // 下载 Zip 方法
+  zip: (data, fileName) => {
+    download0(data, fileName, 'application/zip')
+  },
+  // 下载 Html 方法
+  html: (data, fileName) => {
+    download0(data, fileName, 'text/html')
+  },
+  // 下载 Markdown 方法
+  markdown: (data, fileName) => {
+    download0(data, fileName, 'text/markdown')
+  }
+}
+
+export default download

+ 11 - 1
src/views/recruit/enterprise/positionManagement/index.vue

@@ -6,6 +6,7 @@
       </div>
       <div class="text-end">
         <v-btn prepend-icon="mdi-plus" color="primary" @click="handleAdd">{{ $t('position.newPositionsAdded') }}</v-btn>
+        <v-btn prepend-icon="mdi-export-variant" color="primary" variant="tonal" class="ml-3" @click="handleExport">{{ $t('common.export') }}</v-btn>
       </div>
       
       <div class="mt-3">
@@ -37,10 +38,11 @@ import TextUI from '@/components/FormUI/TextInput'
 import PositionItem from './components/item.vue'
 import { useRoute } from 'vue-router'; const route = useRoute()
 import { useRouter } from 'vue-router'; const router = useRouter()
-import { getJobAdvertisedList } from '@/api/position'
+import { getJobAdvertisedList, getJobAdvertisedExport } from '@/api/position'
 import { dealDictArrayData } from '@/utils/position'
 import { useI18n } from '@/hooks/web/useI18n'
 import { useUserStore } from '@/store/user'
+import download from '@/utils/download'
 
 const store = useUserStore()
 
@@ -81,6 +83,14 @@ const handleAdd = async () => {
   await store.getEnterpriseUserAccountInfo()
 }
 
+const handleExport = async () => {
+  const data = await getJobAdvertisedExport(query.value)
+  console.log('getJobAdvertisedExport', 11111, data)
+  const label = tabList.find(e => e.value === tab.value)?.label || ''
+  const txt = `职位列表${label? '(' + label + ')' : ''}`
+  download.excel(data, txt)
+}
+
 
 // 获取职位列表
 const getPositionList = async () => {