Browse Source

sync 后台

MaiXinRong 5 years ago
parent
commit
53940bf8f5
1 changed files with 42 additions and 0 deletions
  1. 42 0
      app/lib/rpt_data_analysis.js

+ 42 - 0
app/lib/rpt_data_analysis.js

@@ -0,0 +1,42 @@
+'use strict';
+
+/**
+ *
+ *
+ * @author Mai
+ * @date
+ * @version
+ */
+
+const changeSort = {
+    name: '变更令排序',
+    hint: '默认的变更令排序,同时对变更令,变更清单进行排序',
+    /**
+     *
+     * @param ctx - context常量
+     * @param data - 全部数据源{Array}
+     * @param fieldsKey - 计算字段
+     */
+    fun: function (ctx, data, fieldsKey) {
+        if (!data.change || data.change_audit_list) return;
+        // 变更令排序
+        data.change.sort(function (a, b) {
+            return a.code.localeCompare(b.code);
+        };
+        data.change_audit_list.sort(function (a, b) {
+            const aCIndex = data.change.findIndex(function (c) {
+                return c.cid === a.cid;
+            });
+            const bCIndex = data.change.findIndex(function (c) {
+                return c.cid === b.cid;
+            });
+            return aCIndex === bCIndex
+                ? ctx.helper.compareCode(a.code, b.code)
+                : aCIndex - bCindex;
+        })
+    },
+};
+
+module.exports = {
+    changeSort,
+};