From df103e7be700ecb250a71c8d7eed4c0c13f0b2fa Mon Sep 17 00:00:00 2001 From: xy <271556543@qq.com> Date: Mon, 13 Feb 2023 17:00:26 +0800 Subject: [PATCH] 2023-2-13 --- src/api/unifiedRecruitment/progress.js | 7 +- src/api/unifiedRecruitment/recruit.js | 53 ++++ src/api/yearScore/yearScore.js | 9 +- src/components/XyDialog/index.vue | 1 + src/const/index.js | 59 ++-- src/utils/downloadRequest.js | 92 ++++++ .../component/addProgress.vue | 262 +++++++++------- .../component/addRecruit.vue | 78 +++++ .../component/addRecruit1.vue | 287 ++++++++++++++++++ .../component/addTemplate.vue | 7 +- .../unifiedRecruitment/component/setting.vue | 269 ++++++++++++++-- src/views/unifiedRecruitment/progress.vue | 34 ++- src/views/unifiedRecruitment/recruit.vue | 157 ++++++++++ src/views/unifiedRecruitment/template.vue | 24 +- .../yearScore/component/addYearScore.vue | 16 +- 15 files changed, 1169 insertions(+), 186 deletions(-) create mode 100644 src/api/unifiedRecruitment/recruit.js create mode 100644 src/utils/downloadRequest.js create mode 100644 src/views/unifiedRecruitment/component/addRecruit.vue create mode 100644 src/views/unifiedRecruitment/component/addRecruit1.vue create mode 100644 src/views/unifiedRecruitment/recruit.vue diff --git a/src/api/unifiedRecruitment/progress.js b/src/api/unifiedRecruitment/progress.js index 69c7667..6cb68c2 100644 --- a/src/api/unifiedRecruitment/progress.js +++ b/src/api/unifiedRecruitment/progress.js @@ -1,5 +1,5 @@ import request from "@/utils/request"; - +import qs from 'qs'; export function index(params,isLoading = true){ return request({ url:"/api/admin/progress/index", @@ -41,6 +41,9 @@ export function init(data,isLoading = true){ url:"/api/admin/progress/init", method:"post", isLoading, - data + data:qs.stringify(data), + headers:{ + 'Content-Type':'application/x-www-form-urlencoded' + } }) } diff --git a/src/api/unifiedRecruitment/recruit.js b/src/api/unifiedRecruitment/recruit.js new file mode 100644 index 0000000..6879616 --- /dev/null +++ b/src/api/unifiedRecruitment/recruit.js @@ -0,0 +1,53 @@ +import request from "@/utils/request"; +import { download } from "@/utils/downloadRequest"; + +export function index(params,isLoading = true){ + return request({ + url:"/api/admin/recruit/index", + method:"get", + isLoading, + params + }) +} + +export function show(params,isLoading = true){ + return request({ + url:"/api/admin/recruit/show", + method:"get", + isLoading, + params + }) +} + +export function save(data,isLoading = true){ + return request({ + url:"/api/admin/recruit/save", + method:"post", + data, + isLoading + }) +} + +export function destroy(params,isLoading = true){ + return request({ + url:"/api/admin/recruit/destroy", + method:"get", + params, + isLoading + }) +} + +export function imports(data,isLoading = true){ + return request({ + url:"/api/admin/recruit/import", + method:"post", + data, + isLoading + }) +} + +export async function exports(params){ + await download('/api/admin/recruit/export','get',params,`统招生管理-${params.year}`) +} + + diff --git a/src/api/yearScore/yearScore.js b/src/api/yearScore/yearScore.js index ee29353..990996e 100644 --- a/src/api/yearScore/yearScore.js +++ b/src/api/yearScore/yearScore.js @@ -1,5 +1,5 @@ import request from "@/utils/request"; - +import qs from 'qs'; export function index(params,isLoading = true){ return request({ url:"/api/admin/year_socre/index", @@ -22,8 +22,11 @@ export function save(data,isLoading = true){ return request({ url:"/api/admin/year_socre/save", method:"post", - data, - isLoading + data:qs.stringify(data), + isLoading, + headers:{ + 'Content-Type':'application/x-www-form-urlencoded' + } }) } diff --git a/src/components/XyDialog/index.vue b/src/components/XyDialog/index.vue index c4591b4..aac5b1f 100644 --- a/src/components/XyDialog/index.vue +++ b/src/components/XyDialog/index.vue @@ -60,6 +60,7 @@ export default { }, showChange(e){ this.$emit('update:isShow',e) + this.$emit('on-visible-change',e) }, validate(){ return new Promise((resolve,reject)=>{ diff --git a/src/const/index.js b/src/const/index.js index 11a65e6..ecc7c9b 100644 --- a/src/const/index.js +++ b/src/const/index.js @@ -1,32 +1,47 @@ -const progressStatus = [ - { - id: 1, - value: "待投档", - }, - { - id: 2, - value: "录取中", - }, - { - id: 3, - value: "录取结束", - }, - { - id: 4, - value: "已邮寄通知书", - }, -]; +const data = { + "progressStatus":[ + { + id: 1, + value: "待投档", + }, + { + id: 2, + value: "录取中", + }, + { + id: 3, + value: "录取结束", + }, + { + id: 4, + value: "已邮寄通知书", + }, + ], + "templateType":[ + { + id: 1, + value: "文本", + type:"text" + }, + { + id:2, + value:"年份", + type:"year" + } + ] +} -function getProgressStatus(type = "array") { +function getConst(name,type = "array") { + let arr = data[name] if (type === "array") { - return progressStatus; + return arr; } if (type === "map") { let map = new Map(); - progressStatus.forEach((item) => { + arr.forEach((item) => { map.set(item.id, item.value); }); return map; } } -export { getProgressStatus }; +export { getConst }; diff --git a/src/utils/downloadRequest.js b/src/utils/downloadRequest.js new file mode 100644 index 0000000..3dfce31 --- /dev/null +++ b/src/utils/downloadRequest.js @@ -0,0 +1,92 @@ +import axios from 'axios' +import { getToken } from '@/utils/auth' +import { Loading, Message } from 'element-ui' + +/* + * @params {string} url 请求拼接地址 + * @params {object} info 请求参数params或data + */ + +let loading; +export async function download(url,method='get',info,filename){ + + loading = Loading.service({ + lock:true, + background:"rgba(0,0,0,0.4)", + text:"文件正在生成中..." + }) + + let options = { + baseURL:process.env.VUE_APP_BASE_API, + url, + method, + responseType: 'blob', + timeout:10000, + headers: { + Accept: 'application/json','Content-Type':'application/json; charset=utf-8', + withCredentials: true, + Authorization:"Bearer " + getToken() + }, + } + if(method === 'get'){ + Object.defineProperty(options,'params',{ + value:info, + enumerable:true, + writable:false + }) + } + if(method === 'post'){ + Object.defineProperty(options,'data',{ + value:info, + enumerable:true, + writable:false + }) + } + + try { + const response = await axios.request(options) + + loading.close() + + // 提取文件名 + if(!filename){ + filename = response.headers['content-disposition']?.match( + /filename=(.*)/ + )[1] || '' + } + + // 将二进制流转为blob + const blob = new Blob([response.data], { type: 'application/octet-stream' }) + if (typeof window.navigator.msSaveBlob !== 'undefined') { + // 兼容IE,window.navigator.msSaveBlob:以本地方式保存文件 + window.navigator.msSaveBlob(blob, decodeURI(filename)) + } else { + // 创建新的URL并指向File对象或者Blob对象的地址 + const blobURL = window.URL.createObjectURL(blob) + // 创建a标签,用于跳转至下载链接 + const tempLink = document.createElement('a') + tempLink.style.display = 'none' + tempLink.href = blobURL + tempLink.setAttribute('download', decodeURI(filename)) + // 兼容:某些浏览器不支持HTML5的download属性 + if (typeof tempLink.download === 'undefined') { + tempLink.setAttribute('target', '_blank') + } + // 挂载a标签 + document.body.appendChild(tempLink) + tempLink.click() + document.body.removeChild(tempLink) + // 释放blob URL地址 + window.URL.revokeObjectURL(blobURL) + } + }catch (err){ + console.error(err) + loading.close() + Message({ + type:'error', + message:err + }) + } +} + + diff --git a/src/views/unifiedRecruitment/component/addProgress.vue b/src/views/unifiedRecruitment/component/addProgress.vue index d397f3f..5ffe97c 100644 --- a/src/views/unifiedRecruitment/component/addProgress.vue +++ b/src/views/unifiedRecruitment/component/addProgress.vue @@ -1,26 +1,54 @@