From 9dba26f6865d5c8cd44690dda5a4806fa4a6b262 Mon Sep 17 00:00:00 2001
From: GULIMMO <2820890765@qq.com>
Date: Mon, 06 Nov 2023 20:33:25 +0800
Subject: [PATCH] 房屋上报、租户详情、房屋详情逻辑修改

---
 subPackage/house/roomDetails/index.vue     |  266 +++++++++++++++++++++++++++-------------------------
 subPackage/bs/views/rentDetail.vue         |   16 ++
 subPackage/bs/components/list/rentList.vue |   12 +-
 3 files changed, 158 insertions(+), 136 deletions(-)

diff --git a/subPackage/bs/components/list/rentList.vue b/subPackage/bs/components/list/rentList.vue
index 073bd05..3b597cd 100644
--- a/subPackage/bs/components/list/rentList.vue
+++ b/subPackage/bs/components/list/rentList.vue
@@ -31,9 +31,9 @@
 			<u-divider text="已经到底了"></u-divider>
 		</view>
 
-		<u-datetime-picker v-model="currentTime" :closeOnClickOverlay="true" @close="isPickerShow = false" :show="isPickerShow" @cancel="isPickerShow = false" mode="date"
+		<u-datetime-picker v-model="currentTime" v-if="isPickerShow" :closeOnClickOverlay="true" @close="isPickerShow = false" :show="isPickerShow" @cancel="isPickerShow = false" mode="date"
 			@confirm="dueTimeConfirm"></u-datetime-picker>
-		<u-datetime-picker v-model="currentTime" :closeOnClickOverlay="true" @close="istPickerShow = false" :show="istPickerShow" @cancel="istPickerShow = false" mode="date"
+		<u-datetime-picker v-model="currentTime" v-if="istPickerShow" :closeOnClickOverlay="true" @close="istPickerShow = false" :show="istPickerShow" @cancel="istPickerShow = false" mode="date"
 			@confirm="terminateTimeConfirm"></u-datetime-picker>
 		<u-modal :show="isModelShow" width="auto" :showCancelButton="true" title="提示" content="请确认是否删除当前租户信息"
 			@cancel="isModelShow = false" @confirm="deleteRentalConfirm"></u-modal>
@@ -72,7 +72,7 @@
 						value: 2
 					},
 				],
-				currentTime: Number(new Date()),
+				currentTime: '',
 				currentRentInfo: {}
 			}
 		},
