bug 修改
parent
5299838758
commit
ba444ed6c8
@ -0,0 +1,30 @@
|
||||
import request from '@/utils/request'
|
||||
let baseUrl = '/pc/competition/member/'
|
||||
|
||||
export function add(cat) {
|
||||
return request({
|
||||
url: baseUrl+"add",
|
||||
method: 'post',
|
||||
data: cat
|
||||
})
|
||||
}
|
||||
|
||||
export function uploadExcel(obj){
|
||||
let fd = new FormData()
|
||||
if(obj instanceof Object){
|
||||
Object.keys(obj).forEach(key =>{
|
||||
const o = obj[key]
|
||||
console.log(o)
|
||||
if(o instanceof Object){
|
||||
fd.append(key,o)
|
||||
}else{
|
||||
fd.append(key,o)
|
||||
}
|
||||
})
|
||||
}
|
||||
return request({
|
||||
url: "/api/competition/upload/importMember",
|
||||
method: 'post',
|
||||
data: fd
|
||||
})
|
||||
}
|
@ -1,5 +1,173 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
akdk
|
||||
<div class="tz-line">
|
||||
<el-button @click="dialogFormVisible = false">返回</el-button>
|
||||
<el-button type="primary">确认</el-button>
|
||||
</div>
|
||||
<div class="tz-line2">
|
||||
<el-button :loading="downloadLoading" style="margin:0 0 20px 0;" type="primary" icon="el-icon-download" @click="handleDownload">
|
||||
批量导入模板下载
|
||||
</el-button>
|
||||
|
||||
<el-button :loading="uploading" style="margin:0 20px 20px 20px;" type="primary" icon="el-icon-upload" @click="handelUpload">
|
||||
批量导入
|
||||
<input ref="uploadExcel" type="file" accept=".xlsx" style="display:none;" @change="uploadExcel">
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<!-- <upload-excel-component :on-success="handleSuccess" :before-upload="beforeUpload" /> -->
|
||||
<el-table
|
||||
v-loading="listLoading"
|
||||
:data="list"
|
||||
element-loading-text="Loading"
|
||||
border
|
||||
fit
|
||||
highlight-current-row
|
||||
>
|
||||
<el-table-column label="题干" align="center">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ scope.row.stem }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="题型">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.questionType }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="题目ID" align="center">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ scope.row.id }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="归属课程" align="center">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ scope.row.courseName }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="状态" align="center">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ scope.row.status }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import * as questionApi from '@/api/question'
|
||||
|
||||
export default {
|
||||
filters: {
|
||||
statusFilter(status) {
|
||||
const statusMap = {
|
||||
published: 'success',
|
||||
draft: 'info',
|
||||
deleted: 'danger'
|
||||
}
|
||||
return statusMap[status]
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
list: null,
|
||||
listLoading: false,
|
||||
listQuery: {
|
||||
pageNo: 0
|
||||
},
|
||||
downloadLoading: false,
|
||||
uploading: false,
|
||||
total: 0,
|
||||
limit: 20,
|
||||
textMap: {
|
||||
update: 'Edit',
|
||||
create: 'Create'
|
||||
},
|
||||
dialogFormVisible: false,
|
||||
provincOtions: [{
|
||||
id: '1',
|
||||
name: '北京'
|
||||
}],
|
||||
regionOptions: [{
|
||||
id: 1,
|
||||
name: '东南地区'
|
||||
}],
|
||||
levelOtions: [{
|
||||
id: 1,
|
||||
name: '本科'
|
||||
}],
|
||||
dialogStatus: '',
|
||||
statusOptions: ['published', 'draft', 'deleted'],
|
||||
temp: {
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.fetchData()
|
||||
},
|
||||
methods: {
|
||||
fetchData() {
|
||||
// this.listLoading = true
|
||||
},
|
||||
beforeUpload(file) {
|
||||
const isLt1M = file.size / 1024 / 1024 < 1
|
||||
|
||||
if (isLt1M) {
|
||||
return true
|
||||
}
|
||||
|
||||
this.$message({
|
||||
message: 'Please do not upload files larger than 1m in size.',
|
||||
type: 'warning'
|
||||
})
|
||||
return false
|
||||
},
|
||||
handleSuccess({ results, header }) {
|
||||
this.tableData = results
|
||||
this.tableHeader = header
|
||||
},
|
||||
handleDownload() {
|
||||
location.href = "/excel/questionTemplate.xlsx"
|
||||
// this.downloadLoading = true
|
||||
// import('@/vendor/Export2Excel').then(excel => {
|
||||
// const tHeader = ['学号', '姓名', '学校', '电话', '省份',"学校层次"]
|
||||
// excel.export_json_to_excel({
|
||||
// header: tHeader,
|
||||
// filename: 'userTemplate',
|
||||
// data:[ ['202203929','张三','天泽大学','18999999999','北京市','本科']],
|
||||
// autoWidth: true,
|
||||
// bookType: 'xlsx'
|
||||
// })
|
||||
// this.downloadLoading = false
|
||||
// })
|
||||
},
|
||||
handelUpload(){
|
||||
this.$refs['uploadExcel'].click()
|
||||
},
|
||||
uploadExcel(e){
|
||||
this.uploading = true
|
||||
|
||||
const files = e.target.files
|
||||
const rawFile = files[0] // only use files[0]
|
||||
questionApi.importExcel({
|
||||
file: rawFile
|
||||
}).then(res=>{
|
||||
if(res.code == 200){
|
||||
this.list = res.data.list
|
||||
this.uploading =false
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
.tz-line{
|
||||
display: flex;
|
||||
width: 100%;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.tz-line button{
|
||||
margin-right: 10px;
|
||||
width: 100px;
|
||||
}
|
||||
</style>
|
||||
|
Loading…
Reference in New Issue