|
@@ -221,7 +221,6 @@ const gatherChapter = {
|
|
|
},
|
|
|
customSetting1: {
|
|
|
count: 7,
|
|
|
- other: 1,
|
|
|
gclSum: {
|
|
|
name: '第100章至700章清单合计',
|
|
|
order: 1,
|
|
@@ -755,6 +754,66 @@ const union = {
|
|
|
data.mem_union_data = result;
|
|
|
}
|
|
|
};
|
|
|
+const addSumChapter = {
|
|
|
+ name: '添加章级合计',
|
|
|
+ defaultSetting: {
|
|
|
+ table: 'mem_stage_bills',
|
|
|
+ code: 'b_code',
|
|
|
+ chapter: 'chapter',
|
|
|
+ stdChapter: { title: '%s章', sum: '%s章合计'},
|
|
|
+ otherChapter: { title: '其他章', sum: '其他章合计'},
|
|
|
+ sum: { name: '总合计' },
|
|
|
+ fields: ['ex_value1', 'ex_value2', 'end_gather_tp', 'pre_gather_tp', 'gather_tp'],
|
|
|
+ },
|
|
|
+ fun: function (ctx, data, fields, options) {
|
|
|
+ if (!options || !options.table || !options.code || !options.chapter || !options.stdChapter) return;
|
|
|
+
|
|
|
+ const gclData = data[options.table];
|
|
|
+ if (!gclData || !data.tender_info) return;
|
|
|
+
|
|
|
+ const chapters = ctx.helper._.uniq(ctx.helper._.map(gclData, options.chapter));
|
|
|
+ for (const chapter of chapters) {
|
|
|
+ const chapterInfo = data.tender_info.chapter.find(function (x) { return x.code === chapter});
|
|
|
+ const chapterOptions = chapterInfo ? options.stdChapter : options.otherChapter;
|
|
|
+ // sum
|
|
|
+ const chapterGcl = gclData.filter(function (x) {
|
|
|
+ return x.chapter === chapter;
|
|
|
+ });
|
|
|
+ const sum = { chapter: chapter, chapterPart: 3, chapterNum: parseInt(chapter) };
|
|
|
+ for (const cg of chapterGcl) {
|
|
|
+ cg.chapterPart = 2;
|
|
|
+ cg.chapterNum = parseInt(cg[options.chapter]);
|
|
|
+ for (const f of options.fields) {
|
|
|
+ sum[f] = ctx.helper.add(sum[f], cg[f]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (chapterOptions.sum !== undefined) {
|
|
|
+ sum.name = chapterOptions.sum.replace('%s', chapter);
|
|
|
+ gclData.push(sum);
|
|
|
+ }
|
|
|
+ // title
|
|
|
+ if (chapterOptions.title !== undefined) {
|
|
|
+ const title = { chapter: chapter, chapterPart: 1, chapterNum: parseInt(chapter) };
|
|
|
+ if (chapterInfo) {
|
|
|
+ title[options.code] = options.stdChapter.title.replace('%s', chapter);
|
|
|
+ title.name = chapterInfo.name;
|
|
|
+ } else {
|
|
|
+ title.name = chapterOptions.title;
|
|
|
+ }
|
|
|
+ gclData.push(title);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ gclData.sort(function (a, b) {
|
|
|
+ if (a.chapter !== b.chapter) {
|
|
|
+ return a.chapterNum - b.chapterNum;
|
|
|
+ } else if (a.chapterPart !== b.chapterPart) {
|
|
|
+ return a.chapterPart - b.chapterPart;
|
|
|
+ } else {
|
|
|
+ return ctx.helper.compareCode(a[options.code], b[options.code]);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+};
|
|
|
|
|
|
const analysisObj = {
|
|
|
changeSort,
|
|
@@ -766,6 +825,7 @@ const analysisObj = {
|
|
|
filter,
|
|
|
union,
|
|
|
gatherStagePay,
|
|
|
+ addSumChapter,
|
|
|
};
|
|
|
const analysisDefine = (function (obj) {
|
|
|
const result = [];
|