index.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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).map(item => {
  100. item.zyId = item.id;
  101. return item;
  102. }));
  103. handleClose();
  104. }
  105. function getZyList(alreadySelect) {
  106. getJiazhengZhiye({
  107. id: props.id
  108. }).then(res => {
  109. data.list = res.data.map(item => {
  110. if (alreadySelect) {
  111. const da1 = alreadySelect.find(ite => ite.zyId == item.id);
  112. if (da1) {
  113. return {
  114. id: item.id,
  115. name: item.name,
  116. zyLevel: da1.zyLevel,
  117. zyLevelName: da1.zyLevelName
  118. }
  119. }
  120. }
  121. return {
  122. id: item.id,
  123. name: item.name,
  124. zyLevel: null,
  125. zyLevelName: null
  126. }
  127. })
  128. commonPopup.value.handleShow();
  129. })
  130. }
  131. function toggleSelect(item) {
  132. if (item.zyLevelName) {
  133. item.zyLevel = null;
  134. item.zyLevelName = null
  135. } else {
  136. data.activeId = item.id;
  137. getLevelList(item);
  138. }
  139. }
  140. function getLevelList() {
  141. getJiazhengLevel({jgId: props.id,zyId: data.activeId}).then(res => {
  142. data.zyLevelList = res.data;
  143. commonPopup2.value.handleShow();
  144. })
  145. }
  146. function handleSelectLevelId(item) {
  147. data.list.map(ite => {
  148. if (ite.id === data.activeId) {
  149. ite.zyLevel = item.id;
  150. ite.zyLevelName = item.name
  151. }
  152. return ite;
  153. })
  154. commonPopup2.value.handleClose()
  155. }
  156. defineExpose({
  157. handleShow,
  158. handleClose
  159. })
  160. </script>
  161. <style scoped>
  162. </style>