From 12a2f18a968c29b3502a50c4f0a9f49c27c9f3f6 Mon Sep 17 00:00:00 2001
From: jazz <jazzxhunter@163.com>
Date: 星期三, 03 一月 2024 19:10:25 +0800
Subject: [PATCH] update_202401031910_单个治疗室多个客人的逻辑编写v2

---
 src/components/xio_room_guest_info_box/index.vue |   16 +-
 src/config/index.js                              |    2 
 src/utils/jun_login.js                           |  160 +++++++++++++-------------
 src/pages/room/detail.vue                        |  144 +++++++++++++++++-------
 4 files changed, 189 insertions(+), 133 deletions(-)

diff --git a/src/components/xio_room_guest_info_box/index.vue b/src/components/xio_room_guest_info_box/index.vue
index c5d07fd..69c01bc 100644
--- a/src/components/xio_room_guest_info_box/index.vue
+++ b/src/components/xio_room_guest_info_box/index.vue
@@ -34,14 +34,14 @@
       <div v-if="occupyInfoView.ciq" class="ciq">({{ occupyInfoView.ciq }})</div>
       <div v-if="occupyInfoView.startTime" class="time">瀹夋帓娌荤枟鏃堕棿锛歿{ occupyInfoView.startTime }} 寮�濮�</div>
     </div>
-    <div v-show="roomInfo" class="room_left_btn_box flex flex-ver" style="margin-top: 105px;">
-      <div v-show="roomInfo.status == 0" class="room_left_btn_box__item flex flex-1 flex-center b-green btn_ani" @click="setStatus('鏁烽夯涓�', 4, occupyInfoView)">寮�濮嬫暦楹�</div>
-      <div v-show="roomInfo.status == 0" class="room_left_btn_box__item flex flex-1 flex-center green btn_ani" style="margin-right: 0;" @click="setStatus('浣跨敤涓�', 1, occupyInfoView)">寮�濮嬫不鐤�</div>
-      <div v-show="roomInfo.status == 4" class="room_left_btn_box__item flex flex-center green btn_ani" @click="setStatus('浣跨敤涓�', 1, occupyInfoView)">寮�濮嬫不鐤�</div>
-      <div v-show="roomInfo.status == 1" class="room_left_btn_box__item flex-1 flex flex-center yellow btn_ani" @click="setStatus('瀹汉浼戞伅', 2, occupyInfoView)">瀹汉浼戞伅</div>
-      <div v-show="roomInfo.status == 1" class="room_left_btn_box__item flex-1 flex flex-center gray btn_ani" style="margin-right: 0;" @click="setStatus('鎵撴壂涓�', 3, occupyInfoView)">閫氱煡鎵撴壂</div>
-      <div v-show="roomInfo.status == 2" class="room_left_btn_box__item flex flex-center green btn_ani" @click="setStatus('鎵撴壂涓�', 3, occupyInfoView)">閫氱煡鎵撴壂</div>
-      <div v-show="roomInfo.status == 3" class="room_left_btn_box__item flex flex-center green btn_ani" @click="setStatus('绌洪棽', 0, occupyInfoView)">缁撴潫鎵撴壂</div>
+    <div v-show="occupyInfoView" class="room_left_btn_box flex flex-ver" style="margin-top: 105px;">
+      <div v-show="occupyInfoView.treatRoomStatus == 0" class="room_left_btn_box__item flex flex-1 flex-center b-green btn_ani" @click="setStatus('鏁烽夯涓�', 4, occupyInfoView)">寮�濮嬫暦楹�</div>
+      <div v-show="occupyInfoView.treatRoomStatus == 0" class="room_left_btn_box__item flex flex-1 flex-center green btn_ani" style="margin-right: 0;" @click="setStatus('浣跨敤涓�', 1, occupyInfoView)">寮�濮嬫不鐤�</div>
+      <div v-show="occupyInfoView.treatRoomStatus == 4" class="room_left_btn_box__item flex flex-center green btn_ani" @click="setStatus('浣跨敤涓�', 1, occupyInfoView)">寮�濮嬫不鐤�</div>
+      <div v-show="occupyInfoView.treatRoomStatus == 1" class="room_left_btn_box__item flex-1 flex flex-center yellow btn_ani" @click="setStatus('瀹汉浼戞伅', 2, occupyInfoView)">瀹汉浼戞伅</div>
+      <div v-show="occupyInfoView.treatRoomStatus == 1" class="room_left_btn_box__item flex-1 flex flex-center gray btn_ani" style="margin-right: 0;" @click="setStatus('鎵撴壂涓�', 3, occupyInfoView)">閫氱煡鎵撴壂</div>
+      <div v-show="occupyInfoView.treatRoomStatus == 2" class="room_left_btn_box__item flex flex-center green btn_ani" @click="setStatus('鎵撴壂涓�', 3, occupyInfoView)">閫氱煡鎵撴壂</div>
+      <div v-show="occupyInfoView.treatRoomStatus == 3" class="room_left_btn_box__item flex flex-center green btn_ani" @click="setStatus('绌洪棽', 0, occupyInfoView)">缁撴潫鎵撴壂</div>
     </div>
     <!-- MIC閫氱煡鍗搁夯 -->
     <XioRoomOffNarcosisNotice ref="XioRoomOffNarcosisNotice" @confirm="offNarcosisNoticeConfirm" />
