Browse Source

1.单价文件费率文件加入侧滑
2.工料机页面加入当前使用工料机信息

olym 7 years ago
parent
commit
38a2cf90f2

+ 18 - 12
modules/glj/controllers/glj_controller.js

@@ -9,9 +9,9 @@ import BaseController from "../../common/base/base_controller";
 import GLJTypeConst from "../../common/const/glj_type_const";
 import GLJTypeConst from "../../common/const/glj_type_const";
 import GLJListModel from "../models/glj_list_model";
 import GLJListModel from "../models/glj_list_model";
 import UnitPriceModel from "../models/unit_price_model";
 import UnitPriceModel from "../models/unit_price_model";
-import UnitPriceFileModel from "../models/unit_price_file_model";
 import MixRatioModel from "../models/mix_ratio_model";
 import MixRatioModel from "../models/mix_ratio_model";
 
 
+const ProjectModel = require('../../pm/models/project_model').project;
 class GLJController extends BaseController {
 class GLJController extends BaseController {
 
 
     /**
     /**
@@ -46,13 +46,21 @@ class GLJController extends BaseController {
             }
             }
 
 
             // 获取标段对应的单价文件id
             // 获取标段对应的单价文件id
-            let unitPriceFileModel = new UnitPriceFileModel();
-            let unitPriceFile = await unitPriceFileModel.getDataByProject(projectId);
-            if (!unitPriceFile) {
+            let unitPriceFileId = await ProjectModel.getUnitPriceFileId(projectId);
+            if (unitPriceFileId <= 0) {
                 throw '没有对应的单价文件';
                 throw '没有对应的单价文件';
             }
             }
-            // 单价文件id作为同步的roomId
-            let unitPriceFileId = unitPriceFile.id;
+
+            // 获取使用该单价文件的项目数据
+            let tenderData = await ProjectModel.getTenderByUnitPriceFileId(unitPriceFileId);
+            let usedTenderList = [];
+            let usedUnitPriceName = '';
+            if (tenderData !== null) {
+                for (let tmp of tenderData) {
+                    usedTenderList.push(tmp.name);
+                    usedUnitPriceName = tmp.property.unitPriceFile.name;
+                }
+            }
 
 
             // 先获取对应标段的项目工料机数据
             // 先获取对应标段的项目工料机数据
             let gljListModel = new GLJListModel();
             let gljListModel = new GLJListModel();
@@ -60,12 +68,14 @@ class GLJController extends BaseController {
 
 
             responseData.data.gljList = gljList;
             responseData.data.gljList = gljList;
             responseData.data.mixRatioConnectData = mixRatioConnectData;
             responseData.data.mixRatioConnectData = mixRatioConnectData;
+            responseData.data.usedTenderList = usedTenderList;
             responseData.data.constData = {
             responseData.data.constData = {
                 materialIdList: gljListModel.materialIdList,
                 materialIdList: gljListModel.materialIdList,
                 ownCompositionTypes: gljListModel.ownCompositionTypes,
                 ownCompositionTypes: gljListModel.ownCompositionTypes,
                 hostname: request.hostname,
                 hostname: request.hostname,
                 roomId: unitPriceFileId,
                 roomId: unitPriceFileId,
                 GLJTypeConst: JSON.stringify(GLJTypeConst),
                 GLJTypeConst: JSON.stringify(GLJTypeConst),
+                usedUnitPriceName: usedUnitPriceName
             };
             };
         } catch (error) {
         } catch (error) {
             responseData.err = 1;
             responseData.err = 1;
@@ -180,15 +190,11 @@ class GLJController extends BaseController {
         };
         };
         try {
         try {
             // 获取标段对应的单价文件id
             // 获取标段对应的单价文件id
-            let unitPriceFileModel = new UnitPriceFileModel();
-            let unitPriceFile = await unitPriceFileModel.getDataByProject(projectId);
-            if (!unitPriceFile) {
+            let unitPriceFileId = await ProjectModel.getUnitPriceFileId(projectId);
+            if (unitPriceFileId <= 0) {
                 throw '没有对应的单价文件';
                 throw '没有对应的单价文件';
             }
             }
 
 
-            // 单价文件id作为同步的roomId
-            let unitPriceFileId = unitPriceFile.id;
-
             let gljListModel = new GLJListModel();
             let gljListModel = new GLJListModel();
             let result = await gljListModel.getCompositionList(projectGLJId, unitPriceFileId);
             let result = await gljListModel.getCompositionList(projectGLJId, unitPriceFileId);
             if (result.length <= 0) {
             if (result.length <= 0) {

+ 1 - 1
modules/pm/controllers/pm_controller.js

@@ -149,7 +149,7 @@ module.exports = {
             // 获取对应的单价文件
             // 获取对应的单价文件
             let unitPriceFileModel = new UnitPriceFileModel();
             let unitPriceFileModel = new UnitPriceFileModel();
             let unitPriceFileData = await unitPriceFileModel.getDataByTenderId(idList);
             let unitPriceFileData = await unitPriceFileModel.getDataByTenderId(idList);
-            console.log(unitPriceFileData);
+
             if (unitPriceFileData === null) {
             if (unitPriceFileData === null) {
                 throw {msg: '不存在对应单价文件', err: 0};
                 throw {msg: '不存在对应单价文件', err: 0};
             }
             }

+ 54 - 14
modules/pm/models/project_model.js

@@ -65,6 +65,23 @@ ProjectsDAO.prototype.updateUserProjects = async function(userId, datas, callbac
             } else if (data.updateType === 'new') {
             } else if (data.updateType === 'new') {
                 data.updateData['userID'] = userId;
                 data.updateData['userID'] = userId;
                 data.updateData['createDateTime'] = new Date();
                 data.updateData['createDateTime'] = new Date();
+                // 如果没有选中单价文件则新增单价文件
+                if (data.updateData.projType === projectType.tender && data.updateData.property !== null &&
+                    Object.keys(data.updateData.property.unitPriceFile).length > 0 &&
+                    data.updateData.property.unitPriceFile.id === '') {
+                    let unitPriceFileModel = new UnitPriceFileModel();
+
+                    let insertData = {
+                        name: data.updateData.name,
+                        project_id: data.updateData.ID
+                    };
+                    let addResult = await unitPriceFileModel.add(insertData);
+                    if (!addResult) {
+                        callback(1, '新增单价文件失败.', null);
+                        return;
+                    }
+                    data.updateData.property.unitPriceFile.id = addResult.id + '';
+                }
                 newProject = new Projects(data.updateData);
                 newProject = new Projects(data.updateData);
                 // 查找同级是否存在同名数据
                 // 查找同级是否存在同名数据
                 let exist = await this.isExist(data.updateData.name, data.updateData.ParentID);
                 let exist = await this.isExist(data.updateData.name, data.updateData.ParentID);
@@ -77,20 +94,6 @@ ProjectsDAO.prototype.updateUserProjects = async function(userId, datas, callbac
                 newProject.save(async function (err, result) {
                 newProject.save(async function (err, result) {
                     if (!err && result._doc.projType === projectType.tender) {
                     if (!err && result._doc.projType === projectType.tender) {
                         newProjController.copyTemplateData(data.updateData.property, newProject.ID, updateAll);
                         newProjController.copyTemplateData(data.updateData.property, newProject.ID, updateAll);
-                        // 如果没有选中单价文件则新增单价文件
-                        if (data.updateData.property !== null && data.updateData.property.unitPriceFile === '') {
-                            let unitPriceFileModel = new UnitPriceFileModel();
-                            let insertData = {
-                                name: data.updateData.name,
-                                project_id: data.updateData.ID
-                            };
-                            let addResult = await unitPriceFileModel.add(insertData);
-                            if (!addResult) {
-                                callback(1, '新增单价文件失败.', null);
-                                return;
-                            }
-                        }
-
                     } else {
                     } else {
                         updateAll(err);
                         updateAll(err);
                     }
                     }
@@ -257,6 +260,43 @@ ProjectsDAO.prototype.getTenderByProjectId = async function(projectId) {
     return result;
     return result;
 };
 };
 
 
+/**
+ * 根据单价文件id获取对应的标段数据
+ *
+ * @param {Number} unitPriceFileId
+ * @return {Promise}
+ */
+ProjectsDAO.prototype.getTenderByUnitPriceFileId = async function(unitPriceFileId) {
+    let result = [];
+
+    unitPriceFileId = parseInt(unitPriceFileId);
+    if (isNaN(unitPriceFileId) && unitPriceFileId <= 0) {
+        return result;
+    }
+
+    let condition = {projType: 'Tender', "property.unitPriceFile.id": unitPriceFileId + ''};
+    result = await Projects.find(condition);
+
+    return result;
+};
+
+/**
+ * 根据项目id获取单价文件列表id
+ *
+ * @param {Number} projectId
+ * @return {Promise}
+ */
+ProjectsDAO.prototype.getUnitPriceFileId = async function(projectId) {
+    let result = 0;
+    let projectData = await Projects.findOne({ID: projectId});
+    if (projectData === null) {
+        return result;
+    }
+
+    result = projectData.property.unitPriceFile.id;
+    return result;
+};
+
 module.exports ={
 module.exports ={
     project: new ProjectsDAO(),
     project: new ProjectsDAO(),
     projType: projectType
     projType: projectType

+ 4 - 6
web/building_saas/glj/html/glj_index.html

@@ -1,10 +1,8 @@
 <div class="toolsbar px-1">
 <div class="toolsbar px-1">
-    <div class="tools-btn btn-group align-top">
-        <a href="" class="btn btn-sm"><i class="fa fa-arrow-down" aria-hidden="true"></i>下移</a>
-        <a href="" class="btn btn-sm"><i class="fa fa-arrow-up" aria-hidden="true"></i>上移</a>
-        <a href="" class="btn btn-sm"><i class="fa fa-arrow-left" aria-hidden="true"></i></a>
-        <a href="" class="btn btn-sm"><i class="fa fa-arrow-right" aria-hidden="true"></i></a>
-        <a href="" class="btn btn-sm"><i class="fa fa-undo" aria-hidden="true"></i></a>
+    <div class="form-inline py-1">
+        <label class="mx-2">当前使用:<span id="used-name"></span>(<a href="#" id="pop-dj" data-original-title="" title=""><span id="used-count">0</span> 单位工程使用</a>)
+            <a class="btn btn-sm ml-1" href="#" data-toggle="modal" data-target="#change-dj"><i class="fa fa-exchange"></i> 选择其他</a>
+            <a class="btn btn-sm ml-1" href="#" data-toggle="modal" data-target="#copy-dj"><i class="fa fa-files-o"></i> 另存单独用</a></label>
     </div>
     </div>
 </div>
 </div>
 <div class="container-fluid">
 <div class="container-fluid">

+ 25 - 0
web/building_saas/glj/js/project_glj.js

@@ -76,10 +76,15 @@ function init() {
                 data.constData.ownCompositionTypes : canNotChangeTypeId;
                 data.constData.ownCompositionTypes : canNotChangeTypeId;
             GLJTypeConst = data.constData.GLJTypeConst !== undefined ? JSON.parse(data.constData.GLJTypeConst) : GLJTypeConst;
             GLJTypeConst = data.constData.GLJTypeConst !== undefined ? JSON.parse(data.constData.GLJTypeConst) : GLJTypeConst;
 
 
+            let usedTenderList = data.usedTenderList !== undefined ? data.usedTenderList : [];
+            let usedUnitFileName = data.constData.usedUnitPriceName !== undefined ?
+                data.constData.usedUnitPriceName : '';
             // 存入缓存
             // 存入缓存
             projectObj.project.projectGLJ.datas = jsonData;
             projectObj.project.projectGLJ.datas = jsonData;
             console.log(projectObj.project);
             console.log(projectObj.project);
+
             spreadInit();
             spreadInit();
+            unitPriceFileInit(usedUnitFileName, usedTenderList);
         }
         }
     });
     });
 
 
