parent
5af91a028a
commit
af61d53211
1 changed files with 199 additions and 210 deletions
@ -1,231 +1,220 @@ |
|||||||
<template> |
<template> |
||||||
<ifrm ref="ifrm"> |
<view> |
||||||
<!-- 安全巡检--> |
<!-- 安全巡检--> |
||||||
<uni-forms ref="form" err-show-type="toast"> |
<uni-forms ref="form" err-show-type="toast"> |
||||||
<uni-forms-item><input type="text" v-model="patrolRegisterValue" @confirm="patrolRegisterConfirm" |
<uni-forms-item> |
||||||
class="uni-input-border" placeholder="巡检点编码" /></uni-forms-item> |
<input type="text" v-model="insNum" @confirm="insConfirm" class="uni-input-border" placeholder="巡检点编码" /> |
||||||
</uni-forms> |
</uni-forms-item> |
||||||
|
</uni-forms> |
||||||
|
<uni-table border stripe emptyText="暂无更多数据" class="table"> |
||||||
|
<uni-tr> |
||||||
|
<uni-th align="center">巡检点编码</uni-th> |
||||||
|
<uni-th align="center">巡检点位置</uni-th> |
||||||
|
</uni-tr> |
||||||
|
<uni-tr v-for="(item, index) in insList" :key="index"> |
||||||
|
<uni-td align="center">{{ item.insNum }}</uni-td> |
||||||
|
<uni-td align="center">{{ item.insSite }}</uni-td> |
||||||
|
</uni-tr> |
||||||
|
</uni-table> |
||||||
|
|
||||||
<uni-table border stripe emptyText="暂无更多数据" class="table"> |
<view style="font-size: 36rpx; margin: 20rpx 0">巡检备注:</view> |
||||||
<uni-tr> |
<uni-forms ref="form" err-show-type="toast"> |
||||||
<uni-th align="center">巡检点编码</uni-th> |
<uni-forms-item> |
||||||
<uni-th align="center">巡检点位置</uni-th> |
<uni-easyinput type="textarea" autoHeight v-model="memo" placeholder="请输入内容" /> |
||||||
</uni-tr> |
</uni-forms-item> |
||||||
<uni-tr v-for="(item, index) in patrolRegisterList" :key="index"> |
</uni-forms> |
||||||
<uni-td align="center">{{ item.patrolRegister }}</uni-td> |
|
||||||
<uni-td align="center">{{ item.insSpot }}</uni-td> |
|
||||||
</uni-tr> |
|
||||||
</uni-table> |
|
||||||
|
|
||||||
<view style="font-size: 36rpx;">巡检备注:</view> |
<view class="photoTitleSize">{{ uploader.length }}/9</view> |
||||||
<uni-forms ref="form" err-show-type="toast"> |
<view class="showImage"> |
||||||
<uni-forms-item><uni-easyinput type="textarea" autoHeight v-model="parMemo" |
<view v-for="(item, i) in uploader" :key="i" class="showImage-for"> |
||||||
placeholder="请输入内容"></uni-easyinput></uni-forms-item> |
<view class="view-image"> |
||||||
</uni-forms> |
<image :src="item.imageUrl" @tap="previewImage(i)" mode="widthFix" /> |
||||||
<view class="photoTitleSize">{{uploader.length}}/9</view> |
|
||||||
<view class="showImage"> |
|
||||||
<view v-for="(item, i) in uploader" :key="i" class="showImage-for"> |
|
||||||
<view class="view-image"> |
|
||||||
<image :src="item.imageUrl" @tap="previewImage(i)" /> |
|
||||||
</view> |
|
||||||
<view class="view-icon"> |
|
||||||
<uni-icons type='trash' size="14" color='gray' @click="removeScene(item, i)"></uni-icons> |
|
||||||
</view> |
|
||||||
</view> |
|
||||||
<view class="view-center" v-if="uploader.length < 9"> |
|
||||||
<image src="../../static/images/photo.png" @click="chooseImage()"></image> |
|
||||||
</view> |
|
||||||
</view> |
</view> |
||||||
<view class="buttonBox"><button class="button" type="primary" :disabled="!(patrolRegisterList.length > 0)" |
<view class="view-icon"> |
||||||
@click="submitClick">提交</button></view> |
<uni-icons type="trash" size="14" color="gray" @click="removeScene(item, i)"></uni-icons> |
||||||
</ifrm> |
</view> |
||||||
|
</view> |
||||||
|
|
||||||
|
<view class="view-center" v-if="uploader.length < 9"> |
||||||
|
<image src="../../static/images/photo.png" @click="chooseImage"></image> |
||||||
|
</view> |
||||||
|
</view> |
||||||
|
|
||||||
|
<view class="buttonBox"> |
||||||
|
<button class="button" type="primary" :disabled="!(insList.length > 0)" @click="submitClick"> |
||||||
|
提交 |
||||||
|
</button> |
||||||
|
</view> |
||||||
|
</view> |
||||||
</template> |
</template> |
||||||
|
|
||||||
<script> |
<script> |
||||||
import ifrm from '@/pages/index/ifrm'; |
import scan from "../../mixin/scan.js"; |
||||||
import scan from '../../mixin/scan.js'; |
import { |
||||||
export default { |
options |
||||||
mixins: [scan], |
} from '@/http/config.js'; |
||||||
components: { |
export default { |
||||||
ifrm |
mixins: [scan], |
||||||
}, |
data() { |
||||||
data() { |
return { |
||||||
return { |
insNum: "", |
||||||
patrolRegisterValue: '', |
insList: [], |
||||||
patrolRegisterList: [], |
uploader: [], // 存放 { imageUrl, upId } |
||||||
uploader: [], |
memo: "", |
||||||
parMemo: '' |
uploadCount: 0, // 上传计数 |
||||||
}; |
}; |
||||||
}, |
}, |
||||||
methods: { |
methods: { |
||||||
getBarCode(code) { |
getBarCode(code) { |
||||||
this.getData(code); |
this.getData(code); |
||||||
}, |
}, |
||||||
patrolRegisterConfirm(e) { |
insConfirm(e) { |
||||||
this.getBarCode(e.target.value); |
this.getBarCode(e.target.value); |
||||||
}, |
}, |
||||||
getData(code) { |
getData(code) { |
||||||
if (!code) return; |
if (!code) return; |
||||||
this.patrolRegisterValue = code; |
this.insNum = code; |
||||||
this.$ajax.request({ |
this.$u.api.getInspectionByCode(code).then((res) => { |
||||||
url: 'pdaLoad/getInspectionByEcCode/' + code, |
this.insNum = ""; |
||||||
method: 'GET', |
this.insList = res.data; |
||||||
success: data => { |
uni.showToast({ title: "数据获取成功" }); |
||||||
console.log(data); |
}); |
||||||
this.patrolRegisterValue = ''; |
}, |
||||||
this.patrolRegisterList = data; |
submitClick() { |
||||||
uni.showToast({ |
this.$u.api |
||||||
title: '数据获取成功' |
.saveInspection({ |
||||||
}); |
code: this.insList.map((item) => item.insNum).join(","), |
||||||
} |
memo: this.memo, |
||||||
}); |
// 取出所有上传成功的文件 |
||||||
}, |
path: this.uploader.map((item) => item.imageUrl), |
||||||
submitClick() { |
}) |
||||||
let piList = []; |
.then((data) => { |
||||||
this.patrolRegisterList.forEach(item => { |
uni.showToast({ title: "巡检成功" }); |
||||||
piList.push({ |
// 清空表单 |
||||||
piId: item.piId |
this.insList = []; |
||||||
}); |
this.memo = ""; |
||||||
|
this.uploader = []; |
||||||
}); |
}); |
||||||
this.$ajax.request({ |
}, |
||||||
url: 'pdaSave/saveByInspection', |
chooseImage: async function () { |
||||||
method: 'POST', |
if (this.insList.length == 0) { |
||||||
data: { |
return uni.showToast({ |
||||||
piList, |
title: '请先查询巡检点', |
||||||
parMemo: this.parMemo |
icon: 'none' |
||||||
}, |
}); |
||||||
success: data => { |
} |
||||||
uni.showToast({ |
uni.chooseImage({ |
||||||
title: '巡检成功' |
count: 9, |
||||||
}); |
// sizeType: ['compressed'], |
||||||
this.patrolRegisterValue = ''; |
// sourceType: ['album', 'camera'], |
||||||
this.patrolRegisterList = []; |
success: (res) => { |
||||||
this.uploader = [] |
uni.showLoading({ |
||||||
} |
title: '上传中,请稍候' |
||||||
|
}); |
||||||
|
res.tempFilePaths.forEach(filePath => { |
||||||
|
uni.uploadFile({ |
||||||
|
url: options.baseURL + '/blade-resource/oss/endpoint/put-file-attach', |
||||||
|
filePath: filePath, |
||||||
|
name: 'file', |
||||||
|
header: { |
||||||
|
'token': 'bearer ' + uni.getStorageSync('accessToken'), |
||||||
|
'Blade-Auth': 'bearer ' + uni.getStorageSync('accessToken'), |
||||||
|
'Blade-Requested-With': 'BladeHttpRequest' |
||||||
|
}, |
||||||
|
success: (uploadRes) => { |
||||||
|
uni.hideLoading(); |
||||||
|
uni.showToast({ title: '上传成功' }); |
||||||
|
this.uploader.push({ |
||||||
|
upId: JSON.parse(uploadRes.data).data.attachId, |
||||||
|
imageUrl: JSON.parse(uploadRes.data).data.link |
||||||
}); |
}); |
||||||
}, |
}, |
||||||
chooseImage: async function() { |
fail: (err) => { |
||||||
if (this.patrolRegisterList.length == 0) { |
console.error('❌ 上传失败', err); |
||||||
return uni.showToast({ |
uni.showToast({ title: '上传失败', icon: 'none' }); |
||||||
title: '请先查询巡检点', |
} |
||||||
icon: 'none' |
}); |
||||||
}); |
}); |
||||||
} |
|
||||||
uni.chooseImage({ |
|
||||||
// sourceType: ['album','camera'], //album 从相册选图,camera 使用相机,默认二者都有 |
|
||||||
// sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有 |
|
||||||
count: 9, |
|
||||||
success: (res) => { |
|
||||||
uni.showLoading({ |
|
||||||
title: '上传中,请稍候' |
|
||||||
}); |
|
||||||
var tempFilePaths = res.tempFilePaths; |
|
||||||
for (var i = 0; i < tempFilePaths.length; i++) { |
|
||||||
const file = res.tempFiles[i]; |
|
||||||
this.$uploadUtil.upload(file, { |
|
||||||
theId: this.patrolRegisterList[0].piId, |
|
||||||
theTag: 'SafePatrolInspection', |
|
||||||
subTag: 'appDoc' |
|
||||||
}, tempFilePaths[i]).then((upId) => { |
|
||||||
uni.hideLoading(); |
|
||||||
//展示图片 |
|
||||||
this.uploader.push({ |
|
||||||
upId: upId, |
|
||||||
imageUrl: file.path |
|
||||||
}); |
|
||||||
}) |
|
||||||
|
|
||||||
} |
|
||||||
}, |
|
||||||
complete() { |
|
||||||
uni.hideLoading(); |
|
||||||
} |
|
||||||
}) |
|
||||||
}, |
|
||||||
previewImage: function(index) { |
|
||||||
var imags = []; |
|
||||||
this.uploader.forEach(item => { |
|
||||||
imags.push(item.imageUrl); |
|
||||||
}) |
|
||||||
uni.previewImage({ |
|
||||||
current: index, |
|
||||||
urls: imags |
|
||||||
}) |
|
||||||
}, |
|
||||||
|
|
||||||
removeScene(item, i) { |
|
||||||
//删除现场图片 |
|
||||||
this.uploader.splice(i, 1); |
|
||||||
// //删除附件记录 |
|
||||||
this.$uploadUtil.asyncDelete(item.upId).then((data) => { |
|
||||||
uni.showToast({ |
|
||||||
title: '删除成功', |
|
||||||
icon: 'none' |
|
||||||
}); |
|
||||||
}) |
|
||||||
// this.upIdList.splice(this.upIdList.findIndex((upId) => (upId === item.upId)), 1); |
|
||||||
}, |
|
||||||
}, |
}, |
||||||
|
}); |
||||||
|
}, |
||||||
|
// 预览图片 |
||||||
|
previewImage(index) { |
||||||
|
const urls = this.uploader.map((item) => item.imageUrl); |
||||||
|
uni.previewImage({ current: index, urls }); |
||||||
|
}, |
||||||
|
|
||||||
onNavigationBarButtonTap(btn) { |
// 删除图片 |
||||||
this.$refs.ifrm.topMenuClick(btn); |
removeScene(item, index) { |
||||||
}, |
// 先删本地列表 |
||||||
onShow() {} |
this.uploader.splice(index, 1); |
||||||
}; |
uni.showToast({ title: "删除成功", icon: "none" }); |
||||||
|
}, |
||||||
|
}, |
||||||
|
|
||||||
|
onNavigationBarButtonTap(btn) { |
||||||
|
this.$refs.ifrm.topMenuClick(btn); |
||||||
|
}, |
||||||
|
onShow() { }, |
||||||
|
}; |
||||||
</script> |
</script> |
||||||
|
|
||||||
<style scoped lang="less"> |
<style scoped lang="less"> |
||||||
.photoTitleSize { |
.photoTitleSize { |
||||||
color: #a1a1a1; |
color: #a1a1a1; |
||||||
text-align: right; |
text-align: right; |
||||||
margin-right: 30rpx; |
margin-right: 30rpx; |
||||||
margin-top: -30rpx; |
margin-top: 20rpx; |
||||||
} |
} |
||||||
|
|
||||||
.showImage { |
.showImage { |
||||||
display: flex; |
display: flex; |
||||||
flex-direction: row; |
flex-direction: row; |
||||||
justify-content: flex-start; |
justify-content: flex-start; |
||||||
flex-wrap: wrap; |
flex-wrap: wrap; |
||||||
margin-left: -20rpx; |
margin-left: -20rpx; |
||||||
|
|
||||||
.showImage-for { |
.showImage-for { |
||||||
|
display: flex; |
||||||
|
flex-direction: column; |
||||||
|
width: 200rpx; |
||||||
|
margin-left: 30rpx; |
||||||
|
height: 260rpx; |
||||||
|
|
||||||
display: flex; |
.view-icon { |
||||||
flex-direction: column; |
display: flex; |
||||||
width: 200rpx; |
flex-direction: row; |
||||||
margin-left: 30rpx; |
justify-content: center; |
||||||
height: 260rpx; |
margin-top: -10rpx; |
||||||
|
} |
||||||
.view-icon { |
|
||||||
display: flex; |
|
||||||
flex-direction: row; |
|
||||||
justify-content: center; |
|
||||||
margin-top: -10rpx; |
|
||||||
} |
|
||||||
|
|
||||||
image { |
image { |
||||||
border-width: 2rpx; |
border-width: 2rpx; |
||||||
border-color: rgb(229, 229, 229); |
border-color: rgb(229, 229, 229); |
||||||
border-style: solid; |
border-style: solid; |
||||||
border-radius: 20rpx; |
border-radius: 20rpx; |
||||||
width: 190rpx; |
width: 190rpx; |
||||||
height: 190rpx; |
height: 190rpx; |
||||||
} |
|
||||||
} |
|
||||||
} |
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
.view-center { |
.view-center { |
||||||
margin: 0rpx 25rpx; |
margin: 0rpx 25rpx; |
||||||
|
|
||||||
image { |
image { |
||||||
border-width: 2rpx; |
border-width: 2rpx; |
||||||
border-color: rgb(229, 229, 229); |
border-color: rgb(229, 229, 229); |
||||||
border-style: solid; |
border-style: solid; |
||||||
border-radius: 20rpx; |
border-radius: 20rpx; |
||||||
width: 190rpx; |
width: 190rpx; |
||||||
height: 190rpx; |
height: 190rpx; |
||||||
} |
} |
||||||
} |
} |
||||||
|
|
||||||
|
.buttonBox { |
||||||
|
margin-top: 30rpx; |
||||||
|
display: flex; |
||||||
|
justify-content: center; |
||||||
|
} |
||||||
</style> |
</style> |
||||||
Loading…
Reference in new issue