feat: 上传异常

This commit is contained in:
yangzhe 2025-04-14 15:10:19 +08:00
parent b306ba4cdb
commit fcd8459c2f
5 changed files with 157 additions and 57 deletions

View File

@ -17,7 +17,7 @@
<view class="label">保洁人员</view> <view class="label">保洁人员</view>
</view> </view>
<view class="block"> <view class="block">
<view class="value">{{ dataInfo.cleanTime }}</view> <view class="value">{{ dataInfo.completedTime }}</view>
<view class="label">清扫时间</view> <view class="label">清扫时间</view>
</view> </view>
<view class="block"> <view class="block">
@ -31,9 +31,9 @@
class="image" class="image"
v-for="(v, i) in dataInfo.pictures" v-for="(v, i) in dataInfo.pictures"
:key="i" :key="i"
mode="scaleToFill" mode="aspectFill"
style="width: 180rpx; height: 180rpx; border-radius: 18rpx"
:src="BASE_URL + '/uploads/' + v.path" :src="BASE_URL + '/uploads/' + v.path"
@click="previewImage(i)"
></image> ></image>
</view> </view>
</view> </view>
@ -43,6 +43,7 @@
<script> <script>
import BASE_URL from "@/api/env.js"; // import BASE_URL from "@/api/env.js"; //
import { GetPlanInfoAre } from "@/api/apiList"; import { GetPlanInfoAre } from "@/api/apiList";
import { dateFormat } from "@/utils/utils.js";
export default { export default {
data() { data() {
return { return {
@ -66,6 +67,16 @@ export default {
}, },
methods: { methods: {
dateFormat,
//
previewImage(index) {
uni.previewImage({
urls: this.dataInfo.pictures.map((v) => BASE_URL + "/uploads/" + v.path),
current: index,
});
},
async getAreaInfo() { async getAreaInfo() {
const res = await GetPlanInfoAre({ const res = await GetPlanInfoAre({
id: this.params.id, id: this.params.id,
@ -73,6 +84,10 @@ export default {
if (res.succeed) { if (res.succeed) {
this.dataInfo = res.data; this.dataInfo = res.data;
this.dataInfo.completedTime = dateFormat(
new Date(this.dataInfo.completedTime),
"YYYY/MM/DD HH:mm:ss"
);
} }
}, },
}, },
@ -127,6 +142,7 @@ export default {
flex-direction: column; flex-direction: column;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
gap: 10rpx;
width: 48.5%; width: 48.5%;
height: 160rpx; height: 160rpx;
background: #f1f7fe; background: #f1f7fe;
@ -135,12 +151,32 @@ export default {
.block:nth-child(n + 3) { .block:nth-child(n + 3) {
margin-top: 14rpx; margin-top: 14rpx;
} }
.label {
color: #5a6c88;
}
} }
.images { .images {
margin-top: 46rpx; display: flex;
display: grid; flex-wrap: wrap; /* 允许换行 */
grid-template-columns: repeat(auto-fill, 212rpx); justify-content: flex-start; /* 从左开始排列 */
gap: 20rpx; // margin-top: 32rpx;
}
.image {
/* 设置宽度,留出间隙 */
width: calc((100% - 40rpx) / 3); /* 假设间隙为 20rpx */
height: 210rpx; /* 或根据需要调整高度 */
border-radius: 18rpx;
background-color: #eee;
overflow: hidden;
margin-right: 20rpx; /* 右边间隙 */
margin-bottom: 20rpx; /* 下边间隙 */
}
/* 清除每行最后一个元素的右边距 */
.image:nth-child(3n) {
margin-right: 0;
} }
} }
} }

View File

@ -41,7 +41,12 @@
</view> </view>
</view> </view>
<view class="arealist" v-if="dataInfo.areas.length > 0"> <view class="arealist" v-if="dataInfo.areas.length > 0">
<view class="block-info" v-for="item in dataInfo.areas" :key="item.id" @click="toItemPage(item)"> <view
class="block-info"
v-for="item in dataInfo.areas"
:key="item.id"
@click="toItemPage(item)"
>
<view v-if="!item.isCompleted" class="schedule schedule-wait" <view v-if="!item.isCompleted" class="schedule schedule-wait"
>待保洁</view >待保洁</view
> >
@ -210,7 +215,7 @@ export default {
const params = { const params = {
planName: this.dataInfo.planName, planName: this.dataInfo.planName,
areaId: this.dataInfo.areas[this.dataInfo.areas.length - 1].id, id: this.dataInfo.areas[this.dataInfo.areas.length - 1].id,
aeraNmae: this.dataInfo.areas[this.dataInfo.areas.length - 1].aeraNmae, aeraNmae: this.dataInfo.areas[this.dataInfo.areas.length - 1].aeraNmae,
}; };
console.log(params); console.log(params);
@ -235,10 +240,27 @@ export default {
}, },
toItemPage(item) { toItemPage(item) {
console.log("%c%s", "color:red", "跳转至详情页"); console.log("%c%s", "color:red", "跳转至详情页", item);
uni.navigateTo({
url: "/pages/index/cleanDetails?params=" + encodeURIComponent(JSON.stringify(item)), const combinedData = {
}); ...item, // item
planName: this.dataInfo.planName, // planName
};
const params = encodeURIComponent(JSON.stringify(combinedData));
if (item.isCompleted) {
//
uni.navigateTo({
url: "/pages/index/cleanDetails?params=" + params,
});
return;
} else {
//
uni.navigateTo({
url: "/pages/index/list?params=" + params,
});
}
}, },
openFn() {}, openFn() {},
@ -281,6 +303,9 @@ export default {
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
page {
background-color: #f3f5fa !important;
}
.content { .content {
// height: 100vh; // height: 100vh;
background: #f7f8fc; background: #f7f8fc;

View File

@ -128,7 +128,7 @@ export default {
}, },
mounted() { mounted() {
console.log('%c%s', 'color:red', 'mounted--') console.log("%c%s", "color:red", "mounted--");
this.getPlanByDate(); this.getPlanByDate();
}, },

View File

@ -5,7 +5,7 @@
<u-cell-item <u-cell-item
:arrow="false" :arrow="false"
title="保洁人员" title="保洁人员"
:value="baseInfo.cleaner" :value="dataInfo.userName"
:title-style="{ :title-style="{
color: '#303133', color: '#303133',
fontSize: '32rpx', fontSize: '32rpx',
@ -18,7 +18,7 @@
<u-cell-item <u-cell-item
:arrow="false" :arrow="false"
title="上报时间" title="上报时间"
:value="baseInfo.reportTime" :value="reportingTime"
:title-style="{ :title-style="{
color: '#303133', color: '#303133',
fontSize: '32rpx', fontSize: '32rpx',
@ -38,11 +38,11 @@
:model="form" :model="form"
:rules="rules" :rules="rules"
ref="uForm" ref="uForm"
label-width="200" label-width="400rpx"
:label-style="{ fontSize: '32rpx' }" :label-style="{ fontSize: '32rpx' }"
> >
<!-- 区域选择多选 --> <!-- 区域选择多选 -->
<u-form-item :label="baseInfo.area" prop="areas"> <u-form-item :label="dataInfo.name" prop="areas">
<!-- <u-input v-model="form.cleaner" placeholder="请输入故障" /> --> <!-- <u-input v-model="form.cleaner" placeholder="请输入故障" /> -->
<view style="width: 100%; font-size: 32rpx; text-align: right" <view style="width: 100%; font-size: 32rpx; text-align: right"
>NFC卡损坏</view >NFC卡损坏</view
@ -50,9 +50,9 @@
</u-form-item> </u-form-item>
<!-- 备注文本域 --> <!-- 备注文本域 -->
<u-form-item label="备注" prop="notes" label-position="top"> <u-form-item label="备注" prop="note" label-position="top">
<u-input <u-input
v-model="form.notes" v-model="form.note"
placeholder="请对故障进行描述" placeholder="请对故障进行描述"
autoHeight autoHeight
maxlength="200" maxlength="200"
@ -103,18 +103,16 @@
</template> </template>
<script> <script>
import { ReportingNFCDanger } from "@/api/apiList"; import { ReportingNFCDanger, GetPlanInfoAre, UploadFiles } from "@/api/apiList";
import { dateFormat } from "@/utils/utils";
export default { export default {
data() { data() {
return { return {
baseInfo: { reportingTime: "", // 2025-4-14 10:00
cleaner: "小饼", //
reportTime: "2025.4.1", //
area: "东大门操场", //
},
form: { form: {
notes: "", // note: "", //
url: "", // url: "", //
}, },
areaOptions: [ areaOptions: [
@ -130,7 +128,7 @@ export default {
trigger: ["blur", "change"], trigger: ["blur", "change"],
}, },
], ],
reportTime: [ reportingTime: [
{ {
required: true, required: true,
message: "请选择上报时间", message: "请选择上报时间",
@ -155,17 +153,32 @@ export default {
}, },
], ],
}, },
params: {},
dataInfo: {},
}; };
}, },
onLoad(options) {
console.log("options", JSON.parse(decodeURIComponent(options.params)));
this.params = JSON.parse(decodeURIComponent(options.params));
},
created() {
this.reportingTime = dateFormat(new Date(), "YYYY-MM-DD HH:mm");
this.getAreaInfo();
},
methods: { methods: {
// //
handleImageUpload(event) { handleImageUpload(event) {
const files = event.file; const files = event.file;
// //
this.form.images.push(...files.map((file) => ({ url: file.url }))); this.form.images.push(...files.map((file) => ({ url: file.url })));
}, },
// //
handleImageDelete(index) { handleImageDelete(index) {
this.form.images.splice(index, 1); this.form.images.splice(index, 1);
}, },
@ -193,6 +206,17 @@ export default {
this.form.url = ""; this.form.url = "";
}, },
//
async getAreaInfo() {
const res = await GetPlanInfoAre({
id: this.params.id,
});
if (res.succeed) {
this.dataInfo = res.data;
}
},
// //
async submitForm() { async submitForm() {
if (!this.form.url) { if (!this.form.url) {
@ -200,25 +224,35 @@ export default {
return; return;
} }
console.log(this.form); const res = await UploadFiles([this.form.url]);
if (!res.succeed) return;
return; const params = {
note: this.form.note,
planInfoId: this.dataInfo.planInfoId,
reportingTime: this.reportingTime.replace(" ", "T"),
userId: this.dataInfo.userId,
id: this.dataInfo.id,
url: res.data[0].path,
};
const res = await ReportingNFCDanger({ const res1 = await ReportingNFCDanger(params);
...this.form,
// if (res1.succeed) {
id: "3fa85f64-5717-4562-b3fc-2c963f66afa6", const queryParams = encodeURIComponent(JSON.stringify(this.params));
userId: "3fa85f64-5717-4562-b3fc-2c963f66afa6", uni.showModal({
reportingTime: "2025-04-10T08:02:40.917Z", title: "提示",
note: "string", content: "任务已完成,快去上传图片吧",
url: "string", confirmText: "去上传图片",
planInfoId: "3fa85f64-5717-4562-b3fc-2c963f66afa6", showCancel: false,
}); success: function (res) {
if (res.confirm) {
if (res.succeed) { uni.navigateTo({
console.log(res); url: "/pages/index/uploadPhoto?params=" + queryParams,
uni.showToast({ title: "上报成功", icon: "success" }); });
}
},
});
} }
}, },
}, },
@ -227,7 +261,7 @@ export default {
<style lang="scss" scoped> <style lang="scss" scoped>
page { page {
background-color: #f3f5fa; background-color: #f3f5fa !important;
} }
.content { .content {
height: auto; height: auto;

View File

@ -22,7 +22,7 @@
:background="{ backgroundColor: '#F7F8FC' }" :background="{ backgroundColor: '#F7F8FC' }"
:border-bottom="false" :border-bottom="false"
> >
<view slot="right"> <!-- <view slot="right">
<view class="menu-wrapper"> <view class="menu-wrapper">
<image <image
src="/static/iconfont/more.svg" src="/static/iconfont/more.svg"
@ -31,7 +31,7 @@
@click="toggleMenu" @click="toggleMenu"
/> />
</view> </view>
</view> </view> -->
</u-navbar> </u-navbar>
<view class="content-header"> <view class="content-header">
@ -181,23 +181,28 @@ export default {
} }
const params = { const params = {
id: this.params.areaId, id: this.params.id,
note: this.remark, note: this.remark,
picturesDto: [], picturesDto: [],
}; };
const res = await UploadFiles(this.imageList); const res = await UploadFiles(this.imageList);
if (res.succeed) { if (!res.succeed) return;
params.picturesDto = res.data; params.picturesDto = res.data;
}
const res2 = await UploadArea(params); const res2 = await UploadArea(params);
if (res2.succeed) { if (res2.succeed) {
// //
uni.showToast({ title: "上传成功", icon: "success" }); uni.showToast({ title: "上传成功", icon: "success", duration: 1500 });
} else { setTimeout(() => {
uni.showToast({ title: res2.error || "上传失败", icon: "none" }); uni.switchTab({
url: "/pages/index/index",
});
}, 1500);
} }
// else {
// uni.showToast({ title: res2.error || "", icon: "none" });
// }
}, },
}, },
}; };