

**此方案自控行很强，使用请注意依据自己逻辑，不作为标准方案**

### 1、对应表格视图代码添加代码

```typescript

// 编码
function encode(str) {
  return btoa(encodeURIComponent(str));
}

// JSON编码
function JSONEncode(val) {
  return encode(JSON.stringify(val));
}

window.ebdfpageBatchPrint = (listId)=>{
  var listSdk = ebdfpageSDK.getListSDK(listId);
  var checkDatas = listSdk?.getListCheckedData() ||[];
  const objid = listSdk.getObjID(); //获取表格视图对应EB表单ID
  const formid = listSdk.getBaseFormID(); // 获取表单模块表单id
  console.log("checkDatas",checkDatas);
  const printList =  checkDatas.map((data) => ({
        dataId: data.form_data_id,
        title: data.name || data.id,
        targetId: formid,
        customParam: JSONEncode({ dataid: data.id, objid }),
        apiModule:"ebuilder/form",
        templateId:"1" //打印模板id，默认1
    }));
    
   weappUtils.request({
      method: "post",
      url: "/api/print/batchPrint/saveBatchPrintData.json",
      data: {
        module:"ebuilderform",
        pdfUrl:"/api/ebuilder/form/print/findPrintPagePdf",
        dataList:printList
    },
  }).then(res=>{
    console.log(res);
    const tempdata = res.data;
    const list = tempdata.batchPrintDataList?.[0];
    window.open(`/sp/print/batchPrintPage/ebuilderform/${tempdata?.batchId}/${list?.groupId}`)
  });
}
```

[图片附件未整合: ../../../../../_assets/934564207862480897/001-d6d1c27459.png]

### 2、自定义按钮添加动作

```typescript

window.ebdfpageBatchPrint("925643375902810115");//925643375902810115 为当前视图id
```

[图片附件未整合: ../../../../../_assets/934564207862480897/002-edc1b5ae88.png]

### 3、效果

[图片附件未整合: ../../../../../_assets/934564207862480897/003-25b783e4f7.png]
