{
    template:'${tmpl}',
    data:function(){
        return {
          multipleSelection: [],
          isSingleSelect:false,
          bizCode:"invoice",
          a:true,
          c:true,
          d:true,
          b:false,
          orderid:"",
          invoiceType:"",
          form:{
            electronicInvoiceUrl:"",
            expressNum:"",
            expressDate:"",
            expressCompany:"",
            invoiceHeadUp:"",
            taxpayerID:"",
            applyAddr:"",
            applytelephone:"",
            bankAddrNum:"",
            content:"",
            mobile:"",
            address:"",
            email:"",
            totalSum:""
          },
        }
    },
    mounted:function(){

    },
    created:function(){
      console.log(this.codePath);
      if(this.codePath.indexOf("msginvoice")>=0){
        this.bizCode="msginvoice";
      }else{
        this.bizCode="invoice";
      }
    },
    methods:{
       rowClick(row,key,t,e){
         if(key=="dealing"){
           if(row["statusName"]=="处理中"){
             this.$message.warning(`当前发票正在处理`);
           }
           if(row["statusName"]=="已完成"){
             this.$message.warning(`当前发票已开具`);
           }
           if(row["statusName"]=="已提交"){
             var that=this;
             this.modelName="invoice";
             var url=this.getUrl("update");
             row["statusName"]="处理中";
             row["status"]="processing";
             row["version"]+=1;
             this.$root.postReq(url,row).then(rd=>{
               if(rd.status==0){
                 that.$refs.containerGrid.fetchData();
               }
             }).catch(function(e){
               that.$message.warning(`操作失败，请刷新页面后重新操作`);
             });
           }
           console.log("----------------------------------row");
           console.log(row);
         }
         if(key=="mycancel"){
           console.log("--------------------------------row");
           console.log(row);
           if(row["statusName"]=="已完成"){
             this.$message.warning(`当前发票已开具，不可取消处理`);
           }
           if(row["statusName"]=="已提交"){
             this.$message.warning(`当前发票未处理`);
           }
           if(row["statusName"]=="处理中"){
             var that=this;
             this.modelName="invoice";
             var url=this.getUrl("update");
             row["statusName"]="已提交";
             row["status"]="submitted";
             row["version"]+=1;
             this.$root.postReq(url,row).then(rd=>{
               if(rd.status==0){
                 that.$refs.containerGrid.fetchData();
               }
             }).catch(function(e){
               that.$message.warning(`操作失败，请刷新页面后重新操作`);
             });
           }
         }
         if(key=="editing"){
           console.log("----------------------row");
           console.log(row);
           this.orderid=row["id"];
           this.invoiceType=row["invoiceType"];
           this.form.invoiceHeadUp=row["invoiceHeadUp"];
           this.form.taxpayerID=row["taxpayerID"];
           this.form.applyAddr=row["applyAddr"];
           this.form.applytelephone=row["applytelephone"];
           this.form.bankAddrNum=row["bankAddrNum"];
           this.form.content=row["content"];
           this.form.mobile=row["mobile"];
           this.form.address=row["address"];
           this.form.email=row["email"];
           this.form.totalSum=row["totalSum"];
           if(row["invoiceType"]=="pt"){
             this.a=true;
             this.c=false;
             this.d=false;
           }
           if(row["invoiceType"]=="zy"){
             this.a=false;
             this.c=true;
             this.d=false;
             this.b=false;
           }
           if(row["invoiceType"]=="zs"){
             this.a=false;
             this.c=true;
             this.d=true;
             this.b=false;
           }
           this.form.electronicInvoiceUrl=row["electronicInvoiceUrl"];
           this.form.expressNum=row["expressNum"];
           this.form.expressDate=row["expressDate"];
           this.form.expressCompany=row["expressCompany"];
           this.$refs.card.changeButtonState();
           this.$refs.containerGrid.showDlgForm();
         }
         if(key=="myinvoice"){
           console.log("----------------myinvoice");
           console.log(row);
           this.form.invoiceHeadUp=row["invoiceHeadUp"];
           this.form.taxpayerID=row["taxpayerID"];
           this.form.applyAddr=row["applyAddr"];
           this.form.applytelephone=row["applytelephone"];
           this.form.bankAddrNum=row["bankAddrNum"];
           this.form.content=row["content"];
           this.form.mobile=row["mobile"];
           this.form.address=row["address"];
           this.form.email=row["email"];
           this.form.totalSum=row["totalSum"];
           if(row["invoiceType"]=="pt"){
             if(row["electronicInvoiceUrl"]!=null &&row["electronicInvoiceUrl"]!=""){
               var url=row["electronicInvoiceUrl"];
               window.open(url);
             }else{
               this.$message.warning(`电子发票未开具，不可查看`);
             }
           }
           if(row["invoiceType"]=="zy"){
             if(row["expressNum"]!=""&&row["expressNum"]!=null&&row["expressDate"]!=""&&row["expressDate"]!=null&&row["expressCompany"]!=""&&row["expressCompany"]!=null){
               this.a=false;
               this.c=true;
               this.d=false;
               this.form.expressNum=row["expressNum"];
               this.form.expressDate=row["expressDate"];
               this.form.expressCompany=row["expressCompany"];
               this.b=true;
               this.$refs.card.changeButtonState();
               this.$refs.containerGrid.showDlgForm();
             }else{
               this.$message.warning(`纸质普通发票未开具，不可查看`);
             }
           }
           if(row["invoiceType"]=="zs"){
             if(row["expressNum"]!=""&&row["expressNum"]!=null&&row["expressDate"]!=""&&row["expressDate"]!=null&&row["expressCompany"]!=""&&row["expressCompany"]!=null){
               this.a=false;
               this.c=true;
               this.d=true;
               this.form.expressNum=row["expressNum"];
               this.form.expressDate=row["expressDate"];
               this.form.expressCompany=row["expressCompany"];
               this.b=true;
               this.$refs.card.changeButtonState();
               this.$refs.containerGrid.showDlgForm();
             }else{
               this.$message.warning(`纸质专用发票未开具，不可查看`);
             }
           }
         }
         if(key=="myedit"){
           if(row["statusName"]=="已提交"){
             this.$router.push({path:"/platform/invoicedetail",query:{orderNum:row.orderNum,k:key}});
           }else{
             this.$message.warning(`发票已处理，不可修改`)
           }
         }
       },
       onColFormater(row,column,cellvalue,index){
         if(column.property=="created_at"){
           var date = new Date(row["created_at"]);
           var time= date.toLocaleDateString();
           return time;
         }
         if(column.property=="invoiceType"){
           if(row["invoiceType"]=="pt"){
             return "电子普通发票";
           }
           if(row["invoiceType"]=="zy"){
             return "纸质普通发票";
           }
           if(row["invoiceType"]=="zs"){
             return "纸质专用发票";
           }
         }
         return cellvalue;
       },
       onDlgFormClick(k,model){
         console.log("-----------------------------------model1");
         if(k=="saving"){
           console.log("--------------------------------------zhangjiao");
           var that=this;
           this.modelName="invoice";
           var url=this.getUrl("update");
           var obj={
             id:this.orderid,
             electronicInvoiceUrl:this.form.electronicInvoiceUrl,
             expressCompany:this.form.expressCompany,
             expressDate:this.form.expressDate,
             expressNum:this.form.expressNum,
             status:"processed",
             statusName:"已完成",
          };
          console.log(obj);
          if(this.invoiceType=="pt"){
            console.log("---------------------------------pt");
            if(this.form.electronicInvoiceUrl!=""&&this.form.electronicInvoiceUrl!=null){
                console.log("----------------------------1111111");
                this.$root.postReq(url,obj).then(rd=>{
                  console.log(rd.status);
                  if(rd.status==0){
                    that.$refs.containerGrid.showLeft();
                    that.$refs.containerGrid.status="common";
                    that.$refs.containerGrid.fetchData();
                  }
              });
            }else{
              this.$message.warning(`请填写电子发票链接`);
            }
          }
          if(this.invoiceType=="zy"||this.invoiceType=="zs"){
            console.log("---------------------------------zy");
            if(this.form.expressCompany!=""&&this.form.expressDate!=""&&this.form.expressNum!=""){
              console.log("----------------------------------------------22222");
              this.$root.postReq(url,obj).then(rd=>{
                console.log(rd.status);
               if(rd.status==0){
                 that.$refs.containerGrid.showLeft();
                 that.$refs.containerGrid.status="common";
                 that.$refs.containerGrid.fetchData();
               }
             });
            }else{
              this.$message.warning(`请填写纸质发票相关快递信息`);
            }
          }
         }
         if(k=="mysave"){
           if(model.electronicInvoiceUrl!=""&&model.electronicInvoiceUrl!=null){
             var that=this;
             this.modelName="invoice";
             var url=this.getUrl("update");
             model.status="processed";
             model.version+=1;
             model.statusName="已完成";
             this.$root.postReq(url,model).then(rd=>{
               if(rd.status==0){
                 that.$refs.containerGrid.showLeft();
                 that.$refs.containerGrid.status="common";
                 that.$refs.containerGrid.fetchData();
               }
             });
           }else{
             this.$message.warning(`请填写电子发票链接`);
           }
         }
       },
       toolbarclick(key,b,selectedRows){
         var that=this;
         this.modelName="invoice";
         if(key=="mynew"){
            this.$router.push("/sysmag/myinvoiceapply");
         }
         var url=this.getUrl("update");
         if(key=="dealings"){
           console.log("-------------------------dealings");
           console.log(selectedRows);
           if(selectedRows==null){
             this.$message.warning(`请选择至少一行记录`);
           }else{
             this.$confirm('此操作将处理所有选中的发票, 是否继续?', '提示', {
              confirmButtonText: '确定',
              cancelButtonText: '取消',
              type: 'warning'
            }).then(()=>{
              selectedRows.forEach(d=>{
                if(d.status!="submitted"){
                  this.$message.warning('请查看订单号为'+ d.orderNum +'的状态是否为已提交');
                }else{
                  d.status="processing";
                  d.statusName="处理中";
                  d.version+=1;
                  var that=this;
                  this.modelName="invoice";
                  var url=this.getUrl("update");
                  this.$root.postReq(url,d).then(rd=>{
                    if(rd.status==0){
                      that.$refs.containerGrid.fetchData();
                    }
                  }).catch(function(e){
                    that.$message.warning(`操作失败，请刷新页面后重新操作`);
                  });
                }
              });
            });
           }
         }
       },
       fetchData:function(){

       },
       handleSelectionChange:function(val){
         this.multipleSelection = val;
         console.log(this.cc);
       },
       headerCellStyle:function(){
         return {"background-color":"red"};
       },
    },
    computed:{
      headStyle:function(){
        return {"background-color":"white"};
      }
    },
    vname:"gsb-invoice"
}
