Browse Source

退房检查,退房详情接口联调

wyx
wangyx 1 month ago
parent
commit
c70cc918c9
  1. 15
      pages/api.js
  2. 141
      pagesA/checkout/detail/detail.vue
  3. 83
      pagesA/checkout/list/list.vue
  4. 72
      pagesA/force/index/index.vue
  5. 37
      utils/request.js

15
pages/api.js

@ -1,4 +1,4 @@
import request from "../utils/request.js"; import request, { uploadFile } from "../utils/request.js";
// 获取验证码 // 获取验证码
export function getCodeImg() { export function getCodeImg() {
@ -45,3 +45,16 @@ export function submitCheckout(data) {
data: data, data: data,
}); });
} }
export function uploadImage(filePath, formData = {}) {
return uploadFile(filePath, {
formData: formData,
});
}
// 暂存提交退房
export function tempSaveCheckOut(data) {
return request({
url: "/apartment/manager/tempSaveCheckOut",
method: "post",
data: data,
});
}

141
pagesA/checkout/detail/detail.vue

@ -21,7 +21,7 @@ import { detail } from '@/api/mz/contract';
><text class="label">联系电话</text>{{ info.telephone }}</view ><text class="label">联系电话</text>{{ info.telephone }}</view
> >
<view class="info-row" <view class="info-row"
><text class="label">居住日期</text>{{ info.startDate }}{{ ><text class="label">居住日期</text>{{ info.checkInDate }}{{
info.checkOutDate info.checkOutDate
}}</view }}</view
> >
@ -36,17 +36,17 @@ import { detail } from '@/api/mz/contract';
> >
<text class="device-label">{{ item.name }}</text> <text class="device-label">{{ item.name }}</text>
<u-radio-group <u-radio-group
v-model="item.status"
placement="row" placement="row"
@change="onDeviceChange(idx, $event)" @change="onDeviceChange(idx, $event)"
v-model="checkStatus[idx]"
> >
<u-radio <u-radio
:custom-style="'margin-right:36rpx;'" :custom-style="'margin-right:36rpx;'"
activeColor="#0DC6C6" activeColor="#0DC6C6"
v-for="opt in statusOptions" v-for="opt in statusOptions"
:key="opt" :key="opt.value"
:label="opt" :label="opt.label"
:name="opt" :name="opt.value"
></u-radio> ></u-radio>
</u-radio-group> </u-radio-group>
</view> </view>
@ -78,7 +78,6 @@ import { detail } from '@/api/mz/contract';
<view class="section-title">其他说明</view> <view class="section-title">其他说明</view>
<u-textarea <u-textarea
v-model="facilitiesCheckDesc" v-model="facilitiesCheckDesc"
ref="textarea" ref="textarea"
placeholder="请输入内容(不超过500字)" placeholder="请输入内容(不超过500字)"
maxlength="500" maxlength="500"
@ -96,9 +95,9 @@ import { detail } from '@/api/mz/contract';
@delete="deletePic" @delete="deletePic"
multiple multiple
:maxCount="10" :maxCount="10"
accept="image,video"
uploadIconColor="#12c3c3" uploadIconColor="#12c3c3"
uploadText="点击上传" uploadText="点击上传"
:previewImage="true"
> >
</u-upload> </u-upload>
</view> </view>
@ -116,19 +115,52 @@ import { detail } from '@/api/mz/contract';
</template> </template>
<script> <script>
import { getRoomFacilities,submitCheckout } from "../../../pages/api"; import {
getRoomFacilities,
submitCheckout,
uploadImage,
tempSaveCheckOut,
} from "../../../pages/api";
export default { export default {
data() { data() {
return { return {
btnStyle: btnStyle:
"background:linear-gradient(90deg,#0DC6C6 0%,#13C2C2 100%);font-size:36rpx;border-radius:48rpx;width:60vw;height:80rpx;", "background:linear-gradient(90deg,#0DC6C6 0%,#13C2C2 100%);font-size:36rpx;border-radius:48rpx;width:60vw;height:80rpx;",
deviceList: [ ], deviceList: [],
statusOptions: ["完好", "破损", "丢失"], statusOptions: [
waterMeterValue: '', {
energyMeterValue: '', label: "完好",
value: "0",
},
{
label: "破损",
value: "1",
},
{
label: "丢失",
value: "2",
},
],
waterMeterValue: "",
energyMeterValue: "",
checkStatus: [
{
label: "完好",
value: "0",
},
{
label: "破损",
value: "1",
},
{
label: "丢失",
value: "2",
},
],
remark: "", remark: "",
fileList: [], fileList: [],
img1: [],
info: {}, info: {},
facilitiesCheckDesc: "", facilitiesCheckDesc: "",
}; };
@ -149,25 +181,80 @@ export default {
onDeviceChange(idx, val) { onDeviceChange(idx, val) {
this.deviceList[idx].status = val; this.deviceList[idx].status = val;
}, },
afterRead(event) { beforeRead(event) {
let files = Array.isArray(event.file) ? event.file : [event.file]; console.log("event", event);
this.fileList = this.fileList.concat(files); },
//
async afterRead(event) {
let lists = [].concat(event.file);
let fileListLen = this[`fileList${event.name}`].length;
lists.map((item) => {
this[`fileList${event.name}`].push({
...item,
status: "uploading",
message: "上传中",
});
});
for (let i = 0; i < lists.length; i++) {
const result = await uploadImage(lists[i].url);
let item = this[`fileList${event.name}`][fileListLen];
this[`fileList${event.name}`].splice(
fileListLen,
1,
Object.assign(item, {
status: "success",
message: "",
url: result.url,
})
);
fileListLen++;
}
var arry = [];
this.fileList.filter((v, i) => {
arry.push(v.url);
});
this.img1 = arry;
}, },
//
deletePic(event) { deletePic(event) {
this.fileList.splice(event.index, 1); this[`fileList${event.name}`].splice(event.index, 1);
var arry = [];
this.fileList.filter((v, i) => {
arry.push(v.url);
});
this.img1 = arry;
}, },
onSubmit() { //
let data = { handleTempSave(formData) {
checkOutRecId: this.info.checkOutRecId, tempSaveCheckOut(formData).then((res) => {
houseId: this.info.houseId, if (res.code === 200) {
roomId: this.info.roomId, uni.showToast({ title: res.msg, icon: "success" });
graduateId: this.info.graduateId, uni.navigateTo({
graduateName: this.info.graduateName, url: `/pagesA/checkout/list/list`,
startDate: this.info.startDate, });
checkOutDate: this.info.checkOutDate, } else {
waterMeterValue: this.waterMeterValue, uni.showToast({ title: res.msg, icon: "warning" });
} }
});
},
onSubmit() {
const facilitiesCheckResults = this.deviceList.map((item, index) => ({
facilityId: item.id,
checkResult: this.checkStatus[index],
}));
console.log(facilitiesCheckResults, "facilitiesCheckResults");
const params = {
idCard: this.info.idCard,
checkOutType: 0, //退
facilitiesCheckDesc: this.facilitiesCheckDesc,
facilitiesCheckImages: this.fileList,
facilitiesCheckResults: facilitiesCheckResults,
waterMeterValue: this.waterMeterValue || "",
energyMeterValue: this.energyMeterValue || "",
};
this.handleTempSave(params);
uni.showToast({ title: "提交成功", icon: "success" }); uni.showToast({ title: "提交成功", icon: "success" });
}, },
}, },

83
pagesA/checkout/list/list.vue

@ -6,10 +6,16 @@
:refreshing="refreshing" :refreshing="refreshing"
:finished="finished" :finished="finished"
:finished-text="'没有更多了'" :finished-text="'没有更多了'"
v-if="list && list.length > 0"
> >
<u-list-item v-for="item in list" :key="item.chooseRoomRecId"> <u-list-item v-for="item in list" :key="item.chooseRoomRecId">
<view class="checkout-card" @click="goDetail(item)"> <view class="checkout-card" @click="goDetail(item)">
<image :src="item.img" class="room-img" mode="aspectFill"></image> <image
v-if="item.houseTypeImages && item.houseTypeImages.length > 0"
:src="item.houseTypeImages[0].url || ''"
class="room-img"
mode="aspectFill"
></image>
<view class="room-info"> <view class="room-info">
<view class="room-title">{{ item.roomNamePath }}</view> <view class="room-title">{{ item.roomNamePath }}</view>
<view class="room-user"> <view class="room-user">
@ -18,12 +24,13 @@
<text class="phone">{{ item.telephone }}</text> <text class="phone">{{ item.telephone }}</text>
</view> </view>
<view class="room-date" <view class="room-date"
>{{ item.startDate }}{{ item.checkOutDate }}</view >{{ item.checkInDate }}{{ item.checkOutDate }}</view
> >
</view> </view>
</view> </view>
</u-list-item> </u-list-item>
</u-list> </u-list>
<view v-else class="no-data"> 暂无数据~ </view>
</view> </view>
</template> </template>
@ -33,49 +40,81 @@ export default {
data() { data() {
return { return {
list: [], list: [],
page: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
refreshing: false, refreshing: false,
finished: false, finished: false,
loading: false,
}; };
}, },
onLoad() { onLoad() {
this.getList(); this.getList();
}, },
methods: { methods: {
async getList() { async getList(isLoadMore = false) {
if (this.loading) return; //
this.loading = true;
try {
const res = await listCheckoutAlert({ const res = await listCheckoutAlert({
pageNum: 1, pageNum: this.pageNum,
pageSize: 10, pageSize: this.pageSize,
}); });
this.list = res.rows;
console.log(res, "res");
// if (res.code === 200) { console.log("列表数据:", res);
// this.list = this.page === 1 ? res.data : [...this.list, ...res.data];
// this.finished = res.data.length < this.pageSize; if (res.code === 200) {
// this.refreshing = false; const newList = res.rows || [];
// }
if (isLoadMore) {
//
this.list = [...this.list, ...newList];
} else {
//
this.list = newList;
}
//
this.finished = newList.length < this.pageSize;
// +1
if (newList.length > 0) {
this.pageNum++;
}
} else {
uni.showToast({ title: res.msg || "获取数据失败", icon: "none" });
}
} catch (error) {
console.error("获取列表失败:", error);
uni.showToast({ title: "网络异常", icon: "none" });
} finally {
this.loading = false;
this.refreshing = false; //
}
}, },
// //
onRefresh() { async onRefresh() {
this.page = 1; this.refreshing = true;
this.finished = false; this.pageNum = 1; //
this.getList(); this.finished = false; //
await this.getList(false); //
}, },
// //
loadMore() { async loadMore() {
if (this.finished) return; if (this.finished || this.loading) return; //
this.page++; await this.getList(true); //
this.getList();
}, },
goDetail(item) { goDetail(item) {
uni.setStorageSync("checkoutDetail", { uni.setStorageSync("checkoutDetail", {
idCard: item.idCard,
roomNamePath: item.roomNamePath, // roomNamePath: item.roomNamePath, //
graduateName: item.graduateName, // graduateName: item.graduateName, //
gender: item.gender, // gender: item.gender, //
telephone: item.telephone, // telephone: item.telephone, //
checkInDate: item.checkInDate,
checkOutDate: item.checkOutDate, // checkOutDate: item.checkOutDate, //
}); });
uni.navigateTo({ uni.navigateTo({

72
pagesA/force/index/index.vue

@ -57,8 +57,7 @@
<view class="desc-card"> <view class="desc-card">
<view class="label-des">说明</view> <view class="label-des">说明</view>
<u-textarea <u-textarea
v-model="value" v-model="descRemark"
:formatter="formatter"
ref="textarea" ref="textarea"
placeholder="请输入内容(不超过500字)" placeholder="请输入内容(不超过500字)"
maxlength="500" maxlength="500"
@ -73,9 +72,9 @@
@delete="deletePic" @delete="deletePic"
multiple multiple
:maxCount="10" :maxCount="10"
accept="image,video"
uploadIconColor="#12c3c3" uploadIconColor="#12c3c3"
uploadText="点击上传" uploadText="点击上传"
previewImage="true"
> >
</u-upload> </u-upload>
</view> </view>
@ -101,6 +100,7 @@
</template> </template>
<script> <script>
import { uploadImage } from "../../../pages/api";
export default { export default {
data() { data() {
return { return {
@ -116,7 +116,9 @@ export default {
imageUrl: "", imageUrl: "",
pickerValue: "", pickerValue: "",
}, },
descRemark: "",
fileList: [], fileList: [],
img1: [],
showDate: false, showDate: false,
minDate: "2000-01-01", minDate: "2000-01-01",
maxDate: "2100-12-31", maxDate: "2100-12-31",
@ -125,20 +127,58 @@ export default {
}; };
}, },
methods: { methods: {
afterRead(event) { //
// beforeRead(event) {
const file = event.file; //
this.fileList = [file]; const { file } = event;
this.form.imageUrl = file.url || file.path; if (file.size > 10 * 1024 * 1024) {
// 10MB
uni.showToast({ title: "文件过大", icon: "none" });
return false;
}
return true;
}, },
onDateConfirm(e) {
// e.value YYYY-MM-DD //
const date = new Date(e.value); async afterRead(event) {
const y = date.getFullYear(); let lists = [].concat(event.file);
const m = (date.getMonth() + 1).toString().padStart(2, "0"); let fileListLen = this[`fileList${event.name}`].length;
const d = date.getDate().toString().padStart(2, "0"); lists.map((item) => {
this.form.leaveDate = `${y}-${m}-${d}`; this[`fileList${event.name}`].push({
this.showDate = false; ...item,
status: "uploading",
message: "上传中",
});
});
for (let i = 0; i < lists.length; i++) {
const result = await uploadImage(lists[i].url);
let item = this[`fileList${event.name}`][fileListLen];
this[`fileList${event.name}`].splice(
fileListLen,
1,
Object.assign(item, {
status: "success",
message: "",
url: result.url,
})
);
fileListLen++;
}
var arry = [];
this.fileList.filter((v, i) => {
arry.push(v.url);
});
this.img1 = arry;
},
//
deletePic(event) {
this[`fileList${event.name}`].splice(event.index, 1);
var arry = [];
this.fileList.filter((v, i) => {
arry.push(v.url);
});
this.img1 = arry;
}, },
submit() { submit() {
this.$refs.uForm.validate((valid) => { this.$refs.uForm.validate((valid) => {

37
utils/request.js

@ -37,3 +37,40 @@ export default function request(options = {}) {
}); });
}); });
} }
export function uploadFile(filePath, options = {}) {
const token = uni.getStorageSync("token") || "";
console.log(filePath,'filePath');
return new Promise((resolve, reject) => {
uni.uploadFile({
url: baseUrl + "/common/upload",
filePath: filePath,
name: "file", // 后端接收的参数名
header: {
Authorization: token ? `Bearer ${token}` : "",
...options.header,
},
formData: options.formData || {}, // 额外的表单数据
success: (res) => {
console.log('res::',res)
try {
const data = JSON.parse(res.data);
if (res.statusCode === 200) {
console.log('data::',data)
resolve(data);
} else {
uni.showToast({ title: data.msg || "上传失败", icon: "none" });
reject(data);
}
} catch (e) {
uni.showToast({ title: "上传失败", icon: "none" });
reject(e);
}
},
fail: (err) => {
uni.showToast({ title: "网络异常", icon: "none" });
reject(err);
},
});
});
}
Loading…
Cancel
Save