解决websdk demo扫描图片错位的问题

This commit is contained in:
luoliangyi 2023-02-28 15:18:06 +08:00
parent 8b97af1e30
commit 3a5fd9c28a
5 changed files with 151 additions and 83 deletions

View File

@ -1,12 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="b2ba291d-311b-4300-aa9d-2294abc20088" name="Default Changelist" comment=""> <list default="true" id="b2ba291d-311b-4300-aa9d-2294abc20088" name="Default Changelist" comment="" />
<change beforePath="$PROJECT_DIR$/js/WebScanController.js" beforeDir="false" afterPath="$PROJECT_DIR$/js/WebScanController.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/js/scanWeb.js" beforeDir="false" afterPath="$PROJECT_DIR$/js/scanWeb.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/logo.png" beforeDir="false" afterPath="$PROJECT_DIR$/logo.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/webDemo.html" beforeDir="false" afterPath="$PROJECT_DIR$/webDemo.html" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
@ -176,7 +171,14 @@
<workItem from="1656292180128" duration="14823000" /> <workItem from="1656292180128" duration="14823000" />
<workItem from="1656642781712" duration="356000" /> <workItem from="1656642781712" duration="356000" />
<workItem from="1658798079592" duration="12987000" /> <workItem from="1658798079592" duration="12987000" />
<workItem from="1659077228592" duration="2265000" /> <workItem from="1659077228592" duration="2926000" />
<workItem from="1659599005751" duration="14209000" />
<workItem from="1662097948480" duration="555000" />
<workItem from="1673398667787" duration="615000" />
<workItem from="1677128522843" duration="1487000" />
<workItem from="1677133435997" duration="1177000" />
<workItem from="1677134756747" duration="10561000" />
<workItem from="1677567691663" duration="756000" />
</task> </task>
<task id="LOCAL-00001" summary="init"> <task id="LOCAL-00001" summary="init">
<created>1654157535371</created> <created>1654157535371</created>
@ -213,12 +215,36 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1655369381641</updated> <updated>1655369381641</updated>
</task> </task>
<option name="localTasksCounter" value="6" /> <task id="LOCAL-00006" summary="添加上传功能">
<created>1659080182659</created>
<option name="number" value="00006" />
<option name="presentableId" value="LOCAL-00006" />
<option name="project" value="LOCAL" />
<updated>1659080182659</updated>
</task>
<task id="LOCAL-00007" summary="修复扫描时,图片显示错位的问题">
<created>1677145533776</created>
<option name="number" value="00007" />
<option name="presentableId" value="LOCAL-00007" />
<option name="project" value="LOCAL" />
<updated>1677145533776</updated>
</task>
<option name="localTasksCounter" value="8" />
<servers /> <servers />
</component> </component>
<component name="TypeScriptGeneratedFilesManager"> <component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" /> <option name="version" value="3" />
</component> </component>
<component name="Vcs.Log.History.Properties">
<option name="COLUMN_ID_ORDER">
<list>
<option value="Default.Root" />
<option value="Default.Author" />
<option value="Default.Date" />
<option value="Default.Subject" />
</list>
</option>
</component>
<component name="Vcs.Log.Tabs.Properties"> <component name="Vcs.Log.Tabs.Properties">
<option name="TAB_STATES"> <option name="TAB_STATES">
<map> <map>
@ -237,6 +263,8 @@
<MESSAGE value="优化第一次使用缩略图加载,提高界面展示速度" /> <MESSAGE value="优化第一次使用缩略图加载,提高界面展示速度" />
<MESSAGE value="新增批量水印功能" /> <MESSAGE value="新增批量水印功能" />
<MESSAGE value="添加动态参数配置" /> <MESSAGE value="添加动态参数配置" />
<option name="LAST_COMMIT_MESSAGE" value="添加动态参数配置" /> <MESSAGE value="添加上传功能" />
<MESSAGE value="修复扫描时,图片显示错位的问题" />
<option name="LAST_COMMIT_MESSAGE" value="修复扫描时,图片显示错位的问题" />
</component> </component>
</project> </project>

View File

