fix : 文件下载路径(总部文件)

This commit is contained in:
zty 2024-05-27 14:10:36 +08:00
parent 2ae5c21a1a
commit 28e2cc84e2
7 changed files with 115 additions and 16 deletions

File diff suppressed because one or more lines are too long

View File

@ -117,6 +117,15 @@ export function createPaper(data) {
data
})
}
//导入试卷
export function UploadPaper(data) {
return request({
url: `/exam/paper/upload_paper/`,
method: 'post',
data
})
}
//编辑试卷
export function updatePaper(id, data) {
return request({

View File

@ -30,7 +30,7 @@
<el-table-column type="index" width="50" />
<el-table-column label="名称" min-width="110">
<template slot-scope="scope" v-if="scope.row.file_.file">
<a v-if="scope.row.file_.file.indexOf('.pdf')>-1 " :href="`/static/build/generic/web/viewer.html?file=${scope.row.file_.file}`" target="view_window" class="flv">
<a v-if="scope.row.file_.file.indexOf('.pdf')>-1 " :href="scope.row.file_.file" target="view_window" class="flv">
<el-link type="primary">{{ scope.row.name }}</el-link>
</a>
<el-link v-else :href="scope.row.file_.file" type="primary">{{ scope.row.name }}</el-link>

View File

@ -153,9 +153,9 @@
</el-option>
</el-select>
</el-form-item>
<el-form-item label="考试部门" prop="participant_dep" style="width:100%" clearable>
<el-form-item label="考试部门" prop="participant_dep" style="width:100%" clearable collapse-tags filterable >
<el-button @click="selectAll">全选部门</el-button>
<el-select v-model="exam.participant_dep" multiple placeholder = "选择部门" >
<el-select v-model="exam.participant_dep" multiple collapse-tags filterable placeholder = "选择部门" >
<el-option
v-for="item in depOptions"
:key = "item.id"
@ -166,7 +166,7 @@
</el-form-item>
<el-form-item label="考试人员" prop="participant_user" style="width:100%" clearable>
<el-select v-model="exam.participant_user" multiple placeholder = "请选择人员">
<el-select v-model="exam.participant_user" multiple filterable placeholder = "请选择人员">
<el-option
v-for="item in userOptions"
:key = "item.id"
@ -174,6 +174,15 @@
:value = "item.id">
</el-option>
</el-select>
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="currentPage"
:page-sizes="[10, 20, 30, 40]"
:page-size="pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="total"
></el-pagination>
</el-form-item>
</el-form>
<div style="text-align:right;">
@ -230,6 +239,9 @@
dialogType: "new",
workscopeOptions:[],
paperOptions:[],
currentPage: 1, // 当前页码
pageSize: 10, // 每页显示的条数
total: 0, // 总条数
rule1: {
name: [{ required: true, message: "请输入", trigger: "blur" }],
place: [{ required: true, message: "请输入", trigger: "change" }],
@ -248,6 +260,7 @@
this.getList();
this.getCourseList();
this.getDepartmentList();
this.getUser();
},
methods: {
checkPermission,
@ -268,16 +281,27 @@
this.listLoading = false;
});
},
handleSizeChange(val) {
// 改变每页显示的条数
this.pageSize = val;
this.getUser();
},
handleCurrentChange(val) {
// 改变当前页码
this.currentPage = val;
this.getUser();
},
getDepartmentList(){
getDepartment().then(response =>{
this.depOptions = response.data
return this.depOptions
})
},
getUserList(){
getUserList().then(response =>{
this.userOptions = response.data
console.log(this.userOptions)
getUser(){
getUserList({page: this.currentPage, size: this.pageSize}).then(response =>{
this.userOptions = response.data.results
this.total = response.data.total;
// console.log(this.userOptions)
})
},
getCourseList(){

View File

@ -24,8 +24,12 @@
<div style="text-align: left; margin: 0;">
<el-link href="/media/muban/question.xlsx" target="_blank" @click="popovervisible = false"
type="primary">下载模板</el-link>
<el-upload :action="upUrl" :on-success="handleUploadSuccess" accept=".xlsx" :headers="upHeaders"
:show-file-list="false">
<el-upload
:action="upUrl"
:on-success="handleUploadSuccess"
accept=".xlsx"
:headers="upHeaders"
:show-file-list="false">
<el-button size="small" type="primary" @click="popovervisible = false">上传导入</el-button>
</el-upload>
</div>
@ -153,8 +157,9 @@ export default {
methods: {
checkPermission,
handleUploadSuccess(res, file) {
if (res.code == 200) {
if (res.code == 201) {
const loading = this.$loading({ text: "正在导入中..." })
console.log(res.data);
importQuestion(res.data).then(response => {
loading.close()
if (response.code == 200) {

View File

@ -45,7 +45,20 @@
</el-col>
<el-col :span="16">
<h3>选题信息</h3>
<el-button type="primary" @click="handleChoose" icon="el-icon-plus">选择试题</el-button>
<!-- <div> -->
<div style="display: flex;">
<el-button type="primary" @click="handleChoose" icon="el-icon-plus" style="margin-right: 10px;">选择试题</el-button>
<el-upload
:action="upUrl"
:on-success="handleUpSuccess"
:on-remove="handleRemove"
:headers="upHeaders"
:file-list="fileList"
:limit="1"
accept=".doc,.docx">
<el-button icon="el-icon-plus" type="primary" >上传试题</el-button>
</el-upload>
</div>
<div v-for="(item, index) in questions">
<h4>
<el-button
@ -61,19 +74,37 @@
</h4>
<div v-for="(value, name) in item.options">{{ name }}: {{ value }}</div>
</div>
<div v-for="(item, index) in up_questions">
<h4>
<el-button
type="danger"
size="small"
@click="handleDeleteUp(index)"
icon="el-icon-delete"
></el-button>
{{ index+1 }} -
<el-tag>{{item.type}}</el-tag>
{{ item.name }}
<span>(正确答案:{{item.right}})</span>
</h4>
<div v-for="(value, name) in item.options">{{ name }}: {{ value }}</div>
</div>
</el-col>
</el-row>
<Questionchoose v-bind:chooseVisible="chooseVisible" @closeDg="closeDg" @choseQ="choseQ"></Questionchoose>
</div>
</template>
<script>
import { getQuestioncatList, createPaper } from "@/api/exam";
import { getQuestioncatList, createPaper, UploadPaper } from "@/api/exam";
import Questionchoose from "@/views/exam/questionChoose";
import { upUrl, upHeaders } from "@/api/file";
export default {
components: { Questionchoose },
data() {
return {
questions: [],
up_questions: [],
Form: {
name: "",
// workscope: null,
@ -81,6 +112,7 @@
total_score: 0,
pass_score: 60,
questions_: [],
uo_questions: [],
danxuan_score: 2,
danxuan_count: 0,
duoxuan_score: 4,
@ -88,7 +120,13 @@
panduan_score: 2,
panduan_count: 0
},
upUrl: upUrl(),
fileList: [],
upHeaders: upHeaders(),
submitLoding: false,
impForm:{
doc_path:''
},
rules: {
name: [
{ required: true, message: "名称不能为空", trigger: "blur" }
@ -118,6 +156,27 @@
this.workscopeData = response.data.results;
});
},
handleUpSuccess(res, file, filelist) {
if (res.code == 201){
// this.impForm.file = res.data.path;
this.impForm.doc_path = "C:\\code\\data\\test.docx";
console.log(this.impForm)
UploadPaper(this.impForm).then(res => {
if (res.code == 200) {
this.up_questions == res.data;
this.$message({
type: "success",
message: "上传成功"
})
}
}
)
}
},
handleRemove() {
this.fileList = [];
this.impForm.file = '';
},
submitForm(formName) {
this.$refs[formName].validate(valid => {
if (valid) {
@ -155,6 +214,9 @@
handleDelete(val) {
this.questions.splice(val, 1);
},
handleDeleteUp(val) {
this.up_questions.splice(val, 1);
},
calScore() {
let danxuan_count = 0,
duoxuan_count = 0,

View File

@ -136,7 +136,7 @@
accept=".doc,.docx,.xls,.xlsx,.ppt,.pptx,.pdf,.zip">
<el-button size="small" type="primary">上传文件</el-button>
</el-upload>
</el-form-item>
</el-form-item>``
</el-form>
<div style="text-align: right">
<el-button type="danger" @click="close_dialog">取消</el-button>
@ -352,7 +352,6 @@ export default {
handleUpSuccess(res, file, filelist) {
this.Content.file = res.data.id;
this.impForm.file = res.data.path;
},
handleRemove(file, filelist) {
this.Content.file = null;