{
    template:'${tmpl}',
    data:function(){
        var validateSFZ = (rule, value, callback) => {
         if (this.form.applier.type=="person" && value=="") {
           callback(new Error('身份证明不能为空'));
         } else {
           callback();
         }
       };
        return {
          activeNames: [0],
          d:{},
          action:"",
          title:"商标进度",
          multipleSelection: [],
          isSingleSelect:false,
          c:"hello",
          tableData: [],
          showData:0,
          stepOneShow:0,
          step:0,
          bizcode:"",
          steps:[
            {title:"订单号查询信息"},
            {title:"确认商标信息"},
            {title:"提交材料"}
          ],
          form:{
            query:{
              orderNum:"",
              tsclType:"4",
            },
            applier:{
              type:"",
              applyName:"",
              creditCode:"",
              applyAddr:"",
              identityCard:"",
              businessLicensePic:"",
              identityCardPic:"",
              priority_to_prove:"",
            },
            customer:{
              customerContact:"",
              mobile:"",
              email:"",
              zipCode:"",
              fax:"",
            },
            tminfo:[],
          },
          queryRules:{
            orderNum: [
              {required: true, message: '请输入订单号' },
            ],
            tsclType: [
              {required: true, message: '请选择处理类型' },
            ],
          },
          applierRules: {
            businessLicensePic: [
              {required: true, message: '营业执照不能为空' }
            ],
            identityCardPic: [ { validator: validateSFZ, trigger: 'blur' }],
          },
          customerRules: {
            customerContact: [
              {required: true, message: '请输入联系人名称' }
            ],
            mobile: [
              {required: true, message: '请输入联系电话'},
            ],
            zipCode:[
              {required: true, message: '请输入邮政编码'},
            ],
          },
          tmlistRules:{},
        }
    },
    mounted:function(){
      var that=this;
      this.$root.postReq("/web/uploadCtl/getOssConfig","").then(function(d){
          that.d["key"]="key";
          that.d["Bucket"]=d.Bucket;
          that.d["OSSAccessKeyId"]=d.OSSAccessKeyId;
          that.d["Signature"]=d.Signature;
          that.d["policy"]=d.policy;
          that.d["success_action_status"]=d.success_action_status;
          that.action=d.url;
      });
    },
    created:function(){
      console.log(this.codePath);
      if(this.codePath.indexOf("alltrademark")>=0){
        this.bizCode="alltrademark";
      }else{
        this.bizCode="trademark";
      }
    },
    methods:{
      orderQuery(){
          var that=this;
          that.$refs.query.validate((valid) => {
            if (valid) {
              that.form.applier={
                            type:"",
                            applyName:"",
                            creditCode:"",
                            applyAddr:"",
                            identityCard:"",
                            businessLicensePic:"",
                            identityCardPic:"",
                            priority_to_prove:"",
                          };
              that.form.customer={
                            customerContact:"",
                            mobile:"",
                            email:"",
                            zipCode:"",
                            fax:"",
                          };
              that.form.tminfo=[];
              var obj={orderNum:that.form.query.orderNum,tmStatus:that.form.query.tsclType};
              this.$root.getReq("/web/trademarkCtl/getOrderDetail",obj).then(function(d){
                if(d.code==1){
                  if(d.data.customer&&d.data.applier&&d.data.tms.count>0){
                    that.stepOneShow=12;
                    that.form.customer=d.data.customer;
                    that.form.applier=d.data.applier;
                     var calcs=d.data.tms.rows;
                     var bindNclList=[];
                     for(var i=0;i<calcs.length;i++){
                        var tItem=calcs[i];
                        var nclFindIndex1= bindNclList.findIndex(f=>f.tmName===tItem.tmName);
                        if(nclFindIndex1<0){
                          var nclItem={
                            id:tItem.id,
                            tmpPicUrl:"picUrl",
                            tmpColorizedPicUrlOne:"colorizedPicUrlOne",
                            tmpColorizedPicUrlTwo:"colorizedPicUrlTwo",
                            tmName:tItem.tmName,
                            sealAuthorizeStuff:tItem.sealAuthorizeStuff,
                            tmFormTypeName:tItem.tmFormTypeName,
                            picUrl:tItem.picUrl,
                            tmFormType:tItem.tmFormType,
                            colorizedPicUrl:tItem.colorizedPicUrl,
                            proxyCode:tItem.proxyCode,
                            tmRegistNum:tItem.tmRegistNum,
                            ncl:[]
                          };
                          bindNclList.push(nclItem);
                        }
                       var nclFindIndex2= bindNclList.findIndex(f=>f.tmName===tItem.tmName);
                       var tmpNcl={
                         code:tItem.nclOneCodes,
                         name:"",
                         proxyCode:tItem.proxyCode,
                         nclThree:JSON.parse(tItem.nclSmallCodes)
                       };
                       bindNclList[nclFindIndex2].ncl.push(tmpNcl);
                     }
                    that.form.tminfo=bindNclList;
                  }else {
                      that.$refs.grid.$message({
                        showClose: true,
                        type: 'warning',
                        duration:6000,
                        message: `订单状态正常，无需处理`
                      });
                  }
                }else {
                  that.$message.warning(`操作失败，请刷新页面后重新操作`);
                }
              }).catch(function(e){
                that.$message.warning(`操作失败，请刷新页面后重tmlistRules新操作`);
              });
            }else {
                this.$message.warning("请完善填写的数据再进行查询");
            }
          }
        );
      },
      tonext(){
        if(this.step=="1"){
          this.$refs.applier.validate((valid) => {
            if (valid) {
              this.$refs.customer.validate((valid) => {
                if (valid) {
                  this.step=Number(this.step)+1;
                  this.step=this.step.toString();
                }
              });
            }
          });
        }else{
          this.step=Number(this.step)+1;
          this.step=this.step.toString();
        }
      },
      tobefore(){
        this.step=Number(this.step)-1;
        this.step=this.step.toString();
      },
      beforeUpload(file){
        var that=this;
        var isSize = false;
        var img = new Image();
        var _URL = window.URL || window.webkitURL;
        img.onload=function(){
          console.log("11");
            if(img.width == img.height) {
                isSize = true;
                that.$refs.ys_upload.ifupload=true;
            } else {
                isSize = false;
                that.$message.warning('上传的图片宽高必须相等');
                that.$refs.ys_upload.$refs.upload.abort(file);
            }
        };
        img.src =window.URL.createObjectURL(file);

      },
      uploadsuccess(obj){
        var that=this;
        if(obj.flag=="yyzz"){
          that.$root.showMask();
          this.$root.getReq("/web/orderCtl/pic2pdf",{"key":obj.key}).then(function(d){
            if(d.status==0){
              that.form.applier.businessLicensePic=d.data.url;
            }else{
              that.form.applier.businessLicensePic="";
              that.$root.hideMask();
              that.$message.warning(`上传失败请重新上传`);
              return false;
            }
            that.$root.hideMask();
          }).catch(function(e){
            that.form.applier.businessLicensePic="";
            that.$root.hideMask();
            that.$message.warning(`上传失败请重新上传`);
            return false;
          })
        }
        if(obj.flag=="sfz"){
          that.$root.showMask();
          this.$root.getReq("/web/orderCtl/pic2pdf",{"key":obj.key}).then(function(d){
            if(d.status==0){
              that.form.applier.identityCardPic=d.data.url;
            }else{
              that.form.applier.identityCardPic="";
              that.$root.hideMask();
              that.$message.warning(`上传失败请重新上传`);
              return false;
            }
            that.$root.hideMask();
          }).catch(function(e){
            that.form.applier.identityCardPic="";
            that.$root.hideMask();
            that.$message.warning(`上传失败请重新上传`);
            return false;
          })
        }
      },
      error(err){
        this.$message.warning(`上传失败，请重新上传`);
      },
      success(obj){

      },
      uploadsuccess2(result,obj){
          var that=this;
          that.$refs[obj.flag][0].result="";
          that.$root.showMask();
          this.$root.getReq("/web/orderCtl/adjustWTSSize",{"key":obj.key}).then(function(d){
            if(d.status==0){
              that.$refs[obj.flag][0].result=d.data.url;
              that.$root.hideMask();
            }else{
              that.$refs[obj.flag][0].result="";
              that.$root.hideMask();
              that.$message.warning(`上传失败请重新上传`);
              return false;
            }

          }).catch(function(){
            that.$refs[obj.flag][0].result="";
            that.$root.hideMask();
            that.$message.warning(`上传失败请重新上传`);
            return false;
          });
      },
      uploadsuccessTmInfo(result){
        var that=this;
        if(result.flag.indexOf("picUrl")>=0){
          this.$root.getReq("/web/calculatepriceCtl/toblack",{"key":result.key}).then(function(d){
            if(d.status==0){
              result.dataSouce.picUrl=d.data.url;
              that.$root.hideMask();
            }else{
              that.$root.hideMask();
              that.$message.warning(`上传失败请重新上传`);
              return false;
            }

          }).catch(function(){
            that.$root.hideMask();
            that.$message.warning(`上传失败请重新上传`);
            return false;
          });
        }
        if(result.flag.indexOf("colorizedPicUrl")>=0){
          this.$root.getReq("/web/calculatepriceCtl/adjustTMSize",{"key":result.key}).then(function(d){
            if(d.status==0){
              result.dataSouce.colorizedPicUrl=d.data.url;
              that.$root.hideMask();
            }else{
              that.$root.hideMask();
              that.$message.warning(`上传失败请重新上传`);
              return false;
            }

          }).catch(function(){
            that.$root.hideMask();
            that.$message.warning(`上传失败请重新上传`);
            return false;
          });

        }
      },
      word2pic(rowObj){
        if(rowObj.tmName=="" || rowObj.tmName==null){
          this.$root.showMask();
          this.$root.hideMask();
          return false;
        }
        var obj={word:rowObj.tmName};
        var that=this;
        this.$root.showMask();
        this.$root.getReq("/web/calculatepriceCtl/word2pic",obj).then(function(d){
          if(d.status==0){
            rowObj.picUrl=d.data.url;
            that.$root.hideMask();
          }else{
            rowObj.picUrl="";
            that.$root.hideMask();
            that.$message.warning(`上传失败请重新生成`);
            return false;
          }

        }).catch(function(){
          rowObj.picUrl="";
          that.$root.hideMask();
          that.$message.warning(`上传失败请重新生成`);
          return false;
        });
      },
      orderSubmit(){
        var that=this;
        this.$refs.stuff.validate((valid) => {
          if (valid) {
            for(var i=0;i<that.form.tminfo.length;i++){
              var wts=that.form.tminfo[i].sealAuthorizeStuff;
              if(wts=="" || wts==null || wts==undefined){
                that.$message.warning(`委托书不能为空`);
                return false;
              }
            }
            var obj={order:this.form.query,tms:this.form.tminfo,applier:this.form.applier,customer:this.form.customer};
            that.$root.postReq("/web/orderCtl/tsclResubmit",obj).then(function(d){
              if(d.code=="1"){
                that.step="1";
                that.$refs.grid.$message({
                  showClose: true,
                  type: 'success',
                  duration:6000,
                  message: '提报成功，请在商标档案查看商标进度!'
                });
                that.$refs.card.changeButtonState();
                that.$refs.grid.hideDlgForm();
                that.title="商标档案";
                that.$root.hideMask();
                that.$refs.grid.fetchData();
              }else{
                that.$message.warning(`操作失败，请刷新页面后重新操作`);
              }
            }).catch(function(e){
              that.$message.warning(`操作失败，请刷新页面后重新操作`);
            });

          }
        });
      },

/*列表*/
      dateFormat(row, column) {
        if(!row.created_at||row.created_at==undefined){
          return "";
        }
        var date = new Date(row.created_at);
        var year = date.getFullYear();
        var month = (date.getMonth()+1)<10 ? '0' + (date.getMonth()+1):(date.getMonth()+1);
        var day = date.getDate()<10 ? '0' + date.getDate():date.getDate();
        return year + '-' + month + '-' + day;
      },
      toolbarclick(key,b,selectedRows){
        var that=this;
        if(key=="tmhzuploadlist"){
          this.$router.push("/products/tmhzuploadlist");
        }
        else if(key=="tscl"){
          that.form.query.orderNum="";
          that.form.query.tsclType="4";
          if(selectedRows!=null && selectedRows.length>0){
            var orderNumDiff=0;
            var objOrderNum = {};
            var objTmStatus = {};
            var resultNumDiff = [];
            var resultTmStatus = [];
            for (var i = 0; i < selectedRows.length; i++) {
              if(!objOrderNum[selectedRows[i].orderNum]){
                objOrderNum[selectedRows[i].orderNum] = true;
                resultNumDiff.push(selectedRows[i].orderNum);
              }
              if(selectedRows[i].tmStatus=="4"||selectedRows[i].tmStatus=="FILLEXCEPTION"){
                if(!objTmStatus[selectedRows[i].tmStatus]){
                  objTmStatus[selectedRows[i].tmStatus] = true;
                  resultTmStatus.push(selectedRows[i].tmStatus);
                }
              }
            }
            if(resultNumDiff.length>1){
              that.$refs.grid.$message({
                showClose: true,
                type: 'warning',
                duration:4000,
                message: `只能选择同一个订单号的数据进行处理`
              });
              return false;
            }
            if(resultTmStatus.length==0){
              that.$refs.grid.$message({
                showClose: true,
                type: 'warning',
                duration:4000,
                message: `只能选择同一个订单号中状态为不予受理或填报异常的数据进行处理`
              });
              return false;
            }
            if(resultTmStatus.length>1){
              that.$refs.grid.$message({
                showClose: true,
                type: 'warning',
                duration:4000,
                message: `只能选择同一个订单号中同一状态的数据进行处理`
              });
              return false;
            }
            that.form.query.orderNum=selectedRows[0].orderNum;
            that.form.query.tsclType=selectedRows[0].tmStatus;
          }
          that.title="特殊处理";
          that.showData=2;
          that.step=1;
          that.stepOneShow=11;
          that.$refs.card.changeButtonState();
          that.$refs.grid.showDlgForm();
        }
        else if(key=="tmhzlook"){
          if(selectedRows==null || selectedRows.length!=1){
            this.$message.warning(`请选择一行记录`);
            return false;
          }else{
            if(selectedRows[0].tmRegistNum==null||selectedRows[0].tmRegistNum==""){
              this.$message.warning(`目前该数据还没有回执，敬请期待`);
              return false;
            }

            var options={"tmRegistNum":selectedRows[0].tmRegistNum};

            that.$root.postReq("/web/tmflowCtl/getDetail",options).then(function(d){
              if(d.code=="1"){
                that.showData=1;
                that.tableData=d.data.rows;
                that.$refs.grid.showDlgForm();
              }
              else{
                  that.$message.warning(`操作失败，请刷新页面后重新操作`);
                }

              }).catch(function(e){
                that.$message.warning(`操作失败，请刷新页面后重新操作!`);
              });

            }
          }
         else if(key=="awte"){
            if(selectedRows==null){
              this.$message.warning(`请选择一行记录`);
              return false;
            }else{
              this.$confirm('此操作将提交商标到机器人, 是否继续?', '提示', {
               confirmButtonText: '确定',
               cancelButtonText: '取消',
               type: 'warning'
             }).then(()=>{
              selectedRows.forEach(d=>{
                if(d.tmStatus!="WAITARTIFICIALEXAMINE"){
                  this.$message.warning('请查看代理号为'+ d.proxyCode +'的状态是否是等待人工提交');
                  return false;
                }else{
                  var param={status:"WAITCOMMIT",id:d.id};
                  this.$root.postReq("/web/trademarkCtl/putStatusById",param).then(rd=>{
                    if(rd.code==1){
                      that.$refs.grid.fetchData();
                    }
                  }).catch(function(e){
                    that.$message.warning(`操作失败，请刷新页面后重新操作`);
                  });
                }
              })
               }).catch(()=>{
               });
            }
          }
          else if(key=="repulses"){
             if(selectedRows==null){
               this.$message.warning(`请选择一行记录`);
               return false;
             }else{
               this.$prompt('', '原因', {
                 confirmButtonText: '确定',
                 cancelButtonText: '取消'
               }).then(({ value }) => {
               selectedRows.forEach(d=>{
                 if(d.tmStatus!="WAITARTIFICIALEXAMINE"){
                   this.$message.warning('请查看代理号为'+ d.proxyCode +'的状态是否是等待人工提交');
                   return false;
                 }else{
                   var param={status:"FILLEXCEPTION",remarkinfo:value,id:d.id};
                   this.$root.postReq("/web/trademarkCtl/putStatusById",param).then(rd=>{
                     if(rd.code==1){
                       that.$refs.grid.fetchData();
                     }
                   }).catch(function(e){
                     that.$message.warning(`操作失败，请刷新页面后重新操作`);
                   });
                 }
               })
                }).catch(()=>{
                });
             }
           }
          else if(key=="atoback"){
             if(selectedRows==null){
               this.$message.warning(`请选择一行记录`);
               return false;
             }else{
               this.$confirm('此操作将退回上一状态, 是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
              }).then(()=>{
               selectedRows.forEach(d=>{
                 if(d.tmStatus!="WAITCOMMIT"){
                   this.$message.warning('请查看代理号为'+ d.proxyCode +'的状态是否是待提交');
                   return false;
                 }else{
                   var param={status:"WAITARTIFICIALEXAMINE",id:d.id};
                   this.$root.postReq("/web/trademarkCtl/putStatusById",param).then(rd=>{
                     if(rd.code==1){
                       that.$refs.grid.fetchData();
                     }
                   }).catch(function(e){
                     that.$message.warning(`操作失败，请刷新页面后重新操作`);
                   });
                 }
               })
                }).catch(()=>{
                });
             }
           }
      },
      onDlgFormClick(type,b){
        if(type=="mysave"){

        }
        this.title="商标档案";
      },
       handleSelectionChange:function(val){
         this.multipleSelection = val;
         console.log(this.cc);
       },
       headerCellStyle:function(){
         return {"background-color":"red"};
       },
       onsave(m){
         console.log(m.content);
       },
       onColFormater(row,column,cellvalue,index){
         if(column.property=="created_at"){
             var date = new Date(row["created_at"]);
             var time= date.toLocaleString();
             return time;
         }
         return cellvalue;
        },

       rowClick(row,key){
         var that=this;
         if(key=="yyzz"){
           var url=row.applier.businessLicensePic;
           if(url==null || url==""){
             this.$message.warning(`营业执照尚未上传`);
           }else {
             window.open(row.applier.businessLicensePic);
           }
         }
         if(key=="sfz"){
           var url=row.applier.identityCardPic;
           if(url==null || url==""){
             this.$message.warning(`身份证尚未上传`);
           }else {
             window.open(row.applier.identityCardPic);
           }
         }
         if(key=="tedit"){
           this.$router.push("/platform/trademarkdetail/"+row.proxyCode);
         }
         if(key=="wte"){
           this.$confirm('此操作将提交商标到机器人, 是否继续?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(()=>{
           if(row.tmStatus!="WAITARTIFICIALEXAMINE"){
             this.$message.warning('请查看状态是否是等待人工提交');
             return false;
           }else{
             var param={status:"WAITCOMMIT",id:row.id};
             this.$root.postReq("/web/trademarkCtl/putStatusById",param).then(rd=>{
               if(rd.code==1){
                 console.log("--------------------------fetchData");
                 that.$refs.grid.fetchData();
               }
             }).catch(function(e){
               that.$message.warning(`操作失败，请刷新页面后重新操作`);
             });
           }
         }).catch(()=>{
         });
         }
         if(key=="repulse"){
           if(row.tmStatus!="WAITARTIFICIALEXAMINE"){
             this.$message.warning('请查看状态是否是等待人工提交');
             return false;
           }else{
           this.$prompt('', '原因', {
             confirmButtonText: '确定',
             cancelButtonText: '取消'
           }).then(({ value }) => {
             var param={status:"FILLEXCEPTION",remarkinfo:value,id:row.id};
             this.$root.postReq("/web/trademarkCtl/putStatusById",param).then(rd=>{
               if(rd.code==1){
                 that.$refs.grid.fetchData();
               }
             }).catch(function(e){
               that.$message.warning(`操作失败，请刷新页面后重新操作`);
             });

         }).catch(()=>{
         });
         }
         }
         if(key=="toback"){
           this.$confirm('此操作将退回上一状态, 是否继续?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(()=>{
           if(row.tmStatus!="WAITCOMMIT"){
             this.$message.warning('请查看状态是否是待提交');
             return false;
           }else{
             var param={status:"WAITARTIFICIALEXAMINE",id:row.id};
             this.$root.postReq("/web/trademarkCtl/putStatusById",param).then(rd=>{
               if(rd.code==1){
                 console.log("--------------------------fetchData");
                 that.$refs.grid.fetchData();
               }
             }).catch(function(e){
               that.$message.warning(`操作失败，请刷新页面后重新操作`);
             });
           }
         }).catch(()=>{
         });
         }
         if(key=="sbty"){
           var url=row.picUrl;
           console.log(row.tmFormType);
           if(row.tmFormType=="6" || row.tmFormType=="7"){
             url=row.colorizedPicUrl;
           }
           if(url==null || url==""){
             this.$message.warning(`商标图样尚未上传`);
           }else {
             window.open(url);
           }
         }

         if(key=="wts"){
           var url=row.sealAuthorizeStuff;
           if(url==null || url==""){
             this.$message.warning(`商标委托书尚未上传`);
           }else {
             window.open(row.sealAuthorizeStuff);
           }
         }
         if(key=="mydetail"){
          console.log("mydetail--------------row.orderNum");
          console.log(row.orderNum);
          this.$store.state.queryParam=row.orderNum;
          this.$router.push("/autosubmitorderdetail");
          return 
         }
       },
    },
    computed:{
      headStyle:function(){
        return {"background-color":"white"};
      }
    },
    vname:"gsb-autosubmittrademark"
}
