123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- <template>
- <div class="resume-box">
- <div class="resume-header">
- <div class="resume-title">{{ $t('resume.trainingExperience') }}</div>
- <v-btn variant="text" color="primary" prepend-icon="mdi-plus-box" @click="isEdit = true; type = 'add'">{{ $t('common.add') }}</v-btn>
- </div>
- <div v-if="isEdit" class="edit">
- <h4 class="label-title my-3 mx-2"> {{ type === 'add' ? $t('common.add') : $t('common.edit') }}{{ $t('resume.trainingExperience') }}</h4>
- <CtForm ref="formPageRef" :items="items" style="width: 100%;"></CtForm>
- <div class="text-end">
- <v-btn class="half-button mr-3" variant="tonal" @click="handleCancel">{{ $t('common.cancel') }}</v-btn>
- <v-btn color="primary" class="half-button" :loading="loading" @click="handleSave">{{ $t('common.save') }}</v-btn>
- </div>
- </div>
- <div v-else>
- <div v-if="trainExp.length">
- <div v-for="(k, i) in trainExp" :key="i" class="exp mx-n2 mt-5" @mouseenter="k.active = true" @mouseleave="k.active = false">
- <span class="float-right" v-if="k.active">
- <v-btn variant="text" color="primary" prepend-icon="mdi-square-edit-outline" @click="handleEdit(k)">{{ $t('common.edit') }}</v-btn>
- <v-btn variant="text" color="primary" prepend-icon="mdi-trash-can-outline" @click="handleDelete(k)">{{ $t('common.delete') }}</v-btn>
- </span>
- <div class="level1 d-flex align-center justify-space-between" style="height: 40px;">
- <div>
- <span style="font-size: 18px; font-weight: bold;">{{ k.orgName }}</span>
- <span class="label-title ml-5">
- <span>{{ timesTampChange(k.startTime, 'Y-M') }}</span>
- <span class="mx-1">至</span>
- <span>{{ timesTampChange(k.endTime, 'Y-M') }}</span>
- </span>
- </div>
- </div>
- <div class="my-2">
- <span class="label-title">培训课程:{{ k.course }}</span>
- </div>
- <div>
- <span class="label-title">培训描述:</span>
- <span class="label-title">{{ k.content || '暂无描述' }}</span>
- </div>
- </div>
- </div>
- <div v-else class="resumeNoDataText">{{ $t('resume.dataDefaultPrompt') }}{{ $t('resume.trainingExperience') }}...</div>
- </div>
- </div>
- </template>
- <script setup name="trainingExperience">
- import { ref } from 'vue'
- import { timesTampChange } from '@/utils/date'
- import { saveResumeTrainExp, getResumeTrainExp, deleteResumeTrainExp } from '@/api/recruit/personal/resume'
- import CtForm from '@/components/CtForm'
- import Snackbar from '@/plugins/snackbar'
- import Confirm from '@/plugins/confirm'
- const emit = defineEmits(['complete'])
- const isEdit = ref(false)
- const formPageRef = ref()
- const type = ref('')
- const editId = ref(null)
- const loading = ref(false)
- const items = ref({
- options: [
- {
- type: 'text',
- key: 'orgName',
- value: '',
- col: 6,
- label: '培训中心 *',
- flexStyle: 'mr-3',
- rules: [v => !!v || '请输入培训中心']
- },
- {
- type: 'text',
- key: 'course',
- value: '',
- col: 6,
- label: '培训课程 *',
- rules: [v => !!v || '请输入培训课程']
- },
- {
- type: 'datePicker',
- key: 'startTime',
- dateType: 'month', // 时间类型 year month date time
- value: null,
- label: '培训开始时间 *',
- col: 6,
- flexStyle: 'mr-3',
- outlined: true,
- clearable: true,
- rules: [v => !!v || '请选择培训开始时间']
- // options: {},
- },
- {
- type: 'datePicker',
- key: 'endTime',
- dateType: 'month', // 时间类型 year month date time
- value: null,
- label: '培训结束时间 *',
- col: 6,
- outlined: true,
- clearable: true,
- rules: [v => !!v || '请选择培训结束时间']
- // options: {},
- },
- {
- type: 'textarea',
- key: 'content',
- value: '',
- label: '培训描述',
- rows: 5,
- resize: true,
- counter: 2000,
- rules: [
- value => {
- if (value?.length <= 2000) return true
- return '请输入2-2000个字符'
- }
- ]
- }
- ]
- })
- const handleCancel = () => {
- isEdit.value = false
- type.value = ''
- editId.value = null
- items.value.options.forEach(e => {
- if (e.type === 'datePicker') e.value = {}
- else e.value = null
- })
- }
- // 获取培训经历
- const trainExp = ref([])
- const getResumeTrainExpData = async () => {
- const data = await getResumeTrainExp()
- // 完成度展示
- emit('complete', { status: Boolean(data?.length), id: 'trainingExperience' })
- trainExp.value = data
- }
- getResumeTrainExpData()
- // 保存培训经历
- const handleSave = async () => {
- const { valid } = await formPageRef.value.formRef.validate()
- if (!valid) return
- loading.value = true
- const obj = {}
- items.value.options.forEach(e => {
- obj[e.key] = e.value
- })
- if (editId.value) obj.id = editId.value
- try {
- await saveResumeTrainExp(obj)
- Snackbar.success('保存成功!')
- handleCancel()
- getResumeTrainExpData()
- } finally {
- loading.value = false
- }
- }
- const handleEdit = (item) => {
- editId.value = item.id
- items.value.options.forEach(e => {
- e.value = item[e.key]
- })
- isEdit.value = true
- }
- // 删除培训经历
- const handleDelete = ({ id }) => {
- Confirm('系统提示', '是否确认删除此项培训经历?').then(async () => {
- await deleteResumeTrainExp(id)
- Snackbar.success('删除成功!')
- getResumeTrainExpData()
- })
- }
- </script>
- <style scoped lang="scss">
- .exp {
- font-size: 15px;
- cursor: pointer;
- border-radius: 6px;
- padding: 2px 10px 8px;
- &:hover {
- background-color: var(--color-f8);
- }
- }
- .label-title {
- color: var(--color-666);
- }
- .edit {
- background-color: var(--color-f8);
- padding: 2px 10px 8px;
- border-radius: 6px;
- }
- </style>
|