index.vue 3.6 KB

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