{
    template:'${tmpl}',
    data:function(){
      var validateAddr = (rule, value, callback) => {
        var x = /(([省])|([中][国])|([中][华][人][民][共][和][国])|([北][京][市])|([上][海][市])|([天][津][市])|([重][庆][市])|([内][蒙][古])|([广][西])|([宁][夏])|([新][疆])|([西][藏])|([内][蒙][古][自][治][区])|([新][疆][维][吾][尔][自][治][区])|([广][西][壮][族][自][治][区])|([宁][夏][回][族][自][治][区])|([西][藏][自][治][区]))/g.test(value);
        if (!x) {
          callback(new Error('请检查申请人地址，必须出现省市县（区）三级！'));
        }else {
         callback();
       }
     };
      var colorizedtm = (rule, value, callback) => {
       if (this.form.tmFormType=="7" && value=="") {
         callback(new Error('请上传彩色商标图样'));
       } else {
         callback();
       }
     };
     var validateIdCard = (rule, value, callback) => {
       if (this.form.type=="person") {
         if(value==""){
           callback(new Error('请输入身份证号码'));
         }else{
           var x= /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(value);
           if(!x){
             callback(new Error('身份证格式错误'));
           }else{
               callback();
           }
         }
       } else {
           callback();
       }
    };
        return {
          refbizcode:'',
          bizCode:'',
          filterText: '',
          status:"",
          data2: [{
            id: 1,
            label: '一级 1',
            children: []
          }],
          ncldata:[
            {code:"01",name:"化学原料"},{code:"02",name:"颜料油漆"},{code:"03",name:"日化用品"},{code:"04",name:"燃料油脂"},{code:"05",name:"医药"},
            {code:"06",name:"金属材料"},{code:"07",name:"机械设备"},{code:"08",name:"手工器械"},{code:"09",name:"科学仪器"},{code:"10",name:"医疗器械"},
            {code:"11",name:"灯具空调"},{code:"12",name:"运输工具"},{code:"13",name:"军火烟火"},{code:"14",name:"珠宝钟表"},{code:"15",name:"乐器"},
            {code:"16",name:"办公用品"},{code:"17",name:"橡胶制品"},{code:"18",name:"皮革皮具"},{code:"19",name:"建筑材料"},{code:"20",name:"家具"},
            {code:"21",name:"厨房洁具"},{code:"22",name:"绳网袋篷"},{code:"23",name:"纱线丝"},{code:"24",name:"布料床单"},{code:"25",name:"服装鞋帽"},
            {code:"26",name:"纽扣拉链"},{code:"27",name:"地毯席垫"},{code:"28",name:"健身器材"},{code:"29",name:"食品"},{code:"30",name:"方便食品"},
            {code:"31",name:"饲料种籽"},{code:"32",name:"啤酒饮料"},{code:"33",name:"酒"},{code:"34",name:"烟草烟具"},{code:"35",name:"广告销售"},
            {code:"36",name:"金融物管"},{code:"37",name:"建筑修理"},{code:"38",name:"通讯服务"},{code:"39",name:"运输贮藏"},{code:"40",name:"材料加工"},
            {code:"41",name:"教育娱乐"},{code:"42",name:"网站服务"},{code:"43",name:"餐饮住宿"},{code:"44",name:"医疗园艺"},{code:"45",name:"社会服务"}

          ],
          bigtype:[{value: '人工智能',label: '人工智能',
                          children: [{value: '技术研究',label: '技术研究',},{value: '智能办公',label: '智能办公',}, {value: '智能驾驶',label: '智能驾驶',}, {value: '智能教育',label: '智能教育',}, {value: '智能穿戴',label: '智能穿戴',}]},
                   {value: '文教娱|传媒、教育、文化、娱乐',label: '文教娱|传媒、教育、文化、娱乐',
                          children: [{value: '影视',label: '影视',}, {value: '教育培训',label: '教育培训',}, {value: '文化娱乐',label: '文化娱乐',}, {value: '旅游服务',label: '旅游服务',}]},
                   {value: '服务业|餐饮、修理安装',label: '服务业|餐饮、修理安装',
                          children: [{value: '餐饮',label: '餐饮',}, {value: '修理安装',label: '修理安装',}]},
                   {value: '商业服务|广告、金融、法律财务人力服务',label: '商业服务|广告、金融、法律财务人力服务',
                          children: [{value: '广告、会展',label: '广告、会展',},{value: '人力资源',label: '人力资源',},{value: '创业孵化器',label: '创业孵化器',},{value: '金融财务',label: '金融财务',},{value: '商业咨询',label: '商业咨询',},{value: '法律服务',label: '法律服务',}]},
                   {value: '房产建材|建筑工程监理物管',label: '房产建材|建筑工程监理物管',
                          children: [{value: '装饰装潢',label: '装饰装潢',},{value: '家具家居',label: '家具家居',},{value: '建材',label: '建材',},{value: '建筑、监理',label: '建筑、监理',}]},
                   {value: '交通物流|运输、仓储、物流、快递、车辆养护',label: '交通物流|运输、仓储、物流、快递、车辆养护',
                          children: [{value: '物流运输、快递',label: '物流运输、快递',},{value: '车辆养护、维修',label: '车辆养护、维修',},{value: '物流仓储',label: '物流仓储',}]},
                   {value: '医药保健化工能源',label: '医药保健化工能源',
                          children: [{value: '化工能源',label: '化工能源',},{value: '眼镜面罩',label: '眼镜面罩',},{value: '医疗保健',label: '医疗保健',},{value: '医疗器械',label: '医疗器械',},{value: '药品',label: '药品',},{value: '医疗服务',label: '医疗服务',}]},
                   {value: '食品饮料|生鲜、保健产品、烟酒糖茶',label: '食品饮料|生鲜、保健产品、烟酒糖茶',
                          children: [{value: '烟酒糖茶、饮料',label: '烟酒糖茶、饮料',},{value: '营养产品',label: '营养产品',},{value: '生鲜食品、糕点',label: '生鲜食品、糕点',},{value: '珠宝钟表',label: '珠宝钟表',},{value: '美容、化妆品',label: '美容、化妆品',},{value: '服装、配饰',label: '服装、配饰',}]},
                   {value: 'IT、互联网||通信、电子、互联网',label: 'IT、互联网||通信、电子、互联网',
                          children: [{value: '在线服务',label: '在线服务',},{value: '游戏',label: '游戏',},{value: '社交、论坛',label: '社交、论坛',},{value: '电商平台',label: '电商平台',},{value: '软件开发运营',label: '软件开发运营',},{value: '家电产品',label: '家电产品',},{value: '计算机及周边',label: '计算机及周边',},{value: '通信',label: '通信',}]},
                   {value: '农业|农、林、牧、渔等',label: '农业|农、林、牧、渔等',
                          children: [{value: '化肥、饲料',label: '化肥、饲料',},{value: '农产品加工',label: '农产品加工',}]},
                   {value: '机械制造|机械车辆五金工具',label: '机械制造|机械车辆五金工具',
                          children: [{value: '五金器械',label: '五金器械',},{value: '车船航空器制造',label: '车船航空器制造',},{value: '机械、加工制造',label: '机械、加工制造',}]},

                 ],
              selectedOptions: [],
          defaultProps: {
            children: 'children',
            label: function(data,node){
              if(data.code==null || data.code==null){
                return data.name;
              }else{
                return data.code+" "+data.name;
              }
            }
          },
          form:{
            applyName:"",
            applyAddr:"",
            zipCode:"",
            createAuthorizeStuff:"",
            customerContact:"",
            mobile:"",
            picUrl:"",
            colorizedPicUrl:"",
            tmName:"",
            tmFormType:"3",
            nclTotalPublicExpense:0,
            nclServiceCharge:0,
            totalSum:0,
            invoiceTaxes:0,
            totalPlatformCost:0,
            creditCode:"",
            identityCard:"",
            type:"",
            id:0,
            disabled:false,
          },

          rules: {
            type: [
              {type:'string', required: true, message: '请选择申请类型', trigger: 'change' },
            ],
            applyName: [
              { required: true, message: '请输入商标申请人姓名'},
            ],
            applyAddr: [
              { required: true, message: '请输入商标申请地址'},
              {validator: validateAddr, trigger: 'blur' }
            ],
            zipCode: [
              { required: true, message: '请输入邮政编码'},
            ],

            customerContact: [
              { required: true, message: '请输入联系人姓名' },
            ],
            mobile: [
              { required: true, message: '请输入联系电话'}
            ],
            email: [
              { required: true, message: '请输入联系邮箱' }
            ],
            tmName: [
              {required: true, message: '请输入商标名称'}
            ],
            picUrl: [
              {required: true, message: '请上传商标图样' }
            ],
            colorizedPicUrl:[
              { validator: colorizedtm,trigger: 'blur'}
            ],
            tmFormType: [
              {required: true, message: '请选择商标类型'}
            ],
            identityCard:[ { validator: validateIdCard, trigger: 'blur' }],
          },
          nclOne:[],
          d:{},
          action:"",
          platformUseFee:0,
          invoiceTaxRate:5,
          selectedCalcs:null,
          calcNclNums:0,
          calids:'',
          selectedOrder:null,
        }
    },
    computed: Vuex.mapState({
      count:state=>state.count,
      headStyle:function(){
        return {"background-color":"white"};
      }
    }),
    created:function(){

      if(this.codePath.indexOf("allcalctm")>=0){
        console.log("mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm");
        console.log(this.codePath);
        this.bizCode="allcalctm";
        this.refbizcode="orderhookreference";
      }else{
        this.bizCode="calculateprice";
        this.refbizcode="myorderhookreference";
      }
    },
    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;
        });
        this.$root.getReq("/web/pconfigCtl/getConfigValue",{configType:"platformUseProfit"}).then(function(d){
            console.log(d);
            if(d!=null && d.configValue!=null && d.configValue!=""){
              that.platformUseFee=Number(d.configValue);
            }
        });
        this.$root.getReq("/web/pconfigCtl/getConfigValue",{configType:"invoiceTaxRate"}).then(function(d){
            console.log(d);
            if(d!=null && d.configValue!=null && d.configValue!=""){
              that.invoiceTaxRate=Number(d.configValue);
            }
        });
    },
    methods:{
      getDefaultQuery(){
        console.log("mmmmmmmmmmmmmmmmmmmmmnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnbbbbbbbbbbbbbbbb");
        return {
          "orderSourceType":"2",
          "isHooked":0,
        };
      },
      gotoorder:function(){
        this.$router.push("/products/order/13");
      },
      searchInputBlur(){
        var text=this.filterText;
        if(text=="" || text==null){
          this.initNclData();
        }
      },
      nclSearch(){
        var that=this;
        var text=this.filterText;
        if(text=="" || text==null){
          this.initNclData();
        }else{
          this.$root.showMask();
          this.$root.getReq("/web/calculatepriceCtl/getNclByLikeName",{"name":text}).then(function(d){
            if(d.status==0){
              console.log(d);
              that.ncldata=d.data;
            }
            that.$root.hideMask();
          }).catch(function(e){
            that.$root.hideMask();
          });
        }
      },
      initNclData(){
        this.ncldata=[
          {code:"01",name:"化学原料"},{code:"02",name:"颜料油漆"},{code:"03",name:"日化用品"},{code:"04",name:"燃料油脂"},{code:"05",name:"医药"},
          {code:"06",name:"金属材料"},{code:"07",name:"机械设备"},{code:"08",name:"手工器械"},{code:"09",name:"科学仪器"},{code:"10",name:"医疗器械"},
          {code:"11",name:"灯具空调"},{code:"12",name:"运输工具"},{code:"13",name:"军火烟火"},{code:"14",name:"珠宝钟表"},{code:"15",name:"乐器"},
          {code:"16",name:"办公用品"},{code:"17",name:"橡胶制品"},{code:"18",name:"皮革皮具"},{code:"19",name:"建筑材料"},{code:"20",name:"家具"},
          {code:"21",name:"厨房洁具"},{code:"22",name:"绳网袋篷"},{code:"23",name:"纱线丝"},{code:"24",name:"布料床单"},{code:"25",name:"服装鞋帽"},
          {code:"26",name:"纽扣拉链"},{code:"27",name:"地毯席垫"},{code:"28",name:"健身器材"},{code:"29",name:"食品"},{code:"30",name:"方便食品"},
          {code:"31",name:"饲料种籽"},{code:"32",name:"啤酒饮料"},{code:"33",name:"酒"},{code:"34",name:"烟草烟具"},{code:"35",name:"广告销售"},
          {code:"36",name:"金融物管"},{code:"37",name:"建筑修理"},{code:"38",name:"通讯服务"},{code:"39",name:"运输贮藏"},{code:"40",name:"材料加工"},
          {code:"41",name:"教育娱乐"},{code:"42",name:"网站服务"},{code:"43",name:"餐饮住宿"},{code:"44",name:"医疗园艺"},{code:"45",name:"社会服务"}
        ];
      },
      error(err){
        this.$message.warning(`上传失败，请重新上传`);
        console.log(err);
      },
      uploadsuccess(obj){
        var that=this;
        if(obj.flag=="picUrl"){
          that.$root.showMask();
          this.$root.getReq("/web/calculatepriceCtl/toblack",{"key":obj.key}).then(function(d){
            if(d.status==0){
              that.form.picUrl=d.data.url;
              that.$root.hideMask();
            }else{
              that.form.picUrl="";
              that.$root.hideMask();
              that.$message.warning(`上传失败请重新上传`);
              return false;
            }

          }).catch(function(){
            that.form.picUrl="";
            that.$root.hideMask();
            that.$message.warning(`上传失败请重新上传`);
            return false;
          });
        }
        if(obj.flag=="colorizedPicUrl"){
          that.$root.showMask();
          this.$root.getReq("/web/calculatepriceCtl/adjustTMSize",{"key":obj.key}).then(function(d){

            if(d.status==0){
              that.form.colorizedPicUrl=d.data.url;
              that.$root.hideMask();
            }else{
              that.form.colorizedPicUrl="";
              that.$root.hideMask();
              that.$message.warning(`上传失败请重新上传`);
              return false;
            }
          }).catch(function(){
            that.form.colorizedPicUrl="";
            that.$root.hideMask();
            that.$message.warning(`上传失败请重新上传`);
            return false;
          });

        }
      },
      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);

      },
      showUrl(url){
        window.open(url);
      },
      rowClick(row,key,t,e){
        if(key=="detail" || key=="myedit"){
          var nclObj=row.nclSmallCodes;
          if(nclObj!=null && nclObj!=""){
            var nclJson=JSON.parse(nclObj);
            this.nclOne=nclJson.ncl;
          }else{
            this.nclOne=[];
          }
          this.form=row;
          this.form.tmFormType=Number(row.tmFormType);
          this.status=key;
          this.$refs.card.changeButtonState();
          this.$refs.grid.showDlgForm();

        }
        if(key=="mydelete"){
          if(row.status=="2"){
            this.$message.warning(`删除失败，该提报单已创建订单`);
            return false;
          }else{
            this.$refs.grid.rowClick(row,"delete",t,e);
          }
        }
        if(key=="createWTS"){
          var that=this;
            var calcCodes= row.code;
            this.$root.showMask();
            var url=window.location.href.split("#")[0]+"mobile2#/products/createwts/"+calcCodes;
            this.$root.getReq("/web/calculatepriceCtl/createWTS",{"url":url,"code":calcCodes}).then(function(d){

              if(d.data.url!="" && d.data.url!=null){
                that.$refs.grid.fetchData();
                that.showUrl(d.data.url);
              }else{
                that.$message.warning(`操作失败，请刷新页面后重新操作`);
              }
              that.$root.hideMask();
            }).catch(function(e){
              that.$root.hideMask();
              that.$message.warning(`操作失败，请刷新页面后重新操作`);
            });

        }
        if(key=="downloadWTS"){
          if(row.createAuthorizeStuff=="" || row.createAuthorizeStuff==null){
            this.$message.warning(`委托书尚未生成`);
            return false;
          }
          window.open(row.createAuthorizeStuff);
        }
      },
      toolbarclick(key,b,selectedRows){
        if(key=="hookorder"){
          /*校验大类数量*/
          this.selectedCalcs=selectedRows;
          if(this.selectedCalcs && this.selectedCalcs.length>0){
            var nclOneCalcNums=0;
            var calidarray=[];
            var s = new Set();
            this.selectedCalcs.forEach(c=>{
              nclOneCalcNums+=c.nclOneCodes.split(",").length;
              s.add(c.applyName);
              calidarray.push(c.id);
            });
            this.calids=calidarray.join(",");
            if(s.size>1){
              this.$alert('选择交付的商标档案的申请人必须一致', '提示', {
                 confirmButtonText: '确定',
                 callback: action => {

                 }
               });
              return;
            }
            this.calcNclNums=nclOneCalcNums;
            this.$refs.reforderdlg.show();
          }else{
            this.$alert('请选择要交付的商标档案', '提示', {
               confirmButtonText: '确定',
               callback: action => {

               }
             });
          }


        }
        if(key=="myOrderSubmit"){
          this.$router.push("/products/order/13");
        }
        if(key=="mynew"){
          this.status=key;
          this.form={
            applyName:"",
            applyAddr:"",
            zipCode:"",
            createAuthorizeStuff:"",
            customerContact:"",
            mobile:"",
            picUrl:"",
            colorizedPicUrl:"",
            email:"",
            tmName:"",
            tmFormType:"3",
            nclTotalPublicExpense:0,
            nclServiceCharge:0,
            totalSum:0,
            invoiceTaxes:0,
            totalPlatformCost:0,
            creditCode:"",
            selecttype:"自主选择",
            id:0,
          };
          this.nclOne=[];
          this.$refs.card.changeButtonState();
          this.$refs.grid.showDlgForm();
        }
        if(key=="copy"){
          var that=this;
          if(selectedRows==null || selectedRows.length!=1){
            this.$message.warning(`请选择一行记录`);
            return false;
          }else{
            this.$root.getReq("/web/calculatepriceCtl/copy",{"calcId":selectedRows[0].id}).then(function(d){

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

        }
        if(key=="makeOrder"){
          var that=this;
          var calcCodes="";
          var calcCodes2=[];
          if(selectedRows==null || selectedRows.length<1){
            this.$message.warning(`请选择记录`);
            return false;
          }else{
            var applier=selectedRows[0].applyName;
            for(var i=0;i<selectedRows.length;i++){
              if(applier!=selectedRows[i].applyName){
                that.$message.warning(`生成订单失败，所选提报单商标申请人不一致`);
                return false;
              }
              calcCodes2.push(selectedRows[i].code);
              if(i==(selectedRows.length-1)){
                calcCodes=calcCodes+selectedRows[i].code;
              }else{
                calcCodes=calcCodes+selectedRows[i].code+",";
              }
            }
            this.$root.getReq("/web/calculatepriceCtl/findByCodes",{"codes":calcCodes2}).then(function(d){

              for(var i=0;i<d.data.count;i++){

                if(d.data.rows[i].status!="1"){
                  that.$message.warning(`该提报单已生成订单，不能再次生成`);
                  that.$refs.grid.fetchData();
                  return;
                }
              }
              that.$router.push("/products/calculatepricedetail/"+calcCodes);
            }).catch(function(){
              that.$message.warning(`操作失败，请刷新页面后重新操作`);
            });

            return;
          }

        }

      },
      onDlgFormClick(type,b){
        if(type=="mysave"){
          var that=this;
          if(this.nclOne.length<1){
            that.$message.warning(`尼斯选项不能为空，请选择商标小项`);
            return false;
          }
          this.$root.showMask();
          var obj={
            type:this.status,
            form:this.form,
            ncl:this.nclOne,
          };
          console.log("onDlgFormClick>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
          
          var a=this.updatePrice();
          if(a==false){
              this.$root.hideMask();
             return false;
           }
          this.$refs["form"].validate((valid) => {
            if (valid) {
              this.$root.postReq("/web/calculatepriceCtl/save",obj).then(function(d){
                  if(d.status==0){
                    if(that.status=="mynew"){
                        that.$refs.grid.$message({
                          type: 'success',
                          message: '新增成功!'
                        });
                    }
                    if(that.status=="myedit"){
                        that.$refs.grid.$message({
                          type: 'success',
                          message: '修改成功!'
                        });
                    }

                    that.$root.hideMask();
                    that.$refs.grid.hideDlgForm();
                    that.$refs.card.changeButtonState();
                    that.$refs.grid.fetchData();
                  }else{
                    that.$root.hideMask();
                    that.$message.warning(d.msg);
                  }

              }).catch(function(e){
                that.$root.hideMask();
                that.$message.warning(`操作失败，请刷新页面后重新操作`);
              });
            } else {
              console.log('error submit!!');
              that.$root.hideMask();
              return false;
            }

          });

        }
      },
      closeTag(nclThree,index,index2){
        if( this.form.status == 2 ){
          this.$message.warning("已生成订单，不可修改");
          return false;
        }
        this.nclOne[index].nclThree.splice(index2,1);
        if(this.nclOne[index].nclThree.length>10){
          this.nclOne[index].price=Number(300+(this.nclOne[index].nclThree.length-10)*30);
        }else if(this.nclOne[index].nclThree.length>0 && this.nclOne[index].nclThree.length<=10){
          this.nclOne[index].price=300;
        }else{
          this.nclOne[index].price=0;
          this.removeNclOne(index);
        }
        this.updatePrice();
        var json={json:this.nclOne};
        var jsonStr=JSON.stringify(json);
      },
      removeNclOne(index){
          if( this.form.status == 2 ){
            this.$message.warning("已生成订单，不可修改");
            return false;
          }
          this.nclOne.splice(index,1);
          this.updatePrice();
      },
      nodeClick(obj,e,a){
        var that = this;
        if( this.form.status == 2 ){
          this.$message.warning("已生成订单，不可修改");
          return false;
        }
        if(e.level<3 && e.childNodes.length==0){
          var o={
            nclcode:obj.code,
          };
          this.$root.getReq("/web/ncloneCtl/getNcl",o).then(function(d){
            var data=d.data.rows;
            for(var i=0;i<data.length;i++){
              that.appendNode(data[i],e);
            }
          });
        }
        if(e.level==3){
          var ppncl=e.parent.parent.data;
          var nclThree=[e.data];

          var result=this.nclOneIsExist(ppncl.code);
            if(result.result){
              var nclThree=this.nclOne[result.index].nclThree;
              var hasNclThree=this.nclThreeIsExist(e.data.name,nclThree);
              if(!hasNclThree.result){
                this.nclOne[result.index].nclThree.push(e.data);
                if(this.nclOne[result.index].nclThree.length>10){
                  this.nclOne[result.index].price=Number(300+(this.nclOne[result.index].nclThree.length-10)*30);
                }

              }
            }else{
              var data={
                code:ppncl.code,
                name:ppncl.name,
                price:300,
                nclThree:nclThree,
              };
              this.nclOne.push(data);
            }
            this.updatePrice();
        }
      },
      nclThreeIsExist(name,nclThree){
        if(nclThree.length<1){
          return {result:false,index:0};
        }else{
          for(var i=0;i<nclThree.length;i++){
            if(nclThree[i].name==name){
              return {result:true,index:i};
            }
          }
          return {result:false,index:0};
        }
      },
      nclOneIsExist(nclOneCode){
        if(this.nclOne.length<1){
          return {result:false,index:0};
        }else{
          for(var i=0;i<this.nclOne.length;i++){
            if(this.nclOne[i].code==nclOneCode){
              return {result:true,index:i};
            }
          }
          return {result:false,index:0};
        }
      },
      word2pic(){
        if(this.form.tmName=="" || this.form.tmName==null){
          this.$root.showMask();
          this.$root.hideMask();
          return false;
        }
        var obj={word:this.form.tmName};
        var that=this;
        this.$root.showMask();
        this.$root.getReq("/web/calculatepriceCtl/word2pic",obj).then(function(d){

          if(d.status==0){
            that.form.picUrl=d.data.url;
            that.$root.hideMask();
          }else{
            that.form.picUrl="";
            that.$root.hideMask();
            that.$message.warning(`上传失败请重新生成`);
            return false;
          }

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

      },
      updatePrice(){
        this.form.totalSum=parseFloat(this.form.totalSum);
        this.form.invoiceTaxes=parseFloat(this.form.totalSum)-parseFloat(this.form.totalSum/(1+(this.invoiceTaxRate/100)));
        this.form.invoiceTaxes=this.form.invoiceTaxes.toFixed(2);
        this.form.totalPlatformCost=0;
        this.form.nclTotalPublicExpense=0;
        for(var i=0;i<this.nclOne.length;i++){
          this.form.nclTotalPublicExpense=this.form.nclTotalPublicExpense+this.nclOne[i].price;
        }
        this.form.totalPlatformCost=parseFloat(this.platformUseFee)*this.nclOne.length;
        this.form.nclServiceCharge=parseFloat(this.form.totalSum-this.form.totalPlatformCost-this.form.nclTotalPublicExpense-this.form.invoiceTaxes);
        this.form.nclServiceCharge=this.form.nclServiceCharge.toFixed(2);
        if(parseFloat(this.form.nclServiceCharge)<0){
          this.form.totalSum=0;
          this.form.invoiceTaxes=0;
          this.form.nclServiceCharge=0;
          this.$message.warning(`提报金额不足，请重新输入`);
          return false;
        }

      },
      appendNode (data,pnode) {

        this.$refs.tree.append(data,pnode);
      },
      filterNode(value, data) {
        if (!value) return true;
        return data.label.indexOf(value) !== -1;
      },
      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 orderNclNums=selorder.itemOrderNum;
            if(this.calcNclNums!=orderNclNums){
              this.$alert('选择交付的件数必须与订单上件数'+orderNclNums+"相同", '提示', {
                 confirmButtonText: '确定',
                 callback: action => {

                 }
               });
               return;
            }
            /*开始挂接*/
            var oid=selorder.id;
            var cids=this.calids;
            console.log(cids);
            var x={
              "oid":oid,
              "cids":cids,
              "orderNum":selorder.orderNum,
            };
            this.$root.postReq("/web/calculatepriceCtl/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{
           this.$alert('最多选择一条订单挂接', '提示', {
              confirmButtonText: '确定',
              callback: action => {

              }
            });
         }
      },
      onRefColFormater(row,column,cellvalue,index){
        return cellvalue;
      },
      onColFormater(row,column,cellvalue,index){
        if(column.property=="status"){
          if(row["status"]==1){
            return "未创建订单";
          }else{
            return "已创建订单";
          }
        }
        if(column.property=="created_at"){
            var date = new Date(row["created_at"]);
            var time= date.toLocaleString();
            return time;
        }
        return cellvalue;
       },
      pageChanged(ps,cp,searchObj){
        if(searchObj==null){
          return false;
        }
        var obj={
            search:searchObj,
            pageInfo:{
              pageSize:ps,
              pageNo:cp
            }
        };
        var that=this;
        this.$root.postReq("/web/calculatepriceCtl/findAndCountAll",obj).then(function(d){
            that.$refs.grid.data=d.data.rows;
        }).catch(function(e){
          that.$message.warning(`操作失败，请刷新页面后重新操作`);
        });
      },
      applierChange(){
        console.log(this.form.applyName);
        this.$root.getReq("/web/calculatepriceCtl/getEntregistryByCompanyName",{companyName:this.form.applyName}).then(d=>{
          console.log(d);
          if(d.businessAddress && d.businessAddress!=""){
            this.form.applyAddr=d.businessAddress;
            this.form.creditCode=d.creditCode;
          }
        });
      },
      aiadive(){
        if( this.form.status == 2 ){
          this.$message.warning("已生成订单，不可修改");
          return false;
        }
        if( this.selectedOptions.length == 0 )
        {
          this.$message.warning(`请选择行业`);
          return false;
        }
        this.$root.getReq("/web/calculatepriceCtl/aiadive",{seltype:this.selectedOptions}).then(d=>{
          console.log(d.data);
          var ncl=JSON.parse(d.data);
          this.nclOne=ncl.ncl;
          this.updatePrice();
        });
      },
      selfclear(){
        this.nclOne=[];
      }
    },

    vname:"gsb-calculateprice"
}
