<template>
|
<div>
|
<el-dialog :visible.sync="addTrainingPlanDia" :show="currshowlist" @close="$emit('update:currshowlist', false)"
|
title="新增培训计划" width="50%">
|
<div class="body">
|
<el-form ref="trainingPlan" :model="trainingPlan" label-position="right" label-width="90px"
|
:rules="trainingPlanRules">
|
<el-row>
|
<el-col :span="12">
|
<!-- <el-form-item label="培训日期:" prop="trainingDate">
|
<el-date-picker v-model="trainingPlan.trainingDate" format="yyyy-MM-dd"
|
placeholder="选择日期" size="small" value-format="yyyy-MM-dd"
|
type="date" style="width: 100%"></el-date-picker>
|
</el-form-item> -->
|
<el-form-item label="培训月份:" prop="trainingDate">
|
<el-select v-model="trainingPlan.trainingDate">
|
<el-option v-for="(v, i) in months" :key="i" :label="v.label" :value="v.value"></el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="培训日期:" prop="trainingDateTwo">
|
<el-date-picker v-model="trainingPlan.trainingDateTwo" type="date" value-format="yyyy-MM-dd"
|
placeholder="选择日期">
|
</el-date-picker>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="开始时间:" prop="openingTime">
|
<el-time-picker v-model="trainingPlan.openingTime" placeholder="选择时间" size="small" style="width: 100%"
|
value-format="HH:mm:ss"></el-time-picker>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="结束时间:" prop="endTime">
|
<el-time-picker v-model="trainingPlan.endTime" placeholder="选择时间" size="small" style="width: 100%"
|
value-format="HH:mm:ss"></el-time-picker>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="培训目标:">
|
<el-input v-model="trainingPlan.trainingObjectives" placeholder="请输入" size="small"></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="参加对象:">
|
<el-input v-model="trainingPlan.participants" placeholder="请输入" size="small"></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="培训内容:" prop="trainingContent">
|
<el-input v-model="trainingPlan.trainingContent" placeholder="请输入" size="small"></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="培训讲师:" prop="trainingLecturerId">
|
<el-select v-model="trainingPlan.trainingLecturerId" multiple clearable filterable placeholder="请选择"
|
size="small" style="width: 100%">
|
<el-option v-for="item in responsibleOptions" :key="item.id" :label="item.name" :value="item.name">
|
</el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="课题学分:">
|
<el-input type="number" v-model="trainingPlan.projectCredits" label="描述文字" size="small"></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="培训地点:">
|
<el-input v-model="trainingPlan.placeTraining" placeholder="请输入" size="small"></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="培训方式:">
|
<el-input v-model="trainingPlan.trainingMode" placeholder="请输入" size="small"></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="举办部门:">
|
<el-select v-model="trainingPlan.holdingDepartment" placeholder="请选择">
|
<el-option v-for="(v, i) in departLims" :key="i" :label="v.name" :value="v.id"></el-option>
|
</el-select>
|
<!--
|
<el-input
|
v-model="trainingPlan.holdingDepartment"
|
placeholder="请输入"
|
size="small"
|
></el-input> -->
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="课时:">
|
<el-input type="number" v-model="trainingPlan.classHour" label="描述文字" size="small"></el-input>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</el-form>
|
</div>
|
<span slot="footer" class="dialog-footer">
|
<el-button @click="closeAdd">取 消</el-button>
|
<el-button type="primary" @click="submitAdd">确 定</el-button>
|
</span>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script>
|
import {
|
selectDepartLims,
|
addOrUpdatePersonTrainingDetailed,
|
} from '@/api/cnas/personnel/personnelInfo.js'
|
import { selectUserCondition } from "@/api/system/user";
|
export default {
|
props: {
|
currshowlist: {
|
type: Boolean,
|
default: false,
|
},
|
currentChangeRow: {
|
type: Object,
|
default: () => {
|
return {};
|
},
|
},
|
},
|
name: "Add",
|
// import 引入的组件需要注入到对象中才能使用
|
components: {},
|
data() {
|
var trainingLecturerIdValidate = (rule, value, callback) => {
|
if (typeof value !== "undefined" && value.length == 0) {
|
callback(new Error("请选择讲师"));
|
} else {
|
callback();
|
}
|
};
|
// 这里存放数据
|
return {
|
departLims: [],
|
months: [
|
{ label: "1月", value: "1月" },
|
{ label: "2月", value: "2月" },
|
{ label: "3月", value: "3月" },
|
{ label: "4月", value: "4月" },
|
{ label: "5月", value: "5月" },
|
{ label: "6月", value: "6月" },
|
{ label: "7月", value: "7月" },
|
{ label: "8月", value: "8月" },
|
{ label: "9月", value: "9月" },
|
{ label: "10月", value: "10月" },
|
{ label: "11月", value: "11月" },
|
{ label: "12月", value: "12月" },
|
],
|
addTrainingPlanDia: false,
|
trainingPlan: {
|
id: "",
|
planId: "",
|
trainingDate: "",
|
trainingDateTwo: "",
|
classHour: "",
|
openingTime: "",
|
endTime: "",
|
trainingObjectives: "",
|
participants: "",
|
trainingContent: "",
|
trainingLecturerId: undefined,
|
projectCredits: "",
|
placeTraining: "",
|
trainingMode: "",
|
holdingDepartment: "",
|
},
|
trainingPlanRules: {
|
trainingDate: [
|
{ required: true, message: "请选择培训日期", trigger: "change" },
|
],
|
trainingDateTwo: [
|
{ required: true, message: "请选择培训日期", trigger: "change" },
|
],
|
openingTime: [
|
{ required: true, message: "请选择开始时间", trigger: "change" },
|
],
|
endTime: [
|
{ required: true, message: "请选择结束时间", trigger: "change" },
|
],
|
trainingContent: [
|
{ required: true, message: "请输入培训内容", trigger: "blur" },
|
],
|
trainingLecturerId: [
|
{
|
required: true,
|
validator: trainingLecturerIdValidate,
|
trigger: "change",
|
},
|
],
|
},
|
responsibleOptions: [],
|
};
|
},
|
created() {
|
this.departLims = [];
|
selectDepartLims().then((res) => {
|
this.departLims = res.data;
|
});
|
},
|
// 方法集合
|
methods: {
|
showDialog(id) {
|
this.trainingPlan.planId = id;
|
this.getUserList();
|
// this.addTrainingPlanDia = true;
|
},
|
showEditDialog(row) {
|
this.getUserList();
|
let data = JSON.parse(JSON.stringify(row));
|
|
console.log(data.trainingLecturerId);
|
let list = data.trainingLecturerId.split(/、|,|,|\\s+/);
|
this.$set(this.trainingPlan, "trainingLecturerId", list);
|
this.$set(this.trainingPlan, "id", data.id);
|
this.$set(this.trainingPlan, "trainingDate", data.trainingDate);
|
this.$set(this.trainingPlan, "trainingDateTwo", data.trainingDateTwo);
|
this.$set(this.trainingPlan, "classHour", data.classHour);
|
this.$set(this.trainingPlan, "openingTime", data.openingTime);
|
this.$set(this.trainingPlan, "endTime", data.endTime);
|
this.$set(
|
this.trainingPlan,
|
"trainingObjectives",
|
data.trainingObjectives
|
);
|
this.$set(this.trainingPlan, "participants", data.participants);
|
this.$set(this.trainingPlan, "projectCredits", data.projectCredits);
|
this.$set(this.trainingPlan, "placeTraining", data.placeTraining);
|
this.$set(this.trainingPlan, "trainingContent", data.trainingContent);
|
this.$set(this.trainingPlan, "trainingMode", data.trainingMode);
|
this.$set(this.trainingPlan, "holdingDepartment", data.holdingDepartment);
|
this.$set(this.trainingPlan, "planId", data.planId);
|
|
console.log("222", this.trainingPlan);
|
},
|
// 提交新增
|
submitAdd() {
|
this.$refs.trainingPlan.validate((valid) => {
|
if (valid) {
|
// 将培训讲师值封装
|
this.trainingPlan.trainingLecturerId =
|
this.trainingPlan.trainingLecturerId.join(",");
|
console.log(
|
"this.trainingPlan.trainingLecturerId",
|
this.trainingPlan.trainingLecturerId
|
);
|
const personTrainingDetailed = this.trainingPlan;
|
console.log("personTrainingDetailed", personTrainingDetailed);
|
addOrUpdatePersonTrainingDetailed(personTrainingDetailed).then((res) => {
|
if (res.code == 200) {
|
this.$message.success("提交成功");
|
this.closeAdd();
|
this.dialogVisible = false;
|
}
|
});
|
}
|
});
|
},
|
// 关闭弹框
|
closeAdd() {
|
this.$refs.trainingPlan.resetFields();
|
this.$emit("search");
|
this.$emit("searchPlan");
|
this.addTrainingPlanDia = false;
|
},
|
// 获取负责人信息接口
|
getUserList() {
|
selectUserCondition().then((res) => {
|
if (res.code == 200) {
|
this.responsibleOptions = res.data;
|
}
|
});
|
},
|
},
|
watch: {
|
// addTrainingPlanDia(newVal) {
|
// if (newVal) {
|
// this.trainingPlan.planId = null;
|
// }
|
// },
|
currshowlist(newValue) {
|
this.addTrainingPlanDia = this.currshowlist;
|
if (!newValue) {
|
this.closeAdd();
|
this.trainingPlan = {
|
id: "",
|
planId: "",
|
trainingDate: "",
|
classHour: "",
|
openingTime: "",
|
endTime: "",
|
trainingObjectives: "",
|
participants: "",
|
trainingContent: "",
|
trainingLecturerId: undefined,
|
projectCredits: "",
|
placeTraining: "",
|
trainingMode: "",
|
holdingDepartment: "",
|
};
|
}
|
if (this.currshowlist) {
|
this.$nextTick(() => {
|
if (this.trainingPlan.trainingLecturerId.length == 0) {
|
this.trainingPlan.trainingLecturerId = undefined;
|
}
|
});
|
}
|
},
|
},
|
};
|
</script>
|
|
<style scoped></style>
|