index.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <template>
  2. <contentDialogVue ref="commonPopup" @confirm-btn="confirmBtn" title="选择职业">
  3. <!-- 技能块展示 -->
  4. <view v-for="item in data.list" :key="item.id" class="phone-radio-item"
  5. :class="{ radioActive: !!item.zyLevelName }" @click="toggleSelect(item)">
  6. {{ item.name }}
  7. <view class="radio-item-tag" v-if="!!item.zyLevelName">{{item.zyLevelName[0]}}</view>
  8. </view>
  9. </contentDialogVue>
  10. <!-- 弹窗 -->
  11. <contentDialogVue ref="commonPopup2" :showBtn="false" title="请选择职业等级">
  12. <!-- 等级选择 -->
  13. <view v-for="item in data.zyLevelList" :key="item.id" @click="handleSelectLevelId(item)">
  14. {{item.name}}
  15. </view>
  16. </contentDialogVue>
  17. </template>
  18. <script setup>
  19. import {
  20. reactive,
  21. ref
  22. } from 'vue';
  23. import {
  24. getJiazhengZhiye,
  25. getJiazhengLevel
  26. } from "@/api/jiazheng.js"
  27. import contentDialogVue from '@/components/dialog/contentDialog.vue';
  28. const props = defineProps({
  29. title: {
  30. type: String,
  31. default: ''
  32. },
  33. content: {
  34. type: String,
  35. require: true,
  36. default: ''
  37. },
  38. dialogContentClass: {
  39. type: String,
  40. require: true,
  41. default: 'content-center-class'
  42. },
  43. notBtn: {
  44. type: String,
  45. require: true,
  46. default: '取消'
  47. },
  48. okBtn: {
  49. type: String,
  50. require: true,
  51. default: '确认'
  52. },
  53. id: {
  54. type: Number,
  55. }
  56. });
  57. const commonPopup = ref(null);
  58. const commonPopup2 = ref(null);
  59. const $emit = defineEmits(['confirm-btn'])
  60. const data = reactive({
  61. list: [],
  62. // item: {
  63. // zyId: null,
  64. // zyName: null,
  65. // zyLevel: null,
  66. // zyLevelName: null
  67. // }
  68. activeId: null, // 激活的zyId
  69. zyLevelList: [],
  70. })
  71. // 打开弹窗
  72. function handleShow(mdata) {
  73. getZyList(mdata)
  74. }
  75. // 取消
  76. function handleClose() {
  77. commonPopup.value.handleClose();
  78. }
  79. // 确认
  80. function confirmBtn() {
  81. $emit('confirm-btn', data.list.filter(item => item.zyLevelName));
  82. }
  83. function getZyList(alreadySelect) {
  84. getJiazhengZhiye({
  85. id: props.id
  86. }).then(res => {
  87. data.list = res.data.map(item => {
  88. if (alreadySelect) {
  89. const da1 = alreadySelect.find(ite => ite.zyId == item.id);
  90. if (da1) {
  91. return {
  92. id: item.id,
  93. name: item.name,
  94. zyLevel: da1.zyLevel,
  95. zyLevelName: da1.zyLevelName
  96. }
  97. }
  98. }
  99. return {
  100. id: item.id,
  101. name: item.name,
  102. zyLevel: null,
  103. zyLevelName: null
  104. }
  105. })
  106. commonPopup.value.handleShow();
  107. })
  108. }
  109. function toggleSelect(item) {
  110. if (item.zyLevelName) {
  111. item.zyLevel = null;
  112. item.zyLevelName = null
  113. } else {
  114. data.activeId = item.id;
  115. getLevelList(item);
  116. }
  117. }
  118. function getLevelList() {
  119. getJiazhengLevel({jgId: props.id,zyId: data.activeId}).then(res => {
  120. data.zyLevelList = res.data;
  121. commonPopup2.value.handleShow();
  122. })
  123. }
  124. function handleSelectLevelId(item) {
  125. data.list.map(ite => {
  126. if (ite.id === data.activeId) {
  127. ite.zyLevel = item.id;
  128. ite.zyLevelName = item.name
  129. }
  130. return ite;
  131. })
  132. commonPopup2.value.handleClose()
  133. }
  134. defineExpose({
  135. handleShow,
  136. handleClose
  137. })
  138. </script>
  139. <style scoped>
  140. </style>