This commit is contained in:
Li xia 2024-09-10 16:50:53 +08:00
parent 34dea64d3d
commit d01a56caec
3 changed files with 521 additions and 456 deletions

View File

@ -16,17 +16,17 @@
:value="item.value"
/>
</el-select>
<el-date-picker
v-model="value"
type="daterange"
align="right"
unlink-panels
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
:picker-options="pickerOptions">
</el-date-picker>
<el-input
<el-date-picker
v-model="value"
type="daterange"
align="right"
unlink-panels
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
:picker-options="pickerOptions"
/>
<el-input
v-model="listQuery.search"
placeholder="输入用户名或用户单位名搜索"
style="width: 200px;"
@ -39,30 +39,29 @@
icon="el-icon-refresh-left"
@click="resetFilter"
>刷新重置</el-button>
<el-button type="primary" icon="el-icon-download" @click="exportTest" >导出Excel</el-button>
<div style="margin-top:10px">
</div>
<el-button type="primary" icon="el-icon-download" @click="exportTest">导出Excel</el-button>
<div style="margin-top:10px" />
</div>
<el-table
<el-table
v-loading="listLoading"
:data="tableData.results"
style="width: 100%;margin-top:10px;"
border
stripe
fit
v-loading="listLoading"
highlight-current-row
max-height="600"
@sort-change="changeSort"
>
<el-table-column type="index" width="50"></el-table-column>
<el-table-column type="index" width="50" />
<el-table-column align="left" label="类型">
<template slot-scope="scope">{{ scope.row.type }}</template>
</el-table-column>
<el-table-column align="left" label="用户">
<template slot-scope="scope" v-if="scope.row.consumer_detail">{{ scope.row.consumer_detail.name }}</template>
<template v-if="scope.row.consumer_detail" slot-scope="scope">{{ scope.row.consumer_detail.name }}</template>
</el-table-column>
<el-table-column align="left" label="单位">
<template slot-scope="scope" v-if="scope.row.consumer_detail">{{ scope.row.consumer_detail.company_name }}</template>
<template v-if="scope.row.consumer_detail" slot-scope="scope">{{ scope.row.consumer_detail.company_name }}</template>
</el-table-column>
<el-table-column align="left" label="工作类别">
<template slot-scope="scope">{{ scope.row.workscope_name }}</template>
@ -70,16 +69,16 @@
<el-table-column align="left" label="所属考试">
<template slot-scope="scope">{{ scope.row.exam_name }}</template>
</el-table-column>
<el-table-column align="left" label="是否通过" sortable='custom' prop="is_pass">
<el-table-column align="left" label="是否通过" sortable="custom" prop="is_pass">
<template slot-scope="scope">
<el-tag v-if="scope.row.is_pass" type="success"></el-tag>
<el-tag v-else type="danger"></el-tag>
</template>
</el-table-column>
<el-table-column align="left" label="得分" sortable='custom' prop="score">
<el-table-column align="left" label="得分" sortable="custom" prop="score">
<template slot-scope="scope">{{ scope.row.score }}</template>
</el-table-column>
<el-table-column align="left" label="耗时(时分秒)" sortable='custom' prop="took">
<el-table-column align="left" label="耗时(时分秒)" sortable="custom" prop="took">
<template slot-scope="scope">{{ scope.row.took_format }}</template>
</el-table-column>
<el-table-column align="left" label="答题时间">
@ -88,32 +87,32 @@
<el-table-column align="center" label="操作" fixed="right">
<template slot-scope="scope">
<el-button
v-if="scope.row.type=='正式考试'&&scope.row.candidate_==null"
v-if="scope.row.type=='正式考试'&&scope.row.candidate_==null"
type="primary"
size="small"
@click="handleIssue(scope)"
plain
@click="handleIssue(scope)"
>发证</el-button>
<el-button
v-if="scope.row.type=='正式考试'"
v-if="scope.row.type=='正式考试'"
type="primary"
size="small"
@click="handleExport(scope)"
plain
@click="handleExport(scope)"
>生成Word</el-button>
<el-button
v-if="scope.row.type=='正式考试'"
v-if="scope.row.type=='正式考试'"
type="warning"
size="small"
@click="handleExport2(scope)"
plain
@click="handleExport2(scope)"
>重新生成</el-button>
<el-button
v-if="scope.row.type=='正式考试'"
v-if="scope.row.type=='正式考试'"
type="danger"
size="small"
@click="handleDelete(scope)"
plain
@click="handleDelete(scope)"
>删除</el-button>
</template>
</el-table-column>
@ -129,176 +128,179 @@
</template>
<script>
import { getExamTestlist, exportTest, exportwTest, deleteExamtest, issue } from "@/api/examtest";
import checkPermission from "@/utils/permission";
import Pagination from "@/components/Pagination";
import { getExamTestlist, exportTest, exportwTest, deleteExamtest, issue } from '@/api/examtest'
import checkPermission from '@/utils/permission'
import Pagination from '@/components/Pagination'
const listQuery = {
page: 1,
limit: 20,
type:'正式考试',
type: '正式考试',
workscope__can_examself: false,
search:''
};
search: ''
}
export default {
components: { Pagination },
data() {
return {
listQuery: Object.assign({}, listQuery),
tableData: {
count:0,
results:[],
count: 0,
results: []
},
listLoading: true,
typeOptions: [
{ key: "自助模考", label: "自助模考", value: "自助模考" },
{ key: "押卷模考", label: "押卷模考", value: "押卷模考"},
{ key: "正式考试", label: "正式考试", value: "正式考试"},
{ key: '自助模考', label: '自助模考', value: '自助模考' },
{ key: '押卷模考', label: '押卷模考', value: '押卷模考' },
{ key: '正式考试', label: '正式考试', value: '正式考试' }
],
passOptions: [
{ key: true, label: "通过", value: true },
{ key: false, label: "未通过", value: false},
{ key: true, label: '通过', value: true },
{ key: false, label: '未通过', value: false }
],
pickerOptions: {
shortcuts: [{
text: '最近一天',
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24);
picker.$emit('pick', [start, end]);
}
}, {
text: '最近一周',
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
picker.$emit('pick', [start, end]);
}
}, {
text: '最近一个月',
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
picker.$emit('pick', [start, end]);
}
}, {
text: '最近三个月',
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
picker.$emit('pick', [start, end]);
}
}]
},
value: '',
};
shortcuts: [{
text: '最近一天',
onClick(picker) {
const end = new Date()
const start = new Date()
start.setTime(start.getTime() - 3600 * 1000 * 24)
picker.$emit('pick', [start, end])
}
}, {
text: '最近一周',
onClick(picker) {
const end = new Date()
const start = new Date()
start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
picker.$emit('pick', [start, end])
}
}, {
text: '最近一个月',
onClick(picker) {
const end = new Date()
const start = new Date()
start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
picker.$emit('pick', [start, end])
}
}, {
text: '最近三个月',
onClick(picker) {
const end = new Date()
const start = new Date()
start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
picker.$emit('pick', [start, end])
}
}]
},
value: ''
}
},
computed: {},
watch:{
value:'setTimeRange',
watch: {
value: 'setTimeRange'
},
created() {
this.getQuery();
this.getQuery()
},
methods: {
checkPermission,
getQuery() {
if(this.$route.params.exam){
this.listQuery.exam = this.$route.params.exam;
if (this.$route.params.exam) {
this.listQuery.exam = this.$route.params.exam
this.getList()
}else{
} else {
this.getList()
}
},
getList() {
this.listLoading = true;
this.listLoading = true
getExamTestlist(this.listQuery).then(response => {
this.tableData = response.data;
this.listLoading = false;
});
this.tableData = response.data
this.listLoading = false
})
},
handleFilter() {
this.listQuery.page = 1;
this.getList();
this.listQuery.page = 1
this.getList()
},
resetFilter() {
this.listQuery = {
page: 1,
limit: 20,
type:'正式考试',
search:'',
};
type: '正式考试',
search: ''
}
this.value = []
this.getList();
this.getList()
},
handleExport(scope) {
const loading = this.$loading({text: '正在生成word...',});
exportwTest(scope.row.id).then(res=>{
loading.close()
window.open(res.data.path, "_blank");
}).catch(e=>{loading.close()})
const loading = this.$loading({ text: '正在生成word...' })
exportwTest(scope.row.id).then(res => {
loading.close()
window.open(res.data.path, '_blank')
}).catch(e => { loading.close() })
},
handleDelete(scope){
this.$confirm("确认删除该考试记录吗?将丢失数据!", "警告", {
confirmButtonText: "确认",
cancelButtonText: "取消",
type: "error"
handleDelete(scope) {
this.$confirm('确认删除该考试记录吗?将丢失数据!', '警告', {
confirmButtonText: '确认',
cancelButtonText: '取消',
type: 'error'
})
.then(async () => {
await deleteExamtest(scope.row.id);
.then(async() => {
await deleteExamtest(scope.row.id)
this.getList()
this.$message({
type: "success",
message: "成功删除!"
});
type: 'success',
message: '成功删除!'
})
})
.catch(err => {
console.error(err);
});
console.error(err)
})
},
handleExport2(scope) {
const loading = this.$loading({text: '正在重新生成word...',});
exportwTest(scope.row.id, {anew:true}).then(res=>{
loading.close()
window.open(res.data.path, "_blank");
}).catch(e=>{loading.close()})
const loading = this.$loading({ text: '正在重新生成word...' })
exportwTest(scope.row.id, { anew: true }).then(res => {
loading.close()
window.open(res.data.path, '_blank')
}).catch(e => { loading.close() })
},
exportTest() {
const loading = this.$loading();
const loading = this.$loading()
exportTest(this.listQuery).then(response => {
loading.close()
window.open(response.data.path, "_blank");
});
window.open(response.data.path, '_blank')
})
},
handleIssue(scope) {
const loading = this.$loading({text: '正在发证..',});
issue(scope.row.id).then(res=>{
loading.close()
this.$message.success('发证成功')
scope.row.candidate_ = res.data
}).catch(e=>{loading.close()})
if (scope.row.is_pass === true) {
const loading = this.$loading({ text: '正在发证..' })
issue(scope.row.id).then(res => {
loading.close()
this.$message.success('发证成功')
scope.row.candidate_ = res.data
}).catch(e => { loading.close() })
}
else {
this.$message.error('未通过考试,发证失败!')
}
},
setTimeRange(){
setTimeRange() {
this.listQuery.start = this.value[0],
this.listQuery.end = this.value[1],
this.getList()
},
changeSort (val) {
if(val.order == 'ascending'){
changeSort(val) {
if (val.order == 'ascending') {
this.listQuery.ordering = val.prop
}else{
} else {
this.listQuery.ordering = '-' + val.prop
}
this.getList()
},
this.getList()
}
}
};
}
</script>

