index.js 3.07 KB
Newer Older
fukai committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
import Api from '~/service/Api';
import moment from 'moment';
import Utils from "~/utils";
export default {
  methods: { 
    
  formSubmit(typ) {
    this.column = ''
    this.order  = ''
    this.typ = typ
    this.handleSearch();
  },	
    async handleSearch() {
        if(!this.model.infcon.corpid){
          this.$notify.error({ title: '错误', message: '组织机构代码必输' });
          return;
        }
          let params = {
            ...this.model.infcon,
          };
          delete params.markSet
          delete params.modifySet
          let rtnmsg = await Api.post('/manager/infent/queryInfent', params);
          if (rtnmsg.respCode == SUCCESS) {
            if(rtnmsg.data.code == '00000'){
              this.model.entinf = rtnmsg.data;
              let msg = rtnmsg.data.chkmsg.split('|');
              if(msg.length > 1){
                console.log('msg:',msg);
                this.$alert(msg[0],
                  '提示', {
                      confirmButtonText: '确定',
                      type: 'warning',
                  }).then(() =>{
                    this.$alert(msg[1],
                      '提示', {
                          confirmButtonText: '确定',
                          type: 'warning',
                      })
                    }
                  );
              }else{
                console.log('msg1:',msg);
                this.$alert(msg[0],
                  '提示', {
                      confirmButtonText: '确定',
                      type: 'warning',
                  }) 
              }
              // this.$notify.warning({ title: '提示', type:'warning', message: rtnmsg.data.chkmsg});
            }else{
              this.$notify.error({ title: '错误', message: rtnmsg.data.detail});
              return;
            }
          } else {
            this.$notify.error({ title: '错误', message: '服务请求失败!' });
          }
      
    },

    async show(){
      let params = {
        ...this.model.entinf,
     };
     let res = await Api.post( `/manager/infent/show`, params);
     if (res.respCode == SUCCESS) {
       let content = res.data.data
      if (!content) {
        console.log(content);
        this.$message.error("暂无预览详情");
        return;
      }
      const blob = this.base64ToBlob(content);
      if (window.navigator && window.navigator.msSaveOrOpenBlob) {
        window.navigator.msSaveOrOpenBlob(blob);
      } else {
        const fileURL = URL.createObjectURL(blob);
        this.viewPdfUrl = fileURL + "#view=FitH,top"+(this.noPrint?"&toolbar=0":"");
      }
       this.previewDetailVisible=true;
     }else{
      this.$notify.error({ title: '错误', message: '面函生成异常!' });
     }
    },

    base64ToBlob(code) {
      code = code.replace(/[\n\r]/g, "");
      const raw = window.atob(code);
      const rawLength = raw.length;
      const uInt8Array = new Uint8Array(rawLength);
      for (let i = 0; i < rawLength; ++i) {
        uInt8Array[i] = raw.charCodeAt(i);
      }
      return new Blob([uInt8Array], { type: "application/pdf" });
    },
   
  },

};