接车时应有拍照上传功能

This commit is contained in:
PQZ 2024-11-04 14:32:41 +08:00
parent 641d0b3780
commit 38373ee3de
2 changed files with 69 additions and 9 deletions

View File

@ -162,9 +162,18 @@
<project-picker ref="proj" @confirm="projConfirm"></project-picker>
</view>
<!-- 普通弹窗---拍照上传 -->
<uni-popup ref="popup" background-color="#fff">
<view class="popup-content">
<view class="dl-avatar-box">
<uni-file-picker :value="fileList" :sizeType="sizeType" @select="afterRead" @delete="deleteFile" limit="9" title="请上传车辆照片最多选择9张图片"></uni-file-picker>
</view>
<button type="primary" @click="submit">保存</button>
</view>
</uni-popup>
<view class="footer">
<view class="btn" @click="submit">创建工单</view>
<view class="btn" @click="submitUpload">创建工单</view>
</view>
</view>
</view>
@ -178,6 +187,7 @@ import request from "@/utils/request";
import {getToken, setUserInfo, getUserInfo} from '@/utils/auth.js'
import config from "@/config";
import {formatTimestamp, formatTimestampCustom} from "@/utils/utils";
import upload from "@/utils/upload";
export default {
components: {
@ -186,6 +196,9 @@ export default {
},
data() {
return {
//
fileList: [],
sizeType:['compressed'],
phone: '',
carList: [],
activeCarIndex: 0,
@ -226,13 +239,41 @@ export default {
}
},
methods: {
afterRead(file) {
for (let i = 0; i < file.tempFilePaths.length; i++) {
upload({
url:'/admin-api/infra/file/upload',
filePath: file.tempFilePaths[i]
}).then((res)=>{
this.fileList.push({
url: config.baseImageUrl+res.data
})
console.log(this.fileList)
})
}
},
deleteFile(file, index) {
this.fileList.splice(index, 1);
},
saveWorkingItem(){
console.log(this.fileList,145)
},
createUniqueCodeByHead(head = '') {
const min = 100; //
const max = 999; //
return head.toString() + Date.now().toString() + Math.floor(Math.random() * (max - min + 1)) + min;
},
//
submit() {
/**
* 创建工单前上传图片
*/
submitUpload(){
if (this.userInfo === null || this.carList.length === 0 || this.selectedProj.length === 0) {
uni.showToast({
title: '请完善信息',
@ -240,6 +281,12 @@ export default {
})
return
}
this.$refs.popup.open("bottom");
},
//
submit() {
let fileStr = this.fileList.map(item=>item.url.replace(config.baseImageUrl,"")).join(",")
const data = {
userId: this.userInfo.id,
ticketNo: this.ticketNo,
@ -254,7 +301,8 @@ export default {
adviserId: getUserInfo().id,
adviserName: getUserInfo().nickname,
ticketType: this.ticketType,
itemList: this.formatItem(this.selectedProj)
itemList: this.formatItem(this.selectedProj),
fileStr:fileStr
}
uni.navigateTo({
// url: '/pages-repair/signature/signature?data=' + JSON.stringify(data)
@ -428,6 +476,14 @@ export default {
</script>
<style lang="less" scoped>
.popup-content {
@include flex;
align-items: center;
justify-content: center;
padding: 15px;
height: auto;
background-color: #fff;
}
.container {
height: 100%;
background-color: #F3F5F7;

View File

@ -27,7 +27,6 @@
<view class="handTitle">请签名</view>
</view>
</view>
<pickerColor :isShow="showPickerColor" :bottom="0" @callback='getPickerColor' />
</view>
</template>
@ -424,10 +423,15 @@
url: '/admin-api/common/upload',
filePath: res.tempFilePath,
}).then((res) => {
console.log('服务器返回图片地址', res);
console.log('打印data',newData)
newData.image = res.data.url
console.log('提交的内容', newData)
// console.log('', res);
// console.log('data',newData)
console.log(res.data.url,'服务器返回图片地址')
if (newData.fileStr == null || newData.fileStr == ''){
newData.image = res.data.url
} else {
newData.image = newData.fileStr + ',' + res.data.url
}
// console.log('', newData)
request({
url: '/admin-api/repair/tickets/create',
method: 'POST',