diff --git a/src/config/index.js b/src/config/index.js
index 12bd2c8..91e711d 100644
--- a/src/config/index.js
+++ b/src/config/index.js
@@ -7,7 +7,7 @@
 
 import appId from './appid.js'
 
-var ismock = 1// 铏氭嫙鏁版嵁 0涓嶄娇鐢� 1浣跨敤
+var ismock = 0// 铏氭嫙鏁版嵁 0涓嶄娇鐢� 1浣跨敤
 var istest = 2// 0绾夸笂 1鏈湴 2娴嬭瘯鐜
 var isConsole = 1// 鏄惁灞忚斀console 0灞忚斀 1寮�鏀�
 var debug = isConsole
diff --git a/src/pages/room/detail.vue b/src/pages/room/detail.vue
index 13df298..643f04f 100644
--- a/src/pages/room/detail.vue
+++ b/src/pages/room/detail.vue
@@ -87,7 +87,7 @@
     <div v-if="occupyInfoViewArr && occupyInfoViewArr.length" class="page_container flex flex-1" :class="[occupyInfoViewArr && occupyInfoViewArr.length>1?'over-width':'']">
       <div class="flex flex-1">
         <div v-for="(item,index) in occupyInfoViewArr" :key="index" class="main flex-1">
-          <div v-if="occupyInfoViewArr.length>1" class="cancel_icon_block" @click="cancelCustomerItem(item)">
+          <div v-if="occupyInfoViewArr.length>1 && item.treatRoomStatus === 0" class="cancel_icon_block" @click="cancelCustomerItem(item)">
             <img class="img" src="static/imgs/cancel.png">
           </div>
           <XioRoomGuestInfoBox :ref="`XioRoomGuestInfoBox_${item.id}`" :room-info="roomInfo" :occupy-info-view="item" :off-narcosis-ids="offNarcosisIds" @setStatus="setComStatus" />
