<!-- 工作履历 -->
|
<template>
|
<div>
|
<div style="text-align: right; margin-bottom: 15px;">
|
<el-button v-if="clickNodeVal.userId" size="small" type="primary" @click="dialogVisible = true">添加工作履历</el-button>
|
<el-button :loading="outLoading" size="small" type="primary" @click="exportExcel">导出excel</el-button>
|
</div>
|
<div class="table">
|
<el-table :data="tableData" height="70vh" style="width: 100%">
|
<el-table-column label="序号" type="index" width="120">
|
<template v-slot="scope">
|
<span>{{ (search.current - 1) * search.size + scope.$index + 1 }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column label="起始日期" min-width="180" prop="startTime">
|
</el-table-column>
|
<el-table-column label="结束日期" min-width="180" prop="endTime">
|
</el-table-column>
|
<el-table-column label="工作单位" min-width="120" prop="placeWork">
|
</el-table-column>
|
<el-table-column label="工作部门" min-width="120" prop="department">
|
</el-table-column>
|
<el-table-column label="职务" min-width="120" prop="post">
|
</el-table-column>
|
<el-table-column label="备注" min-width="180" prop="remarks">
|
</el-table-column>
|
<el-table-column label="创建人" min-width="180" prop="createUser">
|
</el-table-column>
|
<el-table-column label="创建时间" min-width="180" prop="createTime">
|
</el-table-column>
|
<el-table-column fixed="right" label="操作" width="150">
|
<template v-slot="scope">
|
<el-button size="small" type="text" @click="downloadFile(scope.row.fileName)">导出</el-button>
|
<el-button size="small" type="text" @click="checkFun(scope.row)">查看</el-button>
|
<el-button size="small" style="color: red;" type="text" @click="deleteFun(scope.row.id)">删除</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
<el-pagination :current-page="1" :page-size="search.size" :page-sizes="[10, 20, 30, 50, 100]"
|
:total="search.total" layout="->,total, sizes, prev, pager, next, jumper" @size-change="handleSizeChange"
|
@current-change="handleCurrentChange">
|
</el-pagination>
|
</div>
|
<el-dialog :visible.sync="dialogVisible" title="提示" width="45%">
|
<div style="height: 30vh;">
|
<el-form ref="ruleForm" :model="ruleForm" :rules="rules" class="demo-ruleForm" label-width="100px">
|
<el-row>
|
<el-col :span="12">
|
<el-form-item label="起始日期" prop="startTime">
|
<el-date-picker v-model="ruleForm.startTime" format="yyyy-MM-dd" placeholder="选择日期" required
|
size="small" style="width: 99%;" type="date" value-format="yyyy-MM-dd HH:mm:ss">
|
</el-date-picker>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="结束日期">
|
<el-date-picker v-model="ruleForm.endTime" format="yyyy-MM-dd" placeholder="选择日期" size="small"
|
style="width: 99%;" type="date" value-format="yyyy-MM-dd HH:mm:ss">
|
</el-date-picker>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="12">
|
<el-form-item label="工作单位" prop="placeWork">
|
<el-input v-model="ruleForm.placeWork" clearable required size="small"></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="工作部门" prop="department">
|
<el-input v-model="ruleForm.department" clearable required size="small"></el-input>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="12">
|
<el-form-item label="最高职务" prop="post">
|
<el-input v-model="ruleForm.post" clearable required size="small"></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="附件资料">
|
<el-row>
|
<el-col :span="17"><el-input v-model="ruleForm.fileName" disabled size="small"></el-input></el-col>
|
<el-col :span="7">
|
<el-upload ref="upload" :action="action" :on-change="handleChangePic" :on-success="onSuccess"
|
:show-file-list="false" style="float: left; margin: 0 20px;" :headers="uploadHeader">
|
<el-button slot="trigger" class="uploadFile" size="mini" type="primary">浏览</el-button>
|
</el-upload>
|
</el-col>
|
</el-row>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="24">
|
<el-form-item label="备注">
|
<el-input v-model="ruleForm.remarks" clearable size="small"></el-input>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</el-form>
|
</div>
|
<span slot="footer" class="dialog-footer">
|
<el-button @click="dialogVisible = false">取 消</el-button>
|
<el-button type="primary" @click="saveOrUpdate">{{ isUpdate ? '更 新' : '保 存' }}</el-button>
|
</span>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script>
|
import {
|
personTrackRecordExport,
|
personTrackRecordUpdate,
|
personTrackRecordSave,
|
personTrackRecordDelete,
|
personTrackRecordSelect,
|
} from '@/api/cnas/personnel/personnelInfo.js'
|
export default {
|
props: {
|
clickNodeVal: {
|
type: Object,
|
default: () => {
|
return {};
|
}
|
}
|
},
|
data() {
|
return {
|
tableData: [],
|
search: {
|
size: 20,
|
current: 1,
|
total: 0
|
},
|
dialogVisible: false,
|
ruleForm: {
|
fileName: '',
|
sysFileName: ''
|
},
|
rules: {
|
startTime: [
|
{ required: true, message: '请输入起始日期', trigger: 'blur' },
|
{ required: true, message: '请输入起始日期', trigger: 'change' }
|
],
|
placeWork: [
|
{ required: true, message: '请输入工作单位', trigger: 'blur' }
|
],
|
department: [
|
{ required: true, message: '请输入工作部门', trigger: 'blur' }
|
],
|
post: [
|
{ required: true, message: '请输入最高职务', trigger: 'blur' }
|
]
|
},
|
isUpdate: false,
|
outLoading: false
|
};
|
},
|
created() {
|
this.init();
|
},
|
computed: {
|
action() {
|
return this.javaApi + '/personBasicInfo/saveCNASFile'
|
}
|
},
|
methods: {
|
downloadFile(fileName) {
|
this.$download.saveAs(fileName, fileName)
|
},
|
handleChangePic(file, fileList) {
|
if (fileList.length > 1) {
|
fileList.splice(0, 1);
|
}
|
},
|
onSuccess(response, file, fileList) {
|
if (response.code === 200) {
|
this.$set(this.ruleForm, 'fileName', response.data)
|
} else {
|
this.$message.warning(response.message)
|
}
|
},
|
exportExcel() {
|
this.outLoading = true
|
let userId = this.clickNodeVal.userId ? this.clickNodeVal.userId : null
|
let departmentId = this.clickNodeVal.id ? this.clickNodeVal.id : null
|
personTrackRecordExport({
|
userId,
|
departmentId
|
}).then(res => {
|
this.outLoading = false
|
const blob = new Blob([res], { type: 'application/octet-stream' });
|
this.$download.saveAs(blob, '工作履历.xlsx')
|
})
|
},
|
saveOrUpdate() {
|
this.$refs['ruleForm'].validate((valid) => {
|
if (valid) {
|
if (this.isUpdate) {
|
personTrackRecordUpdate(this.ruleForm).then(res => {
|
if (res.code = 200) {
|
this.dialogVisible = false
|
this.$message.success('更新成功!')
|
this.init()
|
}
|
})
|
} else {
|
this.ruleForm.userId = this.clickNodeVal.userId
|
personTrackRecordSave(this.ruleForm).then(res => {
|
if (res.code = 200) {
|
this.dialogVisible = false
|
this.$message.success('新增成功!')
|
this.init()
|
}
|
})
|
}
|
} else {
|
return false;
|
}
|
});
|
},
|
deleteFun(id) {
|
this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
|
confirmButtonText: '确定',
|
cancelButtonText: '取消',
|
type: 'warning'
|
}).then(() => {
|
personTrackRecordDelete({ id }).then(res => {
|
this.$message.success('删除成功!')
|
this.init()
|
})
|
}).catch(() => {
|
this.$message({
|
type: 'info',
|
message: '已取消删除'
|
});
|
});
|
},
|
handleSizeChange(val) {
|
this.search.size = val
|
this.init()
|
},
|
handleCurrentChange(val) {
|
this.search.current = val
|
this.init()
|
},
|
// 初始化调用
|
init() {
|
if (this.clickNodeVal.userId) {
|
this.getPersonnelTraining(this.clickNodeVal.userId ? this.clickNodeVal.userId : null, null);
|
} else {
|
this.getPersonnelTraining(null, this.clickNodeVal.id ? this.clickNodeVal.id : null);
|
}
|
},
|
getPersonnelTraining(userId, departmentId) {
|
personTrackRecordSelect({
|
userId,
|
departmentId,
|
...this.search
|
}).then(res => {
|
this.tableData = res.data.records
|
this.search.total = res.data.total
|
})
|
},
|
checkFun(row) {
|
this.ruleForm = { ...row }
|
this.dialogVisible = true
|
this.isUpdate = true
|
}
|
},
|
watch: {
|
// 监听点击el-tree的数据,进行数据刷新
|
clickNodeVal(newVal) {
|
if (newVal.userId) {
|
// 用户id
|
this.getPersonnelTraining(newVal.userId, null);
|
} else {
|
// 部门id
|
this.getPersonnelTraining(null, newVal.id);
|
}
|
},
|
dialogVisible(newVal) {
|
if (!newVal) {
|
this.isUpdate = false
|
this.$refs.ruleForm.resetFields();
|
this.ruleForm = {}
|
}
|
}
|
}
|
};
|
</script>
|
<style scoped>
|
>>>.el-form-item {
|
margin-bottom: 13px;
|
}
|
</style>
|