@ -82,8 +82,10 @@ ul {
} }
.el-container .el-header .menuContainer { .el-container .el-header .menuContainer {
float: left; /*float: left;*/
margin-left: 15px; /*margin-left: 15px;*/
/*height: 80px;*/
overflow-x: auto;
} }
.el-container .el-header .menuContainer ul { .el-container .el-header .menuContainer ul {
@ -218,3 +220,10 @@ ul {
.cursor-pointer { .cursor-pointer {
cursor: pointer cursor: pointer
} }
.menuStyle {
display: inline-block;
/*margin-left: 10px;*/
margin: 5px;
}

View File

@ -448,11 +448,11 @@
}, },
//插入本地图像需返回成功后前端缩略图才能作相应的UI修改 //插入本地图像需返回成功后前端缩略图才能作相应的UI修改
insertLocalImage: function (imagePath, insertIndex, callBack) { insertLocalImage: function (imagePath, insertIndex, idenInfo, callBack) {
const that = this const that = this
this.sendCommand({ this.sendCommand({
func: "insert_local_image", func: "insert_local_image",
iden: that.wslicence, iden: JSON.stringify(idenInfo),
image_path: imagePath, image_path: imagePath,
insert_pos: insertIndex,//插入位置,-1表示最后 insert_pos: insertIndex,//插入位置,-1表示最后
image_tag: ''//标签名,可以为空 image_tag: ''//标签名,可以为空
@ -501,11 +501,11 @@
}, },
//修改图像 //修改图像
modifyImage: function (imageIndex, imageBase64, callBack) { modifyImage: function (imageIndex, imageBase64, idenInfo, callBack) {
const that = this const that = this
this.sendCommand({ this.sendCommand({
func: "modify_image", func: "modify_image",
iden: that.wslicence, iden: idenInfo == null ? that.wslicence : JSON.stringify(idenInfo),
image_index: imageIndex, image_index: imageIndex,
image_base64: imageBase64 image_base64: imageBase64
}, callBack) }, callBack)

View File

@ -292,8 +292,10 @@ new Vue({
this.eleMessage(info.info, info.is_error ? 'error' : 'warning') this.eleMessage(info.info, info.is_error ? 'error' : 'warning')
break break
case "scan_image"://图片回调 case "scan_image"://图片回调
this.appendLog('图片回调:' + info.image_path) let imagePath = info.image_path
console.log('图片回调:' + info.image_path)
this.appendLog('图片回调:' + imagePath)
console.log('图片回调:' + imagePath + ' info:' + JSON.stringify(info))
let that = this let that = this
if (this.scanMode == 'insert') {//是插入扫描 if (this.scanMode == 'insert') {//是插入扫描
@ -306,14 +308,21 @@ new Vue({
this.curInsertIndex = this.selectImageObj.index this.curInsertIndex = this.selectImageObj.index
} }
console.log('插入扫描待插入index:' + this.curInsertIndex + " path:" + info.image_path) console.log('插入扫描待插入index:' + this.curInsertIndex + " path:" + imagePath)
this.WebScanController.insertLocalImage(info.image_path, this.curInsertIndex, function (insertInfo) { this.WebScanController.insertLocalImage(imagePath, this.curInsertIndex,
console.log('插入扫描插入index' + that.curInsertIndex) {
path: imagePath,
that.urls.splice(that.curInsertIndex, 0, {
path: info.image_path,
thumbnail: info.image_base64, thumbnail: info.image_base64,
base64: info.image_base64 base64: info.image_base64
},
function (insertInfo) {
console.log('插入扫描插入index' + that.curInsertIndex)
let idenInfo = JSON.parse(insertInfo.iden);
that.urls.splice(that.curInsertIndex, 0, {
path: idenInfo.path,
thumbnail: idenInfo.thumbnail,
base64: idenInfo.base64
}); });
that.curInsertIndex++ that.curInsertIndex++
that.$forceUpdate() that.$forceUpdate()
@ -333,15 +342,20 @@ new Vue({
} }
if (this.needCoverCount > 0) {//还在覆盖范围内,直接覆盖掉 if (this.needCoverCount > 0) {//还在覆盖范围内,直接覆盖掉
this.WebScanController.modifyImage(this.curCoverIndex, info.image_base64, function (modifyInfo) { this.WebScanController.modifyImage(this.curCoverIndex, info.image_base64, {
base64: info.image_base64,
thumbnail: info.image_base64,
path: imagePath
}, function (modifyInfo) {
console.log('覆盖扫描:修改成功 index:' + that.curCoverIndex) console.log('覆盖扫描:修改成功 index:' + that.curCoverIndex)
console.log('覆盖前index==' + that.curCoverIndex + ' path:' + that.urls[that.curCoverIndex].path) console.log('覆盖前index==' + that.curCoverIndex + ' path:' + that.urls[that.curCoverIndex].path)
let idenInfo = JSON.parse(modifyInfo.iden);
that.urls[that.curCoverIndex] = { that.urls[that.curCoverIndex] = {
base64: info.image_base64, base64: idenInfo.base64,
thumbnail: info.image_base64, thumbnail: idenInfo.thumbnail,
path: info.image_path path: idenInfo.path
} }
console.log('覆盖后index==' + that.curCoverIndex + ' path:' + that.urls[that.curCoverIndex].path) console.log('覆盖后index==' + that.curCoverIndex + ' path:' + that.urls[that.curCoverIndex].path)
@ -351,12 +365,18 @@ new Vue({
that.$forceUpdate() that.$forceUpdate()
}) })
} else {//之后都是新增的往后添加了 } else {//之后都是新增的往后添加了
this.WebScanController.insertLocalImage(info.image_path, this.urls.length, function (result) { this.WebScanController.insertLocalImage(imagePath, this.urls.length, {
console.log('覆盖扫描:插入成功 index' + that.urls.length) path: imagePath,
that.urls.push({
path: info.image_path,
thumbnail: info.image_base64, thumbnail: info.image_base64,
base64: info.image_base64 base64: info.image_base64
}, function (result) {
console.log('覆盖扫描:插入成功 index' + that.urls.length)
let idenInfo = JSON.parse(result.iden);
that.urls.push({
path: idenInfo.path,
thumbnail: idenInfo.thumbnail,
base64: idenInfo.base64
}) })
that.$forceUpdate() that.$forceUpdate()
@ -374,12 +394,20 @@ new Vue({
let that = this; let that = this;
this.WebScanController.insertLocalImage(info.image_path, this.urls.length, function (result) {
console.log('正常扫描:插入成功 index' + that.urls.length) this.WebScanController.insertLocalImage(imagePath, this.urls.length, {
that.urls.push({ path: imagePath,
path: info.image_path,
thumbnail: info.image_base64, thumbnail: info.image_base64,
base64: info.image_base64 base64: info.image_base64
}, function (result) {
let idenInfo = JSON.parse(result.iden);
console.log('正常扫描:插入成功 index' + that.urls.length + ' path:' + idenInfo.path)
that.urls.push({
path: idenInfo.path,
thumbnail: idenInfo.thumbnail,
base64: idenInfo.base64
}) })
that.$nextTick(function () { that.$nextTick(function () {
if (that.$refs.imageArea) { if (that.$refs.imageArea) {
@ -1023,7 +1051,7 @@ new Vue({
that.WebScanController.imageAddWatermark(modifyIndex, that.waterMarkInfo, true, function (info) { that.WebScanController.imageAddWatermark(modifyIndex, that.waterMarkInfo, true, function (info) {
console.log('添加水印成功:') console.log('添加水印成功:')
that.WebScanController.modifyImage(modifyIndex, info.image_base64, function (modifyInfo) { that.WebScanController.modifyImage(modifyIndex, info.image_base64, {}, function (modifyInfo) {
console.log('添加水印:修改' + modifyIndex + '成功:') console.log('添加水印:修改' + modifyIndex + '成功:')
that.urls[modifyIndex].thumbnail = info.image_base64 that.urls[modifyIndex].thumbnail = info.image_base64
that.urls[modifyIndex].base64 = info.image_base64 that.urls[modifyIndex].base64 = info.image_base64
@ -1056,7 +1084,7 @@ new Vue({
this.WebScanController.imageAddWatermark(imageIndex, markInfoParams, true, function (markInfo) { this.WebScanController.imageAddWatermark(imageIndex, markInfoParams, true, function (markInfo) {
console.log('多张添加水印成功index' + imageIndex) console.log('多张添加水印成功index' + imageIndex)
let resultImage = markInfo.image_base64 let resultImage = markInfo.image_base64
that.WebScanController.modifyImage(imageIndex, resultImage, function (modifyInfo) { that.WebScanController.modifyImage(imageIndex, resultImage, {}, function (modifyInfo) {
console.log('多张添加水印:修改' + imageIndex + '成功:') console.log('多张添加水印:修改' + imageIndex + '成功:')
that.urls[imageIndex].thumbnail = resultImage that.urls[imageIndex].thumbnail = resultImage
that.urls[imageIndex].base64 = resultImage that.urls[imageIndex].base64 = resultImage
@ -1249,9 +1277,9 @@ new Vue({
this.totalAngle = 0 this.totalAngle = 0
this.canvas.discardActiveObject() this.canvas.discardActiveObject()
let that = this let that = this
console.log('准备加载图像到画布:' + JSON.stringify(imageSrc)) // console.log('准备加载图像到画布:' + JSON.stringify(imageSrc))
new fabric.Image.fromURL(imageSrc ? imageSrc.base64 : null, function (image) { new fabric.Image.fromURL(imageSrc ? imageSrc.base64 : null, function (image) {
console.log('加载图像image===' + image) // console.log('加载图像image===' + image)
let result = imageSrc ? image : null let result = imageSrc ? image : null
that.image = result that.image = result
that.canvas.add(image) that.canvas.add(image)
@ -1452,7 +1480,7 @@ new Vue({
let firstPath = info.image_path_list[0] let firstPath = info.image_path_list[0]
let secondPath = info.image_path_list[1] let secondPath = info.image_path_list[1]
that.WebScanController.modifyImage(currentIndex, secondBase64, function (info) { that.WebScanController.modifyImage(currentIndex, secondBase64, {}, function (info) {
console.log('图像拆分:第二张修改成功...') console.log('图像拆分:第二张修改成功...')
that.urls[currentIndex] = { that.urls[currentIndex] = {
base64: secondBase64, base64: secondBase64,
@ -1886,7 +1914,7 @@ new Vue({
console.log('save image dataUrl:' + dataUrl) console.log('save image dataUrl:' + dataUrl)
this.WebScanController.modifyImage(this.selectImageObj.index, dataUrl, function (info) { this.WebScanController.modifyImage(this.selectImageObj.index, dataUrl, {}, function (info) {
console.log('修改图像成功:' + JSON.stringify(info)) console.log('修改图像成功:' + JSON.stringify(info))
that.eleUnloadding() that.eleUnloadding()
that.undoStack.length = 0; that.undoStack.length = 0;
@ -2073,7 +2101,7 @@ new Vue({
console.log('save image dataUrl:' + dataUrl) console.log('save image dataUrl:' + dataUrl)
that.WebScanController.modifyImage(currentIndex, dataUrl, function (info) { that.WebScanController.modifyImage(currentIndex, dataUrl, {}, function (info) {
that.eleUnloadding() that.eleUnloadding()
console.log('修改成功') console.log('修改成功')
that.urls[currentIndex].base64 = dataUrl that.urls[currentIndex].base64 = dataUrl

View File

@ -9,7 +9,7 @@
</head> </head>
<body> <body>
<el-container id="container"> <el-container id="container" style="min-width: 1500px;min-height: 900px">
<el-aside width="195px" class="aside" v-loading.fullscreen.lock="fullscreenLoading" <el-aside width="195px" class="aside" v-loading.fullscreen.lock="fullscreenLoading"
element-loading-text="拼命加载中" element-loading-text="拼命加载中"
element-loading-spinner="el-icon-loading" element-loading-spinner="el-icon-loading"
@ -59,39 +59,41 @@
<el-header height="auto" v-if="!debugMode"> <el-header height="auto" v-if="!debugMode">
<div class="menuContainer"> <div class="menuContainer">
<div style="display: inline-block;float: left;margin: 14px 0px;cursor: pointer"> <!-- <ul style="width: 100%;height: 100%;overflow-x: scroll;float: left;padding-left: 0px">-->
<div class="iconContainer" @click="openDeviceSetting">
<div class="menuStyle" @click="openDeviceSetting()">
<div class="iconContainer">
<img src="images/icons/setup.png"/> <img src="images/icons/setup.png"/>
</div> </div>
<div class="menus">扫描设定</div> <div class="menu">扫描设定</div>
</div> </div>
<ul v-show="deviceOpened" style="float: left;padding-left: 0px">
<li @click="startScan()"> <div v-show="deviceOpened">
<div class="menuStyle" @click="startScan()">
<div class="iconContainer"> <div class="iconContainer">
<img src="images/icons/scan.png"/> <img src="images/icons/scan.png"/>
</div> </div>
<div class="menu">顺序扫描</div> <div class="menu">顺序扫描</div>
</li> </div>
<li @click="stopScan()"> <div class="menuStyle" @click="stopScan()">
<div class="iconContainer"> <div class="iconContainer">
<img src="images/icons/stop.png"/> <img src="images/icons/stop.png"/>
</div> </div>
<div class="menu">停止扫描</div> <div class="menu">停止扫描</div>
</li> </div>
<li @click="insertScan()"> <div class="menuStyle" @click="insertScan()">
<div class="iconContainer"> <div class="iconContainer">
<img src="images/icons/insert-scan.png"/> <img src="images/icons/insert-scan.png"/>
</div> </div>
<div class="menu">插入扫描</div> <div class="menu">插入扫描</div>
</li> </div>
<li @click="coverScan()"> <div class="menuStyle" @click="coverScan()">
<div class="iconContainer"> <div class="iconContainer">
<img src="images/icons/cover-scan.png"/> <img src="images/icons/cover-scan.png"/>
</div> </div>
<div class="menu">覆盖扫描</div> <div class="menu">覆盖扫描</div>
</li> </div>
<li> <div class="menuStyle">
<el-popover <el-popover
placement="bottom" placement="bottom"
width="360" width="360"
@ -130,45 +132,45 @@
<div class="menu">选择批次</div> <div class="menu">选择批次</div>
</div> </div>
</el-popover> </el-popover>
</li> </div>
<li @click="deleteSelectedImage()"> <div class="menuStyle" @click="deleteSelectedImage()">
<div class="iconContainer"> <div class="iconContainer">
<img src="images/icons/delImage.png"/> <img src="images/icons/delImage.png"/>
</div> </div>
<div class="menu">删除图片</div> <div class="menu">删除图片</div>
</li> </div>
<li @click="exchangeImage()"> <div class="menuStyle" @click="exchangeImage()">
<div class="iconContainer"> <div class="iconContainer">
<img src="images/icons/exchange.png" style="height:31px"/> <img src="images/icons/exchange.png" style="height:31px"/>
</div> </div>
<div class="menu">图片互换</div> <div class="menu">图片互换</div>
</li> </div>
<li @click="mergeHorizontal(true)"> <div class="menuStyle" @click="mergeHorizontal(true)">
<div class="iconContainer"> <div class="iconContainer">
<img src="images/icons/merge-horizontal.png"/> <img src="images/icons/merge-horizontal.png"/>
</div> </div>
<div class="menu">水平合并</div> <div class="menu">水平合并</div>
</li> </div>
<li @click="mergeHorizontal(false)"> <div class="menuStyle" @click="mergeHorizontal(false)">
<div class="iconContainer"> <div class="iconContainer">
<img src="images/icons/merge-vertical.png" style="height:31px"/> <img src="images/icons/merge-vertical.png" style="height:31px"/>
</div> </div>
<div class="menu">垂直合并</div> <div class="menu">垂直合并</div>
</li> </div>
<li @click="bookSort()"> <div class="menuStyle" @click="bookSort()">
<div class="iconContainer"> <div class="iconContainer">
<img src="images/icons/book_sort.png" style="height:31px"/> <img src="images/icons/book_sort.png" style="height:31px"/>
</div> </div>
<div class="menu">书籍自动排序</div> <div class="menu">书籍自动排序</div>
</li> </div>
<li @click="showBatchMarkConfigure=true"> <div class="menuStyle" @click="showBatchMarkConfigure=true">
<div class="iconContainer"> <div class="iconContainer">
<img src="images/icons/add-watermark.png" style="height:31px"/> <img src="images/icons/add-watermark.png" style="height:31px"/>
</div> </div>
<div class="menu">批量添加水印</div> <div class="menu">批量添加水印</div>
</li> </div>
<li> <div class="menuStyle">
<el-popover <el-popover
placement="bottom" placement="bottom"
@ -208,26 +210,27 @@
<div class="menu">文件导出</div> <div class="menu">文件导出</div>
</div> </div>
</el-popover> </el-popover>
</li> </div>
<li v-if="uploadConfig.upload_mode!=='none'" @click="uploadFile"> <div class="menuStyle" v-if="uploadConfig.upload_mode!=='none'" @click="uploadFile">
<div class="iconContainer"> <div class="iconContainer">
<img src="images/icons/upload.png" style="height:31px"/> <img src="images/icons/upload.png" style="height:31px"/>
</div> </div>
<div class="menu">一键上传</div> <div class="menu">一键上传</div>
</li> </div>
<li @click="clearBatch()"> <div class="menuStyle" @click="clearBatch()">
<div class="iconContainer"> <div class="iconContainer">
<img src="images/icons/delAll.png"/> <img src="images/icons/delAll.png"/>
</div> </div>
<div class="menu">清空列表</div> <div class="menu">清空列表</div>
</li> </div>
<li @click="clearGlobalFileSavePath()"> <div class="menuStyle" @click="clearGlobalFileSavePath()">
<div class="iconContainer"> <div class="iconContainer">
<img src="images/icons/delete-all.png"/> <img src="images/icons/delete-all.png"/>
</div> </div>
<div class="menu">清理全局文件保存目录</div> <div class="menu">清理全局文件保存目录</div>
</li> </div>
</ul> </div>
<!-- </ul>-->
</div> </div>
</el-header> </el-header>
<el-main> <el-main>