select.vue 14 KB

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