美文网首页
前端定时任务

前端定时任务

作者: Hush____ | 来源:发表于2021-06-30 11:23 被阅读0次
    <template>
        <div class="logo">
        </div>
    </template>
    
    <script>
    export default {
        name: "",
        computed: {
         
        },
        data(){
          return {
              getDdsListTimer: null,
              getDdsValidateTimer: null
          }
        },
        mounted(){
            // this.validateDdsLogin(); //初始化获取session
            // this.getDdsListTimer = setInterval(this.getDdsList, 10000);   //数据每10秒同步一次
            // this.getDdsValidateTimer = setInterval(this.validateDdsLogin, 1800000); //权限身份每半小时秒同步一次
        },
        beforeDestroy(){
            // clearInterval(this.getDdsListTimer);
            // clearInterval(this.getDdsValidateTimer);
        },
        methods: {
            async validateDdsLogin(){
                await this.$datadiscovery.get("/portal/frame/login/validate-login/manage_report?userID=VTIwMDAwMDA=&userPassword=XWIHJkvKjtkoq92BRot1Bg==").then((res) => {
                    console.log("dds权限认证成功:" + JSON.stringify(res.data));
                },(err) => {
                    this.$Message.danger("dds权限认证失败" + err);
                });
            },
            async getDdsList(){
                console.log("获取dds列表数据定时任务启动。")
                
                let dtwinLbael = 'LABEL84110E3B50E04FD8BAE9B4D280BA93A7'; //dts分类标签
                let listParam = "?page=0&rows=100&type=all&labelIds=" + dtwinLbael;
                
                await this.$datadiscovery.get("/report/myreport/manage/query-reps/manage_report" + listParam).then((res) => {
                    // console.log(JSON.stringify(res.data));
                    this.getRows = res.data.reportList.rows;
                    this.insertToTwins();
                },(err) => {
                    this.$Message.danger("获取dds列表数据失败" + err);
                });
            },
            async insertToTwins(){
                let paramList = [];
                for(let i = 0; i < this.getRows.length; i++){
                    if(this.getRows[i].delFlag != '0' || this.getRows[i].dataDeletaFlag != '0'){
                        break;
                    }
    
                    let chart = {};
                    chart.reportId = this.getRows[i].reportId;
                    chart.compName = this.getRows[i].reportName;
                    chart.updateTime = this.getRows[i].adminTime;
                    chart.comment = this.getRows[i].reportConfig;
                    chart.imgbyte = this.getRows[i].imgByte;
                    paramList.push(chart);
                }
    
                await this.$confParmJson.post("/component/compInfo/addDtsComponent", JSON.stringify(paramList)).then((res) => {
                     console.log(res.data.message)
                },(err) => {
                    this.$Message.danger("dds组件入库异常" + err);
                });
    
            }
        }
    };
    </script>
    
    

    相关文章

      网友评论

          本文标题:前端定时任务

          本文链接:https://www.haomeiwen.com/subject/ogfrultx.html