mui offline View

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

Merge function (oldData) {
the let Array.from List = (oldData);
// the source data to target data becomes the rule
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);
});

/ **
* weight go, after the merger
* 1, source data deduplication
* 2, the data source and the data to the combined weight of the same name the citys
* /
var newData = []
var newobj = {}
oldDataRule. forEach ((EL, I) => {
IF (newobj [el.item_id]) {!
newData.push (EL);
newobj [el.item_id] = to true;
} the else {
newData.forEach (EL => {
IF ( === oldDataRule el.item_id [I] .item_id) {
el.measure_data = el.measure_data.concat (oldDataRule [I] .measure_data);
}
})
}

});
return newData;

}

Guess you like

Origin www.cnblogs.com/yyjspace/p/11599256.html
Recommended