## 1、编辑保存后拦截默认跳转

```
asyncFn((resolve, reject) => {
  if(ebdfpageSDK&&ebdfpageSDK.getCardSDK()&&ebdfpageSDK.getCardSDK().getCardStore().isOpenSourceAssociated()){
    resolve({refreshCard:false,interrupt:true,extraEvent:{refreshCard:false}})
    return 
   }
  resolve()
   
 });
```

[图片附件未整合: ../../../../_assets/218163488063750144/001-4567ab36ec.png]

## 2、点击按钮生成内容到剪贴板

> 类似ctrl+c

```javascript
var linkSrc = this.data['yqhdz'];
var src = linkSrc.replaceAll('amp;','');
var topic=this.data['hyzt'];
var addr=this.data['dd']+this.data['xxdz'];
var time=this.data['rq']+'('+this.data['xq']+')'+this.data['sj'];
var fullText='诚邀您参加泛微举办的客户体验会议'+'\n'+'会议主题：'+topic+'\n'+'会议地点：'+addr+'\n'+'会议时间：'+time+'\n'+'报名链接：'+src;

if(window.navigator.clipboard && fullText){
  navigator.clipboard.writeText(fullText);
  console.log(fullText);
  weappUi.Dialog.message({type:'success',content:'邀请函链接已复制到剪贴板！'});
}
```

## 3、ebdcoms的jumplink复写（慎用，不对外建议）

```javascript
const JumpLinkOrign = window.weappEbdcoms.JumpLink;

const newWOpen = (linkInfo, options) => {
  console.log("linkInfo, options",linkInfo, options)
  if(options?.compId==="ec7fa411371d461bb0b6a53212fc7e8c" && linkInfo?.page?.pageId==="1/905655220966793217"){
    linkInfo = {
      ...linkInfo,
      params:linkInfo.params?.filter(item=>['openSource', 'targetConditionId', 'openSourceId'].includes(item.name)),
      ownParams:{'openSource':linkInfo?.ownParams?.openSource, 'targetConditionId':linkInfo?.ownParams?.targetConditionId,         'openSourceId':linkInfo?.ownParams?.openSourceId}
    }
  }

  JumpLinkOrign(linkInfo, options);

}
weappEbdcoms = { ...weappEbdcoms, JumpLink: newWOpen }
```

```
ebdfpageSDK.registerJumpLinkRewrite((fn,info,props)=>{
 console.log("info:::",info);
    //判断打开新建布局--目标表单
    if(info&&info.ownParams&& info.ownParams.targetConditionId ==="替换为真实id"){
      console.log("拦截url参数成功")
      const params = []

       fn({...info,params},props)
      return
    }
   //不做处理默认放行
     fn(info,props)
    
   
})
```

## 4、页面树组件事件调用表格视图参数污染问题

> 左边树不同节点同时对同一表格视图点击过滤，参数之间独立调用本方法，在树事件执行后添加

```
const instanceId = pageSdk.instanceId;
  window.weappEbdcoms.clearEbParams("pageParams", instanceId);
  console.log(instanceId);
   console.log( window.weappEbdcoms.getEbParams("pageParams", instanceId))

asyncFn((resolve) => {
  
  window.weappUtils.throttle( async () => {
    resolve();
  }, 200)();
});
```

## [图片附件未整合: ../../../../_assets/218163488063750144/002-d3514775d2.png]

5、自定义按钮实现直接导出

```
//加载导出组件
ebdfpageSDK.getListSDK().getListStore().expBtnClick()

weappUtils.debounce(()=>{
//导出组件api
ebdfpageSDK.getListSDK().getExportApi().doInitExport('导出名称1')
},100)()
```

## 6、新建布局默认值的后端赋值方案

> 支持基线： 251001 +
> 
> 这个方案涉及到缓存，新窗口单页或者iframe场景需要主动清除，不然容易污染

```
//key: EbdfInitialDatas_1192906318890229760 (objId，eb表单id)
 sessionStorage.setItem('EbdfInitialDatas_1192906318890229760', JSON.stringify(
   [{key:"1192906331710791681",value:"222",},{key:'1192906331710791683',value:"33"}])
);
```

> 基线：260101+

```
/sp/ebdfpage/card/1/1190734328017756160/0?field_1190734358042181634=11&field_1190734358042181635=666&field_1190734371119407105=2&fieldAssignKeys=field_1190734358042181634,field_1190734371119407105

地址支持固定参数：fieldAssignKeys =XXX   //对应的需要走后端赋值的字段key
```

## 7、按钮动作前，判断是否勾选了数据

```javascript

// 注意本示例仅能用于表格视图右上角按钮！
const judgeSelectedDatas = () => {
  let selectedIds = [];
  if (window.eblistSdk) {
    //数据列表
    selectedIds = window.eblistSdk.getCheckedID();
  } else if (window.ebdfListSdk) {
    // 表格视图
    selectedIds = window.ebdfListSdk.getCheckedID();
  }
  asyncFn((resolve, reject) => {
    if (selectedIds.length > 0) {
      resolve();
    } else {
      window.weappUi.Dialog.message({ type: 'info', content: '需勾选数据执行' });
      reject();
    }
  });
};

judgeSelectedDatas();
```

## 8、表格视图按钮根据分类搜索选项控制按钮显隐

> 写在表格视图的代码块中，自行控制好逻辑

```
const ebdfListSdk = ebdfpageSDK.getListSDK();
var btnid = "1084898061786333308";//按钮id--批量确认研发  
var btnid2 = "1180215639682719800";//按钮id--指定申领人
var listid = "1173598117192826958";//表格id
var tabitemid = "1173598121580069334";//tab选项id--待提交研发
var tabitemid2 = "1173598121580069340";//tab选项id--待申领需求
 const urlparams = ebdfListSdk?.getUrlParams?.();
 const showbtnid = !(urlparams&&urlparams['GroupCustom_1173598121580069333']===tabitemid);
 const showbenid2 = !(urlparams&&urlparams['GroupCustom_1173598121580069333']===tabitemid2);

ebdfListSdk.controlBtnHidden(showbtnid,btnid);
ebdfListSdk.controlBtnHidden(showbenid2,btnid2);

import { regOvProps } from '@weapp/utils';
regOvProps(
  'weappUi',
  'Menu',
  (props) => {
   //视图ID
    if (props.weId.indexOf(listid)>-1) {
     

      return {...props,onChange:(id,item)=>{
        props.onChange(id,item);
       ebdfListSdk.controlBtnHidden(id!==tabitemid,btnid);
       ebdfListSdk.controlBtnHidden(id!==tabitemid2,btnid2);

      }}
    }
    return props;
  },
  0,
);

// 拦截eb列表按钮接口请求后
axios.interceptors.response.use(
  function (response) {
    if (
      response.status === 200 &&
      response.config.url.includes('/form/list/getListButtons/')
    ) {
      // 获取表格视图id
      const listId = response.config.url.split('/getListButtons/')?.[1]?.split('?')?.[0];
      if(listid  === listId){
         let _btns = response.data.data.buttons.map((btn)=>{
           if(btn.id === btnid){
             btn.hidden = showbtnid;
           }
           if(btn.id === btnid2){
             btn.hidden = showbenid2;
           }
           return btn;
         }) ;
          response.data.data.buttons = _btns;
      }
      return response;
    } else {
      return response;
    }
  },
  function (error) {
    return Promise.reject(error);
  },
);
```
