vocationalSkills.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <!-- 1职业技能 -->
  2. <template>
  3. <view class="ss-m-x-30 ss-m-y-30">
  4. <!-- 已选中 -->
  5. <view class="chose borderLine">
  6. <view class="choseTitle MiSans-Noraml">当前职业技能</view>
  7. <view class="tags">
  8. <view
  9. v-for="tag in skillExp"
  10. :key="tag.id"
  11. class="tag"
  12. style="color: #00B760; border: 2rpx solid #00B760;"
  13. @tap="handleDelete(tag.id)"
  14. >
  15. {{ tag.title }}
  16. <uni-icons type="clear" size="16" color="#00B760"></uni-icons>
  17. </view>
  18. </view>
  19. </view>
  20. <uni-section title="新增" type="line">
  21. <uni-forms ref="form" :modelValue="formData" :rules="rules" validateTrigger="bind" label-width="90px" class="ss-m-t-50">
  22. <uni-forms-item label="技能名称" name="skillId" required>
  23. <uni-data-picker :localdata="skill" v-model="formData.skillId" :map="{ text: 'nameCn', value: 'id' }" placeholder="技能名称" popup-title="请选择技能名称"></uni-data-picker>
  24. </uni-forms-item>
  25. <uni-forms-item label="熟练度" name="level" required>
  26. <uni-data-picker :localdata="skillLevelArr" v-model="formData.level" :map="{ text: 'label', value: 'value' }" placeholder="熟练度" popup-title="请选择熟练度"></uni-data-picker>
  27. </uni-forms-item>
  28. </uni-forms>
  29. <view class="f-horizon-center">
  30. <button size="default" class="send-button MiSans-Medium" :disabled="disabled" @click="submit">提 交</button>
  31. </view>
  32. </uni-section>
  33. </view>
  34. </template>
  35. <script setup>
  36. import { ref, unref } from 'vue'
  37. import { saveResumePersonSkill, deleteResumePersonSkill, getResumePersonSkill, getSkillTree } from '@/api/resume.js'
  38. import { getDict } from '@/hooks/useDictionaries'
  39. import { getText } from '@/utils/getText'
  40. let formData = ref({})
  41. const form = ref()
  42. const rules = {
  43. skillId:{
  44. rules: [{required: true, errorMessage: '请选择技能名称' }]
  45. },
  46. level:{
  47. rules: [{required: true, errorMessage: '请选择熟练度' }]
  48. }
  49. }
  50. // 熟练度
  51. const skillLevelArr = ref([])
  52. getDict('menduner_skill_level').then(({ data }) => {
  53. data = data.data?.length && data.data || []
  54. skillLevelArr.value = data
  55. })
  56. const skillList = ref([])
  57. getDict('skillList', {}, 'skillList').then(({ data }) => {
  58. data = data.data?.length && data.data || []
  59. skillList.value = data
  60. })
  61. // 获取 职业技能选项
  62. const skill = ref([])
  63. const getSkillTreeFunc = async () => {
  64. const { data } = await getSkillTree()
  65. skill.value = data || []
  66. }
  67. getSkillTreeFunc()
  68. // 职业技能
  69. const skillExp = ref([])
  70. async function getSkillExpData () {
  71. const { data } = await getResumePersonSkill()
  72. if (!data || !data.length) {
  73. return
  74. }
  75. skillExp.value = data.map(e => {
  76. return {
  77. ...e,
  78. title: `${getText(e.skillId, skillList.value, 'nameCn', 'id')} / ${getText(e.level, skillLevelArr.value)}`
  79. }
  80. })
  81. }
  82. getSkillExpData()
  83. // 保存
  84. const disabled = ref(false)
  85. const submit = async () => {
  86. const valid = await unref(form).validate()
  87. if (!valid) return
  88. disabled.value = true
  89. try {
  90. await saveResumePersonSkill(formData.value)
  91. uni.showToast({
  92. icon: 'success',
  93. title: '新增成功'
  94. })
  95. setTimeout(() => {
  96. disabled.value = false
  97. getSkillExpData()
  98. })
  99. } catch (err) {
  100. disabled.value = false
  101. uni.showToast({
  102. icon: 'none',
  103. title: err.msg
  104. })
  105. }
  106. }
  107. // 删除
  108. const handleDelete = async (id) => {
  109. try {
  110. await deleteResumePersonSkill(id)
  111. uni.showToast({
  112. icon: 'success',
  113. title: '删除成功'
  114. })
  115. setTimeout(() => {
  116. getSkillExpData()
  117. })
  118. } catch (err) {
  119. uni.showToast({
  120. icon: 'none',
  121. title: err.msg
  122. })
  123. }
  124. }
  125. </script>
  126. <style lang="scss" scoped>
  127. .borderLine {
  128. border-bottom: 2rpx solid #f5f5f5;
  129. }
  130. .chose {
  131. margin-bottom: 30rpx;
  132. .choseTitle {
  133. margin-bottom: 30rpx;
  134. }
  135. }
  136. .tags {
  137. padding: 30rpx 0;
  138. display: flex;
  139. flex-wrap: wrap;
  140. .tag {
  141. margin: 0 15rpx 12rpx 0;
  142. border: 2rpx 15rpx #00B760;
  143. color: #00B760;
  144. white-space: nowrap;
  145. padding: 4rpx 10rpx;
  146. border-radius: 10rpx;
  147. font-size: 24rpx;
  148. }
  149. }
  150. :deep(.uni-section .uni-section-header__decoration) {
  151. background-color: #00B760 !important;
  152. }
  153. </style>