@@ -161,15 +161,11 @@
   computed: {
     // 褰撳墠宸查�夋嫨鐢ㄦ埛鐨勬暟缁勬暟鎹�
     occupyInfoViewArr() {
-      // 缂撳瓨璁板綍
-      if (this.curTreatIds && this.curTreatIds.length) {
-        // todo 瀛樺湪缂撳瓨涓斿瓨鍦ㄥ崰鐢ㄦ暟鎹殑鏃跺�欙紝鏍规嵁鍚庣杩斿洖鍐嶈ˉ鍏呴�昏緫
-        return this.getCurTreatArr(this.curTreatIds)
+      if (this.occupyInfo && this.occupyInfo.length) {
+        return this.occupyInfoViewArrIdsHandleArr()
       } else {
-        // todo 瀛樺湪鍗犵敤鏁版嵁鐨勬椂鍊欙紝鏍规嵁鍚庣杩斿洖鍐嶈ˉ鍏呴�昏緫
-        if (this.occupyInfo) {
-          this.occupyInfoViewArrIdsHandle(this.occupyInfo)
-          return [this.occupyInfo]
+        if (this.curTreatIds && this.curTreatIds.length) {
+          return this.getCurTreatArr(this.curTreatIds)
         } else {
           if ((!isUseDefault || (isUseDefault && isUseDefaultChg === 0)) && this.assignTreatList && this.assignTreatList.length) {
             isUseDefault = true
@@ -272,6 +268,32 @@
       }
       this.curTreatIds.push(item.id)
       this.setLocalCurTreatIds()
+    },
+    // 鍒濆榛樿閫夋嫨鐨刬d鏁扮粍澶勭悊
+    occupyInfoViewArrIdsHandleArr() {
+      if (!this.curTreatIds) {
+        this.curTreatIds = []
+      }
+      if (this.occupyInfo && this.occupyInfo.length === 1) {
+        var res = []
+        res.push(this.occupyInfo[0])
+        if (this.curTreatIds && this.curTreatIds.length) {
+          this.curTreatIds = this.curTreatIds.filter((o) => { return o !== this.occupyInfo[0].id })
+          if (this.assignTreatList && this.assignTreatList.length && this.curTreatIds && this.curTreatIds.length) {
+            var curTreatItem = this.assignTreatList.find((o) => { return o.id === this.curTreatIds[0] })
+            if (curTreatItem) {
+              res.push(curTreatItem)
+            }
+          }
+        }
+        this.setLocalCurTreatIds()
+        return res
+      } else if (this.occupyInfo && this.occupyInfo.length > 1) {
+        this.occupyInfo.forEach((o) => {
+          this.curTreatIds.push(o.id)
+        })
+        return this.occupyInfo
+      }
     },
     // 璁剧疆宸查�氱煡鍗搁夯id鏁扮粍
     setLocalStorageOffNarcosisIds() {
@@ -408,18 +430,17 @@
               o.appellationName = o.userName[0] + `${o.gender ? ['濂冲+', '鍏堢敓', '濂冲+'][o.gender] : '濂冲+'}`
             })
           }
-          // todo 宸插崰鐢ㄧ敤鎴锋暟鎹鐞嗭紝寰呭悗绔慨鏀瑰啀澶勭悊
-          if (res.data.occupyInfo && res.data.occupyInfo.userName) {
-            res.data.occupyInfo.appellationName = res.data.occupyInfo.userName[0] + `${res.data.occupyInfo.gender ? ['濂冲+', '鍏堢敓', '濂冲+'][res.data.occupyInfo.gender] : '濂冲+'}`
+          if (res.data.occupyInfo && res.data.occupyInfo.length) {
+            res.data.occupyInfo.forEach((o) => {
+              // 娌荤枟鏃堕棿澶勭悊
+              var st = (o.startTime).split(' ')[1].split(':')
+              o.startTime = `${st[0]}:${st[1]}`
+              // 绉拌皳澶勭悊
+              o.appellationName = o.userName[0] + `${o.gender ? ['濂冲+', '鍏堢敓', '濂冲+'][o.gender] : '濂冲+'}`
+            })
           }
-          // todo 宸叉湁鍗犵敤鐨勶紝鏇存敼宸蹭娇鐢ㄩ粯璁ゅ浜虹殑鐘舵��
-          res.data.occupyInfo && (isUseDefaultChg = 1)
-          res.data.occupyInfo && (isUseDefault = 1)
-          // todo 鍗犵敤淇℃伅娌荤枟鏃堕棿澶勭悊
-          if (res.data.occupyInfo && res.data.occupyInfo.startTime) {
-            var ost = (res.data.occupyInfo.startTime).split(' ')[1].split(':')
-            res.data.occupyInfo.startTime = `${ost[0]}:${ost[1]}`
-          }
+          res.data.occupyInfo && res.data.occupyInfo.length && (isUseDefaultChg = 1)
+          res.data.occupyInfo && res.data.occupyInfo.length && (isUseDefault = 1)
           for (const key in res.data) {
             this[key] = res.data[key]
           }
@@ -498,16 +519,62 @@
     // 鏀瑰彉鎴块棿鐘舵�佸紓姝ユ柟娉�
     changeStatusFn(item = {}, status, cb) {
       var params = {}
-      // 鏇存敼鐨勭姸鎬�
-      params.status = status * 1
       // 鎴块棿id
       if (this.id) {
         params.shopRoomId = this.id
       }
-      // 娌荤枟璁板綍id
+      // 娌荤枟璁板綍id this.curTreatIds occupyInfoViewArr
+      // 1.浣跨敤涓�/鏁烽夯涓� 鏁烽夯涓� 2 浜哄崰鐢�
+      // 2.浣跨敤涓�/浣跨敤涓� 浣跨敤涓� 2 浜哄崰鐢�
+      // 3.浣跨敤涓�/浼戞伅涓�  浣跨敤涓� 1 浜哄崰鐢�
+      var arr = JSON.parse(JSON.stringify(this.occupyInfoViewArr))
       if (item && item.id) {
-        params.treatRecordId = item.id
+        if (arr && arr.length) {
+          arr.forEach((o) => {
+            if (o.id === item.id) {
+              o.treatRoomStatus = status * 1
+            }
+          })
+          // 鏄惁鏈変汉浣跨敤涓�
+          var status_1 = arr.find((o) => { return o.treatRoomStatus === 1 })
+          // 鏄惁鏈夊浜轰紤鎭�
+          var status_2 = arr.find((o) => { return o.treatRoomStatus === 2 })
+          // 鏄惁鏈変汉鎵撴壂涓�
+          var status_3 = arr.find((o) => { return o.treatRoomStatus === 3 })
+          // 鏄惁鏈変汉鏁烽夯
+          var status_4 = arr.find((o) => { return o.treatRoomStatus === 4 })
+          // 鏇存敼鐨勭姸鎬� 鏁烽夯涓� > 浣跨敤涓� > 浼戞伅涓� > 寰呮墦鎵�
+          params.status = status * 1
+          if (status_3) {
+            params.status = 3
+          }
+          if (status_2) {
+            params.status = 2
+          }
+          if (status_1) {
+            params.status = 1
+          }
+          if (status_4) {
+            params.status = 4
+          }
+        }
+
+        // 褰撳墠閫夋嫨瀹㈡埛鐨勬暟缁勫垹闄ゅ鎴�
+        this.occupyInfoViewArrDataHandle('cancel', item)
+      } else {
+        // 鏇存敼鐨勭姸鎬�
+        params.status = status * 1
       }
+      params.treatRoomList = []
+      if (arr && arr.length) {
+        arr.forEach((o) => {
+          params.treatRoomList.push({
+            treatRecordId: o.id,
+            status: o.treatRoomStatus
+          })
+        })
+      }
+
       Req.http.post({
         url: 'guide/treat/screen/room/status/update',
         data: params,
@@ -523,12 +590,6 @@
           console.log('鍦ㄥ凡鏈夐粯璁ゅ浜虹殑鎯呭喌涓嬶紝鏀瑰彉鐘舵�佹洿鏀规爣璇�')
           isUseDefaultChg = 1
         }
-        // 褰撳墠閫変腑鐨勭敤鎴锋埧闂存洿鏀逛簡鐘舵�侊紝宸茬粡鎴愪负鍗犵敤鏃讹紝娓呴櫎閫変腑鍖荤枟璁板綍id
-        // if (item && item.id && item.id === this.curTreatId) {
-        //   console.log('褰撳墠閫変腑鐨勭敤鎴锋埧闂存洿鏀逛簡鐘舵�侊紝宸茬粡鎴愪负鍗犵敤鏃讹紝娓呴櫎閫変腑鍖荤枟璁板綍id')
-        //   localStorage.removeItem('curTreatId')
-        //   this.curTreatId = ''
-        // }
         // 鍙鏇存敼涓虹┖闂插氨閲嶇疆鍙傛暟
         if (status === 0) {
           console.log('鎴块棿鏇存敼涓虹┖闂�')
@@ -536,12 +597,6 @@
           isUseDefault = false
           isUseDefaultChg = 0
           // this.isShowAppellationName = true
-        }
-        // todo 鐢ㄦ埛缁撴潫娌荤枟鍚庯紝灏嗗叾浠庣紦瀛樹腑鍒犻櫎, 寰呮祴璇�
-        if (item && item.id && this.curTreatIds && this.curTreatIds.length && status === 0) {
-          console.log('褰撳墠鐢ㄦ埛鎵�鍦ㄦ埧闂存洿鏀逛簡鐘舵�佷负缁撴潫锛屾竻闄ゅ綋鍓嶇殑鍖荤枟璁板綍id')
-          // 褰撳墠閫夋嫨瀹㈡埛鐨勬暟缁勫垹闄ゅ鎴�
-          this.occupyInfoViewArrDataHandle('cancel', item)
         }
         // console.log('8888888888888888888888888888888888', res)
         cb && cb()
@@ -597,12 +652,12 @@
       // 褰撳墠閫夋嫨瀹㈡埛鐨勬暟缁勫鍔犲鎴�
       this.occupyInfoViewArrDataHandle('add', opt)
       // 閲嶇疆鎴块棿鐘舵��
-      if (this.roomInfo) {
-        this.changeStatusFn({}, 0, () => {
-          // 鍒锋柊璇︽儏
-          this.getData()
-        })
-      }
+      // if (this.roomInfo) {
+      //   this.changeStatusFn({}, 0, () => {
+      //     // 鍒锋柊璇︽儏
+      //     this.getData()
+      //   })
+      // }
       // 鍏抽棴寮圭獥
       this.$refs['XioCustomerSelect'].hideDialog()
     },
@@ -625,6 +680,11 @@
           // 缂撳瓨
           this.setLocalCurTreatIds()
         }
+        if (this.curTreatIds && !this.curTreatIds.length) {
+          this.curTreatIds.push(item.id)
+          // 缂撳瓨
+          this.setLocalCurTreatIds()
+        }
         // 鏁扮粍鏁版嵁澶勭悊
         // if (this.occupyInfoViewArr && this.occupyInfoViewArr.length) {
         //   this.occupyInfoViewArr.push(item)
diff --git a/src/utils/jun_login.js b/src/utils/jun_login.js
index 7eef385..eff9513 100644
--- a/src/utils/jun_login.js
+++ b/src/utils/jun_login.js
@@ -9,35 +9,35 @@
 import Config from '../config'
 // import { Message } from 'element-ui'
 
-let config = {
-	// 鐧诲綍璇锋眰鎺ュ彛閾炬帴
-	url: 'weixin!ajaxGetInfoByCode',
-	// 2灏忔椂杩囨湡
-	expire: 7.2e6,
+const config = {
+  // 鐧诲綍璇锋眰鎺ュ彛閾炬帴
+  url: 'weixin!ajaxGetInfoByCode',
+  // 2灏忔椂杩囨湡
+  expire: 7.2e6
 }
 
 /**
  * 妫�鏌ョ櫥褰曠紦瀛樿繃鏈燂紝榛樿涓嶈繃鏈�
  * @param {object} we_session 缂撳瓨瀵硅薄
  */
-function checkExpire(we_session){
-	// if ((we_session && Date.now() >= we_session.expire) || !we_session) {
-	// 	// 鍒犻櫎store缂撳瓨
-	//  Store.commit('unLogined')
-	// 	// wx.removeStorageSync('we_session')
-	// 	localStorage.removeItem('we_session')
-	// 	return true
-	// }
-	return false
+function checkExpire(we_session) {
+  // if ((we_session && Date.now() >= we_session.expire) || !we_session) {
+  // 	// 鍒犻櫎store缂撳瓨
+  //  Store.commit('unLogined')
+  // 	// wx.removeStorageSync('we_session')
+  // 	localStorage.removeItem('we_session')
+  // 	return true
+  // }
+  return false
 }
 
 /**
  * 杩涘叆寰俊闀块摼锛屽彲鑾峰彇code
  */
-function toLongUrl () {
-	// fn.urlReplace(Config.codeUrl)
-	// location.href = Config.codeUrl
-	location.href = Config.createCodeUrl()
+function toLongUrl() {
+  // fn.urlReplace(Config.codeUrl)
+  // location.href = Config.codeUrl
+  location.href = Config.createCodeUrl()
 }
 
 /**
@@ -46,80 +46,76 @@
  * @param {boolean}  option.force 鏄惁寮哄埗閲嶆柊鐧诲綍
  * @param {function} option.callback 鐧诲綍鎴愬姛鍚庡洖璋�
  */
-function checkLogin(option={}){
-	loginReq(option).then(()=>{
-		if (typeof option.callback === 'function') {
-			option.callback()
-		}
-	})
+function checkLogin(option = {}) {
+  loginReq(option).then(() => {
+    if (typeof option.callback === 'function') {
+      option.callback()
+    }
+  })
 }
 
 /**
  * 鐧诲綍璇锋眰
- * @param {object} option 
+ * @param {object} option
  * @param {object} option.data 璇锋眰鍙傛暟
  */
-function loginReq(option){
-	
-	if (Config.ismock || Config.istest) {
-		option.data.code = '011h5c000ySdaK1lbw000ubdtm2h5c00'
-	}
+function loginReq(option) {
+  if (Config.ismock || Config.istest) {
+    option.data.code = '011h5c000ySdaK1lbw000ubdtm2h5c00'
+  }
 
-	return new Promise((resolve, reject)=>{
-		// 鍓嶇疆鍒ゆ柇
-		let userData = Store.getters.getUserData
-		if (userData.key) {
-			resolve(userData)
-			return
-		}
+  return new Promise((resolve, reject) => {
+    // 鍓嶇疆鍒ゆ柇
+    const userData = Store.getters.getUserData
+    if (userData.key) {
+      resolve(userData)
+      return
+    }
 
-		if (!option || !option.data) {
-			reject()
-			console.error('璋冪敤loginReq锛岀己澶� option')
-			return
-		}
-		if (!option.data.code) {
-			console.error('璋冪敤loginReq锛岀己澶� code')
-			reject()
-			return
-		}
-		Req.http3.post({
-			url: config.url,
-			data: option.data
-		}).then((res)=>{
-			// 缂撳瓨key鍊�
-			fn.setLocalStorage('we_session', {
-				we_session: res.inf.key,
-				expire: Date.now() + config.expire
-			})
-			// 缂撳瓨鐢ㄦ埛鏁版嵁
-			Store.commit('setUserData', res.inf)
-			console.log(res.inf)
+    if (!option || !option.data) {
+      reject()
+      console.error('璋冪敤loginReq锛岀己澶� option')
+      return
+    }
+    if (!option.data.code) {
+      console.error('璋冪敤loginReq锛岀己澶� code')
+      reject()
+      return
+    }
+    Req.http3.post({
+      url: config.url,
+      data: option.data
+    }).then((res) => {
+      // 缂撳瓨key鍊�
+      fn.setLocalStorage('we_session', {
+        we_session: res.inf.key,
+        expire: Date.now() + config.expire
+      })
+      // 缂撳瓨鐢ㄦ埛鏁版嵁
+      Store.commit('setUserData', res.inf)
+      console.log(res.inf)
 
-			// if (res.inf.name) {
-			// 	Store.commit('setNickName', res.inf.name)
-			// }
-	
-			// 澶勭悊鐧诲綍瀹屾垚 store
-			// getUserInfo().then(_res=>{
-			// 	// Store.commit('setLogined', _res.inf)
-			// 	resolve(res)
-			// })
-			// Store.commit('setLogined')
+      // if (res.inf.name) {
+      // 	Store.commit('setNickName', res.inf.name)
+      // }
 
-			resolve(res)
-			
-		}).catch((res)=>{
-			console.log(res)
-			reject(res)
-		})
-	})
+      // 澶勭悊鐧诲綍瀹屾垚 store
+      // getUserInfo().then(_res=>{
+      // 	// Store.commit('setLogined', _res.inf)
+      // 	resolve(res)
+      // })
+      // Store.commit('setLogined')
+
+      resolve(res)
+    }).catch((res) => {
+      console.log(res)
+      reject(res)
+    })
+  })
 }
 
-
-
 export default {
-	checkLogin,
-	loginReq,
-	toLongUrl
-}
\ No newline at end of file
+  checkLogin,
+  loginReq,
+  toLongUrl
+}

--
Gitblit v1.8.0