PDA-安环管理-安全巡检-页面对接

test
ysn 1 week ago
parent 5af91a028a
commit af61d53211
  1. 215
      pages/safe/inspection.vue

@ -1,189 +1,173 @@
<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-item>
</uni-forms> </uni-forms>
<uni-table border stripe emptyText="暂无更多数据" class="table"> <uni-table border stripe emptyText="暂无更多数据" class="table">
<uni-tr> <uni-tr>
<uni-th align="center">巡检点编码</uni-th> <uni-th align="center">巡检点编码</uni-th>
<uni-th align="center">巡检点位置</uni-th> <uni-th align="center">巡检点位置</uni-th>
</uni-tr> </uni-tr>
<uni-tr v-for="(item, index) in patrolRegisterList" :key="index"> <uni-tr v-for="(item, index) in insList" :key="index">
<uni-td align="center">{{ item.patrolRegister }}</uni-td> <uni-td align="center">{{ item.insNum }}</uni-td>
<uni-td align="center">{{ item.insSpot }}</uni-td> <uni-td align="center">{{ item.insSite }}</uni-td>
</uni-tr> </uni-tr>
</uni-table> </uni-table>
<view style="font-size: 36rpx;">巡检备注</view> <view style="font-size: 36rpx; margin: 20rpx 0">巡检备注</view>
<uni-forms ref="form" err-show-type="toast"> <uni-forms ref="form" err-show-type="toast">
<uni-forms-item><uni-easyinput type="textarea" autoHeight v-model="parMemo" <uni-forms-item>
placeholder="请输入内容"></uni-easyinput></uni-forms-item> <uni-easyinput type="textarea" autoHeight v-model="memo" placeholder="请输入内容" />
</uni-forms-item>
</uni-forms> </uni-forms>
<view class="photoTitleSize">{{uploader.length}}/9</view>
<view class="photoTitleSize">{{ uploader.length }}/9</view>
<view class="showImage"> <view class="showImage">
<view v-for="(item, i) in uploader" :key="i" class="showImage-for"> <view v-for="(item, i) in uploader" :key="i" class="showImage-for">
<view class="view-image"> <view class="view-image">
<image :src="item.imageUrl" @tap="previewImage(i)" /> <image :src="item.imageUrl" @tap="previewImage(i)" mode="widthFix" />
</view> </view>
<view class="view-icon"> <view class="view-icon">
<uni-icons type='trash' size="14" color='gray' @click="removeScene(item, i)"></uni-icons> <uni-icons type="trash" size="14" color="gray" @click="removeScene(item, i)"></uni-icons>
</view> </view>
</view> </view>
<view class="view-center" v-if="uploader.length < 9"> <view class="view-center" v-if="uploader.length < 9">
<image src="../../static/images/photo.png" @click="chooseImage()"></image> <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>
</view> </view>
<view class="buttonBox"><button class="button" type="primary" :disabled="!(patrolRegisterList.length > 0)"
@click="submitClick">提交</button></view>
</ifrm>
</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
} from '@/http/config.js';
export default {
mixins: [scan], mixins: [scan],
components: {
ifrm
},
data() { data() {
return { return {
patrolRegisterValue: '', insNum: "",
patrolRegisterList: [], insList: [],
uploader: [], uploader: [], // { imageUrl, upId }
parMemo: '' memo: "",
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;
uni.showToast({
title: '数据获取成功'
});
}
}); });
}, },
submitClick() { submitClick() {
let piList = []; this.$u.api
this.patrolRegisterList.forEach(item => { .saveInspection({
piList.push({ code: this.insList.map((item) => item.insNum).join(","),
piId: item.piId memo: this.memo,
}); //
path: this.uploader.map((item) => item.imageUrl),
}); })
this.$ajax.request({ .then((data) => {
url: 'pdaSave/saveByInspection', uni.showToast({ title: "巡检成功" });
method: 'POST', //
data: { this.insList = [];
piList, this.memo = "";
parMemo: this.parMemo this.uploader = [];
},
success: data => {
uni.showToast({
title: '巡检成功'
});
this.patrolRegisterValue = '';
this.patrolRegisterList = [];
this.uploader = []
}
}); });
}, },
chooseImage: async function() { chooseImage: async function () {
if (this.patrolRegisterList.length == 0) { if (this.insList.length == 0) {
return uni.showToast({ return uni.showToast({
title: '请先查询巡检点', title: '请先查询巡检点',
icon: 'none' icon: 'none'
}); });
} }
uni.chooseImage({ uni.chooseImage({
// sourceType: ['album','camera'], //album camera 使
// sizeType: ['original', 'compressed'], //
count: 9, count: 9,
// sizeType: ['compressed'],
// sourceType: ['album', 'camera'],
success: (res) => { success: (res) => {
uni.showLoading({ uni.showLoading({
title: '上传中,请稍候' title: '上传中,请稍候'
}); });
var tempFilePaths = res.tempFilePaths; res.tempFilePaths.forEach(filePath => {
for (var i = 0; i < tempFilePaths.length; i++) { uni.uploadFile({
const file = res.tempFiles[i]; url: options.baseURL + '/blade-resource/oss/endpoint/put-file-attach',
this.$uploadUtil.upload(file, { filePath: filePath,
theId: this.patrolRegisterList[0].piId, name: 'file',
theTag: 'SafePatrolInspection', header: {
subTag: 'appDoc' 'token': 'bearer ' + uni.getStorageSync('accessToken'),
}, tempFilePaths[i]).then((upId) => { 'Blade-Auth': 'bearer ' + uni.getStorageSync('accessToken'),
'Blade-Requested-With': 'BladeHttpRequest'
},
success: (uploadRes) => {
uni.hideLoading(); uni.hideLoading();
// uni.showToast({ title: '上传成功' });
this.uploader.push({ this.uploader.push({
upId: upId, upId: JSON.parse(uploadRes.data).data.attachId,
imageUrl: file.path imageUrl: JSON.parse(uploadRes.data).data.link
}); });
})
}
}, },
complete() { fail: (err) => {
uni.hideLoading(); console.error('❌ 上传失败', err);
uni.showToast({ title: '上传失败', icon: 'none' });
} }
}) });
});
}, },
previewImage: function(index) { });
var imags = []; },
this.uploader.forEach(item => { //
imags.push(item.imageUrl); previewImage(index) {
}) const urls = this.uploader.map((item) => item.imageUrl);
uni.previewImage({ uni.previewImage({ current: index, urls });
current: index,
urls: imags
})
}, },
removeScene(item, i) { //
// removeScene(item, index) {
this.uploader.splice(i, 1); //
// // this.uploader.splice(index, 1);
this.$uploadUtil.asyncDelete(item.upId).then((data) => { uni.showToast({ title: "删除成功", icon: "none" });
uni.showToast({
title: '删除成功',
icon: 'none'
});
})
// this.upIdList.splice(this.upIdList.findIndex((upId) => (upId === item.upId)), 1);
}, },
}, },
onNavigationBarButtonTap(btn) { onNavigationBarButtonTap(btn) {
this.$refs.ifrm.topMenuClick(btn); this.$refs.ifrm.topMenuClick(btn);
}, },
onShow() {} 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;
@ -191,7 +175,6 @@
margin-left: -20rpx; margin-left: -20rpx;
.showImage-for { .showImage-for {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
width: 200rpx; width: 200rpx;
@ -214,9 +197,9 @@
height: 190rpx; height: 190rpx;
} }
} }
} }
.view-center { .view-center {
margin: 0rpx 25rpx; margin: 0rpx 25rpx;
image { image {
@ -227,5 +210,11 @@
width: 190rpx; width: 190rpx;
height: 190rpx; height: 190rpx;
} }
} }
.buttonBox {
margin-top: 30rpx;
display: flex;
justify-content: center;
}
</style> </style>
Loading…
Cancel
Save