select.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581
  1. <template>
  2. <view class="container" v-if="studentInfo">
  3. <view class="form">
  4. <view class="form_box">
  5. <view class="form_key">姓名:</view>
  6. <view class="form_value">
  7. <input
  8. class="input"
  9. type="text"
  10. placeholder="请输入姓名"
  11. placeholder-style="color:#ccc;font-size:28rpx"
  12. v-model="studentInfo.name"
  13. :disabled="studentInfo.name"
  14. />
  15. </view>
  16. </view>
  17. <view class="form_box">
  18. <view class="form_key">院系:</view>
  19. <view class="form_value">
  20. <input
  21. class="input"
  22. type="text"
  23. placeholder="请输入院系"
  24. placeholder-style="color:#ccc;font-size:28rpx"
  25. v-model="studentInfo.college"
  26. :disabled="studentInfo.college"
  27. />
  28. </view>
  29. </view>
  30. <view class="form_box">
  31. <view class="form_key">专业:</view>
  32. <view class="form_value">
  33. <input
  34. class="input"
  35. type="text"
  36. placeholder="请输入专业"
  37. placeholder-style="color:#ccc;font-size:28rpx"
  38. v-model="studentInfo.major"
  39. :disabled="studentInfo.major"
  40. />
  41. </view>
  42. </view>
  43. <view class="form_box">
  44. <view class="form_key">班级:</view>
  45. <view class="form_value">
  46. <input
  47. class="input"
  48. type="text"
  49. placeholder="请输入班级"
  50. placeholder-style="color:#ccc;font-size:28rpx"
  51. v-model="studentInfo.classstr"
  52. :disabled="studentInfo.classstr"
  53. />
  54. </view>
  55. </view>
  56. <view class="form_box">
  57. <view class="form_key">校区:</view>
  58. <view class="form_value">
  59. <picker @change="bindPickerChange" :value="currtIndex" :range="schoolList" range-key="school">
  60. <view class="select" :class="{ active: currtIndex != null }">
  61. {{ currtIndex != null ? schoolList[currtIndex].school : '请选择校区' }}
  62. <uni-icons type="down" size="20" color="#ccc"></uni-icons>
  63. </view>
  64. </picker>
  65. </view>
  66. </view>
  67. <view class="form_box">
  68. <view class="form_key">楼栋:</view>
  69. <view class="form_value">
  70. <picker @change="bindPickerChange_build" :value="currtIndex_build" :range="buildList" range-key="build" :disabled="!schoolId">
  71. <view class="select" :class="{ active: currtIndex_build != null }">
  72. {{ currtIndex_build != null ? buildList[currtIndex_build]?.build : '请选择楼栋' }}
  73. <uni-icons type="down" size="20" color="#ccc"></uni-icons>
  74. </view>
  75. </picker>
  76. </view>
  77. </view>
  78. <view class="form_box">
  79. <view class="form_key">寝室:</view>
  80. <view class="form_value">
  81. <picker @change="bindPickerChange_dorm" :value="currtIndex_dorm" :range="dormList" range-key="dormitory" :disabled="!buildId">
  82. <view class="select" :class="{ active: currtIndex_dorm != null }">
  83. {{ currtIndex_dorm != null ? dormList[currtIndex_dorm]?.dormitory : '请选择寝室' }}
  84. <uni-icons type="down" size="20" color="#ccc"></uni-icons>
  85. </view>
  86. </picker>
  87. </view>
  88. </view>
  89. <view class="form_box">
  90. <view class="form_key">床位:</view>
  91. <view class="form_value">
  92. <picker @change="bindPickerChange_bed" :value="currtIndex_bed" :range="bedList" range-key="number" :disabled="!dormId">
  93. <view class="select" :class="{ active: currtIndex_bed != null }">
  94. {{ currtIndex_bed != null ? bedList[currtIndex_bed]?.number : '请选择床位' }}
  95. <uni-icons type="down" size="20" color="#ccc"></uni-icons>
  96. </view>
  97. </picker>
  98. </view>
  99. </view>
  100. </view>
  101. <view class="tips" @click="handleBed">点击查看床位示意图</view>
  102. <!-- 提交按钮区域 -->
  103. <view class="btn">
  104. <view class="btn_box" @click="handleSubmit">提交</view>
  105. </view>
  106. <!-- 弹窗区域 -->
  107. <uni-popup ref="popup" :is-mask-click="false">
  108. <view class="pop">
  109. <image class="pop_img" src="/static/3.png" mode="aspectFill"></image>
  110. <!-- 关闭图标 -->
  111. <uni-icons class="pop_close" type="closeempty" color="#808080" size="20" @click="handleClose"></uni-icons>
  112. <view class="pop_title">温馨提示</view>
  113. <view class="pop_content">选择入住之后将不能修改, 确定选择吗?</view>
  114. <view class="pop_btn" @click="handleConfirm">确定</view>
  115. <view class="pop_tips">(如有问题请联系管理员:0791-82293574)</view>
  116. </view>
  117. </uni-popup>
  118. <!-- 寝室示意图弹窗区域 -->
  119. <uni-popup ref="popup_dorm" :is-mask-click="false">
  120. <view class="pop">
  121. <!-- 关闭图标 -->
  122. <uni-icons class="pop_close" type="closeempty" color="#808080" size="20" @click="handleCloseDorm"></uni-icons>
  123. <image class="pop_img_dorm" src="/static/8.png" mode="aspectFill"></image>
  124. </view>
  125. </uni-popup>
  126. </view>
  127. </template>
  128. <script setup>
  129. import { onLoad } from '@dcloudio/uni-app'
  130. import { ref } from 'vue'
  131. import { getSchoolListDataReq, getBuildGroupReq, getDormGroupReq, getBedGroupReq, postSubmitBedInfoReq, isSelectReq } from '@/api/index.js'
  132. // 学生信息
  133. const studentInfo = ref()
  134. // 校区索引
  135. const currtIndex = ref(null)
  136. // 校区数组
  137. const schoolList = ref([])
  138. // 校区ID
  139. const schoolId = ref()
  140. const currtIndex_build = ref(null)
  141. // 楼栋数组
  142. const buildList = ref([])
  143. const buildId = ref()
  144. const currtIndex_dorm = ref(null)
  145. // 寝室分组
  146. const dormList = ref([])
  147. const dormId = ref()
  148. const currtIndex_bed = ref(null)
  149. // 床位分组
  150. const bedList = ref([])
  151. const bedId = ref()
  152. // 弹窗DOM
  153. const popup = ref()
  154. const popup_dorm = ref()
  155. onLoad(() => {
  156. // 判断是否选择了床位
  157. isSelect()
  158. })
  159. const isSelect = async () => {
  160. const res = await isSelectReq({
  161. studentCard: uni.getStorageSync('studentInfo').cardId
  162. })
  163. // console.log(res)
  164. if (res.code == 200) {
  165. if (res.data.isCheck == 1) {
  166. let str = res.data.school + res.data.build + res.data.dormitory
  167. uni.reLaunch({
  168. url: `/pages/myDorm/myDorm?str=${str}`
  169. })
  170. } else {
  171. studentInfo.value = uni.getStorageSync('studentInfo') || {}
  172. // console.log(studentInfo.value)
  173. // 获取校区数据
  174. getSchoolListData()
  175. }
  176. }
  177. }
  178. // 获取校区数据
  179. const getSchoolListData = async () => {
  180. const res = await getSchoolListDataReq()
  181. // console.log(res)
  182. if (res.code == 200) {
  183. schoolList.value = res.data
  184. let info = uni.getStorageSync('studentInfo')
  185. if (info.schoolId) {
  186. schoolList.value.forEach((ele, index) => {
  187. if (ele.id == info.schoolId) {
  188. currtIndex.value = index
  189. }
  190. })
  191. // form.value.school = info.school
  192. schoolId.value = info.schoolId
  193. // 获取楼栋分组
  194. getBuildGroup()
  195. }
  196. }
  197. }
  198. // 选择校区回调
  199. const bindPickerChange = (e) => {
  200. // console.log(e)
  201. currtIndex.value = e.detail.value
  202. schoolId.value = schoolList.value[currtIndex.value].id
  203. currtIndex_build.value = null
  204. currtIndex_dorm.value = null
  205. currtIndex_bed.value = null
  206. // 获取楼栋分组
  207. getBuildGroup()
  208. }
  209. // 获取楼栋分组
  210. const getBuildGroup = async () => {
  211. const res = await getBuildGroupReq({
  212. schoolId: schoolId.value,
  213. collegeId: studentInfo.value.collegeId,
  214. majorId: studentInfo.value.majorId,
  215. classstrid: studentInfo.value.classstrId,
  216. sex: studentInfo.value.sex
  217. })
  218. // console.log(res)
  219. if (res.code == 200) {
  220. buildList.value = res.data
  221. }
  222. }
  223. // 选择楼栋回调
  224. const bindPickerChange_build = (e) => {
  225. currtIndex_build.value = e.detail.value
  226. buildId.value = buildList.value[currtIndex_build.value].buildId
  227. currtIndex_dorm.value = null
  228. currtIndex_bed.value = null
  229. // 获取寝室分组
  230. getDormGroup()
  231. }
  232. // 获取寝室分组
  233. const getDormGroup = async () => {
  234. const res = await getDormGroupReq({
  235. schoolId: schoolId.value,
  236. buildId: buildId.value,
  237. collegeId: studentInfo.value.collegeId,
  238. majorId: studentInfo.value.majorId,
  239. classstrid: studentInfo.value.classstrId,
  240. sex: studentInfo.value.sex
  241. })
  242. // console.log(res)
  243. if (res.code == 200) {
  244. dormList.value = res.data
  245. }
  246. }
  247. // 选择寝室回调
  248. const bindPickerChange_dorm = (e) => {
  249. currtIndex_dorm.value = e.detail.value
  250. dormId.value = dormList.value[currtIndex_dorm.value].dormitoryId
  251. currtIndex_bed.value = null
  252. // 获取床位分组
  253. getBedGroup()
  254. }
  255. // 获取床位分组
  256. const getBedGroup = async () => {
  257. const res = await getBedGroupReq({
  258. schoolId: schoolId.value,
  259. buildId: buildId.value,
  260. dormitoryId: dormId.value,
  261. collegeId: studentInfo.value.collegeId,
  262. majorId: studentInfo.value.majorId,
  263. classstrid: studentInfo.value.classstrId,
  264. sex: studentInfo.value.sex
  265. })
  266. // console.log(res)
  267. if (res.code == 200) {
  268. bedList.value = res.data
  269. }
  270. }
  271. // 选择床位回调
  272. const bindPickerChange_bed = (e) => {
  273. // console.log(e)
  274. currtIndex_bed.value = e.detail.value
  275. bedId.value = bedList.value[currtIndex_bed.value].bedId
  276. }
  277. // 点击查看床位回调
  278. const handleBed = () => {
  279. if (!schoolId.value) {
  280. uni.showToast({
  281. title: '请先选择校区',
  282. icon: 'none'
  283. })
  284. return
  285. }
  286. if (!buildId.value) {
  287. uni.showToast({
  288. title: '请先选择楼栋',
  289. icon: 'none'
  290. })
  291. return
  292. }
  293. if (!dormId.value) {
  294. uni.showToast({
  295. title: '请先选择寝室',
  296. icon: 'none'
  297. })
  298. return
  299. }
  300. popup_dorm.value.open()
  301. }
  302. // 提交按钮回调
  303. const handleSubmit = () => {
  304. if (!schoolId.value) {
  305. uni.showToast({
  306. title: '请选择校区',
  307. icon: 'none'
  308. })
  309. return
  310. }
  311. if (!buildId.value) {
  312. uni.showToast({
  313. title: '请选择楼栋',
  314. icon: 'none'
  315. })
  316. return
  317. }
  318. if (!dormId.value) {
  319. uni.showToast({
  320. title: '请选择寝室',
  321. icon: 'none'
  322. })
  323. return
  324. }
  325. if (!bedId.value) {
  326. uni.showToast({
  327. title: '请选择床位',
  328. icon: 'none'
  329. })
  330. return
  331. }
  332. popup.value.open()
  333. }
  334. // 弹窗确定按钮回调
  335. const handleConfirm = async () => {
  336. const res = await postSubmitBedInfoReq({
  337. id: bedId.value,
  338. number: bedList.value[currtIndex_bed.value].number, //床位号
  339. studentCard: studentInfo.value.cardId, //学生身份证号
  340. school: schoolList.value[currtIndex.value].school, //校区名称
  341. schoolId: schoolId.value, //校区id
  342. buildId: buildId.value, //楼栋ID
  343. build: buildList.value[currtIndex_build.value].build, //楼栋名称
  344. dormitoryId: dormId.value, //宿舍ID
  345. dormitory: dormList.value[currtIndex_dorm.value].dormitory, //宿舍名称
  346. sex: studentInfo.value.sex, //床位性别
  347. college: studentInfo.value.college,
  348. collegeId: studentInfo.value.collegeId,
  349. major: studentInfo.value.major,
  350. majorId: studentInfo.value.majorId,
  351. classstr: studentInfo.value.classstr,
  352. classstrId: studentInfo.value.classstrId,
  353. isCheck: 1, // 是否入住 1:入住,0:未入住
  354. cardNum: studentInfo.value.admissNum,
  355. name: studentInfo.value.name,
  356. remark: ''
  357. })
  358. // console.log(res)
  359. if (res.code == 200) {
  360. uni.showToast({
  361. title: '提交成功',
  362. icon: 'success'
  363. })
  364. setTimeout(() => {
  365. popup.value.close()
  366. let str = schoolList.value[currtIndex.value].school + buildList.value[currtIndex_build.value].build + dormList.value[currtIndex_dorm.value].dormitory
  367. // console.log(str)
  368. uni.reLaunch({
  369. url: `/pages/myDorm/myDorm?str=${str}`
  370. })
  371. }, 1500)
  372. }
  373. }
  374. // 弹窗关闭图标回调
  375. const handleClose = () => {
  376. popup.value.close()
  377. }
  378. // 寝室示意图弹窗关闭图标回调
  379. const handleCloseDorm = () => {
  380. popup_dorm.value.close()
  381. }
  382. </script>
  383. <style lang="scss" scoped>
  384. .container {
  385. padding-top: 12rpx;
  386. min-height: 100vh;
  387. background-color: #f5f9ff;
  388. .form {
  389. padding: 20rpx 20rpx 10rpx;
  390. background-color: #fff;
  391. .form_box {
  392. display: flex;
  393. align-items: center;
  394. margin-bottom: 20rpx;
  395. height: 75rpx;
  396. .form_key {
  397. width: 100rpx;
  398. font-size: 28rpx;
  399. text-align: end;
  400. }
  401. .form_value {
  402. display: flex;
  403. align-items: center;
  404. justify-content: space-between;
  405. box-sizing: border-box;
  406. padding: 0 25rpx;
  407. width: 616rpx;
  408. height: 100%;
  409. font-size: 28rpx;
  410. border-radius: 4rpx;
  411. border: 2rpx solid #cccccc;
  412. .input {
  413. width: 100%;
  414. height: 100%;
  415. }
  416. .value_text {
  417. color: #cccccc;
  418. }
  419. .select {
  420. display: flex;
  421. align-items: center;
  422. justify-content: space-between;
  423. width: 556rpx;
  424. height: 74rpx;
  425. font-size: 28rpx;
  426. color: #ccc;
  427. }
  428. .active {
  429. color: #000;
  430. }
  431. }
  432. }
  433. }
  434. .tips {
  435. padding-left: 120rpx;
  436. font-size: 28rpx;
  437. color: #0061ff;
  438. background-color: #fff;
  439. }
  440. .btn {
  441. padding: 100rpx 20rpx 0;
  442. background-color: #fff;
  443. .btn_box {
  444. display: flex;
  445. justify-content: center;
  446. align-items: center;
  447. height: 100rpx;
  448. font-size: 32rpx;
  449. color: #fff;
  450. border-radius: 8rpx;
  451. background-color: #0061ff;
  452. }
  453. }
  454. .pop {
  455. position: relative;
  456. display: flex;
  457. flex-direction: column;
  458. align-items: center;
  459. width: 659rpx;
  460. height: 728rpx;
  461. border-radius: 15rpx;
  462. background: linear-gradient(180deg, #ebf2ff 0%, #ffffff 100%);
  463. .pop_img {
  464. position: absolute;
  465. top: -103rpx;
  466. left: 227rpx;
  467. width: 206rpx;
  468. height: 206rpx;
  469. }
  470. .pop_img_dorm {
  471. margin-top: 80rpx;
  472. width: 475rpx;
  473. height: 600rpx;
  474. }
  475. .pop_close {
  476. position: absolute;
  477. top: 19rpx;
  478. right: 29rpx;
  479. }
  480. .pop_title {
  481. margin-top: 151rpx;
  482. font-size: 32rpx;
  483. font-weight: bold;
  484. }
  485. .pop_content {
  486. margin-top: 85rpx;
  487. font-size: 28rpx;
  488. color: #333333;
  489. }
  490. .pop_btn {
  491. display: flex;
  492. align-items: center;
  493. justify-content: center;
  494. margin-top: 137rpx;
  495. width: 543rpx;
  496. height: 101rpx;
  497. font-size: 32rpx;
  498. color: #fff;
  499. border-radius: 8rpx;
  500. background-color: #0061ff;
  501. }
  502. .pop_tips {
  503. margin-top: 15rpx;
  504. font-size: 24rpx;
  505. color: #333333;
  506. }
  507. }
  508. }
  509. </style>