2022-06-17 02:51:29 +00:00
|
|
|
|
(function (window) {
|
|
|
|
|
const TAG = 'WebScanController:'
|
2024-03-27 01:29:09 +00:00
|
|
|
|
var Result = function (code, msg, data) {
|
2022-06-17 02:51:29 +00:00
|
|
|
|
this.code = code;
|
|
|
|
|
this.msg = msg;
|
|
|
|
|
this.data = data;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function WebScanController(options) {
|
|
|
|
|
|
|
|
|
|
if (options.wsUrl == '' || options.wsUrl == null || options.wsUrl == undefined) {
|
|
|
|
|
WebScanController.prototype.wsUrl = "ws://localhost:38999";
|
|
|
|
|
} else {
|
|
|
|
|
WebScanController.prototype.wsUrl = options.wsUrl;
|
|
|
|
|
}
|
|
|
|
|
WebScanController.prototype.wslicence = options.wslicence;
|
|
|
|
|
return WebScanController.prototype;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WebScanController.prototype = {
|
|
|
|
|
constructor: WebScanController,
|
|
|
|
|
|
|
|
|
|
/*****************************************扫描仪相关********************************************************************************/
|
2023-11-14 08:33:20 +00:00
|
|
|
|
isDeviceInit: function (callBack) {
|
|
|
|
|
const that = this
|
|
|
|
|
this.sendCommand({
|
|
|
|
|
func: "is_device_init",
|
|
|
|
|
iden: that.wslicence
|
|
|
|
|
}, callBack)
|
|
|
|
|
|
|
|
|
|
},
|
2022-06-17 02:51:29 +00:00
|
|
|
|
initDevice: function (callBack) {
|
|
|
|
|
const that = this
|
|
|
|
|
this.sendCommand({
|
|
|
|
|
func: "init_device",
|
|
|
|
|
iden: that.wslicence
|
|
|
|
|
}, callBack)
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
deinitDevices: function (callBack) {
|
|
|
|
|
const that = this
|
|
|
|
|
this.sendCommand({
|
|
|
|
|
func: "deinit_device",
|
|
|
|
|
iden: that.wslicence
|
|
|
|
|
}, callBack)
|
|
|
|
|
},
|
|
|
|
|
getDeviceNameList: function (callBack) {
|
|
|
|
|
const that = this
|
|
|
|
|
this.sendCommand({
|
|
|
|
|
func: "get_device_name_list",
|
|
|
|
|
iden: that.wslicence
|
|
|
|
|
}, callBack)
|
|
|
|
|
},
|
|
|
|
|
openDevice: function (device_name, callBack) {
|
|
|
|
|
const that = this
|
|
|
|
|
this.sendCommand({
|
|
|
|
|
func: "open_device",
|
|
|
|
|
iden: that.wslicence,
|
|
|
|
|
device_name: device_name
|
|
|
|
|
}, callBack)
|
|
|
|
|
},
|
|
|
|
|
closeDevice: function (callBack) {
|
|
|
|
|
const that = this
|
|
|
|
|
this.sendCommand({
|
|
|
|
|
func: "close_device",
|
|
|
|
|
iden: that.wslicence
|
|
|
|
|
}, callBack)
|
|
|
|
|
},
|
|
|
|
|
setScanParams: function (appendParams, callBack) {
|
|
|
|
|
const that = this
|
2024-03-27 01:29:09 +00:00
|
|
|
|
var fixedParams = {
|
2022-06-17 02:51:29 +00:00
|
|
|
|
func: "set_device_param",
|
|
|
|
|
iden: that.wslicence
|
|
|
|
|
}
|
|
|
|
|
fixedParams.device_param = appendParams
|
|
|
|
|
console.log('final set scan params:' + JSON.stringify(fixedParams))
|
|
|
|
|
this.sendCommand(fixedParams, callBack)
|
|
|
|
|
},
|
|
|
|
|
getScanParams: function (callBack) {
|
|
|
|
|
const that = this
|
|
|
|
|
this.sendCommand({
|
|
|
|
|
func: "get_device_param",
|
|
|
|
|
iden: that.wslicence
|
|
|
|
|
}, callBack)
|
|
|
|
|
},
|
|
|
|
|
resetScanParams: function (callBack) {
|
|
|
|
|
const that = this
|
|
|
|
|
this.sendCommand({
|
|
|
|
|
func: "reset_device_param",
|
|
|
|
|
iden: that.wslicence
|
|
|
|
|
}, callBack)
|
|
|
|
|
},
|
|
|
|
|
getCurrDeviceName: function (callBack) {
|
|
|
|
|
const that = this
|
|
|
|
|
this.sendCommand({
|
|
|
|
|
func: "get_curr_device_name",
|
|
|
|
|
iden: that.wslicence
|
|
|
|
|
}, callBack)
|
|
|
|
|
},
|
|
|
|
|
//开始扫描
|
|
|
|
|
startScan: function (callBack) {
|
|
|
|
|
const that = this
|
|
|
|
|
this.sendCommand({
|
|
|
|
|
func: "start_scan",
|
|
|
|
|
iden: that.wslicence,
|
|
|
|
|
get_base64: true
|
|
|
|
|
}, callBack)
|
|
|
|
|
},
|
|
|
|
|
stopScan: function (callBack) {
|
|
|
|
|
const that = this
|
|
|
|
|
this.sendCommand({
|
|
|
|
|
func: "stop_scan",
|
|
|
|
|
iden: that.wslicence
|
|
|
|
|
}, callBack)
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************基本接口********************************************************************************/
|
|
|
|
|
|
2024-03-27 01:29:09 +00:00
|
|
|
|
// getLocalPic(path, callBack) {
|
|
|
|
|
// var that = this
|
|
|
|
|
// const cmd = {
|
|
|
|
|
// func: "load_local_image",
|
|
|
|
|
// iden: that.wslicence,
|
|
|
|
|
// image_path: path
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// console.log(TAG, 'getLocalPic', JSON.parse(cmd))
|
|
|
|
|
// this.sendCommand(cmd, callBack)
|
|
|
|
|
// },
|
2022-06-17 02:51:29 +00:00
|
|
|
|
saveLocalPic(base64, callBack) {
|
|
|
|
|
const that = this
|
|
|
|
|
const cmd = {
|
|
|
|
|
func: "save_local_image",
|
|
|
|
|
iden: that.wslicence,
|
|
|
|
|
image_base64: base64
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
console.log(TAG, 'saveLocalPic', JSON.parse(cmd))
|
|
|
|
|
this.sendCommand(cmd, callBack)
|
|
|
|
|
},
|
|
|
|
|
//获取全局配置
|
|
|
|
|
getGlobalConfig: function (callBack) {
|
|
|
|
|
const that = this
|
|
|
|
|
this.sendCommand({
|
|
|
|
|
func: "get_global_config",
|
|
|
|
|
iden: that.wslicence
|
|
|
|
|
}, callBack)
|
|
|
|
|
},
|
|
|
|
|
//设置全局配置
|
|
|
|
|
setGlobalConfig: function (appendParams, callBack) {
|
|
|
|
|
const that = this
|
2024-03-27 01:29:09 +00:00
|
|
|
|
var fixedParams = {
|
2022-06-17 02:51:29 +00:00
|
|
|
|
func: "set_global_config",
|
|
|
|
|
iden: that.wslicence
|
|
|
|
|
}
|
|
|
|
|
const finalParams = Object.assign({}, appendParams, fixedParams)
|
|
|
|
|
console.log('final set global params:' + JSON.stringify(finalParams))
|
|
|
|
|
this.sendCommand(finalParams, callBack)
|
|
|
|
|
},
|
|
|
|
|
//加载本地图像
|
|
|
|
|
loadLocalImage: function (imagePath, callBack) {
|
|
|
|
|
const that = this
|
|
|
|
|
this.sendCommand({
|
|
|
|
|
func: "load_local_image",
|
|
|
|
|
iden: that.wslicence,
|
|
|
|
|
image_path: imagePath
|
|
|
|
|
}, callBack)
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
//保存本地图像
|
|
|
|
|
saveLocalImage: function (imageBase64, callBack) {
|
|
|
|
|
const that = this
|
|
|
|
|
this.sendCommand({
|
|
|
|
|
func: "save_local_image",
|
|
|
|
|
iden: that.wslicence,
|
|
|
|
|
image_base64: imageBase64
|
|
|
|
|
}, callBack)
|
|
|
|
|
},
|
|
|
|
|
//删除本地文件(为了安全,仅能删除后端生成的文件)
|
|
|
|
|
deleteLocalFile: function (filePath, callBack) {
|
|
|
|
|
const that = this
|
|
|
|
|
this.sendCommand({
|
|
|
|
|
func: "delete_local_file",
|
|
|
|
|
iden: that.wslicence,
|
|
|
|
|
file_path: filePath
|
|
|
|
|
}, callBack)
|
|
|
|
|
},
|
|
|
|
|
//清理全局文件保存目录(为了安全,只会删除后端生成的文件)
|
|
|
|
|
clearGlobalFileSavePath: function (callBack) {
|
|
|
|
|
const that = this
|
|
|
|
|
this.sendCommand({
|
|
|
|
|
func: "clear_global_file_save_path",
|
|
|
|
|
iden: that.wslicence
|
|
|
|
|
}, callBack)
|
|
|
|
|
},
|
|
|
|
|
//合成本地图像
|
|
|
|
|
mergeLocalImage: function (imagePathList, mode, align, getBase64, callBack) {
|
|
|
|
|
|
|
|
|
|
const that = this
|
|
|
|
|
this.sendCommand({
|
|
|
|
|
func: "merge_local_image",
|
|
|
|
|
iden: that.wslicence,
|
|
|
|
|
image_path_list: imagePathList,
|
|
|
|
|
mode: mode,
|
|
|
|
|
align: align,
|
|
|
|
|
interval: 0,
|
|
|
|
|
get_base64: getBase64
|
|
|
|
|
}, callBack)
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
//本地合成多张图像
|
|
|
|
|
localMakeMultiImage: function (imagePathList, format, tiffCompression, tiffJpegQuality, callBack) {
|
|
|
|
|
|
|
|
|
|
const that = this
|
|
|
|
|
this.sendCommand({
|
|
|
|
|
func: "local_make_multi_image",
|
|
|
|
|
iden: that.wslicence,
|
|
|
|
|
image_path_list: imagePathList,
|
|
|
|
|
format: format,
|
|
|
|
|
tiff_compression: tiffCompression,
|
|
|
|
|
tiff_jpeg_quality: tiffJpegQuality
|
|
|
|
|
}, callBack)
|
|
|
|
|
},
|
|
|
|
|
//拆分本地图像
|
|
|
|
|
splitLocalImage: function (imagePath, mode, location, callBack) {
|
|
|
|
|
const that = this
|
|
|
|
|
this.sendCommand({
|
|
|
|
|
func: "split_local_image",
|
|
|
|
|
iden: that.wslicence,
|
|
|
|
|
image_path: imagePath,
|
|
|
|
|
mode: mode,
|
2022-07-29 08:29:30 +00:00
|
|
|
|
location: location,
|
|
|
|
|
local_save: true,
|
|
|
|
|
get_base64: false
|
2022-06-17 02:51:29 +00:00
|
|
|
|
}, callBack)
|
|
|
|
|
},
|
|
|
|
|
//本地生成压缩文件
|
|
|
|
|
localMakeZipFile: function (imagePathList, callBack) {
|
|
|
|
|
|
|
|
|
|
const that = this
|
|
|
|
|
this.sendCommand({
|
|
|
|
|
func: "local_make_zip_file",
|
|
|
|
|
iden: that.wslicence,
|
2022-07-29 08:29:30 +00:00
|
|
|
|
file_path_list: imagePathList
|
2022-06-17 02:51:29 +00:00
|
|
|
|
}, callBack)
|
|
|
|
|
},
|
|
|
|
|
//本地图像纠偏
|
|
|
|
|
localImageDeskew: function (imagePath, callBack) {
|
|
|
|
|
|
|
|
|
|
const that = this
|
|
|
|
|
this.sendCommand({
|
|
|
|
|
func: "local_image_deskew",
|
|
|
|
|
iden: that.wslicence,
|
|
|
|
|
image_path: imagePath
|
|
|
|
|
}, callBack)
|
|
|
|
|
},
|
|
|
|
|
//上传本地文件
|
2022-07-29 08:29:30 +00:00
|
|
|
|
uploadLocalFile: function (filePath, uploadMode,
|
|
|
|
|
remoteFilePath, httpHost, httpPort, httpPath,
|
|
|
|
|
ftpUser, ftpPassword, ftpHost, ftpPort, callBack) {
|
2022-06-17 02:51:29 +00:00
|
|
|
|
|
|
|
|
|
const that = this
|
|
|
|
|
this.sendCommand({
|
|
|
|
|
func: "upload_local_file",
|
|
|
|
|
iden: that.wslicence,
|
|
|
|
|
file_path: filePath,
|
|
|
|
|
upload_mode: uploadMode,
|
2022-07-29 08:29:30 +00:00
|
|
|
|
remote_file_path: remoteFilePath,
|
|
|
|
|
http_host: httpHost,
|
|
|
|
|
http_port: httpPort,
|
|
|
|
|
http_path: httpPath,
|
|
|
|
|
ftp_user: ftpUser,
|
|
|
|
|
ftp_password: ftpPassword,
|
|
|
|
|
ftp_host: ftpHost,
|
|
|
|
|
ftp_port: ftpPort
|
2022-06-17 02:51:29 +00:00
|
|
|
|
}, callBack)
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
//本地图片添加水印
|
|
|
|
|
localImageAddWatermark: function (imagePath, text, textColor, textOpacity, textPos, marginRight,
|
|
|
|
|
marginBottom, locationX, locationY, fontName, fontSize, fontBold, fontUnderline,
|
|
|
|
|
fontItalic, fontStrikeout, getBase64,
|
|
|
|
|
callBack) {
|
|
|
|
|
|
|
|
|
|
const that = this
|
|
|
|
|
this.sendCommand({
|
|
|
|
|
func: "local_image_add_watermark",
|
|
|
|
|
iden: that.wslicence,
|
|
|
|
|
image_path: imagePath,
|
|
|
|
|
text: text,
|
|
|
|
|
text_color: textColor,
|
|
|
|
|
text_opacity: textOpacity,
|
|
|
|
|
text_pos: textPos,
|
|
|
|
|
margin_left: parseInt(marginLeft),
|
|
|
|
|
margin_top: parseInt(marginTop),
|
|
|
|
|
margin_right: parseInt(marginRight),
|
|
|
|
|
margin_bottom: parseInt(marginBottom),
|
|
|
|
|
location_x: parseInt(locationX),
|
|
|
|
|
location_y: parseInt(locationY),
|
|
|
|
|
font_name: fontName,
|
|
|
|
|
font_size: parseInt(fontSize),
|
|
|
|
|
font_bold: fontBold,
|
|
|
|
|
font_underline: fontUnderline,
|
|
|
|
|
font_italic: fontItalic,
|
|
|
|
|
font_strikeout: fontStrikeout,
|
2022-07-29 08:29:30 +00:00
|
|
|
|
local_save: true,
|
2022-06-17 02:51:29 +00:00
|
|
|
|
get_base64: getBase64
|
|
|
|
|
}, callBack)
|
|
|
|
|
|
|
|
|
|
},
|
2022-07-29 08:29:30 +00:00
|
|
|
|
//本地图像去污
|
|
|
|
|
localImageDecontamination: function (imagePath, mode, color, x, y, width, height, getBase64, callBack) {
|
|
|
|
|
|
|
|
|
|
const that = this
|
|
|
|
|
this.sendCommand({
|
|
|
|
|
func: "local_image_decontamination",
|
|
|
|
|
iden: that.wslicence,
|
|
|
|
|
image_path: imagePath,
|
|
|
|
|
mode: mode,
|
|
|
|
|
color: color,
|
|
|
|
|
x: x,
|
|
|
|
|
y: y,
|
|
|
|
|
width: width,
|
|
|
|
|
height: height,
|
|
|
|
|
local_save: true,
|
|
|
|
|
get_base64: getBase64
|
|
|
|
|
}, callBack)
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
//本地图像方向校正
|
|
|
|
|
localImageDirectionCorrect: function (imagePath, getBase64, callBack) {
|
|
|
|
|
|
|
|
|
|
const that = this
|
|
|
|
|
this.sendCommand({
|
|
|
|
|
func: "local_image_direction_correct",
|
|
|
|
|
iden: that.wslicence,
|
|
|
|
|
image_path: imagePath,
|
|
|
|
|
local_save: true,
|
|
|
|
|
get_base64: getBase64
|
|
|
|
|
}, callBack)
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
2022-06-17 02:51:29 +00:00
|
|
|
|
/*****************************************文件管理相关********************************************************************************/
|
|
|
|
|
|
|
|
|
|
//获取批次号列表
|
|
|
|
|
getBatchIdList: function (callBack) {
|
|
|
|
|
const that = this
|
|
|
|
|
this.sendCommand({
|
|
|
|
|
func: "get_batch_id_list",
|
|
|
|
|
iden: that.wslicence
|
|
|
|
|
}, callBack)
|
|
|
|
|
},
|
|
|
|
|
//打开批次(后端启动后默认打开最近批次,没有最近批次则会新建default批次并打开)
|
|
|
|
|
openBatch: function (batchId, callBack) {
|
|
|
|
|
const that = this
|
|
|
|
|
this.sendCommand({
|
|
|
|
|
func: "open_batch",
|
|
|
|
|
iden: that.wslicence,
|
|
|
|
|
batch_id: batchId + ""
|
|
|
|
|
}, callBack)
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
//删除批次
|
|
|
|
|
deleteBatch: function (batchId, callBack) {
|
|
|
|
|
const that = this
|
|
|
|
|
this.sendCommand({
|
|
|
|
|
func: "delete_batch",
|
|
|
|
|
iden: that.wslicence,
|
|
|
|
|
batch_id: batchId + ""// 批次id,不能是当前批次
|
|
|
|
|
}, callBack)
|
|
|
|
|
},
|
|
|
|
|
//新建批次(新建批次到列表尾部并打开该批次)
|
|
|
|
|
createNewBatch: function (batchId, callBack) {
|
|
|
|
|
const that = this
|
|
|
|
|
this.sendCommand({
|
|
|
|
|
func: "new_batch",
|
|
|
|
|
iden: that.wslicence,
|
|
|
|
|
batch_id: batchId + ""
|
|
|
|
|
}, callBack)
|
|
|
|
|
},
|
|
|
|
|
//获取当前批次号
|
|
|
|
|
getCurrBatchId: function (callBack) {
|
|
|
|
|
const that = this
|
|
|
|
|
this.sendCommand({
|
|
|
|
|
func: "get_curr_batch_id",
|
|
|
|
|
iden: that.wslicence
|
|
|
|
|
}, callBack)
|
|
|
|
|
},
|
|
|
|
|
//修改批次号
|
|
|
|
|
modifyBatchId: function (batchId, newBatchId, callBack) {
|
|
|
|
|
const that = this
|
|
|
|
|
this.sendCommand({
|
|
|
|
|
func: "modify_batch_id",
|
|
|
|
|
iden: that.wslicence,
|
|
|
|
|
batch_id: batchId,
|
|
|
|
|
new_batch_id: newBatchId
|
|
|
|
|
}, callBack)
|
|
|
|
|
},
|
|
|
|
|
//加载图像缩略图列表
|
|
|
|
|
getImageThumbnailList: function (callBack) {
|
|
|
|
|
const that = this
|
|
|
|
|
this.sendCommand({
|
|
|
|
|
func: "get_image_thumbnail_list",
|
|
|
|
|
iden: that.wslicence
|
|
|
|
|
}, callBack)
|
|
|
|
|
},
|
|
|
|
|
//获取图像数量
|
|
|
|
|
getImageCount: function (callBack) {
|
|
|
|
|
const that = this
|
|
|
|
|
this.sendCommand({
|
|
|
|
|
func: "get_image_count",
|
|
|
|
|
iden: that.wslicence
|
|
|
|
|
}, callBack)
|
|
|
|
|
},
|
|
|
|
|
//绑定文件夹
|
|
|
|
|
bindFolder: function (folder, callBack) {
|
|
|
|
|
|
|
|
|
|
const that = this
|
|
|
|
|
this.sendCommand({
|
|
|
|
|
func: "bind_folder",
|
|
|
|
|
iden: that.wslicence,
|
|
|
|
|
folder: folder,
|
|
|
|
|
name_mode: "order",
|
|
|
|
|
name_width: 4,
|
|
|
|
|
name_base: 0
|
|
|
|
|
}, callBack)
|
|
|
|
|
},
|
|
|
|
|
//停止绑定文件夹
|
|
|
|
|
stopBindFolder: function (callBack) {
|
|
|
|
|
const that = this
|
|
|
|
|
this.sendCommand({
|
|
|
|
|
func: "stop_bind_folder",
|
|
|
|
|
iden: that.wslicence,
|
|
|
|
|
}, callBack)
|
|
|
|
|
},
|
|
|
|
|
//加载图像
|
|
|
|
|
loadImage: function (imageIndex, callBack) {
|
2024-03-27 01:29:09 +00:00
|
|
|
|
|
2022-06-17 02:51:29 +00:00
|
|
|
|
this.sendCommand({
|
|
|
|
|
func: "load_image",
|
|
|
|
|
iden: imageIndex + "",
|
|
|
|
|
image_index: imageIndex
|
|
|
|
|
}, callBack)
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
//保存图像
|
|
|
|
|
saveImage: function (imageIndex, callBack) {
|
|
|
|
|
const that = this
|
|
|
|
|
this.sendCommand({
|
|
|
|
|
func: "save_image",
|
|
|
|
|
iden: that.wslicence,
|
|
|
|
|
image_index: imageIndex
|
|
|
|
|
}, callBack)
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
//插入本地图像(需返回成功后前端缩略图才能作相应的UI修改)
|
2023-02-28 07:18:06 +00:00
|
|
|
|
insertLocalImage: function (imagePath, insertIndex, idenInfo, callBack) {
|
2023-11-14 08:33:20 +00:00
|
|
|
|
console.log('insertLocalImage insertIndex:' + insertIndex + ' imagePath:' + imagePath + ' ')
|
2022-06-17 02:51:29 +00:00
|
|
|
|
const that = this
|
|
|
|
|
this.sendCommand({
|
|
|
|
|
func: "insert_local_image",
|
2023-02-28 07:18:06 +00:00
|
|
|
|
iden: JSON.stringify(idenInfo),
|
2022-06-17 02:51:29 +00:00
|
|
|
|
image_path: imagePath,
|
|
|
|
|
insert_pos: insertIndex,//插入位置,-1表示最后
|
|
|
|
|
image_tag: ''//标签名,可以为空
|
|
|
|
|
}, callBack)
|
|
|
|
|
},
|
|
|
|
|
//插入图像
|
|
|
|
|
insertImage: function (imageBase64, insertIndex, callBack) {
|
|
|
|
|
const that = this
|
|
|
|
|
this.sendCommand({
|
|
|
|
|
func: "insert_image",
|
|
|
|
|
iden: that.wslicence,
|
|
|
|
|
image_base64: imageBase64,
|
|
|
|
|
insert_pos: insertIndex,//插入位置,-1表示最后
|
|
|
|
|
image_tag: ''//标签名,可以为空
|
|
|
|
|
}, callBack)
|
|
|
|
|
},
|
|
|
|
|
//修改图像标签
|
|
|
|
|
modifyImageTag: function (imageIndexList, imageTagList, callBack) {
|
|
|
|
|
const that = this
|
|
|
|
|
this.sendCommand({
|
|
|
|
|
func: "modify_image_tag",
|
|
|
|
|
iden: that.wslicence,
|
|
|
|
|
image_index_list: imageIndexList,
|
|
|
|
|
image_tag_list: imageTagList
|
|
|
|
|
}, callBack)
|
|
|
|
|
},
|
|
|
|
|
//删除图像
|
|
|
|
|
deleteImage: function (imageIndexList, callBack) {
|
|
|
|
|
|
|
|
|
|
const that = this
|
|
|
|
|
this.sendCommand({
|
|
|
|
|
func: "delete_image",
|
|
|
|
|
iden: that.wslicence,
|
|
|
|
|
image_index_list: imageIndexList
|
|
|
|
|
}, callBack)
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
//清理图像列表
|
|
|
|
|
clearImageList: function (callBack) {
|
|
|
|
|
|
|
|
|
|
const that = this
|
|
|
|
|
this.sendCommand({
|
|
|
|
|
func: "clear_image_list",
|
|
|
|
|
iden: that.wslicence
|
|
|
|
|
}, callBack)
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
//修改图像
|
2023-02-28 07:18:06 +00:00
|
|
|
|
modifyImage: function (imageIndex, imageBase64, idenInfo, callBack) {
|
2023-11-14 08:33:20 +00:00
|
|
|
|
console.log('modifyImage imageIndex:' + imageIndex)
|
2022-06-17 02:51:29 +00:00
|
|
|
|
const that = this
|
|
|
|
|
this.sendCommand({
|
|
|
|
|
func: "modify_image",
|
2023-02-28 07:18:06 +00:00
|
|
|
|
iden: idenInfo == null ? that.wslicence : JSON.stringify(idenInfo),
|
2022-06-17 02:51:29 +00:00
|
|
|
|
image_index: imageIndex,
|
|
|
|
|
image_base64: imageBase64
|
|
|
|
|
}, callBack)
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
//使用本地图像修改图像
|
|
|
|
|
modifyImageByLocal: function (imageIndex, imagePath, callBack) {
|
|
|
|
|
const that = this
|
|
|
|
|
this.sendCommand({
|
|
|
|
|
func: "modify_image_by_local",
|
|
|
|
|
iden: that.wslicence,
|
|
|
|
|
image_index: imageIndex,
|
|
|
|
|
image_path: imagePath
|
|
|
|
|
}, callBack)
|
|
|
|
|
},
|
|
|
|
|
//移动图像
|
|
|
|
|
moveImage: function (imageIndexList, target, callBack) {
|
|
|
|
|
|
|
|
|
|
const that = this
|
|
|
|
|
this.sendCommand({
|
|
|
|
|
func: "move_image",
|
|
|
|
|
iden: that.wslicence,
|
|
|
|
|
image_index_list: imageIndexList,
|
|
|
|
|
mode: 'index',
|
|
|
|
|
target: target
|
|
|
|
|
}, callBack)
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
//图像书籍排序
|
|
|
|
|
imageBookSort: function (callBack) {
|
|
|
|
|
const that = this
|
|
|
|
|
this.sendCommand({
|
|
|
|
|
func: "image_book_sort",
|
|
|
|
|
iden: that.wslicence
|
|
|
|
|
}, callBack)
|
|
|
|
|
},
|
|
|
|
|
//合成图像
|
|
|
|
|
mergeImage: function (imageIndexList, mode, align, getBase64, callBack) {
|
|
|
|
|
const that = this
|
|
|
|
|
this.sendCommand({
|
|
|
|
|
func: "merge_image",
|
|
|
|
|
iden: that.wslicence,
|
|
|
|
|
image_index_list: imageIndexList,
|
|
|
|
|
mode: mode,
|
|
|
|
|
align: align,
|
|
|
|
|
interval: 0,
|
|
|
|
|
get_base64: getBase64
|
|
|
|
|
}, callBack)
|
|
|
|
|
},
|
|
|
|
|
//合成多张图像
|
|
|
|
|
makeMultiImage: function (imageIndexList, format, callBack) {
|
|
|
|
|
const that = this
|
2024-03-27 01:29:09 +00:00
|
|
|
|
var msg = {
|
2022-06-17 02:51:29 +00:00
|
|
|
|
func: "make_multi_image",
|
|
|
|
|
iden: that.wslicence,
|
|
|
|
|
image_index_list: imageIndexList,
|
|
|
|
|
format: format,
|
|
|
|
|
tiff_compression: 'none',
|
|
|
|
|
tiff_jpeg_quality: 80,
|
|
|
|
|
get_base64: true
|
|
|
|
|
}
|
|
|
|
|
this.sendCommand(msg, callBack)
|
|
|
|
|
},
|
|
|
|
|
//交换图片
|
|
|
|
|
exchangeImage: function (index1, index2, callBack) {
|
|
|
|
|
const that = this
|
|
|
|
|
this.sendCommand({
|
|
|
|
|
func: "exchange_image",
|
|
|
|
|
iden: that.wslicence,
|
|
|
|
|
image_index_1: index1,
|
|
|
|
|
image_index_2: index2
|
|
|
|
|
}, callBack)
|
|
|
|
|
},
|
|
|
|
|
//拆分图像
|
|
|
|
|
splitImage: function (imageIndex, mode, location, callBack) {
|
|
|
|
|
|
|
|
|
|
const that = this
|
|
|
|
|
this.sendCommand({
|
|
|
|
|
func: "split_image",
|
|
|
|
|
iden: that.wslicence,
|
|
|
|
|
image_index: imageIndex,
|
|
|
|
|
mode: mode,
|
|
|
|
|
location: location,
|
|
|
|
|
get_base64: true
|
|
|
|
|
}, callBack)
|
|
|
|
|
},
|
|
|
|
|
//压缩图像
|
|
|
|
|
makeZipFile: function (imageIndexList, callBack) {
|
|
|
|
|
|
|
|
|
|
const that = this
|
|
|
|
|
this.sendCommand({
|
|
|
|
|
func: "make_zip_file",
|
|
|
|
|
iden: that.wslicence,
|
|
|
|
|
image_index_list: imageIndexList,
|
|
|
|
|
get_base64: true
|
|
|
|
|
}, callBack)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
//图像纠偏
|
|
|
|
|
imageDeskew: function (imageIndex, getBase64, callBack) {
|
|
|
|
|
|
|
|
|
|
const that = this
|
|
|
|
|
this.sendCommand({
|
|
|
|
|
func: "image_deskew",
|
|
|
|
|
iden: that.wslicence,
|
|
|
|
|
image_index: imageIndex,
|
|
|
|
|
get_base64: getBase64
|
|
|
|
|
}, callBack)
|
|
|
|
|
},
|
|
|
|
|
//图片添加水印
|
|
|
|
|
imageAddWatermark: function (imageIndex, markInfo, getBase64,
|
|
|
|
|
callBack) {
|
|
|
|
|
|
|
|
|
|
const that = this
|
|
|
|
|
|
2024-03-27 01:29:09 +00:00
|
|
|
|
var params = {
|
2022-06-17 02:51:29 +00:00
|
|
|
|
func: "image_add_watermark",
|
|
|
|
|
iden: that.wslicence,
|
|
|
|
|
image_index: imageIndex,
|
|
|
|
|
text: markInfo.text,
|
|
|
|
|
text_color: markInfo.text_color,
|
|
|
|
|
text_opacity: markInfo.text_opacity,
|
|
|
|
|
text_pos: markInfo.text_pos,
|
|
|
|
|
margin_left: parseInt(markInfo.margin_left),
|
|
|
|
|
margin_top: parseInt(markInfo.margin_top),
|
|
|
|
|
margin_right: parseInt(markInfo.margin_right),
|
|
|
|
|
margin_bottom: parseInt(markInfo.margin_bottom),
|
|
|
|
|
location_x: parseInt(markInfo.location_x),
|
|
|
|
|
location_y: parseInt(markInfo.location_y),
|
|
|
|
|
font_name: markInfo.font_name,
|
|
|
|
|
font_size: parseInt(markInfo.font_size),
|
|
|
|
|
font_bold: markInfo.font_bold,
|
|
|
|
|
font_underline: markInfo.font_underline,
|
|
|
|
|
font_italic: markInfo.font_italic,
|
|
|
|
|
font_strikeout: markInfo.font_strikeout,
|
|
|
|
|
get_base64: getBase64
|
|
|
|
|
}
|
|
|
|
|
console.log('添加水印:params===' + JSON.stringify(params))
|
|
|
|
|
|
|
|
|
|
this.sendCommand(params, callBack)
|
|
|
|
|
|
|
|
|
|
},
|
2022-07-29 08:29:30 +00:00
|
|
|
|
//图像去污
|
|
|
|
|
imageDecontamination: function (imageIndex, mode, color, x, y, width, height, getBase64,
|
|
|
|
|
callBack) {
|
|
|
|
|
|
|
|
|
|
const that = this
|
|
|
|
|
|
2024-03-27 01:29:09 +00:00
|
|
|
|
var params = {
|
2022-07-29 08:29:30 +00:00
|
|
|
|
func: "image_decontamination",
|
|
|
|
|
iden: that.wslicence,
|
|
|
|
|
image_index: imageIndex,
|
|
|
|
|
mode: mode,
|
|
|
|
|
color: color,
|
|
|
|
|
x: x,
|
|
|
|
|
y: y,
|
|
|
|
|
width: width,
|
|
|
|
|
height: height,
|
|
|
|
|
local_save: true,
|
|
|
|
|
get_base64: getBase64
|
|
|
|
|
}
|
|
|
|
|
this.sendCommand(params, callBack)
|
|
|
|
|
},
|
2024-03-28 05:32:33 +00:00
|
|
|
|
//背景消除
|
|
|
|
|
imageFadebkColor: function (imageIndex, localSave, getBase64,
|
|
|
|
|
callBack) {
|
|
|
|
|
const that = this
|
|
|
|
|
|
|
|
|
|
var params = {
|
|
|
|
|
func: "image_fade_bkcolor",
|
|
|
|
|
iden: that.wslicence,
|
|
|
|
|
image_index: imageIndex,
|
|
|
|
|
local_save: localSave,
|
|
|
|
|
get_base64: getBase64
|
|
|
|
|
}
|
|
|
|
|
this.sendCommand(params, callBack)
|
|
|
|
|
},
|
|
|
|
|
//图像二值化
|
|
|
|
|
imageBinarization: function (imageIndex, localSave, getBase64,
|
|
|
|
|
callBack) {
|
|
|
|
|
const that = this
|
|
|
|
|
|
|
|
|
|
var params = {
|
|
|
|
|
func: "image_binarization",
|
|
|
|
|
iden: that.wslicence,
|
|
|
|
|
image_index: imageIndex,
|
|
|
|
|
local_save: localSave,//是否保存到本地,默认保存
|
|
|
|
|
get_base64: getBase64// 是否获取base64, 默认不获取
|
|
|
|
|
}
|
|
|
|
|
this.sendCommand(params, callBack)
|
|
|
|
|
},
|
|
|
|
|
//图像调整色彩
|
|
|
|
|
imageAdjustColors: function (imageIndex, brightness, contrast, gamma, localSave, getBase64,
|
|
|
|
|
callBack) {
|
|
|
|
|
const that = this
|
|
|
|
|
|
|
|
|
|
var params = {
|
|
|
|
|
func: "image_adjust_colors",
|
|
|
|
|
iden: that.wslicence,
|
|
|
|
|
image_index: imageIndex,
|
|
|
|
|
brightness: brightness,// 亮度,取值-255值255之间
|
|
|
|
|
contrast: contrast,// 饱和度,取值-127至127之间
|
|
|
|
|
gamma: gamma,// 伽马,取值0.1值5.0之间
|
|
|
|
|
local_save: localSave,//是否保存到本地,默认保存
|
|
|
|
|
get_base64: getBase64// 是否获取base64, 默认不获取
|
|
|
|
|
}
|
|
|
|
|
this.sendCommand(params, callBack)
|
|
|
|
|
},
|
2022-07-29 08:29:30 +00:00
|
|
|
|
//图像方向校正
|
|
|
|
|
imageDirectionCorrect: function (imageIndex, getBase64,
|
|
|
|
|
callBack) {
|
|
|
|
|
|
|
|
|
|
const that = this
|
|
|
|
|
|
2024-03-27 01:29:09 +00:00
|
|
|
|
var params = {
|
2022-07-29 08:29:30 +00:00
|
|
|
|
func: "image_direction_correct",
|
|
|
|
|
iden: that.wslicence,
|
|
|
|
|
image_index: imageIndex,
|
|
|
|
|
local_save: true,
|
|
|
|
|
get_base64: getBase64
|
|
|
|
|
}
|
|
|
|
|
this.sendCommand(params, callBack)
|
|
|
|
|
},
|
|
|
|
|
uploadImage: function (imageIndex, uploadMode,
|
|
|
|
|
remoteFilePath, httpHost, httpPort, httpPath,
|
|
|
|
|
ftpUser, ftpPassword, ftpHost, ftpPort, callBack) {
|
|
|
|
|
|
|
|
|
|
const that = this
|
|
|
|
|
this.sendCommand({
|
|
|
|
|
func: "upload_image",
|
|
|
|
|
iden: that.wslicence,
|
|
|
|
|
image_index: imageIndex,
|
|
|
|
|
upload_mode: uploadMode,
|
|
|
|
|
remote_file_path: remoteFilePath,
|
|
|
|
|
http_host: httpHost,
|
|
|
|
|
http_port: httpPort,
|
|
|
|
|
http_path: httpPath,
|
|
|
|
|
ftp_user: ftpUser,
|
|
|
|
|
ftp_password: ftpPassword,
|
|
|
|
|
ftp_host: ftpHost,
|
|
|
|
|
ftp_port: ftpPort
|
|
|
|
|
}, callBack)
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
2022-06-17 02:51:29 +00:00
|
|
|
|
/*****************************************socket相关********************************************************************************/
|
|
|
|
|
callBackList: {}
|
|
|
|
|
,
|
|
|
|
|
addCallBack: function (key, listener) {
|
|
|
|
|
this.callBackList[key] = listener;
|
|
|
|
|
},
|
|
|
|
|
removeCallBack: function (key) {
|
|
|
|
|
delete this.callBackList[key];
|
|
|
|
|
},
|
|
|
|
|
getCallBack: function (key) {
|
|
|
|
|
return this.callBackList[key];
|
|
|
|
|
},
|
|
|
|
|
sendCommand: function (json, callBackListener) {
|
|
|
|
|
if (json.func && callBackListener) {
|
|
|
|
|
this.addCallBack(json.func, callBackListener)
|
|
|
|
|
}
|
|
|
|
|
this.SocketClient.send(JSON.stringify(json))
|
|
|
|
|
},
|
|
|
|
|
//初始化socketIO
|
|
|
|
|
initSocketIo: function (socketCallBack) {
|
|
|
|
|
this.socketCallBacks = socketCallBack
|
|
|
|
|
console.log(TAG, "initSocketIo ===============" + 'ws:' + this.wsUrl);
|
|
|
|
|
|
|
|
|
|
this.SocketClient = new WebSocket(this.wsUrl);
|
|
|
|
|
this.SocketClient.onopen = function (msg) {
|
|
|
|
|
console.log(TAG, "connect onopen")
|
|
|
|
|
socketCallBack(new Result(SOCKET_CONNECTED, "", null))
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
this.SocketClient.onmessage = function (event) {
|
2023-11-14 08:33:20 +00:00
|
|
|
|
// console.log(TAG, "connect onmessage data:" + event.data)
|
2022-06-17 02:51:29 +00:00
|
|
|
|
if (event && event.data) {
|
|
|
|
|
socketCallBack(new Result(SOCKET_EVENT, "", event.data))
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
this.SocketClient.onclose = function (msg) {
|
|
|
|
|
console.log(TAG, "connect onclose:" + JSON.stringify(msg))
|
|
|
|
|
socketCallBack(new Result(SOCKET_DISCONNECTED, "", msg))
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
disconnect: function () {
|
|
|
|
|
if (this.SocketClient) {
|
|
|
|
|
this.SocketClient.close()
|
|
|
|
|
this.SocketClient = null
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
window.WebScanController = WebScanController;
|
|
|
|
|
})(window);
|