Sfoglia il codice sorgente

feat: 公路云版,新增建议估算、可行性估算、概算项目选项;养护云版保持不变

TASK #3568
vian 4 anni fa
parent
commit
f2901acf1d

File diff suppressed because it is too large
+ 12 - 1
config/config.js


+ 17 - 2
modules/all_models/compilation.js

@@ -33,12 +33,27 @@ let modelSchema = {
     id: {
         type: Number
     },
-    // 清单计价规则
+    // 建议估算
+    suggestion_valuation: {
+        type: [childrenSchema],
+        default: []
+    },
+    // 可行性估算
+    feasibility_valuation: {
+        type: [childrenSchema],
+        default: []
+    },
+    // 概算
+    rough_valuation: {
+        type: [childrenSchema],
+        default: []
+    },
+    // 预算
     bill_valuation: {
         type: [childrenSchema],
         default: []
     },
-    // 定额计价规则
+    // 工程量清单
     ration_valuation: {
         type: [childrenSchema],
         default: []

+ 111 - 0
modules/ration_repository/models/ration_item.js

@@ -11,6 +11,7 @@ const scMathUtil = require('../../../public/scMathUtil').getUtil();
 const rationItemModel = mongoose.model('std_ration_lib_ration_items');
 const stdRationLibModel = mongoose.model('std_ration_lib_map');
 const stdRationSectionModel = mongoose.model('std_ration_lib_ration_chapter_trees');
+const stdCoeModel = mongoose.model('std_ration_lib_coe_list');
 const compleRationModel = mongoose.model('complementary_ration_items');
 import STDGLJListModel from '../../std_glj_lib/models/gljModel';
 import InstallationDao from '../models/installation';
@@ -20,9 +21,119 @@ const stdGljDao = new GljDao();
 import stdgljutil  from "../../../public/cache/std_glj_type_util";
 //add
 const stdGLJItemModel = mongoose.model('std_glj_lib_gljList');
+// const _rationItemModelBackup = mongoose.model('std_ration_lib_ration_items_backup');
 
 var rationItemDAO = function(){};
 
+
+async function getIDMapping(counterName, data) {
+    const counterInfo = await counter.counterDAO.getIDAfterCount(counterName, data.length);
+    const maxID = +counterInfo.sequence_value;
+    const IDMapping = {};
+    data.forEach((item, index) => {
+        IDMapping[item.ID] = maxID - (data.length - 1) + index;
+    });
+    return IDMapping;
+}
+
+// 拷贝分类树
+async function copyClassData(sourceLibID, targetLibID) {
+    const sourceClassData = await stdRationSectionModel.find({ rationRepId: sourceLibID }, '-_id').lean();
+    const IDMapping = await getIDMapping(counter.moduleName.rationTree, sourceClassData);
+    const insertData = sourceClassData.map(item => ({
+        ...item,
+        rationRepId: targetLibID,
+        ID: IDMapping[item.ID],
+        ParentID: IDMapping[item.ParentID] || -1,
+        NextSiblingID: IDMapping[item.NextSiblingID] || -1,
+    }));
+    if (insertData.length) {
+        await stdRationSectionModel.insertMany(insertData);
+    }
+    return IDMapping;
+}
+
+// 拷贝子目换算
+async function copyCoeData(sourceLibID, targetLibID) {
+    const sourceCoeData = await stdCoeModel.find({ libID: sourceLibID }, '-_id').lean();
+    const IDMapping = await getIDMapping(counter.moduleName.coeList, sourceCoeData);
+    const insertData = sourceCoeData.map(item => ({
+        ...item,
+        libID: targetLibID,
+        ID: IDMapping[item.ID],
+    }));
+    if (insertData.length) {
+        await stdCoeModel.insertMany(insertData);
+    }
+    return IDMapping;
+}
+
+
+// 拷贝定额库
+rationItemDAO.prototype.copyLib = async function(sourceLibID, targetLibID, sourceGLJLibID, targetGLJLibID) {
+    const sourceRationData = await rationItemModel.find({ rationRepId: sourceLibID }, '-_id').lean();
+    const rationIDMapping = await getIDMapping(counter.moduleName.rations, sourceRationData);
+    const classIDMapping = await copyClassData(sourceLibID, targetLibID);
+    const coeIDMapping = await copyCoeData(sourceLibID, targetLibID);
+    const sourceGLJData = await stdGLJItemModel.find({ repositoryId: sourceGLJLibID }, '-_id code ID').lean();
+    const sourceGLJCodeMapping = {};
+    sourceGLJData.forEach(glj => sourceGLJCodeMapping[glj.code] = glj.ID);
+    const targetGLJData = await stdGLJItemModel.find({ repositoryId: targetGLJLibID }, '-_id code ID').lean();
+    // 旧ID-新ID映射
+    const gljIDMapping = {};
+    targetGLJData.forEach(glj => {
+        const orgID = sourceGLJCodeMapping[glj.code];
+        if (orgID) {
+            gljIDMapping[orgID] = glj.ID;
+        }
+    });
+    sourceRationData.forEach(ration => {
+        ration.rationRepId = targetLibID;
+        ration.ID = rationIDMapping[ration.ID];
+        ration.sectionId = classIDMapping[ration.sectionId];
+        ration.rationCoeList.forEach(coe => {
+            coe.ID = coeIDMapping[coe.ID];
+        });
+        const rationGLJList = [];
+        ration.rationGljList.forEach(rGLJ => {
+            const newGLJID = gljIDMapping[rGLJ.gljId];
+            if (newGLJID) {
+                rGLJ.gljId = newGLJID;
+                rationGLJList.push(rGLJ);
+            }
+        });
+        ration.rationGljList = rationGLJList;
+    });
+    if (sourceRationData.length) {
+        await rationItemModel.insertMany(sourceRationData);
+    }
+
+}
+
+rationItemDAO.prototype.handleGLJCode = async function (rationLibID, gljLibID) {
+    const rations = await _rationItemModelBackup.find({ rationRepId: rationLibID }, 'ID rationGljList').lean();
+    const gljs = await stdGLJItemModel.find({ repositoryId: gljLibID }, 'ID code').lean();
+    const gljMap = {};
+    gljs.forEach(glj => gljMap[glj.ID] = glj.code);
+    const bulks = [];
+    rations.forEach(ration => {
+        if (ration.rationGljList && ration.rationGljList.length) {
+            ration.rationGljList.forEach(rGLJ => {
+                rGLJ.gljCode = gljMap[rGLJ.gljId];
+            });
+            bulks.push({
+                updateOne: {
+                    filter: { ID: ration.ID },
+                    update: { $set: { rationGljList: ration.rationGljList } }
+                }
+            })
+        }
+    });
+    if (bulks.length) {
+        await _rationItemModelBackup.bulkWrite(bulks);
+    }
+}
+
 rationItemDAO.prototype.updateRationGLJByOrgID = async function (rationLibID, gljLibID) {
     const gljList = await stdGLJItemModel.find({ repositoryId: gljLibID }, 'ID orgID').lean();
     const IDMap = {};

+ 3 - 0
modules/std_glj_lib/models/gljModel.js

@@ -54,8 +54,11 @@ class GljDao  extends OprDao{
                 ID: IDMapping[c.ID],
                 consumeAmt: c.consumeAmt
             }));
+            // 设备改材料
+            const gljType = glj.gljType === 5 ? 201 : glj.gljType;
             return {
                 ...glj,
+                gljType,
                 repositoryId: targetLibID,
                 ID: IDMapping[glj.ID],
                 component: newComponent

+ 9 - 2
modules/users/models/compilation_model.js

@@ -16,7 +16,7 @@ class CompilationModel extends BaseModel {
      *
      * @var {Array}
      */
-    sectionList = ['bill', 'ration'];
+    sectionList = ['suggestion', 'feasibility', 'rough', 'bill', 'ration'];
 
     /**
      * 构造函数
@@ -37,6 +37,9 @@ class CompilationModel extends BaseModel {
     async getCompilationList(fields = null) {
         // 筛选字段
         let field = fields == null ?{_id: 1, name: 1, is_release: 1,release_time:1, defaultLocation:1,categoryID: 1, description: 1,overWriteUrl: 1,example: 1, "ration_valuation.id": 1, "ration_valuation.name": 1, "ration_valuation.enable": 1,
+            "suggestion_valuation.id": 1, "suggestion_valuation.name": 1, "suggestion_valuation.enable": 1,
+            "feasibility_valuation.id": 1, "feasibility_valuation.name": 1, "feasibility_valuation.enable": 1,
+            "rough_valuation.id": 1, "rough_valuation.name": 1, "rough_valuation.enable": 1,
             "bill_valuation.id": 1, "bill_valuation.name": 1, "bill_valuation.enable": 1}:fields;
         let compilationData = await this.findDataByCondition({name: {$ne: ''}}, field, false);
 
@@ -277,7 +280,11 @@ class CompilationModel extends BaseModel {
         if (status) {
             let compilationData = await this.findDataByCondition({_id: id});
             // 最少需要有一个计价规则存在
-            if (compilationData.bill_valuation.length <= 0 && compilationData.ration_valuation.length <= 0) {
+            if (compilationData.suggestion_valuation.length <= 0 &&
+                compilationData.feasibility_valuation.length <= 0 &&
+                compilationData.rough_valuation.length <= 0 &&
+                compilationData.bill_valuation.length <= 0 && 
+                compilationData.ration_valuation.length <= 0) {
                 throw '至少需要一个计价规则';
             }
 

+ 2 - 2
web/users/js/compilation.js

@@ -21,7 +21,7 @@ function delayKeyup(callback) {
 $(document).ready(function() {
     let isAdding = false;
     let model = '';
-    let section = 'bill';
+    let section = $(".nav-tabs li.active > a").text() === '建议估算' ? 'suggestion' : 'bill';
     let id = $("#compilation-id").val();
 
     // 计价规则页面初始化数据
@@ -449,7 +449,7 @@ $(document).ready(function() {
         if (id === undefined || id === '') {
             return false;
         }
-        window.location.href = `/compilation/valuation/bill/delete/${id}`;
+        window.location.href = `/compilation/valuation/${section}/delete/${id}`;
     });
 
     // 发布编办

+ 124 - 2
web/users/views/compilation/index.html

@@ -16,12 +16,134 @@
     <div class="content-wrap">
         <div class="c-header" style="padding:0">
             <ul class="nav nav-tabs">
-                <li role="presentation" class="active"><a href="#bill" aria-controls="bill" role="tab" data-toggle="tab">预算</a></li>
+                <% if(selectedCompilation.name.includes('公路造价')) { %>
+                <li role="presentation" class="active"><a href="#suggestion" aria-controls="suggestion" role="tab" data-toggle="tab">建议估算</a></li>
+                <li role="presentation"><a href="#feasibility" aria-controls="feasibility" role="tab" data-toggle="tab">可行性估算</a></li>
+                <li role="presentation"><a href="#rough" aria-controls="rough" role="tab" data-toggle="tab">概算</a></li>
+                <% } %>
+                <li role="presentation" class=<%= selectedCompilation.name.includes('公路造价') ? '' : 'active' %>><a href="#bill" aria-controls="bill" role="tab" data-toggle="tab">预算</a></li>
                 <li role="presentation"><a href="#ration" aria-controls="ration" role="tab" data-toggle="tab">工程量清单</a></li>
             </ul>
         </div>
         <div class="c-body tab-content">
-            <div class="tab-pane active" role="tabpanel" id="bill">
+            <% if(selectedCompilation.name.includes('公路造价')) { %>
+            <div class="tab-pane active" role="tabpanel" id="suggestion">
+                <a class="btn btn-default btn-sm" href="#" data-toggle="modal" data-target="#valuation-dialog"><span class="glyphicon glyphicon-plus"></span> 添加计价规则</a>
+                <table class="table">
+                    <thead>
+                    <tr>
+                        <th>计价规则</th>
+                        <th>启用/禁用</th>
+                        <th>操作</th>
+                    </tr>
+                    </thead>
+                    <tbody>
+                    <% if (selectedCompilation.suggestion_valuation && selectedCompilation.suggestion_valuation.length > 0) { %>
+                    <% selectedCompilation.suggestion_valuation.forEach(function(suggestion) { %>
+                    <tr>
+                        <td><%= suggestion.name %></td>
+                        <td>
+                            <% if (suggestion.enable) { %>
+                            <div class="btn-group enable" data-id="<%= suggestion.id %>">
+                                <button class="btn btn-success  disabled" disabled="disabled">已开启</button>
+                                <button class="btn btn-default" title="禁用">禁用</button>
+                            </div>
+                            <% }else { %>
+                            <div class="btn-group enable" data-id="<%= suggestion.id %>">
+                                <button class="btn btn-default" title="开启">开启</button>
+                                <button class="btn btn-danger disabled" disabled="disabled">已禁用</button>
+                            </div>
+                            <% } %>
+                        </td>
+                        <td>
+                            <a href="/compilation/valuation/suggestion/<%= suggestion.id %>" class="btn btn-sm">编辑</a>
+                            <a onclick="$('#del').attr('selectedId', '<%= suggestion.id %>')" href="#" data-id="<%= suggestion.id %>" data-toggle="modal" data-target="#del" class="btn btn-sm text-danger">删除</a>
+                        </td>
+                    </tr>
+                    <% }) %>
+                    <% } %>
+                    </tbody>
+                </table>
+            </div>
+            <div class="tab-pane" role="tabpanel" id="feasibility">
+                <a class="btn btn-default btn-sm" href="#" data-toggle="modal" data-target="#valuation-dialog"><span class="glyphicon glyphicon-plus"></span> 添加计价规则</a>
+                <table class="table">
+                    <thead>
+                    <tr>
+                        <th>计价规则</th>
+                        <th>启用/禁用</th>
+                        <th>操作</th>
+                    </tr>
+                    </thead>
+                    <tbody>
+                    <% if (selectedCompilation.feasibility_valuation && selectedCompilation.feasibility_valuation.length > 0) { %>
+                    <% selectedCompilation.feasibility_valuation.forEach(function(feasibility) { %>
+                    <tr>
+                        <td><%= feasibility.name %></td>
+                        <td>
+                            <% if (feasibility.enable) { %>
+                            <div class="btn-group enable" data-id="<%= feasibility.id %>">
+                                <button class="btn btn-success  disabled" disabled="disabled">已开启</button>
+                                <button class="btn btn-default" title="禁用">禁用</button>
+                            </div>
+                            <% }else { %>
+                            <div class="btn-group enable" data-id="<%= feasibility.id %>">
+                                <button class="btn btn-default" title="开启">开启</button>
+                                <button class="btn btn-danger disabled" disabled="disabled">已禁用</button>
+                            </div>
+                            <% } %>
+                        </td>
+                        <td>
+                            <a href="/compilation/valuation/feasibility/<%= feasibility.id %>" class="btn btn-sm">编辑</a>
+                            <a onclick="$('#del').attr('selectedId', '<%= feasibility.id %>')" href="#" data-id="<%= feasibility.id %>" data-toggle="modal" data-target="#del" class="btn btn-sm text-danger">删除</a>
+                        </td>
+                    </tr>
+                    <% }) %>
+                    <% } %>
+                    </tbody>
+                </table>
+            </div>
+            <div class="tab-pane" role="tabpanel" id="rough">
+                <a class="btn btn-default btn-sm" href="#" data-toggle="modal" data-target="#valuation-dialog"><span class="glyphicon glyphicon-plus"></span> 添加计价规则</a>
+                <table class="table">
+                    <thead>
+                    <tr>
+                        <th>计价规则</th>
+                        <th>启用/禁用</th>
+                        <th>操作</th>
+                    </tr>
+                    </thead>
+                    <tbody>
+                    <% if (selectedCompilation.rough_valuation && selectedCompilation.rough_valuation.length > 0) { %>
+                    <% selectedCompilation.rough_valuation.forEach(function(rough) { %>
+                    <tr>
+                        <td><%= rough.name %></td>
+                        <td>
+                            <% if (rough.enable) { %>
+                            <div class="btn-group enable" data-id="<%= rough.id %>">
+                                <button class="btn btn-success  disabled" disabled="disabled">已开启</button>
+                                <button class="btn btn-default" title="禁用">禁用</button>
+                            </div>
+                            <% }else { %>
+                            <div class="btn-group enable" data-id="<%= rough.id %>">
+                                <button class="btn btn-default" title="开启">开启</button>
+                                <button class="btn btn-danger disabled" disabled="disabled">已禁用</button>
+                            </div>
+                            <% } %>
+                        </td>
+                        <td>
+                            <a href="/compilation/valuation/rough/<%= rough.id %>" class="btn btn-sm">编辑</a>
+                            <a onclick="$('#del').attr('selectedId', '<%= rough.id %>')" href="#" data-id="<%= rough.id %>" data-toggle="modal" data-target="#del" class="btn btn-sm text-danger">删除</a>
+                        </td>
+                    </tr>
+                    <% }) %>
+                    <% } %>
+                    </tbody>
+                </table>
+            </div>
+            <% } %>
+
+            <div class="<%= selectedCompilation.name.includes('公路造价') ? 'tab-pane' : 'tab-pane active' %>" role="tabpanel" id="bill">
                 <a class="btn btn-default btn-sm" href="#" data-toggle="modal" data-target="#valuation-dialog"><span class="glyphicon glyphicon-plus"></span> 添加计价规则</a>
                 <table class="table">
                     <thead>