index.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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)).map(item => {
  84. return {
  85. name: item.name,
  86. id: item.id,
  87. }
  88. });
  89. handleClose();
  90. }
  91. function getZyList(alreadySelect) {
  92. getJiazhengZhiye({
  93. id: props.id
  94. }).then(res => {
  95. data.list = res.data.map(item => {
  96. if (alreadySelect) {
  97. const da1 = alreadySelect.find(ite => ite.zyId == item.id);
  98. if (da1) {
  99. return {
  100. id: item.id,
  101. name: item.name,
  102. active: true
  103. }
  104. }
  105. }
  106. return {
  107. id: item.id,
  108. name: item.name,
  109. active: false
  110. }
  111. })
  112. commonPopup.value.handleShow();
  113. })
  114. }
  115. function toggleSelect(item) {
  116. item.active = !item.active;
  117. if (props.mode == 'danxuan') {
  118. data.list = res.data.map(cite => {
  119. if (cite.id != item.id) {
  120. cite.active = false;
  121. }
  122. })
  123. }
  124. }
  125. defineExpose({
  126. handleShow,
  127. handleClose
  128. })
  129. </script>
  130. <style scoped>
  131. </style>