提交图片修改

This commit is contained in:
liyuanchao 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),
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),

View File

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

View File

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

View File

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

View File

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