提交 61bafb0b authored 作者: 吴强's avatar 吴强

Merge branch 'master' of git://192.168.1.116/bolan-root/frontend/manager-app-sz into wq

# Conflicts: # src/models/login.js # src/routes/login.js #新做出来的界面,列表。
上级 2b48c022
import _ from 'lodash';
import { datasourceApi } from '../services/datasource';
export const getData = async (coordinate, { pst, psz, params = {}, filters = [], sortBys = [], sortTypes = [] }) => {
const options = { pst, psz, params, filters, sortBys, sortTypes };
const api = datasourceApi(coordinate);
const meta = await api.meta();
const dsb = await api.query(options);
return getArrayData(dsb, meta);
};
// const tmp = async(ddd) => {
// await
// }
// function abc() {
//
// for (cont a of b) {
// await a()
// }
// getData().then((r) => {
//
// }).catch(err => {
//
// })
// }
const getArrayData = ({ dataType, arrayData, singularData }, meta) => {
if (dataType === 'TABLE') {
const data = (arrayData || []).map(() => ({}));
(meta.properties || [])
.filter(property => !property.skip)
.forEach((property, i) => {
data.forEach((row, j) => {
row[property.name] = arrayData[j][i]; // eslint-disable-line no-param-reassign
});
});
return data;
} else if (dataType === 'PROPERTIES') {
const data = [];
(meta.properties || [])
.filter(property => !property.skip)
.forEach((property) => {
data.push((singularData || {})[property.name]);
});
return [_.toPlainObject(data)];
} else {
throw new Error(`Unsupported data type: ${dataType}`);
}
};
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论