import printBill from '../control/printBill.vue'
export default {
  execute: function (bill, param) {
    if (param) {
      
        GMS.$hideContainer.addComponent(printBill, {}, function (c) {
            if(param.param.detailFieldName){
            let url = `/rbcfunc/print/merge/multi/${param.define}/${bill.getMasterData().getValue('id')}/${param.param.detailFieldName}?detailName=BXMXZB`;
            GMS.$http
              .post(url, JSON.stringify(), {
                responseType: "blob",
                headers: {
                  "Content-Type": "application/pdf;charset=utf-8",
                  "X-Requested-With": "XMLHttpRequest",
                },
              })
              .then((res) => {
                let blob = new Blob([res.data], {
                  type: "application/pdf;charset=utf-8",
                });            let downloadElement = document.createElement("a");
                let href = window.URL.createObjectURL(blob); //创建下载的链接
                downloadElement.href = href;
                window.open(href)
              });
            }else{
                c.billId = bill.getMasterData().getValue('id');
                c.billDefineName = param.define;
                if(param.param.subName){
                  c.subName = param.param.subName;
                }
                c.modalShow = true;
            }
          })
    } else {
      GAMS.Common.messagePrompt('缺少参数')
    }
  }
}