• Web SQL Database离线数据查看


    function GetConfirmItem() {
    var data = [];
    db.transaction(function(tx) {
    //查询所有整改项
    tx.executeSql(
    'select * from ry_confirm_item where confirm_id =? ',
    [String(confirm_id)],
    function(tx, rs) {
    if (rs.rows.length > 0) {
    data = merge(rs.rows);
    }
    //console.log(data)
    var html = template('confirm-item', data);
    $(".item").html(html);
    mui('#scroll1').pullRefresh().endPullupToRefresh(true);
    });
    });
    };
    
    function merge(oldData) {
    let list = Array.from(oldData);
    // 把源数据先变成目标数据的规则
    var oldDataRule = [];
    
    list.forEach(el => {
    var oldObj = {
    item_id: el.item_id,
    item_type: el.item_type,
    detail_content: el.detail_content,
    report_id: el.report_id,
    rectify_item_id: el.rectify_item_id,
    measure_data: [],
    }
    var measureObj = {
    id: el.id,
    confirm_id: el.confirm_id,
    report_item_id: el.report_item_id,
    is_conform: el.is_conform,
    measure_name: el.measure_name
    }
    oldObj.measure_data.push(measureObj);
    oldDataRule.push(oldObj);
    });
    
    /**
    * 先去重,后合并
    * 1、源数据去重
    * 2、把去重后的数据和源数据中相同name的数据合并citys
    */
    var newData = []
    var newObj = {}
    oldDataRule.forEach((el, i) => {
    if (!newObj[el.item_id]) {
    newData.push(el);
    newObj[el.item_id] = true;
    } else {
    newData.forEach(el => {
    if (el.item_id === oldDataRule[i].item_id) {
    el.measure_data = el.measure_data.concat(oldDataRule[i].measure_data);
    }
    })
    }
    
    });
    return newData;
    
    }
  • 相关阅读:
    Vue学习笔记(4)-带参数路由,嵌套路由,编程式导航
    JS数组&&数组对象去重
    Vue学习笔记(3)-品牌管理系统
    Vue学习笔记(2)-组件生命周期
    负margin
    CSS布局奇淫巧计之-强大的负边距
    由浅入深漫谈margin属性
    双飞翼布局和圣杯布局的对比
    圣杯布局的实现过程
    CSS实现垂直居中的5种方法
  • 原文地址:https://www.cnblogs.com/yyjspace/p/11599256.html
Copyright © 2020-2023  润新知