Explorar o código

变更令清单delete按钮移除数量

ellisran hai 8 meses
pai
achega
7b302645fe

+ 17 - 3
app/controller/change_controller.js

@@ -678,12 +678,26 @@ module.exports = app => {
                         const changeList = await ctx.service.changeAuditList.getList(ctx.change.cid);
                         const auditList2 = await ctx.service.changeAudit.getListGroupByTimes(ctx.change.cid, ctx.change.times);
                         // changeList = JSON.parse(JSON.stringify(changeList.sort())).sort().sort();
+                        // for (const cl of changeList) {
+                        //     const audit_amount = cl.audit_amount !== null && cl.audit_amount !== '' ? cl.audit_amount.split(',') : '';
+                        //     // 清单表页赋值
+                        //     for (const [index, au] of auditList2.entries()) {
+                        //         if (au.usite !== 0) {
+                        //             cl['audit_amount_' + au.uid] = au.uid === ctx.session.sessionUser.accountId ? cl.spamount : (audit_amount[index - 1] ? audit_amount[index - 1] : null);
+                        //         }
+                        //     }
+                        // }
                         for (const cl of changeList) {
                             const audit_amount = cl.audit_amount !== null && cl.audit_amount !== '' ? cl.audit_amount.split(',') : '';
                             // 清单表页赋值
-                            for (const [index, au] of auditList2.entries()) {
-                                if (au.usite !== 0) {
-                                    cl['audit_amount_' + au.uid] = au.uid === ctx.session.sessionUser.accountId ? cl.spamount : (audit_amount[index - 1] ? audit_amount[index - 1] : null);
+                            for (const au in ctx.change.userGroups) {
+                                if (ctx.change.userGroups[au][0].audit_order !== 0) {
+                                    cl['audit_amount_' + ctx.change.userGroups[au][0].audit_order] =
+                                        (ctx.change.userGroups[au][0].audit_type === auditType.key.and &&
+                                            ctx.helper._.findIndex(ctx.change.userGroups[au], { status: audit.change.status.checking }) !== -1 &&
+                                            ctx.helper._.findIndex(ctx.change.userGroups[au], { uid: ctx.session.sessionUser.accountId, status: audit.change.status.checked }) !== -1) ||
+                                        (ctx.change.shenpiPower && ctx.helper._.findIndex(ctx.change.userGroups[au], { uid: ctx.session.sessionUser.accountId }) !== -1) ?
+                                            cl.spamount : (audit_amount[au - 1] !== undefined ? parseFloat(audit_amount[au - 1]) : null);
                                 }
                             }
                         }

+ 36 - 1
app/public/js/change_information_approval.js

@@ -70,7 +70,7 @@ $(document).ready(() => {
             title: (audit && audit.length > 1 ? (aid + '审') : audit[0].name) + ' 审批|数量',
             colSpan: '2|1', rowSpan: '1|1',
             field: 'audit_amount_' + aid,
-            hAlign: 2, width: 60, type: 'Number', readOnly: _.findIndex(auditors2[aid - 1], { uid: parseInt(accountId) }) === -1 ? true : 'readOnly.isSettle' ,
+            hAlign: 2, width: 60, type: 'Number', readOnly: _.findIndex(audit, { uid: parseInt(accountId) }) === -1 ? true : 'readOnly.isSettle' ,
         };
         const newColTp = {
             title: '|金额',
@@ -222,6 +222,41 @@ $(document).ready(() => {
             }
         },
         deletePress: function (sheet) {
+            if (!sheet.zh_setting) return;
+            // 暂时仅支持移除数量
+            const sel = sheet.getSelections()[0], datas = [];
+            for (let iRow = sel.row; iRow < sel.row + sel.rowCount; iRow++) {
+                let bDel = false;
+                const node = sheet.zh_data[iRow];
+                const data = { id: node.id };
+                for (let iCol = sel.col; iCol < sel.col + sel.colCount; iCol++) {
+                    const col = sheet.zh_setting.cols[iCol];
+                    if (col.field === 'oamount2' || (col.readOnly !== true && _.includes(col.field, 'audit_amount_') && !checkIsSettle(node))) {
+                        // node[col.field] = null;
+                        if (col.field !== 'oamount2') {
+                            data.spamount = null;
+                        } else {
+                            data[col.field] = null;
+                        }
+                        bDel = true;
+                    }
+                }
+                if (bDel) datas.push(data);
+            }
+            if (datas.length > 0) {
+                // 更新至服务器
+                postData(window.location.pathname + '/save', { type:'paste_amount_rows', updateData: datas }, function (result) {
+                    changeList = result;
+                    changeSpreadObj.setAuditValue();
+                    SpreadJsObj.loadSheetData(changeSpreadSheet, SpreadJsObj.DataType.Data, changeList);
+                    changeSpreadObj.makeSjsFooter();
+                    changeSpreadObj.resetXmjSpread(SpreadJsObj.getSelectObject(changeSpreadSheet));
+                }, function () {
+                    changeSpreadObj.setAuditValue();
+                    SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
+                    return;
+                });
+            }
             return;
         },
         editEnded: function (e, info) {

+ 31 - 0
app/public/js/change_information_set.js

@@ -463,6 +463,37 @@ $(document).ready(() => {
             // setObjEnable($('#add-white-btn'), !readOnly && select && changeList.indexOf(select) !== -1);
         },
         deletePress: function (sheet) {
+            if (!sheet.zh_setting) return;
+            // 暂时仅支持移除数量
+            const sel = sheet.getSelections()[0], datas = [];
+            for (let iRow = sel.row; iRow < sel.row + sel.rowCount; iRow++) {
+                let bDel = false;
+                const node = sheet.zh_data[iRow];
+                for (let iCol = sel.col; iCol < sel.col + sel.colCount; iCol++) {
+                    const col = sheet.zh_setting.cols[iCol];
+                    if (col.field === 'camount' || col.field === 'oamount2') {
+                        node[col.field] = null;
+                        if (col.field === 'camount') {
+                            node.camount_expr = '';
+                            node.spamount = null;
+                        }
+                        delete node.waitingLoading;
+                        bDel = true;
+                    }
+                }
+                if (bDel) datas.push(node);
+            }
+            if (datas.length > 0) {
+                postData(window.location.pathname + '/save', { type:'paste', updateData: datas }, function (result) {
+                    changeList = result;
+                    SpreadJsObj.loadSheetData(changeSpreadSheet, SpreadJsObj.DataType.Data, changeList);
+                    changeSpreadObj.makeSjsFooter();
+                    changeSpreadObj.resetXmjSpread(SpreadJsObj.getSelectObject(changeSpreadSheet));
+                }, function () {
+                    SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
+                    return;
+                });
+            }
             return;
         },
         editEnded: function (e, info) {