فهرست منبع

Merge branch 'master' of http://smartcost.f3322.net:3000/SmartCost/ConstructionOperation

TonyKang 7 سال پیش
والد
کامیت
04ada6da19

+ 2 - 2
modules/ration_repository/controllers/ration_repository_controller.js

@@ -150,7 +150,7 @@ class RationRepositoryController extends baseController {
         const allowHeader = ['application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'];
         try {
             const uploadOption = {
-                uploadDir: './public/tmp'
+                uploadDir: './public'
             };
             const form = new multiparty.Form(uploadOption);
             form.parse(request, async function(err, fields, files) {
@@ -215,7 +215,7 @@ class RationRepositoryController extends baseController {
             }
             const excelData = await rationItem.exportExcelData(rationRepId);
             const buffer = excel.build([{name: "sheet", data: excelData}]);
-            const filePath = './public/tmp/export.xlsx';
+            const filePath = './public/export.xlsx';
             fs.writeFileSync(filePath, buffer, 'binary');
             const stats = fs.statSync(filePath);
             // 下载相关header

+ 11 - 6
modules/ration_repository/models/ration_item.js

@@ -501,7 +501,7 @@ rationItemDAO.prototype.getRationItemByCondition = async function (condition, fi
     if (Object.keys(condition).length <= 0) {
         return result;
     }
-    result = await rationItemModel.find(condition, fields);
+    result = await rationItemModel.find(condition, fields).sort({code: 1});
     if (indexBy !== null && result.length > 0) {
         let tmpResult = {};
         for(let tmp of result) {
@@ -634,13 +634,14 @@ rationItemDAO.prototype.exportExcelData = async function(rationRepId) {
     };
     // @todo 限制导出的数量以防内存溢出
     const rationDataList = await this.getRationItemByCondition(condition, ['name', 'code', 'ID']);
+
     // 整理数据
     let rationData = [];
     for (const tmp of rationDataList) {
-        const ration = [null, tmp.ID, tmp.code, tmp.name];
+        const ration = [null, null, tmp.ID, tmp.code, tmp.name];
         rationData.push(ration);
     }
-    const excelData = [['树ID', '定额ID', '定额编码', '定额名']];
+    const excelData = [['树ID', '取费专业', '定额ID', '定额编码', '定额名']];
     excelData.push.apply(excelData, rationData);
 
     return excelData;
@@ -659,14 +660,18 @@ rationItemDAO.prototype.batchUpdateSectionIdFromExcel = async function(data) {
     // 批量执行update
     const bulk = rationItemModel.collection.initializeOrderedBulkOp();
     for (const tmp of data) {
-        let rationId = parseInt(tmp[1]);
+        let rationId = parseInt(tmp[2]);
         rationId = isNaN(rationId) || rationId <= 0 ? 0 : rationId;
         let sectionId = parseInt(tmp[0]);
         sectionId = isNaN(sectionId) || sectionId <= 0 ? 0 : sectionId;
-        if (sectionId <= 0 || rationId <= 0) {
+        // 取费专业
+        let feeType = parseInt(tmp[1]);
+        feeType = isNaN(feeType) || feeType <= 0 ? 0 : feeType;
+        if (sectionId <= 0 || rationId <= 0 || feeType <= 0) {
             continue;
         }
-        bulk.find({"ID": rationId}).update({$set: { sectionId: sectionId }});
+
+        bulk.find({"ID": rationId}).update({$set: { sectionId: sectionId, feeType: feeType }});
     }
 
     const result = await bulk.execute();

+ 21 - 23
web/maintain/ration_repository/main.html

@@ -155,33 +155,31 @@
     </div>
     <!--弹出导入原始数据-->
     <div class="modal fade" id="import" data-backdrop="static" style="display: none;" aria-hidden="true">
-        <form action="/rationRepository/api/upload" enctype="multipart/form-data" method="post">
-            <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">×</span>
-                        </button>
+        <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">×</span>
+                    </button>
+                </div>
+                <div class="modal-body">
+                    <div class="alert alert-warning" role="alert">
+                        导入操作会覆盖数据,请谨慎操作!!
                     </div>
-                    <div class="modal-body">
-                        <div class="alert alert-warning" role="alert">
-                            导入操作会覆盖数据,请谨慎操作!!
+                    <form>
+                        <div class="form-group">
+                            <label>请选择Excel格式文件</label>
+                            <input class="form-control-file" type="file" name="source_file">
                         </div>
-                        <form>
-                            <div class="form-group">
-                                <label>请选择Excel格式文件</label>
-                                <input class="form-control-file" type="file" name="source_file">
-                            </div>
-                        </form>
-                    </div>
-                    <div class="modal-footer">
-                        <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
-                        <button type="button" class="btn btn-primary" id="source-import">确定导入</button>
-                    </div>
+                    </form>
+                </div>
+                <div class="modal-footer">
+                    <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
+                    <button type="button" class="btn btn-primary" id="source-import">确定导入</button>
                 </div>
             </div>
-        </form>
+        </div>
     </div>
 
     <!--弹出导入内部数据-->

+ 3 - 2
web/maintain/std_glj_lib/js/components.js

@@ -71,13 +71,14 @@ let componentOprObj = {
         }
     },
     setShowGljList: function (gljList, clearChecked) {
-        //初始为所有工料机,机械类型可添加机械组成物、机上人工,混凝土,砂浆、配合比可添加普通材料
+        //初始为所有工料机,机械类型可添加机械组成物、机上人工,混凝土,砂浆、配合比可添加普通材料, 主材只能添加没有组成物的主材
         let machineArr = [302, 303];
         let materialArr = [202, 203, 204];//混凝土、砂浆、配合比, 201普通材料
         let that = repositoryGljObj, me = componentOprObj;
         for(let i = 0; i < gljList.length; i++){
             if(that.currentGlj.gljType === 301 && machineArr.indexOf(gljList[i].gljType) !== -1 ||
-                materialArr.indexOf(that.currentGlj.gljType) !== -1 && gljList[i].gljType === 201){
+                materialArr.indexOf(that.currentGlj.gljType) !== -1 && gljList[i].gljType === 201||
+                that.currentGlj.gljType === 4 && gljList[i].gljType === 4 && (!gljList[i].component || gljList[i].component.length === 0) && gljList[i].ID !== that.currentGlj.ID){
                 let isExist = false;
                 for(let j = 0; j < that.currentComponent.length; j++){
                     if(that.currentComponent[j].ID === gljList[i].ID){

+ 22 - 11
web/maintain/std_glj_lib/js/glj.js

@@ -36,20 +36,11 @@ let repositoryGljObj = {
     currentCache: null,
     parentNodeIds: {},
     gljList: [],
-    allowComponent: [202, 203, 204, 301],//可带组成物类型:混凝土、砂浆、配合比、机械台班
-    componentGljType: [201, 302, 303],//可成为组成物的工料机类型: 普通材料、 机械组成物、 机上人工
+    allowComponent: [202, 203, 204, 301, 4],//可带组成物类型:混凝土、砂浆、配合比、机械台班
+    componentGljType: [201, 302, 303, 4],//可成为组成物的工料机类型: 普通材料、 机械组成物、 机上人工
     distTypeTree: null,//add
     setting: {
         owner: "glj",
-        /*header:[
-            {headerName:"编码",headerWidth:120,dataCode:"code", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"},
-            {headerName:"名称",headerWidth:260,dataCode:"name", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"},
-            {headerName:"规格型号",headerWidth:220,dataCode:"specs", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"},
-            {headerName:"单位",headerWidth:120,dataCode:"unit", dataType: "String", hAlign: "center", vAlign: "center"},
-            {headerName:"基价单价",headerWidth:120,dataCode:"basePrice", dataType: "Number", formatter: "0.00", hAlign: "right", vAlign: "center"},
-            {headerName:"类型",headerWidth:120,dataCode:"gljType", dataType: "String", hAlign: "center", vAlign: "center"},
-            {headerName:"调整系数",headerWidth:80,dataCode:"adjCoe", dataType: "Number", hAlign: "center", vAlign: "center"},
-        ],*/
         header:[
             {headerName:"编码",headerWidth:80,dataCode:"code", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"},
             {headerName:"名称",headerWidth:160,dataCode:"name", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"},
@@ -213,6 +204,26 @@ let repositoryGljObj = {
         me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.LeaveCell, me.onLeaveCell);
         me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.SelectionChanged, me.onSelectionChanged);
     },
+
+    isDef: function (v) {
+        return v !== undefined && v !== null;
+    },
+
+    //成为了组成物,暂时只需要判断主材的
+    isComponent: function (gljId, gljList) {
+        for(let i = 0, len = gljList.length; i < len; i++){
+            let gljComponent = gljList[i].component;
+            if(gljList[i].gljType === 4 && this.isDef(gljComponent) && gljComponent.length > 0){
+                for(let j = 0, jLen = gljComponent.length; j < jLen; j++){
+                    if(gljComponent[j].ID === gljId){
+                        return true;
+                    }
+                }
+            }
+        }
+        return false;
+    },
+
     getCurrentComponent: function (gljComponent) {
         let me = repositoryGljObj, rst = [];
         for(let i = 0; i < gljComponent.length; i++){

+ 8 - 4
web/maintain/std_glj_lib/js/gljComponent.js

@@ -156,7 +156,7 @@ let gljComponentOprObj = {
                     //控制按钮是否可用
                     let insertDis = false,
                         delDis = false;
-                    if(!(that.currentGlj && that.allowComponent.indexOf(that.currentGlj.gljType) !== -1)){
+                    if(!(that.currentGlj && that.allowComponent.indexOf(that.currentGlj.gljType) !== -1) || (that.currentGlj.gljType === 4 && that.isComponent(that.currentGlj.ID, that.gljList))){
                         insertDis = true;
                     }
                     if(!that.currentGlj || typeof that.currentComponent === 'undefined' || (typeof that.currentComponent !== 'undefined' && target.row >= that.currentComponent.length)){//右键定位在有组成物的行,删除键才显示可用
@@ -219,6 +219,7 @@ let gljComponentOprObj = {
         if(thatRow < that.currentCache.length){
             that.currentGlj = that.currentCache[thatRow];
             if(me.setting.view.lockedCols.indexOf(args.col) !== -1 || that.allowComponent.indexOf(that.currentGlj.gljType) === -1 ||
+                (that.currentGlj.gljType === 4 && that.isComponent(that.currentGlj.ID, that.gljList)) ||
                 (args.col === 4 && (!that.currentComponent|| args.row >= that.currentComponent.length))){
                 args.cancel = true;
             }
@@ -237,7 +238,8 @@ let gljComponentOprObj = {
                 if(gljList[i].code === args.editingText){//有效的组成物
                     hasCode = true;
                     if((materialComponent.indexOf(that.currentGlj.gljType) !== -1 && gljList[i].gljType === 201)
-                        || (that.currentGlj.gljType === 301 && machineComponent.indexOf(gljList[i].gljType) !== -1 )){//普通材料
+                        || (that.currentGlj.gljType === 301 && machineComponent.indexOf(gljList[i].gljType) !== -1 )
+                        || (that.currentGlj.gljType === 4 && gljList[i].gljType === 4 && that.currentGlj.ID !== gljList[i].ID)){//普通材料
                         //是否与原有组成物不同
                         let isExist = false;
                         for(let j = 0; j < component.length; j++){
@@ -355,9 +357,10 @@ let gljComponentOprObj = {
     },
     onClipboardPasting: function (sender, info) {
         let me = gljComponentOprObj;
+        let that = repositoryGljObj;
         let maxCol = info.cellRange.col + info.cellRange.colCount - 1;
         //复制的列数超过正确的列数,不可复制
-        if(info.cellRange.col !== 0 && info.cellRange.col !== 4 || info.cellRange.colCount > 1){
+        if(info.cellRange.col !== 0 && info.cellRange.col !== 4 || info.cellRange.colCount > 1 || (that.currentGlj.gljType === 4 && that.isComponent(that.currentGlj.ID, that.gljList))){
             args.cancel = true;
         }
     },
@@ -371,7 +374,8 @@ let gljComponentOprObj = {
                 for(let j = 0; j < gljCache.length; j++){
                     if(items[i].code === gljCache[j].code){
                         if((materialComponent.indexOf(that.currentGlj.gljType) !== -1 && gljCache[j].gljType === 201)
-                            || (that.currentGlj.gljType === 301 && machineComponent.indexOf(gljCache[j].gljType) !== -1 )){
+                            || (that.currentGlj.gljType === 301 && machineComponent.indexOf(gljCache[j].gljType) !== -1 )
+                            || (that.currentGlj.gljType === 4 && gljCache[i].gljType === 4 && that.currentGlj.ID !== gljCache[i].ID)){
                             //是否与原有组成物不同
                             let isExist = false;
                             for(let k = 0; k < component.length; k++){