@@ -126,6 +131,26 @@ function spreadInit() {
 }
 }
 
 
 /**
 /**
+ * 单价文件相关初始化
+ *
+ * @param {String} name
+ * @param {Array} data
+ * @return {void}
+ */
+function unitPriceFileInit(name, data) {
+    $("#used-name").text(name);
+    let usedCount = data.length <= 0 ? 1 : data.length;
+    $("#used-count").text(usedCount);
+    $('#pop-dj').popover({
+            placement:"bottom",
+            html:true,
+            trigger:"hover | focus",
+            content: data.join('<br>')
+        }
+    );
+}
+
+/**
  * 成功事件
  * 成功事件
  *
  *
  * @param {string} field
  * @param {string} field

+ 2 - 2
web/building_saas/pm/html/project-management.html

@@ -183,7 +183,7 @@
                 <div class="row">
                 <div class="row">
                     <div class="col-md-6">
                     <div class="col-md-6">
                         <legend>单价文件</legend>
                         <legend>单价文件</legend>
-                        <table class="table table-bordered table-hover table-sm">
+                        <table class="table table-bordered table-hover table-sm" id="summary-project-unit-price-table">
                             <thead><th></th><th>名称</th></thead>
                             <thead><th></th><th>名称</th></thead>
                             <tbody>
                             <tbody>
                             <tr><td>1</td><td>A单价文件</td></tr>
                             <tr><td>1</td><td>A单价文件</td></tr>
@@ -194,7 +194,7 @@
                     </div>
                     </div>
                     <div class="col-md-6">
                     <div class="col-md-6">
                         <legend>费率文件</legend>
                         <legend>费率文件</legend>
-                        <table class="table table-bordered table-hover table-sm">
+                        <table class="table table-bordered table-hover table-sm" id="summary-project-fee-table">
                             <thead><th></th><th>名称</th></thead>
                             <thead><th></th><th>名称</th></thead>
                             <tbody>
                             <tbody>
                             <tr><td>1</td><td>A费率文件</td></tr>
                             <tr><td>1</td><td>A费率文件</td></tr>

+ 51 - 4
web/building_saas/pm/js/pm_main.js

@@ -720,11 +720,13 @@ function AddTender() {
         }
         }
 
 
         let unitPriceFile = $("#unit-price").val();
         let unitPriceFile = $("#unit-price").val();
+        let unitPriceName = unitPriceFile !== '' ? $("#unit-price").children("option:selected").text() : name;
 
 
         let feeFile = $("#tender-fee-rate").val();
         let feeFile = $("#tender-fee-rate").val();
         if (feeFile === '') {
         if (feeFile === '') {
             throw '请选择费率文件';
             throw '请选择费率文件';
         }
         }
+        let feeFileName = $("#tender-fee-rate").children("option:selected").text();
 
 
         let valuation = $("#tender-valuation").val();
         let valuation = $("#tender-valuation").val();
         let valuationName = $("#tender-valuation").children("option:selected").text();
         let valuationName = $("#tender-valuation").children("option:selected").text();
@@ -762,8 +764,8 @@ function AddTender() {
             engineering: engineering,
             engineering: engineering,
             engineering_id: engineering_id,
             engineering_id: engineering_id,
             engineeringName: engineeringName,
             engineeringName: engineeringName,
-            unitPriceFile: unitPriceFile,
-            feeFile: feeFile
+            unitPriceFile: {name: unitPriceName, id: unitPriceFile},
+            feeFile: {name: feeFileName, id: feeFile}
         };
         };
         // 如果选择的是单项工程则新增同级数据
         // 如果选择的是单项工程则新增同级数据
         if (selectedItem !== null && selectedItem.data.projType === projectType.tender) {
         if (selectedItem !== null && selectedItem.data.projType === projectType.tender) {
@@ -822,7 +824,7 @@ function GetUpdateData(parent, next, name, property, newId, type) {
     let updateData = {};
     let updateData = {};
     let rootProject = parent ? parent.parent : Tree._root;
     let rootProject = parent ? parent.parent : Tree._root;
     let rootProjectID = rootProject ? rootProject.id() : -1;
     let rootProjectID = rootProject ? rootProject.id() : -1;
-    property.rootProjectID=rootProjectID;
+
     updateData['updateType'] = type.updateType === undefined ? 'new' : type.updateType;
     updateData['updateType'] = type.updateType === undefined ? 'new' : type.updateType;
     updateData['updateData'] = {};
     updateData['updateData'] = {};
     if (newId !== '') {
     if (newId !== '') {
@@ -833,7 +835,8 @@ function GetUpdateData(parent, next, name, property, newId, type) {
     if (name !== '') {
     if (name !== '') {
         updateData['updateData']['name'] = name;
         updateData['updateData']['name'] = name;
     }
     }
-    if (property !== undefined) {
+    if (property !== null && property !== undefined) {
+        property.rootProjectID = rootProjectID;
         updateData['updateData']['property'] = property;
         updateData['updateData']['property'] = property;
     }
     }
     if (type !== null && type.projectType !== null) {
     if (type !== null && type.projectType !== null) {
@@ -1092,6 +1095,7 @@ function getUnitFile(parentID) {
                 for(let tmp of response.data) {
                 for(let tmp of response.data) {
                     unitFileHtml += '<option value="'+ tmp.id +'">'+ tmp.name +'</option>';
                     unitFileHtml += '<option value="'+ tmp.id +'">'+ tmp.name +'</option>';
                 }
                 }
+                $("#unit-price").children("option:not(':first')").remove();
                 $("#unit-price").children("option").first().after(unitFileHtml);
                 $("#unit-price").children("option").first().after(unitFileHtml);
             }
             }
         }
         }
@@ -1142,4 +1146,47 @@ function setDataToSideBar() {
         '</tr>';
         '</tr>';
     $(target + '-table tbody').html(html);
     $(target + '-table tbody').html(html);
 
 
+    // 加载单价文件与费率文件
+    if (selectedItem.data.projType === projectType.project) {
+        let engineeringData = selectedItem.children !== null && selectedItem.children.children !== null ?
+            selectedItem.children : [];
+        if (engineeringData.length <= 0) {
+            return;
+        }
+        let unitPriceFileHtml = '';
+        let feeFileHtml = '';
+        let unitPriceFileCounter = 1;
+        let feeFileCounter = 1;
+        let unitPriceFileList = [];
+        let feeFileList = [];
+        for(let engineering of engineeringData) {
+            let tenderData = engineering.children !== null ? engineering.children : [];
+            if (tenderData.length <= 0) {
+                continue;
+            }
+            for(let tmp of tenderData) {
+                tmp = tmp.data.property !== null ? tmp.data.property : null;
+                if(tmp === null) {
+                    continue;
+                }
+
+                if (tmp.feeFile !== undefined && feeFileList.indexOf(tmp.feeFile.name) < 0) {
+                    feeFileHtml += '<tr><td>'+ unitPriceFileCounter +'</td><td>'+ tmp.feeFile.name +'</td></tr>';
+                    feeFileCounter++;
+                    feeFileList.push(tmp.feeFile.name);
+                }
+
+                if (tmp.unitPriceFile !== undefined && unitPriceFileList.indexOf(tmp.unitPriceFile.name) < 0) {
+                    unitPriceFileHtml += '<tr><td>'+ unitPriceFileCounter +'</td><td>'+ tmp.unitPriceFile.name +'单价文件</td></tr>';
+                    unitPriceFileCounter++;
+                    unitPriceFileList.push(tmp.unitPriceFile.name);
+                }
+            }
+
+            $(target + '-unit-price-table tbody').html(unitPriceFileHtml);
+            $(target + '-fee-table tbody').html(feeFileHtml);
+        }
+
+    }
+
 }
 }