<!-- 工作履历 -->
|
<template>
|
<div>
|
<div style="text-align: right; margin-bottom: 15px;">
|
<el-button type="primary" size="small" @click="dialogVisible = true" v-if="clickNodeVal.userId">添加工作履历</el-button>
|
<el-button type="primary" size="small" @click="exportExcel" :loading="outLoading">导出excel</el-button>
|
</div>
|
<div class="table">
|
<el-table :data="tableData" style="width: 100%" height="70vh">
|
<el-table-column type="index" label="序号" width="120">
|
<template v-slot="scope">
|
<span>{{ (search.current - 1) * search.size + scope.$index + 1 }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column prop="startTime" label="起始日期" min-width="180">
|
</el-table-column>
|
<el-table-column prop="endTime" label="结束日期" min-width="180">
|
</el-table-column>
|
<el-table-column prop="placeWork" label="工作单位" min-width="120">
|
</el-table-column>
|
<el-table-column prop="department" label="工作部门" min-width="120">
|
</el-table-column>
|
<el-table-column prop="post" label="职务" min-width="120">
|
</el-table-column>
|
<el-table-column prop="remarks" label="备注" min-width="180">
|
</el-table-column>
|
<el-table-column prop="createUser" label="创建人" min-width="180">
|
</el-table-column>
|
<el-table-column prop="createTime" label="创建时间" min-width="180">
|
</el-table-column>
|
<el-table-column fixed="right" label="操作" width="150">
|
<template v-slot="scope">
|
<el-button type="text" size="small" @click="downloadFile(scope.row.fileName)">下载</el-button>
|
<el-button type="text" size="small" @click="checkFun(scope.row)">查看</el-button>
|
<el-button type="text" size="small" style="color: red;" @click="deleteFun(scope.row.id)">删除</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="1"
|
:page-sizes="[10, 20, 30, 50, 100]" :page-size="search.size" layout="->,total, sizes, prev, pager, next, jumper"
|
:total="search.total">
|
</el-pagination>
|
</div>
|
<el-dialog title="提示" :visible.sync="dialogVisible" width="45%">
|
<div style="height: 30vh;">
|
<el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
|
<el-row>
|
<el-col :span="12">
|
<el-form-item label="起始日期" prop="startTime">
|
<el-date-picker v-model="ruleForm.startTime" type="date" placeholder="选择日期" size="small"
|
style="width: 99%;" format="yyyy-MM-dd" value-format="yyyy-MM-dd HH:mm:ss" required>
|
</el-date-picker>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="结束日期">
|
<el-date-picker v-model="ruleForm.endTime" type="date" placeholder="选择日期" size="small"
|
style="width: 99%;" format="yyyy-MM-dd" 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" size="small" clearable required></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="工作部门" prop="department">
|
<el-input v-model="ruleForm.department" size="small" clearable required></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" size="small" clearable required></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" size="small" disabled></el-input></el-col>
|
<el-col :span="7">
|
<el-upload ref="upload" style="float: left; margin: 0 20px;" :action="action"
|
:on-success="onSuccess" :on-change="handleChangePic" :show-file-list="false">
|
<el-button class="uploadFile" slot="trigger" 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" size="small" clearable></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 fileDownload from '../../../util/file'
|
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 + this.$api.personnel.saveCNASFile
|
}
|
},
|
methods: {
|
downloadFile(fileName) {
|
let url = this.javaApi + '/img/' + fileName;
|
fileDownload.downloadIamge(url,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
|
this.$axios.get(this.$api.personnel.personTrackRecordExport + "?userId=" + userId + "&departmentId=" + departmentId, { responseType: "blob" }).then(res => {
|
this.outLoading = false
|
const blob = new Blob([res], { type: 'application/octet-stream' });
|
//将Blob 对象转换成字符串
|
let reader = new FileReader();
|
reader.readAsText(blob, 'utf-8');
|
reader.onload = () => {
|
try {
|
let result = JSON.parse(reader.result);
|
if (result.message) {
|
this.$message.error(result.message);
|
} else {
|
const url = URL.createObjectURL(blob);
|
const link = document.createElement('a');
|
link.href = url;
|
link.download = '工作履历.xlsx';
|
link.click();
|
this.$message.success('导出成功')
|
}
|
} catch (err) {
|
console.log(err);
|
const url = URL.createObjectURL(blob);
|
const link = document.createElement('a');
|
link.href = url;
|
link.download = '工作履历.xlsx';
|
link.click();
|
this.$message.success('导出成功')
|
}
|
}
|
})
|
},
|
saveOrUpdate() {
|
this.$refs['ruleForm'].validate((valid) => {
|
if (valid) {
|
if (this.isUpdate) {
|
this.$axios.put(this.$api.personnel.personTrackRecordUpdate, this.ruleForm, {
|
headers: {
|
'Content-Type': 'application/json'
|
}
|
}).then(res => {
|
if (res.code = 200) {
|
this.dialogVisible = false
|
this.$message.success('更新成功!')
|
this.init()
|
}
|
})
|
} else {
|
this.ruleForm.userId = this.clickNodeVal.userId
|
this.$axios.post(this.$api.personnel.personTrackRecordSave, this.ruleForm, {
|
headers: {
|
'Content-Type': 'application/json'
|
}
|
}).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(() => {
|
this.$axios.delete(this.$api.personnel.personTrackRecordDelete + "?id=" + 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) {
|
this.$axios.get(this.$api.personnel.personTrackRecordSelect + "?userId=" + userId + "&size=" + this.search.size + "¤t=" + this.search.current + "&departmentId=" + departmentId).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>
|