index.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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" @click="handleClose"></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.active }" @click="toggleSelect(item)">
  12. {{ item.name }}
  13. </view>
  14. </view>
  15. <view class="zydj-popup-btn-box">
  16. <button type="default" class="phone-green-btn" @click="confirmBtn">保存</button>
  17. </view>
  18. </view>
  19. </contentDialogVue>
  20. </template>
  21. <script setup>
  22. import {
  23. reactive,
  24. ref
  25. } from 'vue';
  26. import {
  27. getJiazhengZhiye,
  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. mode: {
  59. type: String,
  60. default: 'duoxuan' // danxuan / duoxuan
  61. }
  62. });
  63. const commonPopup = ref(null);
  64. const $emit = defineEmits(['confirm-btn'])
  65. const data = reactive({
  66. list: [],
  67. // item: {
  68. // zyId: null,
  69. // zyName: null,
  70. // active: true
  71. // }
  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.active));
  84. handleClose();
  85. }
  86. function getZyList(alreadySelect) {
  87. getJiazhengZhiye({
  88. id: props.id
  89. }).then(res => {
  90. data.list = res.data.map(item => {
  91. if (alreadySelect) {
  92. const da1 = alreadySelect.find(ite => ite.zyId == item.id);
  93. if (da1) {
  94. return {
  95. id: item.id,
  96. name: item.name,
  97. active: true
  98. }
  99. }
  100. }
  101. return {
  102. id: item.id,
  103. name: item.name,
  104. active: false
  105. }
  106. })
  107. commonPopup.value.handleShow();
  108. })
  109. }
  110. function toggleSelect(item) {
  111. item.active = !item.active;
  112. if (props.mode == 'danxuan') {
  113. data.list = res.data.map(cite => {
  114. if (cite.id != item.id) {
  115. cite.active = false;
  116. }
  117. })
  118. }
  119. }
  120. defineExpose({
  121. handleShow,
  122. handleClose
  123. })
  124. </script>
  125. <style scoped>
  126. </style>