trainingExperience.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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 isEdit = ref(false)
  53. const formPageRef = ref()
  54. const type = ref('')
  55. const editId = ref(null)
  56. const loading = ref(false)
  57. const items = ref({
  58. options: [
  59. {
  60. type: 'text',
  61. key: 'orgName',
  62. value: '',
  63. col: 6,
  64. label: '培训中心 *',
  65. flexStyle: 'mr-3',
  66. rules: [v => !!v || '请输入培训中心']
  67. },
  68. {
  69. type: 'text',
  70. key: 'course',
  71. value: '',
  72. col: 6,
  73. label: '培训课程 *',
  74. rules: [v => !!v || '请输入培训课程']
  75. },
  76. {
  77. type: 'datePicker',
  78. key: 'startTime',
  79. dateType: 'month', // 时间类型 year month date time
  80. value: null,
  81. label: '培训开始时间 *',
  82. col: 6,
  83. flexStyle: 'mr-3',
  84. outlined: true,
  85. clearable: true,
  86. rules: [v => !!v || '请选择培训开始时间']
  87. // options: {},
  88. },
  89. {
  90. type: 'datePicker',
  91. key: 'endTime',
  92. dateType: 'month', // 时间类型 year month date time
  93. value: null,
  94. label: '培训结束时间 *',
  95. col: 6,
  96. outlined: true,
  97. clearable: true,
  98. rules: [v => !!v || '请选择培训结束时间']
  99. // options: {},
  100. },
  101. {
  102. type: 'textarea',
  103. key: 'content',
  104. value: '',
  105. label: '培训描述',
  106. rows: 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. if (e.type === 'datePicker') e.value = {}
  124. else e.value = null
  125. })
  126. }
  127. // 获取培训经历
  128. const trainExp = ref([])
  129. const getResumeTrainExpData = async () => {
  130. const data = await getResumeTrainExp()
  131. trainExp.value = data
  132. }
  133. getResumeTrainExpData()
  134. // 保存培训经历
  135. const handleSave = async () => {
  136. const { valid } = await formPageRef.value.formRef.validate()
  137. if (!valid) return
  138. loading.value = true
  139. const obj = {}
  140. items.value.options.forEach(e => {
  141. obj[e.key] = e.value
  142. })
  143. if (editId.value) obj.id = editId.value
  144. try {
  145. await saveResumeTrainExp(obj)
  146. Snackbar.success('保存成功!')
  147. handleCancel()
  148. getResumeTrainExpData()
  149. } finally {
  150. loading.value = false
  151. }
  152. }
  153. const handleEdit = (item) => {
  154. editId.value = item.id
  155. items.value.options.forEach(e => {
  156. e.value = item[e.key]
  157. })
  158. isEdit.value = true
  159. }
  160. // 删除培训经历
  161. const handleDelete = ({ id }) => {
  162. Confirm('系统提示', '是否确认删除此项培训经历?').then(async () => {
  163. await deleteResumeTrainExp(id)
  164. Snackbar.success('删除成功!')
  165. getResumeTrainExpData()
  166. })
  167. }
  168. </script>
  169. <style scoped lang="scss">
  170. .exp {
  171. font-size: 15px;
  172. cursor: pointer;
  173. border-radius: 6px;
  174. padding: 2px 10px 8px;
  175. &:hover {
  176. background-color: var(--color-f8);
  177. }
  178. }
  179. .label-title {
  180. color: var(--color-666);
  181. }
  182. .edit {
  183. background-color: var(--color-f8);
  184. padding: 2px 10px 8px;
  185. border-radius: 6px;
  186. }
  187. </style>