This commit is contained in:
愉快的大福 2024-08-13 09:08:22 +08:00
parent 9fd23ae016
commit 17cfb910e0
45 changed files with 608 additions and 558 deletions

View File

@ -1,4 +1,4 @@
import request from '@/axios'; import request from '@/utils/request'
export function findAll(params) { export function findAll(params) {
return request({ return request({

View File

@ -1,4 +1,4 @@
import request from '@/axios'; import request from '@/utils/request'
export function coursePushFindList() { export function coursePushFindList() {
return request({ return request({

View File

@ -1,4 +1,4 @@
import request from '@/axios'; import request from '@/utils/request'
export function getTree(params) { export function getTree(params) {
return request({ return request({

View File

@ -1,5 +1,5 @@
import request from '@/axios'; import request from '@/utils/request'
import download from '@/axios'; import download from '@/utils/request';
// 获取员工列表 // 获取员工列表

View File

@ -1,4 +1,4 @@
import request from '@/axios' import request from '@/utils/request'
export function expertZoneFindAll(params) { export function expertZoneFindAll(params) {
return request({ return request({

View File

@ -1,4 +1,4 @@
import request from '@/axios' import request from '@/utils/request'
export function zoneCollectionFindAll(params) { export function zoneCollectionFindAll(params) {
return request({ return request({

View File

@ -1,4 +1,4 @@
import request from '@/axios' import request from '@/utils/request'
export function zoneCommentFindAll(params) { export function zoneCommentFindAll(params) {
return request({ return request({

View File

@ -1,4 +1,4 @@
import request from '@/axios' import request from '@/utils/request'
export function expertFindAll(params) { export function expertFindAll(params) {
return request({ return request({

View File

@ -1,4 +1,4 @@
import request from '@/axios' import request from '@/utils/request'
export function expertMaintenanceFindAll(params) { export function expertMaintenanceFindAll(params) {
return request({ return request({

View File

@ -1,4 +1,4 @@
import request from '@/axios'; import request from '@/utils/request'
export function headCardListStatistics(query) { export function headCardListStatistics(query) {

View File

@ -1,5 +1,5 @@
import request from '@/axios'; import request from '@/utils/request'
import download from '@/axios'; import download from '@/utils/request';
// 查询角色列表 // 查询角色列表
export function findAll(query) { export function findAll(query) {
return request({ return request({

View File

@ -1,5 +1,5 @@
import request from '@/axios'; import request from '@/utils/request'
import download from '@/axios'; import download from '@/utils/request';
// 查询角色列表 // 查询角色列表
export function findAll(query) { export function findAll(query) {
return request({ return request({

View File

@ -1,4 +1,4 @@
import request from '@/axios'; import request from '@/utils/request'
export function findAll(params) { export function findAll(params) {
return request({ return request({

View File

@ -1,4 +1,4 @@
import request from '@/axios'; import request from '@/utils/request'
export function getTree(params) { export function getTree(params) {
return request({ return request({

View File

@ -1,5 +1,5 @@
import request from '@/axios'; import request from '@/utils/request'
import download from '@/axios'; import download from '@/utils/request';
// 查询角色列表 // 查询角色列表
export function findAll(query) { export function findAll(query) {
return request({ return request({

View File

@ -1,5 +1,5 @@
import request from '@/axios'; import request from '@/utils/request'
import download from '@/axios'; import download from '@/utils/request';
// 新建操作文件 // 新建操作文件

View File

@ -1,4 +1,4 @@
import request from '@/axios'; import request from '@/utils/request'
//查询题库树 //查询题库树
export function getTree() { export function getTree() {

View File

@ -1,4 +1,4 @@
import request from '@/axios'; import request from '@/utils/request'
// 获取题干列表 // 获取题干列表
export function getStemList(params) { export function getStemList(params) {

View File

@ -1,5 +1,5 @@
import request from '@/axios'; import request from '@/utils/request'
import download from '@/axios'; import download from '@/utils/request';
// 查询角色列表 // 查询角色列表
export function findAll(query) { export function findAll(query) {
return request({ return request({

View File

@ -1,4 +1,4 @@
import request from '@/axios'; import request from '@/utils/request'
// 文件查看 // 文件查看
export function findAll(query) { export function findAll(query) {

View File

@ -1,5 +1,5 @@
import request from '@/axios'; import request from '@/utils/request'
import download from '@/axios'; import download from '@/utils/request';
// 查询角色列表 // 查询角色列表
export function findAll(query) { export function findAll(query) {
return request({ return request({

View File

@ -1,5 +1,5 @@
import request from '@/axios'; import request from '@/utils/request'
import download from '@/axios'; import download from '@/utils/request';
// 查询角色列表 // 查询角色列表
export function findAll(query) { export function findAll(query) {
return request({ return request({

View File

@ -1,5 +1,5 @@
import request from '@/axios'; import request from '@/utils/request'
import download from '@/axios'; import download from '@/utils/request';
// 获取员工列表 // 获取员工列表

View File

@ -1,5 +1,5 @@
import request from '@/axios'; import request from '@/utils/request'
import download from '@/axios'; import download from '@/utils/request';
// 查询角色列表 // 查询角色列表
export function findAll(query) { export function findAll(query) {
return request({ return request({

View File

@ -1,5 +1,5 @@
import request from '@/axios'; import request from '@/utils/request'
import download from '@/axios'; import download from '@/utils/request';
// 新建操作文件 // 新建操作文件

View File

@ -1,5 +1,5 @@
import request from '@/axios'; import request from '@/utils/request'
import download from '@/axios'; import download from '@/utils/request';
// 新建操作文件 // 新建操作文件

View File

@ -1,4 +1,4 @@
import request from '@/axios'; import request from '@/utils/request'
// 文件查看 // 文件查看
export function findAll(query) { export function findAll(query) {

View File

@ -1,4 +1,4 @@
import request from '@/axios'; import request from '@/utils/request'
export function judge(query) { export function judge(query) {
return request({ return request({

View File

@ -1,4 +1,4 @@
import request from '@/axios'; import request from '@/utils/request'
//查询题库树 //查询题库树
export function getTree() { export function getTree() {

View File

@ -1,4 +1,4 @@
import request from '@/axios'; import request from '@/utils/request'
// 获取题干列表 // 获取题干列表
export function getStemList(params) { export function getStemList(params) {

View File

@ -1,5 +1,5 @@
import request from '@/axios'; import request from '@/utils/request'
import download from '@/axios'; import download from '@/utils/request';
// 查询角色列表 // 查询角色列表
export function findAll(query) { export function findAll(query) {
return request({ return request({

View File

@ -1,4 +1,4 @@
import request from '@/axios'; import request from '@/utils/request'
export const getDeptTree = (id) => { export const getDeptTree = (id) => {
return request({ return request({
url: `/knowledge/commonApi/getDeptData`, method: 'get' url: `/knowledge/commonApi/getDeptData`, method: 'get'

View File

@ -1,9 +1,9 @@
import request from '@/axios'; import request from '@/utils/request'
// 文件查看 // 文件查看
export function findAll(query) { export function findAll(query) {
return request({ return request({
url: '/knowledge/system/tArchives/findAll', url: '/system/tArchives/findAll',
method: 'get', method: 'get',
params: query params: query
}) })
@ -12,7 +12,7 @@ export function findAll(query) {
// 文件查看 // 文件查看
export function findAllDocList(query) { export function findAllDocList(query) {
return request({ return request({
url: '/knowledge/system/tArchives/findAllDocList', url: '/system/tArchives/findAllDocList',
method: 'get', method: 'get',
params: query params: query
}) })
@ -21,7 +21,7 @@ export function findAllDocList(query) {
// 文件查看 // 文件查看
export function getParentId(query) { export function getParentId(query) {
return request({ return request({
url: '/knowledge/system/tArchives/getParentId', url: '/system/tArchives/getParentId',
method: 'get', method: 'get',
params: query params: query
}) })
@ -31,7 +31,7 @@ export function getParentId(query) {
//文件保存/新建文件夹 //文件保存/新建文件夹
export function save(data) { export function save(data) {
return request({ return request({
url: '/knowledge/system/tArchives/save', url: '/system/tArchives/save',
method: 'post', method: 'post',
data: data data: data
}) })
@ -40,7 +40,7 @@ export function save(data) {
// 删除文件或文件夹 // 删除文件或文件夹
export function delByIds(ids) { export function delByIds(ids) {
return request({ return request({
url: '/knowledge/system/tArchives/delete', url: '/system/tArchives/delete',
method: 'post', method: 'post',
params:ids params:ids
}) })
@ -49,7 +49,7 @@ export function delByIds(ids) {
// 彻底删除 // 彻底删除
export function ackDelete(ids) { export function ackDelete(ids) {
return request({ return request({
url: '/knowledge/system/tArchives/ackDelete', url: '/system/tArchives/ackDelete',
method: 'post', method: 'post',
params:ids params:ids
}) })
@ -58,7 +58,7 @@ export function ackDelete(ids) {
// 还原 // 还原
export function restore(ids) { export function restore(ids) {
return request({ return request({
url: '/knowledge/system/tArchives/restore', url: '/system/tArchives/restore',
method: 'post', method: 'post',
params:ids params:ids
}) })

View File

@ -1,4 +1,4 @@
import request from '@/axios'; import request from '@/utils/request'
export function selfDetail(id) { export function selfDetail(id) {
return request({ return request({

View File

@ -1,4 +1,4 @@
import request from '@/axios'; import request from '@/utils/request'
export function testPaperInfoFindAll(params) { export function testPaperInfoFindAll(params) {
return request({ return request({

View File

@ -1,4 +1,4 @@
import request from '@/axios'; import request from '@/utils/request'
export function getTaskList(data) { export function getTaskList(data) {

View File

@ -1,4 +1,4 @@
import request from '@/axios'; import request from '@/utils/request'
export function findTeacherByName(teacherName) { export function findTeacherByName(teacherName) {
return request({ return request({

View File

@ -1,5 +1,5 @@
import request from '@/axios'; import request from '@/utils/request'
import download from '@/axios'; import download from '@/utils/request';
// 查询角色列表 // 查询角色列表
export function findAll(query) { export function findAll(query) {
return request({ return request({

View File

@ -55,12 +55,12 @@ export default {
// (MB) // (MB)
fileSize: { fileSize: {
type: Number, type: Number,
default: 5, default: 500,
}, },
// , ['png', 'jpg', 'jpeg'] // , ['png', 'jpg', 'jpeg']
fileType: { fileType: {
type: Array, type: Array,
default: () => ["doc", "xls", "ppt", "txt", "pdf"], default: () => ["doc", "xls", "ppt", "txt", "pdf","mp4","png","jpg","zip","rar","jpeg","xlsx","docx"],
}, },
// //
isShowTip: { isShowTip: {

View File

@ -1,15 +1,5 @@
<template> <template>
<!-- 文件列表 -->
<transition-group v-if="position=='top'" class="upload-file-list el-upload-list el-upload-list--text" name="el-fade-in-linear" tag="ul">
<li :key="file.uid" class="el-upload-list__item ele-upload-list__item-content" v-for="(file, index) in fileList">
<el-link :href="`${file.url}`" :underline="false" target="_blank">
<span class="el-icon-document"> {{ getFileName(file.name) }} </span>
</el-link>
<div class="ele-upload-list__item-content-action">
<el-link :underline="false" @click="handleDelete(index)" type="danger">删除</el-link>
</div>
</li>
</transition-group>
<div class="upload-file"> <div class="upload-file">
@ -27,9 +17,9 @@
class="upload-file-uploader" class="upload-file-uploader"
ref="fileUpload" ref="fileUpload"
> >
<div class="tp-anniu" v-if="buttonType=='question'" style="margin: 0px">上传图片/视频</div>
<!-- 上传按钮 --> <!-- 上传按钮 -->
<el-button v-else type="primary">{{name}}</el-button> <el-button type="primary">{{name}}</el-button>
</el-upload> </el-upload>
<!-- 上传提示 --> <!-- 上传提示 -->
<div class="el-upload__tip" v-if="showTip"> <div class="el-upload__tip" v-if="showTip">
@ -38,8 +28,10 @@
<template v-if="fileType"> 格式为 <b style="color: #f56c6c">{{ fileType.join("/") }}</b></template> <template v-if="fileType"> 格式为 <b style="color: #f56c6c">{{ fileType.join("/") }}</b></template>
的文件 的文件
</div> </div>
<!-- 文件列表 --> <!-- 文件列表 -->
<transition-group v-if="position=='bottom'" class="upload-file-list el-upload-list el-upload-list--text" name="el-fade-in-linear" tag="ul"> <transition-group class="upload-file-list el-upload-list el-upload-list--text" name="el-fade-in-linear" tag="ul">
<li :key="file.uid" class="el-upload-list__item ele-upload-list__item-content" v-for="(file, index) in fileList"> <li :key="file.uid" class="el-upload-list__item ele-upload-list__item-content" v-for="(file, index) in fileList">
<el-link @click="down(file)" :underline="false" target="_blank"> <el-link @click="down(file)" :underline="false" target="_blank">
<span class="el-icon-document"> {{ getFileName(file.name) }} </span> <span class="el-icon-document"> {{ getFileName(file.name) }} </span>
@ -53,185 +45,164 @@
</div> </div>
</template> </template>
<script setup> <script>
import {getToken} from "@/utils/auth"; import { getAccessToken } from "@/utils/auth";
import {downloadFile} from "@/views/knowledge/views/util/file"; import { downloadFile } from "@/views/knowledge/views/util/file";
const props = defineProps({
modelValue: [String, Object, Array],
position:{
type: String,
default: "bottom",
},
name:{
type: String,
default: "选取文件",
export default {
props: {
value: {
type: [String, Object, Array],
},
position: {
type: String,
default: "bottom",
},
name: {
type: String,
default: "选取文件",
},
buttonType: {
type: String,
default: "common",
},
limit: {
type: Number,
default: 1,
},
fileSize: {
type: Number,
default: 200,
},
fileType: {
type: Array,
default: () => ["doc", "xls", "ppt", "txt", "pdf","mp4","png","jpg","zip","rar","jpeg","xlsx","docx"],
},
isShowTip: {
type: Boolean,
default: true,
},
}, },
uploadFileUrl:{ data() {
type: String, return {
default: "/knowledge/api/uploadfile" number: 0,
uploadList: [],
baseUrl: "",
headers: { Authorization: "Bearer " + getAccessToken() }, //
fileList: [],
uploadFileUrl: process.env.VUE_APP_BASE_API + "/admin-api/infra/file/uploadDetail", //
};
}, },
buttonType:{ computed: {
type: String, showTip() {
default: 'common', return this.isShowTip && (this.fileType || this.fileSize);
},
}, },
// watch: {
limit: { value(val) {
type: Number, if (val) {
default: 1, let temp = 1;
}, const list = Array.isArray(val)? val : this.value.split(",");
// (MB) this.fileList = list.map((item) => {
fileSize: { if (typeof item === "string") {
type: Number, item = { name: item, url: item };
default: 200, }
}, item.uid = item.uid || new Date().getTime() + temp++;
// , ['png', 'jpg', 'jpeg'] return item;
fileType: { });
type: Array, } else {
/*default: () => ["doc", "xls", "ppt", "txt", "pdf"],*/ this.fileList = [];
/*default: () => ['png', 'jpg', 'jpeg',"doc", "xls", "ppt", "txt", "pdf"],*/
default: () => [],
},
//
isShowTip: {
type: Boolean,
default: true
}
});
const {proxy} = getCurrentInstance();
const emit = defineEmits();
const number = ref(0);
const uploadList = ref([]);
const baseUrl = import.meta.env.VITE_APP_BASE_API;
const headers = ref({
Authorization: "Bearer " + getToken(),
'Tenant-id': 1
})
;
const fileList = ref([]);
const showTip = computed(
() => props.isShowTip && (props.fileType || props.fileSize)
);
watch(() => props.modelValue, val => {
if (val) {
let temp = 1;
//
const list = Array.isArray(val) ? val : props.modelValue.split(',');
//
fileList.value = list.map(item => {
if (typeof item === "string") {
item = {name: item, url: item};
} }
item.uid = item.uid || new Date().getTime() + temp++; },
return item; },
}); methods: {
} else { handleBeforeUpload(file) {
fileList.value = []; if (this.fileType.length) {
return []; const name = file.name.split(".");
} const fileExt = name[name.length - 1];
}, {deep: true, immediate: true}); const isTypeOk = this.fileType.indexOf(fileExt) >= 0;
if (!isTypeOk) {
this.$modal.msgError(`文件格式不正确, 请上传${this.fileType.join("/")}格式文件!`);
return false;
}
}
if (this.fileSize) {
const isLt = file.size / 1024 / 1024 < this.fileSize;
if (!isLt) {
this.$modal.msgError(`上传文件大小不能超过 ${this.fileSize} MB!`);
return false;
}
}
this.$modal.loading("正在上传文件,请稍候...");
this.number++;
return true;
},
down(row) {
console.log(row, 162);
downloadFile(row.url, row.name);
},
handleExceed() {
this.$modal.msgError(`上传文件数量不能超过 ${this.limit} 个!`);
},
handleUploadError(err) {
this.$modal.msgError("上传文件失败");
},
handleUploadSuccess(res, file) {
if (res.code === 0) {
if (res.data) {
this.uploadList.push({
name: res.data.name,
url: res.data.url,
size: res.data.size,
});
this.uploadedSuccessfully();
} else {
this.$modal.closeLoading();
// }
function handleBeforeUpload(file) { } else {
this.number--;
this.$modal.closeLoading();
this.$modal.msgError(res.msg);
this.$refs.fileUpload.handleRemove(file);
this.uploadedSuccessfully();
}
},
handleDelete(index) {
this.fileList.splice(index, 1);
this.$emit("input", this.listToString(this.fileList));
},
uploadedSuccessfully() {
if (this.number > 0 && this.uploadList.length === this.number) {
this.fileList = this.fileList.concat(this.uploadList);
this.uploadList = [];
console.log(179,this.fileList)
this.number = 0;
this.$emit("input", this.fileList);
// this.$modal.closeLoading();
if (props.fileType.length) { }
const fileName = file.name.split('.'); },
const fileExt = fileName[fileName.length - 1]; getFileName(name) {
const isTypeOk = props.fileType.indexOf(fileExt) >= 0; if (name.lastIndexOf("/") > -1) {
if (!isTypeOk) { return name.slice(name.lastIndexOf("/") + 1);
proxy.$modal.msgError(`文件格式不正确, 请上传${props.fileType.join("/")}格式文件!`); } else {
return false; return name;
} }
} },
// listToString(list, separator) {
if (props.fileSize) { let strs = "";
const isLt = file.size / 1024 / 1024 < props.fileSize; separator = separator || ",";
if (!isLt) { for (let i in list) {
proxy.$modal.msgError(`上传文件大小不能超过 ${props.fileSize} MB!`); if (list[i].url) {
return false; strs += list[i].url + separator;
} }
} }
proxy.$modal.loading("正在上传文件,请稍候..."); return strs!= ""? strs.substr(0, strs.length - 1) : "";
number.value++; },
return true; },
} };
function down(row){
console.log(row,162)
downloadFile(row.url,row.name)
}
//
function handleExceed() {
proxy.$modal.msgError(`上传文件数量不能超过 ${props.limit} 个!`);
}
//
function handleUploadError(err) {
proxy.$modal.msgError("上传文件失败");
}
//
function handleUploadSuccess(res, file) {
if (res.code === 200) {
if (res.data){
uploadList.value.push({name: res.data.fileName, url: res.data.url, size: res.data.fileSize});
uploadedSuccessfully();
}else {
proxy.$modal.closeLoading();
emit("update:modelValue", fileList.value);
}
} else {
number.value--;
proxy.$modal.closeLoading();
proxy.$modal.msgError(res.msg);
proxy.$refs.fileUpload.handleRemove(file);
uploadedSuccessfully();
}
}
//
function handleDelete(index) {
fileList.value.splice(index, 1);
emit("update:modelValue", listToString(fileList.value));
}
//
function uploadedSuccessfully() {
if (number.value > 0 && uploadList.value.length === number.value) {
fileList.value = fileList.value.filter(f => f.url !== undefined).concat(uploadList.value);
uploadList.value = [];
number.value = 0;
//emit("update:modelValue", listToString(fileList.value));
emit("update:modelValue", fileList.value);
proxy.$modal.closeLoading();
}
}
//
function getFileName(name) {
// url
if (name.lastIndexOf("/") > -1) {
return name.slice(name.lastIndexOf("/") + 1);
} else {
return name;
}
}
//
function listToString(list, separator) {
let strs = "";
separator = separator || ",";
for (let i in list) {
if (list[i].url) {
strs += list[i].url + separator;
}
}
return strs != '' ? strs.substr(0, strs.length - 1) : '';
}
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.upload-file-uploader { .upload-file-uploader {
margin-bottom: 5px; margin-bottom: 5px;

View File

@ -20,6 +20,12 @@ import { parseTime, resetForm, handleTree, addBeginAndEndTime, divide} from "@/u
import Pagination from "@/components/Pagination"; import Pagination from "@/components/Pagination";
// 自定义表格工具扩展 // 自定义表格工具扩展
import RightToolbar from "@/components/RightToolbar" import RightToolbar from "@/components/RightToolbar"
// 图片上传组件
import ImageUpload from "@/components/ImageUpload/index.vue";
// 文件上传组件
import FileUpload from "@/components/FileUpload2/index.vue";
// 图片预览组件
import ImagePreview from "@/components/ImagePreview/index.vue";
// 代码高亮插件 // 代码高亮插件
// import hljs from 'highlight.js' // import hljs from 'highlight.js'
// import 'highlight.js/styles/github-gist.css' // import 'highlight.js/styles/github-gist.css'
@ -43,6 +49,9 @@ Vue.component('DictTag', DictTag)
Vue.component('DocAlert', DocAlert) Vue.component('DocAlert', DocAlert)
Vue.component('Pagination', Pagination) Vue.component('Pagination', Pagination)
Vue.component('RightToolbar', RightToolbar) Vue.component('RightToolbar', RightToolbar)
Vue.component("ImageUpload", ImageUpload);
Vue.component("ImagePreview", ImagePreview);
Vue.component("FileUpload", FileUpload);
// 字典标签组件 // 字典标签组件
import DictTag from '@/components/DictTag' import DictTag from '@/components/DictTag'
import DocAlert from '@/components/DocAlert' import DocAlert from '@/components/DocAlert'
@ -75,7 +84,8 @@ import '@/styles/index.scss'
// 默认点击背景不关闭弹窗 // 默认点击背景不关闭弹窗
import ElementUI from 'element-ui' import ElementUI from 'element-ui'
ElementUI.Dialog.props.closeOnClickModal.default = false ElementUI.Dialog.props.closeOnClickModal.default = false
import dayjs from "dayjs"
Vue.prototype.$dayjs = dayjs;
/** /**
* If you don't want to use mock-server * If you don't want to use mock-server
* you want to use MockJs for mock api * you want to use MockJs for mock api

View File

@ -97,3 +97,50 @@ export function removeTenantId() {
export class getToken { export class getToken {
} }
/**
* 获取预览地址
* @param url 请求地址不带无需带orgin
* @param fullfilename 文件名
* @param watermarkTxt 水印
*/
export function getPreViewUrl(url, fullfilename, watermarkTxt) {
// let Base64 = require('js-base64').Base64
let connectChart = url.indexOf("?") !== -1 ? "&" : "?";
let urlAdded =
website.ossUrl +
url +
connectChart +
"fullfilename=" +
randomString(8) +
"-" +
fullfilename +
"&Authorization=Bearer " +
getToken();
let preViewUrl =
website.preViewUrl + encodeURIComponent(Base64.encode(urlAdded));
if (watermarkTxt) {
preViewUrl += "&watermarkTxt=" + watermarkTxt;
}
return preViewUrl;
}
export function getPreViewUrlForPhone(url, fullfilename, watermarkTxt) {
console.log(url,86)
let connectChart = '&' ;
let urlAdded = website.ossUrl +
url +
connectChart +
'fullfilename=' +
randomString(8) +
'-' +
fullfilename +
'&Authorization=Bearer ' +
"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZGVudGl0eUlkIjoxLCJkZXB0SWQiOjEsIm5pY2tuYW1lIjoiR2xvYmFsIFVzZXIiLCJ0ZW5hbnQtaWQiOjEsInVzZXJuYW1lIjoiR2xvYmFsIFVzZXIiLCJleHAiOjE5NzU2NTcyNzZ9.VuFK-ubqp54VwSL3O8yprt7lMWkc77jfSboxUXtRqQ4";
let preViewUrl =
"https://ylgfscgk.ylgf.com:17031/kkPreview/onlinePreview?url=" + encodeURIComponent(Base64.encode(urlAdded))
console.log(urlAdded,90)
if (watermarkTxt) {
preViewUrl += ('&watermarkTxt=' + watermarkTxt)
}
return preViewUrl;
}

View File

@ -208,5 +208,42 @@ function handleAuthorized() {
} }
return Promise.reject('无效的会话,或者会话已过期,请重新登录。') return Promise.reject('无效的会话,或者会话已过期,请重新登录。')
} }
let downloadLoadingInstance;
// 通用下载方法
export function download(url, params, filename, config) {
downloadLoadingInstance = ElLoading.service({text: "正在下载数据,请稍候", background: "rgba(0, 0, 0, 0.7)",})
return axios.post(url, params, {
transformRequest: [(params) => {
return tansParams(params)
}],
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
responseType: 'blob',
...config
}).then(async (data) => {
const isBlob = blobValidate(data.data);
if (isBlob) {
let blob = new Blob([data.data], {type: "application/vnd.ms-excel"}); // 设置文件类型excel
let url = window.URL.createObjectURL(blob); // 创建一个临时的url指向blob对象
// 创建url之后可以模拟对此文件对象的一系列操作例如预览、下载
let a = document.createElement("a");
a.href = url;
a.download = filename + ".xlsx";
a.click();
// 释放这个临时的对象url
window.URL.revokeObjectURL(url);
} else {
const resText = await data.data.text();
const rspObj = JSON.parse(resText);
const errMsg = errorCode[rspObj.code] || rspObj.msg || errorCode['default']
ElMessage.error(errMsg);
}
downloadLoadingInstance.close();
}).catch((r) => {
console.error(r)
ElMessage.error('下载文件出现错误,请联系管理员!')
downloadLoadingInstance.close();
})
}
export default service export default service

View File

@ -36,9 +36,9 @@
<div class="right-box-top"> <div class="right-box-top">
<div class="left-ds-box"> <div class="left-ds-box">
<div style="display: flex; align-items: center"> <div style="display: flex; align-items: center">
<el-button class="lan-bottom" @click="centerDialogVisible = true" v-if="tabIndex != 6">上传文件</el-button> <el-button class="lan-bottom" @click="openUpload()" v-if="tabIndex != 6">上传文件</el-button>
<el-button class="lan-bottom" @click="Bfolder()" v-if="tabIndex != 6">新建文件夹</el-button> <el-button class="lan-bottom" @click="Bfolder()" v-if="tabIndex != 6">新建文件夹</el-button>
<el-button class="dlan-bottom" @click="handleExport()" v-if="tabIndex != 6">批量导出</el-button>
<el-button class="hong-bottom" v-if="tabIndex != 6" @click="handleDelete">批量删除</el-button> <el-button class="hong-bottom" v-if="tabIndex != 6" @click="handleDelete">批量删除</el-button>
<el-button class="hong-bottom" v-if="tabIndex == 6" @click="handleRealDelete">批量删除</el-button> <el-button class="hong-bottom" v-if="tabIndex == 6" @click="handleRealDelete">批量删除</el-button>
<el-button class="hong-bottom" @click="returnDir" v-if="tabIndex != 6">返回</el-button> <el-button class="hong-bottom" @click="returnDir" v-if="tabIndex != 6">返回</el-button>
@ -46,7 +46,7 @@
<div class="input-box"> <div class="input-box">
<!-- <input type="text" @input="findAllDocLists()" v-model="queryParams.originalFilename" placeholder="输入搜索关键词"> --> <!-- <input type="text" @input="findAllDocLists()" v-model="queryParams.originalFilename" placeholder="输入搜索关键词"> -->
<el-input @input="findAllDocLists()" v-model="queryParams.originalFilename" placeholder="输入搜索关键词" :prefix-icon="Search"/> <el-input @input="findAllDocLists()" v-model="queryParams.originalFilename" placeholder="输入搜索关键词" />
</div> </div>
</div> </div>
<el-table <el-table
@ -61,15 +61,15 @@
<el-table-column property="curFilename" label="名称" width="360"> <el-table-column property="curFilename" label="名称" width="360">
<template #default="scope"> <template #default="scope">
<div style="display: flex;align-items: center" @click="shijian(scope.row)"> <div style="display: flex;align-items: center" @click="shijian(scope.row)">
<img src="/src/views/knowledge/assets/images/wjj.png" v-if=" scope.row.type == '0' " @click="enterDir(scope.row)" <img src="../../assets/images/wjj.png" v-if=" scope.row.type == '0' " @click="enterDir(scope.row)"
style="width: 28px; height: 28px;margin-right: 5px"> style="width: 28px; height: 28px;margin-right: 5px">
<img src="/src/views/knowledge/assets/images/wd.png" v-if=" scope.row.type == '3' " @click="view(scope.row)" <img src="../../assets/images/wd.png" v-if=" scope.row.type == '3' " @click="view(scope.row)"
style="width: 28px; height: 28px;margin-right: 5px"> style="width: 28px; height: 28px;margin-right: 5px">
<img src="/src/views/knowledge/assets/images/zp.png" v-if=" scope.row.type == '1' " @click="view(scope.row)" <img src="../../assets/images/zp.png" v-if=" scope.row.type == '1' " @click="view(scope.row)"
style="width: 28px; height: 28px;margin-right: 5px"> style="width: 28px; height: 28px;margin-right: 5px">
<img src="/src/views/knowledge/assets/images/yp.png" v-if=" scope.row.type == '4' " @click="view(scope.row)" <img src="../../assets/images/yp.png" v-if=" scope.row.type == '4' " @click="view(scope.row)"
style="width: 28px; height: 28px;margin-right: 5px"> style="width: 28px; height: 28px;margin-right: 5px">
<img src="/src/views/knowledge/assets/images/sp.png" v-if=" scope.row.type == '2' " @click="view(scope.row)" <img src="../../assets/images/sp.png" v-if=" scope.row.type == '2' " @click="view(scope.row)"
style="width: 28px; height: 28px;margin-right: 5px"> style="width: 28px; height: 28px;margin-right: 5px">
<div v-if="scope.row.curFilename" style="cursor:pointer" > {{ scope.row.curFilename }}</div> <div v-if="scope.row.curFilename" style="cursor:pointer" > {{ scope.row.curFilename }}</div>
<div v-else > {{ scope.row.curFilename }}</div> <div v-else > {{ scope.row.curFilename }}</div>
@ -78,7 +78,9 @@
</el-table-column> </el-table-column>
<el-table-column property="fileSize" label="大小"> <el-table-column property="fileSize" label="大小">
<template #default="scope"> <template #default="scope">
<span>{{ scope.row.fileSize }}KB</span> <span >{{ (scope.row.fileSize/(1024*1024)).toFixed(1) }}MB</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column property="type" label="类型"> <el-table-column property="type" label="类型">
@ -92,7 +94,7 @@
</el-table-column> </el-table-column>
<el-table-column property="createTime" label="创建时间" v-if="tabIndex != 6 "> <el-table-column property="createTime" label="创建时间" v-if="tabIndex != 6 ">
<template #default="scope"> <template #default="scope">
<span>{{ scope.row.createTime }}</span> <span>{{ formatDate(scope.row.createTime) }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column property="updateTime" label="删除日期" v-if="tabIndex == 6 "> <el-table-column property="updateTime" label="删除日期" v-if="tabIndex == 6 ">
@ -117,10 +119,10 @@
</div> </div>
</div> </div>
</div> </div>
<el-dialog v-model="centerDialogVisible" title="上传文件" width="500" center> <el-dialog :visible.sync="centerDialogVisible" title="上传文件" width="500" center>
<div style="display: flex"> <div style="display: flex">
<span style="color: red;margin-right: 10px">*</span> <span style="color: red;margin-right: 10px">*</span>
<FileUpload v-if="centerDialogVisible" @update:modelValue="uploadUrl" :limit="5"></FileUpload> <FileUpload v-if="centerDialogVisible" v-model="fileInfos" :limit="5"></FileUpload>
</div> </div>
<template #footer> <template #footer>
<div class="dialog-footer"> <div class="dialog-footer">
@ -131,7 +133,7 @@
</div> </div>
</template> </template>
</el-dialog> </el-dialog>
<el-dialog v-model="folder" title="新建文件夹" width="500" center> <el-dialog :visible.sync="folder" title="新建文件夹" width="500" center>
<div class="wj-box"> <div class="wj-box">
<div><span style="color: red">*</span> 名称</div> <div><span style="color: red">*</span> 名称</div>
<el-input v-model="form.curFilename" style="width: 240px" placeholder="请输入新建文件夹名称"/> <el-input v-model="form.curFilename" style="width: 240px" placeholder="请输入新建文件夹名称"/>
@ -149,304 +151,289 @@
</div> </div>
</template> </template>
<script setup name="archives"> <script>
import {findAll, save, delByIds, ackDelete, restore,getParentId,findAllDocList} from "@/api/knowledge/tarchives/tarchives"; import { findAll, save, delByIds, ackDelete, restore, getParentId, findAllDocList } from "@/api/knowledge/tarchives/tarchives";
import {getPreViewUrl} from "utils/auth"; import { getPreViewUrl } from "@/utils/auth";
import {downloadFileUrl,downloadFile} from "../util/file" import { downloadFileUrl, downloadFile } from "../util/file";
import {Search} from '@element-plus/icons-vue';
const loading = ref(true);
const {proxy} = getCurrentInstance();
const tabIndex = ref(1);
const folder = ref(false) export default {
const input = ref('') data() {
const parentId = ref('') return {
const tableData = ref([]); loading: true,
const ids = ref(null); tabIndex: 1,
const idList = ref(null); folder: false,
const selectIds = ref(null); input: '',
const total = ref(0); parentId: '',
const data = reactive({ tableData: [],
form: {}, ids: null,
queryParams: { idList: null,
originalFilename: "", selectIds: null,
parentId: null, total: 0,
isRecycled: 1, form: {},
type: null, queryParams: {
pageNo: 1, originalFilename: "",
pageSize: 10 parentId: null,
isRecycled: 1,
type: null,
pageNo: 1,
pageSize: 10
},
rules: {
parentId: [{ required: true, message: "上级部门不能为空", trigger: "blur" }],
deptName: [{ required: true, message: "部门名称不能为空", trigger: "blur" }],
orderNum: [{ required: true, message: "显示排序不能为空", trigger: "blur" }],
email: [{ type: "email", message: "请输入正确的邮箱地址", trigger: ["blur", "change"] }],
phone: [{ pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, message: "请输入正确的手机号码", trigger: "blur" }]
},
centerDialogVisible: false,
presentId: null,
fileInfos: []
};
}, },
methods: {
formatDate(value) {
const date = new Date(value);
// 使toISOStringYYYY-MM-DD
const isoString = date.toISOString();
// ISO
return isoString.slice(0, 10);
rules: { },
parentId: [{required: true, message: "上级部门不能为空", trigger: "blur"}], padLeftZero(str) {
deptName: [{required: true, message: "部门名称不能为空", trigger: "blur"}], return ('00' + str).substr(str.length)
orderNum: [{required: true, message: "显示排序不能为空", trigger: "blur"}], },
email: [{type: "email", message: "请输入正确的邮箱地址", trigger: ["blur", "change"]}],
phone: [{pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, message: "请输入正确的手机号码", trigger: "blur"}] openUpload(){
console.log(193)
this.centerDialogVisible = true
},
/**
* 上传文件
*/
uploadUrl(obj) {
this.fileInfos = obj;
},
cancel() {
this.centerDialogVisible = false;
this.fileInfos = [];
},
addFile() {
console.log(this.fileInfos,207)
if (!this.fileInfos) {
this.$modal.msgError("请选择文件");
return;
}
this.fileInfos.forEach(fileInfo => {
let data = {
parentId: this.presentId,
originalFilename: fileInfo.name,
fileUrl: fileInfo.url,
fileSize: fileInfo.size
};
save(data).then(res => {
if (res.code === 200) {
this.folder = false;
this.form = {};
} else {
// this.$modal.msgError(res.data.msg);
}
this.getList();
this.centerDialogVisible = false
});
});
this.$modal.msgSuccess("上传成功");
},
shijian(data) {
if (data.type === '0') {
this.enterDir(data);
} else {
this.view(data);
}
},
enterDir(data) {
this.queryParams.pageNo = 1;
if (data.isRecycled === 1 && data.isDir === 0) {
this.queryParams.parentId = data.id;
this.parentId = data.id;
this.form.parentId = data.id;
this.getList();
}
this.presentId = data.id;
},
returnDir() {
let data = {
id: this.presentId
};
this.queryParams.pageNo = 1;
getParentId(data).then(res => {
if (res.data.parentId) {
this.queryParams.parentId = res.data.parentId;
this.form.parentId = res.data.parentId;
this.presentId = res.data.parentId;
} else {
this.queryParams.parentId = '';
this.form.parentId = '';
}
this.getList();
});
},
//
handleSelectionChange(selection) {
let tempId = selection.map(item => item.id);
this.selectIds = tempId.join(',');
this.ids = tempId.join(',');
},
/** 文件查看 */
getList() {
this.loading = true;
findAll(this.queryParams).then(response => {
console.log(response,274)
this.tableData = response.data.records;
this.total = response.data.total;
this.loading = false;
});
},
pageCurrentChangeHandle(val) {
this.loading = true;
this.queryParams.pageNo = val;
findAll(this.queryParams).then(response => {
this.tableData = response.data.records;
this.total = response.data.total;
this.loading = false;
});
},
pageSizeChangeHandle(val) {
this.loading = true;
this.queryParams.pageNo = 1;
this.queryParams.pageSize = val;
findAll(this.queryParams).then(response => {
this.tableData = response.data.records;
this.total = response.data.total;
this.loading = false;
});
},
/** 文件查看 */
findAllDocLists() {
this.loading = true;
findAllDocList(this.queryParams).then(response => {
this.tableData = response.data.records;
this.total = response.data.total;
this.loading = false;
});
},
clickType(type, idx) {
this.queryParams.pageNo = 1;
this.tableData = [];
this.form.parentId = null;
this.tabIndex = idx;
this.loading = true;
this.queryParams.parentId = null;
this.queryParams.isRecycled = 1;
this.queryParams.type = type;
this.getList();
},
getListRecycled(idx) {
this.tabIndex = idx;
this.loading = true;
this.queryParams.type = null;
this.queryParams.parentId = null;
this.queryParams.isRecycled = 0;
this.getList();
},
closeDir() {
this.form = {};
this.folder = false;
},
/** 文件保存 */
createDir() {
if (!this.form.curFilename) {
this.$modal.msgWarning("请填写文件名称");
return;
}
if (this.form.id!== undefined) {
save(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.folder = false;
this.getList();
});
} else {
save(this.form).then(response => {
if (response.code === 200) {
this.$modal.msgSuccess("新增成功");
this.folder = false;
this.form = {};
this.getList();
} else {
this.$modal.msgError(response.msg);
}
});
}
},
/** 文件删除 */
handleDelete(row) {
const ids = row.id || this.selectIds;
this.$modal.confirm('是否确认删除此项数据?').then(() => {
let data = {
ids: ids
};
return delByIds(data);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {
});
},
/** 彻底删除 */
handleRealDelete(row) {
const ids = row.id || this.selectIds;
this.$modal.confirm('是否确认删除此项数据?').then(() => {
let data = {
ids: ids
};
return ackDelete(data);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {
});
},
handleExport() {
this.$download("/knowledge/system/tArchives/export", this.queryParams, `档案管理_${new Date().getTime()}`);
},
/** 还原 */
restores(row) {
const ids = row.id || this.ids;
this.$modal.confirm('是否确认还原此项数据?').then(() => {
let data = {
ids: ids
};
return restore(data);
}).then(() => {
this.getList();
this.$modal.msgSuccess("还原成功");
}).catch(() => {
});
},
down(row) {
downloadFile(row.fileUrl,row.originalFilename);
},
view(row) {
var preViewUrl = getPreViewUrl(downloadFileUrl + "?fileName=" + row.fileUrl, row.fileUrl, "连铝");
window.open(preViewUrl);
},
Bfolder() {
this.folder = true;
}
}, },
}); created() {
this.getList();
const {queryParams, form, rules} = toRefs(data);
/**
* 上传文件
*/
const centerDialogVisible = ref(false);
const presentId = ref(null);
const fileInfos = ref([])
function uploadUrl(obj) {
fileInfos.value = obj
}
function cancel(){
centerDialogVisible.value = false;
fileInfos.value = []
}
function addFile() {
if (!fileInfos.value) {
console.log("211",fileInfos.value)
proxy.$modal.msgError("请选择文件")
return
} }
if (fileInfos.value.length > 5) { };
proxy.$modal.msgError("最多只能选择五个文件")
return;
}
// const fileInfo = fileInfos.value[0]
fileInfos.value.forEach(fileInfo => {
console.log(fileInfo);
let data = {
parentId: presentId.value, originalFilename: fileInfo.name,
fileUrl: fileInfo.url, fileSize: fileInfo.size
}
save(data).then(res => {
console.log(res,229)
centerDialogVisible.value = false
if (res.data.code==200){
folder.value = false;
form.value = {}
}else {
// proxy.$modal.msgError(res.data.msg);
}
})
});
proxy.$modal.msgSuccess("上传成功");
getList();
}
function shijian(data) {
if (data.type == '0'){
enterDir(data)
}else {
view(data)
}
}
function enterDir(data) {
queryParams.value.pageNo =1;
if (data.isRecycled == 1 && data.isDir == 0) {
queryParams.value.parentId = data.id
parentId.value = data.id
form.value.parentId = data.id
getList()
}
presentId.value = data.id
}
function returnDir() {
let data = {
id:presentId.value
}
queryParams.value.pageNo =1;
getParentId(data).then((res=>{
console.log("260",res.data.data)
if (res.data.data.data.parentId){
queryParams.value.parentId = res.data.data.data.parentId
form.value.parentId = res.data.data.data.parentId
presentId.value = res.data.data.data.parentId
}else {
queryParams.value.parentId = ''
form.value.parentId = ''
console.log("267",res.data.data.data.parentId)
}
getList()
}))
}
//
function handleSelectionChange(selection) {
console.log("266",selection)
let tempId = selection.map(item => item.id)
selectIds.value = tempId.join(',')
ids.value = tempId.join(',')
console.log("271",ids.value)
}
/** 文件查看 */
function getList() {
loading.value = true;
findAll(queryParams.value).then(response => {
console.log(response)
tableData.value = response.data.data.records;
total.value = response.data.data.total;
loading.value = false;
});
}
function pageCurrentChangeHandle(val) {
loading.value = true;
queryParams.value.pageNo = val;
findAll(queryParams.value).then(response => {
console.log(response)
tableData.value = response.data.data.records;
total.value = response.data.data.total;
loading.value = false;
});
}
function pageSizeChangeHandle(val) {
loading.value = true;
queryParams.value.pageNo = 1;
queryParams.value.pageSize = val;
findAll(queryParams.value).then(response => {
console.log(response)
tableData.value = response.data.data.records;
total.value = response.data.data.total;
loading.value = false;
});
}
/** 文件查看 */
function findAllDocLists() {
loading.value = true;
findAllDocList(queryParams.value).then(response => {
console.log(response)
tableData.value = response.data.data.records;
total.value = response.data.data.total;
loading.value = false;
});
}
function clickType(type, idx) {
queryParams.value.pageNo = 1;
tableData.value = [];
form.value.parentId = null;
tabIndex.value = idx
loading.value = true;
queryParams.value.parentId = null
queryParams.value.isRecycled = 1
queryParams.value.type = type
getList()
}
function getListRecycled(idx) {
tabIndex.value = idx
loading.value = true;
queryParams.value.type = null
queryParams.value.parentId = null
queryParams.value.isRecycled = 0
getList()
}
function closeDir() {
form.value = {}
folder.value = false;
}
/** 文件jia保存 */
function createDir() {
console.log("286",form.value)
if (!form.value.curFilename) {
proxy.$modal.msgWarning("请填写文件名称");
return
}
if (form.value.id != undefined) {
save(form.value).then(response => {
proxy.$modal.msgSuccess("修改成功");
folder.value = false;
getList();
});
} else {
save(form.value).then(response => {
console.log("301",response.data)
if (response.data.code==200){
proxy.$modal.msgSuccess("新增成功");
folder.value = false;
form.value = {}
getList();
}else {
proxy.$modal.msgError(response.data.msg);
}
});
}
}
/** 文件删除 */
function handleDelete(row) {
const ids = row.id || selectIds.value;
proxy.$modal.confirm('是否确认删除此项数据?').then(function () {
let data = {
ids: ids
}
return delByIds(data);
}).then(() => {
getList();
proxy.$modal.msgSuccess("删除成功");
}).catch(() => {
});
}
/** 彻底删除 */
function handleRealDelete(row) {
const ids = row.id || selectIds.value;
proxy.$modal.confirm('是否确认删除此项数据?').then(function () {
let data = {
ids: ids
}
return ackDelete(data);
}).then(() => {
getList();
proxy.$modal.msgSuccess("删除成功");
}).catch(() => {
});
}
function handleExport(){
proxy.download("/knowledge/system/tArchives/export", queryParams.value, `档案管理_${new Date().getTime()}`);
}
/** 还原 */
function restores(row) {
const ids = row.id || ids.value;
proxy.$modal.confirm('是否确认还原此项数据?').then(function () {
let data = {
ids: ids
}
return restore(data);
}).then(() => {
getList();
proxy.$modal.msgSuccess("还原成功");
}).catch(() => {
});
}
function down(row){
downloadFile(row.fileUrl,row.originalFilename)
}
function view(row){
var preViewUrl = getPreViewUrl(downloadFileUrl+"?fileName="+row.fileUrl,row.fileUrl,"连铝");
window.open(preViewUrl);
}
function Bfolder() {
folder.value = true
}
getList()
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.centenr { .centenr {

View File

@ -1,7 +1,5 @@
import request from "@/axios" import request from '@/utils/request'
import website from "@/config/website"; import {getToken} from "@/utils/auth";
import {Base64} from "js-base64";
import {getToken} from "utils/auth";
const apiUrl = `/knowledge/api` const apiUrl = `/knowledge/api`
@ -49,7 +47,7 @@ export const deleteFile = fileCode => {
// 文件下载 // 文件下载
export const downloadFile = (url,fileName) => { export const downloadFile = (url,fileName) => {
request({ request({
url: downloadFileUrl+"?fileName=" + url, url: url,
method: 'get', method: 'get',
responseType: 'blob' responseType: 'blob'
}).then(res => { }).then(res => {