From ff04f261ed6d4d9d44991071e58d9d2fa908c34d Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 31 八月 2023 16:16:03 +0800 Subject: [PATCH] 2023-08-31 --- src/utils/utils.js | 21 +++++++++++++++++++-- 1 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/utils/utils.js b/src/utils/utils.js index 0c250c8..44c6a54 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -923,6 +923,8 @@ val = 0 } else if (col.type === 'date') { val = '1949-10-01' + } else if (col.type === 'datetime') { + val = '1949-10-01 00:00:00' } } else if (/^Nvarchar/ig.test(col.type)) { val = val + '' @@ -955,7 +957,7 @@ } else if ((col.max || col.max === 0) && val > col.max) { // 鏈�澶у�兼楠� errors.push(_position + '澶т簬鏈�澶у��') } - } else if (col.type === 'date') { + } else if (col.type === 'date' || col.type === 'datetime') { if (typeof(val) === 'number') { if (val > 2958465 || val <= 0) { // 鏃堕棿杩囧ぇ鎴栧皬浜庣瓑浜�0 errors.push(_position + '鏃堕棿涓鸿礋鍊兼垨澶ぇ') @@ -963,7 +965,14 @@ if (val < 60) { // 1900-2-29锛宔xcel涓瓨鍦紝瀹為檯涓嶅瓨鍦� val++ } - val = moment('19000101', 'YYYYMMDD').add(Math.floor(val - 2), 'days').format('YYYY-MM-DD') + if (col.type === 'datetime') { + val = val - 2 + let day = Math.floor(val) + let seconds = Math.round((val - day) * 24 * 60 * 60) + val = moment('19000101', 'YYYYMMDD').add(day, 'days').add(seconds, 'seconds').format('YYYY-MM-DD HH:mm:ss') + } else { + val = moment('19000101', 'YYYYMMDD').add(Math.floor(val - 2), 'days').format('YYYY-MM-DD') + } } } else if (typeof(val) === 'string') { val = val.replace(/(^\s+$)|\t+|\v+/ig, '') @@ -1012,6 +1021,10 @@ {reg: /@\$/ig, value: isDM ? '*/' : ''}, {reg: /@datam@/ig, value: isDM ? `'Y'` : `''`}, ] + + if (window.GLOB.externalDatabase !== null) { + regs.push({reg: /@db@/ig, value: window.GLOB.externalDatabase}) + } btn.scripts && btn.scripts.forEach(script => { if (script.status === 'false') return @@ -1219,6 +1232,10 @@ {reg: /@datam@/ig, value: isDM ? `'Y'` : `''`}, ] + if (window.GLOB.externalDatabase !== null) { + regs.push({reg: /@db@/ig, value: window.GLOB.externalDatabase}) + } + btn.scripts && btn.scripts.forEach(script => { if (script.status === 'false') return -- Gitblit v1.8.0