View File

@ -1,81 +1,81 @@
<template>
<div class="app-container">
<div style="margin-top:10px">
<el-input
v-model="listQuery.search"
placeholder="输入考试名称进行搜索"
style="width: 300px;"
class="filter-item"
@keyup.enter.native="handleFilter"
/>
<el-button type="primary" @click="handleAdd" icon="el-icon-plus" v-if ="checkPermission(['exam_create'])">新增</el-button>
<el-button
<div style="margin-top:10px">
<el-input
v-model="listQuery.search"
placeholder="输入考试名称进行搜索"
style="width: 300px;"
class="filter-item"
@keyup.enter.native="handleFilter"
/>
<el-button v-if="checkPermission(['exam_create'])" type="primary" icon="el-icon-plus" @click="handleAdd">新增</el-button>
<el-button
class="filter-item"
type="primary"
icon="el-icon-refresh-left"
@click="resetFilter"
>刷新重置</el-button>
</div>
<el-table
:data="tableData.results"
style="width: 100%;margin-top:10px;"
border
fit
v-loading="listLoading"
highlight-current-row
max-height="600"
row-key="id"
default-expand-all
>
<el-table-column label="考试名称">
<template slot-scope="scope">{{ scope.row.name }}</template>
</el-table-column>
<el-table-column label="考试编号">
<template slot-scope="scope">{{ scope.row.code }}</template>
</el-table-column>
<el-table-column label="考试地点">
<template slot-scope="scope">{{ scope.row.place }}</template>
</el-table-column>
<el-table-column label="工作类别">
<template slot-scope="scope">{{ scope.row.workscope_name }}</template>
</el-table-column>
<el-table-column label="参考机会">
<template slot-scope="scope">{{ scope.row.chance }}</template>
</el-table-column>
<el-table-column label="开启时间">
<template slot-scope="scope">{{ scope.row.opentime }}</template>
</el-table-column>
<el-table-column label="关闭时间">
<template slot-scope="scope">{{ scope.row.closetime }}</template>
</el-table-column>
<el-table-column label="创建人">
<template slot-scope="scope">
<span>{{ scope.row.create_admin_username }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="操作" fixed="right">
<template slot-scope="scope">
<el-button
type="primary"
size="small"
@click="handleView(scope)"
:disabled="!checkPermission(['exam_view'])"
>详情</el-button>
<el-button
size="small"
@click="handleEdit(scope)"
:disabled="!checkPermission(['exam_update'])"
>编辑</el-button>
<el-button
type="danger"
size="small"
@click="handleDelete(scope)"
:disabled="!checkPermission(['exam_delete'])"
>删除</el-button>
</template>
</el-table-column>
</el-table>
</div>
<el-table
v-loading="listLoading"
:data="tableData.results"
style="width: 100%;margin-top:10px;"
border
fit
highlight-current-row
max-height="600"
row-key="id"
default-expand-all
>
<el-table-column label="考试名称">
<template slot-scope="scope">{{ scope.row.name }}</template>
</el-table-column>
<el-table-column label="考试编号">
<template slot-scope="scope">{{ scope.row.code }}</template>
</el-table-column>
<el-table-column label="考试地点">
<template slot-scope="scope">{{ scope.row.place }}</template>
</el-table-column>
<el-table-column label="工作类别">
<template slot-scope="scope">{{ scope.row.workscope_name }}</template>
</el-table-column>
<el-table-column label="参考机会">
<template slot-scope="scope">{{ scope.row.chance }}</template>
</el-table-column>
<el-table-column label="开启时间">
<template slot-scope="scope">{{ scope.row.opentime }}</template>
</el-table-column>
<el-table-column label="关闭时间">
<template slot-scope="scope">{{ scope.row.closetime }}</template>
</el-table-column>
<el-table-column label="创建人">
<template slot-scope="scope">
<span>{{ scope.row.create_admin_username }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="操作" fixed="right">
<template slot-scope="scope">
<el-button
type="primary"
size="small"
:disabled="!checkPermission(['exam_view'])"
@click="handleView(scope)"
>详情</el-button>
<el-button
size="small"
:disabled="!checkPermission(['exam_update'])"
@click="handleEdit(scope)"
>编辑</el-button>
<el-button
type="danger"
size="small"
:disabled="!checkPermission(['exam_delete'])"
@click="handleDelete(scope)"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="tableData.count>0"
:total="tableData.count"
@ -83,142 +83,153 @@
:limit.sync="listQuery.limit"
@pagination="getList"
/>
<el-dialog :visible.sync="dialogVisible" :title="dialogType==='edit'?'编辑考试':'新增考试'" >
<el-form :model="exam" label-width="80px" :rules="rule1" ref="examForm">
<el-dialog :visible.sync="dialogVisible" :title="dialogType==='edit'?'编辑考试':'新增考试'">
<el-form ref="examForm" :model="exam" label-width="80px" :rules="rule1">
<el-row>
<el-col :span="12">
<el-form-item label="名称" prop="name">
<el-input v-model="exam.name" placeholder="名称" />
</el-form-item>
<el-input v-model="exam.name" placeholder="名称" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="考试地点" prop="place">
<el-input v-model="exam.place" placeholder="考试地点" />
</el-form-item>
<el-input v-model="exam.place" placeholder="考试地点" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="工作类别" prop="workscope" >
<el-select v-model="exam.workscope" placeholder="请选择工作类别" style="width:100%">
<el-option
v-for="item in workscopeOptions"
:key="item.id"
:label="item.name"
:value="item.id"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="工作类别" prop="workscope">
<el-select v-model="exam.workscope" placeholder="请选择工作类别" style="width:100%">
<el-option
v-for="item in workscopeOptions"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="选定试卷" prop="paper" >
<el-select v-model="exam.paper" placeholder="可指定试卷" style="width:100%" clearable>
<el-option
v-for="item in paperOptions"
:key="item.id"
:label="item.name"
:value="item.id"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="选定试卷" prop="paper">
<el-select v-model="exam.paper" placeholder="可指定试卷" style="width:100%" clearable>
<el-option
v-for="item in paperOptions"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="开启时间" prop="opentime">
<el-date-picker
v-model="exam.opentime"
type="datetime"
placeholder="开启时间"
style="width:100%">
</el-date-picker>
</el-form-item>
<el-date-picker
v-model="exam.opentime"
type="datetime"
placeholder="开启时间"
style="width:100%"
/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="关闭时间" prop="closetime">
<el-date-picker
v-model="exam.closetime"
type="datetime"
placeholder="关闭时间"
style="width:100%"
></el-date-picker>
</el-form-item>
<el-date-picker
v-model="exam.closetime"
type="datetime"
placeholder="关闭时间"
style="width:100%"
/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="参考机会" prop="chance">
<el-input-number v-model="exam.chance" placeholder="参考机会" :min="1"/>
</el-form-item>
<el-input-number v-model="exam.chance" placeholder="参考机会" :min="1" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="仅培训班学员" prop="only_vip" label-width="100px">
<el-switch v-model="exam.only_vip"></el-switch>
</el-form-item>
<el-switch v-model="exam.only_vip" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="自动发证" prop="auto_issue">
<el-switch v-model="exam.auto_issue"></el-switch>
</el-form-item>
<el-switch v-model="exam.auto_issue" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="证书模板">
<el-select v-model="exam.cert_template" placeholder="证书模板" clearable>
<el-option v-for="item in certTemplateOptions" :key="item.value">{{ item.label }}</el-option>
</el-select>
</el-form-item>
<el-select v-if=" uploadUrl=='https://qw.ctc-zc.com/api'" v-model="exam.cert_template" placeholder="证书模板" clearable>
<el-option
v-for="item in certTemplateOptionsqw"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
<el-select v-else v-model="exam.cert_template" placeholder="证书模板" clearable>
<el-option
v-for="item in certTemplateOptions"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-divider></el-divider>
<el-row>
<el-col :span="12">
<el-form-item label="监考人姓名" prop="proctor_name" label-width="120px">
<el-input v-model="exam.proctor_name" placeholder="监考人姓名" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="监考人联系方式" prop="proctor_phone" label-width="120px">
<el-input v-model="exam.proctor_phone" placeholder="监考人联系方式" />
</el-form-item>
</el-col>
</el-row>
<el-divider />
<el-row>
<el-col :span="12">
<el-form-item label="监考人姓名" prop="proctor_name" label-width="120px">
<el-input v-model="exam.proctor_name" placeholder="监考人姓名" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="监考人联系方式" prop="proctor_phone" label-width="120px">
<el-input v-model="exam.proctor_phone" placeholder="监考人联系方式" />
</el-form-item>
</el-col>
</el-row>
<el-form-item label="培训名称" prop="train_name">
<el-input v-model="exam.train_name" placeholder="培训名称" />
</el-form-item>
<el-row>
<el-col :span="12">
<el-form-item label="培训开始" prop="train_start_date">
<el-date-picker
v-model="exam.train_start_date"
type="date"
placeholder="培训开始"
value-format="yyyy-MM-dd"
style="width:100%">
</el-date-picker>
</el-form-item>
<el-date-picker
v-model="exam.train_start_date"
type="date"
placeholder="培训开始"
value-format="yyyy-MM-dd"
style="width:100%"
/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="培训结束" prop="train_end_date">
<el-date-picker
v-model="exam.train_end_date"
type="date"
placeholder="培训结束"
value-format="yyyy-MM-dd"
style="width:100%"
></el-date-picker>
</el-form-item>
<el-date-picker
v-model="exam.train_end_date"
type="date"
placeholder="培训结束"
value-format="yyyy-MM-dd"
style="width:100%"
/>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div style="text-align:right;">
@ -230,77 +241,80 @@
</template>
<script>
import { getexamlist, createexam, deleteexam, updateexam} from "@/api/exam";
import { getWorkScopeAll, getPaperList } from "@/api/examtest"
import { deepClone } from "@/utils";
import checkPermission from "@/utils/permission";
import Pagination from "@/components/Pagination"
import { getexamlist, createexam, deleteexam, updateexam } from '@/api/exam'
import { getWorkScopeAll, getPaperList } from '@/api/examtest'
import { deepClone } from '@/utils'
import checkPermission from '@/utils/permission'
import Pagination from '@/components/Pagination'
const defaultexam = {
id: "",
name: "",
place: "",
opentime: null,
closetime: null,
chance:3,
only_vip:false,
cert_template:null,
auto_issue:false
};
id: '',
name: '',
place: '',
opentime: null,
closetime: null,
chance: 3,
only_vip: false,
cert_template: null,
auto_issue: false
}
const listQuery = {
page: 1,
limit: 20,
search: ""
search: ''
}
export default {
components: { Pagination },
data() {
return {
selects:[],
uploadUrl: process.env.VUE_APP_BASE_API,
selects: [],
exam: {
id: "",
name: "",
id: '',
name: ''
},
certTemplateOptions:[
{value: 1, label: "模板1"},
{value: 2, label: "模板2"}
certTemplateOptionsqw: [
{ value: 3, label: '气味评价证书' },
{ value: 4, label: '气味检验证书' }
],
listQuery:listQuery,
tableData: {count:0},
certTemplateOptions: [
{ value: 1, label: '模板1' },
{ value: 2, label: '模板2' }
],
listQuery: listQuery,
tableData: { count: 0 },
listLoading: true,
dialogVisible: false,
dialogType: "new",
workscopeOptions:[],
paperOptions:[],
dialogType: 'new',
workscopeOptions: [],
paperOptions: [],
rule1: {
name: [{ required: true, message: "请输入", trigger: "blur" }],
place: [{ required: true, message: "请输入", trigger: "change" }],
workscope: [{ required: true, message: "请选择", trigger: "change" }],
opentime: [{ required: true, message: "请选择", trigger: "change" }],
closetime: [{ required: true, message: "请选择", trigger: "change" }],
proctor_name: [{ required: true, message: "请输入", trigger: "change" }],
proctor_phone: [{ required: true, message: "请输入", trigger: "change" }],
chance: [{ required: true, message: "请输入", trigger: "change" }]
},
};
name: [{ required: true, message: '请输入', trigger: 'blur' }],
place: [{ required: true, message: '请输入', trigger: 'change' }],
workscope: [{ required: true, message: '请选择', trigger: 'change' }],
opentime: [{ required: true, message: '请选择', trigger: 'change' }],
closetime: [{ required: true, message: '请选择', trigger: 'change' }],
proctor_name: [{ required: true, message: '请输入', trigger: 'change' }],
proctor_phone: [{ required: true, message: '请输入', trigger: 'change' }],
chance: [{ required: true, message: '请输入', trigger: 'change' }]
}
}
},
computed: {},
created() {
this.getList();
this.getworkscopeOptions();
this.getPaperOptions();
this.getList()
this.getworkscopeOptions()
this.getPaperOptions()
},
methods: {
checkPermission,
getworkscopeOptions(){
getWorkScopeAll({can_exam:true}).then(res=>{
getworkscopeOptions() {
getWorkScopeAll({ can_exam: true }).then(res => {
this.workscopeOptions = res.data
})
},
getPaperOptions(){
getPaperList({pageoff:true}).then(res=>{
getPaperOptions() {
getPaperList({ pageoff: true }).then(res => {
this.paperOptions = res.data
})
},
@ -309,82 +323,81 @@ export default {
getexamlist(this.listQuery).then(response => {
this.tableData = response.data
this.listLoading = false
});
})
},
resetFilter() {
this.listQuery = {
page: 1,
limit: 20,
search: ""
};
this.getList();
search: ''
}
this.getList()
},
handleFilter() {
this.listQuery.page = 1;
this.getList();
this.listQuery.page = 1
this.getList()
},
handleAdd() {
this.exam = Object.assign({}, defaultexam);
this.dialogType = "new";
this.dialogVisible = true;
this.exam = Object.assign({}, defaultexam)
this.dialogType = 'new'
this.dialogVisible = true
this.$nextTick(() => {
this.$refs["examForm"].clearValidate();
});
this.$refs['examForm'].clearValidate()
})
},
handleEdit(scope) {
this.exam = Object.assign({}, scope.row); // copy obj
this.dialogType = "edit";
this.dialogVisible = true;
this.exam = Object.assign({}, scope.row) // copy obj
this.dialogType = 'edit'
this.dialogVisible = true
this.$nextTick(() => {
this.$refs["examForm"].clearValidate();
});
this.$refs['examForm'].clearValidate()
})
},
handleDelete(scope) {
this.$confirm("确认删除该考试吗?将丢失数据!", "警告", {
confirmButtonText: "确认",
cancelButtonText: "取消",
type: "error"
this.$confirm('确认删除该考试吗?将丢失数据!', '警告', {
confirmButtonText: '确认',
cancelButtonText: '取消',
type: 'error'
})
.then(async () => {
await deleteexam(scope.row.id);
.then(async() => {
await deleteexam(scope.row.id)
this.getList()
this.$message({
type: "success",
message: "成功删除!"
});
type: 'success',
message: '成功删除!'
})
})
.catch(err => {
// console.error(err);
});
})
},
handleView(scope){
this.$router.push({name:'ExamTest2', params:{exam:scope.row.id}})
handleView(scope) {
this.$router.push({ name: 'ExamTest2', params: { exam: scope.row.id }})
},
async confirmexam(form) {
this.$refs[form].validate(valid => {
if (valid) {
const isEdit = this.dialogType === "edit";
const isEdit = this.dialogType === 'edit'
if (isEdit) {
updateexam(this.exam.id, this.exam).then(() => {
this.getList();
this.dialogVisible = false;
this.getList()
this.dialogVisible = false
this.$message.success('成功')
});
})
} else {
createexam(this.exam).then(res => {
// this.exam = res.data
// this.tableData.unshift(this.exam)
this.getList();
this.dialogVisible = false;
this.getList()
this.dialogVisible = false
this.$message.success('成功')
});
})
}
} else {
return false;
return false
}
});
},
})
}
}
};
}
</script>

