Browse Source

Merge branch 'dev' of http://192.168.1.41:3000/maixinrong/Calculation into dev

Tony Kang 1 năm trước cách đây
mục cha
commit
776adab1b6

+ 3 - 2
app/const/spread.js

@@ -147,8 +147,8 @@ const BaseSetCol = {
         { key: 'estimate_qty', name: '预计变更数量', fixed: ['valid', 'alias'], bills: 0, pos: 1},
         { key: 'cur_calc', name: '本期计量', fixed: ['alias'], bills: 1, pos: 1, },
         { key: 'end_calc', name: '截止本期计量', fixed: ['alias'], bills: 1, pos: 1, },
-        { key: 'deal_dgn_qty', name: '合同-项目节数量', fixed: [], bills: 1, pos: 0, },
-        { key: 'c_dgn_qty', name: '签约-项目节数量', fixed: [], bills: 1, pos: 0, },
+        { key: 'deal_dgn_qty', name: '合同-项目节数量', fixed: ['alias'], bills: 1, pos: 0, },
+        { key: 'c_dgn_qty', name: '变更-项目节数量', fixed: ['alias'], bills: 1, pos: 0, },
         { key: 'final_dgn_price', name: '经济指标', fixed: [], bills: 1, pos: 0 },
         { key: 'postil', name: '本期批注', fixed: [], bills: 1, pos: 1 },
         { key: 'drawing_code', name: '图册号', fixed: [], bills: 1, pos: 1 },
@@ -451,6 +451,7 @@ const ProjectSpreadTemplate = [
     { code: 'gl', name: '公路', template: glSpreadTemplate, isDefault: 1 },
     { code: 'sz', name: '市政', template: szSpreadTemplate },
     { code: 'fj', name: '房建', template: fjSpreadTemplate },
+    { code: 'xxby', name: '小修保养', template: glSpreadTemplate },
 ];
 const BaseSpreadColSetting = {
     Ledger: {

+ 27 - 15
app/public/js/profile_cert.js

@@ -33,13 +33,19 @@ $(document).ready(function() {
                         const val = res.$el.val();
                         const oldVal = res.$el.attr('data-old-date') || '';
                         // 日期格式判断
-                        if (val !== '' && !(isNaN(val) && !isNaN(Date.parse(val)))) {
-                            toastr.error('日期格式有误!');
-                            res.$el.val(oldVal);
-                            if (oldVal === '') {
-                                res.clear();
-                            } else {
-                                res.selectDate(new Date(oldVal));
+                        if (val !== '') {
+                            const valArr = val.split(' ~ ');
+                            for (const v of valArr) {
+                                if (!(isNaN(v) && !isNaN(Date.parse(v)))) {
+                                    toastr.error('日期格式有误!');
+                                    res.$el.val(oldVal);
+                                    if (oldVal === '') {
+                                        res.clear();
+                                    } else {
+                                        res.selectDate(new Date(oldVal));
+                                    }
+                                    return;
+                                }
                             }
                         } else if(val !== oldVal) {
                             const data = {
@@ -140,13 +146,19 @@ $(document).ready(function() {
                 const val = res.$el.val();
                 const oldVal = res.$el.attr('data-old-date') || '';
                 // 日期格式判断
-                if (val !== '' && !(isNaN(val) && !isNaN(Date.parse(val)))) {
-                    toastr.error('日期格式有误!');
-                    res.$el.val(oldVal);
-                    if (oldVal === '') {
-                        res.clear();
-                    } else {
-                        res.selectDate(new Date(oldVal));
+                if (val !== '') {
+                    const valArr = val.split(' ~ ');
+                    for (const v of valArr) {
+                        if (!(isNaN(v) && !isNaN(Date.parse(v)))) {
+                            toastr.error('日期格式有误!');
+                            res.$el.val(oldVal);
+                            if (oldVal === '') {
+                                res.clear();
+                            } else {
+                                res.selectDate(new Date(oldVal));
+                            }
+                            return;
+                        }
                     }
                 } else if(val !== oldVal) {
                     const data = {
@@ -305,7 +317,7 @@ $(document).ready(function() {
                                                                 <div class="form-group row">
                                                                     <label for="uname" class="ml-3 col-form-label">培训时间:</label>
                                                                     <div class="col-sm-10">
-                                                                        <input data-language="zh" data-old-date="${jxdata.date}" data-type="date" placeholder="请选择时间" type="text" data-date-format="yyyy-MM-dd" class="jx-date datepicker-here form-control form-control-sm" value="${jxdata.date ? jxdata.date : ''}">
+                                                                        <input data-language="zh" data-old-date="${jxdata.date}" data-type="date" placeholder="请选择时间" type="text" data-range="true" data-multiple-dates-separator=" ~ " class="jx-date datepicker-here form-control form-control-sm" value="${jxdata.date ? jxdata.date : ''}">
                                                                     </div>
                                                                 </div>
                                                                 <div class="form-group row">

+ 4 - 3
app/public/js/setting.js

@@ -448,9 +448,10 @@ $(document).ready(() => {
                         if (!reg.test(j.password)) {
                             continue;
                         }
-                        if (_.findIndex(tree, function (o) { return o.account === j.account; }) === -1) {
-                            tree.push(j);
-                        }
+                        tree.push(j);
+                        // if (_.findIndex(tree, function (o) { return o.account === j.account; }) === -1) {
+                        //     tree.push(j);
+                        // }
                     }
                 }
                 console.log(tree);

+ 16 - 0
app/public/js/tender_cert.js

@@ -134,6 +134,22 @@ $(function () {
     });
 
     $('#add_cert_btn').click(function () {
+        // 判断是否有重复项cert_id的,否则不允许提交
+        const certIdList = [];
+        let isRepeat = false;
+        $('#select-certs-table tr[data-remove="0"]').each(function () {
+            const certId = parseInt($(this).attr('data-certid'));
+            if (certIdList.indexOf(certId) === -1) {
+                certIdList.push(certId);
+            } else {
+                isRepeat = true;
+                return;
+            }
+        });
+        if (isRepeat) {
+            toastr.error('用户不能添加重复的证书');
+            return;
+        }
         // 判断增删改
         const insertList = [];
         if ($('#select-certs-table tr[data-insert="1"][data-remove="0"]').length > 0) {

+ 11 - 1
app/service/change_apply_audit.js

@@ -323,7 +323,17 @@ module.exports = app => {
                 '  WHERE ((ma.`aid` = ? and ma.`status` = ?) OR (m.`uid` = ? and ma.`status` = ? and m.`status` = ? and ma.`times` = (m.`times`-1)))' +
                 '    and ma.`caid` = m.`id` and ma.`tid` = t.`id` ORDER BY ma.`begin_time` DESC';
             const sqlParam = [this.tableName, this.ctx.service.changeApply.tableName, this.ctx.service.tender.tableName, auditorId, auditConst.status.checking, auditorId, auditConst.status.checkNo, auditConst.status.checkNo];
-            return await this.db.query(sql, sqlParam);
+            const result = await this.db.query(sql, sqlParam);
+            // 过滤result中存在重复sid的值, 保留最新的一条
+            const filterResult = [];
+            const caidArr = [];
+            for (const r of result) {
+                if (caidArr.indexOf(r.caid) === -1) {
+                    filterResult.push(r);
+                    caidArr.push(r.caid);
+                }
+            }
+            return filterResult;
         }
 
         /**

+ 11 - 1
app/service/change_plan_audit.js

@@ -327,7 +327,17 @@ module.exports = app => {
                 '  WHERE ((ma.`aid` = ? and ma.`status` = ?) OR (m.`uid` = ? and ma.`status` = ? and m.`status` = ? and ma.`times` = (m.`times`-1)))' +
                 '    and ma.`cpid` = m.`id` and ma.`tid` = t.`id` ORDER BY ma.`begin_time` DESC';
             const sqlParam = [this.tableName, this.ctx.service.changePlan.tableName, this.ctx.service.tender.tableName, auditorId, auditConst.status.checking, auditorId, auditConst.status.checkNo, auditConst.status.checkNo];
-            return await this.db.query(sql, sqlParam);
+            const result = await this.db.query(sql, sqlParam);
+            // 过滤result中存在重复sid的值, 保留最新的一条
+            const filterResult = [];
+            const cpidArr = [];
+            for (const r of result) {
+                if (cpidArr.indexOf(r.cpid) === -1) {
+                    filterResult.push(r);
+                    cpidArr.push(r.cpid);
+                }
+            }
+            return filterResult;
         }
 
         /**

+ 11 - 1
app/service/change_project_audit.js

@@ -325,7 +325,17 @@ module.exports = app => {
                 '  WHERE ((ma.`aid` = ? and ma.`status` = ?) OR (m.`uid` = ? and ma.`status` = ? and m.`status` = ? and ma.`times` = (m.`times`-1)))' +
                 '    and ma.`cpid` = m.`id` and ma.`tid` = t.`id` ORDER BY ma.`begin_time` DESC';
             const sqlParam = [this.tableName, this.ctx.service.changeProject.tableName, this.ctx.service.tender.tableName, auditorId, auditConst.status.checking, auditorId, auditConst.status.back, auditConst.status.back];
-            return await this.db.query(sql, sqlParam);
+            const result = await this.db.query(sql, sqlParam);
+            // 过滤result中存在重复cpid的值, 保留最新的一条
+            const filterResult = [];
+            const cpidArr = [];
+            for (const r of result) {
+                if (cpidArr.indexOf(r.cpid) === -1) {
+                    filterResult.push(r);
+                    cpidArr.push(r.cpid);
+                }
+            }
+            return filterResult;
         }
 
         /**

+ 23 - 12
app/service/project_spread.js

@@ -98,16 +98,20 @@ module.exports = app => {
             return [billsSpread, posSpread];
         }
 
+        async initProjectSpreadByTemplate(id, spreadTemplate) {
+            const data = JSON.parse(JSON.stringify(spreadTemplate.template));
+            [data.tz_ledger_bills_spread, data.tz_ledger_pos_spread] = this.generateRelaSpread('tz_ledger_set', data.tz_ledger_set);
+            [data.tz_stage_bills_spread, data.tz_stage_pos_spread] = this.generateRelaSpread('tz_stage_set', data.tz_stage_set);
+            [data.gcl_ledger_bills_spread, data.gcl_ledger_pos_spread] = this.generateRelaSpread('gcl_ledger_set', data.gcl_ledger_set);
+            [data.gcl_stage_bills_spread, data.gcl_stage_pos_spread] = this.generateRelaSpread('gcl_stage_set', data.gcl_stage_set);
+            const updateData = { pid: id, code: spreadTemplate.code, name: spreadTemplate.name, is_default: spreadTemplate.isDefault ? 1 : 0 };
+            JsonFields.forEach(jf => { if (data[jf]) updateData[jf] = JSON.stringify(data[jf]) });
+            await this.db.insert(this.tableName, updateData);
+        }
+
         async initProjectSpread(id) {
-            for (const SpreadTemplate of SpreadConst.ProjectSpreadTemplate) {
-                const data = JSON.parse(JSON.stringify(SpreadTemplate.template));
-                [data.tz_ledger_bills_spread, data.tz_ledger_pos_spread] = this.generateRelaSpread('tz_ledger_set', data.tz_ledger_set);
-                [data.tz_stage_bills_spread, data.tz_stage_pos_spread] = this.generateRelaSpread('tz_stage_set', data.tz_stage_set);
-                [data.gcl_ledger_bills_spread, data.gcl_ledger_pos_spread] = this.generateRelaSpread('gcl_ledger_set', data.gcl_ledger_set);
-                [data.gcl_stage_bills_spread, data.gcl_stage_pos_spread] = this.generateRelaSpread('gcl_stage_set', data.gcl_stage_set);
-                const updateData = { pid: id, code: SpreadTemplate.code, name: SpreadTemplate.name, is_default: SpreadTemplate.isDefault };
-                JsonFields.forEach(jf => { if (data[jf]) updateData[jf] = JSON.stringify(data[jf]) });
-                await this.db.insert(this.tableName, updateData);
+            for (const template of SpreadConst.ProjectSpreadTemplate) {
+                await this.initProjectSpreadByTemplate(id, template);
             }
         }
 
@@ -123,9 +127,16 @@ module.exports = app => {
                 columns: ['code', 'name', 'is_default'],
                 where: { pid: id },
             });
-            if (result.length > 0) return result;
-
-            await this.initProjectSpread(id);
+            if (result.length === SpreadConst.ProjectSpreadTemplate.length) return result;
+
+            if (result.length === 0) {
+                await this.initProjectSpread(id);
+            } else {
+                for (const spreadTemplate of SpreadConst.ProjectSpreadTemplate) {
+                    const SpreadType = result.find(x => { return x.code === spreadTemplate.code; });
+                    if (!SpreadType) await this.initProjectSpreadByTemplate(id, spreadTemplate);
+                }
+            }
             return await this.getAllDataByCondition({
                 columns: ['code', 'name', 'is_default'],
                 where: { pid: id },

+ 1 - 1
app/service/stage.js

@@ -543,7 +543,7 @@ module.exports = app => {
                     const priceCalc = new RevisePrice(this.ctx);
                     pcTp = await priceCalc.newStagePriceChange(newStage, preStage, transaction);
                 }
-                if (order === 0 || (preStage && preCheckedStage && preStage.order === preCheckedStage.order)) {
+                if (order === 1 || (preStage && preCheckedStage && preStage.order === preCheckedStage.order)) {
                     await this.ctx.service.tenderCache.updateStageCache4Add(transaction, newStage, pcTp);
                 }
                 // 新增期拷贝报表相关配置/签名角色 等

+ 11 - 1
app/service/stage_audit.js

@@ -1562,7 +1562,17 @@ module.exports = app => {
                 auditConst.status.checkNo,
                 auditConst.status.checkNo,
             ];
-            return await this.db.query(sql, sqlParam);
+            const result = await this.db.query(sql, sqlParam);
+            // 过滤result中存在重复sid的值, 保留最新的一条
+            const filterResult = [];
+            const sidArr = [];
+            for (const r of result) {
+                if (sidArr.indexOf(r.sid) === -1) {
+                    filterResult.push(r);
+                    sidArr.push(r.sid);
+                }
+            }
+            return filterResult;
         }
 
         /**

+ 1 - 1
app/view/profile/cert.ejs

@@ -109,7 +109,7 @@
                                                                             <div class="form-group row">
                                                                                 <label for="uname" class="ml-3 col-form-label">培训时间:</label>
                                                                                 <div class="col-sm-10">
-                                                                                    <input data-language="zh" data-old-date="<%- e.date %>" data-type="date" placeholder="请选择时间" type="text" data-date-format="yyyy-mm-dd" class="jx-date datepicker-here form-control form-control-sm" value="<%- e.date %>">
+                                                                                    <input data-language="zh" data-old-date="<%- e.date %>" data-type="date" placeholder="请选择时间" type="text" data-range="true" data-multiple-dates-separator=" ~ " class="jx-date datepicker-here form-control form-control-sm" value="<%- e.date %>">
                                                                                 </div>
                                                                             </div>
                                                                             <div class="form-group row">