zhongzewei 6 vuotta sitten
vanhempi
commit
6a2ebdcadb

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 15 - 0
lib/js-zip/jszip.min.js


+ 3 - 1
modules/common/const/bills_fixed.js

@@ -62,7 +62,9 @@ const fixedFlag = {
     //建设工程竣工档案编制费
     //建设工程竣工档案编制费
     PROJECT_COMPLETE_ARCH_FEE:30,
     PROJECT_COMPLETE_ARCH_FEE:30,
     //住宅工程质量分户验收费
     //住宅工程质量分户验收费
-    HOUSE_QUALITY_ACCEPT_FEE:31
+    HOUSE_QUALITY_ACCEPT_FEE:31,
+    //组织措施费
+    ORGANIZATION:32
 };
 };
 
 
 export default fixedFlag;
 export default fixedFlag;

+ 8 - 1
modules/main/routes/main_route.js

@@ -5,6 +5,7 @@
 
 
 import BaseController from "../../common/base/base_controller";
 import BaseController from "../../common/base/base_controller";
 const projectModel = require("../../pm/models/project_model");
 const projectModel = require("../../pm/models/project_model");
+const pmFacade = require('../../pm/facade/pm_facade');
 let config = require("../../../config/config.js");
 let config = require("../../../config/config.js");
 module.exports =function (app) {
 module.exports =function (app) {
     const baseController = new BaseController();
     const baseController = new BaseController();
@@ -22,6 +23,11 @@ module.exports =function (app) {
                     //允许协作的项目允许编辑,非只读
                     //允许协作的项目允许编辑,非只读
                     projectReadOnly = !projectCooperate;
                     projectReadOnly = !projectCooperate;
                 }
                 }
+                let fileKind = '1'; //默认投标文件
+                let constructProject = await pmFacade.getConstructionProject(req.query.project);
+                if (constructProject && constructProject.property && constructProject.property.fileKind) {
+                    fileKind = constructProject.property.fileKind;
+                }
                 res.render('building_saas/main/html/main.html',
                 res.render('building_saas/main/html/main.html',
                     {
                     {
                         userAccount: req.session.userAccount,
                         userAccount: req.session.userAccount,
@@ -32,7 +38,8 @@ module.exports =function (app) {
                         projectReadOnly: projectReadOnly,
                         projectReadOnly: projectReadOnly,
                         projectCooperate: projectCooperate,
                         projectCooperate: projectCooperate,
                         LicenseKey:config.getLicenseKey(process.env.NODE_ENV),
                         LicenseKey:config.getLicenseKey(process.env.NODE_ENV),
-                        overWriteUrl:req.session.sessionCompilation.overWriteUrl
+                        overWriteUrl:req.session.sessionCompilation.overWriteUrl,
+                        fileKind: fileKind
                     });
                     });
             } else {
             } else {
                 res.redirect('/pm');
                 res.redirect('/pm');

+ 88 - 0
web/building_saas/main/html/main.html

@@ -95,6 +95,13 @@
                             <a id="uploadGld" class="dropdown-item" href="#import" data-toggle="modal" data-target="#import">导入广联达算量Excel清单</a>
                             <a id="uploadGld" class="dropdown-item" href="#import" data-toggle="modal" data-target="#import">导入广联达算量Excel清单</a>
                         </div>
                         </div>
                     </span>
                     </span>
+                      <span id="exportSpan" class="btn btn-light btn-sm" data-toggle="tooltip" data-original-title="数据接口" data-placement="bottom">
+                    <a class="dropdown-toggle" href="#" data-toggle="dropdown"><i class="fa  fa-code-fork"></i></a>
+                    <div class="dropdown-menu">
+                        <a class="dropdown-item" href="#export" data-toggle="modal" data-target="#export">重庆市电子招投标数据接口</a>
+                        <a class="dropdown-item" href="#">重庆其他电子招投标数据接口</a>
+                    </div>
+                </span>
                     <a href="javascript:void(0)" class="btn btn-light btn-sm" id="insertRation" data-toggle="tooltip" data-placement="bottom" data-original-title="插入定额"><i class="fa fa-sign-in" aria-hidden="true"></i></a>
                     <a href="javascript:void(0)" class="btn btn-light btn-sm" id="insertRation" data-toggle="tooltip" data-placement="bottom" data-original-title="插入定额"><i class="fa fa-sign-in" aria-hidden="true"></i></a>
                     <!--2018-11-15 隐藏删除按钮   <a href="javascript:void(0)" class="btn btn-light btn-sm" id="delete" data-toggle="tooltip" data-placement="bottom" data-original-title="删除"><i class="fa fa-remove" aria-hidden="true"></i></a>-->
                     <!--2018-11-15 隐藏删除按钮   <a href="javascript:void(0)" class="btn btn-light btn-sm" id="delete" data-toggle="tooltip" data-placement="bottom" data-original-title="删除"><i class="fa fa-remove" aria-hidden="true"></i></a>-->
                     <a href="javascript:void(0)" class="btn btn-light btn-sm" id="upLevel" data-toggle="tooltip" data-placement="bottom" data-original-title="升级"><i class="fa fa-arrow-left" aria-hidden="true"></i></a>
                     <a href="javascript:void(0)" class="btn btn-light btn-sm" id="upLevel" data-toggle="tooltip" data-placement="bottom" data-original-title="升级"><i class="fa fa-arrow-left" aria-hidden="true"></i></a>
@@ -1999,6 +2006,86 @@
             </div>
             </div>
         </div>
         </div>
     </div>
     </div>
+<!--弹出 数据接口导出-->
+<div class="modal fade" id="export" data-backdrop="static">
+    <div class="modal-dialog" role="document">
+        <div class="modal-content">
+            <div class="modal-header">
+                <h5 class="modal-title">重庆市电子招投标数据接口<!-- 重庆其他电子招投标数据接口 --></h5>
+                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+                    <span aria-hidden="true">&times;</span>
+                </button>
+            </div>
+            <div class="modal-body">
+                <!--检测提醒-->
+                <div class="card">
+                    <div class="card-body">
+                        <h5 class="card-title">Card title</h5>
+                        <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
+                        <a id="exportCheck" href="javascript:void(0);" class="btn btn-primary">自检</a>
+                    </div>
+                </div>
+                <!--招标-->
+                <% if (fileKind == 2 || fileKind == 3) { %>
+                <div class="form-group">
+                    <label class="mb-0">招标接口文件导出</label>
+                    <small class="form-text text-muted">招标接口文件由以下2个文件组成,其内容必须保持一致,因此建议一次性全部导出。</small>
+                </div>
+                <div class="form-group">
+                    <div class="form-check ml-4">
+                        <input class="form-check-input" type="checkbox" value="2" id="ex-bid">
+                        <label class="form-check-label" for="ex-bid">
+                            招标工程量清单
+                        </label>
+                        <small class="form-text text-muted">招标工程量清单数据文件,用于投标人投标报价</small>
+                    </div>
+                    <div class="form-check ml-4">
+                        <input class="form-check-input" type="checkbox" value="3" id="ex-control">
+                        <label class="form-check-label" for="ex-control">
+                            招标控制价
+                        </label>
+                        <small class="form-text text-muted">包含完整组价数据的招标控制价文件</small>
+                    </div>
+                </div>
+                <% } else { %>
+                <!--投标-->
+                <div class="form-group">
+                    <label class="mb-0">投标接口文件导出</label>
+                </div>
+                <div class="form-group">
+                    <div class="form-check ml-4">
+                        <input class="form-check-input" type="checkbox" value="1" id="ex-tender">
+                        <label class="form-check-label" for="ex-tender">
+                            投标文件
+                        </label>
+                        <small class="form-text text-muted">投标工程数据文件</small>
+                    </div>
+                </div>
+                <% } %>
+            </div>
+            <div class="modal-footer">
+                <a id="export-confirm" href="javascript:void(0);" class="btn btn-primary">确定导出</a>
+                <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
+            </div>
+        </div>
+    </div>
+</div>
+<!--进度条-->
+<div class="modal fade" id="progress" data-backdrop="static">
+    <div class="modal-dialog" role="document">
+        <div class="modal-content">
+            <div class="modal-header">
+                <h5 id="progress-title" class="modal-title"></h5>
+            </div>
+            <div class="modal-body">
+                <h5 id="progress-content" class="my-3"></h5>
+                <div class="progress mb-3">
+                    <div class="progress-bar progress-bar-striped progress-bar-animated" id="progressBar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%"></div>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
 
 
     <img src="/web/dest/css/img/folder_open.png" id="folder_open_pic" style="display: none">
     <img src="/web/dest/css/img/folder_open.png" id="folder_open_pic" style="display: none">
     <img src="/web/dest/css/img/folder_close.png" id="folder_close_pic" style="display: none">
     <img src="/web/dest/css/img/folder_close.png" id="folder_close_pic" style="display: none">
@@ -2025,6 +2112,7 @@
     <script src="/lib/js-xlsx/xlsx.core.min.js"></script>
     <script src="/lib/js-xlsx/xlsx.core.min.js"></script>
     <script src="/lib/lz-string/lz-string.min.js"></script>
     <script src="/lib/lz-string/lz-string.min.js"></script>
     <script src="/lib/fileSaver/FileSaver.min.js"></script>
     <script src="/lib/fileSaver/FileSaver.min.js"></script>
+    <script src="/lib/js-zip/jszip.min.js"></script>
     <!-- inject:js -->
     <!-- inject:js -->
     <!--<script type="text/javascript" src="/test/tmp_data/test_ration_calc/ration_calc_base.js"></script>-->
     <!--<script type="text/javascript" src="/test/tmp_data/test_ration_calc/ration_calc_base.js"></script>-->
     <script type="text/javascript" src="/web/building_saas/main/js/models/main_consts.js"></script>
     <script type="text/javascript" src="/web/building_saas/main/js/models/main_consts.js"></script>

+ 172 - 31
web/building_saas/main/js/models/exportStandardInterface.js

@@ -31,6 +31,7 @@ const XMLStandard = (function () {
         [fixedFlag.SUB_ENGINERRING]: '1100',
         [fixedFlag.SUB_ENGINERRING]: '1100',
         [fixedFlag.MEASURE]: '1200',
         [fixedFlag.MEASURE]: '1200',
         [fixedFlag.CONSTRUCTION_ORGANIZATION]: '120201',
         [fixedFlag.CONSTRUCTION_ORGANIZATION]: '120201',
+        [fixedFlag.ORGANIZATION]: '120201',
         [fixedFlag.SAFETY_CONSTRUCTION]: '1204',
         [fixedFlag.SAFETY_CONSTRUCTION]: '1204',
         [fixedFlag.PROJECT_COMPLETE_ARCH_FEE]: '10041',
         [fixedFlag.PROJECT_COMPLETE_ARCH_FEE]: '10041',
         [fixedFlag.HOUSE_QUALITY_ACCEPT_FEE]: '1206',
         [fixedFlag.HOUSE_QUALITY_ACCEPT_FEE]: '1206',
@@ -54,6 +55,67 @@ const XMLStandard = (function () {
         '1': '一般计税法',
         '1': '一般计税法',
         '2': '简易计税法',
         '2': '简易计税法',
     };
     };
+    //固定类别-基数映射
+    const FlagCalcBaseMap = {
+        [fixedFlag.SUB_ENGINERRING]: 'FBFXHJ',
+        [fixedFlag.MEASURE]: 'CSXMHJ',
+        [fixedFlag.CONSTRUCTION_TECH]: 'JSCSF',
+        [fixedFlag.CONSTRUCTION_ORGANIZATION]: 'ZZCSF',
+        [fixedFlag.Other]: 'QTXMHJ',
+        [fixedFlag.CHARGE]: 'GF',
+        [fixedFlag.TAX]: 'SJ',
+        [fixedFlag.PROVISIONAL]: 'ZLJE',
+        [fixedFlag.ENGINEERING_ESITIMATE]: 'ZYZGJ',
+        [fixedFlag.DAYWORK]: 'JRG',
+        [fixedFlag.TURN_KEY_CONTRACT]: 'ZCBFWF',
+        [fixedFlag.CLAIM_VISA]: 'SPQZ',
+        '{分部分项工程费}': fixedFlag.SUB_ENGINERRING,
+        '{措施项目费}': fixedFlag.MEASURE,
+        '{组织措施项目费}': fixedFlag.CONSTRUCTION_ORGANIZATION,
+        '{技术措施项目费}': fixedFlag.CONSTRUCTION_TECH,
+        '{安全文明施工专项费}': fixedFlag.SAFETY_CONSTRUCTION,
+        '{其他项目费}': fixedFlag.OTHER,
+        '{规费}': fixedFlag.CHARGE,
+        '{税金}': fixedFlag.TAX,
+        '{增值税}': fixedFlag.ADDED_VALUE_TAX,
+    };
+    //计算基础表达式映射
+    const CalcBaseMap = {
+        '{分部分项工程费}': 'FBFXHJ',
+        '{措施项目费}': 'CSXMHJ',
+        '{组织措施项目费}': 'ZZCSF',
+        '{其他项目费}': 'QTXMHJ',
+        '{规费}': 'GF',
+        '{税金}': 'SJ',
+        '{分部分项定额人工费}': 'RGF',
+        '{分部分项定额材料费}': 'CLF',
+        '{分部分项定额施工机具使用费}': 'JXF',
+        '{分部分项主材费}': 'ZCF',
+        '{分部分项人工工日}': 'GR',
+        '{技术措施项目费}': 'JSCSF',
+        '{技术措施项目定额人工费}': 'JSCS_RGF',
+        '{技术措施项目定额材料费}': 'JSCS_CLF',
+        '{技术措施项目定额施工机具使用费}': 'JSCS_JXF',
+        '{技术措施项目主材费}': 'JSCS_ZCF',
+        '{技术措施项目人工工日}': 'JSCS_GR',
+        '{建筑面积}': 'JZMJ',
+        '{人材机价差}': 'RCJJC',
+        '{人工价差}': 'RGJC',
+        '{材料价差}': 'CLJC',
+        '{施工机具使用费价差}': 'JXJC',
+        '{甲供人工费}': 'JGRGF',
+        '{甲供材料费}': 'JGCLF',
+        '{甲供施工机具使用费}': 'JGJXF',
+        '{甲供主材费}': 'JGZCF',
+        '{甲供设备费}': 'JGSBF',
+        '{分包费}': 'FBF',
+        '{分包定额人工费}': 'FBRGF',
+        '{分包定额材料费}': 'FBCLF',
+        '{分包定额机械费}': 'FBJXF',
+        '{分包主材费}': 'FBZCF',
+        '{分包设备费}': 'FBSBF',
+        '{分包人工工日}': 'FBGR'
+    };
     //加载数据间隔,减少服务器压力
     //加载数据间隔,减少服务器压力
     const TIMEOUT_TIME = 500;
     const TIMEOUT_TIME = 500;
     function isDef(v) {
     function isDef(v) {
@@ -77,9 +139,9 @@ const XMLStandard = (function () {
             granularity = GRANULARITY.PROJECT;
             granularity = GRANULARITY.PROJECT;
         }
         }
         this.granularity = granularity;
         this.granularity = granularity;
-        //默认导出标文件
+        //默认导出标文件
         if (!exportKind || ![1, 2, 3].includes(exportKind)) {
         if (!exportKind || ![1, 2, 3].includes(exportKind)) {
-            exportKind = ExportKind.Bid;
+            exportKind = ExportKind.Tender;
         }
         }
         this.exportKind = exportKind;
         this.exportKind = exportKind;
         /*
         /*
@@ -109,27 +171,21 @@ const XMLStandard = (function () {
                 if (data.minLen && data.value.length < data.minLen){
                 if (data.minLen && data.value.length < data.minLen){
                     isFail = true;
                     isFail = true;
                     tempFail = `“${data.name}”字符数不可小于${data.minLen}个`;
                     tempFail = `“${data.name}”字符数不可小于${data.minLen}个`;
-                    //rst.failHints.push(`“${data.name}”字符数不可小于${data.minLen}个`);
                 } else if (data.maxLen && data.value.length > data.maxLen) {
                 } else if (data.maxLen && data.value.length > data.maxLen) {
                     isFail = true;
                     isFail = true;
                     tempFail = `“${data.name}”字符数不可大于${data.maxLen}个`;
                     tempFail = `“${data.name}”字符数不可大于${data.maxLen}个`;
-                    //rst.failHints.push(`“${data.name}”字符数不可大于${data.maxLen}个`);
                 } else if (data.enumeration && !data.enumeration.includes(data.value)) {
                 } else if (data.enumeration && !data.enumeration.includes(data.value)) {
                     isFail = true;
                     isFail = true;
                     tempFail = `“${data.name}”只能从“${data.enumeration.join(';')}”中选择`;
                     tempFail = `“${data.name}”只能从“${data.enumeration.join(';')}”中选择`;
-                    //rst.failHints.push(`“${data.name}”只能从“${data.enumeration.join(';')}”中选择`);
                 } else if (data.type && data.type === TYPE.DATE && !dateReg.test(data.value)) {
                 } else if (data.type && data.type === TYPE.DATE && !dateReg.test(data.value)) {
                     isFail = true;
                     isFail = true;
                     tempFail = `“${data.name}”日期格式必须是YYYY-MM-DD`;
                     tempFail = `“${data.name}”日期格式必须是YYYY-MM-DD`;
-                    //rst.push(`“${data.name}”日期格式必须是YYYY-MM-DD`);
                 } else if (data.type && data.type === TYPE.INT && !Number.isInteger(parseFloat(data.value))) {
                 } else if (data.type && data.type === TYPE.INT && !Number.isInteger(parseFloat(data.value))) {
                     isFail = true;
                     isFail = true;
                     tempFail = `“${data.name}”必须为整数`;
                     tempFail = `“${data.name}”必须为整数`;
-                    //rst.failHints.push(`“${data.name}”必须为整数`);
                 } else if (data.type && data.type === TYPE.DECIMAL && isNaN(parseFloat(data.value))) {
                 } else if (data.type && data.type === TYPE.DECIMAL && isNaN(parseFloat(data.value))) {
                     isFail = true;
                     isFail = true;
                     tempFail = `“${data.name}”必须为数值`;
                     tempFail = `“${data.name}”必须为数值`;
-                    //rst.failHints.push(`“${data.name}”必须为数值`)
                 } else if (data.type && data.type === TYPE.NUM2) {
                 } else if (data.type && data.type === TYPE.NUM2) {
                     let v = parseFloat(data.value);
                     let v = parseFloat(data.value);
                     if (isNaN(v)) {
                     if (isNaN(v)) {
@@ -138,13 +194,10 @@ const XMLStandard = (function () {
                         rst.failHints.push(`“${data.name}”必须为数值`);
                         rst.failHints.push(`“${data.name}”必须为数值`);
                     } else if (!data.value.length || (data.value.split('.').length > 1 && data.value.split('.')[1].length > 2)){
                     } else if (!data.value.length || (data.value.split('.').length > 1 && data.value.split('.')[1].length > 2)){
                         isFail = true;
                         isFail = true;
-                        //tempFail = `“${data.name}”小数位数不得多于两位`;
-                        //rst.failHints.push(`“${data.name}”小数位数不得多于两位`);
                     }
                     }
                 } else if (data.type && data.type === TYPE.BOOL && !['true', 'false'].includes(data.value.toString())) {
                 } else if (data.type && data.type === TYPE.BOOL && !['true', 'false'].includes(data.value.toString())) {
                     isFail = true;
                     isFail = true;
                     tempFail = `“${data.name}”必须为true或false`;
                     tempFail = `“${data.name}”必须为true或false`;
-                    //rst.failHints.push(`“${data.name}”必须为true或false`);
                 }
                 }
                 if (!isFail || data.required) {
                 if (!isFail || data.required) {
                     rst.filterAttrs.push(data);
                     rst.filterAttrs.push(data);
@@ -157,7 +210,7 @@ const XMLStandard = (function () {
         }
         }
         //从fees数组中获取相关费用
         //从fees数组中获取相关费用
         function getFee(fees, feeFields) {
         function getFee(fees, feeFields) {
-            if (!fees) {
+            if (!Array.isArray(fees)) {
                 return 0;
                 return 0;
             }
             }
             let fields = feeFields.split('.');
             let fields = feeFields.split('.');
@@ -182,6 +235,7 @@ const XMLStandard = (function () {
             }
             }
             return '';
             return '';
         }
         }
+
         //造成导出失败
         //造成导出失败
         let failList = [];
         let failList = [];
         /*
         /*
@@ -204,7 +258,7 @@ const XMLStandard = (function () {
         //source:来源数据
         //source:来源数据
         function Project(source) {
         function Project(source) {
             let attrs = [
             let attrs = [
-                {name: '项目编号', value: getValueByKey(source.basicInformation, 'projNumber'), required: true, minLen: 1, maxLen: 255, whiteSpace: WHITE_SPACE.COLLAPSE},
+                {name: '项目编号', value: getValueByKey(source.basicInformation, 'projNum'), required: true, minLen: 1, maxLen: 255, whiteSpace: WHITE_SPACE.COLLAPSE},
                 {name: '项目名称', value: source.name, required: true, minLen: 1, maxLen: 255, whiteSpace: WHITE_SPACE.COLLAPSE},
                 {name: '项目名称', value: source.name, required: true, minLen: 1, maxLen: 255, whiteSpace: WHITE_SPACE.COLLAPSE},
                 {name: '建设单位', value: getValueByKey(source.basicInformation, 'constructionUnit'), required: true},
                 {name: '建设单位', value: getValueByKey(source.basicInformation, 'constructionUnit'), required: true},
                 {name: '标准版本号', value: '3.2.2', required: true},
                 {name: '标准版本号', value: '3.2.2', required: true},
@@ -243,6 +297,7 @@ const XMLStandard = (function () {
         //招标信息定义
         //招标信息定义
         function BiddingInfo(source) {
         function BiddingInfo(source) {
             //控制总价: 如果文件类型是“控制价”,则导出建设项目的工程造价;如果是“招标”、“投标”,则取0
             //控制总价: 如果文件类型是“控制价”,则导出建设项目的工程造价;如果是“招标”、“投标”,则取0
+            console.log(exportKind);
             let attrs = [
             let attrs = [
                 {name: '招标代理机构', value: getValueByKey(source.basicInformation, 'agency')},
                 {name: '招标代理机构', value: getValueByKey(source.basicInformation, 'agency')},
                 {name: '造价工程师', value: getValueByKey(source.basicInformation, 'tenderCostEngineer'), required: true},
                 {name: '造价工程师', value: getValueByKey(source.basicInformation, 'tenderCostEngineer'), required: true},
@@ -307,7 +362,7 @@ const XMLStandard = (function () {
             let attrs = [
             let attrs = [
                 {name: '编号', value: source.code, required: true, minLen: 1, maxLen: 255, whiteSpace: WHITE_SPACE.COLLAPSE},
                 {name: '编号', value: source.code, required: true, minLen: 1, maxLen: 255, whiteSpace: WHITE_SPACE.COLLAPSE},
                 {name: '名称', value: source.name, required: true, minLen: 1, maxLen: 255, whiteSpace: WHITE_SPACE.COLLAPSE},
                 {name: '名称', value: source.name, required: true, minLen: 1, maxLen: 255, whiteSpace: WHITE_SPACE.COLLAPSE},
-                {name: '金额', value: source.summaryInfo.engineeringCost, type: TYPE.NUM2},
+                {name: '金额', value: exportKind === FILE_KIND.tender ? source.summaryInfo.engineeringCost : '0', type: TYPE.NUM2},
             ];
             ];
             element.call(this, '单项工程', attrs);
             element.call(this, '单项工程', attrs);
         }
         }
@@ -326,7 +381,9 @@ const XMLStandard = (function () {
                     '围墙工程', '幕墙工程', '市政安装工程', '城市轨道交通安装', '人工土石方',
                     '围墙工程', '幕墙工程', '市政安装工程', '城市轨道交通安装', '人工土石方',
                     '房屋安装修缮工程', '房屋修缮单拆除'
                     '房屋安装修缮工程', '房屋修缮单拆除'
                 ]},
                 ]},
-                {name: '金额', value: source.summaryInfo.engineeringCost, type: TYPE.NUM2},
+                {name: '金额', value: exportKind === FILE_KIND.tender
+                    ? source.summaryInfo.engineeringCost
+                    : '0', type: TYPE.NUM2},
                 {name: '定额库编码', value: source.defaultRationLibCode, enumeration: [
                 {name: '定额库编码', value: source.defaultRationLibCode, enumeration: [
                     'CQ18TJ', 'CQ18ZS', 'CQ18AZ', 'CQ18SZ', 'CQ18YL', 'CQ18FG', 'CQ18GD', 'CQ18FS',
                     'CQ18TJ', 'CQ18ZS', 'CQ18AZ', 'CQ18SZ', 'CQ18YL', 'CQ18FG', 'CQ18GD', 'CQ18FS',
                     'CQ18LS', 'CQ18GZW', 'CQ18BP', 'CQ18ZP'
                     'CQ18LS', 'CQ18GZW', 'CQ18BP', 'CQ18ZP'
@@ -363,7 +420,7 @@ const XMLStandard = (function () {
         //特征项定义
         //特征项定义
         function FeatureItem(feature) {
         function FeatureItem(feature) {
             let attrs = [
             let attrs = [
-                {name: '编码', value: ''},
+                {name: '编码', value: feature.code || ''},
                 {name: '名称', value: feature.dispName, required: true},
                 {name: '名称', value: feature.dispName, required: true},
                 {name: '内容', value: feature.value, required: true},
                 {name: '内容', value: feature.value, required: true},
             ];
             ];
@@ -374,7 +431,7 @@ const XMLStandard = (function () {
             element.call(this, '单位工程费汇总', []);
             element.call(this, '单位工程费汇总', []);
         }
         }
         //计价程序费用行定义
         //计价程序费用行定义
-        function DXFYRow(source) {
+        function FeeRow(source) {
             let attrs = [
             let attrs = [
                 {name: '序号', value: source.code},
                 {name: '序号', value: source.code},
                 {name: '行代号', value: source.rowCode, required: true},
                 {name: '行代号', value: source.rowCode, required: true},
@@ -618,7 +675,7 @@ const XMLStandard = (function () {
             let attrs = [
             let attrs = [
                 {name: '金额', value: getFee(source.fees, 'common.totalFee')}
                 {name: '金额', value: getFee(source.fees, 'common.totalFee')}
             ];
             ];
-            element.call(this, '', attrs);
+            element.call(this, '计日工', attrs);
         }
         }
         //人工定义
         //人工定义
         function Labour() {
         function Labour() {
@@ -867,11 +924,14 @@ const XMLStandard = (function () {
         }
         }
 
 
         this.failList = failList;
         this.failList = failList;
-        this.granularity = granularity;
         //目前的数据
         //目前的数据
         let curPMData = {project: null, engineering: null, tender: null},   //项目管理项目数据
         let curPMData = {project: null, engineering: null, tender: null},   //项目管理项目数据
             curProjectEle = null,  //建设项目节点
             curProjectEle = null,  //建设项目节点
             curTenderEle = null;   //单位工程节点
             curTenderEle = null;   //单位工程节点
+
+        //记录拉取的单位工程项目详细数据,导出的时候,可能会导出多个文件,只有导出第一个文件的时候需要请求数据
+        let tenderDetailMap = {};   //ID映射 ID: data
+
         //自增编码
         //自增编码
         let incrementData = {
         let incrementData = {
             projectCode: 1,     //项目编号,单项工程、单位工程编号自动生成
             projectCode: 1,     //项目编号,单项工程、单位工程编号自动生成
@@ -977,12 +1037,79 @@ const XMLStandard = (function () {
             return target;
             return target;
 
 
         }
         }
+        //转换基数表达式
+        //1.有子项,则取固定清单对应基数
+        //2.无子项,有基数,a.优先转换为行代号(不可自身) b.不能转换为行代号则找对应字典
+        //3.基数中有无法转换的,设为金额
+        function transformCalcBase(tenderDetail, node) {
+            let expr = node.data.calcBase || '';
+            if (node.children.length) {
+                let flag = getNodeFlag(node);
+                return FlagCalcBaseMap[flag] || '';
+            }
+            if (expr) {
+                let illegal = false;
+                let normalBase = getNormalBase(expr),
+                    idBase = getIDBase(expr);
+                //普通基数转基数字典
+                normalBase.forEach(base => {
+                    let replaceStr = CalcBaseMap[base];
+                    //转换成行代号的优先级比较高,进行清单匹配
+                    let flag = FlagCalcBaseMap[base];
+                    if (flag) {
+                        let flagNode = tenderDetail.mainTree.items.find(mNode => getNodeFlag(mNode) === flag);
+                        //匹配到了 普通基数转换成行引用
+                        if (flagNode) {
+                            replaceStr = flagNode.serialNo() + 1;
+                        }
+                    }
+                    //存在无法处理的基数
+                    if (!replaceStr) {
+                        illegal = true;
+                        return;
+                    }
+                    expr = expr.replace(new RegExp(base, 'g'), replaceStr);
+                });
+                //id引用转行代号引用
+                idBase.forEach(base => {
+                    let id = base.match(/[^@]+/)[0];
+                    let theNode = tenderDetail.mainTree.getNodeByID(id),
+                        rowCode = theNode ? `F${theNode.serialNo() + 1}` : '';
+                    if (!rowCode) {
+                        illegal = true;
+                        return;
+                    }
+                    expr = expr.replace(new RegExp(base, 'g'), rowCode);
+                });
+                //不合法 返回金额
+                if (illegal) {
+                    return getFee(node.data.fees, 'common.totalFee');
+                }
+                return expr;
+            }
+            //获取普通基数: {xxx}
+            function getNormalBase(str) {
+                let reg = /{.+?}/g,
+                    matchs = str.match(reg);
+                return matchs || [];
+            }
+            //获取id引用基数: @xxx-xxx-xx
+            function getIDBase(str) {
+                let reg = /@.{36}/g,
+                    matchs = str.match(reg);
+                return matchs || [];
+            }
+        }
+
         //获取需要导出的项目数据
         //获取需要导出的项目数据
         //@param {Number}tenderID(当前界面的单位工程ID,后台根据这个单位工程,去找其建设项目下所有数据)
         //@param {Number}tenderID(当前界面的单位工程ID,后台根据这个单位工程,去找其建设项目下所有数据)
         //@return {Object}(eleObj)
         //@return {Object}(eleObj)
         async function loadProject(tenderID) {
         async function loadProject(tenderID) {
             //拉取标段数据:建设项目、单项工程、单位工程数据
             //拉取标段数据:建设项目、单项工程、单位工程数据
-            let projectData = curPMData.project = await ajaxPost('/pm/api/getProjectByGranularity', {user_id: userID, tenderID: tenderID, granularity: granularity});
+            let projectData = curPMData.project;
+            if (!projectData) {   //没有数据,需要拉取
+                projectData = curPMData.project = await ajaxPost('/pm/api/getProjectByGranularity', {user_id: userID, tenderID: tenderID, granularity: granularity});
+            }
             if (!projectData) {
             if (!projectData) {
                 throw '获取项目数据错误';
                 throw '获取项目数据错误';
             }
             }
@@ -1063,7 +1190,10 @@ const XMLStandard = (function () {
             //分批次获取单位工程
             //分批次获取单位工程
             for (let tenderData of engData.children) {
             for (let tenderData of engData.children) {
                 curPMData.tender = tenderData;
                 curPMData.tender = tenderData;
-                await setTimeoutSync(() => {},TIMEOUT_TIME);    //间隔一段时间再初始单位工程数据,减少服务器压力
+                //需要请求项目详细数据的时候,间隔一段时间再初始单位工程数据,减少服务器压力
+                if (!tenderDetailMap[tenderData.ID]) {
+                    await setTimeoutSync(() => {},TIMEOUT_TIME);
+                }
                 let tender = await loadTender(summaryInfo, tenderData);
                 let tender = await loadTender(summaryInfo, tenderData);
                 tenderGljs = [];    //清空单位工程内所有的人材机(ID)
                 tenderGljs = [];    //清空单位工程内所有的人材机(ID)
                 engineering.children.push(tender);
                 engineering.children.push(tender);
@@ -1077,8 +1207,12 @@ const XMLStandard = (function () {
         * */
         * */
         async function loadTender(summaryInfo, tenderData) {
         async function loadTender(summaryInfo, tenderData) {
             //获取单位工程详细数据
             //获取单位工程详细数据
-            let tenderDetail = PROJECT.createNew(tenderData.ID, userID);
-            await tenderDetail.loadDataSync();
+            let tenderDetail = tenderDetailMap[tenderData.ID];
+            if (!tenderDetail) {
+                tenderDetail = PROJECT.createNew(tenderData.ID, userID);
+                await tenderDetail.loadDataSync();
+                tenderDetailMap[tenderData.ID] = tenderDetail;
+            }
             //设置定额库编码
             //设置定额库编码
             tenderDetail.rationLibMap = {};
             tenderDetail.rationLibMap = {};
             let defaultLib = null;
             let defaultLib = null;
@@ -1091,7 +1225,6 @@ const XMLStandard = (function () {
             //初始化项目人材机代号(人材机生成的代号要由排序后的项目人材机从C0开始生成),定额下的人材机含量提前使用到了这个代码,所以需要先初始化
             //初始化项目人材机代号(人材机生成的代号要由排序后的项目人材机从C0开始生成),定额下的人材机含量提前使用到了这个代码,所以需要先初始化
             let allGljs = gljUtil.sortRationGLJ(tenderDetail.projectGLJ.datas.gljList); //人材机汇总排序
             let allGljs = gljUtil.sortRationGLJ(tenderDetail.projectGLJ.datas.gljList); //人材机汇总排序
             tenderGljs = allGljs.map(glj => glj.glj_id);
             tenderGljs = allGljs.map(glj => glj.glj_id);
-
             //单位工程
             //单位工程
             let tenderSource = {
             let tenderSource = {
                 code: getIncreamentData('projectCode'),
                 code: getIncreamentData('projectCode'),
@@ -1163,9 +1296,9 @@ const XMLStandard = (function () {
         function loadDXFY(detail) {
         function loadDXFY(detail) {
             //单位工程费汇总
             //单位工程费汇总
             let tenderFeeSummary = new TenderFeeSummary();
             let tenderFeeSummary = new TenderFeeSummary();
-            //计价程序费用行,筛选大项费用行数据
-            let dxfyNodes = detail.Bills.tree.roots;
-            for (let node of dxfyNodes) {
+            //计价程序费用行,筛选大项费用
+            let feeNodes = detail.Bills.tree.roots;
+            for (let node of feeNodes) {
                 let mainTreeNode = detail.mainTree.getNodeByID(node.data.ID),
                 let mainTreeNode = detail.mainTree.getNodeByID(node.data.ID),
                     serialNo = mainTreeNode ? mainTreeNode.serialNo() + 1 : 1;
                     serialNo = mainTreeNode ? mainTreeNode.serialNo() + 1 : 1;
                 let flag = getNodeFlag(node) || 0;
                 let flag = getNodeFlag(node) || 0;
@@ -1173,14 +1306,14 @@ const XMLStandard = (function () {
                     code: node.data.code,
                     code: node.data.code,
                     rowCode: `F${serialNo}`,
                     rowCode: `F${serialNo}`,
                     name: node.data.name,
                     name: node.data.name,
-                    calcBase: node.data.calcBase,
+                    calcBase: transformCalcBase(detail, node),
                     feeRate: node.data.feeRate ? node.data.feeRate : 100,
                     feeRate: node.data.feeRate ? node.data.feeRate : 100,
                     fees: node.data.fees,
                     fees: node.data.fees,
                     feeType: FEE_TYPE[flag] || FEE_TYPE['0'],
                     feeType: FEE_TYPE[flag] || FEE_TYPE['0'],
                     remark: node.data.remark
                     remark: node.data.remark
                 };
                 };
-                let dxfy = new DXFYRow(source);
-                tenderFeeSummary.children.push(dxfy);
+                let feeRow = new FeeRow(source);
+                tenderFeeSummary.children.push(feeRow);
             }
             }
             return tenderFeeSummary;
             return tenderFeeSummary;
         }
         }
@@ -1462,6 +1595,9 @@ const XMLStandard = (function () {
                             remark: node.data.remark,
                             remark: node.data.remark,
                             feeType: FEE_TYPE[getNodeFlag(node)] || FEE_TYPE['0']
                             feeType: FEE_TYPE[getNodeFlag(node)] || FEE_TYPE['0']
                         };
                         };
+                        /*if (source.feeType === '1800') {
+                            debugger;
+                        }*/
                         let formula = new FormulaCalcMeasure(source);
                         let formula = new FormulaCalcMeasure(source);
                         parent.children.push(formula);
                         parent.children.push(formula);
                     }
                     }
@@ -1993,9 +2129,13 @@ const XMLStandard = (function () {
         /*
         /*
          * 导出数据
          * 导出数据
          * @param {Number}tenderID(当前界面的单位工程ID,后台根据这个单位工程,根据导出粒度去找其建设项目下相关数据)
          * @param {Number}tenderID(当前界面的单位工程ID,后台根据这个单位工程,根据导出粒度去找其建设项目下相关数据)
+         * @param {Number}curExportKind(导出的文件类型:1-投标 2-招标 3-控制价)
          * @return {void}
          * @return {void}
          * */
          * */
-        this.toXml = async function (tenderID) {
+        this.toXml = async function (tenderID, curExportKind) {
+            if (curExportKind) {
+                this.exportKind = exportKind = parseInt(curExportKind);
+            }
             let eleData = await loadProject(tenderID);
             let eleData = await loadProject(tenderID);
             this.datas = eleData;
             this.datas = eleData;
             if (!eleData) {
             if (!eleData) {
@@ -2008,6 +2148,7 @@ const XMLStandard = (function () {
             //格式化
             //格式化
             xmlStr = formatXml(xmlStr);
             xmlStr = formatXml(xmlStr);
             let blob = new Blob([xmlStr], {type: 'text/plain;charset=utf-8'});
             let blob = new Blob([xmlStr], {type: 'text/plain;charset=utf-8'});
+            return blob;
             saveAs(blob, '重庆标准交换数据.QTF');
             saveAs(blob, '重庆标准交换数据.QTF');
         }
         }
     }
     }

+ 3 - 1
web/building_saas/main/js/models/main_consts.js

@@ -268,7 +268,9 @@ const fixedFlag = {
     //建设工程竣工档案编制费
     //建设工程竣工档案编制费
     PROJECT_COMPLETE_ARCH_FEE:30,
     PROJECT_COMPLETE_ARCH_FEE:30,
     //住宅工程质量分户验收费
     //住宅工程质量分户验收费
-    HOUSE_QUALITY_ACCEPT_FEE:31
+    HOUSE_QUALITY_ACCEPT_FEE:31,
+    //组织措施费
+    ORGANIZATION:32,
 };
 };
 const gljKeyArray =['code','name','specs','unit','type'];
 const gljKeyArray =['code','name','specs','unit','type'];
 const rationKeyArray =['code','name','specs','unit','subType'];
 const rationKeyArray =['code','name','specs','unit','subType'];

+ 60 - 9
web/building_saas/main/js/views/project_view.js

@@ -2174,6 +2174,21 @@ $('#importSpan').click(function () {
 $('#importDropDown').click(function () {
 $('#importDropDown').click(function () {
     $('[data-toggle="tooltip"]').tooltip('hide');
     $('[data-toggle="tooltip"]').tooltip('hide');
 });
 });
+//导出接口下拉
+$('#exportSpan').click(function () {
+    $('[data-toggle="tooltip"]').tooltip('hide');
+    let toggle = $('#exportSpan>a').attr('data-toggle');
+    if (toggle) {
+        $('#exportSpan>a').removeAttr('data-toggle');
+    }
+    $('#exportSpan>a').dropdown('toggle');
+    setTimeout(function () {
+        $('#exportSpan>a').attr('data-toggle', 'dropdown');
+    }, 100);
+});
+$('#exportSpan>a').click(function () {
+    $('[data-toggle="tooltip"]').tooltip('hide');
+});
 $('body').click(function () {
 $('body').click(function () {
     //点击完后隐藏子菜单
     //点击完后隐藏子菜单
    if ($('#subDisplay').is(':visible')) {
    if ($('#subDisplay').is(':visible')) {
@@ -2355,15 +2370,6 @@ $('#tab_compilation_illustration').on('show.bs.tab', function () {
     $('#compilationIllustration textarea').val(v);
     $('#compilationIllustration textarea').val(v);
 });
 });
 $('#property_ok').click(async function () {
 $('#property_ok').click(async function () {
-    //test-----
-    /*$.bootstrapLoading.start();
-    let xmlObj = new XMLStandard(userID, 1);
-    await xmlObj.toXml(projectObj.project.ID());
-    console.log(xmlObj);
-    xmlObj = null;
-    $.bootstrapLoading.end();
-    return;*/
-    //test-----
     let project = projectObj.project,
     let project = projectObj.project,
         projectID = project.ID(),
         projectID = project.ID(),
         properties = {},
         properties = {},
@@ -3169,6 +3175,9 @@ function disableTools(){
     $('.bottom-tools').remove();
     $('.bottom-tools').remove();
     //导入
     //导入
     $('#importConfirm').addClass('disabled');
     $('#importConfirm').addClass('disabled');
+    //导出
+    $('#export-confirm').addClass('disabled');
+    $('#exportSpan .dropdown-item').addClass('disabled');
     //选项
     //选项
     $('#generalOpts1').prop('disabled', 'disabled');
     $('#generalOpts1').prop('disabled', 'disabled');
     $('#generalOpts2').prop('disabled', 'disabled');
     $('#generalOpts2').prop('disabled', 'disabled');
@@ -3307,3 +3316,45 @@ $('#calcBaseFeeRateConf').click(function () {
 $('#menu_calc_program_manage').click(function () {
 $('#menu_calc_program_manage').click(function () {
     $('#tab_calc_program_manage').click();
     $('#tab_calc_program_manage').click();
 });
 });
+
+//导出接口,如果选中多个文件,导出压缩包
+$('#export-confirm').click(async function () {
+    let checkedDatas = $('#export input[type="checkbox"]:checked');
+    if (!checkedDatas.length) {
+        return;
+    }
+    $('#export').modal('hide');
+    let pr = new SCComponent.InitProgressBar($('#progress'), $('#progress-title'), $('#progress-content'), $('#progressBar'));
+    pr.start('导出数据接口', '正在导出文件,请稍候……');
+    let xmlObj = new XMLStandard(userID, 1),
+        exportData = [],
+        fileKindMap = {
+            1: '投标',
+            2: '招标',
+            3: '控制价'
+        };
+    try {
+        for (let checkedData of checkedDatas) {
+            let fileKind = $(checkedData).val();
+            exportData.push({
+                blob: await xmlObj.toXml(projectObj.project.ID(), fileKind),
+                fileName: `重庆标准交换数据(${fileKindMap[fileKind]}).QTF`
+            });
+        }
+        if (exportData.length === 1) {  //导出文件
+            saveAs(exportData[0].blob, exportData[0].fileName);
+        } else if (exportData.length > 1) { //导出压缩包
+            let zip = new JSZip();
+            for (let expr of exportData) {
+                zip.file(expr.fileName, expr.blob, {binary: true});
+            }
+            let zipFile = await zip.generateAsync({type: 'blob'});
+            saveAs(zipFile, '重庆标准交换数据.zip');
+        }
+    } catch (err) {
+        alert(err);
+    }
+    console.log(xmlObj);
+    xmlObj = null;
+    pr.end();
+});