roomStateDiagram.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541
  1. <template>
  2. <view>
  3. <Header @change="headerChange" :isSwitch="true">
  4. <template #search>
  5. <!-- <u--input placeholder="房间号/姓名/手机号/身份证号" border="surround" shape="circle" prefixIcon="search" prefixIconStyle="font-size: 22px;color: #909399" fontSize="12px" :customStyle="{border:'1px solid #e2e2e2',padding:'0 10px',margin:'0 10px',borderRadius:'20px'}" @change="searchChange"></u--input> -->
  6. </template>
  7. <template #section>
  8. <u-subsection :list="list" mode="subsection" :current="current" @change="sectionChange"></u-subsection>
  9. </template>
  10. </Header>
  11. <div style="background:#fff">
  12. <div class="room-state-explain">
  13. <div style="margin-right:8px">房态说明</div>
  14. <div v-for="(item, index) in roomStatusColorList" :key="index" style="margin-right:8px">
  15. <div :style="{width:'15px',height:'10px',background:item.extend}"></div>{{item.text}}:{{roomStateFilter(item.value)}}
  16. </div>
  17. </div>
  18. <div style="width:50%;margin-bottom:10px">
  19. <u-subsection :bold="false" :list="list1" mode="subsection" :current="current1" @change="selectChange"></u-subsection>
  20. </div>
  21. <div v-if="current1==1">
  22. <!-- <u-subsection :list="list2" mode="subsection" :current="current2" @change="selectChangeRoomState" fontSize="10"></u-subsection> -->
  23. <div class="tabs-list">
  24. <div v-for="(item, index) in cesRoomLayoutList" :key="item.id" class="tabs-list-content" :class="{'tabs-list-border':index!=list2.length-1}" @click="selectChangeRoomModel(item,index)" :style="{background:item.id==current2?'rgb(60, 156, 255)':'',color:item.id==current2?'#fff':''}">{{item.name}}</div>
  25. </div>
  26. </div>
  27. <div v-if="current1==2">
  28. <u-subsection :bold="false" :list="list3" mode="subsection" :current="current3" @change="selectChangeRoomState" fontSize="10"></u-subsection>
  29. </div>
  30. <div style="margin-top:10px">
  31. <div class="room-state-detail" v-for="item in dataList" :key="item.id">
  32. <div class="room-state-detail-title">{{item.name.includes('栋')? item.name : item.buildingName + item.name}}:{{item.rooms.length}}间</div>
  33. <div class="room-state-detail-grid">
  34. <div class="room-state-detail-card" @click="roomClick(sItem)" v-for="sItem in item.rooms" :key="sItem.id" :style="{background: roomStatusColorList && roomStatusColorList.length > 0 ? getRoomStatusColor(sItem.roomInfo.roomStatus) : '',}">
  35. <div style="display:flex;justify-content: space-between;">
  36. <div><b>{{sItem.roomInfo.name}}</b></div>
  37. <div v-if="sItem.livingData.livingOrder" style="background:rgb(255, 141, 26);color:#fff;padding:1px 2px;border-radius:5px;">{{getCustomerSourceList(sItem.livingData.livingOrder.customerSource)}}</div>
  38. </div>
  39. <div v-if="sItem.livingData.livingOrder">
  40. <div style="width:100%;overflow: hidden;"><b>{{sItem.livingData.livingCustomers.customerName}}</b><span v-if="sItem.livingData.livingOrder.vipCustomerId" style="color:red; font-size: 12px;transform: scale(0.6);display:inline-block;">VIP</span></div>
  41. <div>{{sItem.livingData.livingOrder.dayCount}}天/{{ sItem.livingData.livingOrder.arrivalTime }}</div>
  42. <div style="width:100%;overflow: hidden;">¥{{sItem.livingData.price && sItem.livingData.price.length > 0 ? sItem.livingData.price[0].price : 0 }}/ {{sItem.livingData.livingOrder.shouKuan - sItem.livingData.livingOrder.xiaoFei<0? `欠${sItem.livingData.livingOrder.shouKuan - sItem.livingData.livingOrder.xiaoFei}` : `剩${sItem.livingData.livingOrder.shouKuan - sItem.livingData.livingOrder.xiaoFei}` }}</div>
  43. </div>
  44. <b v-else>
  45. {{sItem.layout.name}}
  46. </b>
  47. </div>
  48. </div>
  49. </div>
  50. </div>
  51. </div>
  52. <u-action-sheet safeAreaInsetBottom :cancelText="'取消'" @close="show = false" :actions="listSheet" @select="selectClick" :title="'设置'" :show="show" v-if="selectData">
  53. <div style="line-height:40px;" v-if="selectData.roomInfo.roomStatus === 2" @click="handleClean">置净</div>
  54. <div style="line-height:40px;" v-else @click="handleDirty">置脏</div>
  55. <div style="line-height:40px;" v-if="selectData.roomInfo.roomStatus === 6" @click="handleOffLock">解锁</div>
  56. <div style="line-height:40px;" v-else @click="handleLock">锁定</div>
  57. <div style="line-height:40px;" v-if="selectData.roomInfo.roomStatus === 5" @click="handleCompleteRepair">完成维修</div>
  58. <div style="line-height:40px;" v-else @click="handleWx">维修</div>
  59. </u-action-sheet>
  60. <u-modal :show="showModal" closeOnClickOverlay @confirm="confirmWx" @close="showModal = false" :cancelText="'取消'" :title="'维修'">
  61. <div>
  62. <div style="display:flex;justify-content:center;align-items:center;">
  63. 维修时间 <div style="margin-left:10px" @click="showTime = true" class="calendar">{{`${startTime} ~ ${endTime}`}}</div>
  64. </div>
  65. <div style="display:flex;justify-content:center;align-items:center;">
  66. 维修原因 <u-input v-model="wxReason" placeholder="请输入维修原因"></u-input>
  67. </div>
  68. </div>
  69. </u-modal>
  70. <u-calendar closeOnClickOverlay :show="showTime" mode="range" @close="showTime=false" @confirm="confirmTime"></u-calendar>
  71. <u-toast style="z-index:999999;position: relative;" ref="uToast"></u-toast>
  72. </view>
  73. </template>
  74. <script>
  75. import Header from '@/components/header.vue'
  76. import {
  77. getHotelRoomList,
  78. getRoomStatus,
  79. getCustomerSource,
  80. getRoomType,
  81. setDirty,
  82. lockRoom,
  83. unlockRoom,
  84. setClean,
  85. repairRoom,
  86. finishRepair
  87. } from '../../utils/customerOrder'
  88. export default {
  89. components: {
  90. Header
  91. },
  92. data() {
  93. return {
  94. list: ['全部', '在住', '预离', '欠费', '钟点', '团队', '散客', '联房', '脏房'],
  95. list1: ['按楼层', '按房型', '按房态'],
  96. list2: [],
  97. list3: [],
  98. current: 0,
  99. current1: 0,
  100. current2: 0,
  101. current3: 0,
  102. dataList: [],
  103. dataListCopy: [],
  104. /**
  105. * 用户来源列表
  106. */
  107. customerSourceList: [],
  108. /**
  109. * 方块背景颜色列表
  110. */
  111. roomStatusColorList: [],
  112. /**
  113. * 房型列表
  114. */
  115. cesRoomLayoutList: [],
  116. //弹出框
  117. show:false,
  118. showModal:false,
  119. showTime:false,
  120. startTime: new Date().toISOString().slice(0, 10),
  121. endTime: new Date(new Date().getTime()+ 24 * 60 * 60 * 1000 ).toISOString().slice(0, 10),
  122. wxReason:'',
  123. listSheet: [
  124. {
  125. name:'置脏'
  126. },
  127. {
  128. name: '置净'
  129. },
  130. {
  131. name: '锁定'
  132. },
  133. {
  134. name: '解锁'
  135. },
  136. {
  137. name: '维修'
  138. }
  139. ],
  140. selectData:null,
  141. }
  142. },
  143. mounted() {
  144. this.getData()
  145. },
  146. methods: {
  147. sectionChange(i) {
  148. console.log(i)
  149. this.current = i
  150. this.filter()
  151. },
  152. searchChange(e) {
  153. console.log(e)
  154. },
  155. selectChange(e) {
  156. console.log(e)
  157. this.current1 = e
  158. this.filter()
  159. },
  160. selectChangeRoomModel(data, idx) {
  161. console.log(data)
  162. this.current2 = data.id
  163. this.filter()
  164. },
  165. selectChangeRoomState(e) {
  166. console.log(e)
  167. this.current3 = e
  168. this.filter()
  169. },
  170. randomColor() {
  171. const color = Math.floor(Math.random() * 0xffffff).toString(16).padEnd(6, '0');
  172. return `#${color}`;
  173. },
  174. headerChange(e) {
  175. this.getData(e)
  176. },
  177. getData(id) {
  178. getHotelRoomList({hotelId:id}).then(res => {
  179. console.log(res);
  180. if (res.code == 200 && res.result.length > 0) {
  181. this.dataListCopy = res.result
  182. this.dataList = res.result
  183. }else{
  184. this.dataListCopy = []
  185. this.dataList = []
  186. }
  187. })
  188. getRoomStatus().then(res => {
  189. console.log(res);
  190. if (res.code == 200 && res.result.length > 0) {
  191. let arr = []
  192. res.result.forEach(ele => {
  193. arr.push(ele.text)
  194. })
  195. this.roomStatusColorList = res.result
  196. this.list3 = arr
  197. this.list3.unshift('全部')
  198. }else{
  199. this.roomStatusColorList = []
  200. this.list3 = []
  201. }
  202. })
  203. getCustomerSource().then(res => {
  204. console.log(res);
  205. if (res.code === 200 && res.result.records.length > 0) {
  206. this.customerSourceList = res.result.records
  207. console.log(this.current2);
  208. }else{
  209. this.customerSourceList = []
  210. }
  211. })
  212. getRoomType().then(res => {
  213. console.log(res);
  214. if (res.code === 200 && res.result.records.length > 0) {
  215. this.cesRoomLayoutList = res.result.records
  216. this.current2 = res.result.records[0].id
  217. }else{
  218. this.cesRoomLayoutList = []
  219. }
  220. })
  221. },
  222. /**
  223. * @description: 筛选
  224. * @param
  225. * @return
  226. */
  227. filter() {
  228. console.log('this.current1', this.current1);
  229. console.log('this.current3', this.current3);
  230. let arr = JSON.parse(JSON.stringify(this.dataListCopy))
  231. console.log('...............');
  232. arr.forEach(item => {
  233. this.current3 == 0 ? item.rooms = item.rooms :
  234. item.rooms = item.rooms.filter(ele => {
  235. return ele.roomInfo.roomStatus == this.current3
  236. })
  237. })
  238. if (this.current2 && this.current1 == 1) {
  239. arr.forEach(item => {
  240. item.rooms = item.rooms.filter(ele => {
  241. return ele.layout.id == this.current2
  242. })
  243. })
  244. }
  245. //在住
  246. if (this.current == 1) {
  247. }
  248. //预离
  249. if (this.current == 2) {
  250. arr.forEach(ele => {
  251. ele.rooms = ele.rooms.filter(item => {
  252. return item.livingData && item.livingData.livingOrder && item.livingData.livingOrder.dueOutTime == new Date().toISOString().slice(0, 10);
  253. })
  254. })
  255. }
  256. //欠费
  257. if (this.current == 3) {
  258. arr.forEach(ele => {
  259. ele.rooms = ele.rooms.filter(item => {
  260. return item.livingData && item.livingData.livingOrder && item.livingData.livingOrder.shouKuan - item.livingData.livingOrder.xiaoFei<0
  261. })
  262. })
  263. }
  264. //钟点
  265. if (this.current == 4) {
  266. arr.forEach(ele => {
  267. ele.rooms = ele.rooms.filter(item=>{
  268. return item.livingData && item.livingData.livingOrder && item.livingData.livingOrder.livingType == 2
  269. })
  270. })
  271. }
  272. //团队
  273. if (this.current == 5) {
  274. arr.forEach(ele => {
  275. ele.rooms = ele.rooms.filter(item=>{
  276. return item.livingData && item.livingData.livingOrder && item.livingData.livingOrder.isTeam
  277. })
  278. })
  279. }
  280. //散客
  281. if (this.current == 6) {
  282. // arr.forEach(ele => {
  283. // ele.rooms = ele.rooms.filter(item=>{
  284. // })
  285. // })
  286. }
  287. //联房
  288. if (this.current == 7) {
  289. }
  290. //脏房
  291. if (this.current == 8) {
  292. }
  293. console.log('arrarrarrarr', arr);
  294. this.dataList = JSON.parse(JSON.stringify(arr))
  295. return arr
  296. },
  297. getCustomerSourceList(customerSource, first) {
  298. console.log(customerSource);
  299. var find = this.customerSourceList.find((t) => t.id == customerSource);
  300. // console.log(find);
  301. // console.log(this.customerSourceList);
  302. if (find) {
  303. // return first ? find.label.substr(0, 1) : find.label;
  304. return find.itemText.substr(0, 1);
  305. }
  306. return "";
  307. },
  308. /**
  309. * 计算方块的背景颜色
  310. */
  311. getRoomStatusColor(roomStatus) {
  312. var find = this.roomStatusColorList.find((t) => t.value == roomStatus);
  313. return find ? find.extend : "";
  314. },
  315. /**
  316. * 计算房态出现的数量
  317. */
  318. roomStateFilter(roomStatus) {
  319. let count = 0
  320. let arr = JSON.parse(JSON.stringify(this.dataListCopy))
  321. arr.forEach(ele => {
  322. ele.rooms.forEach(item => {
  323. if (item.roomInfo.roomStatus == roomStatus) {
  324. count++
  325. }
  326. })
  327. })
  328. return count
  329. },
  330. selectClick(e){
  331. console.log(e);
  332. },
  333. roomClick(data){
  334. console.log(data);
  335. this.selectData = data
  336. this.show = true
  337. },
  338. //置脏
  339. handleDirty(){
  340. if (this.selectData!=null) {
  341. setDirty(this.selectData.roomInfo.id).then(res=>{
  342. console.log(res);
  343. if (res.success) {
  344. this.getData(uni.getStorageSync('hotelId'))
  345. }
  346. this.show = false
  347. })
  348. }
  349. },
  350. //置净
  351. handleClean(){
  352. let selectRoom = [];
  353. selectRoom.push({ roomId: this.selectData.roomInfo.id, roomNo: this.selectData.roomInfo.name })
  354. if (this.selectData!=null) {
  355. setClean({roomCleanList:selectRoom,waiterId:' ',hotelId:uni.getStorageSync('hotelId')}).then(res=>{
  356. console.log(res);
  357. if (res.success) {
  358. this.getData(uni.getStorageSync('hotelId'))
  359. }
  360. this.show = false
  361. })
  362. }
  363. },
  364. //锁房
  365. handleLock(){
  366. let selectRoom = [];
  367. selectRoom.push({ roomId: this.selectData.roomInfo.id, roomNo: this.selectData.roomInfo.name })
  368. if (this.selectData!=null) {
  369. lockRoom({roomLockList:selectRoom,remark:'',hotelId:uni.getStorageSync('hotelId')}).then(res=>{
  370. console.log(res);
  371. if (res.success) {
  372. this.getData(uni.getStorageSync('hotelId'))
  373. }
  374. this.show = false
  375. })
  376. }
  377. },
  378. //解锁
  379. handleOffLock(){
  380. if (this.selectData!=null) {
  381. unlockRoom(this.selectData.roomInfo.id).then(res=>{
  382. console.log(res);
  383. if (res.success) {
  384. this.getData(uni.getStorageSync('hotelId'))
  385. }
  386. this.show = false
  387. })
  388. }
  389. },
  390. //维修
  391. handleWx(){
  392. this.show = false
  393. this.showModal = true
  394. },
  395. //完成维修
  396. handleCompleteRepair(){
  397. if (this.selectData!=null) {
  398. finishRepair(this.selectData.roomInfo.id).then(res=>{
  399. console.log(res);
  400. if (res.success) {
  401. this.getData(uni.getStorageSync('hotelId'))
  402. this.$refs.uToast.show({
  403. type:"success",
  404. message:'成功'
  405. })
  406. }else{
  407. this.$refs.uToast.show({
  408. type:"error",
  409. message:'出错了'
  410. })
  411. }
  412. this.show = false
  413. })
  414. }
  415. },
  416. confirmWx(){
  417. if (this.wxReason == '') {
  418. this.$refs.uToast.show({
  419. type:"error",
  420. message:'维修原因不能为空'
  421. })
  422. return
  423. }
  424. let selectRoom = [];
  425. selectRoom.push({ roomId: this.selectData.roomInfo.id, roomNo: this.selectData.roomInfo.name })
  426. if (this.selectData!=null) {
  427. repairRoom({roomRepairList:selectRoom,remark:this.wxReason,hotelId:uni.getStorageSync('hotelId'),startDate:this.startTime,endDate:this.endTime,dateRange:[this.startDate,this.endTime]}).then(res=>{
  428. console.log(res);
  429. if (res.success) {
  430. this.getData(uni.getStorageSync('hotelId'))
  431. this.$refs.uToast.show({
  432. type:"success",
  433. message:'成功'
  434. })
  435. }
  436. this.show = false
  437. })
  438. }
  439. this.showModal = false
  440. },
  441. confirmTime(e){
  442. console.log(e);
  443. this.startTime = e[0]
  444. this.endTime = e[e.length - 1]
  445. this.showTime = false
  446. }
  447. }
  448. }
  449. </script>
  450. <style lang="scss" scoped>
  451. page {
  452. background-color: #f5f5f5;
  453. }
  454. .room-state-explain {
  455. display: flex;
  456. // justify-content: space-between;
  457. align-items: center;
  458. padding: 10px;
  459. font-size: 12px;
  460. height: 30px;
  461. margin-top: 10px;
  462. flex-wrap: wrap;
  463. div {
  464. display: flex;
  465. align-items: center;
  466. justify-content: center;
  467. // width: 20%;
  468. // height: 30px;
  469. // border-radius: 5px;
  470. // background-color: #fff;
  471. }
  472. }
  473. .room-state-detail-title {
  474. font-size: 14px;
  475. color: #00000080;
  476. padding: 0 8px;
  477. text-align: right;
  478. border-bottom: 1px solid #00000030;
  479. }
  480. .room-state-detail-grid {
  481. display: flex;
  482. flex-wrap: wrap;
  483. align-items: center;
  484. justify-content: start;
  485. width: 96vw;
  486. margin: 0 auto;
  487. }
  488. .room-state-detail-card {
  489. width: calc(30vw);
  490. height: calc(30vw );
  491. font-size: 12px;
  492. border-radius: 8px;
  493. margin: 1vw;
  494. // background: red;
  495. color: #fff;
  496. padding: 1vw 1vw;
  497. box-sizing: border-box;
  498. //阴影
  499. box-shadow: 0 4px 5px rgba(0, 0, 0, 0.6);
  500. }
  501. .tabs-list {
  502. display: flex;
  503. flex-wrap: nowrap;
  504. font-size: 12px;
  505. border-radius: 3px;
  506. // overflow: hidden;
  507. border: 1px solid rgb(60, 156, 255);
  508. .tabs-list-content {
  509. text-align: center;
  510. padding: 5px 7px;
  511. flex: 1;
  512. // text-overflow: ellipsis;
  513. white-space: nowrap;
  514. // overflow: hidden;
  515. }
  516. .tabs-list-border {
  517. border-right: 1px solid rgb(60, 156, 255);
  518. }
  519. }
  520. .calendar {
  521. border: 1px solid;
  522. padding: 5px 10px;
  523. border-radius: 5px;
  524. }
  525. </style>