mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/fe-manage.git
synced 2025-12-10 03:16:44 +08:00
Merge branch 'zcwy-zsx0223' into dev0223
This commit is contained in:
36
src/utils/zipdownload.js
Normal file
36
src/utils/zipdownload.js
Normal file
@@ -0,0 +1,36 @@
|
||||
import axios from 'axios'
|
||||
import {getCookieForName} from "@/api/method";
|
||||
|
||||
const mimeMap = {
|
||||
xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
zip: 'application/zip'
|
||||
}
|
||||
|
||||
const baseUrl = process.env.VUE_APP_ACT_API
|
||||
export function downLoadZip(str, filename) {
|
||||
var url = baseUrl + str
|
||||
axios({
|
||||
method: 'get',
|
||||
url: url,
|
||||
responseType: 'blob',
|
||||
headers: { 'Authorization': 'Bearer ' + getCookieForName("token") }
|
||||
}).then(res => {
|
||||
resolveBlob(res, mimeMap.zip,filename)
|
||||
})
|
||||
}
|
||||
/**
|
||||
* 解析blob响应内容并下载
|
||||
* @param {*} res blob响应内容
|
||||
* @param {String} mimeType MIME类型
|
||||
*/
|
||||
export function resolveBlob(res, mimeType,filename) {
|
||||
const link = document.createElement('a');// 创建a标签
|
||||
let blob = new Blob([res.data], { type: mimeType }); // 设置文件类型
|
||||
link.style.display = "none";
|
||||
link.href = URL.createObjectURL(blob); // 创建URL
|
||||
link.setAttribute("download", `${filename}`);
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
URL.revokeObjectURL(link.href);
|
||||
document.body.removeChild(link);
|
||||
}
|
||||
@@ -69,6 +69,7 @@ import { useRoute } from "vue-router";
|
||||
import { message } from "ant-design-vue";
|
||||
import { useStore } from "vuex";
|
||||
import {boeRequest} from "@/api/request";
|
||||
import {downLoadZip} from "@/utils/zipdownload";
|
||||
export default {
|
||||
name: "evadown",
|
||||
components: {},
|
||||
@@ -165,7 +166,8 @@ import {boeRequest} from "@/api/request";
|
||||
message.info('请先上传报告')
|
||||
return
|
||||
}
|
||||
window.open(`/activityApi/evaluation/download?id=${route.query.id}`);
|
||||
// window.open(`/activityApi/evaluation/download?id=${route.query.id}`);
|
||||
downLoadZip(`/evaluation/download?id=${route.query.id}`,route.query.name)
|
||||
}
|
||||
const listData = async () => {
|
||||
state.tableLoading = true
|
||||
|
||||
@@ -161,7 +161,7 @@
|
||||
<div class="bg_body_input" style="display: flex;">
|
||||
<a-upload name="avatar" list-type="picture-card" class="avatar-uploader" :show-upload-list="false"
|
||||
:headers="headers"
|
||||
:before-upload="beforeUpload">
|
||||
:before-upload="beforeUpload" @change="handleChangeImg">
|
||||
<img class="i_upload_img" v-if="formData.cover" :src="formData.cover" alt="avatar" />
|
||||
<div class="i_upload" v-else>
|
||||
<div class="addimg">
|
||||
@@ -177,15 +177,13 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bg_body_bt" v-if="btShowEdit">
|
||||
<div class="bg_body_bttext">上传说明</div>
|
||||
<div class="bg_body_bt" v-if="btShow">
|
||||
<div class="bg_body_bttext">备注</div>
|
||||
<div class="bg_body_input">
|
||||
<span style="color: #999ba3">
|
||||
1、仅支持1个zip压缩包和pdf报告上传;<br/>
|
||||
2、单个附件命名规则:测评名称+姓名+工号(名称中间用英文输入法-连接)例如:大五职业性格测评-李玉冰-00004409.pdf
|
||||
</span>
|
||||
<a-textarea placeholder="请输入备注(限200个字以内)" style="width: 334px;height: 88px;" v-model:value="formData.remarks" showCount :maxlength="200" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bg_body_bt" v-if="btShowEdit">
|
||||
<div class="bg_body_bttext">
|
||||
<div class="bg_body_btimg">
|
||||
@@ -235,9 +233,12 @@
|
||||
:class="`${{uploading: 'updatacolor3', done: 'updatacolor' ,error: 'updatacolor2'}[item.status] || 'updatacolor'}`"
|
||||
:style="{width:`${item.status==='uploading'?parseInt(item.percent):100}%`}"></div>
|
||||
<div v-if="item.status"
|
||||
style="right:-62px;"
|
||||
style="right:-95px;"
|
||||
:class="`${{uploading: 'updataxq1', done: 'updataxq' ,error: 'updataxq2'}[item.status] || 'updataxq'}`">
|
||||
{{ {uploading: '正在上传', done: '上传完成', error: '上传失败'}[item.status] || '' }}
|
||||
{{ {uploading: '正在上传', done: '上传完成', error: '报告错误'}[item.status] || '' }}
|
||||
<span v-if="totalNumber?.failedEntries>0||totalNumber?.successfulEntries>0" @click="failedDownload" style="color: #4ea6ff;cursor: pointer;margin-left: 5px;">
|
||||
下载
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="upjd" v-if="item.percent">
|
||||
@@ -245,16 +246,19 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="file_operation" @click="delUploadList(index)" style="color: #4ea6ff;cursor: pointer">
|
||||
删除
|
||||
<div class="file_operation btn_item" @click="delUploadList(index)" style="color: #4ea6ff;cursor: pointer">
|
||||
<span style="width: 23px;height: 21px;" class="delete"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bg_body_bt" v-if="btShow">
|
||||
<div class="bg_body_bttext">备注</div>
|
||||
<div class="bg_body_bt" v-if="btShowEdit">
|
||||
<div class="bg_body_bttext">上传说明</div>
|
||||
<div class="bg_body_input">
|
||||
<a-textarea placeholder="请输入备注(限200个字以内)" style="width: 334px;height: 88px;" v-model:value="formData.remarks" showCount :maxlength="200" />
|
||||
<span style="color: #999ba3">
|
||||
1、仅支持1个zip压缩包和pdf报告上传;<br/>
|
||||
2、单个附件命名规则:测评名称+姓名+工号(名称中间用英文输入法-连接)例如:大五职业性格测评-李玉冰-00004409.pdf
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bg_footer">
|
||||
@@ -264,6 +268,8 @@
|
||||
<a-button
|
||||
class="btn btn6"
|
||||
:loading="uploadDownLoad"
|
||||
:disabled="totalNumber?.failedEntries>0"
|
||||
:style="{background: totalNumber?.failedEntries>0?'#d9d9d9':'#4ea6ff'}"
|
||||
@click="formData.id&&btShow?showUpload():reportUpload()"
|
||||
>
|
||||
确定
|
||||
@@ -421,9 +427,9 @@
|
||||
</div>
|
||||
<div class="bg_body">
|
||||
<div>上传结果</div>
|
||||
<div style="margin: 25px 0 0 24px;">上传的测评报告总文件数{{totalNumber.totalEntries}}个,成功{{totalNumber.successfulEntries}}个,失败{{totalNumber.failedEntries}}个;<br/>上传结果<span @click="failedDownload" style="color: #4ea6ff;cursor: pointer;">请下载</span>查看!</div>
|
||||
<div style="margin: 25px 0 0 24px;">上传的测评报告总文件数{{totalNumber.totalEntries}}个,成功{{totalNumber.successfulEntries}}个,失败{{totalNumber.failedEntries}}个;<br/>上传结果请下载查看!</div>
|
||||
<div class="bg_footer" style="margin-left: 90px;">
|
||||
<div class="btn btn6" @click="of_results">
|
||||
<!-- <div class="btn btn6" @click="of_results">
|
||||
<div class="btnText">取消</div>
|
||||
</div>
|
||||
<a-button
|
||||
@@ -431,7 +437,7 @@
|
||||
@click="resultsUp"
|
||||
>
|
||||
确定
|
||||
</a-button>
|
||||
</a-button> -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -518,8 +524,10 @@
|
||||
:loading="tableLoadingAdd"
|
||||
:scroll="{ x: 1000,y: 500 }"
|
||||
:pagination="paginationAdd"
|
||||
:customRow="customRow"
|
||||
:row-class-name="getRowClassName"
|
||||
>
|
||||
<template #addAuthority="{ record, column }">
|
||||
<!-- <template #addAuthority="{ record, column }">
|
||||
<a-space>
|
||||
<a-button type="link" @click="powerSetting(record)">
|
||||
<span>权限配置</span>
|
||||
@@ -531,7 +539,7 @@
|
||||
<span class="download">删除</span>
|
||||
</a-button>
|
||||
</a-space>
|
||||
</template>
|
||||
</template> -->
|
||||
</a-table>
|
||||
</div>
|
||||
<div class="bg_body">
|
||||
@@ -692,6 +700,7 @@ import { useStore } from "vuex";
|
||||
import { message } from "ant-design-vue";
|
||||
import {timeoutUpload} from "@/api/configPublic";
|
||||
// import md5 from 'js-md5';
|
||||
import {downLoadZip} from "@/utils/zipdownload";
|
||||
export default {
|
||||
name: 'evaluationUpload',
|
||||
components:{
|
||||
@@ -705,6 +714,7 @@ import {timeoutUpload} from "@/api/configPublic";
|
||||
const state = reactive({
|
||||
activeUrl: process.env.VUE_APP_ACT_API + '/evaluation/import',
|
||||
uploadTypes: true,
|
||||
selectedRow: null,
|
||||
uploadStatusType: true,
|
||||
saveNotUpload: true,
|
||||
stateUpload: true,
|
||||
@@ -855,6 +865,15 @@ import {timeoutUpload} from "@/api/configPublic";
|
||||
saveListItem()
|
||||
})
|
||||
// 添加权限
|
||||
const customRow = (record) => ({
|
||||
onClick: () => {
|
||||
state.selectedRow = record
|
||||
state.saveList.push(record)
|
||||
}
|
||||
})
|
||||
const getRowClassName = (record, index) => {
|
||||
return state.selectedRow === record ? 'highlight-row' : '';
|
||||
}
|
||||
const paginationAdd = computed(() => ({
|
||||
total: state.totalAdd,
|
||||
showSizeChanger: true,
|
||||
@@ -1033,8 +1052,8 @@ import {timeoutUpload} from "@/api/configPublic";
|
||||
},
|
||||
{
|
||||
title: "工号",
|
||||
dataIndex: "departId",
|
||||
key: "departId",
|
||||
dataIndex: "userNo",
|
||||
key: "userNo",
|
||||
className: "h",
|
||||
ellipsis: true,
|
||||
align: "center",
|
||||
@@ -1058,15 +1077,15 @@ import {timeoutUpload} from "@/api/configPublic";
|
||||
align: "center",
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
title: "操作",
|
||||
width: "20%",
|
||||
fixed: 'right',
|
||||
dataIndex: "id",
|
||||
key: "id",
|
||||
align: "center",
|
||||
slots: { customRender: "addAuthority" },
|
||||
},
|
||||
// {
|
||||
// title: "操作",
|
||||
// width: "20%",
|
||||
// fixed: 'right',
|
||||
// dataIndex: "id",
|
||||
// key: "id",
|
||||
// align: "center",
|
||||
// slots: { customRender: "addAuthority" },
|
||||
// },
|
||||
])
|
||||
const textDisabled = async (record) => {
|
||||
await updateStatus({status:1,id:record.id}).then((res)=>{
|
||||
@@ -1142,10 +1161,12 @@ import {timeoutUpload} from "@/api/configPublic";
|
||||
message.info('请先上传报告')
|
||||
return
|
||||
}
|
||||
window.open(`${process.env.VUE_APP_ACT_API}/evaluation/download?id=${record.id}`);
|
||||
// window.open(`${process.env.VUE_APP_ACT_API}/evaluation/download?id=${record.id}`);
|
||||
downLoadZip(`/evaluation/download?id=${record.id}`,record.evaluationName)
|
||||
}
|
||||
const of_exit = () => {
|
||||
// state.tableLoading = false
|
||||
state.totalNumber = {}
|
||||
state.uploadTypes = false
|
||||
state.uploadDownLoad = false
|
||||
state.bg_check = false;
|
||||
@@ -1161,11 +1182,6 @@ import {timeoutUpload} from "@/api/configPublic";
|
||||
}
|
||||
// 上传结果
|
||||
const of_results = () => {
|
||||
if(state.totalNumber.failedEntries!=0){
|
||||
message.warning('上传文件含有错误信息,已自动删除,请上传正确文件')
|
||||
delUploadList()
|
||||
}
|
||||
state.totalNumber = {}
|
||||
state.bg_results = false
|
||||
}
|
||||
const resultsUp = () => {
|
||||
@@ -1192,6 +1208,10 @@ import {timeoutUpload} from "@/api/configPublic";
|
||||
message.error('上传报告含有错误报告,请检查后重新上传')
|
||||
return
|
||||
}
|
||||
if(state.uploadList.length==0&&state.btShowEdit){
|
||||
message.error('请您上传附件')
|
||||
return
|
||||
}
|
||||
// state.tableLoading = true
|
||||
state.uploadDownLoad = true
|
||||
if( !state.loadData&&state.loadNewDown){
|
||||
@@ -1247,6 +1267,7 @@ import {timeoutUpload} from "@/api/configPublic";
|
||||
//上传图片
|
||||
const headers = { token: getCookieForName("token") };
|
||||
const beforeUpload = (file) => {
|
||||
console.log(file,'file')
|
||||
const isJpgOrPng =
|
||||
file.type === "image/jpeg" ||
|
||||
file.type === "image/png"
|
||||
@@ -1264,11 +1285,14 @@ import {timeoutUpload} from "@/api/configPublic";
|
||||
formData.append("file", file);
|
||||
uploadImage(formData).then((res) => {
|
||||
if (res.status === 200) {
|
||||
state.formData.cover = res.data.split('Path:')[1];
|
||||
state.formData.cover = res.data.split('elearning')[1];
|
||||
}
|
||||
});
|
||||
return false;
|
||||
};
|
||||
const handleChangeImg = (info) =>{
|
||||
console.log(info,'info')
|
||||
}
|
||||
const beforeUpload3 = async (file) => {
|
||||
if(!state.formData.evaluationName){
|
||||
message.error('请先填写测评名称')
|
||||
@@ -1374,6 +1398,7 @@ import {timeoutUpload} from "@/api/configPublic";
|
||||
};
|
||||
const uploadRef = ref()
|
||||
const delUploadList = (i) => {
|
||||
state.totalNumber = {}
|
||||
state.uploadTypes = false
|
||||
state.uploadDownLoad = false
|
||||
state.sussessIds = null
|
||||
@@ -1585,6 +1610,7 @@ import {timeoutUpload} from "@/api/configPublic";
|
||||
downloadAll,
|
||||
headers,
|
||||
beforeUpload,
|
||||
handleChangeImg,
|
||||
beforeUpload3,
|
||||
handleChange,
|
||||
delUploadList,
|
||||
@@ -1604,6 +1630,8 @@ import {timeoutUpload} from "@/api/configPublic";
|
||||
changePaginationsAdd,
|
||||
pagination,
|
||||
paginationAdd,
|
||||
customRow,
|
||||
getRowClassName,
|
||||
textDisabled,
|
||||
textDelete,
|
||||
updateAuthority,
|
||||
@@ -1617,6 +1645,9 @@ import {timeoutUpload} from "@/api/configPublic";
|
||||
::v-deep .ant-dropdown{
|
||||
left: 120px !important;
|
||||
}
|
||||
::v-deep .highlight-row{
|
||||
background: #4ea6ff !important;
|
||||
}
|
||||
.evaluationUpload{
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
@@ -1806,7 +1837,7 @@ import {timeoutUpload} from "@/api/configPublic";
|
||||
}
|
||||
}
|
||||
.mbl_items12 {
|
||||
width: 334px;
|
||||
width: 333px;
|
||||
margin-left: 128px;
|
||||
.item_text{
|
||||
width: 300px;
|
||||
@@ -1882,7 +1913,7 @@ import {timeoutUpload} from "@/api/configPublic";
|
||||
.updataxq {
|
||||
position: absolute;
|
||||
right: 2px;
|
||||
top: -30px;
|
||||
top: -37px;
|
||||
color: #57c887;
|
||||
}
|
||||
|
||||
@@ -2005,6 +2036,10 @@ import {timeoutUpload} from "@/api/configPublic";
|
||||
background-color: #4ea6ff;
|
||||
color: #ffffff;
|
||||
}
|
||||
.btndesign {
|
||||
background-color: #eff4fc;
|
||||
color: #ffffff;
|
||||
}
|
||||
}
|
||||
}
|
||||
.headers{
|
||||
|
||||
Reference in New Issue
Block a user