trainingExperience.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <template>
  2. <div class="resume-box elevation-2 mb-3" id="trainingExperience">
  3. <div class="resume-header">
  4. <div class="resume-title">{{ $t('resume.trainingExperience') }}</div>
  5. <v-btn variant="text" color="primary" prepend-icon="mdi-plus-box" @click="isEdit = true; type = 'add'">{{ $t('common.add') }}</v-btn>
  6. </div>
  7. <div v-if="isEdit" class="edit">
  8. <h4 class="label-title my-3 mx-2"> {{ type === 'add' ? $t('common.add') : $t('common.edit') }}{{ $t('resume.trainingExperience') }}</h4>
  9. <CtForm ref="formPageRef" :items="items" style="width: 100%;"></CtForm>
  10. <div class="text-end">
  11. <v-btn class="half-button mr-3" variant="tonal" @click="handleCancel">{{ $t('common.cancel') }}</v-btn>
  12. <v-btn color="primary" class="half-button" :loading="loading" @click="handleSave">{{ $t('common.save') }}</v-btn>
  13. </div>
  14. </div>
  15. <div v-else>
  16. <div v-if="trainExp.length">
  17. <div v-for="(k, i) in trainExp" :key="i" class="exp mx-n2 mt-5" @mouseenter="k.active = true" @mouseleave="k.active = false">
  18. <span class="float-right" v-if="k.active">
  19. <v-btn variant="text" color="primary" prepend-icon="mdi-square-edit-outline" @click="handleEdit(k)">{{ $t('common.edit') }}</v-btn>
  20. <v-btn variant="text" color="primary" prepend-icon="mdi-trash-can-outline" @click="handleDelete(k)">{{ $t('common.delete') }}</v-btn>
  21. </span>
  22. <div class="level1 d-flex align-center justify-space-between" style="height: 40px;">
  23. <div>
  24. <span style="font-size: 18px; font-weight: bold;">{{ k.orgName }}</span>
  25. <span class="label-title ml-5">
  26. <span>{{ timesTampChange(k.startTime, 'Y-M') }}</span>
  27. <span class="mx-1">至</span>
  28. <span>{{ timesTampChange(k.endTime, 'Y-M') }}</span>
  29. </span>
  30. </div>
  31. </div>
  32. <div class="my-2">
  33. <span class="label-title">培训课程:{{ k.course }}</span>
  34. </div>
  35. <div>
  36. <span class="label-title">培训描述:</span>
  37. <span class="label-title">{{ k.content || '暂无描述' }}</span>
  38. </div>
  39. </div>
  40. </div>
  41. <div v-else class="resumeNoDataText">{{ $t('resume.dataDefaultPrompt') }}{{ $t('resume.trainingExperience') }}...</div>
  42. </div>
  43. </div>
  44. </template>
  45. <script setup name="trainingExperience">
  46. import { ref } from 'vue'
  47. import { timesTampChange } from '@/utils/date'
  48. import { saveResumeTrainExp, getResumeTrainExp, deleteResumeTrainExp } from '@/api/recruit/personal/resume'
  49. import CtForm from '@/components/CtForm'
  50. import Snackbar from '@/plugins/snackbar'
  51. import Confirm from '@/plugins/confirm'
  52. const emit = defineEmits(['complete'])
  53. const isEdit = ref(false)
  54. const formPageRef = ref()
  55. const type = ref('')
  56. const editId = ref(null)
  57. const loading = ref(false)
  58. const items = ref({
  59. options: [
  60. {
  61. type: 'text',
  62. key: 'orgName',
  63. value: '',
  64. col: 6,
  65. label: '培训中心 *',
  66. flexStyle: 'mr-3',
  67. rules: [v => !!v || '请输入培训中心']
  68. },
  69. {
  70. type: 'text',
  71. key: 'course',
  72. value: '',
  73. col: 6,
  74. label: '培训课程 *',
  75. rules: [v => !!v || '请输入培训课程']
  76. },
  77. {
  78. type: 'datePicker',
  79. key: 'startTime',
  80. mode: 'month',
  81. value: null,
  82. labelWidth: 140,
  83. format: 'YYYY/MM',
  84. label: '培训开始时间 *',
  85. col: 6,
  86. flexStyle: 'mr-3',
  87. rules: [v => !!v || '请选择培训开始时间']
  88. },
  89. {
  90. type: 'datePicker',
  91. key: 'endTime',
  92. mode: 'month',
  93. value: null,
  94. format: 'YYYY/MM',
  95. labelWidth: 140,
  96. label: '培训结束时间 *',
  97. col: 6,
  98. rules: [v => !!v || '请选择培训结束时间']
  99. },
  100. {
  101. type: 'textarea',
  102. key: 'content',
  103. value: '',
  104. label: '培训描述',
  105. rows: 5,
  106. flexStyle: 'mt-5',
  107. resize: true,
  108. counter: 2000,
  109. rules: [
  110. value => {
  111. if (value?.length <= 2000) return true
  112. return '请输入2-2000个字符'
  113. }
  114. ]
  115. }
  116. ]
  117. })
  118. const handleCancel = () => {
  119. isEdit.value = false
  120. type.value = ''
  121. editId.value = null
  122. items.value.options.forEach(e => {
  123. e.value = null
  124. })
  125. }
  126. // 获取培训经历
  127. const trainExp = ref([])
  128. const getResumeTrainExpData = async () => {
  129. const data = await getResumeTrainExp()
  130. // 完成度展示
  131. emit('complete', { status: Boolean(data?.length), id: 'trainingExperience' })
  132. trainExp.value = data
  133. }
  134. getResumeTrainExpData()
  135. // 保存培训经历
  136. const handleSave = async () => {
  137. const { valid } = await formPageRef.value.formRef.validate()
  138. if (!valid) return
  139. loading.value = true
  140. const obj = {}
  141. items.value.options.forEach(e => {
  142. obj[e.key] = e.value
  143. })
  144. if (!obj.startTime || !obj.endTime) return Snackbar.warning('请选择培训起始时间!')
  145. if (editId.value) obj.id = editId.value
  146. try {
  147. await saveResumeTrainExp(obj)
  148. Snackbar.success('保存成功!')
  149. handleCancel()
  150. getResumeTrainExpData()
  151. } finally {
  152. loading.value = false
  153. }
  154. }
  155. const handleEdit = (item) => {
  156. editId.value = item.id
  157. items.value.options.forEach(e => {
  158. e.value = item[e.key]
  159. })
  160. isEdit.value = true
  161. }
  162. // 删除培训经历
  163. const handleDelete = ({ id }) => {
  164. Confirm('系统提示', '是否确认删除此项培训经历?').then(async () => {
  165. await deleteResumeTrainExp(id)
  166. Snackbar.success('删除成功!')
  167. getResumeTrainExpData()
  168. })
  169. }
  170. </script>
  171. <style scoped lang="scss">
  172. .exp {
  173. font-size: 15px;
  174. cursor: pointer;
  175. border-radius: 6px;
  176. padding: 2px 10px 8px;
  177. &:hover {
  178. background-color: var(--color-f8);
  179. }
  180. }
  181. .label-title {
  182. color: var(--color-666);
  183. }
  184. .edit {
  185. background-color: var(--color-f8);
  186. padding: 2px 10px 8px;
  187. border-radius: 6px;
  188. }
  189. :deep(.el-input--large .el-input__wrapper) {
  190. background-color: #f8f8f8;
  191. }
  192. </style>