index.vue 3.1 KB

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