unify-external-plugin-platform 0.0.3-82 → 0.0.3-85

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -91013,8 +91013,8 @@ id_card_reader_button.install = Vue => {
91013
91013
  Vue.component(id_card_reader_button.name, id_card_reader_button);
91014
91014
  };
91015
91015
  /* harmony default export */ var id_card_reader_id_card_reader_button = (id_card_reader_button);
91016
- ;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-85.use[1]!./node_modules/@vue/cli-service/node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[4]!./node_modules/@vue/cli-service/node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./packages/scanner/scanner-nko/src/scanner-nko.vue?vue&type=template&id=2b36bc1b&
91017
- var scanner_nkovue_type_template_id_2b36bc1b_render = function render() {
91016
+ ;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-85.use[1]!./node_modules/@vue/cli-service/node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[4]!./node_modules/@vue/cli-service/node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./packages/scanner/scanner-nko/src/scanner-nko.vue?vue&type=template&id=09b27ab8&
91017
+ var scanner_nkovue_type_template_id_09b27ab8_render = function render() {
91018
91018
  var _vm = this,
91019
91019
  _c = _vm._self._c;
91020
91020
  return _c('el-container', {
@@ -91190,7 +91190,7 @@ var scanner_nkovue_type_template_id_2b36bc1b_render = function render() {
91190
91190
  "value": item
91191
91191
  }
91192
91192
  });
91193
- }), 1)], 1)], 1), _c('el-form', {
91193
+ }), 1)], 1)], 1), _vm.brand === 'nko' ? _c('el-form', {
91194
91194
  attrs: {
91195
91195
  "model": _vm.scanConfig,
91196
91196
  "label-position": "right",
@@ -91219,7 +91219,7 @@ var scanner_nkovue_type_template_id_2b36bc1b_render = function render() {
91219
91219
  "value": item
91220
91220
  }
91221
91221
  });
91222
- }), 1)], 1)], 1), _c('div', {
91222
+ }), 1)], 1)], 1) : _vm._e(), _c('div', {
91223
91223
  staticClass: "text-right"
91224
91224
  }, [_c('el-button', {
91225
91225
  attrs: {
@@ -91344,7 +91344,7 @@ var scanner_nkovue_type_template_id_2b36bc1b_render = function render() {
91344
91344
  }
91345
91345
  }, [_vm._v("上传")])], 1)])], 1)], 1);
91346
91346
  };
91347
- var scanner_nkovue_type_template_id_2b36bc1b_staticRenderFns = [];
91347
+ var scanner_nkovue_type_template_id_09b27ab8_staticRenderFns = [];
91348
91348
 
91349
91349
  // EXTERNAL MODULE: ./node_modules/core-js/modules/web.dom-exception.stack.js
91350
91350
  var web_dom_exception_stack = __webpack_require__(2801);
@@ -91641,9 +91641,304 @@ _defineProperty(NkoService, "scanWebSocketUrl", 'ws://127.0.0.1:51818');
91641
91641
  _defineProperty(NkoService, "ws", void 0);
91642
91642
  _defineProperty(NkoService, "requestStore", []);
91643
91643
  _defineProperty(NkoService, "fileList", []);
