| | |
| | | } |
| | | } |
| | | |
| | | columns.push({ field: 'ææè®¡åå计', title: 'ææè®¡åå计', filter: true }); |
| | | columns.push({ |
| | | field: 'ææè®¡åå计', title: 'ææè®¡åå计', filter: true }); |
| | | |
| | | option = { |
| | | elem: '#mainTable' |
| | |
| | | data: { "sWhere": sWhere, "user": sessionStorage["HUserName"] }, |
| | | success: function (result) { |
| | | if (result.count == 1) { |
| | | option.data = result.data; |
| | | option.data = addTotalField(result.data); |
| | | //å设置 |
| | | DisPlay_HideColumnForPlan(HModName, sessionStorage["HUserName"], option); |
| | | ins = table.render(option); |
| | |
| | | |
| | | form.render('select'); |
| | | } |
| | | function addTotalField(arr) { |
| | | return arr.map(obj => { |
| | | // å建æ°å¯¹è±¡ï¼é¿å
ä¿®æ¹å对象 |
| | | const newObj = { ...obj }; |
| | | |
| | | // 计ç®ç¬¦åæ¥ææ ¼å¼çåæ®µå¼çå计 |
| | | let total = 0; |
| | | for (const [key, value] of Object.entries(obj)) { |
| | | if (isValidDate(key)) { |
| | | // ç¡®ä¿å¼æ¯æ°åç±»å |
| | | const numValue = Number(value); |
| | | if (!isNaN(numValue)) { |
| | | total += numValue; |
| | | } |
| | | } |
| | | } |
| | | // å¤çæµ®ç¹æ°ç²¾åº¦é®é¢ |
| | | const roundedTotal = parseFloat(total.toFixed(2)); |
| | | |
| | | // æ·»å ææè®¡ååè®¡åæ®µ |
| | | newObj['ææè®¡åå计'] = roundedTotal; |
| | | |
| | | return newObj; |
| | | }); |
| | | } |
| | | |
| | | //#endregion |
| | | //以䏿¯layui模å |
| | | }); |