> 最低版本：10.0.2407.01

## 1、功能测试和使用说明

### 1.1 安装驱动

按照文档 [设备驱动和下载安装文档 ](https://www.e-cology.com.cn/sp/doc/docShare/1008850164035108962?tenantKey=t7akvdnf84)安装驱动，无设备测试请选择TWAIN虚拟扫描仪

[图片附件未整合: ../../../../_assets/220353731164635136/001-9d3a90b8e0.png]

### 1.2 设备集成配置

在后台管理中心 - 设备集成 - 中录入设备信息并测试[图片附件未整合: ../../../../_assets/220353731164635136/002-924a55dee0.png]

[图片附件未整合: ../../../../_assets/220353731164635136/003-734f510443.png]

[图片附件未整合: ../../../../_assets/220353731164635136/004-4e68a8c53c.png]

[图片附件未整合: ../../../../_assets/220353731164635136/005-2f881ca1b3.png]

### 1.3 扫描上传动作配置

设备测试通过后，可在e-builder - 表单 - 按钮动作 - 扫描上传 中配置指定设备。

[图片附件未整合: ../../../../_assets/220353731164635136/006-b8e1da4eb5.png]

### 1.4 前台执行

点击前台按钮执行

### 1.5  事件监听

您可以通过@weapp/utils提供的eventEmitter进行事件监听，在扫描上传后，回调函数将接收扫描上传的结果。

```javascript

window.weappUtils.eventEmitter.on('weappEbdfpage', 'IntDeviceScanCb.common', (res) => {
  console.log(res);
});
```

返回结果res的示例

```json
{
    "status": true,
    "data": [
        {
            "pdfinfo": {
                "targetFileId": "1019256401530822656",
                "targetDocId": "2072051412539680558",
                "targetUrl": "https://release-1301503941.cos.ap-shanghai.myqcloud.com/t7akvdnf84/0a8e23d0-d582-4d39-9d75-ad767ae49d51?sign=q-sign-algorithm%3Dsha1%26q-ak%3DAKIDqcLvPmX4XO8iMjIHoSG3CDXiiXkn8EJD%26q-sign-time%3D1720514125%3B1720517725%26q-key-time%3D1720514125%3B1720517725%26q-header-list%3Dhost%26q-url-param-list%3Dresponse-content-disposition%26q-signature%3D9dd9c7d8e8290d45bfc8e530fc5eef1d76588ee7&response-content-disposition=attachment%3Bfilename%3D1720514124423.pdf",
                "uniqueId": "0a8e23d0-d582-4d39-9d75-ad767ae49d51"
            },
            "deviceImgs": [
                {
                    "fileid": "1019256397219864576",
                    "name": "2024791632300",
                    "size": 177013,
                    "extName": "jpg",
                    "type": "image/jpeg",
                    "img": true,
                    "uploadUser": "8852245221299621885",
                    "uploadUserName": "Tom",
                    "uploadTime": 1720514123516,
                    "doc": false,
                    "docId": "0",
                    "otherParams": {},
                    "ban": false,
                    "base64Str": "/9j/4AAQSkZJRgABAQEAyADIAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE\r\nz+3F8Z9U+Pn7Rvi//hOfijrWj6JoOoa/9ht9O8/TPD1q1npVv9mtQsK/Z7dim4Dc+cmiigD5mooo\r\noAKKKKACiiigAooooAKKKKACiiigAooooA//2Q=="
                }
            ]
        }
    ]
}
```

### 1.6 结合表单的用例

例如：先配置一个扫描监听事件，再配置一个JavaScript动作，该动作中用下面的方法监听扫描结果，当接收到扫描结果后，缓存结果，并执行自定义的内容

如果要获取表格选中的数据，可以参考建模的SDK文档 [https://weapp.eteams.cn/ecode/playground/doc/share/view/990693279847899137](https://weapp.eteams.cn/ecode/playground/doc/share/view/990693279847899137)

示例：按钮动作

[图片附件未整合: ../../../../_assets/220353731164635136/007-5ef62ae7f2.png]

1：扫描上传

2：JavaScript

```javascript
asyncFn((success, fail) => {
  if (window.weappUtils) {
    window.weappUtils.eventEmitter.on('weappEbdfpage', 'IntDeviceScanCb.common', (res) => {
      console.log('IntDeviceScanCb.common',res);
      if (res && res.status === true) {
        // 例如：
        // #1 缓存扫描数据
        //window._customCacheScanData = res.data;
        //success();
        // #2 或触发接口
        // axios.post('/api/scan', res.data).then(() => {
        // success();
        // }).catch(() => {
        //   fail();
        // });
        // #3 通过表单sdk写入数据 表单SDK文档 https://freeform.yunteams.cn/formsdk/guide.html
        // 调用表单sdk的写入数据，再触发success
        success();
      } else {
        fail();
      }
    });
  } else {
    fail();
  }
});
```
