trainingExperience.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <template>
  2. <div class="resume-box">
  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. dateType: 'month', // 时间类型 year month date time
  81. value: null,
  82. label: '培训开始时间 *',
  83. col: 6,
  84. flexStyle: 'mr-3',
  85. outlined: true,
  86. clearable: true,
  87. rules: [v => !!v || '请选择培训开始时间']
  88. // options: {},
  89. },
  90. {
  91. type: 'datePicker',
  92. key: 'endTime',
  93. dateType: 'month', // 时间类型 year month date time
  94. value: null,
  95. label: '培训结束时间 *',
  96. col: 6,
  97. outlined: true,
  98. clearable: true,
  99. rules: [v => !!v || '请选择培训结束时间']
  100. // options: {},
  101. },
  102. {
  103. type: 'textarea',
  104. key: 'content',
  105. value: '',
  106. label: '培训描述',
  107. rows: 5,
  108. resize: true,
  109. counter: 2000,
  110. rules: [
  111. value => {
  112. if (value?.length <= 2000) return true
  113. return '请输入2-2000个字符'
  114. }
  115. ]
  116. }
  117. ]
  118. })
  119. const handleCancel = () => {
  120. isEdit.value = false
  121. type.value = ''
  122. editId.value = null
  123. items.value.options.forEach(e => {
  124. if (e.type === 'datePicker') e.value = {}
  125. else e.value = null
  126. })
  127. }
  128. // 获取培训经历
  129. const trainExp = ref([])
  130. const getResumeTrainExpData = async () => {
  131. const data = await getResumeTrainExp()
  132. // 完成度展示
  133. emit('complete', { status: Boolean(data?.length), id: 'trainingExperience' })
  134. trainExp.value = data
  135. }
  136. getResumeTrainExpData()
  137. // 保存培训经历
  138. const handleSave = async () => {
  139. const { valid } = await formPageRef.value.formRef.validate()
  140. if (!valid) return
  141. loading.value = true
  142. const obj = {}
  143. items.value.options.forEach(e => {
  144. obj[e.key] = e.value
  145. })
  146. if (editId.value) obj.id = editId.value
  147. try {
  148. await saveResumeTrainExp(obj)
  149. Snackbar.success('保存成功!')
  150. handleCancel()
  151. getResumeTrainExpData()
  152. } finally {
  153. loading.value = false
  154. }
  155. }
  156. const handleEdit = (item) => {
  157. editId.value = item.id
  158. items.value.options.forEach(e => {
  159. e.value = item[e.key]
  160. })
  161. isEdit.value = true
  162. }
  163. // 删除培训经历
  164. const handleDelete = ({ id }) => {
  165. Confirm('系统提示', '是否确认删除此项培训经历?').then(async () => {
  166. await deleteResumeTrainExp(id)
  167. Snackbar.success('删除成功!')
  168. getResumeTrainExpData()
  169. })
  170. }
  171. </script>
  172. <style scoped lang="scss">
  173. .exp {
  174. font-size: 15px;
  175. cursor: pointer;
  176. border-radius: 6px;
  177. padding: 2px 10px 8px;
  178. &:hover {
  179. background-color: var(--color-f8);
  180. }
  181. }
  182. .label-title {
  183. color: var(--color-666);
  184. }
  185. .edit {
  186. background-color: var(--color-f8);
  187. padding: 2px 10px 8px;
  188. border-radius: 6px;
  189. }
  190. </style>