91644
+ ;// CONCATENATED MODULE: ./packages/service/external-plugins/pantum-plugin-http.service.ts
91645
+
91646
+
91647
+ /**
91648
+ * 奔图扫描仪(Pantum Scan SDK)
91649
+ *
91650
+ * 奔图 SDK 提供本地 HTTP 服务(dss)完成扫描:
91651
+ * - http :http://127.0.0.1:3883
91652
+ * - https :https://127.0.0.1:3884(证书为服务目录下 cert/cert.crt,需重启服务生效)
91653
+ *
91654
+ * 生产环境存在 http / https 两种部署,页面为 https 时请求 http 接口会被浏览器
91655
+ * 当作混合内容拦截,故这里依据当前页面协议自动选择对应端口。
91656
+ *
91657
+ * 对外接口形态与 NkoService 保持一致(供 scanner-nko 组件通过 brand 切换复用):
91658
+ * 奔图特有的差异点(两段式取图、参数枚举映射、错误码翻译)全部封装在本服务内部。
91659
+ */
91660
+
91661
+ /**
91662
+ * 错误码 -> 中文描述(摘自《奔图扫描SDK-HTTP接口说明文档》)
91663
+ */
91664
+ const PANTUM_ERROR_MESSAGES = {
91665
+ 1: '扫描仪未连接',
91666
+ 2: '扫描仪连接中断',
91667
+ 3: '与扫描仪通信发生错误',
91668
+ 4: '参数设置错误',
91669
+ 5: '当前的扫描设备不支持',
91670
+ 6: '当前的文档来源不支持',
91671
+ 7: '当前的色彩模式不支持',
91672
+ 8: '当前的分辨率不支持',
91673
+ 9: '当前的纸张类型不支持',
91674
+ 10: '当前的图片保存格式不支持',
91675
+ 11: '扫描仪忙',
91676
+ 12: '文档进纸器无文档',
91677
+ 13: '文档进纸器堵塞',
91678
+ 14: '文档进纸器上盖打开',
91679
+ 15: '未检测到原件尺寸,请开合平板盖',
91680
+ 16: '重张进纸,请分离纸张并重新扫描',
91681
+ 17: '扫描仪内部故障,请尝试重启设备或联系客服',
91682
+ 18: '创建文件失败,请检查是否权限不足',
91683
+ 19: '磁盘空间不足',
91684
+ 20: '内存不足',
91685
+ 21: '扫描仪中止扫描',
91686
+ 22: '双向认证失败',
91687
+ 23: '安全认证没有通过',
91688
+ 24: '隔离设备接入,扫描禁用',
91689
+ 25: '无效的路径',
91690
+ 26: '文档进纸器取纸失败',
91691
+ 27: '奇数页扫描完成,请把纸张放回自动进纸器,并在面板上按【开始】键继续扫描偶数页',
91692
+ 28: '不支持该操作',
91693
+ 29: '未检测到扫描仪',
91694
+ 30: '保存失败',
91695
+ 31: '加载动态库失败',
91696
+ 32: '扫描 SDK 正在扫描,请稍后再试',
91697
+ 33: 'ADF 混合扫描(自动尺寸)不支持的纸张类型,或进纸器规制未在对应纸张刻度处',
91698
+ 34: '稿台上的 ADF 装置被抬起,稿台未被盖住',
91699
+ 35: '不支持扫描来源为 ADF',
91700
+ 36: '图像文件损坏',
91701
+ 37: '打印机的扫描功能被禁用,请在打印机面板设置开启扫描功能',
91702
+ 38: '未检测到稿台,请检查是否连接稿台配件,或选择文档进纸器',
91703
+ 39: '当前连接的是 A4 稿台配件,无法扫描 A3 尺寸',
91704
+ 40: '目标文件已存在',
91705
+ 41: '源文件打开失败',
91706
+ 42: '目标文件打开失败',
91707
+ 43: '读取 BMP 文件失败',
91708
+ 44: '读取 JPEG 文件失败',
91709
+ 45: '操作已取消',
91710
+ 46: '处理结果全为空白页',
91711
+ 47: '当前的扫描页数设置不支持',
91712
+ 48: '使用平板扫描时,文档进纸器不能放置纸张',
91713
+ 49: '操作文件失败',
91714
+ 50: '图像列表为空',
91715
+ 51: '鉴别用户未登录',
91716
+ 52: '鉴别用户不存在',
91717
+ 53: '鉴别用户被冻结',
91718
+ 54: '鉴别用户无权限',
91719
+ 1001: '待获取的文件不存在',
91720
+ 1002: '打开文件失败',
91721
+ 1003: '文件删除失败',
91722
+ 1004: '输入的 ID 不存在',
91723
+ 1013: '无扫描作业',
91724
+ 1014: '扫描作业不存在'
91725
+ };
91726
+ /**
91727
+ * 进纸模式:赞彩词汇 -> 奔图 src
91728
+ * 1:稿台;2:文档进纸器;3:文档进纸器双面
91729
+ */
91730
+ const PANTUM_SOURCE_MAP = {
91731
+ 'Flatbed': 1,
91732
+ 'Adf-front': 2,
91733
+ 'Adf-duplex': 3
91734
+ };
91735
+ /**
91736
+ * 扫描颜色:赞彩词汇 -> 奔图 colorType
91737
+ * 1:真彩色;2:灰度;3:黑白
91738
+ */
91739
+ const PANTUM_MODE_MAP = {
91740
+ 'Color': 1,
91741
+ 'Gray': 2,
91742
+ 'Lineart': 3
91743
+ };
91744
+ /**
91745
+ * 纸张类型:赞彩词汇 -> 奔图 geometry
91746
+ */
91747
+ const PANTUM_PAPER_SIZE_MAP = {
91748
+ 'MaxSize': '自动检测',
91749
+ 'A3': 'A3',
91750
+ 'A4': 'A4',
91751
+ 'A5': 'A5',
91752
+ 'JisB5': 'JIS_B5',
91753
+ 'IsoB6': 'B6',
91754
+ 'USExecutive': 'Executive'
91755
+ };
91756
+ /**
91757
+ * 文件格式:赞彩词汇 -> 奔图 saveFmt
91758
+ * 1:BMP;3:JPEG;4:PNG;5:单页压缩 TIFF
91759
+ * 暂不提供 Pdf(13)/Ofd(16):base64 结果无法在扫描结果列表直接预览
91760
+ */
91761
+ const PANTUM_FILE_FORMAT_MAP = {
91762
+ 'Bmp': 1,
91763
+ 'Jpeg': 3,
91764
+ 'Png': 4,
91765
+ 'Tiff': 5
91766
+ };
91767
+ class PantumService {
91768
+ /**
91769
+ * 服务地址:依据当前页面协议自动选择端口
91770
+ * https 页面 -> https://127.0.0.1:3884(要求 dss 服务已配置证书并重启生效)
91771
+ * http 页面 -> http://127.0.0.1:3883
91772
+ */
91773
+ static get baseUrl() {
91774
+ const isHttps = typeof window !== 'undefined' && window.location.protocol === 'https:';
91775
+ return isHttps ? 'https://127.0.0.1:3884' : 'http://127.0.0.1:3883';
91776
+ }
91777
+ /** 当前选中的设备(deviceId 形如 "devName|devAddr",无地址时为 devName) */
91778
+
91779
+ /**
91780
+ * GET 请求并返回 JSON(CustomAxios)
91781
+ * 网络异常时给出服务未启动 / 证书未配置的提示
91782
+ */
91783
+ static async request(path, params = {}) {
91784
+ // CustomAxios 的 GET 查询串不做 URL 编码,含空格/中文的参数值(如 devName、geometry)在此预编码
91785
+ const encodedParams = {};
91786
+ Object.keys(params).filter(key => params[key] !== undefined && params[key] !== null && params[key] !== '').forEach(key => {
91787
+ encodedParams[key] = encodeURIComponent(String(params[key]));
91788
+ });
91789
+ try {
91790
+ return await CustomAxios.get(`${PantumService.baseUrl}${path}`, encodedParams);
91791
+ } catch (e) {
91792
+ // CustomAxios 失败时 reject 的是 xhr 对象:status 有值即 HTTP 错误,否则为网络不通
91793
+ const xhr = e;
91794
+ if (xhr && typeof xhr === 'object' && xhr.status) {
91795
+ throw Error(`奔图扫描服务请求失败,HTTP 状态码:${xhr.status}`);
91796
+ }
91797
+ const httpsTip = PantumService.baseUrl.indexOf('https://') === 0 ? ',且 https 证书(cert/cert.crt)已配置' : '';
91798
+ throw Error(`无法连接奔图扫描服务(${PantumService.baseUrl}),请确认扫描服务已启动${httpsTip}`);
91799
+ }
91800
+ }
91801
+ /**
91802
+ * 校验奔图接口返回码,resultCode 不为 0 时抛出中文错误
91803
+ */
91804
+ static checkResult(response, action) {
91805
+ if (!response || response.resultCode === undefined || isNaN(Number(response.resultCode))) {
91806
+ throw Error(`${action}失败:奔图扫描服务返回数据异常`);
91807
+ }
91808
+ const code = Number(response.resultCode);
91809
+ if (code !== 0) {
91810
+ throw Error(`${action}失败,返回码:${code},错误信息:${PANTUM_ERROR_MESSAGES[code] || response.msg || '未知错误'}`);
91811
+ }
91812
+ }
91813
+ /**
91814
+ * 获取扫描仪设备列表(getAllDevList:含 USB 与网络设备)
91815
+ * 注:接口返回 data 的字段名以实际设备为准,此处做多字段兼容
91816
+ * @returns deviceId:设备标识,形如 "devName|devAddr"(无地址时为 devName)
91817
+ */
91818
+ static async getDeivceList() {
91819
+ const response = await PantumService.request('/getAllDevList');
91820
+ this.checkResult(response, '获取奔图扫描仪设备列表');
91821
+ console.log('获取奔图扫描仪设备列表==>', response);
91822
+ const list = Array.isArray(response.data) ? response.data : [];
91823
+ const devices = list.map(item => {
91824
+ if (typeof item === 'string') {
91825
+ return {
91826
+ deviceId: item
91827
+ };
91828
+ }
91829
+ const devName = item.devName || item.dev_name || item.name || item.devNameInSetting || '';
91830
+ const devAddr = item.devAddr || item.dev_addr || item.address || '';
91831
+ const deviceId = devAddr ? `${devName}|${devAddr}` : devName || item.devId || item.id || '';
91832
+ return {
91833
+ deviceId
91834
+ };
91835
+ }).filter(item => item.deviceId);
91836
+ if (devices.length === 0) {
91837
+ throw Error('未检测到奔图扫描仪,请确认设备已连接且奔图扫描服务(dss)已启动');
91838
+ }
91839
+ return devices;
91840
+ }
91841
+ /**
91842
+ * 选中指定扫描仪(奔图无独立"打开设备"接口,仅记录待扫描设备)
91843
+ * @param scannerId 选中的扫描仪 ID(getDeivceList 返回的 deviceId)
91844
+ */
91845
+ static async openScanDeivce(scannerId) {
91846
+ this.selectedDeviceId = scannerId || '';
91847
+ return {
91848
+ code: 0,
91849
+ msg: 'ok',
91850
+ data: null
91851
+ };
91852
+ }
91853
+ /**
91854
+ * 获取选中扫描仪可配置项
91855
+ * 奔图无能力查询接口,返回静态能力表(见 scanOptions)
91856
+ */
91857
+ static async getScanOptions() {
91858
+ return PantumService.scanOptions;
91859
+ }
91860
+ /**
91861
+ * 常用参数的便捷配置能力(进纸模式、色彩、尺寸、DPI)
91862
+ * 奔图 scan 接口一次性携带全部参数,这里仅暂存,待 scan 时统一映射
91863
+ */
91864
+ static async setScanBasicOptions(config) {
91865
+ this.pendingBasicOptions = config || {};
91866
+ return {
91867
+ code: 0,
91868
+ msg: 'ok',
91869
+ data: null
91870
+ };
91871
+ }
91872
+ /**
91873
+ * 扫描:调 /scan 后逐个 docid 调 /getImg64 取 base64 图片
91874
+ * @param fileFormat 文件保存格式(image-format 选项,如 Jpeg)
91875
+ * @param fileSavePath 保存路径(目录,为空时保存到服务临时路径)
91876
+ * @param fileNamePrefix 未使用(奔图由服务端自行命名)
91877
+ * @param fileNameFormat 未使用(同上)
91878
+ * @param fileTransferMode 未使用(奔图无传输模式概念)
91879
+ * @returns [{name, url}] name:文件名;url:可直接预览的 dataUrl
91880
+ */
91881
+ static async scan(fileFormat, fileSavePath = '', fileNamePrefix = '', fileNameFormat = '', fileTransferMode = '') {
91882
+ const basic = this.pendingBasicOptions || {};
91883
+ const parts = (this.selectedDeviceId || '').split('|');
91884
+ const response = await PantumService.request('/scan', {
91885
+ devName: parts[0] || '',
91886
+ devAddr: parts[1] || '',
91887
+ saveFmt: PANTUM_FILE_FORMAT_MAP[fileFormat] || 3,
91888
+ src: PANTUM_SOURCE_MAP[basic.source] || 1,
91889
+ colorType: PANTUM_MODE_MAP[basic.mode] || 1,
91890
+ dpi: Number(basic.resolution) || 300,
91891
+ geometry: PANTUM_PAPER_SIZE_MAP[basic['paper-size']] || 'A4',
91892
+ // 旋转角度:0 不旋转;页数:0 全部;可选参数 / 条码识别:暂不开启
91893
+ rotate: 0,
91894
+ pages: 0,
91895
+ opt: 0,
91896
+ barcodeTag: 0,
91897
+ savePath: fileSavePath || ''
91898
+ });
91899
+ this.checkResult(response, '扫描');
91900
+ console.log('奔图扫描==>', response);
91901
+ // docs 元素形如 {docid},做裸 id 兼容
91902
+ const docids = (response.docs || []).map(doc => doc && doc.docid !== undefined ? doc.docid : doc);
91903
+ const fileList = [];
91904
+ for (const docid of docids) {
91905
+ const img = await PantumService.request('/getImg64', {
91906
+ docid
91907
+ });
91908
+ this.checkResult(img, '获取扫描图片');
91909
+ // getImg64 取后服务端即清除记录,dataUrl 需由前端持有
91910
+ fileList.push({
91911
+ name: img.filename || `${docid}`,
91912
+ url: `data:${img.mimetype};base64,${img.base64}`
91913
+ });
91914
+ }
91915
+ return fileList;
91916
+ }
91917
+ }
91918
+ _defineProperty(PantumService, "selectedDeviceId", '');
91919
+ _defineProperty(PantumService, "pendingBasicOptions", {});
91920
+ _defineProperty(PantumService, "scanOptions", {
91921
+ // 进纸模式:平板 / 进纸器正面 / 进纸器双面
91922
+ source: ['Flatbed', 'Adf-front', 'Adf-duplex'],
91923
+ // 扫描颜色:彩色 / 灰度 / 黑白
91924
+ mode: ['Color', 'Gray', 'Lineart'],
91925
+ // 分辨率
91926
+ resolution: ['75', '150', '300', '600', '1200'],
91927
+ // 纸张类型
91928
+ 'paper-size': ['MaxSize', 'A3', 'A4', 'A5', 'JisB5', 'IsoB6', 'USExecutive'],
91929
+ // 文件格式
91930
+ 'image-format': ['Bmp', 'Jpeg', 'Png', 'Tiff']
91931
+ });
91644
91932
  ;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-85.use[1]!./node_modules/@vue/cli-service/node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./packages/scanner/scanner-nko/src/scanner-nko.vue?vue&type=script&lang=js&
