ソースを参照

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

TonyKang 7 年 前
コミット
879a5b697d

+ 9 - 0
modules/ration_repository/controllers/ration_controller.js

@@ -79,6 +79,15 @@ class RationController extends BaseController{
             }
         })
     }
+
+    updateJobContent(req, res){
+        let repId = req.body.repId,
+            updateArr = JSON.parse(req.body.updateArr),
+            lastOpr = req.body.lastOpr;
+        rationItem.updateJobContent(lastOpr, repId, updateArr, function (err) {
+            callback(req, res, err, '', null);
+        });
+    }
 }
 
 export default RationController;

+ 10 - 0
modules/ration_repository/controllers/ration_section_tree_controller.js

@@ -69,6 +69,16 @@ class RationChapterTreeController extends BaseController{
         });
 
     }
+    updateSituation(req, res){
+        let repId = req.body.repId,
+            nodeId = req.body.nodeId,
+            situation = req.body.situation,
+            lastOpr = req.body.lastOpr;
+        rationChapterTreeData.updateSituation(lastOpr, repId, nodeId, situation, function (err) {
+            callback(req, res, err, '', null);
+        });
+
+    }
 }
 
 export default RationChapterTreeController;

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

@@ -381,5 +381,27 @@ rationItemDAO.prototype.getRationsCodes = function (data, callback) {
     })
 };
 
+rationItemDAO.prototype.updateJobContent = function (lastOpr, repId, updateArr, callback) {
+    rationRepositoryDao.updateOprArr({ID: repId}, lastOpr, moment(Date.now()).format('YYYY-MM-DD HH:mm:ss'), function (err) {
+        async.each(updateArr, function (obj, cb) {
+            rationItemModel.update({rationRepId: repId, code: obj.code}, {$set: {jobContent: obj.jobContent}}, function (err) {
+                if(err){
+                    cb(err);
+                }
+                else{
+                    cb(null);
+                }
+            })
+        }, function (err) {
+            if(err){
+                callback(err);
+            }
+            else{
+                callback(null);
+            }
+        });
+    });
+}
+
 module.exports = new rationItemDAO()
 

+ 12 - 0
modules/ration_repository/models/ration_section_tree.js

@@ -127,6 +127,18 @@ rationChapterTreeDAO.prototype.updateRuleText = function (lastOpr, repId, nodeId
         }
     });
 };
