Explorar el Código

Merge branch 'dev' of http://192.168.1.41:3000/maixinrong/Calculation into dev

TonyKang hace 4 años
padre
commit
31a4c38c47
Se han modificado 2 ficheros con 61 adiciones y 5 borrados
  1. 60 4
      app/public/js/material_exponent.js
  2. 1 1
      app/view/measure/stage.ejs

+ 60 - 4
app/public/js/material_exponent.js

@@ -205,8 +205,14 @@ $(document).ready(() => {
             if (info.sheet.zh_setting) {
                 const select = SpreadJsObj.getSelectObject(info.sheet);
                 const col = info.sheet.zh_setting.cols[info.col];
-                if (materialExponentCol.readOnly.isEdit(select)) {
-                    return;
+                if (col.field === 'weight_num') {
+                    if(materialExponentCol.readOnly.isConstant(select)) {
+                        return;
+                    }
+                } else {
+                    if(materialExponentCol.readOnly.isEdit(select)) {
+                        return
+                    }
                 }
                 if (col.field === 'is_summary') {
                     if (info.sheet.isEditing()) {
@@ -227,7 +233,58 @@ $(document).ready(() => {
             }
         },
         deletePress: function (sheet) {
-            return;
+            if (sheet.zh_setting && sheet.zh_data) {
+                const sel = sheet.getSelections()[0];
+                if (!sel) return;
+                const sortData = sheet.zh_data || [];
+                const data = [];
+                for (let iRow = sel.row; iRow < sel.row + sel.rowCount; iRow++) {
+                    // let bPaste = true;
+                    const exData = sortData[iRow];
+                    const materialExData = { id: sortData[iRow].id };
+                    for (let iCol = 0; iCol < sel.colCount; iCol++) {
+                        const curCol = sel.col + iCol;
+                        const colSetting = sheet.zh_setting.cols[curCol];
+                        if (!colSetting) continue;
+                        const orgValue = sortData[iRow][colSetting.field];
+                        if(orgValue === null) {
+                            // bPaste = false;
+                            continue;
+                        }
+                        if (exData.type === materialType.ex_type[0].value && colSetting.field !== 'weight_num') {
+                            // bPaste = false;
+                            continue;
+                        }
+                        if (colSetting.field === 'type' || colSetting.field === 'calc_num' || colSetting.field === 'is_summary'){
+                            // bPaste = false;
+                            continue;
+                        }
+                        materialExData[colSetting.field] = null;
+                        sortData[iRow][colSetting.field] = null;
+                    }
+                    if (exData.type !== materialType.ex_type[0].value) materialExData.calc_num = materialExponentCol.getValue.calc_num(sortData[iRow]);
+                    const arr = Object.keys(materialExData);
+                    if (arr.length !== 1) {
+                        data.push(materialExData);
+                    }
+                }
+                if (data.length === 0) {
+                    SpreadJsObj.reLoadSheetData(sheet);
+                    return;
+                }
+                // console.log(data);
+                // 更新至服务器
+                postData(window.location.pathname + '/save', { type:'paste', updateData: data }, function (result) {
+                    materialExponentData = result.info;
+                    SpreadJsObj.loadSheetData(materialExponentSpread.getActiveSheet(), SpreadJsObj.DataType.Data, materialExponentData);
+                    ex_tp = result.ex_tp;
+                    ex_expr = result.ex_expr;
+                    resetExTpTable();
+                }, function () {
+                    SpreadJsObj.reLoadSheetData(sheet);
+                    return;
+                });
+            }
         },
         clipboardPasted(e, info) {
             const hint = {
@@ -302,7 +359,6 @@ $(document).ready(() => {
                             continue;
                         }
                         const total_weight = ZhCalc.add(ZhCalc.sub(_.sumBy(materialExponentData, 'weight_num'), parseFloat(orgValue)), num);
-                        console.log(total_weight, _.sumBy(materialExponentData, 'weight_num'), orgValue, num);
                         if (total_weight > 1) {
                             toastMessageUniq(getPasteHint(hint.weightNumberCan, hintRow));
                             bPaste = false;

+ 1 - 1
app/view/measure/stage.ejs

@@ -9,7 +9,7 @@
             <div class="ml-auto">
                 <% if (ctx.session.sessionUser.accountId === ctx.tender.data.user_id && ctx.tender.data.ledger_status === auditConst.status.checked &&
                         (stages.length === 0 || stages[0].status === auditConst.status.checked)) { %>
-                <% if ((ctx.helper.checkZero(ctx.tender.info.deal_param.contractPrice) || ctx.helper.checkZero(ctx.tender.info.deal_param.startAdvance)) && stages.length === 0) { %>
+                <% if (ctx.helper.checkZero(ctx.tender.info.deal_param.contractPrice) && stages.length === 0) { %>
                     <a href="#add-qi" data-toggle="modal" data-target="#tips" class="btn btn-primary btn-sm pull-right">开始新一期</a>
                 <% } else { %>
                     <a href="#add-qi" data-toggle="modal" data-target="#add-qi" class="btn btn-primary btn-sm pull-right">开始新一期</a>