trainingExperience.vue 5.7 KB

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