@@ -115,8 +115,10 @@
 			},
 			xzHandleClick(item) {
 				this.currentRentalId = item.housingRentalId
-				this.currentRentInfo = item
-				this.isPickerShow = true
+				this.currentRentInfo = item
+				this.currentTime = item.dueTime
+				this.isPickerShow = true
+				
 			},
 			async dueTimeConfirm(e) {
 				// 判断当前选中的时间是否小于租房时间
diff --git a/subPackage/bs/views/rentDetail.vue b/subPackage/bs/views/rentDetail.vue
index 7082d00..3bfd4cc 100644
--- a/subPackage/bs/views/rentDetail.vue
+++ b/subPackage/bs/views/rentDetail.vue
@@ -20,13 +20,13 @@
 					</u--input>
 					<u-icon slot="right" name="arrow-right"></u-icon>
 				</u-form-item>
-				<u-form-item @click="rentTimeShow = true" class="form-item" labelWidth="100" label="租房时间:" required
+				<u-form-item @click="rentTimeClick" class="form-item" labelWidth="100" label="租房时间:" required
 					prop="rentTime">
 					<u--input border="none" v-model="form.rentTime" disabled disabledColor="#ffffff" placeholder="请选择">
 					</u--input>
 					<u-icon slot="right" name="arrow-right"></u-icon>
 				</u-form-item>
-				<u-form-item @click="dueTimeShow = true" class="form-item" labelWidth="100" label="到期时间:" required
+				<u-form-item @click="dueTimeClick" class="form-item" labelWidth="100" label="到期时间:" required
 					prop="dueTime">
 					<u--input border="none" v-model="form.dueTime" disabled disabledColor="#ffffff" placeholder="请选择">
 					</u--input>
@@ -61,9 +61,9 @@
 			:popupTitle="selectBusTitle" :dataLists="selectBusList" @cancel="typeShow = false" @submit="typeSelect">
 		</select-bus>
 		<!--出租时间选择-->
-		<u-datetime-picker v-model="currentTime" :closeOnClickOverlay="true" @close="rentTimeShow = false" :show="rentTimeShow" mode="date" @confirm="rentTimeConfirm"
+		<u-datetime-picker v-model="currentTime" v-if="rentTimeShow" :closeOnClickOverlay="true" @close="rentTimeShow = false" :show="rentTimeShow" mode="date" @confirm="rentTimeConfirm"
 			@cancel="rentTimeShow = false"></u-datetime-picker>
-		<u-datetime-picker v-model="currentTime" :closeOnClickOverlay="true" @close="dueTimeShow = false" :show="dueTimeShow" mode="date" @confirm="dueTimeConfirm"
+		<u-datetime-picker v-model="currentTime" v-if="dueTimeShow" :closeOnClickOverlay="true" @close="dueTimeShow = false" :show="dueTimeShow" mode="date" @confirm="dueTimeConfirm"
 			@cancel="dueTimeShow = false"></u-datetime-picker>
 
 		<view class="bottom-tools">
@@ -216,11 +216,19 @@
 				this[this.selectBusModel] = item.name
 				this.form[this.selectBusKey] = item.value
 				this.typeShow = !this.typeShow
+			},
+			rentTimeClick() {
+				this.currentTime = Number(new Date(this.form.rentTime)) || Number(new Date())
+				this.rentTimeShow = true
 			},
 			rentTimeConfirm(e) {
 				const time = uni.$u.timeFormat(e.value, 'yyyy-mm-dd')
 				this.form.rentTime = time
 				this.rentTimeShow = false
+			},
+			dueTimeClick() {
+				this.currentTime = Number(new Date(this.form.dueTime)) || Number(new Date())
+				this.dueTimeShow = true
 			},
 			dueTimeConfirm(e) {
 				const time = uni.$u.timeFormat(e.value, 'yyyy-mm-dd')
diff --git a/subPackage/house/roomDetails/index.vue b/subPackage/house/roomDetails/index.vue
index db8fa8a..190124b 100644
--- a/subPackage/house/roomDetails/index.vue
+++ b/subPackage/house/roomDetails/index.vue
@@ -22,7 +22,8 @@
 						<view class="l flex-1 flex">
 							<view class="flex_base">
 								<view class="head-img flex_base">
-									<u--image shape="circle" :showLoading="true" :src="item.src|| '/static/icon/user-01.png'"  width="120rpx"
+									<u--image shape="circle" :showLoading="true"
+										:src="item.src|| '/static/icon/user-01.png'" width="120rpx"
 										height="120rpx"></u--image>
 								</view>
 							</view>
@@ -42,12 +43,12 @@
 						</view>
 						<view class="r flex f-d-c j-c-s-a">
 							<view>
-								<u-button size='small' type="primary" :plain="true" text="资料管理" 
-								@click="addOrupdateMember(2,item)"></u-button>
+								<u-button size='small' type="primary" :plain="true" text="资料管理"
+									@click="addOrupdateMember(2,item)"></u-button>
 							</view>
 							<view>
-								<u-button size='small' type="primary" :plain="true" text="标签管理" 
-								@click="goToHouseholdLabel(item)"></u-button>
+								<u-button size='small' type="primary" :plain="true" text="标签管理"
+									@click="goToHouseholdLabel(item)"></u-button>
 							</view>
 						</view>
 					</view>
@@ -62,8 +63,9 @@
 					</view>
 
 				</view>
-				<u-modal :show="isHouseholdModelShow" width="auto" :showCancelButton="true" title="提示" content="请确认是否删除当前住户信息"
-					@cancel="isHouseholdModelShow = false" @confirm="deleteHousehold()"></u-modal>
+				<u-modal :show="isHouseholdModelShow" width="auto" :showCancelButton="true" title="提示"
+					content="请确认是否删除当前住户信息" @cancel="isHouseholdModelShow = false"
+					@confirm="deleteHousehold()"></u-modal>
 
 				<view class="mt-20 rent-out-box">
 					<box-title :title="'出租管理'"></box-title>
@@ -95,12 +97,14 @@
 						</view>
 					</view>
 				</view>
-				<u-datetime-picker :show="isPickerShow" @cancel="isPickerShow = false" mode="date"
-					@confirm="dueTimeConfirm"></u-datetime-picker>
-				<u-datetime-picker :show="istPickerShow" @cancel="istPickerShow = false" mode="date"
+				<u-datetime-picker v-model="currentTime" v-if="isPickerShow" :closeOnClickOverlay="true"
+					@close="isPickerShow = false" :show="isPickerShow" @cancel="isPickerShow = false" mode="date"
+					@confirm="dueTimeConfirm"></u-datetime-picker>
+				<u-datetime-picker v-model="currentTime" v-if="istPickerShow" :closeOnClickOverlay="true"
+					@close="istPickerShow = false" :show="istPickerShow" @cancel="istPickerShow = false" mode="date"
 					@confirm="terminateTimeConfirm"></u-datetime-picker>
-				<u-divider text="已经到底了"></u-divider>
-				<u-modal :show="isModelShow" width="auto" :showCancelButton="true" title="提示" content="请确认是否删除当前租户信息"
+				<u-divider text="已经到底了"></u-divider>
+				<u-modal :show="isModelShow" width="auto" :showCancelButton="true" title="提示" content="请确认是否删除当前租户信息"
 					@cancel="isModelShow = false" @confirm="deleteRentalConfirm"></u-modal>
 			</view>
 
@@ -113,18 +117,18 @@
 					<u-button type="primary" :plain="true" text="添加租赁信息" @click="addRental"></u-button>
 				</view>
 			</view>
-			
-		</view>
+
+		</view>
 	</view>
 </template>
 
 <script>
 	import {
 		getHouseRentInfo
-	} from "@/api/doorplateAddress/doorplateAddress";
-	import {
-		deleteRentalInfo,
-		updateDueTime
+	} from "@/api/doorplateAddress/doorplateAddress";
+	import {
+		deleteRentalInfo,
+		updateDueTime
 	} from "@/api/houseRental/houseRental.js";
 	import {
 		removeHousehold
@@ -134,8 +138,8 @@
 
 		data() {
 			return {
-				householdId:'',
-				isHouseholdModelShow:false,
+				householdId: '',
+				isHouseholdModelShow: false,
 				currentId: '',
 				houseCode: '',
 				houseInfo: {
@@ -148,24 +152,25 @@
 					allNum: 0
 				},
 				ownerInfoList: [],
-				rentOutList: [],
-				isPickerShow: false,
-				istPickerShow: false,
-				currentRentalId: '',
-				isModelShow: false,
-				status: [{
-						name: '未到期',
-						value: 0
-					},
-					{
-						name: '已到期',
-						value: 1
-					},
-					{
-						name: '已终止',
-						value: 2
-					},
+				rentOutList: [],
+				isPickerShow: false,
+				istPickerShow: false,
+				currentRentalId: '',
+				isModelShow: false,
+				status: [{
+						name: '未到期',
+						value: 0
+					},
+					{
+						name: '已到期',
+						value: 1
+					},
+					{
+						name: '已终止',
+						value: 2
+					},
 				],
+				currentTime: null
 			}
 		},
 		onLoad(e) {
@@ -179,20 +184,23 @@
 		},
 		methods: {
 			// 跳转住户标签管理页面
-			goToHouseholdLabel(data){
+			goToHouseholdLabel(data) {
 				data['houseCode'] = this.houseCode
 				var navData = JSON.stringify(data);
 				this.$u.func.globalNavigator(`/subPackage/house/member/householdLabel?data=${navData}`)
 			},
 			// 删除住户弹出
-			removeHouseholdSub(data){
+			removeHouseholdSub(data) {
 				this.householdId = data.id
 				this.isHouseholdModelShow = true
 			},
 			// 删除住户信息
-			deleteHousehold(){
-				removeHousehold(this.householdId).then(res=>{
-					const {code,data}  = res
+			deleteHousehold() {
+				removeHousehold(this.householdId).then(res => {
+					const {
+						code,
+						data
+					} = res
 					if (code !== 200) {
 						uni.showToast({
 							title: "删除失败",
@@ -213,7 +221,7 @@
 						title: "数据加载失败",
 						icon: "error",
 						duration: 1500
-					})
+					})
 					return
 				}
 				const {
@@ -223,7 +231,7 @@
 					houseName,
 					unitName,
 					houseRentalList,
-					householdList,
+					householdList,
 					subAoi
 				} = res.data
 				this.houseCode = addressCode
@@ -231,7 +239,7 @@
 				this.ownerInfoList = householdList
 				this.houseInfo.houseName = houseName
 				this.houseInfo.unitName = unitName
-				this.houseInfo.houseTitle =( aoiName || subAoi) + ':' + buildingName
+				this.houseInfo.houseTitle = (aoiName || subAoi) + ':' + buildingName
 				// 判断当前租客有没有过期
 				this.rentOutList.forEach(item => {
 					// 事件格式处理
@@ -241,7 +249,7 @@
 					item.allNum = item.houseTenantVOList.length
 					// 多人个租客将第一个作为显示
 					item.tenant = item.houseTenantVOList.length > 0 ? item.houseTenantVOList[0].name : ''
-					item.housingRentalId = item.houseTenantVOList[0]?.housingRentalId
+					item.housingRentalId = item.houseTenantVOList[0]?.housingRentalId
 				})
 				this.houseInfo.allNum = householdList.length
 
@@ -254,91 +262,95 @@
 				const url = `/subPackage/bs/views/rentDetail?houseCode=${this.houseCode}`
 				this.$u.func.globalNavigator(url, "navTo")
 			},
-			// 用户资料管理页面跳转  1:新增 2:修改
-			addOrupdateMember(type,data={}) {
-				if(type==1){
+			// 用户资料管理页面跳转  1:新增 2:修改
+			addOrupdateMember(type, data = {}) {
+				if (type == 1) {
 					data['type'] = 1
 					data['houseCode'] = this.houseCode
 				}
-				if(type==2){
+				if (type == 2) {
 					data['type'] = 2
 				}
-				var navData = JSON.stringify(data); 
-				this.$u.func.globalNavigator(`/subPackage/house/member/index?data=${navData}`)
-			},
-			editRent(item) {
-				const { houseCode, id } = item
-				this.$u.func.globalNavigator(`/subPackage/bs/views/rentDetail?houseCode=${houseCode}&id=${id}`)
-			},
-			reletRent(item) {
-				console.log(item);
-				this.currentRentalId = item.housingRentalId
-				this.isPickerShow = true
-			},
-			
-			terRent(item) {
-				this.currentRentalId = item.housingRentalId
-				this.istPickerShow = true
-			},
-			deleteRent(item) {
-				this.currentRentalId = item.housingRentalId
-				this.isModelShow = true
-			},
-			async dueTimeConfirm(e) {
-				const time = uni.$u.timeFormat(e.value, 'yyyy-mm-dd')
-				const res = await updateDueTime({
-					id: this.currentRentalId,
-					dueTime: time
-				})
-				if (res.code !== 200) {
-					uni.showToast({
-						title: "续租失败",
-						icon: "error",
-						duration: 1500
-					})
-					return
-				}
-				this.isPickerShow = false
-				this.getHouseRentInfoList()
-			},
-			async terminateTimeConfirm(e) {
-				const time = uni.$u.timeFormat(e.value, 'yyyy-mm-dd')
-				const res = await updateDueTime({
-					id: this.currentRentalId,
-					terminationTime: time
-				})
-				if (res.code !== 200) {
-					uni.showToast({
-						title: "终止失败",
-						icon: "error",
-						duration: 1500
-					})
-					return
-				}
-				this.istPickerShow = false
-				this.getHouseRentInfoList()
-			},
-			async deleteRentalConfirm() {
-				const {
-					code,
-					data
-				} = await deleteRentalInfo(this.currentRentalId)
-				if (code !== 200) {
-					uni.showToast({
-						title: "删除失败",
-						icon: "error",
-						duration: 1500
-					})
-					return
-				}
-				this.isModelShow = false
-				this.getHouseRentInfoList()
-			},
-			findObjValue(value, obj) {
-				const res = obj.find(item => {
-					return item.value == value
-				})
-				return res.name
+				var navData = JSON.stringify(data);
+				this.$u.func.globalNavigator(`/subPackage/house/member/index?data=${navData}`)
+			},
+			editRent(item) {
+				const {
+					houseCode,
+					id
+				} = item
+				this.$u.func.globalNavigator(`/subPackage/bs/views/rentDetail?houseCode=${houseCode}&id=${id}`)
+			},
+			reletRent(item) {
+				this.currentTime = item.dueTime
+				this.currentRentalId = item.housingRentalId
+				this.isPickerShow = true
+			},
+
+			terRent(item) {
+				this.currentTime = item.dueTime
+				this.currentRentalId = item.housingRentalId
+				this.istPickerShow = true
+			},
+			deleteRent(item) {
+				this.currentRentalId = item.housingRentalId
+				this.isModelShow = true
+			},
+			async dueTimeConfirm(e) {
+				const time = uni.$u.timeFormat(e.value, 'yyyy-mm-dd')
+				const res = await updateDueTime({
+					id: this.currentRentalId,
+					dueTime: time
+				})
+				if (res.code !== 200) {
+					uni.showToast({
+						title: "续租失败",
+						icon: "error",
+						duration: 1500
+					})
+					return
+				}
+				this.isPickerShow = false
+				this.getHouseRentInfoList()
+			},
+			async terminateTimeConfirm(e) {
+				const time = uni.$u.timeFormat(e.value, 'yyyy-mm-dd')
+				const res = await updateDueTime({
+					id: this.currentRentalId,
+					terminationTime: time
+				})
+				if (res.code !== 200) {
+					uni.showToast({
+						title: "终止失败",
+						icon: "error",
+						duration: 1500
+					})
+					return
+				}
+				this.istPickerShow = false
+				this.getHouseRentInfoList()
+			},
+			async deleteRentalConfirm() {
+				const {
+					code,
+					data
+				} = await deleteRentalInfo(this.currentRentalId)
+				if (code !== 200) {
+					uni.showToast({
+						title: "删除失败",
+						icon: "error",
+						duration: 1500
+					})
+					return
+				}
+				this.isModelShow = false
+				this.getHouseRentInfoList()
+			},
+			findObjValue(value, obj) {
+				const res = obj.find(item => {
+					return item.value == value
+				})
+				return res.name
 			},
 		}
 	}
@@ -423,7 +435,7 @@
 							&>.u-button {
 								margin: 0 16rpx;
 							}
-							
+
 							.btn-item {
 								margin: 0 10rpx;
 								border: 0;

--
Gitblit v1.9.3