Bladeren bron

成本审批,导入合同数据调整

MaiXinRong 1 dag geleden
bovenliggende
commit
3a7ca3303f

+ 4 - 0
app/controller/cost_controller.js

@@ -257,6 +257,9 @@ module.exports = app => {
                 const pa = await ctx.service.projectAccount.getDataById(ctx.session.sessionUser.accountId);
                 const pa = await ctx.service.projectAccount.getDataById(ctx.session.sessionUser.accountId);
                 const commonJson = ctx.subProject.common_json ? JSON.parse(ctx.subProject.common_json) : null;
                 const commonJson = ctx.subProject.common_json ? JSON.parse(ctx.subProject.common_json) : null;
                 const contractTypes = commonJson && commonJson.tender_contract_type ? commonJson.tender_contract_type : [];
                 const contractTypes = commonJson && commonJson.tender_contract_type ? commonJson.tender_contract_type : [];
+                const contractUsed = commonJson && commonJson.tender_contract_used ? commonJson.tender_contract_used : [];
+                contractUsed.unshift('合同');
+                contractUsed.unshift('全部');
                 let payStages = [];
                 let payStages = [];
                 if (ctx.subProject.page_show.phasePay) {
                 if (ctx.subProject.page_show.phasePay) {
                     const pstages = await this.ctx.service.phasePay.getAllDataByCondition({
                     const pstages = await this.ctx.service.phasePay.getAllDataByCondition({
@@ -284,6 +287,7 @@ module.exports = app => {
                     jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.cost[`cost_stage_${stageTypeInfo.key}`]),
                     jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.cost[`cost_stage_${stageTypeInfo.key}`]),
                     shenpi_status: ctx.tender.info.shenpi[stageTypeInfo.shenpi_status] || 1,
                     shenpi_status: ctx.tender.info.shenpi[stageTypeInfo.shenpi_status] || 1,
                     contractTypes,
                     contractTypes,
+                    contractUsed,
                 };
                 };
                 await this.layout(`cost/${stageTypeInfo.key}.ejs`, renderData, `cost/${stageTypeInfo.key}_modal.ejs`);
                 await this.layout(`cost/${stageTypeInfo.key}.ejs`, renderData, `cost/${stageTypeInfo.key}_modal.ejs`);
             } catch (err) {
             } catch (err) {

+ 12 - 3
app/public/js/cost_stage_ledger.js

@@ -513,7 +513,6 @@ $(document).ready(function() {
                     {title: '合同名称', colSpan: '1', rowSpan: '1', field: 'name', hAlign: 0, width: 160, formatter: '@', readOnly: true},
                     {title: '合同名称', colSpan: '1', rowSpan: '1', field: 'name', hAlign: 0, width: 160, formatter: '@', readOnly: true},
                     {title: '乙方', colSpan: '1', rowSpan: '1', field: 'party_b', hAlign: 0, width: 150, formatter: '@', readOnly: true},
                     {title: '乙方', colSpan: '1', rowSpan: '1', field: 'party_b', hAlign: 0, width: 150, formatter: '@', readOnly: true},
                     {title: '支付年月', colSpan: '1', rowSpan: '1', field: 'pay_date', hAlign: 1, width: 120, formatter: '@', readOnly: true},
                     {title: '支付年月', colSpan: '1', rowSpan: '1', field: 'pay_date', hAlign: 1, width: 120, formatter: '@', readOnly: true},
-                    {title: '合同金额', colSpan: '1', rowSpan: '1', field: 'deal_tp', hAlign: 2, width: 80, type: 'Number', readOnly: true},
                     {title: '税率(%)', colSpan: '1', rowSpan: '1', field: 'tax', hAlign: 2, width: 80, type: 'Number', readOnly: true},
                     {title: '税率(%)', colSpan: '1', rowSpan: '1', field: 'tax', hAlign: 2, width: 80, type: 'Number', readOnly: true},
                     {title: '付款金额', colSpan: '1', rowSpan: '1', field: 'pay_tp', hAlign: 2, width: 80, type: 'Number', readOnly: true},
                     {title: '付款金额', colSpan: '1', rowSpan: '1', field: 'pay_tp', hAlign: 2, width: 80, type: 'Number', readOnly: true},
                     {title: '扣款金额', colSpan: '1', rowSpan: '1', field: 'cut_tp', hAlign: 2, width: 80, type: 'Number', readOnly: true},
                     {title: '扣款金额', colSpan: '1', rowSpan: '1', field: 'cut_tp', hAlign: 2, width: 80, type: 'Number', readOnly: true},
@@ -967,7 +966,12 @@ $(document).ready(function() {
                 detailObj.loadDetailData(curNode);
                 detailObj.loadDetailData(curNode);
             };
             };
             $('#import-deal-type-ok').click(function() {
             $('#import-deal-type-ok').click(function() {
-                const updateData = { target: 'importContract', ledger_id: curNode.id, cost_id: curNode.cost_id, types: $('[name=contract_type]').val(), months: $('#type-pay-date').val() };
+                const updateData = {
+                    target: 'importContract', ledger_id: curNode.id, cost_id: curNode.cost_id,
+                    types: $('[name=contract_type]').val(),
+                    months: $('#type-pay-date').val(),
+                    used: $('#type-contract-used').val(),
+                };
                 if (updateData.types.length === 0) {
                 if (updateData.types.length === 0) {
                     toastr.warning('请至少选择一种类型');
                     toastr.warning('请至少选择一种类型');
                     return;
                     return;
@@ -1002,7 +1006,12 @@ $(document).ready(function() {
                 contractSelectSpread.refresh();
                 contractSelectSpread.refresh();
             });
             });
             $('#import-deal-select-ok').click(function() {
             $('#import-deal-select-ok').click(function() {
-                const updateData = { target: 'importContract', ledger_id: curNode.id, cost_id: curNode.cost_id, ids: getSelectContractId(), months: $('#select-pay-date').val() };
+                const updateData = {
+                    target: 'importContract', ledger_id: curNode.id, cost_id: curNode.cost_id,
+                    ids: getSelectContractId(),
+                    months: $('#select-pay-date').val(),
+                    used: $('#select-contract-used').val(),
+                };
                 if (updateData.ids.length === 0) {
                 if (updateData.ids.length === 0) {
                     toastr.warning('请至少选择一项合同数据');
                     toastr.warning('请至少选择一项合同数据');
                     return;
                     return;

+ 8 - 7
app/service/cost_stage_detail.js

@@ -270,7 +270,7 @@ module.exports = app => {
             }
             }
         }
         }
 
 
-        async _importContractByIds(ledgerId, costId, ids, months) {
+        async _importContractByIds(ledgerId, costId, ids, months, used) {
             if (!ledgerId || !costId) throw '导入明细数据,提交的数据错误';
             if (!ledgerId || !costId) throw '导入明细数据,提交的数据错误';
             const user_id = this.ctx.session.sessionUser.accountId;
             const user_id = this.ctx.session.sessionUser.accountId;
             const times = months.split(' ~ ');
             const times = months.split(' ~ ');
@@ -278,8 +278,9 @@ module.exports = app => {
             const beginTime = this.ctx.moment(times[0], 'YYYY-MM').startOf('month').format('YYYY-MM-DD HH:mm:ss');
             const beginTime = this.ctx.moment(times[0], 'YYYY-MM').startOf('month').format('YYYY-MM-DD HH:mm:ss');
             const endTime = this.ctx.moment(times[1] || times[0], 'YYYY-MM').endOf('month').format('YYYY-MM-DD HH:mm:ss');
             const endTime = this.ctx.moment(times[1] || times[0], 'YYYY-MM').endOf('month').format('YYYY-MM-DD HH:mm:ss');
 
 
-            const paySql = `SELECT cp.*, c.c_code, c.name, c.party_b FROM ${this.ctx.service.contractPay.tableName} cp LEFT JOIN ${this.ctx.service.contract.tableName} c ON cp.cid = c.id ` +
-                           `    WHERE cp.cid IN(${ids.map(x => { return `'${x}'`}).join(', ')}) AND cp.pay_time >= ? AND cp.pay_time <= ?`;
+            const usedFilter = !used || used === '全部' ? '' : this.db.format(` AND cp.used = ?`, [used]);
+            const paySql = `SELECT cp.*, c.c_code, c.name, c.party_b, c.tax FROM ${this.ctx.service.contractPay.tableName} cp LEFT JOIN ${this.ctx.service.contract.tableName} c ON cp.cid = c.id ` +
+                           `    WHERE cp.cid IN(${ids.map(x => { return `'${x}'`}).join(', ')}) AND cp.pay_time >= ? AND cp.pay_time <= ?` + usedFilter;
             const validPays = await this.db.query(paySql, [beginTime, endTime]);
             const validPays = await this.db.query(paySql, [beginTime, endTime]);
 
 
             const insertDetails = [];
             const insertDetails = [];
@@ -323,13 +324,13 @@ module.exports = app => {
             const ledgerData = await this.ctx.service.costStageLedger.getDataById(ledgerId);
             const ledgerData = await this.ctx.service.costStageLedger.getDataById(ledgerId);
             return { detail: { add: addData, del: detailDatas.map(x => { return x.id; }) }, ledger: ledgerData };
             return { detail: { add: addData, del: detailDatas.map(x => { return x.id; }) }, ledger: ledgerData };
         }
         }
-        async _importContractByTypes(ledgerId, costId, types, months) {
+        async _importContractByTypes(ledgerId, costId, types, months, used) {
             const contracts = await this.ctx.service.contract.getAllDataByCondition({ where: { tid: this.ctx.costStage.tid, contract_type: 1, type: types } });
             const contracts = await this.ctx.service.contract.getAllDataByCondition({ where: { tid: this.ctx.costStage.tid, contract_type: 1, type: types } });
-            return await this._importContractByIds(ledgerId, costId, contracts.map(x => { return x.id; }), months);
+            return await this._importContractByIds(ledgerId, costId, contracts.map(x => { return x.id; }), months, used);
         }
         }
         async importContract(data) {
         async importContract(data) {
-            if (data.types) return this._importContractByTypes(data.ledger_id, data.cost_id, data.types, data.months || this.ctx.costStage.stage_date);
-            if (data.ids) return this._importContractByIds(data.ledger_id, data.cost_id, data.ids, data.months || this.ctx.costStage.stage_date);
+            if (data.types) return this._importContractByTypes(data.ledger_id, data.cost_id, data.types, data.months || this.ctx.costStage.stage_date, data.used);
+            if (data.ids) return this._importContractByIds(data.ledger_id, data.cost_id, data.ids, data.months || this.ctx.costStage.stage_date, data.used);
         }
         }
 
 
         async deletePartData(transaction, tender_id, ledger_id) {
         async deletePartData(transaction, tender_id, ledger_id) {

+ 16 - 0
app/view/cost/ledger_modal.ejs

@@ -21,6 +21,14 @@
                     <label>支付年月</label>
                     <label>支付年月</label>
                     <input class="datepicker-here form-control form-control-sm" readonly autocomplete="off" id="type-pay-date" placeholder="点击选择年月" data-view="months" data-range="true"  data-multiple-dates-separator=" ~ " data-min-view="months" data-date-format="yyyy-MM" data-language="zh" type="text">
                     <input class="datepicker-here form-control form-control-sm" readonly autocomplete="off" id="type-pay-date" placeholder="点击选择年月" data-view="months" data-range="true"  data-multiple-dates-separator=" ~ " data-min-view="months" data-date-format="yyyy-MM" data-language="zh" type="text">
                 </div>
                 </div>
+                <div class="form-group form-group-sm">
+                    <label>选择用户</label>
+                    <select class="form-control form-control-sm" id="type-contract-used">
+                        <% for (const cu of contractUsed) { %>
+                        <option value="<%- cu %>"><%- cu %></option>
+                        <% } %>
+                    </select>
+                </div>
             </div>
             </div>
             <div class="modal-footer">
             <div class="modal-footer">
                 <input type="hidden" name="_csrf_j" value="<%= ctx.csrf %>" />
                 <input type="hidden" name="_csrf_j" value="<%= ctx.csrf %>" />
@@ -42,6 +50,14 @@
                     <label>支付年月</label>
                     <label>支付年月</label>
                     <input class="datepicker-here form-control form-control-sm" readonly autocomplete="off" id="select-pay-date" placeholder="点击选择年月" data-view="months" data-range="true"  data-multiple-dates-separator=" ~ " data-min-view="months" data-date-format="yyyy-MM" data-language="zh" type="text">
                     <input class="datepicker-here form-control form-control-sm" readonly autocomplete="off" id="select-pay-date" placeholder="点击选择年月" data-view="months" data-range="true"  data-multiple-dates-separator=" ~ " data-min-view="months" data-date-format="yyyy-MM" data-language="zh" type="text">
                 </div>
                 </div>
+                <div class="form-group form-group-sm">
+                    <label>选择用户</label>
+                    <select class="form-control form-control-sm" id="select-contract-used">
+                        <% for (const cu of contractUsed) { %>
+                        <option value="<%- cu %>"><%- cu %></option>
+                        <% } %>
+                    </select>
+                </div>
             </div>
             </div>
             <div class="modal-footer">
             <div class="modal-footer">
                 <button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal">取消</button>
                 <button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal">取消</button>