Przeglądaj źródła

1.新建复制立项的数据到申请中,2.修复立项编号重复问题

laiguoran 3 lat temu
rodzic
commit
1619dfa79d

+ 8 - 1
app/controller/change_controller.js

@@ -2418,7 +2418,6 @@ module.exports = app => {
             for (const c of changes) {
                 c.curAuditor = await ctx.service.changeApplyAudit.getAuditorByStatus(c.id, c.status, c.times);
             }
-
             const tender_userInfo = await ctx.service.projectAccount.getDataById(ctx.tender.data.user_id);
             // 分页相关
             const pageInfo = {
@@ -2466,6 +2465,13 @@ module.exports = app => {
                 }
             }
             const changeProjectList = await ctx.service.changeProject.getAllDataByCondition({ where: { tid: tender.id, status: audit.changeProject.status.checked } });
+            const allProjectCodes = await ctx.service.changeApply.getAllDataByCondition({
+                columns: ['project_code'],
+                where: {
+                    tid: tender.id,
+                },
+            });
+            const pcLists = allProjectCodes.length > 0 ? ctx.app._.uniq(ctx.app._.map(allProjectCodes, 'project_code')) : [];
             const renderData = {
                 uid: ctx.session.sessionUser.accountId,
                 tender,
@@ -2484,6 +2490,7 @@ module.exports = app => {
                 ruleConst: codeRuleConst.measure,
                 changeConst,
                 changeProjectList,
+                pcLists,
                 tenderMenu: this.menu.tenderMenu,
                 preUrl: '/tender/' + tender.id,
                 jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.change.apply),

+ 16 - 1
app/service/change_apply.js

@@ -37,7 +37,7 @@ module.exports = app => {
             const codeCount = await this.db.queryOne(sql, sqlParam);
             const count = codeCount.count;
             if (count > 0) {
-                throw '立项书编号重复';
+                throw '变更申请书编号重复';
             }
 
             // 初始化事务
@@ -55,6 +55,21 @@ module.exports = app => {
                     name,
                     quality: changeConst.quality.common.name,
                 };
+                if (project_code) {
+                    const projectInfo = await this.ctx.service.changeProject.getDataByCondition({ code: project_code });
+                    if (projectInfo) {
+                        change.org_name = projectInfo.org_name;
+                        change.peg = projectInfo.peg;
+                        change.new_code = projectInfo.new_code;
+                        change.class = projectInfo.class;
+                        change.quality = projectInfo.quality;
+                        change.reason = projectInfo.reason;
+                        change.content = projectInfo.content;
+                        change.org_price = projectInfo.org_price;
+                        change.change_price = projectInfo.change_price;
+                        change.crease_price = projectInfo.crease_price;
+                    }
+                }
                 const operate = await this.transaction.insert(this.tableName, change);
 
                 if (operate.affectedRows <= 0) {

+ 1 - 1
app/view/change/apply_modal.ejs

@@ -43,7 +43,7 @@
                     <select class="form-control form-control-sm" id="project-code">
                         <option></option>
                         <% for (const cp of changeProjectList) { %>
-                        <% if (ctx.helper._.findIndex(changes, { project_code: cp.code }) === -1) { %>
+                        <% if (ctx.helper._.indexOf(pcLists, cp.code) === -1) { %>
                         <option><%- cp.code %></option>
                         <% } %>
                         <% } %>

+ 1 - 1
app/view/change/project_information.ejs

@@ -84,7 +84,7 @@
                             <td><input class="form-control form-control-sm" type="text" value="<%- change.org_price %>" data-name="org_price" <% if (change.readOnly) { %>readonly<% } %> placeholder=""></td>
                         </tr>
                         <tr>
-                            <th width="120" class="text-center" style="vertical-align: middle">预计变更造价(元)</th>
+                            <th width="120" class="text-center" style="vertical-align: middle">预计变更造价(元)</th>
                             <td><input class="form-control form-control-sm" type="text" value="<%- change.change_price %>" data-name="change_price" <% if (change.readOnly) { %>readonly<% } %> placeholder=""></td>
                             <th width="120" class="text-center" style="vertical-align: middle">预计造价增减(元)</th>
                             <td><input class="form-control form-control-sm" type="text" value="<%- change.crease_price %>" data-name="crease_price" <% if (change.readOnly) { %>readonly<% } %> placeholder=""></td>