91645
91933
 
91646
91934
 
91935
+
91936
+
91937
+ //品牌 → 扫描服务映射(两者接口形态一致,可互换),新增品牌在此加一行
91938
+ const BRAND_SERVICE_MAP = {
91939
+ nko: NkoService,
91940
+ pantum: PantumService
91941
+ };
91647
91942
  /* harmony default export */ var scanner_nkovue_type_script_lang_js_ = ({
91648
91943
  name: 'scanner-nko',
91649
91944
  components: {},
@@ -91686,6 +91981,15 @@ _defineProperty(NkoService, "fileList", []);
91686
91981
  fileTransferMode: {
91687
91982
  default: '',
91688
91983
  type: String
91984
+ },
91985
+ /**
91986
+ * 设备品牌,决定使用哪个扫描服务(两者接口形态一致)
91987
+ * nko - 赞彩五合一设备(默认)
91988
+ * pantum - 奔图扫描仪(本地 HTTP 服务)
91989
+ */
91990
+ brand: {
91991
+ default: 'nko',
91992
+ type: String
91689
91993
  }
91690
91994
  },
91691
91995
  data: () => {
@@ -91734,6 +92038,15 @@ _defineProperty(NkoService, "fileList", []);
91734
92038
  isDeviceReady() {
91735
92039
  return this.scanConfig.deviceId && this.deviceOpend;
91736
92040
  },
92041
+ //当前品牌对应的扫描服务(未知品牌回退 NkoService)
92042
+ scanService() {
92043
+ const service = BRAND_SERVICE_MAP[this.brand];
92044
+ if (!service) {
92045
+ console.warn(`[scanner-nko] 未知的设备品牌:${this.brand},已回退为 NkoService`);
92046
+ return NkoService;
92047
+ }
92048
+ return service;
92049
+ },
91737
92050
  imgUrls() {
91738
92051
  return this.scanFileList.map(item => item.url);
91739
92052
  }
@@ -91748,9 +92061,9 @@ _defineProperty(NkoService, "fileList", []);
91748
92061
  }
91749
92062
  },
