<template>
|
<div>
|
<div class="page-header">
|
<h4><span class="line"></span><span>培训与考核记录</span></h4>
|
<div class="btns">
|
<el-button size="small" type="primary" @click="submitForm">{{ currentRow.state === 4 ? '提交' : '撤销' }}</el-button>
|
<el-button size="small" @click="$emit('goBack')">返回</el-button>
|
</div>
|
</div>
|
<div class="form_title">
|
<el-row>
|
<el-col :span="5">
|
<span class="form_label">课程编号:</span>
|
<span> {{ trainingForm.courseCode }} </span>
|
</el-col>
|
<el-col :span="6">
|
<span class="form_label">培训内容:</span>
|
<span> {{ trainingForm.trainingContent }} </span>
|
</el-col>
|
<el-col :span="4">
|
<span class="form_label">状态:</span>
|
<el-tag v-if="trainingForm.state === 1" type="success">已完成</el-tag>
|
<el-tag v-if="trainingForm.state === 2" type="warning">进行中</el-tag>
|
<el-tag v-if="trainingForm.state === 3" type="primary">未开始</el-tag>
|
<el-tag v-if="trainingForm.state === 4" type="info">已结束</el-tag>
|
</el-col>
|
<el-col :span="4">
|
<span class="form_label">培训讲师:</span>
|
<span> {{ trainingForm.trainingLecturerName }} </span>
|
</el-col>
|
<el-col :span="4">
|
<span class="form_label">培训日期:</span>
|
<span> {{ trainingForm.trainingDate }} </span>
|
</el-col>
|
</el-row>
|
<el-row style="margin: 15px 0">
|
<el-form>
|
<el-col :span="12">
|
<el-form-item label="考核方式">
|
<el-input v-model="trainingForm.assessmentMethod" :disabled="currentRow.state === 1" :rows="2" placeholder="请输入"
|
size="small" style="width: 79%" type="textarea"></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="本次培训综合评价">
|
<el-input v-model="trainingForm.comprehensiveAssessment" :disabled="currentRow.state === 1" :rows="2" placeholder="请输入"
|
size="small" style="width: 68%" type="textarea"></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="评价人">
|
<el-select v-model="trainingForm.assessmentUserId" :disabled="currentRow.state === 1" placeholder="请选择" size="small" style="width: 68%">
|
<el-option v-for="item in userList" :key="item.id" :label="item.name" :value="item.id"></el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="评价时间">
|
<el-date-picker v-model="trainingForm.assessmentDate" :disabled="currentRow.state === 1" style="width:40%"
|
type="date" format="yyyy-MM-dd" value-format="yyyy-MM-dd" size="small"
|
placeholder="选择日期">
|
</el-date-picker>
|
</el-form-item>
|
</el-col>
|
</el-form>
|
</el-row>
|
</div>
|
<el-divider>人员详情</el-divider>
|
<div>
|
<div class="items_center">
|
<span>姓名</span>
|
<el-input v-model="userName" class="search" placeholder="请输入"
|
size="small"></el-input>
|
<el-button size="small" type="primary" @click="getInfo">查询</el-button>
|
</div>
|
<div class="items_btn">
|
<el-button :disabled="currentRow.state === 1" size="small" type="primary" @click="addPerson">新增人员</el-button>
|
<el-button :disabled="currentRow.state === 1" size="small" @click="batchDelete">批量删除</el-button>
|
</div>
|
<el-table :data="trainingTableData" height="calc(100vh - 30em)" stripe style="width: 100%"
|
@selection-change="handleSelectionChange">
|
<el-table-column type="selection" width="55"></el-table-column>
|
<el-table-column label="序号" type="index" width="60"></el-table-column>
|
<el-table-column label="姓名" prop="userName"></el-table-column>
|
<el-table-column label="工号" prop="account"></el-table-column>
|
<el-table-column label="角色" prop="roleName"></el-table-column>
|
<el-table-column label="电话号码" prop="phone"></el-table-column>
|
<el-table-column label="考核结果" prop="examinationResults">
|
<template v-slot="scope">
|
<el-input v-model="scope.row.examinationResults" :disabled="currentRow.state === 1" clearable size="small" style="width: 100%" @blur="updatePersonResult(scope.row)"></el-input>
|
</template>
|
</el-table-column>
|
</el-table>
|
</div>
|
<el-dialog :visible.sync="selectUserDia" title="选择用户" width="70%">
|
<div class="search" style="margin-bottom: 9px;">
|
<div class="search_thing">
|
<div class="search_label">用户名:</div>
|
<div class="search_input">
|
<el-input
|
v-model="addUserTableInfo.entity.name"
|
clearable
|
placeholder="请输入"
|
size="small"
|
@keyup.enter.native="$refs.ValueTable.selectList()"
|
></el-input>
|
</div>
|
</div>
|
</div>
|
<div v-if="selectUserDia" class="body" style="height: 60vh;">
|
<ValueTable
|
ref="ValueTable"
|
:componentData="addUserTableInfo"
|
:isSelectedList="isSelectedList"
|
:url="$api.user.selectUserList"
|
/>
|
</div>
|
<span slot="footer" class="dialog-footer">
|
<el-button @click="selectUserDia = false">取 消</el-button>
|
<el-button type="primary" @click="selectUser">确 定</el-button>
|
</span>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script>
|
import TableCard from '../../caorui/TableCard/index.vue';
|
import ZTTable from '../../caorui/ZTTable/index.vue';
|
import ValueTable from '../../tool/value-table.vue';
|
|
export default {
|
name: 'Edit',
|
// import 引入的组件需要注入到对象中才能使用
|
components: {ValueTable, ZTTable, TableCard},
|
props: {
|
currentRow: {
|
type: Object,
|
default: () => {
|
return {}
|
}
|
},
|
},
|
data() {
|
// 这里存放数据
|
return {
|
isSelectedList: [], // 禁用的多选
|
userName: undefined,
|
trainingForm: {
|
code: '111111',
|
date: '2024-10-10',
|
},
|
trainingColumn: [
|
{
|
label: '姓名',
|
prop: 'userName'
|
},
|
{
|
label: '工号',
|
prop: 'account'
|
},
|
{
|
label: '角色',
|
prop: 'roleName'
|
},
|
{
|
label: '电话号码',
|
prop: 'phone'
|
},
|
{
|
label: '考核结果',
|
prop: 'result'
|
}
|
],
|
trainingTableData: [],
|
trainingLoading: false,
|
selectUserDia: false, // 添加人员弹框
|
addUserTableInfo: {
|
name: null,
|
entity: {
|
departLimsId: '1',
|
orderBy: {
|
field: 'id',
|
order: 'asc'
|
}
|
},
|
isIndex: true,
|
showSelect: true,
|
select: true,
|
do: [],
|
tagField: {
|
state: {
|
select: [
|
{
|
value: 1,
|
type: 'success',
|
label: '启用'
|
},
|
{
|
value: 0,
|
type: 'danger',
|
label: '停用'
|
}
|
]
|
}
|
},
|
selectField: {},
|
upUserDepardLimsIdPower: true
|
},
|
multipleSelection: [],
|
userList: [],
|
};
|
},
|
mounted() {
|
this.trainingForm = this.currentRow
|
this.getInfo()
|
this.getUserList()
|
},
|
// 方法集合
|
methods: {
|
// 获取当前数据
|
async getInfo() {
|
this.trainingLoading = true
|
await this.$axios({
|
method: 'get',
|
url: this.$api.personnel.trainingAndAssessmentRecordsPage,
|
params: {
|
trainingDetailedId: this.currentRow.id,
|
userName: this.userName
|
},
|
headers: {
|
'Content-Type': 'application/x-www-form-urlencoded'
|
},
|
noQs: true
|
})
|
.then(res => {
|
if (res.code === 200) {
|
this.trainingTableData = res.data
|
}
|
this.trainingLoading = false
|
})
|
},
|
async updatePersonResult(row) {
|
const { code } = await this.$axios({
|
method: 'post',
|
url: this.$api.personnel.outOfFocusPreservation,
|
data: row,
|
headers: {
|
'Content-Type': 'application/json'
|
}
|
})
|
if (code === 200) {
|
this.$message.success("操作成功!")
|
}
|
},
|
addPerson() {
|
this.isSelectedList = this.trainingTableData.map(item => item.userId)
|
this.selectUserDia = true;
|
},
|
selectUser() {
|
let selects = this.$refs.ValueTable.multipleSelection;
|
if (selects.length == 0) {
|
this.$message.error('未选择数据');
|
return;
|
}
|
let list = []
|
selects.forEach(a => {
|
const obj = {
|
courseId: this.currentRow.id,
|
examinationResults: "",
|
userId: a.id
|
}
|
list.push(obj)
|
// this.trainingTableData.push(obj);
|
});
|
this.$axios({
|
method: 'post',
|
url: this.$api.personnel.newPersonnelAddedToTrainingRecords,
|
data: list,
|
headers: {
|
'Content-Type': 'application/json'
|
},
|
noQs: true
|
})
|
.then(res => {
|
this.isSelectedList = []
|
this.selectUserDia = false;
|
this.getInfo()
|
})
|
},
|
// 批量删除
|
handleSelectionChange(list) {
|
this.multipleSelection = list
|
},
|
batchDelete() {
|
console.log('批量删除', this.multipleSelection)
|
if (this.multipleSelection.length > 0) {
|
let ids = this.multipleSelection.map(item => item.trainingRecordId)
|
this.$confirm('是否确认删除所选择的数据?', '提示', {
|
confirmButtonText: '确定',
|
cancelButtonText: '取消',
|
type: 'warning'
|
}).then(() => {
|
let formData = new FormData()
|
formData.append('ids', ids)
|
this.$axios({
|
method: 'post',
|
url: this.$api.personnel.deleteTrainingAndAssessmentRecords,
|
data: formData,
|
headers: {
|
'Content-Type': 'application/x-www-form-urlencoded'
|
},
|
noQs: true
|
})
|
.then(res => {
|
if (res.code == 200) {
|
this.$message.success('删除成功');
|
this.getInfo()
|
}
|
});
|
}).catch(() => {
|
this.$message.warning('取消删除');
|
});
|
} else {
|
this.$message.warning('请选择需要删除的数据')
|
}
|
},
|
handleSizeChange(val) {
|
this.search.size = val;
|
this.getInfo();
|
},
|
handleCurrentChange(val) {
|
this.search.current = val;
|
this.getInfo();
|
},
|
/**
|
* @desc 提交表单
|
*/
|
async submitForm() {
|
if (this.currentRow.state !== 4 && this.currentRow.state !== 1) {
|
this.$message.warning("当前状态无法提交/撤销!")
|
return
|
}
|
// 如果等于4 表示该状态为已结束,1 表示已完成
|
let state = this.currentRow.state === 4 ? 1 : 4
|
let data = {
|
assessmentMethod: this.trainingForm.assessmentMethod,
|
comprehensiveAssessment: this.trainingForm.comprehensiveAssessment,
|
trainingDetailedId: this.trainingForm.id,
|
assessmentUserId: this.trainingForm.assessmentUserId,
|
assessmentDate: this.trainingForm.assessmentDate,
|
state: state
|
}
|
const {code} = await this.$axios({
|
method: 'post',
|
url: this.$api.personnel.trainingAndAssessmentRecordsAdded,
|
data: data,
|
headers: {
|
'Content-Type': 'application/json;'
|
},
|
noQs: true
|
})
|
if(code === 200) {
|
this.currentRow.state = state
|
this.$message.success("操作成功")
|
}
|
},
|
getUserList(){
|
this.$axios.post(this.$api.user.selectUserList, {
|
page: {current: -1, size: -1,},
|
entity: {name: null, isCustom: 0}
|
}, {
|
headers: {
|
'Content-Type': 'application/json'
|
}
|
}).then(res => {
|
if (res.code === 201) {
|
return
|
}
|
this.userList = res.data.body.records
|
})
|
},
|
}
|
};
|
</script>
|
|
<style scoped>
|
.page-header {
|
display: flex;
|
align-items: center;
|
justify-content: space-between;
|
padding: 0 20px;
|
margin-bottom: 10px;
|
}
|
|
h4 {
|
display: flex;
|
align-items: center;
|
}
|
|
h4 .line {
|
display: inline-block;
|
width: 3px;
|
height: 16px;
|
background: #3A7BFA;
|
margin-right: 4px;
|
}
|
|
.form_title {
|
font-size: 14px;
|
padding: 0 20px;
|
margin-bottom: 10px;
|
}
|
|
.el-divider {
|
margin: 0 1em 1em 0;
|
}
|
|
.form__input_label {
|
width: 90px;
|
margin-right: 6px;
|
color: #606266;
|
}
|
|
.form__input_label2 {
|
width: 210px;
|
margin-right: 6px;
|
color: #606266;
|
}
|
.search_thing {
|
display: flex;
|
align-items: center
|
}
|
.search_label {
|
width: 120px;
|
}
|
.pagination {
|
display: flex;
|
justify-content: space-between
|
}
|
|
.items_center {
|
float: left;
|
width: 50%;
|
text-align: left;
|
}
|
.items_btn {
|
text-align: right;
|
width: 50%;
|
float: right;
|
margin-bottom: 1em;
|
}
|
|
.search {
|
width: 180px;
|
padding: 0 16px;
|
}
|
</style>
|