RoomForm.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759
  1. <template>
  2. <Dialog ref="dialogRef" v-model="dialogVisible" :title="isDetailTitle">
  3. <el-scrollbar ref="targetRef" max-height="70vh">
  4. <el-form
  5. @submit.prevent
  6. ref="formRef"
  7. :model="dataForm"
  8. :rules="dataRule"
  9. :label-width="labelWidth"
  10. >
  11. <div style="margin-top: 10px">
  12. <el-row>
  13. <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
  14. <el-form-item label="房间用途" prop="buildName" size="default">
  15. <el-radio-group v-model="dataForm.roomUsage" size="default">
  16. <el-radio-button
  17. style=""
  18. v-for="(item, index) in getStrDictOptionsFun(DICT_TYPE.ROOM_PURPOSE)"
  19. :label="item.label"
  20. :value="item.value"
  21. :key="index"
  22. />
  23. </el-radio-group>
  24. </el-form-item>
  25. </el-col>
  26. </el-row>
  27. <el-row>
  28. <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
  29. <el-form-item label="房间名称" prop="roomName">
  30. <el-input :maxlength="6" v-model="dataForm.roomName" :show-word-limit="true" />
  31. </el-form-item>
  32. </el-col>
  33. </el-row>
  34. <div v-if="dataForm.roomUsage === '1'">
  35. <el-row>
  36. <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
  37. <el-form-item label="房间设置" prop="">
  38. <div style="display: flex; flex-direction: row; align-items: center">
  39. <div
  40. @click="iconClick(1)"
  41. style="
  42. width: 40px;
  43. height: 40px;
  44. border-radius: 40px;
  45. display: flex;
  46. justify-content: center;
  47. align-items: center;
  48. cursor: pointer;
  49. "
  50. :style="{
  51. border: icon1 ? '#409eff solid 1px' : '#eeeeee solid 1px',
  52. backgroundColor: icon1 ? '#ffffff' : '#eeeeee'
  53. }"
  54. >
  55. <img
  56. v-if="icon1"
  57. src="@/assets/imgs/nan.png"
  58. style="width: 20px; height: 22px"
  59. alt=""
  60. />
  61. <img
  62. v-else
  63. src="@/assets/imgs/nan-2.png"
  64. style="width: 20px; height: 22px"
  65. alt=""
  66. />
  67. </div>
  68. <div
  69. @click="iconClick(2)"
  70. style="
  71. margin-left: 12px;
  72. width: 40px;
  73. height: 40px;
  74. border-radius: 40px;
  75. display: flex;
  76. justify-content: center;
  77. align-items: center;
  78. cursor: pointer;
  79. "
  80. :style="{
  81. border: icon2 ? '#409eff solid 1px' : '#eeeeee solid 1px',
  82. backgroundColor: icon2 ? '#ffffff' : '#eeeeee'
  83. }"
  84. >
  85. <img
  86. v-if="icon2"
  87. src="@/assets/imgs/nv.png"
  88. style="width: 20px; height: 22px"
  89. alt=""
  90. />
  91. <img
  92. v-else
  93. src="@/assets/imgs/nv-2.png"
  94. style="width: 20px; height: 22px"
  95. alt=""
  96. />
  97. </div>
  98. <div
  99. @click="iconClick(3)"
  100. style="
  101. margin-left: 12px;
  102. width: 40px;
  103. height: 40px;
  104. border-radius: 40px;
  105. display: flex;
  106. justify-content: center;
  107. align-items: center;
  108. cursor: pointer;
  109. "
  110. :style="{
  111. border: icon3 ? '#409eff solid 1px' : '#eeeeee solid 1px',
  112. backgroundColor: icon3 ? '#ffffff' : '#eeeeee'
  113. }"
  114. >
  115. <img
  116. v-if="icon3"
  117. src="@/assets/imgs/matong.png"
  118. style="width: 20px; height: 22px"
  119. alt=""
  120. />
  121. <img
  122. v-else
  123. src="@/assets/imgs/matong-2.png"
  124. style="width: 20px; height: 22px"
  125. alt=""
  126. />
  127. </div>
  128. </div>
  129. </el-form-item>
  130. </el-col>
  131. </el-row>
  132. <el-row>
  133. <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
  134. <el-form-item label="房间区域" prop="roomArea">
  135. <el-radio-group v-model="dataForm.roomArea">
  136. <el-radio-button
  137. @click="clickRoomArea(item.value)"
  138. border
  139. v-for="(item, index) in getStrDictOptionsFun(DICT_TYPE.ROOM_AREA_ARR)"
  140. :key="index"
  141. :label="item.label"
  142. :value="item.value"
  143. />
  144. </el-radio-group>
  145. </el-form-item>
  146. </el-col>
  147. </el-row>
  148. <el-row>
  149. <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
  150. <el-form-item label="长者类型" prop="elderStatus">
  151. <el-radio-group v-model="dataForm.elderType">
  152. <el-radio-button
  153. border
  154. @click="clickElderType(item.value)"
  155. v-for="(item, index) in getStrDictOptionsFun(DICT_TYPE.ELDERLY_HEALTH_STATUS)"
  156. :key="index"
  157. :label="item.label"
  158. :value="item.value"
  159. />
  160. </el-radio-group>
  161. </el-form-item>
  162. </el-col>
  163. </el-row>
  164. <el-row>
  165. <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
  166. <el-form-item label="房间朝向" prop="roomOrientation">
  167. <el-radio-group v-model="dataForm.orientation">
  168. <el-radio-button
  169. border
  170. @click="clickOrientation(item.value)"
  171. v-for="(item, index) in getStrDictOptionsFun(DICT_TYPE.ROOM_ORIENTATION)"
  172. :key="index"
  173. :label="item.label"
  174. :value="item.value"
  175. />
  176. </el-radio-group>
  177. </el-form-item>
  178. </el-col>
  179. </el-row>
  180. </div>
  181. <div v-else>
  182. <el-row>
  183. <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
  184. <el-form-item label="封面图" prop="panoramicUrl">
  185. <el-row>
  186. <div @click="iconCK(item)" v-for="(item, index) in iconList" :key="index">
  187. <img
  188. :class="{ iconS: item.select, iconS2: !item.select }"
  189. :src="item.icon"
  190. style="margin-right: 18px"
  191. alt=""
  192. />
  193. </div>
  194. </el-row>
  195. </el-form-item>
  196. </el-col>
  197. </el-row>
  198. </div>
  199. <el-row>
  200. <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
  201. <el-form-item label="全景URL" prop="panoramicUrl">
  202. <el-input
  203. v-model="dataForm.panoramicUrl"
  204. type="textarea"
  205. :maxlength="1000"
  206. show-word-limit
  207. />
  208. </el-form-item>
  209. </el-col>
  210. </el-row>
  211. <el-row>
  212. <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
  213. <el-form-item label="房间图片" prop="roomFullUrl">
  214. <el-upload
  215. :file-list="dataForm.roomImageLists"
  216. :action="uploadUrl"
  217. list-type="picture-card"
  218. :http-request="httpRequest"
  219. :on-change="roomImageListChange"
  220. :on-remove="handleRemove"
  221. class="my-custom-upload"
  222. >
  223. <el-icon><Plus /></el-icon>
  224. </el-upload>
  225. </el-form-item>
  226. </el-col>
  227. </el-row>
  228. <el-row>
  229. <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
  230. <el-form-item label="房间视频" prop="roomFullUrl">
  231. <el-upload
  232. v-model="dataForm.roomVideoLists"
  233. :action="uploadUrl"
  234. :beforeUpload="beforeAvatarUpload"
  235. :http-request="httpRequest"
  236. :on-remove="handleRemoveVideo"
  237. >
  238. <el-button type="primary">点击上传</el-button>
  239. <template #tip>
  240. <div class="el-upload__tip"> 视频文件最大支持30M </div>
  241. </template>
  242. </el-upload>
  243. </el-form-item>
  244. </el-col>
  245. </el-row>
  246. <el-divider v-show="dataForm.roomUsage === '1'" style="margin-top: 10px" />
  247. <el-row v-show="dataForm.roomUsage === '1'">
  248. <el-col :span="6">
  249. <el-button @click="addFloor" :icon="CirclePlus" style="margin-bottom: 20px"
  250. >添加床位</el-button
  251. >
  252. </el-col>
  253. <el-col :span="16">
  254. <el-text />
  255. </el-col>
  256. </el-row>
  257. <div
  258. v-show="dataForm.roomUsage === '1'"
  259. v-loading="loadingBed"
  260. v-for="(item, index) in dataForm.bedList"
  261. :key="index"
  262. >
  263. <el-row v-show="!item.isDelete">
  264. <el-col :xs="23" :sm="23" :md="23" :lg="11" :xl="11">
  265. <el-form-item label="床位号" prop="bedName">
  266. <el-input v-model="item.bedName" :maxlength="20" />
  267. </el-form-item>
  268. </el-col>
  269. <el-col :xs="23" :sm="23" :md="23" :lg="11" :xl="11">
  270. <el-form-item label="显示顺序" prop="sort">
  271. <el-input v-model="item.sort" :maxlength="5" />
  272. </el-form-item>
  273. </el-col>
  274. <el-col :span="2">
  275. <div
  276. @click="deleteFloor(index)"
  277. style="
  278. height: 30px;
  279. display: flex;
  280. align-items: center;
  281. justify-content: center;
  282. width: 3vw;
  283. "
  284. >
  285. <el-icon :size="16" color="#ff0000">
  286. <Remove />
  287. </el-icon>
  288. </div>
  289. </el-col>
  290. </el-row>
  291. </div>
  292. </div>
  293. </el-form>
  294. </el-scrollbar>
  295. <template #footer>
  296. <el-button @click="handleClosed">关闭</el-button>
  297. <el-button v-loading="formLoading" type="primary" @click="submitForm">确定</el-button>
  298. </template>
  299. </Dialog>
  300. </template>
  301. <script lang="ts" setup>
  302. import { computed, ref } from 'vue'
  303. import {DICT_TYPE, getDictLabel, getStrDictOptions} from '@/utils/dict'
  304. import { elderlyBakAdd, getElderlyBakInfo } from '@/api/elderly/bak/check-out'
  305. import {addRoom, checkBedById, editRoom} from '@/api/system/badManage'
  306. import { FormRules, UploadProps, UploadUserFile } from 'element-plus'
  307. import { useMediaQuery } from '@vueuse/core'
  308. import { CirclePlus, Remove, OfficeBuilding, Plus } from '@element-plus/icons-vue'
  309. import { useUpload } from '@/components/UploadFile/src/useUpload'
  310. const { targetRef, scrollToBottom } = useFocusScroll();
  311. const message = useMessage() // 消息弹窗
  312. const { t } = useI18n() // 国际化
  313. const floorNum = ref('')
  314. const roomFileList = ref<UploadUserFile[]>([])
  315. // const roomFileListVideo = ref<UploadUserFile[]>([]);
  316. const { uploadUrl, httpRequest } = useUpload()
  317. const icon1 = ref(false)
  318. const icon2 = ref(false)
  319. const icon3 = ref(false)
  320. const dialogRef = ref()
  321. import i1 from '../../../../assets/imgs/bed12.png'
  322. import i2 from '../../../../assets/imgs/bed11.png'
  323. import {useFocusScroll} from "@/utils/useFocusScroll";
  324. const iconList = ref([
  325. { icon: i1, select: true },
  326. { icon: i2, select: false }
  327. ])
  328. const dialogVisible = ref(false) // 弹窗
  329. const formRef = ref() // 表单 Ref
  330. const isDetail = ref(false) // 是否详情打开
  331. const loadingBed = ref(false) // 是否详情打开
  332. const isDetailTitle = ref('新增房间') // 是否详情打开
  333. const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
  334. let dataForm = ref({
  335. // 表单字段
  336. tenantId: undefined,
  337. id: 0,
  338. floorId: '',
  339. roomName: '',
  340. roomUsage: '',
  341. roomArea: undefined,
  342. elderType: undefined,
  343. orientation: undefined,
  344. roomSettings: '',
  345. panoramicUrl: '',
  346. roomImage: '',
  347. roomVideo: '',
  348. coverImage: '',
  349. roomVideoLists: [],
  350. roomImageLists: [],
  351. bedList: [] // "id": 0, "bedName": "", "status": 0, "roomId": 0,"sort": 0
  352. })
  353. // 表单规则
  354. const dataRule = reactive<FormRules>({
  355. roomName: [{ required: true, message: '房间名称不能为空', trigger: 'blur' }]
  356. // buildNum: [{required: true, message: '退住原因不能为空', trigger: 'blur'}],
  357. })
  358. const clickOrientation = (v) => {
  359. console.log(v, dataForm.value.orientation)
  360. if (v === dataForm.value.orientation) {
  361. setTimeout(() => {
  362. dataForm.value.orientation = null
  363. console.log(v, dataForm.value.orientation)
  364. }, 100)
  365. }
  366. }
  367. const clickElderType = (v) => {
  368. if (v === dataForm.value.elderType) {
  369. setTimeout(() => {
  370. dataForm.value.elderType = null
  371. }, 100)
  372. }
  373. }
  374. const clickRoomArea = (v) => {
  375. if (v === dataForm.value.roomArea) {
  376. setTimeout(() => {
  377. dataForm.value.roomArea = null
  378. }, 100)
  379. }
  380. }
  381. const beforeAvatarUpload: UploadProps['beforeUpload'] = (rawFile) => {
  382. console.log('上传前', rawFile)
  383. if (rawFile.type !== 'mp4/rmvb/wmv') {
  384. message.error('不支持的视频格式!!')
  385. return false
  386. } else if (rawFile.size / 1024 / 1024 > 30) {
  387. message.error('文件不能超过30M')
  388. return false
  389. }
  390. return true
  391. }
  392. const iconCK = async (item: any) => {
  393. for (const itemElement of iconList.value) {
  394. itemElement.select = false
  395. }
  396. item.select = true
  397. }
  398. // 计算窗口大小
  399. const currentWidth = useMediaQuery('(max-width: 800px)')
  400. // 计算文字大小
  401. const labelWidth = computed(() => {
  402. return currentWidth.value ? '80px' : '80px'
  403. })
  404. const selectElderRef = ref() // 选择老人ref
  405. const iconClick = (type) => {
  406. if (type === 1) {
  407. icon1.value = !icon1.value
  408. }
  409. if (type === 2) {
  410. icon2.value = !icon2.value
  411. }
  412. if (type === 3) {
  413. icon3.value = !icon3.value
  414. }
  415. dataForm.value.roomSettings = `${icon1.value ? '男' : ''},${icon2.value ? '女' : ''},${icon3.value ? '卫生间' : ''}`
  416. }
  417. const getStrDictOptionsFun = (type) => {
  418. const res = getStrDictOptions(type)
  419. if (res) {
  420. try {
  421. switch (type) {
  422. case DICT_TYPE.ROOM_PURPOSE:
  423. if (dataForm.value.roomUsage === '') {
  424. dataForm.value.roomUsage = res[0].value.toString()
  425. }
  426. // break;
  427. // case DICT_TYPE.ROOM_AREA_ARR:
  428. // if(dataForm.value.roomArea===''){
  429. // dataForm.value.roomArea = res[0].value.toString()
  430. // }
  431. // break;
  432. // case DICT_TYPE.ELDERLY_HEALTH_STATUS:
  433. // if(dataForm.value.elderType===''){
  434. // dataForm.value.elderType = res[0].value.toString()
  435. // }
  436. // break;
  437. // case DICT_TYPE.ROOM_ORIENTATION:
  438. // if(dataForm.value.orientation===''){
  439. // dataForm.value.orientation = res[0].value.toString()
  440. // }
  441. // break;
  442. }
  443. } catch (e) {}
  444. }
  445. return res
  446. }
  447. /** 打开弹窗 */
  448. const open = async (tId, floorId, value?: any, detail: boolean = false) => {
  449. resetForm()
  450. dialogVisible.value = true
  451. dataForm.value.floorId = floorId || undefined
  452. dataForm.value.tenantId = tId
  453. console.log('楼层ID:', value)
  454. if (floorId === undefined) {
  455. message.error('没有楼层,无法添加房间')
  456. return
  457. }
  458. isDetail.value = detail
  459. if (isDetail.value) {
  460. isDetailTitle.value = '编辑房间'
  461. let jsonBean = value
  462. dataForm.value.id = jsonBean.id
  463. dataForm.value.floorId = jsonBean.floorId
  464. dataForm.value.roomName = jsonBean.roomName
  465. dataForm.value.roomUsage = jsonBean.roomUsage
  466. dataForm.value.coverImage = jsonBean.coverImage
  467. for (const jsonBeanElement of iconList.value) {
  468. let s = jsonBeanElement.icon.toString().split('/')
  469. let i = s[s.length - 1]
  470. if (i === dataForm.value.coverImage) {
  471. jsonBeanElement.select = true
  472. } else {
  473. jsonBeanElement.select = false
  474. }
  475. }
  476. dataForm.value.roomArea = jsonBean.roomArea
  477. dataForm.value.elderType = jsonBean.elderType
  478. dataForm.value.orientation = jsonBean.orientation
  479. dataForm.value.roomSettings = jsonBean.roomSettings
  480. dataForm.value.panoramicUrl = jsonBean.panoramicUrl
  481. try {
  482. dataForm.value.roomImageLists = JSON.parse(jsonBean.roomImage) || []
  483. } catch (e) {
  484. console.log('A', e)
  485. }
  486. try {
  487. dataForm.value.roomVideoLists = JSON.parse(jsonBean.roomVideo) || []
  488. } catch (e) {
  489. console.error('B', e)
  490. }
  491. dataForm.value.roomImage = ''
  492. dataForm.value.roomVideo = ''
  493. dataForm.value.bedList = JSON.parse(JSON.stringify(jsonBean.bedList)) //拷贝
  494. try {
  495. let roomSettings = (jsonBean.roomSettings || '').split(',')
  496. for (let i = 0; i < roomSettings.length; i++) {
  497. if (roomSettings[i] === '男') {
  498. icon1.value = true
  499. }
  500. if (roomSettings[i] === '女') {
  501. icon2.value = true
  502. }
  503. if (roomSettings[i] === '卫生间') {
  504. icon3.value = true
  505. }
  506. }
  507. } catch (e) {}
  508. console.log("收到的房间数据:",dataForm.value)
  509. }
  510. }
  511. const handleRemove: UploadProps['onRemove'] = (uploadFile, uploadFiles) => {
  512. console.log(uploadFile, uploadFiles)
  513. try {
  514. for (let i = 0; i < dataForm.value.roomImageLists.length; i++) {
  515. if (uploadFile.uid === dataForm.value.roomImageLists[i].uid) {
  516. dataForm.value.roomImageLists.splice(i, 1)
  517. break
  518. }
  519. }
  520. } catch (e) {
  521. console.log(e)
  522. }
  523. }
  524. const handleRemoveVideo: UploadProps['onRemove'] = (uploadFile, uploadFiles) => {
  525. console.log(uploadFile, uploadFiles)
  526. }
  527. const roomImageListChange = (e: any) => {
  528. try {
  529. console.log('添加图片', e)
  530. dataForm.value.roomImageLists.push({ url: e.response.data, uid: e.uid })
  531. } catch (e) {}
  532. }
  533. defineExpose({ open }) // 提供 open 方法,用于打开弹窗
  534. /** 提交表单 */
  535. const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
  536. const submitForm = async () => {
  537. console.log('listImage2', dataForm.value.roomImageLists)
  538. try {
  539. for (const validElement of iconList.value) {
  540. if (validElement.select) {
  541. let s = validElement.icon.toString().split('/')
  542. dataForm.value.coverImage = s[s.length - 1]
  543. }
  544. }
  545. } catch (e) {}
  546. try {
  547. if (dataForm.value.roomImageLists.length > 0) {
  548. dataForm.value.roomImage = JSON.stringify(dataForm.value.roomImageLists)
  549. }
  550. if (dataForm.value.roomVideoLists.length > 0) {
  551. dataForm.value.roomVideo = JSON.stringify(dataForm.value.roomVideoLists)
  552. }
  553. } catch (e) {
  554. console.log(e)
  555. }
  556. if(getDictLabel(DICT_TYPE.ROOM_PURPOSE,dataForm.value.roomUsage)=='托养' && dataForm.value.bedList.length==0) {
  557. message.error('最少需要添加一个床位')
  558. scrollToBottom()
  559. }else {
  560. try {
  561. for (const validElement of dataForm.value.bedList) {
  562. if (validElement.bedName == '') {
  563. message.error('请输入床位号')
  564. return
  565. }
  566. if (validElement.sort != '' && validElement.sort != null) {
  567. console.log('循序:', validElement.sort)
  568. if (!/^\d+$/.test(validElement.sort)) {
  569. // 验证输入是否只包含数字
  570. message.error('显示顺序只能输入数字')
  571. return
  572. }
  573. }
  574. }
  575. } catch (err) {}
  576. try {
  577. if (dataForm.value.floorId === '') {
  578. message.error('没有楼层,无法添加房间')
  579. return
  580. }
  581. } catch (err) {}
  582. console.log('参数', dataForm.value)
  583. // 校验表单
  584. if (!formRef.value) return
  585. const valid = await formRef.value.validate()
  586. if (!valid) return
  587. // 提交请求
  588. formLoading.value = true
  589. try {
  590. let res
  591. if (isDetail.value) {
  592. res = await editRoom(dataForm.value)
  593. } else {
  594. res = await addRoom(dataForm.value)
  595. }
  596. if (res) {
  597. message.success(t('common.updateSuccess'))
  598. // dialogVisible.value = false
  599. // 发送操作成功的事件
  600. emit('success')
  601. }
  602. } catch (e) {
  603. console.log('异常', e)
  604. } finally {
  605. formLoading.value = false
  606. dialogVisible.value = false
  607. }
  608. }
  609. }
  610. /** 重置表单 */
  611. const resetForm = () => {
  612. dataForm.value = {
  613. tenantId: undefined,
  614. id: 0,
  615. floorId: '',
  616. roomName: '',
  617. roomUsage: '',
  618. roomArea: undefined,
  619. elderType: undefined,
  620. orientation: undefined,
  621. roomSettings: '',
  622. panoramicUrl: '',
  623. roomImage: '',
  624. roomVideo: '',
  625. coverImage: '',
  626. roomVideoLists: [],
  627. roomImageLists: [],
  628. bedList: [] // "id": 0, "bedName": "", "status": 0, "roomId": 0,"sort": 0
  629. }
  630. icon1.value = false
  631. icon2.value = false
  632. icon3.value = false
  633. formRef.value?.resetFields()
  634. }
  635. // 关闭表单
  636. const handleClosed = () => {
  637. dialogVisible.value = false
  638. resetForm()
  639. }
  640. // 获取老人
  641. const getItems = () => {
  642. nextTick(() => {
  643. selectElderRef.value.open()
  644. })
  645. }
  646. const floorList = ref([])
  647. const addFloor = () => {
  648. //floorNum.value++;
  649. dataForm.value.bedList.push({ bedName: '', sort: '' ,isDelete:false})
  650. nextTick(()=>{
  651. scrollToBottom()
  652. })
  653. }
  654. const deleteFloor = (index) => {
  655. loadingBed.value=true
  656. //编辑的
  657. if(dataForm.value.bedList[index].id!=undefined && dataForm.value.bedList[index].id!==null){
  658. //根据ID查询床位是否被使用
  659. checkBedById(dataForm.value.bedList[index].id).then((res)=>{
  660. console.log(res)
  661. if(!res){
  662. dataForm.value.bedList[index].isDelete = true
  663. }else {
  664. message.error('床位已被入住,无法删除!')
  665. }
  666. loadingBed.value=false
  667. }).catch((e)=>{ loadingBed.value=false})
  668. }else {//新增的直接删
  669. dataForm.value.bedList.splice(index, 1)
  670. loadingBed.value=false
  671. }
  672. }
  673. </script>
  674. <style lang="scss" scoped>
  675. //:deep(.el-upload--picture-card){
  676. // /* 修改文件列表的样式 */
  677. // width: 100px; /* 示例:限制文件列表的最大高度 */
  678. // height: 100px;
  679. //}
  680. //:deep(.el-upload-list__item){
  681. // /* 修改文件列表的样式 */
  682. // width: 100px; /* 示例:限制文件列表的最大高度 */
  683. // height: 100px;
  684. //}
  685. .iconS {
  686. width: 86px;
  687. height: 86px;
  688. border-radius: 8px;
  689. border: #605be2 solid 1px;
  690. }
  691. .iconS:hover {
  692. transform: scale(0.98);
  693. }
  694. .iconS2 {
  695. width: 86px;
  696. height: 86px;
  697. border-radius: 8px;
  698. border: #ffffff solid 1px;
  699. }
  700. .iconS2:hover {
  701. transform: scale(0.98);
  702. }
  703. </style>