View File

@ -13,22 +13,20 @@
type="primary"
icon="el-icon-refresh-left"
@click="resetFilter"
>刷新重置</el-button
>
>刷新重置</el-button>
<el-button
v-if="checkPermission(['certificate_create'])&&uploadUrl!='https://qw.ctc-zc.com/api'"
type="primary"
@click="handleAdd"
v-if="checkPermission(['certificate_create'])"
>手动创建</el-button
>
>手动创建</el-button>
</div>
<el-table
v-loading="listLoading"
:data="tableData.results"
style="width: 100%; margin-top: 10px"
border
fit
v-loading="listLoading"
highlight-current-row
max-height="600"
row-key="id"
@ -58,8 +56,7 @@
<el-table-column label="手动创建">
<template slot-scope="scope">
<span v-if="scope.row.is_manual"></span>
<span v-else></span></template
>
<span v-else></span></template>
</el-table-column>
<el-table-column label="创建人">
<template slot-scope="scope">
@ -69,20 +66,29 @@
<el-table-column align="center" label="操作" fixed="right">
<template slot-scope="scope">
<el-button
v-if="uploadUrl=='https://qw.ctc-zc.com/api'"
type="primary"
size="small"
@click="handleView(scope)"
icon="el-icon-more"
plain="true"
></el-button>
@click="handleDialogissue(scope)"
/>
<el-button
v-else
type="primary"
size="small"
icon="el-icon-more"
plain="true"
@click="handleView(scope)"
/>
<el-button
v-if="checkPermission(['certificate_update'])"
type="primary"
size="small"
plain="true"
@click="handleEdit(scope)"
icon="el-icon-edit"
v-if="checkPermission(['certificate_update'])"
></el-button>
@click="handleEdit(scope)"
/>
</template>
</el-table-column>
</el-table>
@ -98,11 +104,11 @@
:title="dialogType === 'update' ? '编辑' : '新增'"
>
<el-form
ref="candidateForm"
:model="candidate"
label-width="80px"
label-position="right"
:rules="candidateRule"
ref="candidateForm"
>
<el-row>
<el-col :span="12">
@ -135,8 +141,7 @@
type="date"
placeholder="选择日期"
value-format="yyyy-MM-dd"
>
</el-date-picker>
/>
</el-form-item>
<el-form-item label="有效期始" prop="start_date">
<el-date-picker
@ -144,8 +149,7 @@
type="date"
placeholder="选择日期"
value-format="yyyy-MM-dd"
>
</el-date-picker>
/>
</el-form-item>
<el-form-item label="有效期止" prop="end_date">
<el-date-picker
@ -153,8 +157,7 @@
type="date"
placeholder="选择日期"
value-format="yyyy-MM-dd"
>
</el-date-picker>
/>
</el-form-item>
<el-form-item label="考试时间" prop="examtest_date">
<el-date-picker
@ -162,8 +165,7 @@
type="date"
placeholder="选择日期"
value-format="yyyy-MM-dd"
>
</el-date-picker>
/>
</el-form-item>
<el-form-item label="照片" prop="photo">
<el-upload
@ -179,8 +181,8 @@
v-if="candidate.photo"
:src="candidate.photo"
class="avatar"
/>
<i v-else class="el-icon-plus avatar-uploader-icon"></i>
>
<i v-else class="el-icon-plus avatar-uploader-icon" />
</el-upload>
</el-form-item>
</el-col>
@ -188,9 +190,29 @@
</el-form>
<div style="text-align: right">
<el-button type="danger" @click="dialogVisible = false">取消</el-button>
<el-button type="primary" @click="confirmCandidate('candidateForm')"
>确认</el-button
>
<el-button
type="primary"
@click="confirmCandidate('candidateForm')"
>确认</el-button>
</div>
</el-dialog>
<el-dialog
:visible.sync="dialogVisibleissue"
width="1000px"
title="证书查看"
>
<el-card shadow="never" style="width:100%;height:100%;background-color: black;">
<el-image :src="src" style="width:531px;height:809;margin:10px 230px" />
</el-card>
<div style="text-align: right">
<el-button type="danger" @click="dialogVisibleissue = false">取消</el-button>
<el-button
type="primary"
@click="downCandidate"
>下载</el-button>
</div>
</el-dialog>
</div>
@ -224,113 +246,141 @@
import {
getCandidateList,
createCandidate,
updateCandidate,
} from "@/api/candidate";
import { deepClone } from "@/utils";
import { upUrl, upHeaders } from "@/api/file";
import checkPermission from "@/utils/permission";
import Pagination from "@/components/Pagination";
updateCandidate
} from '@/api/candidate'
import { deepClone } from '@/utils'
import { upUrl, upHeaders } from '@/api/file'
import checkPermission from '@/utils/permission'
import Pagination from '@/components/Pagination'
const listQuery = {
page: 1,
limit: 20,
search: "",
};
search: ''
}
export default {
components: { Pagination },
data() {
return {
uploadUrl: process.env.VUE_APP_BASE_API,
upHeaders: upHeaders(),
upUrl: upUrl(),
listQuery: listQuery,
tableData: { count: 0 },
listLoading: true,
dialogVisible: false,
dialogType: "create",
candidate: { photo: "" },
dialogType: 'create',
dialogVisibleissue: false,
src: null,
name: '',
candidate: { photo: '' },
candidateRule: {
number: [{ required: true, message: "请输入编号", trigger: "blur" }],
},
};
number: [{ required: true, message: '请输入编号', trigger: 'blur' }]
}
}
},
computed: {},
created() {
this.getList();
this.getList()
},
methods: {
checkPermission,
handleAvatarSuccess(res, file) {
this.candidate.photo = res.data.path;
this.candidate.photo = res.data.path
},
beforeAvatarUpload(file) {
const isLt2M = file.size / 1024 / 1024 < 2;
const isLt2M = file.size / 1024 / 1024 < 2
if (!isLt2M) {
this.$message.error("上传图片大小不能超过 2MB!");
this.$message.error('上传图片大小不能超过 2MB!')
}
return isLt2M;
return isLt2M
},
getList() {
this.listLoading = true;
this.listLoading = true
getCandidateList(this.listQuery).then((response) => {
this.tableData = response.data;
this.listLoading = false;
});
this.tableData = response.data
this.listLoading = false
})
},
resetFilter() {
this.listQuery = {
page: 1,
limit: 20,
search: "",
};
this.getList();
search: ''
}
this.getList()
},
handleFilter() {
this.listQuery.page = 1;
this.getList();
this.listQuery.page = 1
this.getList()
},
handleView(scope) {
window.open(
"https://apitest.ahctc.cn/crm/candidate/img?id=" + scope.row.id
'https://apitest.ahctc.cn/crm/candidate/img?id=' + scope.row.id
// "http://localhost:8000/crm/candidate/img?id=" + scope.row.id
);
)
},
//
handleDialogissue(scope) {
if(scope.row.photo==null)
{
this.$message({
message: '请先点击编辑上传证书人员照片!',
type: 'warning'
});
}
else{
this.dialogVisibleissue = true
this.src = 'https://qw.ctc-zc.com' + scope.row.path
this.name = scope.row.workscope_name
}
},
handleAdd() {
this.dialogVisible = true;
this.dialogType = "create";
this.dialogVisible = true
this.dialogType = 'create'
this.$nextTick(() => {
this.$refs["candidateForm"].clearValidate();
});
this.$refs['candidateForm'].clearValidate()
})
},
handleEdit(scope) {
this.candidate = scope.row;
this.dialogType = "update";
this.dialogVisible = true;
this.candidate = scope.row
this.dialogType = 'update'
this.dialogVisible = true
this.$nextTick(() => {
this.$refs["candidateForm"].clearValidate();
});
this.$refs['candidateForm'].clearValidate()
})
},
confirmCandidate(form) {
this.$refs[form].validate((valid) => {
if (valid) {
const isEdit = this.dialogType === "update";
const isEdit = this.dialogType === 'update'
if (isEdit) {
updateCandidate(this.candidate.id, this.candidate).then(() => {
this.getList();
this.dialogVisible = false;
this.$message.success("成功");
});
this.getList()
this.dialogVisible = false
this.$message.success('成功')
})
} else {
createCandidate(this.candidate).then((res) => {
this.getList();
this.dialogVisible = false;
this.$message.success("成功");
});
this.getList()
this.dialogVisible = false
this.$message.success('成功')
})
}
} else {
return false;
return false
}
});
})
},
},
};
//
downCandidate() {
var a = document.createElement('a');
a.href = this.src ;
a.download = this.src ;
a.target="_blank"
a.click()
}
}
}
</script>