提交图片修改

This commit is contained in:
2025-08-23 13:51:56 +08:00
parent 5a0a86fe4a
commit 9a60d90592
5 changed files with 364 additions and 340 deletions

View File

@@ -59,7 +59,7 @@ const install = (Vue, vm) => {
warnsProcess:(params = {})=>vm.$u.post(config.adminPath+'/sis/alarmEvents/complete',params), warnsProcess:(params = {})=>vm.$u.post(config.adminPath+'/sis/alarmEvents/complete',params),
getWarnDetail:(params = {}, id) => vm.$u.get(config.adminPath+`/sis/alarmEvents/${id}`,params), getWarnDetail:(params = {}, id) => vm.$u.get(config.adminPath+`/sis/alarmEvents/${id}`,params),
getWarnEventInfo:(params = {}, alarmId) => vm.$u.get(config.adminPath+`/sis/alarmEventAttachments/query/${alarmId}`,params), getWarnEventInfo:(params = {}, alarmId) => vm.$u.get(config.adminPath+`/sis/alarmEventProcess/query/result/${alarmId}`,params),
//巡检任务列表 //巡检任务列表
getInspection:(params = {})=>vm.$u.get(config.adminPath+'/property/item/list',params), getInspection:(params = {})=>vm.$u.get(config.adminPath+'/property/item/list',params),

View File

@@ -1,337 +1,345 @@
<template> <template>
<view class="add-repair-container"> <view class="add-repair-container">
<!-- 可滚动内容区 --> <!-- 可滚动内容区 -->
<view class="add-repair-scroll-content"> <view class="add-repair-scroll-content">
<!-- 地址选择 --> <!-- 地址选择 -->
<!-- <view class="add-repair-section"> <!-- <view class="add-repair-section">
<view class="add-repair-detail"> <view class="add-repair-detail">
<view class="add-repair-detail1">详细地址 </view> <view class="add-repair-detail1">详细地址 </view>
<input type="text" v-model="repairInfo.location" placeholder="请输入地址" class="add-repair-detail2" /> <input type="text" v-model="repairInfo.location" placeholder="请输入地址" class="add-repair-detail2" />
</view> </view>
</view> --> </view> -->
<!-- 报事报修类型 --> <!-- 报事报修类型 -->
<view class="add-repair-section"> <view class="add-repair-section">
<view class="add-repair-label">详细地址</view> <view class="add-repair-label">详细地址</view>
<input type="text" v-model="repairInfo.location" placeholder="请输入地址" class="add-repair-detail2" /> <input type="text" v-model="repairInfo.location" placeholder="请输入地址" class="add-repair-detail2" />
<view class="add-repair-label">报事报修</view> <view class="add-repair-label">报事报修</view>
<view class="repair-type" @click="chooseType"> <view class="repair-type" @click="chooseType">
<text class="text-type">{{ selectedType }}</text> <text class="text-type">{{ selectedType }}</text>
<image class="right-arrow" src="/static/ic_right_arrow_g.png" /> <image class="right-arrow" src="/static/ic_right_arrow_g.png" />
</view> </view>
<view class="add-repair-label">问题详情 <text class="add-repair-optional">(非必填)</text></view> <view class="add-repair-label">问题详情 <text class="add-repair-optional">(非必填)</text></view>
<textarea v-model="repairInfo.remark" class="add-repair-detail-textarea" placeholder="如果以上报事不能解决您的问题,可以在这里填写说明" /> <textarea v-model="repairInfo.remark" class="add-repair-detail-textarea"
placeholder="如果以上报事不能解决您的问题,可以在这里填写说明" />
</view>
</view>
<!-- 上传照片 -->
<view class="add-repair-section"> <!-- 上传照片 -->
<view class="add-repair-label">上传照片 <text class="add-repair-optional">(非必填最多三张)</text></view> <view class="add-repair-section">
<u-upload <view class="add-repair-label">上传照片 <text class="add-repair-optional">(非必填最多三张)</text></view>
:fileList="selectedImages" <u-upload :fileList="selectedImages" @on-list-change="onListChange" @delete="deletePic" name="upload"
@on-list-change="onListChange" multiple maxCount="3" width="180" height="180" :autoUpload="false"></u-upload>
@delete="deletePic" </view>
name="upload"
multiple <!-- 提交按钮 -->
maxCount="3" <button class="add-repair-submit-btn" @click="submit">提交</button>
width="180" </view>
height="180" </view>
:autoUpload="false" </template>
></u-upload>
</view> <script>
// 导入MediaSelector和MediaType
<!-- 提交按钮 --> import MediaSelector, {
<button class="add-repair-submit-btn" @click="submit">提交</button> MediaType
</view> } from '@/utils/mediaSelector';
</view> import {
</template> uploadFiles
} from '@/common/upload.js';
<script> import toast from '../../../../uview-ui/libs/function/toast';
// 导入MediaSelector和MediaType export default {
import MediaSelector, { MediaType } from '@/utils/mediaSelector'; data() {
import { return {
uploadFiles repairInfo: {
} from '@/common/upload.js'; location: '',
import toast from '../../../../uview-ui/libs/function/toast'; type: '1942879389453230082',
export default { orderImgUrl: '',
data() { remark: ''
return { },
repairInfo:{ repairTypes: [],
location:'', selectedType: '',
type:'1942879389453230082', selectedImages: [] // 存储已选图片
orderImgUrl:'', }
remark:'' },
}, onLoad() {
repairTypes: [], this.getOrderType()
selectedType: '', },
selectedImages: [] // 存储已选图片 methods: {
} selectType(item) {
}, this.selectedType = item;
onLoad() { },
this.getOrderType() async getOrderType() {
}, let params = {
methods: { parentId: '1952989217332658178'
selectType(item) { }
this.selectedType = item; let res = await this.$u.api.getRepairTypes(params);
}, if (res.code == '200') {
async getOrderType() { this.repairTypes = res.data
let params = {parentId:'1952989217332658178'} this.repairInfo.type = res.data[0].id;
let res = await this.$u.api.getRepairTypes(params); this.selectType(res.data[0].orderTypeName)
if (res.code == '200') { }
this.repairTypes = res.data },
this.repairInfo.type = res.data[0].id; // 删除图片
this.selectType(res.data[0].orderTypeName) deletePic(event) {
} this.selectedImages.splice(event.index, 1);
}, },
// 删除图片
deletePic(event) { // 图片列表变化处理
this.selectedImages.splice(event.index, 1); onListChange(list) {
}, this.selectedImages = list;
},
// 图片列表变化处理
onListChange(list) { async submit() {
this.selectedImages = list; if (!this.repairInfo.location) {
}, toast('请先填写地址')
return
async submit() { }
if(!this.repairInfo.location) {
toast('请先填写地址') if (this.selectedImages.length <= 0) {
return this.realSubmit()
} return
}
if(this.selectedImages.length<=0){ console.log("t1", this.selectedImages)
this.realSubmit() const images = this.selectedImages
return .map(item => item?.path?.replace('file://', '') || item?.url || null)
} .filter(path => path !== null);
console.log("t1",this.selectedImages) if (images.length === 0) {
const images = this.selectedImages this.realSubmit();
.map(item => item?.path?.replace('file://', '') || item?.url || null) return;
.filter(path => path !== null); }
if (images.length === 0) {
this.realSubmit(); const result = await uploadFiles({
return; files: images,
} url: this.vuex_config.baseUrl + '/resource/oss/upload',
name: 'file',
const result = await uploadFiles({ vm: this // 关键:用于注入 token 等
files: images, });
url: this.vuex_config.baseUrl + '/resource/oss/upload', const allSuccess = result.every(item => item.code == 200);
name: 'file', if (!allSuccess) {
vm: this // 关键:用于注入 token 等 uni.showToast({
}); title: '上传失败',
icon: 'none'
});
// 遍历result获取data.url加上,分割 return;
const urls = result.map(item => item.data?.url || '').filter(url => url !== ''); }
this.repairInfo.orderImgUrl = urls.join(',');
this.realSubmit() // 遍历result获取data.url加上,分割
const urls = result.map(item => item.data?.ossId || '').filter(ossId => ossId !== '');
}, this.repairInfo.orderImgUrl = urls.join(',');
this.realSubmit()
async realSubmit(){
let res = await this.$u.api.addOrder2(this.repairInfo); },
if (res.code == '200') {
// 关闭页面前发送事件通知前页面刷新 async realSubmit() {
uni.$emit('refreshData', ''); let res = await this.$u.api.addOrder2(this.repairInfo);
// 返回上一页 if (res.code == '200') {
uni.navigateBack(); // 关闭页面前发送事件通知前页面刷新
} uni.$emit('refreshData', '');
}, // 返回上一页
uni.navigateBack();
// 添加chooseType方法实现 }
chooseType() { },
uni.showActionSheet({
itemList: this.repairTypes.map(item => item.orderTypeName), // 添加chooseType方法实现
success: (res) => { chooseType() {
this.selectedType = this.repairTypes[res.tapIndex].orderTypeName; uni.showActionSheet({
this.repairInfo.type = this.repairTypes[res.tapIndex].id; itemList: this.repairTypes.map(item => item.orderTypeName),
}, success: (res) => {
fail: (err) => { this.selectedType = this.repairTypes[res.tapIndex].orderTypeName;
console.log('用户取消选择或出错', err); this.repairInfo.type = this.repairTypes[res.tapIndex].id;
} },
}); fail: (err) => {
}, console.log('用户取消选择或出错', err);
goRepaired(){ }
uni.navigateTo({ url: '/pages/sys/user/myRepair/repaired' }); });
}, },
goSelectLocation(){ goRepaired() {
uni.navigateTo({ url: '/pages/sys/user/myRepair/selectLocation' }); uni.navigateTo({
} url: '/pages/sys/user/myRepair/repaired'
});
} },
} goSelectLocation() {
</script> uni.navigateTo({
url: '/pages/sys/user/myRepair/selectLocation'
<style scoped> });
.add-repair-container { }
height: 100vh;
background: #f7f7f7; }
display: flex; }
flex-direction: column; </script>
}
<style scoped>
.add-repair-container {
.add-repair-scroll-content { height: 100vh;
flex: 1; background: #f7f7f7;
overflow-y: auto; display: flex;
padding-bottom: 40rpx; flex-direction: column;
} }
.add-repair-section {
background: #fff; .add-repair-scroll-content {
border-radius: 12rpx; flex: 1;
margin: 22rpx 30rpx 0 30rpx; overflow-y: auto;
padding: 24rpx 46rpx 24rpx 44rpx; padding-bottom: 40rpx;
} }
.repair-type { .add-repair-section {
width: 100%; background: #fff;
height: 98rpx; border-radius: 12rpx;
background: #F7F8FA; margin: 22rpx 30rpx 0 30rpx;
border-radius: 10rpx; padding: 24rpx 46rpx 24rpx 44rpx;
padding: 0 20rpx; }
display: flex;
align-items: center; .repair-type {
justify-content: space-between; width: 100%;
margin-bottom: 40rpx; height: 98rpx;
box-sizing: border-box; background: #F7F8FA;
} border-radius: 10rpx;
padding: 0 20rpx;
.text-type{ display: flex;
font-size: 24rpx; align-items: center;
color:#808080; justify-content: space-between;
} margin-bottom: 40rpx;
.right-arrow{ box-sizing: border-box;
width: 11rpx; }
height: 21rpx;
} .text-type {
font-size: 24rpx;
.add-repair-address-btn { color: #808080;
width: 100%; }
height: 48rpx;
background: #fff; .right-arrow {
border: 2rpx solid #2186FF; width: 11rpx;
border-radius: 8rpx; height: 21rpx;
margin-bottom: 30rpx; }
padding-left: 18rpx;
display: flex; .add-repair-address-btn {
align-items: center; width: 100%;
justify-content: center; height: 48rpx;
} background: #fff;
border: 2rpx solid #2186FF;
.add-repair-address-text { border-radius: 8rpx;
font-size: 24rpx; margin-bottom: 30rpx;
color: #007CFF; padding-left: 18rpx;
margin-right: 15rpx; display: flex;
} align-items: center;
justify-content: center;
.add-repair-address-img { }
width: 11rpx;
height: 21rpx; .add-repair-address-text {
} font-size: 24rpx;
color: #007CFF;
.add-repair-detail { margin-right: 15rpx;
display: flex; }
flex-direction: row;
align-items: center; .add-repair-address-img {
} width: 11rpx;
height: 21rpx;
.add-repair-detail1 { }
font-size: 26rpx;
font-weight: bold; .add-repair-detail {
color: #000; display: flex;
} flex-direction: row;
align-items: center;
.add-repair-detail2 { }
width: 100%;
height: 98rpx; .add-repair-detail1 {
background-color: #F7F8FA; font-size: 26rpx;
border-radius: 10rpx; font-weight: bold;
font-size: 24rpx; color: #000;
color: #676767; }
padding: 0 20rpx;
margin-bottom: 40rpx; .add-repair-detail2 {
box-sizing: border-box; width: 100%;
} height: 98rpx;
.add-repair-label { background-color: #F7F8FA;
font-size: 32rpx; border-radius: 10rpx;
color: #000000; font-size: 24rpx;
font-weight: 500; color: #676767;
margin-bottom: 41rpx; padding: 0 20rpx;
} margin-bottom: 40rpx;
box-sizing: border-box;
.add-repair-label2 { }
font-size: 32rpx;
color: #000000; .add-repair-label {
font-weight: 500; font-size: 32rpx;
margin-bottom: 25rpx; color: #000000;
margin-top: 25rpx; font-weight: 500;
} margin-bottom: 41rpx;
}
.add-repair-type-list { .add-repair-label2 {
display: flex; font-size: 32rpx;
flex-wrap: wrap; color: #000000;
gap: 28rpx 21rpx; font-weight: 500;
} margin-bottom: 25rpx;
margin-top: 25rpx;
.add-repair-type-btn { }
flex: 0 0 calc((100% - 42rpx) / 3);
box-sizing: border-box;
height: 73rpx; .add-repair-type-list {
background: #F2F7FF; display: flex;
color: #2186FF; flex-wrap: wrap;
font-size: 26rpx; gap: 28rpx 21rpx;
border-radius: 8rpx; }
display: flex;
align-items: center; .add-repair-type-btn {
justify-content: center; flex: 0 0 calc((100% - 42rpx) / 3);
border: none; box-sizing: border-box;
} height: 73rpx;
background: #F2F7FF;
.add-repair-type-btn.selected { color: #2186FF;
background: #2186FF; font-size: 26rpx;
color: #fff; border-radius: 8rpx;
border: 2rpx solid #2186FF; display: flex;
} align-items: center;
justify-content: center;
.add-repair-type-btn.dashed { border: none;
border: 2rpx dashed #BDBDBD; }
background: #fff;
color: #2186FF; .add-repair-type-btn.selected {
} background: #2186FF;
color: #fff;
.add-repair-optional { border: 2rpx solid #2186FF;
color: #888; }
font-size: 24rpx;
font-weight: 400; .add-repair-type-btn.dashed {
} border: 2rpx dashed #BDBDBD;
background: #fff;
.add-repair-detail-textarea { color: #2186FF;
width: 100%; }
min-height: 120rpx;
background: #F7F8FA; .add-repair-optional {
border-radius: 10rpx; color: #888;
font-size: 28rpx; font-size: 24rpx;
color: #888; font-weight: 400;
padding: 18rpx; }
margin-top: 18rpx;
box-sizing: border-box; .add-repair-detail-textarea {
} width: 100%;
min-height: 120rpx;
.add-repair-submit-btn { background: #F7F8FA;
width: 60vw; border-radius: 10rpx;
height: 73rpx; font-size: 28rpx;
background: linear-gradient(90deg, #005DE9 0%, #4B9BFF 100%); color: #888;
color: #fff; padding: 18rpx;
font-size: 32rpx; margin-top: 18rpx;
border: none; box-sizing: border-box;
border-radius: 40rpx; }
margin: 100rpx auto 0 auto;
display: block; .add-repair-submit-btn {
font-weight: bold; width: 60vw;
box-shadow: 0 8rpx 24rpx rgba(0, 0, 0, 0.18); height: 73rpx;
} background: linear-gradient(90deg, #005DE9 0%, #4B9BFF 100%);
color: #fff;
font-size: 32rpx;
border: none;
border-radius: 40rpx;
margin: 100rpx auto 0 auto;
display: block;
font-weight: bold;
box-shadow: 0 8rpx 24rpx rgba(0, 0, 0, 0.18);
}
</style> </style>

View File

@@ -73,6 +73,12 @@
}, },
created() { created() {
this.onRefresh() this.onRefresh()
},
onShow() {
uni.$once('refreshData', () => {
this.tabLoaded = [false, false]
this.onRefresh()
});
}, },
methods: { methods: {
goBack() { goBack() {

View File

@@ -142,7 +142,8 @@ export default {
async loadEevetInfo() { async loadEevetInfo() {
let res = await this.$u.api.getWarnEventInfo({}, this.warnInfo.id); let res = await this.$u.api.getWarnEventInfo({}, this.warnInfo.id);
if (res.code == "200") { if (res.code == "200") {
this.realImages = res.data this.handleDesc = res.data.workReply
this.realImages = res.data.attachments
} }
this.loading = false; this.loading = false;
}, },
@@ -182,8 +183,16 @@ export default {
name: 'file', name: 'file',
vm: this vm: this
}); });
const allSuccess = result.every(item => item.code == 200);
this.realImages = result.map(item => item.data?.url || '').filter(url => url !== ''); if (!allSuccess) {
uni.showToast({
title: '上传失败',
icon: 'none'
});
return;
}
this.realImages = result.map(item => item.data?.ossId || '').filter(ossId => ossId !== '');
this.realSubmit(); this.realSubmit();
}, },

View File

@@ -142,6 +142,7 @@ export default {
}, },
onShow() { onShow() {
uni.$once('refreshData', () => { uni.$once('refreshData', () => {
this.tabLoaded = [false, false]
this.onRefresh() this.onRefresh()
}); });
}, },