<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="100px">
<el-form-item label="课程" prop="classId">
<el-select v-model="queryParams.classId" placeholder="请选择课程" clearable size="small">
<el-option
v-for="dict in classInfoOptions"
:key="dict.id"
:label="dict.className"
:value="dict.id"
/>
</el-select>
</el-form-item>
<el-form-item label="培训时间" prop="trainingTime">
<el-date-picker
v-model="queryDateRange"
type="daterange"
align="right"
unlink-panels
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
value-format="yyyy-MM-dd "
:default-time="['00:00:00', '23:59:59']"
:picker-options="pickerOptions">
</el-date-picker>
</el-form-item>
<el-form-item label="培训方式" prop="type">
<el-select v-model="queryParams.type" placeholder="请选择培训方式" clearable size="small">
<el-option
v-for="dict in typeOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="dict.dictValue"
/>
</el-select>
</el-form-item>
<el-form-item label="考核方式" prop="evaluationMode">
<el-select v-model="queryParams.evaluationMode" placeholder="请选择考核方式" clearable size="small">
<el-option
v-for="dict in evaluationModeOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="dict.dictValue"
/>
</el-select>
</el-form-item>
<el-form-item label="是否结束" prop="recordStatus">
<el-select v-model="queryParams.recordStatus" placeholder="请选择" clearable size="small">
<el-option
v-for="dict in statusOptions"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="讲师" prop="trainer">
<SelectStaffTable v-model="queryParams.trainer" />
</el-form-item>
<el-form-item>
<el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['mes:trainingRecord:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['mes:trainingRecord:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['mes:trainingRecord:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="info"
icon="el-icon-upload2"
size="mini"
@click="handleImportDetail"
v-hasPermi="['mes:trainingRecord:import']"
>导入数据</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="info"
icon="el-icon-upload2"
size="mini"
:disabled="single"
@click="handleImport"
v-hasPermi="['mes:trainingRecord:uploadPDF']"
>导入PDF</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['mes:trainingRecord:export']"
>导出</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
icon="el-icon-download"
size="mini"
@click="handleExportDetail"
v-hasPermi="['mes:trainingRecord:export']"
>明细导出</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
icon="el-icon-download"
size="mini"
@click="handleExportByDept"
v-hasPermi="['mes:trainingRecord:export']"
>部门统计导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="trainingRecordList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="id" align="center" prop="id" v-if="false"/>
<el-table-column label="编号" align="center" prop="code" />
<el-table-column label="培训课程名称" align="center" prop="className" />
<el-table-column label="培训时间" align="center" prop="trainingTime" width="180" >
<!-- <template v-slot="scope">
<span>{{ parseTime(scope.row.trainingTime, '{y}-{m}-{d}') }}</span>
</template> -->
</el-table-column>
<el-table-column label="培训时长(分钟)" align="center" prop="duration" />
<el-table-column label="培训地点" align="center" prop="addr" />
<el-table-column label="培训类型" align="center" prop="type" :formatter="typeFormat" />
<el-table-column label="培训对象" align="center" prop="trainingObj" />
<el-table-column label="培训内容" align="center" prop="content" />
<el-table-column label="考核方式" align="center" prop="evaluationMode" :formatter="evaluationModeFormat"/>
<el-table-column label="讲师" align="center" prop="trainerName" />
<el-table-column label="讲师评分" align="center" prop="trainerScore" />
<el-table-column label="组织名称" align="center" prop="deptName" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="200px" fixed="right" >
<template v-slot="scope" >
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['mes:trainingRecord:edit']" >修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-document"
@click="handleDetail(scope.row)"
v-hasPermi="['mes:trainingRecord:query']" >详情</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['mes:trainingRecord:remove']" >删除</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-picture-outline"
v-show="scope.row.trainingFile"
@click="handleOpenPdf(scope.row,0)"
>签到PDF</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-camera-solid"
v-show="scope.row.scoreFile"
@click="handleOpenPdf(scope.row,1)"
>试卷PDF</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="page.total>0"
:total="page.total"
:page.sync="page.page"
:limit.sync="page.size"
@pagination="getList"
/>
<!-- 添加对话框 -->
<el-dialog :title="title" :visible.sync="open" width="800px" append-to-body :close-on-click-modal="false">
<el-form ref="form" :model="form" :rules="rules" label-width="120px">
<el-row>
<el-col :span=12>
<el-form-item label="培训课程名称" prop="className">
<el-select v-model="form.classId" placeholder="请选择课程类型" @change="selectClassInfo" clearable size="small">
<el-option
v-for="dict in classInfoOptions"
:key="dict.id"
:label="dict.className"
:value="dict.id"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span=12>
<el-form-item label="培训时间" prop="trainingTime">
<el-date-picker clearable size="small" style="width: 200px"
v-model="form.trainingTime"
type="datetime"
value-format="yyyy-MM-dd HH:mm:ss"
placeholder="选择培训时间">
</el-date-picker>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span=12>
<el-form-item label="培训时长(分钟)" prop="duration">
<el-input v-model="form.duration" placeholder="请输入培训时长(分钟)" />
</el-form-item>
</el-col>
<el-col :span=12>
<el-form-item label="培训地点" prop="addr">
<el-select v-model="form.addr" placeholder="请选择培训地点" clearable size="small">
<el-option
v-for="dict in addrOptions"
:key="dict.dictLabel"
:label="dict.dictLabel"
:value="dict.dictLabel"
/>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span=12>
<el-form-item label="培训方式" prop="type">
<el-select v-model="form.type" placeholder="请选择课程类型" clearable size="small">
<el-option
v-for="dict in typeOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="dict.dictValue"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span=12>
<el-form-item label="培训对象" prop="trainingObj">
<el-input v-model="form.trainingObj" placeholder="请输入培训对象" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span=12>
<el-form-item label="考核方式" prop="evaluationMode">
<el-select v-model="form.evaluationModeList" placeholder="请选择考核方式" multiple size="small">
<el-option
v-for="dict in evaluationModeOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="dict.dictValue"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span=12>
<el-form-item label="参加员工" prop="staffList">
<SelectStaffTable v-model="form.staffList" @selection-change="handleSelectionChange" multiple buttonShow />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span=12>
<el-form-item label="讲师" prop="trainer">
<SelectStaffTable v-model="form.trainer" @selection-change="handleSelectionChange" />
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer" >
<el-button type="primary" @click="submitForm">确 定</el-button>
<el-button @click="cancelAdd">取 消</el-button>
</div>
</el-dialog>
<!-- 详情 / 修改 对话框 -->
<el-dialog :title="title" :visible.sync="detailOpen" width="1000px" append-to-body :close-on-click-modal="false">
<el-form ref="detailform" :model="form" :rules="rules" label-width="120px">
<el-row>
<el-col :span=8>
<el-form-item label="培训课程名称" prop="className">
<el-select v-model="form.classId" :disabled="true" placeholder="请选择课程名称" @change="selectClassInfo" clearable size="small">
<el-option
v-for="dict in classInfoOptions"
:key="dict.id"
:label="dict.className"
:value="dict.id"
:disabled="dict.disabled"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span=8>
<el-form-item label="培训时间" prop="trainingTime">
<el-date-picker clearable size="small" :disabled="detailDisabled" style="width: 200px"
v-model="form.trainingTime"
type="datetime"
value-format="yyyy-MM-dd HH:mm:ss"
placeholder="选择培训时间">
</el-date-picker>
</el-form-item>
</el-col>
<el-col :span=8>
<el-form-item label="培训地点" prop="addr">
<el-select v-model="form.addr" placeholder="请选择培训地点" clearable size="small">
<el-option
v-for="dict in addrOptions"
:key="dict.dictLabel"
:label="dict.dictLabel"
:value="dict.dictLabel"
/>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span=8>
<el-form-item label="培训方式" prop="type">
<el-select v-model="form.type" placeholder="请选择课程类型" :disabled="true" clearable size="small">
<el-option
v-for="dict in typeOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="dict.dictValue"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span=8>
<el-form-item label="培训对象" prop="trainingObj">
<el-input v-model="form.trainingObj" :disabled="detailDisabled" placeholder="请输入培训对象" />
</el-form-item>
</el-col>
<el-col :span=8>
<el-form-item label="考核方式" prop="evaluationModeList">
<el-select v-model="form.evaluationModeList" collapse-tags :disabled="detailDisabled" placeholder="请选择考核方式" multiple size="small">
<el-option
v-for="dict in evaluationModeOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="dict.dictValue"
/>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span=8>
<el-form-item label="培训时长" prop="duration">
<el-input v-model="form.duration" :disabled="true" placeholder="请输入培训对象" />
</el-form-item>
</el-col>
<el-col :span=8>
<el-form-item label="讲师" prop="trainer">
<SelectStaffTable v-model="form.trainer" @selection-change="handleSelectionChange" :buttonShow=false />
</el-form-item>
</el-col>
<el-col :span=8>
<el-form-item label="讲师评分" prop="trainerScore">
<el-input v-model="form.trainerScore" :disabled="detailDisabled" placeholder="请输入培训对象" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span=8>
<el-form-item label="达标标准" prop="count">
<el-input v-model="form.passingScore" :disabled="true" placeholder="" />
</el-form-item>
</el-col>
<el-col :span=8>
<el-form-item label="签到人数" prop="count">
<el-input v-model="form.count" :disabled="true" placeholder="" />
</el-form-item>
</el-col>
</el-row>
</el-form>
<el-row :gutter="10" class="mb8" v-show="!detailDisabled">
<el-col :span="1.5">
<el-button
type="primary"
icon="el-icon-plus"
size="mini"
@click="handleAddDetail"
v-hasPermi="['mes:trainingRecord:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button v-if="batchEditFlag"
type="success"
icon="el-icon-edit"
size="mini"
@click="batchEdit"
>批量修改</el-button>
<el-button v-else
type="danger"
icon="el-icon-edit"
size="mini"
@click="batchEdit"
>取消批量修改</el-button>
</el-col>
</el-row>
<el-table :data="form.trainingSignInFormList" :style="{width: '100%' , 'margin-top': '5px'}" height="400" border>
<el-table-column type="index" width="50" />
<el-table-column label="工号" align="center" prop="employeeNum" />
<el-table-column label="姓名" align="center" prop="staffName" />
<el-table-column label="签到" align="center" >
<template slot-scope="scope">
<el-switch v-model="scope.row.signInStatus" :disabled="!scope.row.edit" active-value="1" inactive-value="0" ></el-switch>
</template>
</el-table-column>
<el-table-column label="成绩" align="center" >
<template slot-scope="scope">
<!-- <el-input v-model="scope.row.score" v-if="scope.row.edit" size="small"></el-input> -->
<span >{{ scope.row.score }}</span>
</template>
</el-table-column>
<el-table-column label="是否合格" align="center" prop="qualified" :formatter="passFormat"/>
<el-table-column label="次数" align="center" >
<template slot-scope="scope">
<!-- <el-input v-model="scope.row.retakeTimes" v-if="scope.row.edit" size="small"></el-input> -->
<span >{{ scope.row.retakeTimes }}</span>
</template>
</el-table-column>
<el-table-column label="考核分数" align="center" prop="retakeScore" width="200px" >
<template slot-scope="scope">
<el-input v-model="scope.row.retakeScore" v-if="scope.row.edit" size="small"></el-input>
<span v-else>{{ scope.row.retakeScore }}</span>
</template>
</el-table-column>
<el-table-column label="操作" width="150px" v-if="!detailDisabled">
<template slot-scope="scope" >
<el-button size="mini" type="primary" v-if="scope.row.edit" @click="save(scope.$index, scope.row)">保存</el-button>
<el-button size="mini" v-else @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
<el-button size="mini" type="danger" @click="handleSignDelete(scope.$index, scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<div slot="footer" class="dialog-footer" >
<el-button type="primary" @click="submitDetailForm" v-show="!detailDisabled">保存</el-button>
<el-button @click="cancelDetail">取 消</el-button>
</div>
</el-dialog>
<!-- 添加人员成绩 -->
<el-dialog title="添加人员成绩" :visible.sync="signOpen" width="800px" append-to-body :close-on-click-modal="false">
<el-form ref="signform" :model="signform" :rules="rules" label-width="120px">
<el-row>
<el-col :span=12>
<el-form-item label="参加员工" prop="staffList">
<SelectStaffTable v-model="signform.staffList" :disableList="disableList"
@selection-change="handleSelectionChange" multiple />
</el-form-item>
</el-col>
<el-col :span=12>
<el-form-item label="签到状态" prop="signInStatus">
<el-switch
v-model="signform.signInStatus"
active-value="1"
inactive-value="0"
>
</el-switch>
</el-form-item>
</el-col>
<el-col :span=12>
<el-form-item label="考核分数" prop="retakeScore">
<el-input v-model="signform.retakeScore" placeholder="请输入分数" />
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer" >
<el-button type="primary" @click="submitSignForm">确 定</el-button>
<el-button @click="cancelSign">取 消</el-button>
</div>
</el-dialog>
<!-- 用户导入对话框 -->
<el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body :close-on-click-modal="false">
<el-row>
<el-radio v-model="upload.type" label="0">签到PDF</el-radio>
<el-radio v-model="upload.type" label="1">试卷PDF</el-radio>
</el-row>
<el-upload ref="upload" :limit="1" accept=".PDF, .pdf" :headers="upload.headers"
:action="upload.url + '?updateSupport=' + upload.updateSupport + '&id=' + upload.id+ '&type=' + upload.type"
:disabled="upload.isUploading" :on-progress="handleFileUploadProgress" :on-success="handleFileSuccess" :auto-upload="false" drag>
<i class="el-icon-upload"></i>
<div class="el-upload__text">
将文件拖到此处,或
<em>点击上传</em>
</div>
<div class="el-upload__tip" slot="tip">
<el-checkbox v-model="upload.updateSupport" />是否更新已经存在的用户数据
</div>
<div class="el-upload__tip" style="color:red" slot="tip">提示:仅允许导入“PDF/IMG”格式文件!</div>
</el-upload>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitFileForm">确 定</el-button>
<el-button @click="upload.open = false">取 消</el-button>
</div>
</el-dialog>
<!-- pdf -->
<el-dialog :title="upload.title" :visible.sync="pdfopen" width="1200px" append-to-body :close-on-click-modal="false">
<iframe ref="iframe" title="mip" width="100%" height="900px" :src="pdfurl" > </iframe>
</el-dialog>
<!-- 用户导入对话框 -->
<el-dialog :title="uploadDetail.title" :visible.sync="uploadDetail.open" width="400px" append-to-body :close-on-click-modal="false">
<el-upload ref="uploadDetail" :limit="1" accept=".xlsx, .xls"
:headers="uploadDetail.headers" :action="uploadDetail.url"
:disabled="uploadDetail.isUploading"
:on-progress="handleFileUploadProgressDetail" :on-success="handleFileSuccessDetail" :auto-upload="false" drag>
<i class="el-icon-upload"></i>
<div class="el-upload__text">
将文件拖到此处,或
<em>点击上传</em>
</div>
<div class="el-upload__tip" slot="tip">
<el-link type="info" style="font-size:12px" @click="importTemplate">下载模板</el-link>
</div>
<div class="el-upload__tip" style="color:red" slot="tip">提示:仅允许导入“xls”或“xlsx”格式文件!</div>
</el-upload>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitFileFormDetail">确 定</el-button>
<el-button @click="uploadDetail.open = false">取 消</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import {timeMap,endDay} from "@/api/mes/timeMap";
import { getToken } from "@/utils/auth";
import { listTrainingRecord,getSignDetail, delTrainingRecord, addTrainingRecord,exportTrainingRecordDetail,exportTrainingRecordByDept, updateTrainingRecord, exportTrainingRecord, importTemplate } from "@/api/mes/trainingRecord";
import { selectTrainingClassInfo } from "@/api/mes/TrainingClassInfo";
import {addTrainingSignInForm,updateTrainingSignInForm,delTrainingSignInForm } from "@/api/mes/trainingSignInForm";
import SelectStaffTable from "@/views/components/selectStaffTable";
export default {
name: "TrainingRecord",
components: {
SelectStaffTable,
},
data() {
return {
statusOptions: [ {
value: 0,
label: '未开始'
}, {
value: 1,
label: '已完成'
}],
queryDateRange:null,
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
pdfopen: false,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 培训记录表格数据
trainingRecordList: [],
batchEditFlag: true,
typeOptions: [] ,
addrOptions: [] ,
evaluationModeOptions: [],
classInfoOptions: [],
classInfo: {},
disableList:[],
detailId: undefined,
pdfurl:"",
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
signOpen: false,
selectStaffopen: false,
detailOpen: false,
// 用户导入参数
uploadDetail: {
// 是否显示弹出层(用户导入)
open: false,
// 弹出层标题(用户导入)
title: "导入人数据",
// 是否禁用上传
isUploading: false,
// 设置上传的请求头部
headers: { Authorization: "Bearer " + getToken() },
// 上传的地址
url: process.env.VUE_APP_BASE_API + "/mes/trainingRecord/importData",
},
// 用户导入参数
upload: {
// 是否显示弹出层(用户导入)
open: false,
type: "",
id:"",
// 弹出层标题(用户导入)
title: "",
// 是否禁用上传
isUploading: false,
// 是否更新已经存在的用户数据
updateSupport: 0,
// 设置上传的请求头部
headers: { Authorization: "Bearer " + getToken() },
// 上传的地址
url: process.env.VUE_APP_BASE_API + "/mes/trainingRecord/uploadPDF",
},
// 查询参数
queryParams: {
code: null,
classId: null,
className: null,
trainingTime: null,
duration: null,
addr: null,
type: null,
trainingObj: null,
content: null,
passingScore: null,
evaluationMode: null,
trainerScore: null,
trainer: null,
deptId: null,
deptName: null,
},
page:{
total: 0,
size: 10,
page: 1
},
// 表单参数
form: {},
signform:{},
detailDisabled: false,
// 表单校验
rules: {
className: [
{ required: true, trigger: "blur", message: "课程不能为空" }
],
trainingTime: [
{ required: true, trigger: "blur", message: "培训时间不能为空" },
],
duration: [
{ required: true, trigger: "blur", message: "培训时长不能为空" }
],
addr: [
{ required: true, trigger: "blur", message: "培训地点不能为空" }
],
type: [
{ required: true, trigger: "blur", message: "培训方式不能为空" }
] ,
trainingObj: [
{ required: true, trigger: "blur", message: "培训对象不能为空" }
] ,
evaluationModeList: [
{ required: true, trigger: "blur", message: "考核方式不能为空" }
] ,
trainer: [
{ required: true, trigger: "blur", message: "讲师不能为空" }
] ,
staffList: [
{ required: true, trigger: "blur", message: "参加员工不能为空" }
]
},
pickerOptions:{
disabledDate(time) {
return time.getTime() >= endDay().valueOf();
},
shortcuts: [{
text: '今天',
onClick(picker) {
picker.$emit('pick', timeMap[1].getTime(true));
}
}, {
text: '昨天',
onClick(picker) {
picker.$emit('pick', timeMap[-1].getTime(true));
}
}, {
text: '近7天',
onClick(picker) {
picker.$emit('pick', timeMap["7withToday"].getTime(true));
}
},{
text: '近30天',
onClick(picker) {
picker.$emit('pick', timeMap["30withToday"].getTime(true));
}
},
{
text: '近90天',
onClick(picker) {
picker.$emit('pick', timeMap[90].getTime(true));
}
}, {
text: '今年',
onClick(picker) {
picker.$emit('pick', timeMap["year"].getTime(true));
}
}
]
},
};
},
created() {
this.queryDateRange=timeMap["year"].getTime(true)
this.queryParams.startTime=this.queryDateRange[0]
this.queryParams.endTime=this.queryDateRange[1]
this.getList();
//培训方式
this.getDicts("training_class_type").then(response => {
this.typeOptions = response.data;
});
// training_evaluation_mode
this.getDicts("training_meeting_room").then(response => {
this.addrOptions = response.data;
});
this.getDicts("training_evaluation_mode").then(response => {
this.evaluationModeOptions = response.data;
});
selectTrainingClassInfo().then(response => {
this.classInfoOptions = response.data;
});
},
watch:{
queryDateRange: {
immediate: true, // 设置立即执行
handler(newValue, oldValue) {
console.log(newValue)
if(this.queryDateRange != null){
this.queryParams.startTime=this.queryDateRange[0]
this.queryParams.endTime=this.queryDateRange[1]
}else{
this.queryParams.startTime=null
this.queryParams.endTime=null
}
}
}
},
methods: {
selectClassInfo(e){
const classInfo = this.classInfoOptions.find(item => item.id === e);
this.form.className = classInfo.className;
this.form.content = classInfo.content;
this.form.duration = classInfo.classDuration;
this.form.type = classInfo.type;
this.form.passingScore=classInfo.passMark;
this.form.trainingObj=classInfo.trainingObj;
if( classInfo.evaluationMode && classInfo.evaluationMode != ''){
this.form.evaluationModeList = classInfo.evaluationMode.split(',').map(item => item.trim() );
}
console.log(this.form)
},
handleOpenPdf(row,type){
if(type ==1){
this.pdfurl = process.env.VUE_APP_BASE_API+ row.scoreFile
}else{
this.pdfurl = process.env.VUE_APP_BASE_API+ row.trainingFile
}
this.pdfopen = true;
},
// 考核方式字典翻译
evaluationModeFormat(row, column) {
return this.selectDictLabels(this.evaluationModeOptions, row.evaluationMode,',');
},
//及格
passFormat(row, column) {
let score = parseInt(row.score)
let passingScore = parseInt(this.form.passingScore)
if(!score || !passingScore){
return '-'
}else if(score < passingScore){
return '不合格'
}else{
return '合格';
}
},
// 考核方式字典翻译
typeFormat(row, column) {
return this.selectDictLabel(this.typeOptions, row.type,',');
},
getQueryParams(){
const params = {...this.queryParams, ...this.page};
return params;
},
/** 查询培训记录列表 */
getList() {
this.loading = true;
const queryParams = this.getQueryParams();
listTrainingRecord(queryParams).then(response => {
console.log(response)
this.trainingRecordList = response.data.rows;
console.log( this.trainingRecordList)
this.page.total = response.data.total;
this.loading = false;
});
},
// 取消按钮
cancelSign() {
this.signOpen = false;
this.resetForm("signform")
this.signform.staffList= []
},
cancelDetail() {
this.detailOpen = false;
this.batchEditFlag = true;
this.reset()
},
cancelAdd() {
this.open = false;
this.reset()
},
// 表单重置
reset() {
this.form = { };
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加培训记录";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
this.detailDisabled = false;
const id = row.id || this.ids
this.getDetail(id,"修改")
},
/** 详情按钮操作 */
handleDetail(row) {
const id = row.id
this.detailDisabled = true;
this.getDetail(id,"详情")
},
getDetail(id,title){
this.detailId = id;
getSignDetail(id).then(response => {
response.data.evaluationModeList = response.data.evaluationMode.split(',').map(item => item.trim() );
this.form = response.data;
this.form.count = response.data.trainingSignInFormList.length;
this.form.trainer = parseInt(this.form.trainer);
this.detailOpen = true;
this.title = title;
})
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
console.log(this.form)
this.form.evaluationMode = this.form.evaluationModeList.join(',')
if (this.form.id != null) {
updateTrainingRecord(this.form).then(response => {
if (response.code === 200) {
this.msgSuccess("修改成功");
this.open = false;
this.getList();
}
});
} else {
addTrainingRecord(this.form).then(response => {
if (response.code === 200) {
this.msgSuccess("新增成功");
this.open = false;
this.getList();
}
});
}
}
});
},
submitDetailForm(){
this.$refs["detailform"].validate(valid => {
updateTrainingRecord(this.form).then(response => {
if (response.code === 200) {
this.msgSuccess("保存成功");
this.form.trainingSignInFormList.map(e=>e['edit'] = false);
if(!this.batchEditFlag){
this.batchEditFlag = true;
}
this.getDetail(this.detailId)
}
});
});
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$confirm('是否确认删除培训记录编号为"' + ids + '"的数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return delTrainingRecord(ids);
}).then(() => {
this.getList();
this.msgSuccess("删除成功");
}).catch(function() {});
},
/** 导出按钮操作 */
handleExport() {
const queryParams = this.getQueryParams();
this.$confirm('是否确认导出所有培训记录数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return exportTrainingRecord(queryParams);
}).then(response => {
this.download(response.msg);
}).catch(function() {});
},
/** 导出按钮操作 */
handleExportDetail() {
const queryParams = this.getQueryParams();
this.$confirm('是否确认导出详情?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return exportTrainingRecordDetail(queryParams);
}).then(response => {
this.download(response.msg);
}).catch(function() {});
},
/** 导出按钮操作 */
handleExportByDept() {
const queryParams = this.getQueryParams();
this.$confirm('是否确认导出详情?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return exportTrainingRecordByDept(queryParams);
}).then(response => {
this.download(response.msg);
}).catch(function() {});
},
/** 导入按钮操作 */
handleImport(row) {
this.upload.title = "导入PDF";
this.upload.open = true;
this.upload.type = "";
this.upload.id = row.id || this.ids
console.log( this.upload.id)
},
/** 导入按钮操作 */
handleImportDetail() {
this.uploadDetail.title = "导入";
this.uploadDetail.open = true;
},
/** 下载模板操作 */
importTemplate() {
importTemplate().then((response) => {
this.download(response.msg);
});
},
// 文件上传中处理
handleFileUploadProgress(event, file, fileList) {
this.upload.isUploading = true;
},
// 文件上传成功处理
handleFileSuccess(response, file, fileList) {
this.upload.open = false;
this.upload.isUploading = false;
this.$refs.upload.clearFiles();
this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
this.getList();
},
// 文件上传中处理
handleFileUploadProgressDetail(event, file, fileList) {
this.uploadDetail.isUploading = true;
},
// 文件上传成功处理
handleFileSuccessDetail(response, file, fileList) {
this.uploadDetail.open = false;
this.uploadDetail.isUploading = false;
this.$refs.uploadDetail.clearFiles();
this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
this.getList();
},
// 提交上传文件
// 提交上传文件
submitFileFormDetail() {
console.log("----------------------")
this.$refs.uploadDetail.submit();
}, // 课程类型字典翻译 s stationNameOptions workingAreaOptions staffStatusOptions
submitFileForm() {
if(!this.upload.id ){
this.$message.error('请选择要上传的数据');
return
}
if(!this.upload.type ){
this.$message.error('请选择要上传的文件类型');
return
}
this.$refs.upload.submit();
},
handleEdit(index, row) {
this.$set(row, 'edit', true);
this.$forceUpdate();
console.log(index, row);
},
batchEdit(){
if(!this.batchEditFlag){
this.$confirm('确认取消批量修改,确保数据已保存?' , "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(() =>{
this.form.trainingSignInFormList.map(e=>e['edit']=this.batchEditFlag);
this.batchEditFlag = !this.batchEditFlag;
this.getDetail(this.detailId)
})
} else{
this.form.trainingSignInFormList.map(e=>this.$set(e, 'edit', this.batchEditFlag));
this.batchEditFlag = !this.batchEditFlag;
}
},
handleAddDetail(){
this.resetForm("signForm")
this.signOpen= true;
this.signform.trainningRecrodId = this.form.id;
this.signform.classId = this.form.classId;
this.signform.trainingTime = this.form.trainingTime;
this.disableList = this.form.trainingSignInFormList.map(e=> e.staffId)
},
submitSignForm(){
addTrainingSignInForm(this.signform).then(response => {
if (response.code === 200) {
this.msgSuccess("新增成功");
//关闭窗口
this.cancelSign()
//更新列表
this.getDetail(this.detailId)
}
});
},
save(index, row) {
row.edit = false;
console.log(index, row);
if (row.id != null) {
updateTrainingSignInForm(row).then(response => {
if (response.code === 200) {
this.msgSuccess("修改成功");
this.open = false;
this.getDetail(this.detailId)
}
});
} else {
addTrainingSignInForm(row).then(response => {
if (response.code === 200) {
this.msgSuccess("新增成功");
this.open = false;
this.getDetail(this.detailId)
}
});
}
},
handleSignDelete(index, row) {
console.log(index, row);
const ids = row.id || this.ids;
this.$confirm('是否确认删除 "' + row.staffName + '"的数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return delTrainingSignInForm(ids);
}).then(() => {
this.getDetail(this.detailId)
this.msgSuccess("删除成功");
}).catch( () =>{
});
}
}
};
</script>