Browse Source

新增功能扫描上传

dev-xx
马远东 9 months ago
parent
commit
59559865e7
  1. BIN
      public/img/driveerror.png
  2. BIN
      public/img/loaderror.png
  3. 216
      src/components/webCameraIMG/webCamera.vue
  4. 90
      src/views/distribution/inventory/distrilbutionBillLading.vue
  5. 21
      src/views/distribution/reservation/reservation.vue
  6. 11
      src/views/distribution/reservation/reservationAddFrom.vue
  7. 85
      src/views/distribution/signfor/distributionSignfortreat.vue

BIN
public/img/driveerror.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
public/img/loaderror.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

216
src/components/webCameraIMG/webCamera.vue

@ -1,22 +1,20 @@
<template>
<div class="page">
<el-tabs type="border-card">
<el-tabs type="border-card" class="el_tabs">
<el-tab-pane label="拍摄">
<div>
<!-- <el-button type="primary" @click="Opentrimming" :disabled="!IMG_startUp">{{
IMG_Trimming_edge ? '关闭裁边' : '开启裁边'
}}</el-button> -->
<!-- <el-button type="primary" @click="view1_scan" :disabled="!IMG_startUp"
>点击拍摄</el-button
> -->
</div>
<div class="IMG_VIEW_container">
<!-- 主摄像头 -->
<div class="IMG_VIEW1">
<img id="IMG_VIEW1" v-if="IMG_camera" ref="IMG_VIEW" src="../../../public/img/load.gif" alt="主摄像头" />
<!-- <el-icon v-if="!IMG_startUp" @click="Deviceinitialization" class="SwitchButton"
<img
id="IMG_VIEW1"
v-if="IMG_camera"
ref="IMG_VIEW"
src="../../../public/img/load.gif"
alt="主摄像头"
/>
<el-icon v-if="!IMG_startUp" @click="Devicerestart" class="SwitchButton"
><SwitchButton
/></el-icon> -->
/></el-icon>
<div class="el_icon" v-if="IMG_startUp">
<el-tooltip effect="dark" :content="IMG_Trimming_edge ? '关闭裁边' : '开启裁边'">
<el-icon
@ -35,7 +33,23 @@
</div>
<!-- 缩略图 -->
<div id="suoluetu" ref="IMG_Thumbnail"></div>
<div id="suoluetu" ref="IMG_Thumbnail">
<el-empty style="margin: auto;" description="暂无缩略图" v-if="!IMG_suoluetuList.length" />
<template v-for="(item, index) in IMG_suoluetuList" :key="index">
<el-image
ref="el => setImagePreviewRef(el, index)"
style="width: 90px; height: 90px"
:src="item"
:zoom-rate="1.2"
:max-scale="4"
:min-scale="0.2"
:preview-src-list="IMG_suoluetuList"
:initial-index="initialIndex"
fit="cover"
@click="showPreview(index)"
/>
</template>
</div>
</div>
</el-tab-pane>
@ -52,17 +66,79 @@ import axios from 'axios';
import { ElMessage } from 'element-plus';
const IMG_camera = ref(false); //
const IMG_URL = 'http://127.0.0.1:38088/video=stream&camidx=0'; //
const IMG_error = '../../../public/img/loaderror.png'; //
const IMG_drive = '../../../public/img/driveerror.png'; //
const IMG_VIEW = ref(null); //
const IMG_Thumbnail = ref(null); //
const IMG_TITLE=ref('设备正在初始化中...')
const IMG_TITLE = ref('设备正在初始化中...');
const IMG_suoluetuList = ref([]); //
const initialIndex = ref(0); //
const imagePreviewRefs = ref([]);
let IMG_Trimming_edge = ref(false); //
let IMG_startUp = ref(false); //
let IMG_API = ref('/api/blade-resource/oss/endpoint/put-file');
let zoom = ref(5); //
let IMGstate=ref(1);//
const $emit = defineEmits(['upload-success']);
const props = defineProps({
IMGstate: {
type: Number,//
required: false,//
default: 1 //;0,.1
}
});
watch(() => props.IMGstate, (newValue, oldValue) => {
if(newValue !=IMGstate.value){
IMGstate.value = props.IMGstate
IMG_suoluetuList.value=[];//
}
});
//
const mylog = val => {
let element = document.getElementById('log');
let old_val = element.innerHTML;
let date = new Date().toString().slice(16, 24);
element.innerHTML = date + '&nbsp;&nbsp;' + val + '<br>' + old_val;
};
// el-image
const setImagePreviewRef = (el, index) => {
if (el) {
imagePreviewRefs.value[index] = el.$refs.imageRef;
}
};
const showPreview = async index => {
initialIndex.value = index; //
await nextTick();
//
if (imagePreviewRefs.value[index]) {
imagePreviewRefs.value[index].click();
}
};
//
const IsConnect = async () => {
let timeoutMs = 6000; // 6
let startTime = Date.now();
while (Date.now() - startTime < timeoutMs) {
try {
const response = await axios.post('/imgapi/device=isconnect', {}, { timeout: timeoutMs });
console.log(response.data, 'res');
//
const Getdevicestatus = () => {};
if (response.data.code === '0') {
console.log('设备数量:', response.data);
return response.data; //
} else {
throw new Error('设备未连接');
}
} catch (error) {
console.error(error);
//
}
//
await new Promise(resolve => setTimeout(resolve, 1000)); // 1
}
// 6false
return false;
};
//(/)
const Opentrimming = () => {
IMG_Trimming_edge.value = !IMG_Trimming_edge.value;
@ -74,46 +150,52 @@ const Opentrimming = () => {
mylog('图像裁边已关闭');
}
};
//
const FrameSelectImage = () => {
let data = {
filepath: '', // a
left: 0,
top: 0,
right: 100,
bottom: 100,
};
axios.post('/imgapi/select=imagearea', JSON.stringify(data)).then(res => {
console.log(res, '框选图片');
});
};
//
const Deviceinitialization = () => {
const Deviceinitialization = async () => {
IMG_camera.value = true; //
// 线
let TIME_IMG_VIEW = setTimeout(() => {
if (IMG_VIEW.value) {
IMG_startUp.value = true; //
IMG_VIEW.value.src = IMG_URL; //
IMG_TITLE.value=''
ElMessage({ message: '摄像头已启动', type: 'success' });
mylog('摄像头已启动');
}
clearTimeout(TIME_IMG_VIEW);
}, 2000);
let IMG_state = await IsConnect();
console.log(IMG_state, 'IMG_state');
//
if (IMG_state == false) {
ElMessage({ message: '设备驱动未连接', type: 'warning' });
mylog('设备驱动未连接');
IMG_VIEW.value.src = IMG_drive; //
return;
}
//
if (IMG_state.code == '0' && IMG_state.data == '1') {
ElMessage({ message: '设备已连接,设备数量:1', type: 'success' });
mylog('设备已连接,设备数量:1');
let TIME_IMG_VIEW = setTimeout(() => {
if (IMG_VIEW.value) {
IMG_startUp.value = true; //
IMG_VIEW.value.src = IMG_URL; //
IMG_TITLE.value = '';
ElMessage({ message: '摄像头已启动', type: 'success' });
mylog('摄像头已启动');
}
clearTimeout(TIME_IMG_VIEW);
}, 2000);
} else {
IMG_VIEW.value.src = IMG_error; //
ElMessage({ message: '设备未连接', type: 'warning' });
mylog('设备未连接');
}
};
//
const onLoad=()=>{
Deviceinitialization();//
}
onLoad()
//
const mylog = val => {
let element = document.getElementById('log');
let old_val = element.innerHTML;
let date = new Date().toString().slice(16, 24);
element.innerHTML = date + '&nbsp;&nbsp;' + val + '<br>' + old_val;
const onLoad = async () => {
await Deviceinitialization(); //
};
onLoad();
//
const Devicerestart=()=>{
IMG_camera.value = true; //
mylog('重启设备');
IMG_VIEW.value.src = '../../../public/img/load.gif'; //
Deviceinitialization(); //
}
// API
const zoomAPI = attribute => {
@ -227,19 +309,12 @@ const IMG_add = img_base64 => {
const base64Data = img_base64.replace(/^data:image\/\w+;base64,/, '');
const blob = base64ToBlob(base64Data, 'image/jpeg');
const url = URL.createObjectURL(blob);
let img = document.createElement('img');
img.src = url;
img.style.width = '80px';
img.style.height = '80px';
//
if (IMG_Thumbnail.value) {
IMG_Thumbnail.value.appendChild(img);
IMG_suoluetuList.value.push(url);
mylog('添加缩略图成功');
}
console.log(img, 'img');
Upload_Images(blob); //
console.log(url, 'blob');
};
//
@ -276,6 +351,10 @@ let view1_scan = async () => {
</script>
<style scoped lang="scss">
.el_tabs {
height: 380px;
overflow: hidden;
}
.page {
width: 100%;
img {
@ -329,8 +408,8 @@ let view1_scan = async () => {
}
.SwitchButton {
position: absolute;
top: 50%;
left: 50%;
top: 10%;
right: 0%;
transform: translate(-50%, -50%);
font-size: 25px;
color: #fff;
@ -342,11 +421,18 @@ let view1_scan = async () => {
/* 缩略图 */
#suoluetu {
width: 38%;
height: aut;
border: 1px solid blue;
height: 300px;
overflow: scroll;
border: 1px solid #172e60;
padding: 0 !important;
display: flex;
flex-wrap: wrap;
}
#suoluetu img {
margin-right: 10px;
#suoluetu {
.el-image {
margin: 0 4px;
margin-bottom: 2px;
}
}
/* 操作按钮 */
#myactive {

90
src/views/distribution/inventory/distrilbutionBillLading.vue

@ -198,6 +198,7 @@
<el-row :gutter="20" class="toscontent">
<el-col v-if="!view" :span="8">
<el-form-item label="提货证件" label-width="120px">
<el-upload
v-model:file-list="fileListSell"
class="upload-demo"
@ -205,6 +206,7 @@
:headers="headers"
multiple
:on-preview="handlePreview"
:disabled='smIMG'
:on-success="
(response, file, fileList) => {
uploadSuccess(fileListSell);
@ -213,13 +215,17 @@
:on-remove="handleRemove"
list-type="picture"
>
<el-button type="primary">上传</el-button>
<template #tip>
<el-button type="primary" @click="smIMG=false">上传</el-button>
<el-button type="primary" @click="clicklocal(1)">上传扫描图片</el-button>
<template #tip>
<div class="el-upload__tip">只能上传jpg/png文件且不超过500kb</div>
</template>
</el-upload>
</el-upload>
<!-- <el-button type="primary" @click="clicklocal">上传扫描图片</el-button> -->
</el-form-item>
</el-col>
<el-col v-if="!view" :span="8">
@ -230,6 +236,7 @@
:action="action"
:headers="headers"
multiple
:disabled='smIMG'
:on-preview="handlePreview"
:on-success="
(response, file, fileList) => {
@ -239,7 +246,8 @@
:on-remove="handleRemove"
list-type="picture"
>
<el-button type="primary">上传</el-button>
<el-button type="primary" @click="smIMG=false">上传</el-button>
<el-button type="primary" @click="clicklocal(2)">上传扫描图片</el-button>
<template #tip>
<div class="el-upload__tip">只能上传jpg/png文件且不超过500kb</div>
</template>
@ -253,6 +261,7 @@
class="upload-demo"
:action="action"
:headers="headers"
:disabled='smIMG'
multiple
:on-preview="handlePreview"
:on-success="
@ -263,7 +272,8 @@
:on-remove="handleRemove"
list-type="picture"
>
<el-button type="primary">上传</el-button>
<el-button type="primary" @click="smIMG=false">上传</el-button>
<el-button type="primary" @click="clicklocal(3)">上传扫描图片</el-button>
<template #tip>
<div class="el-upload__tip">只能上传jpg/png文件且不超过500kb</div>
</template>
@ -627,24 +637,9 @@
</el-dialog>
<!-- <el-dialog
v-model="webCamera"
title="Tips"
>
<webCamera> </webCamera>
<template #footer>
<div class="dialog-footer">
<el-button @click="webCamera = false">Cancel</el-button>
<el-button type="primary" @click="dialogVisible = false">
Confirm
</el-button>
</div>
</template>
</el-dialog> -->
<el-dialog v-model="webCamera" title="扫描上传">
<webCamera @upload-success="IMGUploadSuccess" :IMGstate="IMGstate"> </webCamera>
</el-dialog>
<div class="LoadIMG">
<el-dialog v-model="dialogImg">
<img w-full :src="Imgurl" alt="Preview Image" />
@ -686,8 +681,11 @@ export default {
name: '/distribution/inventory/distrilbutionBillLading',
data() {
return {
webCamera:true,//
webCamera:false,//
IMGstate:0,
PackageCheckList:[],//
imgValue:1,//
smIMG:false,//
tabletit: '', //
multifunctional: '', //
PackageState:[],//
@ -2113,10 +2111,37 @@ export default {
console.log(this.order.selectList,'当前勾选');
},
//
clicklocal(){
clicklocal(value){
this.IMGstate=value
this.imgValue=value
this.smIMG=true;//
this.webCamera=true
},
//
IMGUploadSuccess(value){
console.log(this.fileListSell,'this.fileListSell');
console.log(value,'接收上传成功图片地址');
if(this.imgValue ==1){
this.fileListSell.push({
name:value.data.data.originalName,
url:value.data.data.link,
})
}else if(this.imgValue ==2){
this.fileListClerk.push({
name:value.data.data.originalName,
url:value.data.data.link,
})
}else if(this.imgValue ==3){
this.fileListLibrary.push({
name:value.data.data.originalName,
url:value.data.data.link,
})
}
},
scrollToElementWithinTableRow(partialIdString) {
//
const tableRows = document.querySelectorAll('tr');
@ -2307,6 +2332,7 @@ export default {
this.dataList.splice(id1, 1);
}
},
//
callFordeliveryOrder() {
if(!this.selectionList.length){
@ -3011,28 +3037,31 @@ export default {
let o = [];
if (this.fileListClerk.length > 0) {
this.fileListClerk.forEach(i => {
console.log(i,'图片地址');
let num = {};
num.state = '2';
num.name = i.name;
num.url = i.response.data.link;
num.url = i.url ? i.url : i.response.data.link;
o.push(num);
});
}
if (this.fileListLibrary.length > 0) {
this.fileListLibrary.forEach(i => {
console.log(i,'图片地址');
let num = {};
num.state = '3';
num.name = i.name;
num.url = i.response.data.link;
num.url = i.url ? i.url : i.response.data.link;
o.push(num);
});
}
if (this.fileListSell.length > 0) {
this.fileListSell.forEach(i => {
console.log(i,'图片地址');
let num = {};
num.state = '1';
num.name = i.name;
num.url = i.response.data.link;
num.url = i.url ? i.url : i.response.data.link;
o.push(num);
});
}
@ -3152,6 +3181,7 @@ export default {
Object.entries(fileListMapping).forEach(([fileList, state]) => {
if (this[fileList].length > 0) {
this[fileList].forEach(i => {
console.log(i,'编辑图片');
let num = {
state,
};
@ -3160,6 +3190,7 @@ export default {
num.url = i.response.data.link;
mark = true;
} else {
mark = true;
num.name = i.name;
num.url = i.url;
}
@ -3252,6 +3283,7 @@ if (this.dataOwn?.length) {
} else if (this.dataList?.length) {
up.consigneeUnit = this.dataList[0].consigneeUnit;
}
this.Selfpickuploading = true; //
update(up)

21
src/views/distribution/reservation/reservation.vue

@ -407,6 +407,26 @@ export default {
fixed: false,
sortable: true,
},
{
prop: 'isInstallName',
label: '是否安装',
type: 3,
values: '',
width: '100',
checkarr: [
{
label: '否',
value: '1',
},
{
label: '是',
value: '2',
},
],
fixed: false,
sortable: true,
},
{
prop: 'warehouseName',
label: '仓库',
@ -1097,6 +1117,7 @@ export default {
},
inputscA(index, row) {
console.log(index, row);
console.log(row,'row');
this.queryA[row.prop] = index;
if (!index) delete this.queryA[row.prop];
this.onLoad(this.page);

11
src/views/distribution/reservation/reservationAddFrom.vue

@ -121,6 +121,13 @@
</el-input>
</el-form-item>
</el-col>
<el-col :span="10">
<el-form-item label="安&emsp;&emsp;装:" prop="serveType" label-width="100px">
<el-radio-group v-model="form.IsInstall" v-for="item in this.whetherData">
<el-radio :label="item.dictKey" :value="item.dictKey">{{ item.dictValue }}&emsp; </el-radio>
</el-radio-group>
</el-form-item>
</el-col>
</el-row>
</el-form>
@ -1914,7 +1921,9 @@ export default {
total: 0,
},
//
form: {},
form: {
IsInstall:'1',//
},
//
selectionList: [],
selectionInventoryList: [],

85
src/views/distribution/signfor/distributionSignfortreat.vue

@ -287,6 +287,8 @@
</el-form>
<div class="imgName">
<span>上门照</span>
<br/>
<el-button type="primary" @click="UploadTheScanningMap(1)">上传扫描图</el-button>
<el-upload
v-model:file-list="DoorstepPhoto"
:action="doubledCount"
@ -306,6 +308,8 @@
<div class="imgName">
<span>堆码照</span>
<br/>
<el-button type="primary" @click="UploadTheScanningMap(2)">上传扫描图</el-button>
<el-upload
v-model:file-list="StackingPhoto"
:action="doubledCount"
@ -325,6 +329,8 @@
<div class="imgName">
<span>易碎照</span>
<br/>
<el-button type="primary" @click="UploadTheScanningMap(3)">上传扫描图</el-button>
<el-upload
v-model:file-list="FragilePhotos"
:action="doubledCount"
@ -344,6 +350,8 @@
<div class="imgName">
<span>家配照</span>
<br/>
<el-button type="primary" @click="UploadTheScanningMap(4)">上传扫描图</el-button>
<el-upload
v-model:file-list="HomePhotos"
:action="doubledCount"
@ -363,6 +371,8 @@
<div class="imgName">
<span>签收照</span>
<br/>
<el-button type="primary" @click="UploadTheScanningMap(5)">上传扫描图</el-button>
<el-upload
v-model:file-list="SignForPhotos"
:action="doubledCount"
@ -481,6 +491,10 @@
<el-button @click="numberDetailDialogVisible = false"> </el-button>
<el-button type="primary" @click="numberDetailDialogVisible = false"> </el-button>
</el-dialog>
<el-dialog v-model="webCamera" title="扫描上传">
<webCamera @upload-success="IMGUploadSuccess" :IMGstate="IMGstate"> </webCamera>
</el-dialog>
</template>
<script>
@ -511,6 +525,9 @@ export default {
data() {
return {
abnormalReview: '', //
imgValue:1,//
IMGstate:0,
webCamera:false,//
Abnormalloading: false, //
dialogImageUrl: '', //
dialogVisible: false, //
@ -1788,10 +1805,52 @@ export default {
}
},
//
//
generatePhotoArray(photoType, photoItems, reservationId) {
const photoArray = [];
photoItems.forEach(item => {
photoArray.push({
name: item.name,
reservationId: reservationId,
type: photoType,
urlRoute: item.response && item.response.data ? item.response.data.link : item.url,
});
});
return photoArray;
},
cancellation() {
this.signBox = false;
},
//
UploadTheScanningMap(value){
this.IMGstate=value
this.imgValue=value
this.webCamera=true;//
},
//
IMGUploadSuccess(res){
let dataURL={
name:res.data.data.originalName,
url:res.data.data.link,
}
console.log(res,'扫描图返回值');
if(this.imgValue==1){
console.log( this.DoorstepPhoto,' this.DoorstepPhoto');
this.DoorstepPhoto.push(dataURL)
}
if(this.imgValue==2){
this.StackingPhoto.push(dataURL)
}
if(this.imgValue==3){
this.FragilePhotos.push(dataURL)
}
if(this.imgValue==4){
this.HomePhotos.push(dataURL)
}
if(this.imgValue==5){
this.SignForPhotos.push(dataURL)
}
},
//
submitForm() {
// this.isDis = true;
@ -1842,24 +1901,12 @@ export default {
});
//
//
function generatePhotoArray(photoType, photoItems, reservationId) {
const photoArray = [];
photoItems.forEach(item => {
photoArray.push({
name: item.name,
reservationId: reservationId,
type: photoType,
urlRoute: item.response && item.response.data ? item.response.data.link : item.url,
});
});
return photoArray;
}
row.map.photo_1 = generatePhotoArray('photo_1', this.DoorstepPhoto, this.reservationId);
row.map.photo_2 = generatePhotoArray('photo_2', this.StackingPhoto, this.reservationId);
row.map.photo_3 = generatePhotoArray('photo_3', this.FragilePhotos, this.reservationId);
row.map.photo_4 = generatePhotoArray('photo_4', this.HomePhotos, this.reservationId);
row.map.photo_5 = generatePhotoArray('photo_5', this.SignForPhotos, this.reservationId);
row.map.photo_1 = this.generatePhotoArray('photo_1', this.DoorstepPhoto, this.reservationId);
row.map.photo_2 = this.generatePhotoArray('photo_2', this.StackingPhoto, this.reservationId);
row.map.photo_3 = this.generatePhotoArray('photo_3', this.FragilePhotos, this.reservationId);
row.map.photo_4 = this.generatePhotoArray('photo_4', this.HomePhotos, this.reservationId);
row.map.photo_5 = this.generatePhotoArray('photo_5', this.SignForPhotos, this.reservationId);
//
//
this.deduplicateByIdAndUpdate(row.map.photo_1);

Loading…
Cancel
Save