Browse Source

1. 报表,甲供材料、奖罚金、其他,提供数据
2. 甲供材料、奖罚金、其他,期审批流程中,各参与人显示数据调整
3. 页面部分判断调整

MaiXinRong 5 years ago
parent
commit
3d4dd263f6

+ 7 - 2
app/controller/stage_extra_controller.js

@@ -7,6 +7,8 @@
  * @date 2020/2/24
  * @date 2020/2/24
  * @version
  * @version
  */
  */
+const auditConst = require('../const/audit').stage;
+
 module.exports = app => {
 module.exports = app => {
 
 
     class StageExtraController extends app.BaseController {
     class StageExtraController extends app.BaseController {
@@ -100,8 +102,11 @@ module.exports = app => {
          */
          */
         async loadBonus (ctx) {
         async loadBonus (ctx) {
             try {
             try {
-                const data = await ctx.service.stageBonus.getEndStageData(ctx.stage.order);
-                ctx.body = {err: 0, msg: '', data: data};
+                const data = await ctx.service.stageBonus.getStageData(ctx.stage.id);
+                console.log(data);
+                const preData = await ctx.service.stageBonus.getPreStageData(ctx.stage.order);
+                console.log(preData);
+                ctx.body = {err: 0, msg: '', data: data.concat(preData)};
             } catch (error) {
             } catch (error) {
                 ctx.helper.log(error);
                 ctx.helper.log(error);
                 ctx.body = this.ajaxErrorBody(error, '获取甲供材料数据失败,请刷新');
                 ctx.body = this.ajaxErrorBody(error, '获取甲供材料数据失败,请刷新');

+ 2 - 0
app/public/js/path_tree.js

@@ -3,6 +3,8 @@
  *
  *
  * 构建pathTree
  * 构建pathTree
  * 可动态加载子节点,要求子节点获取接口按/xxx/get-children定义
  * 可动态加载子节点,要求子节点获取接口按/xxx/get-children定义
+ *
+ * 所台账结构数据均用到该文件,请勿随意修改。
  * @param {Object} setting - 设置
  * @param {Object} setting - 设置
  * @returns {PathTree}
  * @returns {PathTree}
  */
  */

+ 2 - 2
app/public/js/se_bonus.js

@@ -231,11 +231,11 @@ $(document).ready(() => {
 
 
                 for (let iRow = sels[0].row, iLen = sels[0].row + sels[0].rowCount; iRow < iLen; iRow++) {
                 for (let iRow = sels[0].row, iLen = sels[0].row + sels[0].rowCount; iRow < iLen; iRow++) {
                     const node = sortData[iRow];
                     const node = sortData[iRow];
-                    if (node.sid !== stageID) {
+                    if (node.sid !== stageId) {
                         toastMessageUniq(hint.isOld);
                         toastMessageUniq(hint.isOld);
                         continue;
                         continue;
                     } else {
                     } else {
-                        if (node.uid !== userID || stageUserId !== userID) {
+                        if (node.uid !== userID && stageUserId !== userID) {
                             toastMessageUniq(hint.invalidDel);
                             toastMessageUniq(hint.invalidDel);
                             continue;
                             continue;
                         }
                         }

+ 1 - 1
app/public/js/se_jgcl.js

@@ -176,7 +176,7 @@ $(document).ready(() => {
                         toastMessageUniq(hint.isOld);
                         toastMessageUniq(hint.isOld);
                         continue;
                         continue;
                     } else {
                     } else {
-                        if (node.add_uid !== userID || stageUserId !== userID) {
+                        if (node.add_uid !== userID && stageUserId !== userID) {
                             toastMessageUniq(hint.invalidDel);
                             toastMessageUniq(hint.invalidDel);
                             continue;
                             continue;
                         }
                         }

+ 1 - 1
app/public/js/se_other.js

@@ -224,7 +224,7 @@ $(document).ready(() => {
                         toastMessageUniq(hint.isOld);
                         toastMessageUniq(hint.isOld);
                         continue;
                         continue;
                     } else {
                     } else {
-                        if (node.add_uid !== userID || stageUserId !== userID) {
+                        if (node.add_uid !== userID && stageUserId !== userID) {
                             toastMessageUniq(hint.invalidDel);
                             toastMessageUniq(hint.invalidDel);
                             continue;
                             continue;
                         }
                         }

+ 12 - 0
app/service/report.js

@@ -107,6 +107,18 @@ module.exports = app => {
                             runnableRst.push(service.changeAuditList.getChangeAuditBills(params.tender_id)); // 获取所有审核通过的变更清单
                             runnableRst.push(service.changeAuditList.getChangeAuditBills(params.tender_id)); // 获取所有审核通过的变更清单
                             runnableKey.push(filter);
                             runnableKey.push(filter);
                             break;
                             break;
+                        case 'stage_jgcl':
+                            runnableRst.push(service.reportMemory.getStageJgcl(params.tender_id, param.stage_id, memFieldKeys[filter]));
+                            runnableKey.push(filter);
+                            break;
+                        case 'stage_bonus':
+                            runnableRst.push(service.reportMemory.getStageBonus(params.tender_id, param.stage_id, memFieldKeys[filter]));
+                            runnableKey.push(filter);
+                            break;
+                        case 'stage_other':
+                            runnableRst.push(service.reportMemory.getStageOther(params.tender_id, param.stage_id, memFieldKeys[filter]));
+                            runnableKey.push(filter);
+                            break;
                         default:
                         default:
                             break;
                             break;
                     }
                     }

+ 42 - 0
app/service/report_memory.js

@@ -578,6 +578,48 @@ module.exports = app => {
             }
             }
             return data;
             return data;
         }
         }
+
+        async getStageJgcl(tid, sid, fields) {
+            await this.ctx.service.tender.checkTender(tid);
+            await this.ctx.service.stage.checkStage(sid);
+
+            const data = await this.ctx.service.stageJgcl.getStageData(this.ctx.stage.id);
+            const preData = await this.ctx.service.stageJgcl.getPreStageData(this.ctx.stage.order);
+            for (const d of data) {
+                const pd = this.ctx.helper._.find(preData, {uuid: d.uuid});
+                if (pd) {
+                    d.pre_arrive_qty = pd.arrive_qty;
+                    d.pre_arrive_tp = pd.arrive_tp;
+                    d.pre_deduct_qty = pd.deduct_qty;
+                    d.pre_deduct_tp = pd.deduct_tp;
+                }
+            }
+            return data;
+        }
+
+        async getStageBonus(tid, sid, fields) {
+            await this.ctx.service.tender.checkTender(tid);
+            await this.ctx.service.stage.checkStage(sid);
+
+            const data = await ctx.service.stageBonus.getEndStageData(this.ctx.stage.order);
+            return data;
+        }
+
+        async getStageOther(tid, sid, fields) {
+            await this.ctx.service.tender.checkTender(tid);
+            await this.ctx.service.stage.checkStage(sid);
+
+
+            const data = await this.ctx.service.stageOther.getStageData(this.ctx.stage.id);
+            const preData = await this.ctx.service.stageOther.getPreStageData(this.ctx.stage.order);
+            for (const d of data) {
+                const pd = this.ctx.helper._.find(preData, {uuid: d.uuid});
+                if (pd) {
+                    d.pre_tp = pd.tp;
+                }
+            }
+            return data;
+        }
     }
     }
 
 
     return ReportMemory;
     return ReportMemory;

+ 13 - 1
app/service/stage_bonus.js

@@ -8,6 +8,7 @@
  * @version
  * @version
  */
  */
 
 
+const auditConst = require('../const/audit').stage;
 module.exports = app => {
 module.exports = app => {
     class StageBonus extends app.BaseService {
     class StageBonus extends app.BaseService {
         /**
         /**
@@ -23,6 +24,15 @@ module.exports = app => {
 
 
         async getStageData(sid) {
         async getStageData(sid) {
             const data = await this.getAllDataByCondition({where: { sid: sid }});
             const data = await this.getAllDataByCondition({where: { sid: sid }});
+            if (this.ctx.stage.readOnly && this.ctx.stage.status !== auditConst.status.checked) {
+                for (const d of data) {
+                    const his = d.shistory ? JSON.parse(d.shistory) : [];
+                    const h = this.ctx.helper._.find(his, {
+                        stimes: this.ctx.stage.curTimes, sorder: this.ctx.stage.curOrder
+                    });
+                    d.tp = h ? h.tp : null;
+                }
+            }
             return data;
             return data;
         }
         }
 
 
@@ -68,8 +78,10 @@ module.exports = app => {
 
 
         async _delDatas (data) {
         async _delDatas (data) {
             const datas = data instanceof Array ? data : [data];
             const datas = data instanceof Array ? data : [data];
-            const orgDatas = await this.getAllDataByCondition({sid: this.ctx.stage.id, id: this.ctx.helper._.map(datas, 'id')});
+            const orgDatas = await this.getAllDataByCondition({where: {sid: this.ctx.stage.id, id: this.ctx.helper._.map(datas, 'id')}});
             for (const od of orgDatas) {
             for (const od of orgDatas) {
+                console.log(od);
+                console.log(this.ctx.stage.id);
                 if (od.sid !== this.ctx.stage.id) throw '非本期新增数据,不可删除';
                 if (od.sid !== this.ctx.stage.id) throw '非本期新增数据,不可删除';
             }
             }
             await this.db.delete(this.tableName, {id: datas});
             await this.db.delete(this.tableName, {id: datas});

+ 21 - 1
app/service/stage_jgcl.js

@@ -8,6 +8,7 @@
  * @version
  * @version
  */
  */
 
 
+const auditConst = require('../const/audit').stage;
 module.exports = app => {
 module.exports = app => {
     class StageJgcl extends app.BaseService {
     class StageJgcl extends app.BaseService {
         /**
         /**
@@ -23,6 +24,25 @@ module.exports = app => {
 
 
         async getStageData(sid) {
         async getStageData(sid) {
             const data = await this.getAllDataByCondition({where: { sid: sid }});
             const data = await this.getAllDataByCondition({where: { sid: sid }});
+            if (this.ctx.stage.readOnly && this.ctx.stage.status !== auditConst.status.checked) {
+                for (const d of data) {
+                    const his = d.shistory ? JSON.parse(d.shistory) : [];
+                    const h = this.ctx.helper._.find(his, {
+                        stimes: this.ctx.stage.curTimes, sorder: this.ctx.stage.curOrder
+                    });
+                    if (h) {
+                        d.arrive_qty = h.arrive_qty;
+                        d.arrive_tp = h.arrive_tp;
+                        d.deduct_qty = h.deduct_qty;
+                        d.deduct_tp = h.deduct_tp;
+                    } else {
+                        d.arrive_qty = null;
+                        d.arrive_tp = null;
+                        d.deduct_qty = null;
+                        d.deduct_tp = null;
+                    }
+                }
+            }
             return data;
             return data;
         }
         }
 
 
@@ -84,7 +104,7 @@ module.exports = app => {
 
 
         async _delDatas (data) {
         async _delDatas (data) {
             const datas = data instanceof Array ? data : [data];
             const datas = data instanceof Array ? data : [data];
-            const orgDatas = await this.getAllDataByCondition({sid: this.ctx.stage.id, id: this.ctx.helper._.map(datas, 'id')});
+            const orgDatas = await this.getAllDataByCondition({where: {sid: this.ctx.stage.id, id: this.ctx.helper._.map(datas, 'id')} });
             for (const od of orgDatas) {
             for (const od of orgDatas) {
                 if (od.pre_used) throw '甲供材料往期已经计量,不可删除';
                 if (od.pre_used) throw '甲供材料往期已经计量,不可删除';
             }
             }

+ 11 - 1
app/service/stage_other.js

@@ -8,6 +8,7 @@
  * @version
  * @version
  */
  */
 
 
+const auditConst = require('../const/audit').stage;
 module.exports = app => {
 module.exports = app => {
     class StageOther extends app.BaseService {
     class StageOther extends app.BaseService {
         /**
         /**
@@ -23,6 +24,15 @@ module.exports = app => {
 
 
         async getStageData(sid) {
         async getStageData(sid) {
             const data = await this.getAllDataByCondition({where: { sid: sid }});
             const data = await this.getAllDataByCondition({where: { sid: sid }});
+            if (this.ctx.stage.readOnly && this.ctx.stage.status !== auditConst.status.checked) {
+                for (const d of data) {
+                    const his = d.shistory ? JSON.parse(d.shistory) : [];
+                    const h = this.ctx.helper._.find(his, {
+                        stimes: this.ctx.stage.curTimes, sorder: this.ctx.stage.curOrder
+                    });
+                    d.tp = h ? h.tp : null;
+                }
+            }
             return data;
             return data;
         }
         }
 
 
@@ -71,7 +81,7 @@ module.exports = app => {
 
 
         async _delDatas (data) {
         async _delDatas (data) {
             const datas = data instanceof Array ? data : [data];
             const datas = data instanceof Array ? data : [data];
-            const orgDatas = await this.getAllDataByCondition({sid: this.ctx.stage.id, id: this.ctx.helper._.map(datas, 'id')});
+            const orgDatas = await this.getAllDataByCondition({where: {sid: this.ctx.stage.id, id: this.ctx.helper._.map(datas, 'id')} });
             for (const od of orgDatas) {
             for (const od of orgDatas) {
                 if (od.pre_used) throw '往期已经计量,不可删除';
                 if (od.pre_used) throw '往期已经计量,不可删除';
             }
             }

+ 194 - 0
builder_report_index_define.js

@@ -0,0 +1,194 @@
+'use strict';
+
+/**
+ *
+ *
+ * @author Mai
+ * @date
+ * @version
+ */
+
+const fs = require('fs');
+const path = require('path');
+const savePath = path.join(__dirname, 'report_temp');
+const dataType = {
+    int: 'int',
+    str: 'string',
+    double: 'double',
+    currency: 'currency',
+    time: 'string',
+};
+const tag = {
+    tp: {type: 'tp'},
+    up: {type: 'up'},
+};
+const stage_jgcl = {
+    name: '期-甲供材料(mem_stage_jgcl)',
+    remark: '',
+    id: 30,
+    key: 'stage_jgcl',
+    prefix: '期-甲供材料',
+    cols: [
+        {name: 'id', field: 'id', type: dataType.int},
+        {name: 'uuid', field: 'uuid', type: dataType.str},
+        {name: '名称', field: 'name', type: dataType.str},
+        {name: '单位', field: 'unit', type: dataType.str},
+        {name: '单价', field: 'unit_price', type: dataType.currency, tag: {type: 'up'}},
+        {name: '本期到场-数量', field: 'arrive_qty', type: dataType.currency, tag: {type: 'qty', unitKey: 5}},
+        {name: '本期到场-金额', field: 'arrive_tp', type: dataType.currency, tag: {type: 'tp'}},
+        {name: '本期扣回-数量', field: 'deduct_qty', type: dataType.currency, tag: {type: 'qty', unitKey: 5}},
+        {name: '本期扣回-金额', field: 'deduct_tp', type: dataType.currency, tag: {type: 'tp'}},
+        {name: '材料来源', field: 'source', type: dataType.str},
+        {name: '单据号', field: 'bills_code', type: dataType.str},
+        {name: '检验单编号', field: 'check_code', type: dataType.str},
+        {name: '新增人id', field: 'add_uid', type: dataType.int},
+        {name: '新增期id', field: 'add_sid', type: dataType.int},
+        {name: '所属期id', field: 'sid', type: dataType.int},
+        {name: '期历史记录', field: 'shistory', type: dataType.str},
+        {name: '排序', field: 'order', type: dataType.int},
+        {name: '往期是否已用', field: 'pre_used', type: dataType.int},
+        {name: '截止上期到场-数量', field: 'arrive_qty', type: dataType.currency, tag: {type: 'qty', unitKey: 5}},
+        {name: '截止上期到场-金额', field: 'arrive_tp', type: dataType.currency, tag: {type: 'tp'}},
+        {name: '截止上期扣回-数量', field: 'deduct_qty', type: dataType.currency, tag: {type: 'qty', unitKey: 5}},
+        {name: '截止上期扣回-金额', field: 'deduct_tp', type: dataType.currency, tag: {type: 'tp'}},
+    ]
+};
+const stage_bonus = {
+    name: '期-奖罚金(mem_stage_bonus)',
+    remark: '',
+    id: 31,
+    key: 'stage_bonus',
+    prefix: '期-奖罚金',
+    cols: [
+        {name: 'id', field: 'id', type: dataType.str},
+        {name: '所属标段id', field: 'tid', type: dataType.int},
+        {name: '所属期id', field: 'sid', type: dataType.int},
+        {name: '所属第几期', field: 'sorder', type: dataType.int},
+        {name: '新增人id', field: 'uid', type: dataType.int},
+        {name: '名称', field: 'name', type: dataType.str},
+        {name: '金额', field: 'tp', type: dataType.currency, tag: {type: 'tp'}},
+        {name: '证明材料', field: 'proof', type: dataType.str},
+        {name: '创建时间', field: 'create_time', type: dataType.time},
+        {name: '时间', field: 'real_time', type: dataType.time},
+        {name: '备注', field: 'memo', type: dataType.str},
+        {name: '期历史记录', field: 'shistory', type: dataType.str},
+        {name: '排序', field: 'order', type: dataType.int},
+    ]
+};
+const stage_other = {
+    name: '期-其他(mem_stage_other)',
+    remark: '',
+    id: 32,
+    key: 'stage_other',
+    prefix: '期-其他',
+    cols: [
+        {name: 'id', field: 'id', type: dataType.int},
+        {name: 'uuid', field: 'uuid', type: dataType.str},
+        {name: '所属标段id', field: 'tid', type: dataType.int},
+        {name: '所属期id', field: 'sid', type: dataType.int},
+        {name: '所属第几期', field: 'sorder', type: dataType.int},
+        {name: '新增人id', field: 'add_uid', type: dataType.int},
+        {name: '新增期id', field: 'add_sid', type: dataType.int},
+        {name: '创建时间', field: 'add_time', type: dataType.time},
+        {name: '名称', field: 'name', type: dataType.str},
+        {name: '金额', field: 'total_price', type: dataType.currency, tag: {type: 'tp'}},
+        {name: '本期金额', field: 'tp', type: dataType.currency, tag: {type: 'tp'}},
+        {name: '时间', field: 'real_time', type: dataType.time},
+        {name: '备注', field: 'memo', type: dataType.str},
+        {name: '期历史记录', field: 'shistory', type: dataType.str},
+        {name: '排序', field: 'order', type: dataType.int},
+        {name: '往期是否已用', field: 'pre_used', type: dataType.int},
+        {name: '截止上期-金额', field: 'pre_tp', type: dataType.currency, tag: {type: 'tp'}},
+    ]
+};
+
+const recursiveMkdirSync = async function (pathName) {
+    if (!fs.existsSync(pathName)) {
+        const upperPath = path.dirname(pathName);
+        if (!fs.existsSync(upperPath)) {
+            await this.recursiveMkdirSync(upperPath);
+        }
+        await fs.mkdirSync(pathName);
+    }
+};
+const saveBufferFile = async function (buffer, fileName) {
+    // 检查文件夹是否存在,不存在则直接创建文件夹
+    const pathName = path.dirname(fileName);
+    if (!fs.existsSync(pathName)) {
+        await recursiveMkdirSync(pathName);
+    }
+    await fs.writeFileSync(fileName, buffer);
+};
+const addFields = function(table, name, field, type, tag) {
+    const data = {};
+    data.ID = table.ID * 100 + table.items.length + 1;
+    data.Name = name + '(' + field + ')';
+    if (table.prefix && table.prefix !== '') data.Name = table.prefix + '-' + data.Name;
+    data.DataType = type;
+    data.TableName = table.key;
+    data.descr = '';
+    data.mapExpression = "$PROJECT.REPORT.getProperty('" + table.key + "', '" + field + "')";
+    if (tag) {
+        switch (tag.type) {
+            case 'up':
+                data.Precision = { type: "fixed", fixedMapExpression: "$PROJECT.REPORT.getProperty('tender_info', 'decimal.up')" };
+                break;
+            case 'tp':
+                if (tag.subType) {
+                    data.Precision = { type: "fixed", fixedMapExpression: "$PROJECT.REPORT.getProperty('tender_info', 'decimal." + "_" + tag.subType + "_tp')" };
+                } else {
+                    data.Precision = { type: "fixed", fixedMapExpression: "$PROJECT.REPORT.getProperty('tender_info', 'decimal.tp')" };
+                }
+                break;
+            case 'qty':
+                data.Precision = { type: "flexible", flexibleRefFieldID: table.ID * 100 + tag.unitKey, flexibleMapExpression: "$PROJECT.REPORT.getProperty('tender_info', 'precision')" };
+                break;
+        }
+    }
+    table.items.push(data);
+};
+const saveTableDefine = async function (tableDefine, file) {
+    delete tableDefine.ID;
+    delete tableDefine.key;
+    delete tableDefine.prefix;
+    let defineStr = JSON.stringify(tableDefine, "", "\t");
+    const replaceStr = [
+        {match: '"Name":', str: 'Name:'},
+        {match: '"remark":', str: 'remark:'},
+        {match: '"items":', str: 'items:'},
+        {match: '"ID":', str: 'ID:'},
+        {match: '"DataType":', str: 'DataType:'},
+        {match: '"TableName":', str: 'TableName:'},
+        {match: '"descr":', str: 'descr:'},
+        {match: '"mapExpression":', str: 'mapExpression:'},
+        {match: '"Precision":', str: 'Precision:'},
+        {match: '"type":', str: 'type:'},
+        {match: '"flexibleRefFieldID":', str: 'flexibleRefFieldID:'},
+        {match: '"fixedMapExpression":', str: 'fixedMapExpression:'},
+        {match: '"flexibleMapExpression":', str: 'flexibleMapExpression:'},
+    ];
+    for (const rs of replaceStr) {
+        const reg = new RegExp(rs.match, 'gm');
+        defineStr = defineStr.replace(reg, rs.str);
+    }
+    await saveBufferFile(defineStr, file);
+};
+
+const exportTableDefine = async function (define) {
+    const tableDefine = {};
+    tableDefine.Name = define.name;// '期-清单-全参与人数据表(mem_stage_bills_compare)';
+    tableDefine.remark = define.remark;
+    tableDefine.ID = define.id;
+    tableDefine.key = define.key;
+    tableDefine.items = [];
+    tableDefine.prefix = define.prefix;
+    for (const col of define.cols) {
+        addFields(tableDefine, col.name, col.field, col.type, col.tag);
+    }
+    await saveTableDefine(tableDefine, path.join(savePath, define.key + '.json'));
+};
+
+const defines = [stage_bonus, stage_jgcl, stage_other];
+for (const d of defines) {
+    exportTableDefine(d);
+}