|
@@ -43,15 +43,34 @@ module.exports = app => {
|
|
|
}
|
|
|
|
|
|
analysisFilingType(filing) {
|
|
|
- const curFilingType = filing.filter(f => {
|
|
|
- return f.tree_level === 1;
|
|
|
- });
|
|
|
- curFilingType.sort((x, y) => {
|
|
|
- return x.tree_order - y.tree_order;
|
|
|
- });
|
|
|
- return curFilingType.map(f => {
|
|
|
- return { value: f.filing_type, name: f.name }
|
|
|
+ const copy = JSON.parse(JSON.stringify(filing));
|
|
|
+ const curFilingType = copy.filter(f => {
|
|
|
+ return f.is_fixed;
|
|
|
});
|
|
|
+ const checkChildren = function (parent) {
|
|
|
+ parent.children = curFilingType.filter(x => { return x.tree_pid === parent.id; });
|
|
|
+ if (parent.children.length > 1) parent.children.sort((x, y) => { return x.tree_order - y.tree_order; });
|
|
|
+ for (const c of parent.children) {
|
|
|
+ checkChildren(c);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ const topFiling = curFilingType.filter(x => { return x.tree_level === 1; });
|
|
|
+ topFiling.sort((x, y) => { return x.tree_order - y.tree_order; });
|
|
|
+ for (const tp of topFiling) {
|
|
|
+ checkChildren(tp);
|
|
|
+ }
|
|
|
+ const result = [];
|
|
|
+ const getFilingType = function(arr, prefix = '') {
|
|
|
+ for (const a of arr) {
|
|
|
+ if (a.children.length) {
|
|
|
+ getFilingType(a.children, prefix ? prefix + '/' + a.name : a.name);
|
|
|
+ } else {
|
|
|
+ result.push({ value: a.filing_type, name: a.name, parentsName: prefix });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ getFilingType(topFiling);
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
async getFilingType(spid) {
|
|
@@ -73,7 +92,7 @@ module.exports = app => {
|
|
|
const parent = f.tree_pid !== rootId ? templateFiling.find(x => { return x.id === f.tree_pid; }) : null;
|
|
|
const newData = {
|
|
|
id: f.newId, tree_pid : parent ? parent.newId : rootId, tree_level: f.tree_level, tree_order: f.tree_order,
|
|
|
- spid, add_user_id: this.ctx.session.sessionUser.accountId, is_fixed: f.tree_level === 1,
|
|
|
+ spid, add_user_id: this.ctx.session.sessionUser.accountId, is_fixed: f.is_fixed,
|
|
|
filing_type: f.filing_type, name: f.name,
|
|
|
};
|
|
|
insertData.push(newData);
|
|
@@ -85,11 +104,27 @@ module.exports = app => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ _filterValidFiling(filing, filingType) {
|
|
|
+ const validFiling = filing.filter(x => { return filingType.indexOf(x.filing_type) > -1;});
|
|
|
+ const checkParent = function(child) {
|
|
|
+ let parent = validFiling.find(x => { return x.id === child.tree_pid; });
|
|
|
+ if (!parent) {
|
|
|
+ parent = filing.find(x => { return x.id === child.tree_pid; });
|
|
|
+ validFiling.push(parent);
|
|
|
+ }
|
|
|
+ if (parent.tree_level > 1) checkParent(parent);
|
|
|
+ };
|
|
|
+ for (const vf of validFiling) {
|
|
|
+ if (vf.tree_level > 1 && vf.is_fixed) checkParent(vf);
|
|
|
+ }
|
|
|
+ return validFiling;
|
|
|
+ }
|
|
|
+
|
|
|
async getValidFiling(spid, filingType) {
|
|
|
- const condition = { spid, is_deleted: 0 };
|
|
|
- if (filingType !== 'all') condition.filing_type = filingType;
|
|
|
if (!filingType || filingType.length === 0) return [];
|
|
|
- return await this.getAllDataByCondition({ where: condition });
|
|
|
+ const result = await this.getAllDataByCondition({ where: { spid, is_deleted: 0 } });
|
|
|
+ if (filingType === 'all') return result;
|
|
|
+ return this._filterValidFiling(result, filingType);
|
|
|
}
|
|
|
|
|
|
async getPosterityData(id){
|