| package.json | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| src/components/Excel/luckysheet.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| src/utils/inspectionValueFormat.js | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| src/views/business/inspectionTask/inspection.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| src/views/standard/model/index.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
package.json
@@ -34,6 +34,7 @@ "html2canvas": "^1.4.1", "js-beautify": "1.15.4", "js-cookie": "3.0.5", "jsbarcode": "^3.12.3", "jsencrypt": "3.3.2", "jspdf": "^2.5.2", "mammoth": "^1.13.0", src/components/Excel/luckysheet.vue
@@ -51,6 +51,13 @@ mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1024 1024'%3E%3Cpath d='M512 64a448 448 0 1 1 0 896 448 448 0 0 1 0-896m0 192a58.43 58.43 0 0 0-58.24 63.744l23.36 256.384a35.072 35.072 0 0 0 69.76 0l23.296-256.384A58.43 58.43 0 0 0 512 256m0 512a51.2 51.2 0 1 0 0-102.4 51.2 51.2 0 0 0 0 102.4'/%3E%3C/svg%3E") center/contain no-repeat; } /* Luckysheet çå·¥å ·æ 䏿èåï¼æ¹æ³¨ãåä½é¢è²çï¼æ¯æå¨ body ä¸çï¼ é»è®¤ z-index åªæ 1004ï¼ä¸é¢ #luckysheet æ¬å°äº 99999ï¼ä¼æè¿äºèåæ´ä¸ªçä½ï¼ 表ç°ä¸ºâç¹æ¹æ³¨æ²¡ååºâãæ body 级è忬å°å®¹å¨ä¹ä¸ã */ .luckysheet-cols-menu { z-index: 100001 !important; } #luckysheet .save:hover { opacity: 0.8; } src/utils/inspectionValueFormat.js
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,58 @@ /** * è§£æåå§è®°å½æ¨¡æ¿ä¸çæ£éªå¼æ¹æ³¨ã * å ¼å®¹æ§æ ¼å¼âæ£éªå¼âï¼å¹¶æ¯æï¼æ£éªå¼ï¼2ãæ£éªå¼ï¼2ï¼ç§å¦è®¡æ°æ³ã */ export function parseInspectionValueAnnotation(annotation) { if (typeof annotation !== 'string' || !annotation.includes('æ£éªå¼')) return null; // æ¹æ³¨å è®¸ä¸æéå·ãè±æéå·ä»¥åâåâè¿æ¥æ ¼å¼åæ°ã const parts = annotation .replace(/ï¼/g, ',') .replace(/\s+/g, '') .replace(/å/g, ',') .split(',') .map(item => item.trim()) .filter(Boolean); const decimalPlaces = parts[1] === '' || parts[1] == null ? null : Number(parts[1]); if (decimalPlaces != null && (!Number.isInteger(decimalPlaces) || decimalPlaces < 0 || decimalPlaces > 15)) { return { error: 'å°æ°ä½æ°å¿ é¡»æ¯ 0 å° 15 çæ´æ°' }; } const displayMode = parts.slice(2).includes('ç§å¦è®¡æ°æ³') ? 'SCIENTIFIC' : 'NORMAL'; const roundingNames = { 'åèäºå ¥': 'HALF_UP', 'åèå å ¥': 'HALF_UP_6', 'åä¸èå ¥': 'CEILING', 'åä¸èå ¥': 'FLOOR', 'æªæ': 'DOWN' }; const roundingPart = parts.slice(2).find(item => Object.prototype.hasOwnProperty.call(roundingNames, item)); const unsupported = parts.slice(2).filter(item => item && item !== 'ç§å¦è®¡æ°æ³' && !roundingNames[item]); if (unsupported.length || parts.length > 4) { return { error: 'æ£éªå¼æ¹æ³¨æ ¼å¼åºä¸ºï¼æ£éªå¼ï¼2ï¼åèäºå ¥ æ æ£éªå¼ï¼2ï¼ç§å¦è®¡æ°æ³ï¼åèäºå ¥' }; } return { decimalPlaces, displayMode, roundingMode: roundingPart ? roundingNames[roundingPart] : 'HALF_UP' }; } export function formatInspectionValue(value, config) { if (!config || config.error || config.decimalPlaces == null || value === '' || value == null) return value; const number = Number(value); if (!Number.isFinite(number)) return value; const factor = 10 ** config.decimalPlaces; let rounded; if (config.roundingMode === 'CEILING') rounded = Math.ceil(number * factor) / factor; else if (config.roundingMode === 'FLOOR') rounded = Math.floor(number * factor) / factor; else if (config.roundingMode === 'DOWN') rounded = (number < 0 ? Math.ceil(number * factor) : Math.floor(number * factor)) / factor; else if (config.roundingMode === 'HALF_UP_6') { const absolute = Math.abs(number) * factor; const base = Math.floor(absolute); const fraction = absolute - base; rounded = (number < 0 ? -1 : 1) * ((fraction >= 0.6 ? base + 1 : base) / factor); } else rounded = Math.round((number + (number >= 0 ? Number.EPSILON : -Number.EPSILON)) * factor) / factor; return config.displayMode === 'SCIENTIFIC' ? rounded.toExponential(config.decimalPlaces) : rounded.toFixed(config.decimalPlaces); } export function validateInspectionValueAnnotation(annotation) { const config = parseInspectionValueAnnotation(annotation); return config && config.error ? config.error : null; } src/views/business/inspectionTask/inspection.vue
@@ -521,6 +521,7 @@ import { mapGetters } from "@/utils/store-compat"; import viewManHourDia from "@/views/business/inspectionTask/components/viewManHourDia.vue"; import {getDicts} from "@/api/system/dict/data"; import { parseInspectionValueAnnotation, formatInspectionValue } from "@/utils/inspectionValueFormat"; export default { name: 'Inspection', components: { @@ -1575,6 +1576,17 @@ // æ£éªå¼è¾å ¥å触åç彿° changeInput(m, code, n) { if (n) { const config = parseInspectionValueAnnotation(n.v && n.v.ps && n.v.ps.value); if (config && !config.error && config.decimalPlaces != null && typeof n.v.v === 'string') { const numericPattern = config.displayMode === 'SCIENTIFIC' ? /^[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?$/ : /^[+-]?\d*\.?\d+$/; if (n.v.v.trim() && !numericPattern.test(n.v.v.trim())) { this.$message.warning('该æ£éªå¼å¿ 须填忰å'); return; } n.v.v = formatInspectionValue(n.v.v, config); } // å®ä¹ä¸ä¸ªå½æ°æ¥éªè¯åæ°æ¯å¦ææ if (typeof n.v.v == "string") { function isValidFraction(fraction) { @@ -1705,7 +1717,7 @@ const v = n.v.v; // è½åèå´å·²åºå¼,æ£éªå¼ç±»åä¸åä½ä¸ºå¤æä¾æ®ãæ´ä¸²åªç±ç®å¼åç¬¦ç»ææ¶æè§èåæ ¼å¼, // åºç°ä¸æçå ¶å®åç¬¦å³æææ¬å¤çåæ ·ä¿ç,å¦åæåä¼è¢«éåå æ if (typeof v !== "string" || /[^\d.^e>ï¼â¥â¤<ï¼æè£èå\-/+]/.test(v)) { if (typeof v !== "string" || /[^\d.^eE>ï¼â¥â¤<ï¼æè£èå\-/+]/.test(v)) { return; } n.v.v = v src/views/standard/model/index.vue
@@ -64,6 +64,7 @@ delStandardTemplate, getEditTemplatePreparation, } from "@/api/standard/model"; import { validateInspectionValueAnnotation } from "@/utils/inspectionValueFormat"; export default { name: 'Model', components: { @@ -349,7 +350,12 @@ } } } let annotationError = null; data.data[0].celldata.forEach((a) => { if (a.v && a.v.ps && typeof a.v.ps.value === "string") { const error = validateInspectionValueAnnotation(a.v.ps.value); if (!annotationError && error) annotationError = `åå æ ¼(${a.r + 1}è¡${a.c + 1}å)ï¼${error}`; } if ( a.v.ps != undefined && (a.v.ps.value === "æ£éªå¼" || @@ -362,6 +368,11 @@ } } }); if (annotationError) { this.loading = false; this.$message.error(annotationError); return; } upStandardTemplate({ id: this.row.id, thing: JSON.stringify(data), @@ -370,6 +381,9 @@ this.loading = false; this.$message.success("å·²ä¿å"); this.isShow = false; }).catch((error) => { this.loading = false; this.$message.error(error.message || "模æ¿ä¿å失败"); }); }, isClose(done) {