// 扫描仪操作对象
var Scanner = function() {
};
(function() {
Scanner.prototype = {
construct : Scanner,
// 私有属性
_parameter : {
'domId' : null, // 控件容器ID
'locationPath' : null, // 扫描文件的本地存储路径
'produceFilenameFunc' : null, // 生成扫描文件名称的函数体
'prefix' : 'XXX', // 生成文件的名称前缀
'saveType' : 1, // 生成文件的格式{int} 1:JPG, 2:Tif, 3:Pdf
'dpi' : 200, // 生成文件的dpi设置,默认150
'colorType' : 3, // 扫描影像色彩{int} 1=黑白, 2=灰度, 3=彩色
'isDoubleSide' : 2, // 是否开启双面扫描设置{int} 2=开启, 1=关闭
'isDelNullPage' : 1, // 是否开启去除空白页面{int} 1=开启, 2=关闭
'isRoteWord' : 1, // 是否开启识别文字方向{int} 1=开启 , 2=关闭
'isRectification' : 1, // 是否开启纠偏{int} 1=开启 ,2=关闭
//'srcFileFullPathArr' : new Array(), // 存放本次业务所拍摄的所有文档全路径的数组
'scannerCtrl' : null, // 扫描仪底层控制驱动
'fso' : new ActiveXObject('Scripting.FileSystemObject'), // JS文件操作对象
'scannerCtrlInitHtml' : '<%-- ActiveX控件对象 --%>'
+ ''
},
getParameter : function(key) {
return this._parameter[key];
},
setParameter : function(key, value) {
this._parameter[key] = value;
},
/**
* 【扫描】接口方法
*/
scan : function() {
this.setParameter("prefix", this._executeFunc(this.getParameter("produceFilenameFunc")));
// 进行扫描的参数设置
this._changeDPI(this.getParameter("dpi")); // 设置扫描质量dpi
this._changeSaveType(this.getParameter("saveType")); // 设置扫描影像的格式
this._changeColor(this.getParameter("colorType")); // 设置扫描影像色彩
this._changeDoubleSide(this.getParameter("isDoubleSide")); // 设置是否开启双面扫描设置
this._changeDelNullPage(this.getParameter("isDelNullPage")); // 设置是否开启去除空白页面
this._changeRoteWord(this.getParameter("isRoteWord")); // 设置是否开启识别文字方向
this._changeRectification(this.getParameter("isRectification")); // 设置是否开启纠偏
// 进行扫描的路径设置
this._changeSavePath(this.getParameter("locationPath")); // 设置扫描文件的存放路径
this._changePreFix(this.getParameter("prefix")); // 设置扫描文件的名称
var locationPath = this.getParameter("locationPath");
var flag = this._createDestSavePath(locationPath); // 创建文件存放路径是否成功标志
if(flag){
this._startScan();
}else{// 创建文件夹失败,导致目标文件夹不存在
alert("目标存放文件夹不存在!");
}
},
/**
* 【重新扫描】接口方法
* @introduction 点击【重新扫描】后,删除已有的扫描文件后再进行一次扫描。先调用控件提供的全部删除方法,后使用自身的删除私有方法
*/
rescan : function() {
this._dellAll(); // 调用控件的全部删除方法
this._deleteLocalTempFile(this._getPath()); // 调用自身的删除方法再次进行删除
// 再次进行扫描
this.scan();
},
/**
* 【获取文件路径】接口方法
*
* @return String[] 返回扫描文件在本地上的储存路径的数组
*/
getFilePath : function() {
return this._getPath();
},
/**
* 【设备状态初始化】公用方法
* @introduction 进入页面时触发的初始化动作
*/
initialization : function() {
//scanner._initSettingDiv();
},
/**
* 【设备状态反初始化】公用方法
* @introduction 离开页面是触发的反初始化动作
*/
deinitialization : function() {
this._dellAll(); // 删除所有的本地临时文件
this._deleteLocalTempFile(this._getPath()); // 调用自身的删除方法再次进行删除
},
/**
* 【打开设置窗口】接口方法
*
* @introduction
*/
openSetting : function() {
$('#settingDiv').fwwindow('open');
//