From f2a2e8744370a606a9c74c97857b7217d072bed0 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 17 十二月 2021 16:01:53 +0800 Subject: [PATCH] 2021-12-17 --- src/menu/components/card/cardcellcomponent/formconfig.jsx | 9 ++++ src/tabviews/custom/components/card/cardcellList/index.jsx | 57 +++++++++++++++++++++++++++- src/utils/utils-datamanage.js | 27 ++++++++----- src/menu/components/card/cardcellcomponent/index.jsx | 4 +- src/menu/components/card/cardcellcomponent/elementform/index.jsx | 4 +- 5 files changed, 83 insertions(+), 18 deletions(-) diff --git a/src/menu/components/card/cardcellcomponent/elementform/index.jsx b/src/menu/components/card/cardcellcomponent/elementform/index.jsx index 53b8bf3..a188052 100644 --- a/src/menu/components/card/cardcellcomponent/elementform/index.jsx +++ b/src/menu/components/card/cardcellcomponent/elementform/index.jsx @@ -81,7 +81,7 @@ if (card.eleType === 'text') { item.options = item.oriOptions.filter(op => op.value !== 'percent' && op.value !== 'thdSeparator') } else if (card.eleType === 'number') { - item.options = item.oriOptions.filter(op => op.value !== 'YYYY-MM-DD') + item.options = item.oriOptions.filter(op => !op.value || op.value === 'percent' || op.value === 'thdSeparator') } } else if (item.key === 'url') { item.required = card.eleType !== 'qrcode' @@ -179,7 +179,7 @@ if (value === 'text') { item.options = item.oriOptions.filter(op => op.value !== 'percent' && op.value !== 'thdSeparator') } else if (value === 'number') { - item.options = item.oriOptions.filter(op => op.value !== 'YYYY-MM-DD') + item.options = item.oriOptions.filter(op => !op.value || op.value === 'percent' || op.value === 'thdSeparator') } } else if (item.key === 'url') { item.required = value !== 'qrcode' diff --git a/src/menu/components/card/cardcellcomponent/formconfig.jsx b/src/menu/components/card/cardcellcomponent/formconfig.jsx index 8987fa7..7c26bba 100644 --- a/src/menu/components/card/cardcellcomponent/formconfig.jsx +++ b/src/menu/components/card/cardcellcomponent/formconfig.jsx @@ -136,7 +136,14 @@ { value: '', text: '鏃�' }, { value: 'percent', text: '鐧惧垎鏁�' }, { value: 'thdSeparator', text: '鍗冨垎浣�' }, - { value: 'YYYY-MM-DD', text: 'YYYY-MM-DD' } + { value: 'YYYY-MM-DD', text: 'YYYY-MM-DD' }, + { value: 'MM鏈圖D鏃�', text: 'MM鏈圖D鏃�' }, + { value: 'YYYY骞碝M鏈圖D鏃�', text: 'YYYY骞碝M鏈圖D鏃�' }, + { value: 'HH:mm', text: '鏃跺垎锛堜緥锛�16:57锛�' }, + { value: 'ahh:mm', text: '鑷畾涔�1锛堜緥锛氫笂鍗�10:57锛�' }, + { value: 'MM鏈圖D鏃� ahh:mm', text: '鑷畾涔�2锛堜緥锛�12鏈�17鏃� 涓婂崍10:57锛�' }, + { value: 'calendar1', text: '鑷畾涔�3锛堜緥锛氫粖澶� 涓婂崍10:57锛�' }, + { value: 'calendar2', text: '鑷畾涔�4锛堜緥锛氬垰鍒氥�佹槰澶┿��5澶╁墠锛�' }, ] }, { diff --git a/src/menu/components/card/cardcellcomponent/index.jsx b/src/menu/components/card/cardcellcomponent/index.jsx index 551555c..3654ee5 100644 --- a/src/menu/components/card/cardcellcomponent/index.jsx +++ b/src/menu/components/card/cardcellcomponent/index.jsx @@ -622,9 +622,9 @@ <div onDoubleClick={(e) => e.stopPropagation()}> {/* 缂栬緫鎸夐挳锛氬鍒躲�佺紪杈� */} <Modal - title={'缂栬緫鍏冪礌'} + title="缂栬緫鍏冪礌" visible={visible} - width={800} + width={850} maskClosable={false} onCancel={this.editModalCancel} onOk={this.handleSubmit} diff --git a/src/tabviews/custom/components/card/cardcellList/index.jsx b/src/tabviews/custom/components/card/cardcellList/index.jsx index a1160b1..318f6bd 100644 --- a/src/tabviews/custom/components/card/cardcellList/index.jsx +++ b/src/tabviews/custom/components/card/cardcellList/index.jsx @@ -305,8 +305,61 @@ } if (val !== '' && card.format) { - if (card.format === 'YYYY-MM-DD' && /^[1-9]\d{3}(-|\/)(0[1-9]|1[0-2])(-|\/)(0[1-9]|[1-2][0-9]|3[0-1])/.test(val)) { - val = `${val.substr(0, 4)}-${val.substr(5, 2)}-${val.substr(8, 2)}` + let _val = null + + if (card.format === 'calendar1') { + _val = moment(val).calendar(null, { + sameDay: '[浠婂ぉ] ahh:mm', + nextDay: '[鏄庡ぉ] ahh:mm', + nextWeek: 'MM鏈圖D鏃� ahh:mm', + lastDay: '[鏄ㄥぉ] ahh:mm', + lastWeek: 'dddd ahh:mm', + sameElse: 'MM鏈圖D鏃� ahh:mm' + }) + } else if (card.format === 'calendar2') { + let time = new Date(val).getTime() + if (!isNaN(time)) { + time = parseInt(time / 60000) // 鏃堕棿鍊� + let now = parseInt(new Date().getTime() / 60000) // 褰撳墠鏃堕棿鍊� + let start = new Date(new Date().toDateString()).getTime() / 60000 // 浠婂ぉ闆剁偣鏃堕棿鍊� + let split = now - time + + if (split < 0) { // 鏃堕棿鍊煎湪褰撳墠鏃堕棿涔嬪悗 + _val = moment(val).format('MM鏈圖D鏃� HH:mm') + } else if (split < 3) { + _val = '鍒氬垰' + } else if (split < 5) { + _val = '3鍒嗛挓鍓�' + } else if (split < 10) { + _val = '5鍒嗛挓鍓�' + } else if (split < 20) { + _val = '10鍒嗛挓鍓�' + } else if (split < 30) { + _val = '20鍒嗛挓鍓�' + } else if (split < 60) { + _val = '30鍒嗛挓鍓�' + } else if (split < 420 || time > start) { // 7灏忔椂鍐呮垨鏃堕棿鍊煎湪浠婂ぉ闆剁偣鍚� + _val = parseInt(split / 60) + '灏忔椂鍓�' + } else { // 鏃堕棿鍊煎湪浠婂ぉ闆剁偣涔嬪墠 + let _day = parseInt((start - time) / (24 * 60)) + 1 + if (_day === 1) { + _val = '鏄ㄥぉ' + } else if (_day <= 30) { + _val = _day + '澶╁墠' + } else { + _val = moment(val).format('MM鏈圖D鏃� HH:mm') + } + } + } + } else { + _val = moment(val).format(card.format) + } + + // if (card.format === 'YYYY-MM-DD' && /^[1-9]\d{3}(-|\/)(0[1-9]|1[0-2])(-|\/)(0[1-9]|[1-2][0-9]|3[0-1])/.test(val)) { + // val = `${val.substr(0, 4)}-${val.substr(5, 2)}-${val.substr(8, 2)}` + // } + if (_val && _val !== 'Invalid date') { + val = _val } } diff --git a/src/utils/utils-datamanage.js b/src/utils/utils-datamanage.js index dc431c4..d024e99 100644 --- a/src/utils/utils-datamanage.js +++ b/src/utils/utils-datamanage.js @@ -146,18 +146,23 @@ let _search = '' - if (setting.queryType === 'statistics' && _dataresource) { // 缁熻鏁版嵁婧愶紝鍐呭鏇挎崲 - regoptions.forEach(item => { - _dataresource = _dataresource.replace(item.reg, item.value) - }) - } else if (_dataresource && !id) { - _search = Utils.joinMainSearchkey(search) - if (_search) { - _search = 'where ' + _search + if (_dataresource) { + if (setting.queryType === 'statistics') { // 缁熻鏁版嵁婧愶紝鍐呭鏇挎崲 + regoptions.forEach(item => { + _dataresource = _dataresource.replace(item.reg, item.value) + }) + if (id) { + _dataresource = _dataresource + ` where ${setting.primaryKey || 'ID'}='${id}'` + } + } else if (!id) { + _search = Utils.joinMainSearchkey(search) + if (_search) { + _search = 'where ' + _search + } + } else if (id) { + _search = Utils.joinMainSearchkey(search) + _search = `where ${_search ? _search + ' AND ' : ''} ${setting.primaryKey || 'ID'}='${id}'` } - } else if (_dataresource && id) { - _search = Utils.joinMainSearchkey(search) - _search = `where ${_search ? _search + ' AND ' : ''} ${setting.primaryKey || 'ID'}='${id}'` } if (_customScript) { -- Gitblit v1.8.0