91750
92063
  methods: {
91751
- /** localStorage 缓存 key */
92064
+ /** localStorage 缓存 key(按品牌隔离,避免不同设备记忆配置互相污染) */
91752
92065
  _cacheKey() {
91753
- return 'scanner-nko-config';
92066
+ return `scanner-${this.brand}-config`;
91754
92067
  },
91755
92068
  /** 读取缓存的扫描配置 */
91756
92069
  getCachedConfig() {
@@ -91786,10 +92099,15 @@ _defineProperty(NkoService, "fileList", []);
91786
92099
  async initScanServiceAPI() {
91787
92100
  this.pageLoadingText = '正在连接扫描服务,请稍候...';
91788
92101
  this.pageLoading = true;
91789
- // 获取设备列表
91790
- this.deviceList = await NkoService.getDeivceList();
91791
- this.deviceOpend = true;
91792
- this.pageLoading = false;
92102
+ try {
92103
+ // 获取设备列表
92104
+ this.deviceList = await this.scanService.getDeivceList();
92105
+ this.deviceOpend = true;
92106
+ } catch (e) {
92107
+ this.$message.error(e && e.message || '连接扫描服务失败');
92108
+ } finally {
92109
+ this.pageLoading = false;
92110
+ }
91793
92111
 
91794
92112
  // 连接成功后,恢复缓存的扫描源(deviceId)
91795
92113
  const cached = this.getCachedConfig();
@@ -91816,7 +92134,7 @@ _defineProperty(NkoService, "fileList", []);
91816
92134
  this.scanConfig.source = null;
91817
92135
  this.scanConfig.resolution = null;
91818
92136
  this.scanConfig.mode = null;
91819
- this.scanConfig.paperSideviceOpendze = null;
92137
+ this.scanConfig.paperSize = null;
91820
92138
  this.scanConfig.fileFormat = null;
91821
92139
  this.sourceOptions = [];
91822
92140
  this.modeOptions = [];
@@ -91844,28 +92162,33 @@ _defineProperty(NkoService, "fileList", []);
91844
92162
  async getScanOptions() {
91845
92163
  this.pageLoadingText = '正在获取扫描仪能力,请稍后...';
91846
92164
  this.pageLoading = true;
91847
- await NkoService.openScanDeivce(this.scanConfig.deviceId);
91848
- var options = await NkoService.getScanOptions();
91849
- this.sourceOptions = options.source;
91850
- this.modeOptions = options.mode;
91851
- this.resolutionOptions = options.resolution;
91852
- this.paperSizeOptions = options['paper-size'];
91853
- this.fileFormatOptions = options['image-format'];
91854
-
91855
- // 恢复缓存配置:若缓存值在当前设备能力列表中则使用缓存值,否则取第一项
91856
- const cached = this.getCachedConfig() || {};
91857
- const isValid = (list, val) => val && list.includes(val);
91858
- this.scanConfig.source = isValid(this.sourceOptions, cached.source) ? cached.source : this.sourceOptions[0] || null;
91859
- this.scanConfig.mode = isValid(this.modeOptions, cached.mode) ? cached.mode : this.modeOptions[0] || null;
91860
- this.scanConfig.resolution = isValid(this.resolutionOptions, cached.resolution) ? cached.resolution : this.resolutionOptions[0] || null;
91861
- this.scanConfig.paperSize = isValid(this.paperSizeOptions, cached.paperSize) ? cached.paperSize : this.paperSizeOptions[0] || null;
91862
- this.scanConfig.fileFormat = isValid(this.fileFormatOptions, cached.fileFormat) ? cached.fileFormat : this.fileFormatOptions[0] || null;
91863
- // fileTransferMode 不依赖设备,直接恢复
91864
- if (cached.fileTransferMode) {
91865
- this.scanConfig.fileTransferMode = cached.fileTransferMode;
91866
- }
91867
- this.deviceOpend = true;
91868
- this.pageLoading = false;
92165
+ try {
92166
+ await this.scanService.openScanDeivce(this.scanConfig.deviceId);
92167
+ var options = await this.scanService.getScanOptions();
92168
+ this.sourceOptions = options.source;
92169
+ this.modeOptions = options.mode;
92170
+ this.resolutionOptions = options.resolution;
92171
+ this.paperSizeOptions = options['paper-size'];
92172
+ this.fileFormatOptions = options['image-format'];
92173
+
92174
+ // 恢复缓存配置:若缓存值在当前设备能力列表中则使用缓存值,否则取第一项
92175
+ const cached = this.getCachedConfig() || {};
92176
+ const isValid = (list, val) => val && list.includes(val);
92177
+ this.scanConfig.source = isValid(this.sourceOptions, cached.source) ? cached.source : this.sourceOptions[0] || null;
92178
+ this.scanConfig.mode = isValid(this.modeOptions, cached.mode) ? cached.mode : this.modeOptions[0] || null;
92179
+ this.scanConfig.resolution = isValid(this.resolutionOptions, cached.resolution) ? cached.resolution : this.resolutionOptions[0] || null;
92180
+ this.scanConfig.paperSize = isValid(this.paperSizeOptions, cached.paperSize) ? cached.paperSize : this.paperSizeOptions[0] || null;
92181
+ this.scanConfig.fileFormat = isValid(this.fileFormatOptions, cached.fileFormat) ? cached.fileFormat : this.fileFormatOptions[0] || null;
92182
+ // fileTransferMode 不依赖设备,直接恢复
92183
+ if (cached.fileTransferMode) {
92184
+ this.scanConfig.fileTransferMode = cached.fileTransferMode;
92185
+ }
92186
+ this.deviceOpend = true;
92187
+ } catch (e) {
92188
+ this.$message.error(e && e.message || '获取扫描仪能力失败');
92189
+ } finally {
92190
+ this.pageLoading = false;
92191
+ }
91869
92192
  },
91870
92193
  /**
91871
92194
  * 点击扫描
@@ -91876,17 +92199,22 @@ _defineProperty(NkoService, "fileList", []);
91876
92199
  }
91877
92200
  this.pageLoadingText = '正在提交扫描请求,请稍后...';
91878
92201
  this.pageLoading = true;
91879
- await NkoService.setScanBasicOptions({
91880
- source: this.scanConfig.source,
91881
- mode: this.scanConfig.mode,
91882
- 'paper-size': this.scanConfig.paperSize,
91883
- resolution: this.scanConfig.resolution
91884
- });
91885
- const data = await NkoService.scan(this.scanConfig.fileFormat, this.fileSavePath, this.fileNamePrefix, this.fileNameFormat, this.scanConfig.fileTransferMode);
91886
- this.scanFileList = [...this.scanFileList, ...data];
91887
- // 扫描成功后缓存当前配置,下次使用时直接恢复
91888
- this.saveConfigToCache();
91889
- this.pageLoading = false;
92202
+ try {
92203
+ await this.scanService.setScanBasicOptions({
92204
+ source: this.scanConfig.source,
92205
+ mode: this.scanConfig.mode,
92206
+ 'paper-size': this.scanConfig.paperSize,
92207
+ resolution: this.scanConfig.resolution
92208
+ });
92209
+ const data = await this.scanService.scan(this.scanConfig.fileFormat, this.fileSavePath, this.fileNamePrefix, this.fileNameFormat, this.scanConfig.fileTransferMode);
92210
+ this.scanFileList = [...this.scanFileList, ...data];
92211
+ // 扫描成功后缓存当前配置,下次使用时直接恢复
92212
+ this.saveConfigToCache();
92213
+ } catch (e) {
92214
+ this.$message.error(e && e.message || '扫描失败');
92215
+ } finally {
92216
+ this.pageLoading = false;
92217
+ }
91890
92218
  },
91891
92219
  //预览
91892
92220
  previewImg(index) {
@@ -91917,10 +92245,10 @@ _defineProperty(NkoService, "fileList", []);
91917
92245
  });
91918
92246
  ;// CONCATENATED MODULE: ./packages/scanner/scanner-nko/src/scanner-nko.vue?vue&type=script&lang=js&
91919
92247
  /* harmony default export */ var src_scanner_nkovue_type_script_lang_js_ = (scanner_nkovue_type_script_lang_js_);
91920
- ;// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-67.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-67.use[1]!./node_modules/@vue/cli-service/node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-67.use[2]!./node_modules/sass-loader/dist/cjs.js??clonedRuleSet-67.use[3]!./node_modules/@vue/cli-service/node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./packages/scanner/scanner-nko/src/scanner-nko.vue?vue&type=style&index=0&id=2b36bc1b&prod&lang=scss&
92248
+ ;// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-67.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-67.use[1]!./node_modules/@vue/cli-service/node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-67.use[2]!./node_modules/sass-loader/dist/cjs.js??clonedRuleSet-67.use[3]!./node_modules/@vue/cli-service/node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./packages/scanner/scanner-nko/src/scanner-nko.vue?vue&type=style&index=0&id=09b27ab8&prod&lang=scss&
91921
92249
  // extracted by mini-css-extract-plugin
91922
92250
 
91923
- ;// CONCATENATED MODULE: ./packages/scanner/scanner-nko/src/scanner-nko.vue?vue&type=style&index=0&id=2b36bc1b&prod&lang=scss&
92251
+ ;// CONCATENATED MODULE: ./packages/scanner/scanner-nko/src/scanner-nko.vue?vue&type=style&index=0&id=09b27ab8&prod&lang=scss&
91924
92252
 
91925
92253
  ;// CONCATENATED MODULE: ./packages/scanner/scanner-nko/src/scanner-nko.vue
91926
92254
 
@@ -91933,8 +92261,8 @@ _defineProperty(NkoService, "fileList", []);
91933
92261
 
91934
92262
  var scanner_nko_component = normalizeComponent(
91935
92263
  src_scanner_nkovue_type_script_lang_js_,
91936
- scanner_nkovue_type_template_id_2b36bc1b_render,
91937
- scanner_nkovue_type_template_id_2b36bc1b_staticRenderFns,
92264
+ scanner_nkovue_type_template_id_09b27ab8_render,
92265
+ scanner_nkovue_type_template_id_09b27ab8_staticRenderFns,
91938
92266
  false,
91939
92267
  null,
91940
92268
  null,