{

    template: '${tmpl}',
        data
:

    function () {
        return {
            /*1.监控类型*/
            monit_type: '1',
            tabPosition: 'top',
            a: "",
            b: "",
            /*2.商标名称*/
            sbname: "",
            /*3.商标类型*/
            radio: '',
            /*4.申请号*/
            tm_regist_num: "",
            /*5.申请人*/
            applicant_cn: "",
            /*多选框*/
            checkAll: false,
            isIndeterminate: true,
            checkAllCategoryNum: false,
            categoryOptionNumbers: [
                "01", "02", "03", "04", "05", "06", "07", "08", "09", "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"
            ],
            checkedCategoryNum: [
                "01", "02", "03", "04", "05", "06", "07", "08", "09", "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"
            ],
            /*4.类别ncl_type*/
            ncl_type: [
                "01", "02", "03", "04", "05", "06", "07", "08", "09", "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"
            ],
            isnumIndeterminate: true,

            missOption: false,
            /*动态绑定class*/
            isActive: false,
            generateButton: "",
            tm_agency: "",
            /*弹出框*/
            showMask: false,
            /*监控数量*/
            dynamicsCount: 0,
            nofityQrcodeUrl: "",
            scansStyle: "display:black",
        };
    }

,
    watch: {
        /*监控按钮可用吗*/
        isActive: {
            handler: function (nowVal, oldVal) {
                if (this.sbname != "" && this.radio != "" && this.checkedCategoryNum.length != 0 && this.tm_regist_num != "" && this.applicant_cn != "") {
                    this.isActive = true
                } else {
                    this.isActive = false
                }
            }
        ,
            deep: true
        },

    },
    created: function() {
        $("#byctitle").text("标眼查-标眼监测");
       
    },
    methods: {
        createMonitoringReport(){
            /**
             this.$prompt('请输入邮箱,监控报告生成后将发至您的邮箱', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                inputPattern: /[\w!#$%&'*+/=?^_`{|}~-]+(?:\.[\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\w](?:[\w-]*[\w])?\.)+[\w](?:[\w-]*[\w])?/,
                inputErrorMessage: '邮箱格式不正确'
                }).then(({ value }) => {
                    
                }).catch(() => {
                      
                });
             */
            var companyname = this.applicant_cn;
            if(!companyname){
                this.$message.warning("请输入申请人");
                return false;
            }else{
                this.$prompt('请输入邮箱，监控报告生成后将发至您的邮箱', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    inputPattern: /[\w!#$%&'*+/=?^_`{|}~-]+(?:\.[\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\w](?:[\w-]*[\w])?\.)+[\w](?:[\w-]*[\w])?/,
                    inputErrorMessage: '邮箱格式不正确'
                }).then(({ value }) => {
                    this.$root.getReq("/web/toolCtl/createMonitoringReport", {companyname:companyname,email:value}).then(d=>{
                        console.log("ddddddddd");
                        console.log(d);
                        if(d && d.code==1){
                            this.$message.success("监控报告生成后将发至您的邮箱");
                        }else{
                            this.$message.warning("操作失败");
                        }
                    })
                }).catch(() => {
                        
                });
                
            }

        },
        checkLogin(){
            if(this.currentUser){
                return true;
            }else{
                this.$root.pushx({
                    title:"登录",
                    name:"/login"
                });
                localStorage.setItem("afterLogin",JSON.stringify({
                    title:"商标监控",
                    name:"/bytmmonit"
                }));
                return false;
            }
        },
        bytmmonitlistck()
        {
            if(this.checkLogin()){
                console.log("lllllllllllllllllllllllllllllllllllllllllllllllllddddd");
                var localurl = location.href;
                console.log(localurl);
                var base = localurl.split("bytmmonitlist");
                var url = base[0] + "bytmmonitlist";
                console.log(base);
                console.log(url);
                debugger;
                window.open(url);
            }
            
        },
        bytmmonitdynamics()
        {
            if(this.checkLogin()){
                var localurl = location.href;
                var base = localurl.split("bytmmonit");
                var url = base[0] + "bytmmonitdynamics";
                debugger;
                window.open(url);
            }
            
        },
        /*tab切换*/
        handleClick(tab, event)
        {
            console.log(tab, event);
            console.log('----------------------------------');
            console.log(this.monit_type);
            if (this.monit_type == "1") {
                this.a = true;
                this.b = false;
            }
            if (this.monit_type == "2") {
                this.a = false;
                this.b = true;
            }
        }
    ,

        /*多选框*/
        handleCheckAllCategoryNumChange(val){
            this.checkedCategoryNum = val ? [] : this.categoryOptionNumbers;
            this.isnumIndeterminate = !this.isnumIndeterminate;
        }
    ,
        handleCheckedCategoryNumChange(value)
        {
            let checkedCountCategory = value.length;
            this.checkAllCategoryNum = checkedCountCategory === this.ncl_type.length;
            this.isnumIndeterminate = checkedCountCategory > 0 && checkedCountCategory < this.ncl_type.length;
        }
    ,
        /*生成监控*/
        addMonit()
        {
            if(this.checkLogin()){
                console.log("monit_type...................");
                console.log(this.monit_type);
                if (this.monit_type == 2) {
                    if (!this.tm_agency || !this.tm_agency.trim()) {
                        this.$message.warning("代理机构不能为空");
                        return false;
                    }
                } else {
                    if ((!this.sbname || !this.sbname.trim()) && (!this.tm_regist_num || !this.tm_regist_num.trim()) && (!this.applicant_cn || !this.applicant_cn.trim())) {
                        this.$message.warning("请至少输入一个条件生成监控任务");
                        return false;
                    }
                    if (this.sbname && !this.radio) {
                        this.$message.warning("查询的类型（相同、近似、相同+近似），必须选择一个！");
                        return false;
                    }
                }
                var that = this;
                var obj = {
                    monit_type: this.monit_type,
                    name: this.sbname,
                    name_type: this.radio,
                    ncl_type: this.checkedCategoryNum,
                    tm_regist_num: this.tm_regist_num,
                    applicant_cn: this.applicant_cn,
                    tm_agency: this.tm_agency
                };
                that.$root.postReq("/web/bytmmonitCtl/addMonit", obj).then(function (d) {
                    if (d.code == 1) {
                        that.$root.pushx({
                            title:"",
                            name:"/bytmmonitlist"
                        });
                    } else if (d.code == -100) {
                        that.$message.warning("该监控任务已存在，请到我的监控列表中查看！");
                    } else {
                        that.$message.warning("该监控任务已存在，请到我的监控列表中查看");
                    }
                }).catch(function (e) {
                    that.$message.warning("保存失败!!!");
                    console.log(e);
                });
            }
            
        }
        ,
        checkGenerate()
        {

        },
        mask(){
            if(this.checkLogin()){
                this.showMask = !this.showMask;
            }
            
        },
        getNofityQrcodeUrl() {
            var self = this;
            this.$root.postReq("/web/bytmmonitCtl/notifyQrcode", {}).then(function (d) {
                if (d.code == 1) {
                    self.nofityQrcodeUrl = d.data || "";
                }
            }).catch(function (e) {
                console.log(e);
            });
        },
    }
,
    mounted: function () {
        this.a = true;
        var that = this;
        if(this.currentUser){
            that.$root.postReq("/web/bytmmonitCtl/getDynamicsCount", "").then(function (d) {
                that.dynamicsCount = d.data.count
            }).catch(function (e) {
                that.$message.warning(`操作失败，请刷新页面后重新操作`);
            });
            this.getNofityQrcodeUrl();
        }
      
    }
,
    vname: "gsb-bytmmonit"
}
