|
@@ -1991,6 +1991,41 @@ const masterCross = {
|
|
|
data[options.target] = this._converse(ctx, options, mainTable, subTable);
|
|
|
},
|
|
|
};
|
|
|
+const orderBy = {
|
|
|
+ name: "简单排序",
|
|
|
+ hint: "仅提供简单的排序",
|
|
|
+ defaultSetting: {
|
|
|
+ table: 'mem_material_sum_gl',
|
|
|
+ orders: [['m_order', 'asc']],
|
|
|
+ },
|
|
|
+ fun(ctx, data, fieldsKey, options, csRela) {
|
|
|
+ if (!options || !options.table || !options.orders) return;
|
|
|
+
|
|
|
+ const ascSort = function (x, y, field) {
|
|
|
+ if (!x[field]) return 1;
|
|
|
+ if (!y[field]) return -1;
|
|
|
+ return x[field] === y[field] ? 0 : (x[field] > y[field] ? 1 : -1);
|
|
|
+ };
|
|
|
+ const descSort = function (x, y, field) {
|
|
|
+ if (!x[field]) return -1;
|
|
|
+ if (!y[field]) return 1;
|
|
|
+ return x[field] === y[field] ? 0 : (x[field] > y[field] ? -1 : 1);
|
|
|
+ };
|
|
|
+ const orderFun = [];
|
|
|
+ for (const order of options.orders) {
|
|
|
+ if (order.length !== 2) return;
|
|
|
+ if (['asc', 'desc'].indexOf(order[1]) === -1) return;
|
|
|
+ orderFun.push({ field: order[0], fun: order[1] === 'asc' ? ascSort : descSort });
|
|
|
+ }
|
|
|
+
|
|
|
+ data[options.table].sort((x, y) => {
|
|
|
+ for (const order of orderFun) {
|
|
|
+ const sortResult = order.fun(x, y, order.field);
|
|
|
+ if (sortResult !== 0) return sortResult;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+};
|
|
|
|
|
|
const analysisObj = {
|
|
|
changeSort,
|
|
@@ -2016,7 +2051,8 @@ const analysisObj = {
|
|
|
treeFilter,
|
|
|
gatherGcl2,
|
|
|
gatherMaterialGl,
|
|
|
- masterCross
|
|
|
+ masterCross,
|
|
|
+ orderBy,
|
|
|
};
|
|
|
const analysisDefine = (function(obj) {
|
|
|
const result = [];
|