{
    template:'${tmpl}',
    data:function(){
        var wgqPic = (rule, value, callback) => {
          if(!this.form.wgqPic && this.form.patentsType=="wg"){
            callback(new Error('请上传前视图'));
          }else{
            callback();
          }
        };
        var wghPic = (rule, value, callback) => {
          if(!this.form.wghPic && this.form.patentsType=="wg"){
            callback(new Error('请上传后视图'));
          }else{
            callback();
          }
        };
        var wgzPic = (rule, value, callback) => {
          if(!this.form.wgzPic && this.form.patentsType=="wg"){
            callback(new Error('请上传左视图'));
          }else{
            callback();
          }
        };
        var wgyPic = (rule, value, callback) => {
          if(!this.form.wgyPic && this.form.patentsType=="wg"){
            callback(new Error('请上传右视图'));
          }else{
            callback();
          }
        };
        var wgfstPic = (rule, value, callback) => {
          if(!this.form.wgfstPic && this.form.patentsType=="wg"){
            callback(new Error('请上传俯视图'));
          }else{
            callback();
          }
        };
        var wgystPic = (rule, value, callback) => {
          if(!this.form.wgystPic && this.form.patentsType=="wg"){
            callback(new Error('请上传仰视图'));
          }else{
            callback();
          }
        };
        var wgltPic = (rule, value, callback) => {
          if(!this.form.wgltPic && this.form.patentsType=="wg"){
            callback(new Error('请上传立体视图'));
          }else{
            callback();
          }
        };
        var zipFile =(rule, value, callback) => {
          if(this.form.zipFile==""||this.form.zipFile==null){
            callback(new Error('请上传申请人的发明人资质'));
          }else{
            callback();
          }
        };
        var registrationFormUrl =(rule, value, callback) => {
          if(this.form.registrationFormUrl==""||this.form.registrationFormUrl==null){
            callback(new Error('请上传登记表'));
          }else{
            callback();
          }
        };
        var technicalFileUrl =(rule, value, callback) => {
          if(this.form.technicalFileUrl==""&&this.form.patentsType=="fm"){
            callback(new Error('请上传技术交底书'));
          }else{
            callback();
          }
        };
        return {
          dialogFormVisible:false,
          multipleSelection: [],
          isSingleSelect:false,
          bizCode:"patentarch",
          refbizcode:'mypatentorderhookreference',
          action:"",
          d:{},
          form:{
            statusName:"",
            statusProgress:"",
            totalSum:"",
            orderNum:"",
            patentsName:"",
            patentsType:"",
            applicantRequireType:["fyjh"],
            applierType:"",
            applyName:"",
            applyAddr:"",
            mobile:"",
            customerContact:"",
            customerMobile:"",
            zipFile:"",
            wgqPic:"",
            wghPic:"",
            wgzPic:"",
            wgyPic:"",
            wgfstPic:"",
            wgystPic:"",
            wgltPic:"",
            registrationFormUrl:"",
            technicalFileUrl:""
          },
          rules:{
            patentsName:[
              {required: true, message:'请输入专利名称'}
            ],
            patentsType:[
              {required: true, message:'请选择申请专利类型'}
            ],
            applierType: [
              { required: true, message: '请选择申请人类型' }
            ],
            applyName: [
              {required: true, message: '请输入申请人'}
            ],
            applyAddr:[
              {required: true, message: '请输入申请人地址'}
            ],
            mobile:[
              {required: true, message: '请输入申请人电话'}
            ],
            customerContact:[
              {required: true, message: '请输入联系人'}
            ],
            customerMobile:[
              {required: true, message: '请输入联系电话'}
            ],
            wgqPic:[
              { validator: wgqPic,trigger: 'blur'}
            ],
            wghPic:[
              { validator: wghPic,trigger: 'blur'}
            ],
            wgzPic:[
              { validator: wgzPic,trigger: 'blur'}
            ],
            wgyPic:[
              { validator: wgyPic,trigger: 'blur'}
            ],
            wgfstPic:[
              { validator: wgfstPic,trigger: 'blur'}
            ],
            wgystPic:[
              { validator: wgystPic,trigger: 'blur'}
            ],
            wgltPic:[
              { validator: wgltPic,trigger: 'blur'}
            ],
            zipFile:[
              { validator: zipFile,trigger: 'blur'}
            ],
            registrationFormUrl:[
              { validator: registrationFormUrl,trigger: 'blur'}
            ],
            technicalFileUrl:[
              { validator: technicalFileUrl,trigger: 'blur'}
            ],
          },
          selectPatent:[],
          selectOrder:[],
          selectIds:[],
          patentstatus:"",

        }
    },
    computed: Vuex.mapState({
      count:state=>state.count,
      headStyle:function(){
        return {"background-color":"white"};
      }
    }),
    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(){
      if(this.codePath.indexOf("allpatent")>=0){
        this.bizCode="allpatent";
        this.refbizcode="allpatentorderhookreference";
      }else{
        this.bizCode="patentarch";
        this.refbizcode="mypatentorderhookreference";
      }

    },
    methods:{
      getDefaultQuery(){
        return {
          "orderSourceType":"2",
          "isHooked":0,
          "itemType":"pa",
          "orderStatus":"4",
        };
      },
      onRefColFormater(row,column,cellvalue,index){
        return cellvalue;
      },
      seltoolbarclick(selectedRows,key){
         console.log("selectedRows..........................");
         console.log(selectedRows);
         this.selectedOrder=selectedRows;
         if(this.selectedOrder && this.selectedOrder.length==1){
            var selorder=this.selectedOrder[0];
            var itemNum=selorder.itemOrderNum;
            if(this.selectPatent.length!=itemNum){
              this.$alert('选择关联的版权服务数量必须与订单产品数量'+"相同", '提示', {
                 confirmButtonText: '确定',
                 callback: action => {
                 }
               });
               return;
            }
            /*开始挂接*/
            var oid=selorder.id;
            var cids="";
            var calidarray=[];
            var s = new Set();
            this.selectPatent.forEach(c=>{
              calidarray.push(c.id);
            });
            cids=calidarray.join(",");

            var x={
              "oid":oid,
              "cids":cids,
              "orderNum":selorder.orderNum,
            };
            console.log(x);
            this.$root.postReq("/web/patentinfoCtl/hookOrder",x).then(d=>{
              if(d.status==0){
                 this.$message({"type":"success","message":'关联订单成功。'});
                 this.$refs.reforderdlg.refreshData();
                 this.$refs.grid.fetchData();
                 this.$refs.reforderdlg.close();
              }else {
                 this.$message.error('关联订单失败！');
                 this.$refs.reforderdlg.close();
              }
            });

         }else{
           if(!this.selectedOrder){
             this.$alert('至少选择一条订单进行关联', '提示', {
                confirmButtonText: '确定',
                callback: action => {

                }
              });
           }else{
             this.$alert('最多选择一条订单进行关联', '提示', {
                confirmButtonText: '确定',
                callback: action => {

                }
              });
           }

         }
      },
      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;
       },
       changeStatus(ids,status){
         var that=this;
         if(!status){
           this.$message.warning(`请选择专利进度`);
           return;
         }
         this.$root.postReq("/web/patentinfoCtl/changeStatus",{ids:ids,status:status}).then(function(d){
           if(d.code=="1"){
             that.$message({
               type: 'success',
               message: '状态成功!'
             });
             that.dialogFormVisible = false;
             that.$refs.grid.fetchData();
           }else{
             that.$message.warning(`操作失败，请刷新页面后重新操作`);
           }
         }).catch(function(e){
           that.$message.warning(`操作失败，请刷新页面后重新操作`);
         });
       },

      error(e){
        console.log(e);
      },
       uploadsuccess(obj){
         var that=this;
         console.log("++++++++++++++++++++++++++++++");
         console.log(obj);
         if(obj.flag=="sqrzz"){
           console.log("-------------------------");
           that.form.zipFile=obj.result;
         }
         if(obj.flag=="djb"){
           that.form.registrationFormUrl=obj.result;
         }
         if(obj.flag=="jsjds"){
           that.form.technicalFileUrl=obj.result;
         }

       },

       toolbarclick(key,b,selectedRows){
         if(key=="editStatus"){
           this.selectIds=[];
           this.patentstatus="";
           if(!selectedRows || selectedRows.length<1){
             this.$message.warning(`请选择至少一行记录`);
             return false;
           }else{
             var ids = [];
             for(var i=0;i<selectedRows.length;i++){
               ids.push(selectedRows[i].id);
               if(selectedRows[i].status!="2" ){
                 this.$message.warning(`存在未关联订单的版权服务`);
                 return false
               }
             }
             this.selectIds=ids;
             this.dialogFormVisible=true;
           }
         }
         if(key=="mynew"){
           this.form={
             statusName:"",
             statusProgress:"",
             totalSum:"",
             orderNum:"",
             patentsName:"",
             patentsType:"",
             applicantRequireType:["fyjh"],
             applierType:"",
             applyName:"",
             applyAddr:"",
             mobile:"",
             customerContact:"",
             customerMobile:"",
             wgqPic:"",
             wghPic:"",
             wgzPic:"",
             wgyPic:"",
             wgfstPic:"",
             wgystPic:"",
             wgltPic:"",
             zipFile:"",
             registrationFormUrl:"",
             technicalFileUrl:""
           };
           this.$refs.card.changeButtonState();
           this.$refs.grid.showDlgForm();
           return;
         }
        if(key=="copy"){
          var that=this;
          if(selectedRows==null || selectedRows.length!=1){
            this.$message.warning(`请选择一行记录`);
            return false;
          }else{
            this.$root.getReq("/web/patentinfoCtl/copy",{"id":selectedRows[0].id}).then(function(d){

              that.$refs.grid.hideDlgForm();
              that.$refs.grid.fetchData();
            }).catch(function(e){
              that.$message.warning(`操作失败，请刷新页面后重新操作`);
            });
          }
          return;
        }
        if(key=="myBack"){
          var that=this;

          if(!selectedRows || selectedRows.length<1){
            this.$message.warning(`请选择至少一行记录`);
            return false;
          }else{
            var ids = [];
            for(var i=0;i<selectedRows.length;i++){
              ids.push(selectedRows[i].id);
              if(selectedRows[i].statusProgress!="WAITARTIFICIALEXAMINE" ){
                that.$message.warning(`只能撤销等待人工审核状态的档案`);
                return false
              }
            }
            this.$root.postReq("/web/patentinfoCtl/changeStatus",{ids:ids,status:"AWAITCHECK"}).then(function(d){
              if(d.code=="1"){
                that.$message({
                  type: 'success',
                  message: '撤销成功!'
                });
                that.$refs.grid.fetchData();
              }else{
                that.$message.warning(`操作失败，请刷新页面后重新操作`);
              }
            }).catch(function(e){
              that.$message.warning(`操作失败，请刷新页面后重新操作`);
            });
          }
        }
        if(key=="mycheck"){
          var that=this;
          if(!selectedRows || selectedRows.length<1){
            this.$message.warning(`请选择至少一行记录`);
            return false;
          }else{
            var ids = [];
            for(var i=0;i<selectedRows.length;i++){
              ids.push(selectedRows[i].id);
              if(selectedRows[i].status!="2" ){
                that.$message.warning(`审核失败，存在未关联订单的档案`);
                return false
              }
              if(selectedRows[i].statusProgress!="AWAITCHECK" && selectedRows[i].statusProgress!="AUDITFAIL" ){
                that.$message.warning(`只能审核未提交以及审核不通过状态的档案`);
                return false
              }

            }
            this.$root.postReq("/web/patentinfoCtl/changeStatus",{ids:ids,status:"WAITARTIFICIALEXAMINE"}).then(function(d){
              if(d.code=="1"){
                that.$message({
                  type: 'success',
                  message: '审核成功!'
                });
                that.$refs.grid.fetchData();
              }else{
                that.$message.warning(`操作失败，请刷新页面后重新操作`);
              }
            }).catch(function(e){
              that.$message.warning(`操作失败，请刷新页面后重新操作`);
            });
          }
        }
        if(key=="hookorder"){
          if(selectedRows==null || selectedRows.length<1){
            this.$message.warning(`请选择记录`);
            return false;
          }
          console.log(selectedRows);
          var patenttype=selectedRows[0].patentsType;
          var applier=selectedRows[0].applyName;
          for(var i=0;i<selectedRows.length;i++){
            if(selectedRows[i].status!="1"){
              this.$message.warning(`关联失败，请检查档案状态`);
              return false;
            }
            if(selectedRows[i].patentsType!=patenttype){
              this.$message.warning(`关联失败，版权类型必须一致`);
              return false;
            }
            if(selectedRows[i].applyName!=applier){
              this.$message.warning(`关联失败，申请人必须一致`);
              return false;
            }
          }
          this.selectPatent=selectedRows;
          this.$refs.reforderdlg.show();
        }

      },

       rowClick(row,key,t,e){
         console.log(key);
         console.log(row);
         if(key=="myedit" || key=="mydetail"){
           console.log("----------------------------myedit--------------------");
           console.log(row.applicantRequireType);
           this.form = row;
           this.form.applicantRequireType= row.applicantRequireType.split(",");
           this.$refs.card.changeButtonState();
           this.$refs.grid.showDlgForm();
         }
       },
       setKey(name,flag){
         console.log(name);
         console.log(flag);
         name=name.substring(name.length-5);
         var myDate = new Date();
         var key = "copyright_"+myDate.getMonth()+myDate.getTime()+myDate.getMilliseconds()+name.split(".")[1];
         console.log(this.$refs[flag]);
         this.$refs[flag].d.key = key;
       },
      onDlgFormClick(type,b){
        console.log(type);
        console.log(b);
        if(type=="mysave"){
          this.patentSave();
        }
       },
       patentSave:function(){
         if(this.form.status=="2"){
           this.$message.warning(`保存失败，该档案已关联订单`);
           return false;
         }
         var that=this;
         this.$refs["form"].validate((valid) => {
           if(valid){
             var obj = this.form;
             console.log(obj);
             console.log("aaaaaaaaaaaaaaaaaaaaaaaa");
             this.$root.postReq("/web/patentinfoCtl/createOrEdit",obj).then(function(d){
               console.log(d);
               if(d.code=="1"){
                 that.$message({"type":"success","message":'保存成功'});
                 that.$root.hideMask();
                 that.$refs.grid.hideDlgForm();
                 that.$refs.card.changeButtonState();
                 that.$refs.grid.fetchData();
               }else{
                 that.$message.warning(`保存失败`);
               }
             })
           }
         })

       },

    },

    vname:"gsb-patentarch"
}
