set.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <template>
  2. <view class="container">
  3. <!-- 学生部门区域 -->
  4. <view class="box">
  5. <view class="box_key">学生部门</view>
  6. <view class="box_input">
  7. <uni-data-picker
  8. placeholder="请选择部门"
  9. popup-title="请选择部门"
  10. :map="{ text: 'name', value: 'id' }"
  11. :clear-icon="false"
  12. :localdata="dataTree_student"
  13. v-model="classes_student"
  14. @change="onchange_student"
  15. ></uni-data-picker>
  16. </view>
  17. </view>
  18. <!-- 家属部门区域 -->
  19. <view class="box">
  20. <view class="box_key">家属部门</view>
  21. <view class="box_input">
  22. <uni-data-picker
  23. placeholder="请选择部门"
  24. popup-title="请选择部门"
  25. :map="{ text: 'name', value: 'id' }"
  26. :clear-icon="false"
  27. :localdata="dataTree_family"
  28. v-model="classes_family"
  29. @change="onchange_family"
  30. ></uni-data-picker>
  31. </view>
  32. </view>
  33. <!-- 确认按钮区域 -->
  34. <view class="btn" @click="clickBtn">确认</view>
  35. </view>
  36. </template>
  37. <script setup>
  38. import { ref } from 'vue'
  39. import { onLoad } from '@dcloudio/uni-app'
  40. import { myRequest } from '@/utils/api.js'
  41. // 学生部门数组
  42. const dataTree_student = ref([])
  43. // 学生部门筛选框绑定数据
  44. const classes_student = ref()
  45. // 家属部门数组
  46. const dataTree_family = ref([])
  47. // 家属部门筛选框绑定数据
  48. const classes_family = ref()
  49. onLoad(() => {
  50. classes_student.value = uni.getStorageSync('departmentId')
  51. classes_family.value = uni.getStorageSync('departmentId_list')
  52. // 获取学生部门数据
  53. getData_student()
  54. // 获取家属部门数据
  55. getData_family()
  56. })
  57. // 获取学生部门数据
  58. const getData_student = async () => {
  59. const res = await myRequest({
  60. url: '/wanzai/api/smartDepartment/studentDepartment'
  61. })
  62. // console.log(res)
  63. dataTree_student.value = res.data
  64. }
  65. // 获取家属部门数据
  66. const getData_family = async () => {
  67. const res = await myRequest({
  68. url: '/wanzai/api/smartDepartment/patriarchDepartment'
  69. })
  70. // console.log(res)
  71. dataTree_family.value = res.data
  72. }
  73. // 学生部门筛选框选择时的回调
  74. const onchange_student = (e) => {
  75. // console.log(e.detail.value)
  76. // console.log(classes_student.value)
  77. uni.setStorageSync('departmentId', classes_student.value)
  78. }
  79. // 家属部门筛选框选择时的回调
  80. const onchange_family = (e) => {
  81. // console.log(e.detail.value)
  82. // console.log(classes_family.value)
  83. uni.setStorageSync('departmentId_list', classes_family.value)
  84. }
  85. // 点击确认按钮回调
  86. const clickBtn = () => {
  87. // console.log(classes_student.value)
  88. // console.log(classes_family.value)
  89. uni.reLaunch({
  90. url: '/pages/studentManage/studentManage'
  91. })
  92. }
  93. </script>
  94. <style lang="scss" scoped>
  95. .container {
  96. padding: 20rpx;
  97. .box {
  98. display: flex;
  99. align-items: center;
  100. margin-bottom: 30rpx;
  101. height: 80rpx;
  102. .box_key {
  103. width: 120rpx;
  104. font-size: 28rpx;
  105. }
  106. .box_input {
  107. flex: 1;
  108. margin-left: 20rpx;
  109. overflow: hidden;
  110. }
  111. }
  112. .btn {
  113. position: absolute;
  114. left: 50%;
  115. bottom: 50rpx;
  116. transform: translateX(-50%);
  117. display: flex;
  118. justify-content: center;
  119. align-items: center;
  120. width: 300rpx;
  121. height: 80rpx;
  122. font-size: 28rpx;
  123. color: #fff;
  124. border-radius: 10rpx;
  125. background-color: #0061ff;
  126. }
  127. }
  128. </style>