roomStateDiagram.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549
  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 || selectData.roomInfo.roomStatus === 4" @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. arr.forEach(item => {
  248. item.rooms = item.rooms.filter(ele => {
  249. return ele.roomInfo.roomStatus == 3 || ele.roomInfo.roomStatus == 4
  250. })
  251. })
  252. }
  253. //预离
  254. if (this.current == 2) {
  255. arr.forEach(ele => {
  256. ele.rooms = ele.rooms.filter(item => {
  257. return item.livingData && item.livingData.livingOrder && item.livingData.livingOrder.dueOutTime == new Date().toISOString().slice(0, 10);
  258. })
  259. })
  260. }
  261. //欠费
  262. if (this.current == 3) {
  263. arr.forEach(ele => {
  264. ele.rooms = ele.rooms.filter(item => {
  265. return item.livingData && item.livingData.livingOrder && item.livingData.livingOrder.shouKuan - item.livingData.livingOrder.xiaoFei<0
  266. })
  267. })
  268. }
  269. //钟点
  270. if (this.current == 4) {
  271. arr.forEach(ele => {
  272. ele.rooms = ele.rooms.filter(item=>{
  273. return item.livingData && item.livingData.livingOrder && item.livingData.livingOrder.livingType == 2
  274. })
  275. })
  276. }
  277. //团队
  278. if (this.current == 5) {
  279. arr.forEach(ele => {
  280. ele.rooms = ele.rooms.filter(item=>{
  281. return item.livingData && item.livingData.livingOrder && item.livingData.livingOrder.isTeam
  282. })
  283. })
  284. }
  285. //散客
  286. if (this.current == 6) {
  287. arr.forEach(ele => {
  288. ele.rooms = ele.rooms.filter(item=>{
  289. return item.livingData && item.livingData.livingOrder && this.getCustomerSourceList(item.livingData.livingOrder.customerSource).indexOf('散') > -1
  290. })
  291. })
  292. }
  293. //联房
  294. if (this.current == 7) {
  295. }
  296. //脏房
  297. if (this.current == 8) {
  298. arr.forEach(item => {
  299. item.rooms = item.rooms.filter(ele => {
  300. return ele.roomInfo.roomStatus == 2 || ele.roomInfo.roomStatus == 4
  301. })
  302. })
  303. }
  304. console.log('arrarrarrarr', arr);
  305. this.dataList = JSON.parse(JSON.stringify(arr))
  306. return arr
  307. },
  308. getCustomerSourceList(customerSource, first) {
  309. console.log(customerSource);
  310. var find = this.customerSourceList.find((t) => t.id == customerSource);
  311. // console.log(find);
  312. // console.log(this.customerSourceList);
  313. if (find) {
  314. // return first ? find.label.substr(0, 1) : find.label;
  315. return find.itemText.substr(0, 1);
  316. }
  317. return "";
  318. },
  319. /**
  320. * 计算方块的背景颜色
  321. */
  322. getRoomStatusColor(roomStatus) {
  323. var find = this.roomStatusColorList.find((t) => t.value == roomStatus);
  324. return find ? find.extend : "";
  325. },
  326. /**
  327. * 计算房态出现的数量
  328. */
  329. roomStateFilter(roomStatus) {
  330. let count = 0
  331. let arr = JSON.parse(JSON.stringify(this.dataListCopy))
  332. arr.forEach(ele => {
  333. ele.rooms.forEach(item => {
  334. if (item.roomInfo.roomStatus == roomStatus) {
  335. count++
  336. }
  337. })
  338. })
  339. return count
  340. },
  341. selectClick(e){
  342. console.log(e);
  343. },
  344. roomClick(data){
  345. console.log(data);
  346. this.selectData = data
  347. this.show = true
  348. },
  349. //置脏
  350. handleDirty(){
  351. if (this.selectData!=null) {
  352. setDirty(this.selectData.roomInfo.id).then(res=>{
  353. console.log(res);
  354. if (res.success) {
  355. this.getData(uni.getStorageSync('hotelId'))
  356. }
  357. this.show = false
  358. })
  359. }
  360. },
  361. //置净
  362. handleClean(){
  363. let selectRoom = [];
  364. selectRoom.push({ roomId: this.selectData.roomInfo.id, roomNo: this.selectData.roomInfo.name })
  365. if (this.selectData!=null) {
  366. setClean({roomCleanList:selectRoom,waiterId:' ',hotelId:uni.getStorageSync('hotelId')}).then(res=>{
  367. console.log(res);
  368. if (res.success) {
  369. this.getData(uni.getStorageSync('hotelId'))
  370. }
  371. this.show = false
  372. })
  373. }
  374. },
  375. //锁房
  376. handleLock(){
  377. let selectRoom = [];
  378. selectRoom.push({ roomId: this.selectData.roomInfo.id, roomNo: this.selectData.roomInfo.name })
  379. if (this.selectData!=null) {
  380. lockRoom({roomLockList:selectRoom,remark:'',hotelId:uni.getStorageSync('hotelId')}).then(res=>{
  381. console.log(res);
  382. if (res.success) {
  383. this.getData(uni.getStorageSync('hotelId'))
  384. }
  385. this.show = false
  386. })
  387. }
  388. },
  389. //解锁
  390. handleOffLock(){
  391. if (this.selectData!=null) {
  392. unlockRoom(this.selectData.roomInfo.id).then(res=>{
  393. console.log(res);
  394. if (res.success) {
  395. this.getData(uni.getStorageSync('hotelId'))
  396. }
  397. this.show = false
  398. })
  399. }
  400. },
  401. //维修
  402. handleWx(){
  403. this.show = false
  404. this.showModal = true
  405. },
  406. //完成维修
  407. handleCompleteRepair(){
  408. if (this.selectData!=null) {
  409. finishRepair(this.selectData.roomInfo.id).then(res=>{
  410. console.log(res);
  411. if (res.success) {
  412. this.getData(uni.getStorageSync('hotelId'))
  413. this.$refs.uToast.show({
  414. type:"success",
  415. message:'成功'
  416. })
  417. }else{
  418. this.$refs.uToast.show({
  419. type:"error",
  420. message:'出错了'
  421. })
  422. }
  423. this.show = false
  424. })
  425. }
  426. },
  427. confirmWx(){
  428. if (this.wxReason == '') {
  429. this.$refs.uToast.show({
  430. type:"error",
  431. message:'维修原因不能为空'
  432. })
  433. return
  434. }
  435. let selectRoom = [];
  436. selectRoom.push({ roomId: this.selectData.roomInfo.id, roomNo: this.selectData.roomInfo.name })
  437. if (this.selectData!=null) {
  438. repairRoom({roomRepairList:selectRoom,remark:this.wxReason,hotelId:uni.getStorageSync('hotelId'),startDate:this.startTime,endDate:this.endTime,dateRange:[this.startDate,this.endTime]}).then(res=>{
  439. console.log(res);
  440. if (res.success) {
  441. this.getData(uni.getStorageSync('hotelId'))
  442. this.$refs.uToast.show({
  443. type:"success",
  444. message:'成功'
  445. })
  446. }
  447. this.show = false
  448. })
  449. }
  450. this.showModal = false
  451. },
  452. confirmTime(e){
  453. console.log(e);
  454. this.startTime = e[0]
  455. this.endTime = e[e.length - 1]
  456. this.showTime = false
  457. }
  458. }
  459. }
  460. </script>
  461. <style lang="scss" scoped>
  462. page {
  463. background-color: #f5f5f5;
  464. }
  465. .room-state-explain {
  466. display: flex;
  467. // justify-content: space-between;
  468. align-items: center;
  469. padding: 10px;
  470. font-size: 12px;
  471. height: 30px;
  472. margin-top: 10px;
  473. flex-wrap: wrap;
  474. div {
  475. display: flex;
  476. align-items: center;
  477. justify-content: center;
  478. // width: 20%;
  479. // height: 30px;
  480. // border-radius: 5px;
  481. // background-color: #fff;
  482. }
  483. }
  484. .room-state-detail-title {
  485. font-size: 14px;
  486. color: #00000080;
  487. padding: 0 8px;
  488. text-align: right;
  489. border-bottom: 1px solid #00000030;
  490. }
  491. .room-state-detail-grid {
  492. display: flex;
  493. flex-wrap: wrap;
  494. align-items: center;
  495. justify-content: start;
  496. width: 96vw;
  497. margin: 0 auto;
  498. }
  499. .room-state-detail-card {
  500. width: calc(30vw);
  501. height: calc(30vw );
  502. font-size: 12px;
  503. border-radius: 8px;
  504. margin: 1vw;
  505. // background: red;
  506. color: #fff;
  507. padding: 1vw 1vw;
  508. box-sizing: border-box;
  509. //阴影
  510. box-shadow: 0 4px 5px rgba(0, 0, 0, 0.6);
  511. }
  512. .tabs-list {
  513. display: flex;
  514. flex-wrap: nowrap;
  515. font-size: 12px;
  516. border-radius: 3px;
  517. // overflow: hidden;
  518. border: 1px solid rgb(60, 156, 255);
  519. .tabs-list-content {
  520. text-align: center;
  521. padding: 5px 7px;
  522. flex: 1;
  523. // text-overflow: ellipsis;
  524. white-space: nowrap;
  525. // overflow: hidden;
  526. }
  527. .tabs-list-border {
  528. border-right: 1px solid rgb(60, 156, 255);
  529. }
  530. }
  531. .calendar {
  532. border: 1px solid;
  533. padding: 5px 10px;
  534. border-radius: 5px;
  535. }
  536. </style>