<template>
|
<div class="system-add-user-container">
|
<el-dialog :title="title" v-model="isShowDialog" width="50%">
|
<el-form :model="form" size="default" ref="formRef" :rules="rules" label-width="120px">
|
<el-row :gutter="35">
|
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
|
<el-form-item label="考试参与率" prop="examJoinRate">
|
<el-input v-model.trim="form.examJoinRate" placeholder="考试参与率" type="number" clearable>
|
<template #append>%</template>
|
</el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
|
<el-form-item label="考试合格率" prop="examPassRate">
|
<el-input v-model.trim="form.examPassRate" placeholder="考试合格率" type="number" clearable>
|
<template #append>%</template>
|
</el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
|
<el-form-item label="缺考总数" prop="missExam">
|
<el-input v-model.trim="form.missExam" placeholder="缺考总数" type="number" clearable></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
|
<el-form-item label="待补课总数" prop="repairNum">
|
<el-input v-model.trim="form.repairNum" placeholder="待补课总数" type="number" clearable></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
|
<el-form-item label="人均学时" prop="studyAverage">
|
<el-input v-model.trim="form.studyAverage" placeholder="人均学时" type="number" clearable></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
|
<el-form-item label="学时达标率" prop="studyQualifyRate">
|
<el-input v-model.trim="form.studyQualifyRate" placeholder="学时达标率" type="number" clearable>
|
<template #append>%</template>
|
</el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
|
<el-form-item label="培训人数" prop="trainPerson">
|
<el-input v-model.trim.number="form.trainPerson" placeholder="培训人数" type="number" clearable></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
|
<el-form-item label="培训参与率" prop="trainJoinRate">
|
<el-input v-model.trim="form.trainJoinRate" placeholder="培训参与率" type="number" clearable>
|
<template #append>%</template>
|
</el-input>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</el-form>
|
<template #footer>
|
<span class="dialog-footer">
|
<el-button @click="isShowDialog = !isShowDialog" size="default">取 消</el-button>
|
<el-button type="primary" v-throttle @click="onSubmit" size="default">确 定</el-button>
|
</span>
|
</template>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script lang="ts">
|
import { reactive, toRefs, onMounted, defineComponent, ref } from 'vue';
|
import { ElMessageBox, ElMessage } from 'element-plus';
|
import axios from "axios";
|
import {workApplyApi} from "/@/api/specialWorkSystem/workApply";
|
import {educateTrainApi} from "/@/api/dataUpload/educateTrain";
|
|
// 定义接口来定义对象的类型
|
interface DataState {
|
title: string
|
isShowDialog: boolean
|
form: {
|
examJoinRate: string
|
examPassRate: string
|
missExam: string
|
rankWeek: string
|
repairNum: string
|
studyAverage: string
|
studyQualifyRate: string
|
trainPerson: null | number
|
trainJoinRate: string
|
}
|
rules:{}
|
}
|
|
export default defineComponent({
|
name: 'reportDialog',
|
setup(props, context) {
|
const formRef = ref()
|
const state = reactive<DataState>({
|
title: '',
|
isShowDialog: false,
|
form: {
|
examJoinRate: '',
|
examPassRate: '',
|
missExam: '',
|
rankWeek: '',
|
repairNum: '',
|
studyAverage: '',
|
studyQualifyRate: '',
|
trainPerson: null,
|
trainJoinRate: ''
|
},
|
rules:{
|
examJoinRate: [{ required: true, message: '请填写考试参与率', trigger: 'blur' }],
|
examPassRate: [{ required: true, message: '请填写考试合格率', trigger: 'blur' }],
|
missExam: [{ required: true, message: '请填写缺考总数', trigger: 'blur' }],
|
repairNum: [{ required: true, message: '请填写待补课总数', trigger: 'blur' }],
|
studyAverage: [{ required: true, message: '请填写人均学时', trigger: 'blur' }],
|
studyQualifyRate: [{ required: true, message: '请填写学时达标率', trigger: 'blur' }],
|
trainPerson: [{ required: true, message: '请填写培训人数', trigger: 'blur' }],
|
trainJoinRate: [{ required: true, message: '请填写培训参与率', trigger: 'blur' }]
|
}
|
})
|
|
// 页面加载时
|
onMounted(() => {
|
|
})
|
// 打开弹窗
|
const open = (type: string, data: object) => {
|
state.isShowDialog = true;
|
if (type === 'add') {
|
state.title = '新增上报';
|
state.form = {
|
examJoinRate: '',
|
examPassRate: '',
|
missExam: '',
|
rankWeek: getWeekNumber(),
|
repairNum: '',
|
studyAverage: '',
|
studyQualifyRate: '',
|
trainPerson: null,
|
trainJoinRate: ''
|
};
|
}
|
};
|
|
// 新增修改
|
const onSubmit = async () => {
|
formRef.value.validate(async (valid:Boolean) => {
|
if(valid){
|
const res = await educateTrainApi().addTrain([state.form])
|
if(res.data.code == 200){
|
ElMessage({
|
type:'success',
|
message:'数据上报成功'
|
})
|
state.isShowDialog = false
|
}else{
|
ElMessage({
|
type:'warning',
|
message:res.data.msg
|
})
|
}
|
context.emit('refresh');
|
|
}else{
|
ElMessage({
|
type:'warning',
|
message:'请完善基本信息'
|
})
|
}
|
})
|
}
|
|
function getWeekNumber() {
|
// 获取当前日期
|
const today = new Date();
|
|
// 获取当前年的第一天
|
const firstDayOfYear = new Date(today.getFullYear(), 0, 1);
|
|
// 计算当前日期与第一天之间的时间差(毫秒)
|
const timeDiff = today - firstDayOfYear;
|
|
// 计算经过的天数,并将其转换为周数
|
const weekNumber = Math.ceil((timeDiff / (24 * 60 * 60 * 1000) + 1) / 7);
|
|
return weekNumber.toString()
|
}
|
|
return {
|
formRef,
|
open,
|
onSubmit,
|
...toRefs(state)
|
};
|
}
|
});
|
</script>
|