+rationChapterTreeDAO.prototype.updateSituation = function (lastOpr, repId, nodeId, situation, callback) {
+    rationChapterTreeModel.update({rationRepId: repId, ID: nodeId}, {$set: {jobContentSituation: situation}}, function (err, result) {
+        if(err){
+            callback(err);
+        }
+        else{
+            rationRepositoryDao.updateOprArr({ID: repId}, lastOpr, moment(Date.now()).format('YYYY-MM-DD HH:mm:ss'), function (err) {
+                callback(null);
+            });
+        }
+    });
+};
 
 rationChapterTreeDAO.prototype.updateNodes = function(repId, lastOpr, nodes,callback){
     var functions = [];

+ 2 - 0
modules/ration_repository/models/schemas.js

@@ -55,6 +55,7 @@ let rationChapterTreeSchema = new Schema({
     name: String,
     explanation: String,//说明
     ruleText: String,//计算规则
+    jobContentSituation: String,//工作内容适用情况,ALL适用本项全部定额,PARTIAL适用本项部分定额
     isDeleted: Boolean
 });
 
@@ -92,6 +93,7 @@ var rationItemSchema = new Schema({
     rationRepId: Number,
     caption: String,
     feeType: Number,
+    jobContent: String,
     rationGljList: [rationGljItemSchema],
     rationCoeList: Array,
     rationAssList: [rationAssItemSchema],

+ 2 - 0
modules/ration_repository/routes/ration_rep_routes.js

@@ -41,12 +41,14 @@ module.exports =  function (app) {
     apiRouter.post("/deleteNodes",rationChapterTreeController.auth, rationChapterTreeController.init, rationChapterTreeController.deleteNodes);
     apiRouter.post("/updateExplanation",rationChapterTreeController.auth, rationChapterTreeController.init, rationChapterTreeController.updateExplanation);
     apiRouter.post("/updateRuleText",rationChapterTreeController.auth, rationChapterTreeController.init, rationChapterTreeController.updateRuleText);
+    apiRouter.post("/updateSituation",rationChapterTreeController.auth, rationChapterTreeController.init, rationChapterTreeController.updateSituation);
 
     apiRouter.post("/getRationItems",rationController.auth, rationController.init, rationController.getRationItemsBySection);
     apiRouter.post("/mixUpdateRationItems",rationController.auth, rationController.init, rationController.mixUpdateRationItems);
     apiRouter.post("/updateRationBasePrc",rationController.auth, rationController.init, rationController.updateRationBasePrc);
     apiRouter.post("/getRationGljIds",rationController.auth, rationController.init, rationController.getRationGljIds);
     apiRouter.post("/getRationsCodes",rationController.auth, rationController.init, rationController.getRationsCodes);
+    apiRouter.post("/updateJobContent",rationController.auth, rationController.init, rationController.updateJobContent);
 
     apiRouter.post("/createNewGljTypeNode",repositoryGljController.auth, repositoryGljController.init, repositoryGljController.createNewGljTypeNode);
     apiRouter.post("/updateGljNodes",repositoryGljController.auth, repositoryGljController.init, repositoryGljController.updateGljNodes);

+ 21 - 4
public/web/sheet/sheet_common.js

@@ -9,8 +9,9 @@ var sheetCommonObj = {
         var spreadBook = new GC.Spread.Sheets.Workbook(container, { sheetCount: SheetCount });
         spreadBook.options.allowCopyPasteExcelStyle = false;
         spreadBook.options.tabStripVisible = false;
-        spreadBook.options.showHorizontalScrollbar = false;
+        //spreadBook.options.showHorizontalScrollbar = false;
         spreadBook.options.allowUserDragDrop = false;
+        spreadBook.options.scrollbarMaxAlign = true;
         return spreadBook;
     },
 
@@ -23,6 +24,10 @@ var sheetCommonObj = {
         sheet.setColumnCount(setting.header.length, spreadNS.SheetArea.viewport);
         sheet.options.colHeaderAutoTextIndex = 1;
         sheet.options.colHeaderAutoText = spreadNS.HeaderAutoText.numbers;
+        sheet.options.protectionOptions = {
+            allowResizeRows: true,
+            allowResizeColumns: true
+        };
         sheet.showRowOutline(false);
         me.buildHeader(sheet, setting);
         if (rowCount > 0) sheet.setRowCount(rowCount);
@@ -34,7 +39,7 @@ var sheetCommonObj = {
         var me = this;
         var spreadBook = new GC.Spread.Sheets.Workbook(container, { sheetCount: 1 });
         spreadBook.options.tabStripVisible = false;
-        spreadBook.options.showHorizontalScrollbar = false;
+        //spreadBook.options.showHorizontalScrollbar = false;
         spreadBook.options.scrollbarMaxAlign = true;
         spreadBook.options.allowCopyPasteExcelStyle = false;
         spreadBook.options.allowExtendPasteRange = true;
@@ -48,6 +53,10 @@ var sheetCommonObj = {
         sheet.setColumnCount(setting.header.length, spreadNS.SheetArea.viewport);
         sheet.options.colHeaderAutoTextIndex = 1;
         sheet.options.colHeaderAutoText = spreadNS.HeaderAutoText.numbers;
+        sheet.options.protectionOptions = {
+            allowResizeRows: true,
+            allowResizeColumns: true
+        };
         sheet.showRowOutline(false);
         //setup column header
         me.buildHeader(sheet, setting);
@@ -279,11 +288,15 @@ var sheetCommonObj = {
         sheet.resumeEvent();
     },
     unLockAllCells: function (sheet) {
+        sheet.suspendPaint();
+        sheet.suspendEvent();
         let defaultStyle = new GC.Spread.Sheets.Style();
         defaultStyle.locked = false;
         sheet.setDefaultStyle(defaultStyle, GC.Spread.Sheets.SheetArea.viewport);
         sheet.setStyle(-1, 0, defaultStyle);
         sheet.options.isProtected = false;
+        sheet.resumePaint();
+        sheet.resumeEvent();
     },
     lockAllCells: function (sheet) {
         sheet.suspendPaint();
@@ -314,6 +327,8 @@ var sheetCommonObj = {
         sheet.resumeEvent();
     },
     lockCodeCells: function (sheet, rowCount) {
+        sheet.suspendPaint();
+        sheet.suspendEvent();
         let sheetRowCount = sheet.getRowCount();
         let defaultStyle = new GC.Spread.Sheets.Style();
         defaultStyle.locked = false;
@@ -321,8 +336,6 @@ var sheetCommonObj = {
         let style = new GC.Spread.Sheets.Style();
         style.locked = true;
         sheet.setStyle(-1, 0, style);
-        sheet.suspendPaint();
-        sheet.suspendEvent();
         for(let i =rowCount; i<sheetRowCount; i++){
             sheet.setStyle(i, -1, style);
         }
@@ -331,6 +344,8 @@ var sheetCommonObj = {
         sheet.resumeEvent();
     },
     lockCells: function(sheet, setting){
+        sheet.suspendPaint();
+        sheet.suspendEvent();
         if (setting && setting.view.lockColumns && setting.view.lockColumns.length > 0) {
             sheet.options.isProtected = true;
             sheet.getRange(-1, 0, -1, setting.header.length, GC.Spread.Sheets.SheetArea.viewport).locked(false);
@@ -338,6 +353,8 @@ var sheetCommonObj = {
                 sheet.getRange(-1,setting.view.lockColumns[i] , -1, 1, GC.Spread.Sheets.SheetArea.viewport).locked(true);
             }
         }
+        sheet.resumePaint();
+        sheet.resumeEvent();
     },
     chkIfEmpty: function(rObj, setting) {
         var rst = true;

+ 1 - 1
web/maintain/bills_lib/scripts/set_sheets.js

@@ -5,7 +5,7 @@ var setSheet = {
     initSheet: function(spread, setting, isExtendPaste){
         var spreadNS = GC.Spread.Sheets, sheet = spread.getActiveSheet();
         sheet.suspendPaint();
-        spread.options.showHorizontalScrollbar = false;
+        //spread.options.showHorizontalScrollbar = false;
         //spread.options.showVerticalScrollbar =false;
         spread.options.tabStripVisible = false;
         spread.options.scrollbarMaxAlign = true;

+ 12 - 141
web/maintain/ration_repository/dinge.html

@@ -42,7 +42,7 @@
               </ul>
         </nav>
     </div>
-    <div class="main">
+    <div class="main" style="overflow: hidden">
         <div class="content">
             <div class="container-fluid">
                 <div class="row">
@@ -96,7 +96,7 @@
                                   <!-- 内容 -->
                                   <div class="tab-content">
                                       <div class="tab-pane active" id="rDetail" role="tabpanel">
-                                          <div id="rdSpread" class="main-data-bottom"></div>
+                                          <div id="rdSpread" class="main-data-bottom" style="overflow: hidden"></div>
                                       </div>
                                   </div>
                               </div>
@@ -124,81 +124,14 @@
                           <!--工作内容-->
                           <div class="tab-pane" id="tgz" role="tabpanel">
                               <div class="main-data">
-                                  <div class="form-check m-2"><label class="form-check-label"><input type="radio" class="form-check-input" name="optionsRadios" value="option1" checked=""> 适合本项所有定额</label>&nbsp;&nbsp;<label class="form-check-label"><input type="radio" class="form-check-input" name="optionsRadios" value="option1"> 适合本项部分定额</label></div>
+                                  <div class="form-check m-2"><label class="form-check-label"><input type="radio" class="form-check-input" name="optionsRadios" value="ALL" disabled=""> 适合本项所有定额</label>&nbsp;&nbsp;<label class="form-check-label"><input type="radio" class="form-check-input" name="optionsRadios" value="PARTIAL" disabled> 适合本项部分定额</label></div>
                                   <!-- <p class="m-2">适合本项所有定额</p> -->
-                                  <table class="table table-sm table-bordered m-0">
+                                  <table class="table table-sm table-bordered m-0" id="tableAll">
                                       <tr>
-                                          <td>1.挖土、修理边底。2.挖淤泥、流沙、修理边底。</td>
+                                          <td><textarea class="form-control" rows="30" id="txtareaAll"></textarea></td>
                                       </tr>
                                   </table>
-                                  <div class="form-check m-2"><label class="form-check-label"><input type="radio" class="form-check-input" name="optionsRadios2" value="option1"> 适合本项所有定额</label>&nbsp;&nbsp;<label class="form-check-label"><input type="radio" class="form-check-input" name="optionsRadios2" value="option1" checked=""> 适合本项部分定额</label></div>
-                                  <table class="table table-sm table-bordered m-0">
-                                      <thead>
-                                      <tr>
-                                          <th></th>
-                                          <th>编码</th>
-                                          <th>工作内容</th>
-                                      </tr>
-                                      </thead>
-                                      <tbody>
-                                      <tr>
-                                          <td>1</td>
-                                          <td><a href data-toggle="modal" data-target="#editBianmaQ" class="m-0">编辑编码</a><p class="m-0">AA0017</p><p class="m-0">AA0018</p><p class="m-0">AA0019</p><p class="m-0">AA0020</p><p class="m-0">AA0021</p><p class="m-0">AA0022</p></td>
-                                          <td><p class="m-0">1.松填土:5m内的就地取土,铺平。</p><p class="m-0">2.夯填土方(石渣):5m内的就地取土(石渣)、铺平、夯实、洒水等。</p></td>
-                                      </tr>
-                              <tr>
-                                  <td>2</td>
-                                  <td><a href data-toggle="modal" data-target="#editBianma" class="m-0">点击勾选编码</a></td>
-                                  <td></td>
-                              </tr>
-                              <tr>
-                                  <td>3</td>
-                                  <td></td>
-                                  <td></td>
-                              </tr>
-                              <tr>
-                                  <td>4</td>
-                                  <td></td>
-                                  <td></td>
-                              </tr>
-                              </tbody>
-                              </table>
-                              <div class="form-check m-2"><label class="form-check-label"><input type="radio" class="form-check-input" name="optionsRadios1" value="option1"> 适合本项所有定额</label>&nbsp;&nbsp;<label class="form-check-label"><input type="radio" class="form-check-input" name="optionsRadios1" value="option1" checked=""> 适合本项部分定额</label></div>
-                              <table class="table table-sm table-bordered m-0">
-                                  <thead>
-                                  <tr>
-                                      <th></th>
-                                      <th>编码</th>
-                                      <th>工作内容</th>
-                                  </tr>
-                                  </thead>
-                                  <tbody>
-                                  <tr>
-                                      <td>1</td>
-                                      <td><a href data-toggle="modal" data-target="#editBianma" class="m-0">编辑编码</a><p class="m-0">AA0017</p><p class="m-0">AA0018</p><p class="m-0">AA0019</p></td>
-                                      <td><p class="m-0">1.松填土:5m内的就地取土,铺平。</p><p class="m-0">2.夯填土方(石渣):5m内的就地取土(石渣)、铺平、夯实、洒水等。</p></td>
-                                  </tr>
-                                  <tr>
-                                      <td>2</td>
-                                      <td><a href data-toggle="modal" data-target="#editBianma" class="m-0">编辑编码</a><p class="m-0">AA0020</p><p class="m-0">AA0021</p><p class="m-0">AA0022</p></td>
-                                      <td><p class="m-0">1.松填土:5m内的就地取土,铺平。</p><p class="m-0">2.夯填土方(石渣):5m内的就地取土(石渣)、铺平、夯实、洒水等。</p></td>
-                                  </tr>
-                                  <tr>
-                                      <td>3</td>
-                                      <td><a href data-toggle="modal" data-target="#editBianma" class="m-0">点击勾选编码</a></td>
-                                      <td></td>
-                                  </tr>
-                                  <tr>
-                                      <td>4</td>
-                                      <td></td>
-                                      <td></td>
-                                  </tr>
-                                  <tr>
-                                      <td>5</td>
-                                      <td></td>
-                                      <td></td>
-                                  </tr>
-                                  </tbody>
+                                  <table class="table table-sm table-bordered m-0" id="tablePartial">
                               </table>
                           </div>
                       </div>
@@ -208,6 +141,7 @@
         </div>
     </div>
         <!--弹出添加-->
+        <button id="gznrBtn" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#addNewgznr" style="display: none"></button>
         <div class="modal fade" id="addNewgznr" data-backdrop="static" style="display: none;" aria-hidden="true">
             <div class="modal-dialog" role="document">
                 <div class="modal-content">
@@ -340,38 +274,7 @@
                             <div class="form-group">
                                 <label>编码</label>
                                 <div class="form-control">
-                                    <div class="row code">
-                                        <div class="col">
-                                            <label class="form-check-label">
-                                                <input class="form-check-input" type="checkbox" value="option1" checked> AA0017
-                                            </label>
-                                        </div>
-                                        <div class="col">
-                                            <label class="form-check-label">
-                                                <input class="form-check-input" type="checkbox" value="option1" checked> AA0018
-                                            </label>
-                                        </div>
-                                        <div class="col">
-                                            <label class="form-check-label">
-                                                <input class="form-check-input" type="checkbox" value="option1" checked> AA0019
-                                            </label>
-                                        </div>
-                                        <div class="w-100"></div>
-                                        <div class="col">
-                                            <label class="form-check-label">
-                                                <input class="form-check-input" type="checkbox" value="option1" checked> AA0020
-                                            </label>
-                                        </div>
-                                        <div class="col">
-                                            <label class="form-check-label">
-                                                <input class="form-check-input" type="checkbox" value="option1" checked> AA0021
-                                            </label>
-                                        </div>
-                                        <div class="col">
-                                            <label class="form-check-label">
-                                                <input class="form-check-input" type="checkbox" value="option1" checked> AA0022
-                                            </label>
-                                        </div>
+                                    <div class="row code" id="updateCon">
                                     </div>
                                 </div>
                             </div>
@@ -379,7 +282,7 @@
                     </div>
                     <div class="modal-footer">
                         <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
-                        <a href="" class="btn btn-primary">确定</a>
+                        <a href="javascript: void(0);" class="btn btn-primary" data-dismiss="modal" id="updateConBtn">确定</a>
                     </div>
                 </div>
             </div>
@@ -388,7 +291,7 @@
             <div class="modal-dialog" role="document">
                 <div class="modal-content">
                     <div class="modal-header">
-                        <h5 class="modal-title">修改编码</h5>
+                        <h5 class="modal-title">勾选编码</h5>
                         <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                             <span aria-hidden="true">×</span>
                         </button>
@@ -398,38 +301,7 @@
                             <div class="form-group">
                                 <label>编码</label>
                                 <div class="form-control">
-                                    <div class="row code">
-                                        <div class="col">
-                                            <label class="form-check-label">
-                                                <input class="form-check-input" type="checkbox" value="option1" checked> AA0017
-                                            </label>
-                                        </div>
-                                        <div class="col">
-                                            <label class="form-check-label">
-                                                <input class="form-check-input" type="checkbox" value="option1" checked> AA0018
-                                            </label>
-                                        </div>
-                                        <div class="col">
-                                            <label class="form-check-label">
-                                                <input class="form-check-input" type="checkbox" value="option1" checked> AA0019
-                                            </label>
-                                        </div>
-                                        <div class="w-100"></div>
-                                        <div class="col">
-                                            <label class="form-check-label">
-                                                <input class="form-check-input" type="checkbox" value="option1" disabled> AA0020
-                                            </label>
-                                        </div>
-                                        <div class="col">
-                                            <label class="form-check-label">
-                                                <input class="form-check-input" type="checkbox" value="option1" disabled> AA0021
-                                            </label>
-                                        </div>
-                                        <div class="col">
-                                            <label class="form-check-label">
-                                                <input class="form-check-input" type="checkbox" value="option1" disabled> AA0022
-                                            </label>
-                                        </div>
+                                    <div class="row code" id="addCon">
                                     </div>
                                 </div>
                             </div>
@@ -437,7 +309,7 @@
                     </div>
                     <div class="modal-footer">
                         <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
-                        <a href="" class="btn btn-primary">确定</a>
+                        <a href="javascript: void(0);" class="btn btn-primary" data-dismiss="modal" id="addConBtn">确定</a>
                     </div>
                 </div>
             </div>
@@ -586,7 +458,6 @@
                 $("#linkFZTJ").click(function(){
                     rdSpread.setActiveSheetIndex(2);
                 });
-
             });
         </script>
     </div>

+ 45 - 8
web/maintain/ration_repository/js/ration.js

@@ -256,11 +256,11 @@ var rationOprObj = {
                     me.workBook.getSheet(0).options.isProtected = true;
                     $('#rationAlertCac').click(function () {
                         me.workBook.getSheet(0).options.isProtected = false;
-                        me.workBook.getSheet(0).setActiveCell(me.editingRowIdx, focusToCol);
+                        //me.workBook.getSheet(0).setActiveCell(me.editingRowIdx, focusToCol);
                     });
                     $('#rationAlertCls').click(function () {
                         me.workBook.getSheet(0).options.isProtected = false;
-                        me.workBook.getSheet(0).setActiveCell(me.editingRowIdx, focusToCol);
+                       // me.workBook.getSheet(0).setActiveCell(me.editingRowIdx, focusToCol);
                     });
                     $('#rationAlertCof').click(function () {
                         me.workBook.getSheet(0).options.isProtected = false;
@@ -268,7 +268,7 @@ var rationOprObj = {
                         for(let col=0; col<me.setting.header.length; col++){
                             me.workBook.getSheet(0).getCell(me.editingRowIdx, col).value(me.currentEditingRation[me.setting.header[col].dataCode]);
                         }
-                        me.workBook.getSheet(0).setActiveCell(me.editingRowIdx, 0);
+                        //me.workBook.getSheet(0).setActiveCell(me.editingRowIdx, 0);
                     });
                 }
                // }
@@ -296,7 +296,6 @@ var rationOprObj = {
             updateArr = [], addArr = [];
         let dataCode = me.setting.header[args.col].dataCode;
         me.editingRowIdx = args.row;
-        console.log(rObj);
         if (me.currentEditingRation["ID"]) {
             rObj["ID"] = me.currentEditingRation["ID"];
                 if(me.currentEditingRation[dataCode] !== rObj[dataCode]){
@@ -324,6 +323,10 @@ var rationOprObj = {
                 me.addRationItem = rObj;
                 if(rObj.code && rObj.code.toString().trim().length > 0){
                     if(me.rationsCodes.indexOf(rObj.code) === -1){
+                        //jobContent
+                        if(jobContentOprObj && jobContentOprObj.currentSituation === jobContentOprObj.situations.ALL){
+                            rObj.jobContent = jobContentOprObj.currentJobContent ? jobContentOprObj.currentJobContent : '';
+                        }
                         addArr.push(rObj);
                         me.rationsCodes.push(rObj.code);
                         me.addRationItem = null;
@@ -376,10 +379,14 @@ var rationOprObj = {
             if (cacheSection) {
                 if(!me.isValidUnit(items[i], rationUnits)){//无效单位
                     items[i].unit = typeof cacheSection[rowIdx].unit !== 'undefined' && !cacheSection[rowIdx] ? cacheSection[rowIdx].unit : '';
-                };
+                }
                 //var hasCacheItem = false;
                 if(!cacheSection[rowIdx] && info.cellRange.col === 0 ){
                     if(me.rationsCodes.indexOf(items[i].code) === -1){
+                        //jobConten
+                        if(jobContentOprObj && jobContentOprObj.currentSituation === jobContentOprObj.situations.ALL){
+                            items[i].jobContent = jobContentOprObj.currentJobContent ? jobContentOprObj.currentJobContent : '';
+                        }
                         addArr.push(items[i]);
                         me.rationsCodes.push(items[i].code);
                     }
@@ -412,11 +419,15 @@ var rationOprObj = {
             } else {
                 if(!me.isValidUnit(items[i], rationUnits)){//无效单位
                     items[i].unit = '';
-                };
+                }
                 //add
                 if(info.cellRange.col === 0){
                     //是否含有已存在的编号
                         if(me.rationsCodes.indexOf(items[i].code) === -1){
+                            //jobConten
+                            if(jobContentOprObj && jobContentOprObj.currentSituation === jobContentOprObj.situations.ALL){
+                                items[i].jobContent = jobContentOprObj.currentJobContent ? jobContentOprObj.currentJobContent : '';
+                            }
                             addArr.push(items[i]);
                         }
                         else{
@@ -440,6 +451,15 @@ var rationOprObj = {
         }
         return rst;
     },
+    setLockCol: function (sheet, col, isLocked) {
+        sheet.suspendPaint();
+        sheet.suspendEvent();
+        for(let row = 0, len = sheet.getRowCount(); row < len; row++){
+            sheet.getCell(row, col).locked(isLocked);
+        }
+        sheet.resumePaint();
+        sheet.resumeEvent();
+    },
     getRationsCodes: function (repId) {
         let me = rationOprObj;
         $.ajax({
@@ -456,6 +476,7 @@ var rationOprObj = {
     },
     mixUpdateRequest: function(updateArr, addArr, removeIds) {
         var me = rationOprObj;
+        me.setLockCol(me.workBook.getSheet(0), 0, true);
         $.ajax({
             type:"POST",
             url:"api/mixUpdateRationItems",
@@ -475,10 +496,16 @@ var rationOprObj = {
                         else if (a.code < b.code) rst = -1;
                         return rst;
                     });
+                    //jobContent
+                    if(jobContentOprObj && jobContentOprObj.currentSituation === jobContentOprObj.situations.PARTIAL){
+                        jobContentOprObj.currentRationItems = cacheSection;
+                        jobContentOprObj.buildTablePartial(jobContentOprObj.tablePartial, jobContentOprObj.getGroup(cacheSection));
+                    }
                     me.showRationItems(me.currentSectionId);
                     me.mixUpdate = 0;
-                    me.workBook.getSheet(0).setActiveCell(me.activeCell.row, me.activeCell.col);
+                   // me.workBook.getSheet(0).setActiveCell(me.activeCell.row, me.activeCell.col);
                 }
+                me.setLockCol(me.workBook.getSheet(0), 0, false);
             },
             error:function(){
             }
@@ -490,6 +517,10 @@ var rationOprObj = {
             me.mixUpdate = 0;
             me.currentSectionId = sectionID;
             if (me.currentRations["_SEC_ID_" + sectionID]) {
+                //jobContent--
+                jobContentOprObj.currentRationItems = me.currentRations["_SEC_ID_" + sectionID];
+                jobContentOprObj.rationJobContentOpr(me.currentRations["_SEC_ID_" + sectionID]);
+                //jobContent--
                 me.showRationItems(sectionID);
                 ///sheetCommonObj.unShieldAllCells(me.workBook.getSheet(0));
                 sheetCommonObj.lockCells(rationGLJOprObj.sheet, rationGLJOprObj.setting);
@@ -508,6 +539,10 @@ var rationOprObj = {
                         if (result) {
                             me.currentRations["_SEC_ID_" + sectionID] = result.data;
                             me.sortByCode(me.currentRations["_SEC_ID_" + sectionID]);
+                            //job--
+                            jobContentOprObj.currentRationItems = me.currentRations["_SEC_ID_" + sectionID];
+                            jobContentOprObj.rationJobContentOpr(me.currentRations["_SEC_ID_" + sectionID]);
+                            //job--
                             me.showRationItems(sectionID);
                             //sheetCommonObj.unShieldAllCells(me.workBook.getSheet(0));
                             sheetCommonObj.lockCells(me.workBook.getSheet(0), rationOprObj.setting);
@@ -543,8 +578,10 @@ var rationOprObj = {
         if (me.workBook) {
             if (me.currentRations && me.currentRations["_SEC_ID_" + sectionID] && me.currentRations["_SEC_ID_" + sectionID].length > 0) {
                 var cacheSection = me.currentRations["_SEC_ID_" + sectionID];
-                sheetCommonObj.cleanSheet(me.workBook.getSheet(0), me.setting, -1);
+                //sheetCommonObj.cleanSheet(me.workBook.getSheet(0), me.setting, -1);
+                sheetCommonObj.cleanData(me.workBook.getSheet(0), me.setting, -1);
                 sheetCommonObj.showData(me.workBook.getSheet(0), me.setting, cacheSection);
+                me.setLockCol(me.workBook.getSheet(0), 4, true);
                 //combo
                 me.setCombo(me.workBook.getActiveSheet(), rationUnits);
                 if(me.mixUpdate === 1){

+ 39 - 9
web/maintain/ration_repository/js/ration_glj.js

@@ -99,7 +99,6 @@ var rationGLJOprObj = {
                                 if(sels[sel].row + i < cacheSection.length){
                                     isUpdate = true;
                                     cacheSection.splice(sels[sel].row + i, 1);
-                                    me.updateRationItem();
                                 }
                             }
                         }
@@ -284,16 +283,43 @@ var rationGLJOprObj = {
         }
     },
     onContextmenuOpr: function () {
+        let me = rationGLJOprObj;
         $.contextMenu({
             selector: '#rdSpread',
-            callback: function(key, options) {
-                var m = "clicked: " + key;
-                window.console && console.log(m) || alert(m);
-            },
-            items: {
-                "insert": {name: "插入", callback: function (key, opt) {
-                }},
-                "delete": {name: "删除"}
+            build: function ($triggerElement, e) {
+                //控制允许右键菜单在哪个位置出现
+                let sheet = me.sheet;
+                let offset = $triggerElement.offset(),
+                    x = e.pageX - offset.left,
+                    y = e.pageY - offset.top;
+                let target = sheet.hitTest(x, y);
+                if(sheet.parent.getActiveSheetIndex() === 0){
+                    let delDis = true;
+                    let cacheSection = me.cache["_GLJ_" + me.currentRationItem.ID];
+                    if(target.hitTestType === 3 && typeof target.row !== 'undefined' && typeof target.col !== 'undefined'){//在表格内
+                        sheet.setActiveCell(target.row, target.col);
+                        if(target.row < cacheSection.length){
+                            delDis = false;
+                        }
+                    }
+                    return {
+                        callback: function(key, options) {
+                        },
+                        items: {
+                            /*"insert": {name: "插入", callback: function (key, opt) {
+                            }},*/
+                            "delete": {name: "删除", icon: 'fa-remove', disabled: delDis, callback: function (key, opt) {
+                                cacheSection.splice(target.row, 1);
+                                me.updateRationItem();
+                                sheetCommonObj.cleanSheet(me.sheet, me.setting, -1);
+                                me.showGljItems(me.currentRationItem.ID);
+                            }}
+                        }
+                    };
+                }
+                else{
+                    return false;
+                }
             }
         });
     },
@@ -518,9 +544,13 @@ var rationGLJOprObj = {
         if (me.cache["_GLJ_" + rationID]) {
             sheetCommonObj.showData(me.sheet, me.setting, me.cache["_GLJ_" + rationID], me.distTypeTree);
             //lock
+            me.sheet.suspendPaint();
+            me.sheet.suspendEvent();
             for(let i = 0, len = me.sheet.getRowCount(); i < len; i++){
                 me.sheet.getCell(i, 4).locked(true);
             }
+            me.sheet.resumePaint();
+            me.sheet.resumeEvent();
         }
     }
 }

+ 424 - 424
web/maintain/ration_repository/js/repository_glj.js

@@ -38,7 +38,7 @@ var pageOprObj = {
         }
     }
 }
- repositoryGljObj = {
+repositoryGljObj = {
     treeObj : null,
     workBook: null,
     gljCurTypeId: -1,
@@ -92,9 +92,9 @@ var pageOprObj = {
         });
         distTypeTree.distTypesArr.forEach(function (distTypeObj) {
             /*if(distTypeObj.children.length === 0 && distTypeObj.data.fullName !== '普通机械' &&distTypeObj.data.fullName !== '机械组成物'
-            && distTypeObj.data.fullName !== '机上人工'){
-                distTypeTree.comboDatas.push({text: distTypeObj.data.fullName, value: distTypeObj.data.ID});
-            }*/
+             && distTypeObj.data.fullName !== '机上人工'){
+             distTypeTree.comboDatas.push({text: distTypeObj.data.fullName, value: distTypeObj.data.ID});
+             }*/
             if(distTypeObj.data.fullName !== '材料'){
                 distTypeTree.comboDatas.push({text: distTypeObj.data.fullName, value: distTypeObj.data.ID});
             }
@@ -195,88 +195,88 @@ var pageOprObj = {
         var me = repositoryGljObj;
         me.workBook = sheetCommonObj.buildSheet(container, me.setting, 30, me);
         me.workBook.getSheet(0).options.isProtected = true;
-       /* me.repositoryGljDelOpr();
-        me.workBook.bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
-        me.workBook.bind(GC.Spread.Sheets.Events.ClipboardPasted, me.onClipboardPasted);
-        me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EditStarting, me.onCellEditStart);
-        me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EditEnded, me.onCellEditEnd);
-        //me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.RangeChanged, me.onRangeChanged);
-        me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EnterCell, me.onEnterCell);*/
+        /* me.repositoryGljDelOpr();
+         me.workBook.bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
+         me.workBook.bind(GC.Spread.Sheets.Events.ClipboardPasted, me.onClipboardPasted);
+         me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EditStarting, me.onCellEditStart);
+         me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EditEnded, me.onCellEditEnd);
+         //me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.RangeChanged, me.onRangeChanged);
+         me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EnterCell, me.onEnterCell);*/
     },
-     onEnterCell: function (sender, args) {
-         let me = repositoryGljObj;
-         me.cellRowIdx = args.row;
-         let isHasData = false;
-         if(me.addGljObj){
-             for(let i=0; i<me.setting.header.length; i++){
-                 if(me.addGljObj[me.setting.header[i].dataCode]){
-                     isHasData = true;
-                     break;
-                 }
-             }
-         }
-         if(isHasData){
-             if(me.editingRowIdx !== me.cellRowIdx) {
-                 let isComple = true;
-                 let focusToCol;
-                 function getFocusToCol (me){
-                     if(!me.addGljObj[me.setting.header[0].dataCode]){
-                         $('#alertGljTxt').text('编号不能为空,是否取消增加工料机?');
-                         return 0;
-                     }
-                     else if(!me.addGljObj[me.setting.header[1].dataCode]){
-                         $('#alertGljTxt').text('名称不能为空,是否取消增加工料机?');
-                         return 1;
-                     }
+    onEnterCell: function (sender, args) {
+        let me = repositoryGljObj;
+        me.cellRowIdx = args.row;
+        let isHasData = false;
+        if(me.addGljObj){
+            for(let i=0; i<me.setting.header.length; i++){
+                if(me.addGljObj[me.setting.header[i].dataCode]){
+                    isHasData = true;
+                    break;
+                }
+            }
+        }
+        if(isHasData){
+            if(me.editingRowIdx !== me.cellRowIdx) {
+                let isComple = true;
+                let focusToCol;
+                function getFocusToCol (me){
+                    if(!me.addGljObj[me.setting.header[0].dataCode]){
+                        $('#alertGljTxt').text('编号不能为空,是否取消增加工料机?');
+                        return 0;
+                    }
+                    else if(!me.addGljObj[me.setting.header[1].dataCode]){
+                        $('#alertGljTxt').text('名称不能为空,是否取消增加工料机?');
+                        return 1;
+                    }
                     else if(!me.addGljObj[me.setting.header[5].dataCode]){
-                         $('#alertGljTxt').text('类型不能为空,是否取消增加工料机?');
-                         return 5;
-                     }
-                     else {
-                         return -1;
-                     }
-                 }
-                 focusToCol = getFocusToCol(me);
-                 if(focusToCol === -1){
+                        $('#alertGljTxt').text('类型不能为空,是否取消增加工料机?');
+                        return 5;
+                    }
+                    else {
+                        return -1;
+                    }
+                }
+                focusToCol = getFocusToCol(me);
+                if(focusToCol === -1){
 
-                 }
-                 else {
+                }
+                else {
                     $('#gljAlertBtn').click();
-                     //me.workBook.getSheet(0).options.isProtected = true;
-                     sheetCommonObj.lockAllCells(args.sheet);
-                     $('#aleCanceBtn').click(function () {
+                    //me.workBook.getSheet(0).options.isProtected = true;
+                    sheetCommonObj.lockAllCells(args.sheet);
+                    $('#aleCanceBtn').click(function () {
                         // me.workBook.getSheet(0).options.isProtected = false;
-                         sheetCommonObj.unLockAllCells(args.sheet);
-                         sheetCommonObj.reLockSomeCodes(args.sheet, 0, repositoryGljObj.currentCache.length);
-                         me.workBook.getSheet(0).setActiveCell(me.editingRowIdx, focusToCol);
-                     });
-                     $('#gljAleClose').click(function () {
+                        sheetCommonObj.unLockAllCells(args.sheet);
+                        sheetCommonObj.reLockSomeCodes(args.sheet, 0, repositoryGljObj.currentCache.length);
+                        me.workBook.getSheet(0).setActiveCell(me.editingRowIdx, focusToCol);
+                    });
+                    $('#gljAleClose').click(function () {
                         // me.workBook.getSheet(0).options.isProtected = false;
-                         sheetCommonObj.unLockAllCells(args.sheet);
-                         sheetCommonObj.reLockSomeCodes(args.sheet, 0, repositoryGljObj.currentCache.length);
-                         me.workBook.getSheet(0).setActiveCell(me.editingRowIdx, focusToCol);
-                     });
-                     $('#aleConfBtn').click(function () {
+                        sheetCommonObj.unLockAllCells(args.sheet);
+                        sheetCommonObj.reLockSomeCodes(args.sheet, 0, repositoryGljObj.currentCache.length);
+                        me.workBook.getSheet(0).setActiveCell(me.editingRowIdx, focusToCol);
+                    });
+                    $('#aleConfBtn').click(function () {
                         // me.workBook.getSheet(0).options.isProtected = false;
-                         sheetCommonObj.unLockAllCells(args.sheet);
-                         sheetCommonObj.reLockSomeCodes(args.sheet, 0, repositoryGljObj.currentCache.length);
-                         me.addGljObj = null;
-                         for(let col=0; col<me.setting.header.length; col++){
-                             let field = me.setting.header[col].dataCode;
-                             if(field === 'gljType'){
-                                 me.workBook.getSheet(0).getCell(me.editingRowIdx, col).value(
-                                     me.distTypeTree.distTypes[me.distTypeTree.prefix + me.currentEditingGlj[field]].data.fullName);
-                             }
-                             else{
-                                 me.workBook.getSheet(0).getCell(me.editingRowIdx, col).value(me.currentEditingGlj[me.setting.header[col].dataCode]);
-                             }
-                         }
-                         me.workBook.getSheet(0).setActiveCell(me.editingRowIdx, 0);
-                     });
-                 }
-             }
-         }
-     },
+                        sheetCommonObj.unLockAllCells(args.sheet);
+                        sheetCommonObj.reLockSomeCodes(args.sheet, 0, repositoryGljObj.currentCache.length);
+                        me.addGljObj = null;
+                        for(let col=0; col<me.setting.header.length; col++){
+                            let field = me.setting.header[col].dataCode;
+                            if(field === 'gljType'){
+                                me.workBook.getSheet(0).getCell(me.editingRowIdx, col).value(
+                                    me.distTypeTree.distTypes[me.distTypeTree.prefix + me.currentEditingGlj[field]].data.fullName);
+                            }
+                            else{
+                                me.workBook.getSheet(0).getCell(me.editingRowIdx, col).value(me.currentEditingGlj[me.setting.header[col].dataCode]);
+                            }
+                        }
+                        me.workBook.getSheet(0).setActiveCell(me.editingRowIdx, 0);
+                    });
+                }
+            }
+        }
+    },
     onCellEditStart: function(sender, args) {
         var me = repositoryGljObj;
         var rObj = sheetCommonObj.combineRowData(me.workBook.getSheet(0), me.setting, args.row);
@@ -328,16 +328,16 @@ var pageOprObj = {
             }
             //update basePrice of ration when editting gljType of glj
             if(me.currentEditingGlj.gljType !== rObj.gljType){
-               let gljTypeObj = {gljId: me.currentEditingGlj.ID, gljType: rObj.gljType, basePrice: rObj.basePrice};
+                let gljTypeObj = {gljId: me.currentEditingGlj.ID, gljType: rObj.gljType, basePrice: rObj.basePrice};
                 updateBasePrcArr.push(gljTypeObj);
                 me.updateRationBasePrcRq(updateBasePrcArr);
             }
         } else {
             me.addGljObj = rObj;
             let isCanSav = true;
-                if(!rObj[me.setting.header[0].dataCode] || !rObj[me.setting.header[1].dataCode] || !rObj[me.setting.header[5].dataCode]){
-                    isCanSav = false;
-                }
+            if(!rObj[me.setting.header[0].dataCode] || !rObj[me.setting.header[1].dataCode] || !rObj[me.setting.header[5].dataCode]){
+                isCanSav = false;
+            }
             if(isCanSav){
                 me.addGljObj = null;
                 addArr.push(rObj);
@@ -353,347 +353,347 @@ var pageOprObj = {
             me.mixUpdateRequest(updateArr, addArr, []);
         }
     },
-     repositoryGljDelOpr: function () {
+    repositoryGljDelOpr: function () {
         let me = repositoryGljObj;
-         me.workBook.commandManager().register('repositoryGljDel', function () {
-             let sheet = me.workBook.getSheet(0),
-                 updateArr = [], removeArr = [],
-                 tempRemoveArr= [],
-                 refGljCodes = [], //已被引用的工料机
-                 updateBasePrcArr = [],//删除基价单位后重新计算
-                 sels = sheet.getSelections(),
-                 cacheSection = me.currentCache;
-             if(sels.length > 0 && cacheSection.length > 0){
-                 for(let i = 0; i < sels.length; i++){
-                     if(sels[i].colCount === me.setting.header.length){
-                         for(let j = 0; j < sels[i].rowCount; j++){
-                             if(sels[i].row + j < cacheSection.length){
-                                 tempRemoveArr.push({ID: cacheSection[sels[i].row + j].ID, code: cacheSection[sels[i].row + j].code});
-                             }
-                         }
-                     }
-                     else{
-                         let maxCol = sels[i].col + sels[i].colCount - 1;
-                         if(sels[i].col >= 2 && maxCol <= 4){
-                             for(let j = 0; j < sels[i].rowCount; j++){
-                                 if(sels[i].row + j < cacheSection.length){
-                                     let updateObj = cacheSection[sels[i].row + j];
-                                     for(let col = sels[i].col; col <= maxCol; col++){
-                                         if(me.setting.header[col].dataCode === 'basePrice'){
-                                             updateObj[me.setting.header[col].dataCode] = 0;
-                                             updateBasePrcArr.push({gljId: updateObj.ID, gljType: updateObj.gljType, basePrice: 0});
-                                         }
-                                         else{
-                                             updateObj[me.setting.header[col].dataCode] = '';
-                                         }
-                                     }
-                                     updateArr.push(updateObj);
-                                 }
-                             }
-                         }
-                         //编号、名称、类型不可为空
-                         else{
-                             if(sels[i].row < cacheSection.length){
-                                 let text = '', cantNullStr =['编码', '名称', '类型'];
-                                 for(let col = sels[i].col; col <= sels[i].col + sels[i].colCount -1; col++){
-                                     if(cantNullStr.indexOf(me.setting.header[col].headerName) !== -1){
-                                         text += me.setting.header[col].headerName + " ";
-                                     }
-                                 }
-                                 $('#alertText').text(text + "不可为空!");
-                                 $('#codeAlertBtn').click();
-                                 sheet.options.isProtected = true;
-                                 $('#codAleConfBtn').click(function () {
-                                     sheetCommonObj.lockSomeCodes(sheet, 0, cacheSection.length);
-                                 });
-                                 $('#codAleClose').click(function () {
-                                     sheetCommonObj.lockSomeCodes(sheet, 0, cacheSection.length);
-                                 });
-                             }
-                         }
-                     }
-                 }
-                 //提取已被引用工料机
-                 if(tempRemoveArr.length > 0){
-                     for(let i = 0; i < tempRemoveArr.length; i++){
-                         if(me.rationGljIds.indexOf(tempRemoveArr[i].ID) !== -1){
-                             refGljCodes.push(tempRemoveArr[i].code);
-                             tempRemoveArr.splice(i--, 1);
-                         }
-                         else{
-                             removeArr.push(tempRemoveArr[i].ID);
-                         }
-                     }
-                 }
-                 //提示
-                 if(refGljCodes.length > 0){
-                     let alertText;
-                     if(refGljCodes.length > 3){
-                         alertText = "编号: " + refGljCodes[0]+" 、" + refGljCodes[1] + " 、" + refGljCodes[2] + "...等工料机已有定额引用,删除失败!";
-                     }
-                     else {
-                         let alertCode = " ";
-                         for(let i=0; i< refGljCodes.length; i++){
-                             alertCode += refGljCodes[i] + " 、";
-                         }
-                         alertText = "编号:" + alertCode + "工料机已有定额引用,删除失败!"
-                     }
-                     $('#alertText').text(alertText);
-                     $('#codeAlertBtn').click();
-                     sheet.options.isProtected = true;
-                     $('#codAleConfBtn').click(function () {
-                         sheetCommonObj.lockSomeCodes(sheet, 0, cacheSection.length);
-                         if(removeArr.length > 0){
-                             me.mixUpdateRequest(updateArr, [], removeArr);
-                         }
-                     });
-                     $('#codAleClose').click(function () {
-                         sheetCommonObj.lockSomeCodes(sheet, 0, cacheSection.length);
-                         me.mixUpdateRequest(updateArr, [], removeArr);
-                     });
-                 }
-                 else if(removeArr.length > 0 || updateArr.length > 0){
-                     me.mixUpdateRequest(updateArr, [], removeArr);
-                     if(updateBasePrcArr.length > 0){
-                         me.updateRationBasePrcRq(updateBasePrcArr);
-                     }
-                 }
-             }
+        me.workBook.commandManager().register('repositoryGljDel', function () {
+            let sheet = me.workBook.getSheet(0),
+                updateArr = [], removeArr = [],
+                tempRemoveArr= [],
+                refGljCodes = [], //已被引用的工料机
+                updateBasePrcArr = [],//删除基价单位后重新计算
+                sels = sheet.getSelections(),
+                cacheSection = me.currentCache;
+            if(sels.length > 0 && cacheSection.length > 0){
+                for(let i = 0; i < sels.length; i++){
+                    if(sels[i].colCount === me.setting.header.length){
+                        for(let j = 0; j < sels[i].rowCount; j++){
+                            if(sels[i].row + j < cacheSection.length){
+                                tempRemoveArr.push({ID: cacheSection[sels[i].row + j].ID, code: cacheSection[sels[i].row + j].code});
+                            }
+                        }
+                    }
+                    else{
+                        let maxCol = sels[i].col + sels[i].colCount - 1;
+                        if(sels[i].col >= 2 && maxCol <= 4){
+                            for(let j = 0; j < sels[i].rowCount; j++){
+                                if(sels[i].row + j < cacheSection.length){
+                                    let updateObj = cacheSection[sels[i].row + j];
+                                    for(let col = sels[i].col; col <= maxCol; col++){
+                                        if(me.setting.header[col].dataCode === 'basePrice'){
+                                            updateObj[me.setting.header[col].dataCode] = 0;
+                                            updateBasePrcArr.push({gljId: updateObj.ID, gljType: updateObj.gljType, basePrice: 0});
+                                        }
+                                        else{
+                                            updateObj[me.setting.header[col].dataCode] = '';
+                                        }
+                                    }
+                                    updateArr.push(updateObj);
+                                }
+                            }
+                        }
+                        //编号、名称、类型不可为空
+                        else{
+                            if(sels[i].row < cacheSection.length){
+                                let text = '', cantNullStr =['编码', '名称', '类型'];
+                                for(let col = sels[i].col; col <= sels[i].col + sels[i].colCount -1; col++){
+                                    if(cantNullStr.indexOf(me.setting.header[col].headerName) !== -1){
+                                        text += me.setting.header[col].headerName + " ";
+                                    }
+                                }
+                                $('#alertText').text(text + "不可为空!");
+                                $('#codeAlertBtn').click();
+                                sheet.options.isProtected = true;
+                                $('#codAleConfBtn').click(function () {
+                                    sheetCommonObj.lockSomeCodes(sheet, 0, cacheSection.length);
+                                });
+                                $('#codAleClose').click(function () {
+                                    sheetCommonObj.lockSomeCodes(sheet, 0, cacheSection.length);
+                                });
+                            }
+                        }
+                    }
+                }
+                //提取已被引用工料机
+                if(tempRemoveArr.length > 0){
+                    for(let i = 0; i < tempRemoveArr.length; i++){
+                        if(me.rationGljIds.indexOf(tempRemoveArr[i].ID) !== -1){
+                            refGljCodes.push(tempRemoveArr[i].code);
+                            tempRemoveArr.splice(i--, 1);
+                        }
+                        else{
+                            removeArr.push(tempRemoveArr[i].ID);
+                        }
+                    }
+                }
+                //提示
+                if(refGljCodes.length > 0){
+                    let alertText;
+                    if(refGljCodes.length > 3){
+                        alertText = "编号: " + refGljCodes[0]+" 、" + refGljCodes[1] + " 、" + refGljCodes[2] + "...等工料机已有定额引用,删除失败!";
+                    }
+                    else {
+                        let alertCode = " ";
+                        for(let i=0; i< refGljCodes.length; i++){
+                            alertCode += refGljCodes[i] + " 、";
+                        }
+                        alertText = "编号:" + alertCode + "工料机已有定额引用,删除失败!"
+                    }
+                    $('#alertText').text(alertText);
+                    $('#codeAlertBtn').click();
+                    sheet.options.isProtected = true;
+                    $('#codAleConfBtn').click(function () {
+                        sheetCommonObj.lockSomeCodes(sheet, 0, cacheSection.length);
+                        if(removeArr.length > 0){
+                            me.mixUpdateRequest(updateArr, [], removeArr);
+                        }
+                    });
+                    $('#codAleClose').click(function () {
+                        sheetCommonObj.lockSomeCodes(sheet, 0, cacheSection.length);
+                        me.mixUpdateRequest(updateArr, [], removeArr);
+                    });
+                }
+                else if(removeArr.length > 0 || updateArr.length > 0){
+                    me.mixUpdateRequest(updateArr, [], removeArr);
+                    if(updateBasePrcArr.length > 0){
+                        me.updateRationBasePrcRq(updateBasePrcArr);
+                    }
+                }
+            }
 
-         });
+        });
 
         me.workBook.commandManager().setShortcutKey(null, GC.Spread.Commands.Key.del, false, false, false, false);
         me.workBook.commandManager().setShortcutKey('repositoryGljDel', GC.Spread.Commands.Key.del, false, false, false, false);
-     },
-     onRangeChanged: function(sender, args) {
-         if (args.action == GC.Spread.Sheets.RangeChangedAction.clear) {
-             var me = repositoryGljObj, updateArr = [], removeArr = [], cancelArr = [], isMisCode = true;
-             var cacheSection = me.currentCache;
-             if (cacheSection) {
-                 for (var i = 0; i < args.rowCount; i++) {
-                     let rObj = sheetCommonObj.combineRowData(me.workBook.getSheet(0), me.setting, args.row + i),
-                         isEmpty = sheetCommonObj.chkIfEmpty(rObj, me.setting);
-                     if(isEmpty){
-                         if(args.row + i < cacheSection.length){
-                             rObj.ID = cacheSection[args.row + i].ID
-                             removeArr.push(rObj.ID);
-                         }
-                     }
-                     else {
-                         if(!rObj.code){
-                             cancelArr.push(args.row + i);
-                         }
-                         else if(!rObj.gljType){
-                             isMisCode = false;
-                             cancelArr.push(args.row + i);
-                         }
-                         else{
-                             rObj.gljClass = me.gljCurTypeId;
-                             updateArr.push(rObj);
-                         }
-                     }
-                 }
-                 //reshow datas
-                 function resetDatas(args, repositoryGljObj, cancelArr){
-                     args.sheet.options.isProtected = false;
-                     args.sheet.suspendPaint();
-                     for(let i =0; i <cancelArr.length; i++){
-                         for(let col =args.col; col< repositoryGljObj.setting.header.length; col++){
-                             let value = repositoryGljObj.setting.header[col].dataCode === 'gljType' ?
-                                 repositoryGljObj.distTypeTree.distTypes[repositoryGljObj.distTypeTree.prefix + cacheSection[cancelArr[i]].gljType].data.fullName :
-                                 cacheSection[cancelArr[i]][repositoryGljObj.setting.header[col].dataCode];
-                             args.sheet.setValue(args.row + i, col, value);
-                         }
-                     }
-                     args.sheet.resumePaint();
-                     args.sheet.setActiveCell(args.row, 0);
-                 }
-                 if(cancelArr.length > 0){
-                     let text = isMisCode === true ? "编号不可为空,编辑失败!": "类型不可为空,编辑失败!"
-                     $('#alertText').text(text);
-                     $('#codeAlertBtn').click();
-                     args.sheet.options.isProtected = true;
-                     $('#codAleConfBtn').click(function () {
-                         resetDatas(args, me, cancelArr);
-                     });
-                     $('#codAleClose').click(function () {
-                         resetDatas(args, me, cancelArr);
-                     });
-                 }
-                 let refGljIds = [], refGljCodes = [], alertText;
-                 if(removeArr.length > 0){
-                     for(let i =0; i <removeArr.length; i++){
-                         if(me.rationGljIds.indexOf(removeArr[i]) !== -1){
-                             refGljIds.push(removeArr[i]);
-                             removeArr.splice(i--, 1);
-                         }
-                     }
-                     for(let i =0; i< me.currentCache.length; i++){
-                         for(let j=0; j< refGljIds.length; j++){
-                             if(me.currentCache[i].ID === refGljIds[j]){
-                                 refGljCodes.push(me.currentCache[i].code);
-                             }
-                         }
-                     }
-                 }
-                 if(refGljIds.length > 0){
-                     if(refGljCodes.length > 3){
-                         alertText = "编号:" + refGljCodes[0]+" " + refGljCodes[1] + " " + refGljCodes[2] + "...等工料机已有定额引用,删除失败!";
-                     }
-                     else {
-                         let alertCode = " ";
-                         for(let i=0; i< refGljCodes.length; i++){
-                             alertCode += refGljCodes[i] + " ";
-                         }
-                         alertText = "编号:" + alertCode + "工料机已有定额引用,删除失败!"
-                     }
-                     $('#alertText').text(alertText);
-                     $('#codeAlertBtn').click();
-                     args.sheet.options.isProtected = true;
-                     $('#codAleConfBtn').click(function () {
-                         if(removeArr.length > 0){
-                             me.mixUpdateRequest(updateArr, [], removeArr);
-                         }
-                         else{
-                             let resetArr = [];
-                             for(let i=0; i<args.rowCount; i++){
-                                 resetArr.push(args.row + i);
-                             }
-                             resetDatas(args, me, resetArr);
-                         }
-                     });
-                     $('#codAleClose').click(function () {
-                         if(removeArr.length > 0){
-                             me.mixUpdateRequest(updateArr, [], removeArr);
-                         }
-                         else{
-                             let resetArr = [];
-                             for(let i=0; i<args.rowCount; i++){
-                                 resetArr.push(args.row + i);
-                             }
-                             resetDatas(args, me, resetArr);
-                         }
-                     });
-                 }
-                 else if(refGljIds.length === 0 && removeArr.length > 0){
-                     me.mixUpdateRequest(updateArr, [], removeArr);
-                 }
-                 if(updateArr.length > 0){
-                     me.mixUpdateRequest(updateArr, [], removeArr);
-                 }
-             }
-         }
-     },
-     validUpdateObj: function (pasteObj, rowIdx) {
-         let rst = {}, backUpObj = {},
-             me = repositoryGljObj,
-             tempObj = me.currentCache[rowIdx],
-             reCalBasePrc = false, isValid = true;
-         //备份原始数据
-         for(let atr in tempObj){
-             backUpObj[atr] = tempObj[atr];
-         }
-         if(typeof pasteObj.code !== 'undefined'){
-             if(pasteObj.code.trim().length !== 0){
-                 let isExist = false;
-                 for(let i = 0; i < me.gljList.length; i++){
-                     if(me.gljList[i].code === pasteObj.code){
-                         isExist = true;
-                         break;
-                     }
-                 }
-                 if(!isExist){
-                     tempObj.code = pasteObj.code;
-                 }
-                 else isValid = false;
-             }
-             else isValid = false;
-         }
-         if(typeof pasteObj.name !== 'undefined'){
-             if(pasteObj.name.trim().length === 0) isValid = false;
-             else tempObj.name = pasteObj.name;
-         }
-         if(typeof pasteObj.specs !== 'undefined'){
-             tempObj.specs = pasteObj.specs;
-         }
-         if(typeof pasteObj.unit !== 'undefined'){
-             tempObj.unit = pasteObj.unit;
-         }
-         if(typeof pasteObj.gljType !== 'undefined'){
-             let isExsit = false;
-             for(let i = 0; i < me.distTypeTree.comboDatas.length; i++){
-                 if(pasteObj.gljType === me.distTypeTree.comboDatas[i].text){
-                     isExsit = true;
-                     reCalBasePrc = true;
-                     tempObj.gljType = me.distTypeTree.comboDatas[i].value;
-                     tempObj.shortName = me.distTypeTree.distTypes[me.distTypeTree.prefix + tempObj.gljType].data.shortName;
+    },
+    onRangeChanged: function(sender, args) {
+        if (args.action == GC.Spread.Sheets.RangeChangedAction.clear) {
+            var me = repositoryGljObj, updateArr = [], removeArr = [], cancelArr = [], isMisCode = true;
+            var cacheSection = me.currentCache;
+            if (cacheSection) {
+                for (var i = 0; i < args.rowCount; i++) {
+                    let rObj = sheetCommonObj.combineRowData(me.workBook.getSheet(0), me.setting, args.row + i),
+                        isEmpty = sheetCommonObj.chkIfEmpty(rObj, me.setting);
+                    if(isEmpty){
+                        if(args.row + i < cacheSection.length){
+                            rObj.ID = cacheSection[args.row + i].ID
+                            removeArr.push(rObj.ID);
+                        }
+                    }
+                    else {
+                        if(!rObj.code){
+                            cancelArr.push(args.row + i);
+                        }
+                        else if(!rObj.gljType){
+                            isMisCode = false;
+                            cancelArr.push(args.row + i);
+                        }
+                        else{
+                            rObj.gljClass = me.gljCurTypeId;
+                            updateArr.push(rObj);
+                        }
+                    }
+                }
+                //reshow datas
+                function resetDatas(args, repositoryGljObj, cancelArr){
+                    args.sheet.options.isProtected = false;
+                    args.sheet.suspendPaint();
+                    for(let i =0; i <cancelArr.length; i++){
+                        for(let col =args.col; col< repositoryGljObj.setting.header.length; col++){
+                            let value = repositoryGljObj.setting.header[col].dataCode === 'gljType' ?
+                                repositoryGljObj.distTypeTree.distTypes[repositoryGljObj.distTypeTree.prefix + cacheSection[cancelArr[i]].gljType].data.fullName :
+                                cacheSection[cancelArr[i]][repositoryGljObj.setting.header[col].dataCode];
+                            args.sheet.setValue(args.row + i, col, value);
+                        }
+                    }
+                    args.sheet.resumePaint();
+                    args.sheet.setActiveCell(args.row, 0);
+                }
+                if(cancelArr.length > 0){
+                    let text = isMisCode === true ? "编号不可为空,编辑失败!": "类型不可为空,编辑失败!"
+                    $('#alertText').text(text);
+                    $('#codeAlertBtn').click();
+                    args.sheet.options.isProtected = true;
+                    $('#codAleConfBtn').click(function () {
+                        resetDatas(args, me, cancelArr);
+                    });
+                    $('#codAleClose').click(function () {
+                        resetDatas(args, me, cancelArr);
+                    });
+                }
+                let refGljIds = [], refGljCodes = [], alertText;
+                if(removeArr.length > 0){
+                    for(let i =0; i <removeArr.length; i++){
+                        if(me.rationGljIds.indexOf(removeArr[i]) !== -1){
+                            refGljIds.push(removeArr[i]);
+                            removeArr.splice(i--, 1);
+                        }
+                    }
+                    for(let i =0; i< me.currentCache.length; i++){
+                        for(let j=0; j< refGljIds.length; j++){
+                            if(me.currentCache[i].ID === refGljIds[j]){
+                                refGljCodes.push(me.currentCache[i].code);
+                            }
+                        }
+                    }
+                }
+                if(refGljIds.length > 0){
+                    if(refGljCodes.length > 3){
+                        alertText = "编号:" + refGljCodes[0]+" " + refGljCodes[1] + " " + refGljCodes[2] + "...等工料机已有定额引用,删除失败!";
+                    }
+                    else {
+                        let alertCode = " ";
+                        for(let i=0; i< refGljCodes.length; i++){
+                            alertCode += refGljCodes[i] + " ";
+                        }
+                        alertText = "编号:" + alertCode + "工料机已有定额引用,删除失败!"
+                    }
+                    $('#alertText').text(alertText);
+                    $('#codeAlertBtn').click();
+                    args.sheet.options.isProtected = true;
+                    $('#codAleConfBtn').click(function () {
+                        if(removeArr.length > 0){
+                            me.mixUpdateRequest(updateArr, [], removeArr);
+                        }
+                        else{
+                            let resetArr = [];
+                            for(let i=0; i<args.rowCount; i++){
+                                resetArr.push(args.row + i);
+                            }
+                            resetDatas(args, me, resetArr);
+                        }
+                    });
+                    $('#codAleClose').click(function () {
+                        if(removeArr.length > 0){
+                            me.mixUpdateRequest(updateArr, [], removeArr);
+                        }
+                        else{
+                            let resetArr = [];
+                            for(let i=0; i<args.rowCount; i++){
+                                resetArr.push(args.row + i);
+                            }
+                            resetDatas(args, me, resetArr);
+                        }
+                    });
+                }
+                else if(refGljIds.length === 0 && removeArr.length > 0){
+                    me.mixUpdateRequest(updateArr, [], removeArr);
+                }
+                if(updateArr.length > 0){
+                    me.mixUpdateRequest(updateArr, [], removeArr);
+                }
+            }
+        }
+    },
+    validUpdateObj: function (pasteObj, rowIdx) {
+        let rst = {}, backUpObj = {},
+            me = repositoryGljObj,
+            tempObj = me.currentCache[rowIdx],
+            reCalBasePrc = false, isValid = true;
+        //备份原始数据
+        for(let atr in tempObj){
+            backUpObj[atr] = tempObj[atr];
+        }
+        if(typeof pasteObj.code !== 'undefined'){
+            if(pasteObj.code.trim().length !== 0){
+                let isExist = false;
+                for(let i = 0; i < me.gljList.length; i++){
+                    if(me.gljList[i].code === pasteObj.code){
+                        isExist = true;
+                        break;
+                    }
+                }
+                if(!isExist){
+                    tempObj.code = pasteObj.code;
+                }
+                else isValid = false;
+            }
+            else isValid = false;
+        }
+        if(typeof pasteObj.name !== 'undefined'){
+            if(pasteObj.name.trim().length === 0) isValid = false;
+            else tempObj.name = pasteObj.name;
+        }
+        if(typeof pasteObj.specs !== 'undefined'){
+            tempObj.specs = pasteObj.specs;
+        }
+        if(typeof pasteObj.unit !== 'undefined'){
+            tempObj.unit = pasteObj.unit;
+        }
+        if(typeof pasteObj.gljType !== 'undefined'){
+            let isExsit = false;
+            for(let i = 0; i < me.distTypeTree.comboDatas.length; i++){
+                if(pasteObj.gljType === me.distTypeTree.comboDatas[i].text){
+                    isExsit = true;
+                    reCalBasePrc = true;
+                    tempObj.gljType = me.distTypeTree.comboDatas[i].value;
+                    tempObj.shortName = me.distTypeTree.distTypes[me.distTypeTree.prefix + tempObj.gljType].data.shortName;
 
-                 }
-             }
-             if(!isExsit) isValid = false;
-         }
-         //
-         pasteObj.basePrice = !isNaN(parseFloat(pasteObj.basePrice)) && (pasteObj.basePrice && typeof pasteObj.basePrice !== 'undefined') ? parseFloat(pasteObj.basePrice) :
-                                me.currentCache[rowIdx].basePrice;
-         if(pasteObj.basePrice !== me.currentCache[rowIdx].basePrice){
-             reCalBasePrc = true;
-             tempObj.basePrice = pasteObj.basePrice;
-         }
-         if(isValid){
-             rst.updateGlj = tempObj;
-             if(reCalBasePrc){
-                 //重新计算定额基价对象
-                 rst.updateBasePrc = {gljId: tempObj.ID, gljType: tempObj.gljType, basePrice: tempObj.basePrice};
-             }
-         }
-         else {
-             for(let attr in backUpObj){
-                 tempObj[attr] = backUpObj[attr];
-             }
-         }
-         return rst;
-     },
-     //粘贴的数据是否是可添加的数据,只有含有编号,名称,类型才可添加
-     isValidObj: function(pasteObj) {
+                }
+            }
+            if(!isExsit) isValid = false;
+        }
+        //
+        pasteObj.basePrice = !isNaN(parseFloat(pasteObj.basePrice)) && (pasteObj.basePrice && typeof pasteObj.basePrice !== 'undefined') ? parseFloat(pasteObj.basePrice) :
+            me.currentCache[rowIdx].basePrice;
+        if(pasteObj.basePrice !== me.currentCache[rowIdx].basePrice){
+            reCalBasePrc = true;
+            tempObj.basePrice = pasteObj.basePrice;
+        }
+        if(isValid){
+            rst.updateGlj = tempObj;
+            if(reCalBasePrc){
+                //重新计算定额基价对象
+                rst.updateBasePrc = {gljId: tempObj.ID, gljType: tempObj.gljType, basePrice: tempObj.basePrice};
+            }
+        }
+        else {
+            for(let attr in backUpObj){
+                tempObj[attr] = backUpObj[attr];
+            }
+        }
+        return rst;
+    },
+    //粘贴的数据是否是可添加的数据,只有含有编号,名称,类型才可添加
+    isValidObj: function(pasteObj) {
         let me = repositoryGljObj;
-         if(!(pasteObj.code && typeof pasteObj.code !== 'undefined') || !(pasteObj.name && typeof pasteObj.name !== 'undefined') ||
-         !(pasteObj.gljType && typeof pasteObj.gljType !== 'undefined')){
-             return false;
-         }
-         if(pasteObj.gljType && typeof pasteObj.gljType !== 'undefined'){
-             let isExist = false;
-             for(let i = 0; i < me.distTypeTree.comboDatas.length; i++){
-                 if(me.distTypeTree.comboDatas[i].text === pasteObj.gljType){
-                     isExist = true;
-                     pasteObj.gljType = me.distTypeTree.comboDatas[i].value;
-                     pasteObj.shortName = me.distTypeTree.distTypes[me.distTypeTree.prefix + pasteObj.gljType].data.shortName;
-                     break;
-                 }
-             }
-             if(!isExist){
-                 return false;
-             }
-         }
-         if(pasteObj.code && typeof pasteObj.code !== 'undefined'){
+        if(!(pasteObj.code && typeof pasteObj.code !== 'undefined') || !(pasteObj.name && typeof pasteObj.name !== 'undefined') ||
+            !(pasteObj.gljType && typeof pasteObj.gljType !== 'undefined')){
+            return false;
+        }
+        if(pasteObj.gljType && typeof pasteObj.gljType !== 'undefined'){
+            let isExist = false;
+            for(let i = 0; i < me.distTypeTree.comboDatas.length; i++){
+                if(me.distTypeTree.comboDatas[i].text === pasteObj.gljType){
+                    isExist = true;
+                    pasteObj.gljType = me.distTypeTree.comboDatas[i].value;
+                    pasteObj.shortName = me.distTypeTree.distTypes[me.distTypeTree.prefix + pasteObj.gljType].data.shortName;
+                    break;
+                }
+            }
+            if(!isExist){
+                return false;
+            }
+        }
+        if(pasteObj.code && typeof pasteObj.code !== 'undefined'){
             for(let i = 0; i < me.gljList.length; i++){
                 if(me.gljList[i].code === pasteObj.code){
                     return false;
                 }
             }
-         }
-         pasteObj.basePrice = !isNaN(parseFloat(pasteObj.basePrice)) && (pasteObj.basePrice && typeof pasteObj.basePrice !== 'undefined') ? parseFloat(pasteObj.basePrice) : 0;
-         pasteObj.gljClass = me.gljCurTypeId;
-         return true;
-     },
-     onClipboardPasting: function(sender, args) {
-         var me = repositoryGljObj;
-         /*if (args.cellRange.colCount != me.setting.header.length || me.gljCurTypeId < 0 || me.parentNodeIds["_pNodeId_" + me.gljCurTypeId]) {
-          args.cancel = true;
-          }*/
-         if (me.gljCurTypeId < 0 ) {
-             args.cancel = true;
-         }
-     },
+        }
+        pasteObj.basePrice = !isNaN(parseFloat(pasteObj.basePrice)) && (pasteObj.basePrice && typeof pasteObj.basePrice !== 'undefined') ? parseFloat(pasteObj.basePrice) : 0;
+        pasteObj.gljClass = me.gljCurTypeId;
+        return true;
+    },
+    onClipboardPasting: function(sender, args) {
+        var me = repositoryGljObj;
+        /*if (args.cellRange.colCount != me.setting.header.length || me.gljCurTypeId < 0 || me.parentNodeIds["_pNodeId_" + me.gljCurTypeId]) {
+         args.cancel = true;
+         }*/
+        if (me.gljCurTypeId < 0 ) {
+            args.cancel = true;
+        }
+    },
     onClipboardPasted: function(e, info) {
         var me = repositoryGljObj;
         var updateArr = [], addArr = [];
@@ -787,10 +787,10 @@ var pageOprObj = {
             info.sheet.resumePaint();
         }
         if (updateArr.length > 0 || addArr.length > 0) {
-           me.mixUpdateRequest(updateArr, addArr, []);
+            me.mixUpdateRequest(updateArr, addArr, []);
         }
         if(updateBasePrcArr.length > 0){
-           me.updateRationBasePrcRq(updateBasePrcArr);
+            me.updateRationBasePrcRq(updateBasePrcArr);
         }
     },
     updateRationBasePrcRq: function (basePrcArr) {
@@ -819,7 +819,7 @@ var pageOprObj = {
                 }
             }
         });
-     },
+    },
     mixUpdateRequest: function(updateArr, addArr, removeIds) {
         var me = repositoryGljObj;
         $.ajax({
@@ -853,21 +853,21 @@ var pageOprObj = {
             }
         })
     },
-     getParentCache: function (nodes) {
+    getParentCache: function (nodes) {
         let me = repositoryGljObj, rst = [];
         for(let i = 0; i < me.gljList.length; i++){
             if(nodes.indexOf(me.gljList[i].gljClass) !== -1){
                 rst.push(me.gljList[i]);
             }
         }
-         rst.sort(function (a, b) {
-             let rst = 0;
-             if(a.code > b.code) rst = 1;
-             else if(a.code < b.code)rst = -1;
-             return rst;
-         });
-         return rst;
-     },
+        rst.sort(function (a, b) {
+            let rst = 0;
+            if(a.code > b.code) rst = 1;
+            else if(a.code < b.code)rst = -1;
+            return rst;
+        });
+        return rst;
+    },
     getCache: function() {
         var me = this, rst = [];
         for (var i = 0; i < me.gljList.length; i++) {

+ 430 - 0
web/maintain/ration_repository/js/section_tree.js

@@ -15,6 +15,23 @@ var pageOprObj = {
             me.rationLibName = rationLibName;
             me.rationLibId = rationLibId;
             zTreeOprObj.getRationTree(rationLibId);
+            //job
+            jobContentOprObj.radiosChange(jobContentOprObj.radios, jobContentOprObj.tableAll, jobContentOprObj.tablePartial);
+            $('#addConBtn').click(jobContentOprObj.bindAddConBtn());
+            $('#updateConBtn').click(jobContentOprObj.bindUpdateConBtn());
+            $('#txtareaAll').bind('change', function () {
+                let met = this;
+                let jobContent = $(met).val();
+                $(met).attr('disabled', true);
+                let updateCodes = [];
+                for(let i = 0, len = jobContentOprObj.currentRationItems.length; i < len; i++){
+                    updateCodes.push(jobContentOprObj.currentRationItems[i].code);
+                }
+                jobContentOprObj.updateJobContent(me.rationLibId, jobContentOprObj.getUpdateArr(updateCodes, jobContent), function () {
+                    $(met).attr('disabled', false);
+                    jobContentOprObj.currentJobContent = jobContent;
+                })
+            });
         }
     }
 }
@@ -330,10 +347,14 @@ var zTreeOprObj = {
         explanatoryOprObj.setAttribute(explanatoryOprObj.currentTreeNode ? explanatoryOprObj.currentTreeNode : treeNode, treeNode, treeNode.explanation, treeNode.ruleText);
         explanatoryOprObj.clickUpdate($('#explanationShow'), $('#ruleTextShow'));
         explanatoryOprObj.showText($('#explanationShow'), $('#ruleTextShow'), treeNode.explanation, treeNode.ruleText);
+        jobContentOprObj.currentSituation = typeof treeNode.jobContentSituation !== 'undefined'? treeNode.jobContentSituation : jobContentOprObj.situations.NONE;
         var sectionID = treeNode.ID;
         if (!(treeNode.items) || treeNode.items.length == 0) {
+            jobContentOprObj.setRadiosDisabled(false, jobContentOprObj.radios);
             rationOprObj.getRationItems(sectionID);
         } else {
+            jobContentOprObj.setRadiosDisabled(true, jobContentOprObj.radios);
+            jobContentOprObj.hideTable($('#tableAll'), $('#tablePartial'));
             sheetCommonObj.cleanSheet(rationOprObj.workBook.getSheet(0), rationOprObj.setting, -1);
             sheetCommonObj.shieldAllCells(rationOprObj.workBook.getSheet(0));
         }
@@ -433,3 +454,412 @@ let explanatoryOprObj = {
         });
     }
 };
+
+//工作内容
+let jobContentOprObj = {
+    situations: {ALL: 'ALL', PARTIAL: 'PARTIAL', NONE: 'NONE'},//所有ALL(包括未定义本项工作内容)、部分PARTIA,不可用NONE(非章节树最底层节点时)
+    currentSituation: null,//本项适用情况
+    radios: $("input[name = 'optionsRadios']"),
+    tableAll: $('#tableAll'),
+    tablePartial: $('#tablePartial'),
+    currentOprTr: null,
+    currentJobContent: null,
+    currentRationItems: null,
+    addCon: $('#addCon'),//勾选编码模态框
+    updateCon: $('#updateCon'),//编辑编码模态框
+    //获取本项适用情况
+    getSituation: function (rationItems) {
+        let me = this;
+        let rst = me.situations.ALL;
+        if(rationItems.length > 1){
+            for(let i = 0, len = rationItems.length; i < len; i++){
+                for(let j = i + 1, len = rationItems.length; j < len; j++){
+                    if(typeof rationItems[i].jobContent !== 'undefined' && rationItems[i].jobContent !== rationItems[j].jobContent){
+                        rst = me.situations.PARTIAL;
+                        break;
+                    }
+                }
+            }
+        }
+        return rst;
+    },
+    getGroup: function (rationItems) {
+        let rst = [];//rst = [{jobContent: String, items: Array}]
+        for(let i = 0, len = rationItems.length; i < len; i++){
+            if(typeof rationItems[i].jobContent !== 'undefined' && rationItems[i].jobContent.toString().trim().length > 0){
+                let isExist = false;
+                for(let j = 0, jLen = rst.length; j < jLen; j++){
+                    if(rst[j].jobContent === rationItems[i].jobContent){
+                        isExist = true;
+                        rst[j].items.push(rationItems[i].code);
+                        break;
+                    }
+                }
+                if(!isExist){
+                    rst.push({jobContent: rationItems[i].jobContent, items: [rationItems[i].code]});
+                }
+            }
+        }
+        return rst;
+    },
+    hideTable: function (tableAll, tablePartial) {
+        if(tableAll){
+            tableAll.hide();
+        }
+        if(tablePartial){
+            tablePartial.hide();
+        }
+    },
+    //建table
+    buildTablePartial: function (table, group) {
+        let me = jobContentOprObj;
+        table.empty();
+        let $thead = $("<thead><tr><th></th><th>编码</th><th>工作内容</th>/tr></thead>");
+        let $tbody = $("<tbody></tbody>");
+        let count = 1;
+        for(let i = 0, len = group.length; i < len; i++){
+            let $newTr = me.getNewTr($tbody, group[i].items, group[i].jobContent);
+            $tbody.append($newTr);
+            count++;
+        }
+        let $trEnd = $("<tr><td>"+ count +"</td><td><a href data-toggle='modal' data-target='#editBianma' class='m-0'>点击勾选编码</a></td><td><textarea class='form-control'></textarea></td></tr>");//勾选行
+        $($trEnd.children().children()[0]).bind('click', function () {
+           me.onclickFuncAdd($(this));
+            me.currentOprTr = $trEnd;
+            me.currentJobContent = $(me.currentOprTr.children()[2]).children().val();
+        });
+        $tbody.append($trEnd);
+        table.append($thead);
+        table.append($tbody);
+    },
+    //新增一行tr
+    getNewTr: function (tbody, codes, jobContent) {
+        let me = jobContentOprObj;
+        let count = tbody.children().length > 0 ? tbody.children().length : 1;
+        let $textTd = $("<td></td>");
+        let $textarea = $("<textarea class='form-control'></textarea>");
+        $textarea.val(jobContent);
+        $textTd.append($textarea);
+        let $tr = $("<tr><td>" + count + "</td><td><a href data-toggle='modal' data-target='#editBianmaQ' class='m-0'>编辑编码</a></td></tr>");
+        $tr.children().children().bind('click', function () {
+            me.currentOprTr = $tr;
+            me.currentJobContent = $(me.currentOprTr.children()[2]).children().val();
+            me.onclickFuncEdit($(this));
+        });
+        //文本变化;
+        $textarea.bind('change', function () {
+            let codes = me.getUpdateCodes($($(this).parent().parent().children()[1]).children());
+            let jobContent = $(this).val();
+            me.updateJobContent(pageOprObj.rationLibId, me.getUpdateArr(codes, jobContent), function () {
+                if(jobContent.trim().length === 0){
+                    me.buildTablePartial(me.tablePartial, me.getGroup(me.currentRationItems));
+                }
+            });
+        });
+        $tr.append($textTd);
+        for(let i = 0, len = codes.length; i < len; i ++){
+            let $p = $("<p class='m-0'>" + codes[i] + "</p>");
+            $tr.children()[1].append($p[0]);
+        }
+        me.setTextareaHeight($textarea, codes.length + 1);
+        return $tr[0];
+    },
+    onclickFuncAdd: function (obj) {
+        let me = jobContentOprObj;
+        let txtarea = $(obj.parent().parent().children().children()[1]);
+        let jobContent = txtarea.val();
+        if(jobContent.trim().length > 0){//工作内容不为空才可添加编码
+            let codesObj = me.getAddCodes(me.currentRationItems);
+            me.buildCheckCodesCon(me.addCon, codesObj.checkedCodes, codesObj.disabledCodes)
+            obj.attr('data-target', '#editBianma');
+        }
+        else{
+            obj.attr('data-target', '');
+            alert("工作内容不能为空!");
+        }
+    },
+    onclickFuncEdit: function (obj) {
+        let me = jobContentOprObj;
+        me.buildEditableCodesCon(me.currentRationItems, me.updateCon, me.getUpdateCodes(obj));
+    },
+    //更新显示的编码table
+    updateCodesTable: function (table, codes) {
+        let me = jobContentOprObj;
+        table.empty();
+        table.append("<a href data-toggle='modal' data-target='#editBianmaQ' class='m-0'>编辑编码</a>");
+        table.children().bind('click', function (){
+            me.currentOprTr = table.parent();
+            me.currentJobContent = $(me.currentOprTr.children()[2]).children().val();
+            me.onclickFuncEdit($(this));
+        });
+        for(let i = 0, len = codes.length; i < len; i++){
+            let $p = $("<p class='m-0'>" + codes[i] + "</p>");
+            table.append($p[0]);
+        }
+    },
+    //获取编码td中的编码
+    getUpdateCodes: function (jq) {
+        let rst = [];
+        let nodes = jq.parent().children();
+        for(let i = 1, len = nodes.length; i < len; i++){
+            rst.push(nodes[i].textContent);
+        }
+        return rst;
+    },
+    //建一个编码checkbox Div
+    buildCodeOption: function (code, attr) {
+        let $div = $("<div class='col'><label class='form-check-label'><input class='form-check-input' type='checkbox' value= "+ code +"> "+ code +"</label></div>");
+        let $checkBox = $div.children().children();
+        if(attr){
+            $checkBox.attr(attr, true);
+        }
+        return $div;
+    },
+    //建修改编码弹窗
+    buildEditableCodesCon: function (rationItems, container,codes) {
+        let me = jobContentOprObj;
+        let codeDivs = [];
+        container.empty();
+        for(let i = 0, len = codes.length; i < len; i++){
+            codeDivs.push({code: codes[i], attr: 'checked'});
+        }
+        for(let i = 0, len = rationItems.length; i < len; i++){
+            if(codes.indexOf(rationItems[i].code) === -1){
+                if(typeof rationItems[i].jobContent !== 'undefined' && rationItems[i].jobContent.toString().trim().length > 0){
+                    codeDivs.push({code: rationItems[i].code, attr: 'disabled'});
+                }
+                else{
+                    codeDivs.push({code: rationItems[i].code, attr: ''});
+                }
+            }
+        }
+        //排序
+        codeDivs.sort(function (a, b) {
+            let rst = 0;
+            if(a.code > b.code) rst = 1;
+            else if(a.code < b.code) rst = -1;
+            return rst;
+        });
+        for(let i = 0, len = codeDivs.length; i < len; i++){
+            container.append(me.buildCodeOption(codeDivs[i].code, codeDivs[i].attr));
+        }
+    },
+    //建勾选编码弹窗
+    buildCheckCodesCon: function (container, checkedCodes, disabledCodes) {
+        let me = jobContentOprObj;
+        container.empty();
+        for(let i = 0, len = checkedCodes.length; i < len; i++){
+            let $codeDiv = me.buildCodeOption(checkedCodes[i], 'checked');
+            container.append($codeDiv);
+        }
+        for(let i = 0, len = disabledCodes.length; i < len; i++){
+            let $codeDiv = me.buildCodeOption(disabledCodes[i], 'disabled');
+            container.append($codeDiv);
+        }
+    },
+    getAddCodes: function (rationItems) {
+        let me = jobContentOprObj;
+        let rst = {checkedCodes: [], disabledCodes: []};
+        for(let i = 0, len = rationItems.length; i < len; i++){
+            if(typeof rationItems[i].jobContent !== 'undefined' && rationItems[i].jobContent.toString().trim().length > 0){
+                rst.disabledCodes.push(rationItems[i].code);
+            }
+            else{
+                rst.checkedCodes.push(rationItems[i].code);
+            }
+        }
+        return rst;
+    },
+    //获取选择后的编码窗口的编码及状态
+    getCodesAfterS: function (checkNodes) {
+        let rst = {checked: [], unchecked: []};
+        for(let i = 0, len = checkNodes.length; i < len; i++){
+            if(checkNodes[i].checked){
+                rst.checked.push(checkNodes[i].value);
+            }
+            else if(!checkNodes[i].checked && !checkNodes[i].disabled){
+                rst.unchecked.push(checkNodes[i].value);
+            }
+        }
+        return rst;
+    },
+    setRadiosChecked: function (situation, radios) {
+        let me = jobContentOprObj;
+        if(situation === me.situations.ALL){
+            radios[0].checked = true;
+            radios[1].checked = false;
+            $('#txtareaAll').val(me.currentRationItems.length > 0 ? me.currentRationItems[0].jobContent : '');
+            me.currentJobContent = me.currentRationItems[0].jobContent;
+            me.tableAll.show();
+            me.tablePartial.hide();
+        }
+        else if(situation === me.situations.PARTIAL){
+            radios[0].checked = false;
+            radios[1].checked = true;
+            me.tableAll.hide();
+            me.tablePartial.show();
+        }
+        else if(situation === me.situations.NONE){
+            radios[0].checked = false;
+            radios[1].checked = false;
+            me.tableAll.hide();
+            me.tablePartial.hide();
+        }
+    },
+    //radios是否可用,只有在定额章节树的底层节点才可用
+    setRadiosDisabled: function (val, radios) {
+        let me =jobContentOprObj;
+        if(val){
+            radios[0].checked = false;
+            radios[1].checked = false;
+            me.currentSituation = me.situations.NONE;
+        }
+        radios.attr('disabled', val);
+    },
+    radiosChange: function (radios, tableAll, tablePartial) {
+        let me = jobContentOprObj;
+        radios.change(function () {
+            let val = $("input[name = 'optionsRadios']:checked").val();
+            let selectedNode = zTreeOprObj.treeObj.getSelectedNodes()[0];
+            me.updateSituation(pageOprObj.rationLibId, selectedNode.ID, val, function () {
+                selectedNode.jobContentSituation = val;
+                me.currentSituation = val;
+                if(val === me.situations.ALL){
+                    let updateCodes = [];
+                    for(let i = 0, len = me.currentRationItems.length; i < len; i++){
+                        updateCodes.push(me.currentRationItems[i].code);
+                    }
+                    me.updateJobContent(pageOprObj.rationLibId, me.getUpdateArr(updateCodes, ''), function () {
+                        me.currentJobContent = '';
+                        $('#txtareaAll').val('');
+                        tableAll.show();
+                        tablePartial.hide();
+                    });
+                }
+                else{
+                    me.buildTablePartial(me.tablePartial, me.getGroup(me.currentRationItems));
+                    tableAll.hide();
+                    tablePartial.show();
+                }
+            });
+        });
+    },
+    sortRationItems: function (rationItems, field) {
+        rationItems.sort(function (a, b) {
+            let rst = 0;
+            if(a[field] > b[field]){
+                rst = 1;
+            }
+            else if (a[field] < b[field]){
+                rst = -1;
+            }
+            return rst;
+        });
+    },
+    addCodeNode: function (container, codeNode) {
+        container.append(codeNode);
+    },
+    setTextareaHeight: function (textarea, nodesCount) {
+        const perHeight = 21.6;
+        textarea.height(nodesCount * 21.6);
+    },
+    bindEvents: function (txtarea) {
+        let me = jobContentOprObj;
+        txtarea.bind('change', function () {
+            let jobContent = txtarea.val();
+            let jqNodes = txtarea.parent().parent().children()[1].children;
+            let updateCodes = me.getUpdateCodes(jqNodes);
+            txtarea.attr('disabled', true);
+            me.updateJobContent(pageOprObj.rationLibId, me.getUpdateArr(updateCodes, jobContent), function () {
+                txtarea.attr('disabled', false);
+            });
+        });
+    },
+    unbindEvetns: function (txtarea) {
+        txtarea.unbind();
+    },
+    //定额工作内容相关操作
+    rationJobContentOpr: function (rationItems) {
+        let me = jobContentOprObj;
+        me.setRadiosChecked(me.currentSituation, me.radios);
+        me.buildTablePartial(me.tablePartial, me.getGroup(rationItems));
+    },
+    getUpdateArr: function (updateCodes, jobContent) {
+        let rst = [];
+        for(let i = 0, len = updateCodes.length; i < len; i++){
+            rst.push({code: updateCodes[i], jobContent: jobContent});
+        }
+        return rst;
+    },
+    bindAddConBtn: function () {
+        let me = jobContentOprObj;
+        return function () {
+            let codesObj = me.getCodesAfterS(me.addCon.children().children().children());
+            let $tbody = $('#tablePartial tbody');
+            let lastEle = $tbody[0].lastElementChild;
+            let txtare = lastEle.lastElementChild.children[0];
+            if(me.currentJobContent.trim().length > 0){//工作内容不为空才可添加编码
+                let updateArr = me.getUpdateArr(codesObj.checked, me.currentJobContent);
+                me.updateJobContent(pageOprObj.rationLibId, updateArr, function () {
+                    me.buildTablePartial(me.tablePartial, me.getGroup(me.currentRationItems));
+                    $(txtare).val('');
+                });
+            }
+            else{
+                alert("工作内容不能为空!");
+            }
+        }
+    },
+    bindUpdateConBtn: function () {
+        let me = jobContentOprObj;
+        return function () {
+            let codesObj = me.getCodesAfterS(me.updateCon.children().children().children());
+            let updateC = me.getUpdateArr(codesObj.checked, me.currentJobContent),
+                updateUnC = me.getUpdateArr(codesObj.unchecked, ''),
+                updateArr = updateC.concat(updateUnC);
+            me.updateJobContent(pageOprObj.rationLibId, updateArr, function () {
+                me.buildTablePartial(me.tablePartial, me.getGroup(me.currentRationItems));
+            });
+        }
+    },
+    //更新缓存的定额
+    updateRationItem: function (rationItems, updateArr) {
+        for(let i = 0, len = rationItems.length; i < len; i++){
+            for(let j = 0, jLen = updateArr.length; j < jLen; j++){
+                if(rationItems[i].code === updateArr[j].code){
+                    rationItems[i].jobContent = updateArr[j].jobContent;
+                    break;
+                }
+            }
+        }
+    },
+    updateJobContent: function (repId, updateArr, callback){
+        let me = jobContentOprObj;
+        $.ajax({
+            type: 'post',
+            url: 'api/updateJobContent',
+            data: {lastOpr: userAccount, repId: repId, updateArr: JSON.stringify(updateArr)},
+            dataType: 'json',
+            success: function (result) {
+                if(!result.error){
+                    me.updateRationItem(me.currentRationItems, updateArr);
+                    callback();
+                }
+            }
+        });
+    },
+    updateSituation: function (repId, nodeId, situation, callback) {
+        let me = jobContentOprObj;
+        $.ajax({
+            type: 'post',
+            url: 'api/updateSituation',
+            data: {lastOpr: userAccount, repId: repId, nodeId: nodeId, situation: situation},
+            dataType: 'json',
+            success: function (result) {
+                if(!result.error){
+                    callback();
+                }
+            }
+        })
+    }
+};

+ 8 - 3
web/maintain/std_glj_lib/js/main.js

@@ -3,7 +3,7 @@
  */
 $(function () {
     let dispNameArr;
-    getAllGljLib(function (dispNames) {
+    getAllGljLib(function (dispNames, compilationsUsedArr) {
         dispNameArr = dispNames;
         //添加
         $('#addBtn').click(function () {
@@ -14,6 +14,10 @@ $(function () {
                 alert('名称不可为空!');
                 $('#libNameTxt').val('')
             }
+            else if(compilationsUsedArr.indexOf(compilationId) !== -1){// compilationsUsedArr;//在该编办下已建库,限制一个编办只能有一个库
+                alert('该编办已被绑定!');
+                $('#libNameTxt').val('')
+            }
             else if(dispNames.indexOf(libName) !== -1){
                 alert('此工料机库已存在!');
                 $('#libNameTxt').val('')
@@ -80,8 +84,10 @@ function getAllGljLib(callback){
         dataType: 'json',
         success: function (result) {
             let dispNames = [];
+            let compilationsUsedArr = [];
             if(result.data.length > 0){
                 for(let i = 0; i < result.data.length; i++){
+                    compilationsUsedArr.push(result.data[i].compilationId);//已建库的编办
                     let id = result.data[i].ID;
                     let libName = result.data[i].dispName;
                     let createDate = result.data[i].createDate.split(' ')[0];
@@ -106,7 +112,7 @@ function getAllGljLib(callback){
                     $("#tempId").attr("id", id);
                 }
             }
-            callback(dispNames);
+            callback(dispNames, compilationsUsedArr);
         }
     });
 }
@@ -134,7 +140,6 @@ function createGljLib(gljLibObj, dispNamesArr){
         data: {gljLibObj: JSON.stringify(gljLibObj)},
         dataType: 'json',
         success: function (result) {
-            console.log(result);
             if(result.data){
                 let id = result.data.ID;
                 let libName = result.data.dispName;