index.vue 3.7 KB

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