set.vue 2.9 KB

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