From 99966d855531d813197190f68e84f409f4eb1e61 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 10 三月 2022 18:50:37 +0800 Subject: [PATCH] 2022-03-10 --- src/mob/components/formdragelement/card.jsx | 10 +++ src/tabviews/zshare/mutilform/index.jsx | 49 +++++++++++----- src/templates/zshare/modalform/index.jsx | 2 src/templates/modalconfig/source.jsx | 10 +- src/templates/zshare/formconfig.jsx | 34 +++++++++-- src/templates/modalconfig/dragelement/card.jsx | 12 +++ src/mob/modalconfig/source.jsx | 12 ++-- src/tabviews/zshare/mutilform/mkDatePicker/index.jsx | 32 +++++++--- src/assets/css/main.scss | 8 +- 9 files changed, 119 insertions(+), 50 deletions(-) diff --git a/src/assets/css/main.scss b/src/assets/css/main.scss index 85ccbe3..d9922e3 100644 --- a/src/assets/css/main.scss +++ b/src/assets/css/main.scss @@ -124,15 +124,15 @@ // 閲嶇疆鏃堕棿鎻掍欢鏃堕棿婊氬姩鏉� .ant-calendar-time-picker-select { - overflow-y: auto; + overflow-y: auto!important; } .ant-calendar-time-picker-select::-webkit-scrollbar { - width: 7px; + width: 6px; } .ant-calendar-time-picker-select::-webkit-scrollbar-thumb { border-radius: 5px; - box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.13); - background: rgba(0, 0, 0, 0.13); + box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.08); + background: rgba(0, 0, 0, 0.08); } .ant-calendar-time-picker-select::-webkit-scrollbar-track { box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.05); diff --git a/src/mob/components/formdragelement/card.jsx b/src/mob/components/formdragelement/card.jsx index c839e19..11ba914 100644 --- a/src/mob/components/formdragelement/card.jsx +++ b/src/mob/components/formdragelement/card.jsx @@ -66,7 +66,15 @@ } else if (card.type === 'select' || card.type === 'link') { formItem = (<div className="am-list-item"><div className="am-list-line"><div className="am-input-label">{card.label}</div><div className="am-input-control">{selectval || '璇烽�夋嫨'}</div><div className="am-list-extra"><RightOutlined /></div></div></div>) } else if (card.type === 'date') { - formItem = (<div className="am-list-item"><div className="am-list-line"><div className="am-input-label">{card.label}</div><div className="am-input-control">{card.initval ? moment().subtract(card.initval, 'days').format('YYYY-MM-DD') : '璇烽�夋嫨'}</div><div className="am-list-extra"><RightOutlined /></div></div></div>) + let format = 'YYYY-MM-DD' + if (card.precision === 'hour') { + format = 'YYYY-MM-DD HH' + } else if (card.precision === 'minute') { + format = 'YYYY-MM-DD HH:mm' + } else if (card.precision === 'second') { + format = 'YYYY-MM-DD HH:mm:ss' + } + formItem = (<div className="am-list-item"><div className="am-list-line"><div className="am-input-label">{card.label}</div><div className="am-input-control">{card.initval ? moment().subtract(card.initval, 'days').format(format) : '璇烽�夋嫨'}</div><div className="am-list-extra"><RightOutlined /></div></div></div>) } else if (card.type === 'datemonth') { formItem = (<div className="am-list-item"><div className="am-list-line"><div className="am-input-label">{card.label}</div><div className="am-input-control">{card.initval ? moment().subtract(card.initval, 'month').format('YYYY-MM') : '璇烽�夋嫨'}</div><div className="am-list-extra"><RightOutlined /></div></div></div>) } else if (card.type === 'datetime') { diff --git a/src/mob/modalconfig/source.jsx b/src/mob/modalconfig/source.jsx index 60d8632..42363a7 100644 --- a/src/mob/modalconfig/source.jsx +++ b/src/mob/modalconfig/source.jsx @@ -70,12 +70,12 @@ subType: 'datemonth', url: '' }, - { - type: 'form', - label: '鏃ユ湡锛堝垎/绉掞級', - subType: 'datetime', - url: '' - }, + // { + // type: 'form', + // label: '鏃ユ湡锛堝垎/绉掞級', + // subType: 'datetime', + // url: '' + // }, { type: 'form', label: CommonDict['model.form.textarea'], diff --git a/src/tabviews/zshare/mutilform/index.jsx b/src/tabviews/zshare/mutilform/index.jsx index b50c803..21981c0 100644 --- a/src/tabviews/zshare/mutilform/index.jsx +++ b/src/tabviews/zshare/mutilform/index.jsx @@ -84,9 +84,14 @@ } delete item.field return true + } else if (item.type === 'date') { // 鏃堕棿鎼滅储 + item.precision = item.precision || 'day' + } else if (item.type === 'datetime') { + item.type = 'date' + item.precision = 'second' } - if (!item.field || !['text', 'number', 'switch', 'rate', 'select', 'link', 'linkMain', 'funcvar', 'date', 'datemonth', 'datetime', 'radio', 'checkbox', 'checkcard', 'fileupload', 'textarea', 'multiselect', 'brafteditor', 'color'].includes(item.type)) return false + if (!item.field || !['text', 'number', 'switch', 'rate', 'select', 'link', 'linkMain', 'funcvar', 'date', 'datemonth', 'radio', 'checkbox', 'checkcard', 'fileupload', 'textarea', 'multiselect', 'brafteditor', 'color'].includes(item.type)) return false // 鏁版嵁鑷姩濉厖 let readin = item.readin !== 'false' @@ -139,12 +144,24 @@ if (item.type === 'linkMain') { newval = BData && BData[item.field] ? BData[item.field] : '$empty' } else if (item.type === 'date') { // 鏃堕棿鎼滅储 + let format = 'YYYY-MM-DD' + let _format = 'YYYY-MM-DD HH:mm:ss' + if (item.precision === 'day') { + _format = 'YYYY-MM-DD' + } else if (item.precision === 'hour') { + format = 'YYYY-MM-DD HH' + } else if (item.precision === 'minute') { + format = 'YYYY-MM-DD HH:mm' + } else if (item.precision === 'second') { + format = 'YYYY-MM-DD HH:mm:ss' + } + if (newval !== '$empty') { - newval = moment(newval, 'YYYY-MM-DD').format('YYYY-MM-DD') + newval = moment(newval, format).format(_format) newval = newval === 'Invalid date' ? '$empty' : newval } if (newval === '$empty' && item.initval) { - newval = moment().subtract(item.initval, 'days').format('YYYY-MM-DD') + newval = moment().subtract(item.initval, 'days').format(_format) } } else if (item.type === 'datemonth') { if (newval !== '$empty') { @@ -154,18 +171,18 @@ if (newval === '$empty' && item.initval) { newval = moment().subtract(item.initval, 'month').format('YYYY-MM') } - } else if (item.type === 'datetime') { - if (newval !== '$empty') { - newval = moment(newval, 'YYYY-MM-DD HH:mm:ss').format('YYYY-MM-DD HH:mm:ss') - newval = newval === 'Invalid date' ? '$empty' : newval - } - if (newval === '$empty' && item.initval) { - if (item.initval === '0') { - newval = moment().format('YYYY-MM-DD HH:mm:ss') - } else { - newval = moment().subtract(item.initval, 'days').format('YYYY-MM-DD') + ' 00:00:00' - } - } + // } else if (item.type === 'datetime') { + // if (newval !== '$empty') { + // newval = moment(newval, 'YYYY-MM-DD HH:mm:ss').format('YYYY-MM-DD HH:mm:ss') + // newval = newval === 'Invalid date' ? '$empty' : newval + // } + // if (newval === '$empty' && item.initval) { + // if (item.initval === '0') { + // newval = moment().format('YYYY-MM-DD HH:mm:ss') + // } else { + // newval = moment().subtract(item.initval, 'days').format('YYYY-MM-DD') + ' 00:00:00' + // } + // } } else if (item.type === 'switch') { // 寮�鍏冲彧鎺ユ敹鍥哄畾鍊� if (newval !== '$empty' && (newval === item.closeVal || newval === item.openVal)) { @@ -802,7 +819,7 @@ content = (<MKCheckbox config={item} onChange={(val) => this.recordChange({[item.field]: val})}/>) } else if (item.type === 'radio') { content = (<MKRadio config={item} onChange={(val, other) => this.recordChange({[item.field]: val, ...other}, item)}/>) - } else if (item.type === 'date' || item.type === 'datemonth' || item.type === 'datetime') { + } else if (item.type === 'date' || item.type === 'datemonth') { content = (<MKDatePicker config={item} onChange={(val) => this.recordChange({[item.field]: val})} />) } else if (item.type === 'fileupload') { className = item.readonly ? 'readonly' : '' diff --git a/src/tabviews/zshare/mutilform/mkDatePicker/index.jsx b/src/tabviews/zshare/mutilform/mkDatePicker/index.jsx index b2acd83..a3d0899 100644 --- a/src/tabviews/zshare/mutilform/mkDatePicker/index.jsx +++ b/src/tabviews/zshare/mutilform/mkDatePicker/index.jsx @@ -20,13 +20,19 @@ if (config.type === 'datemonth') { mode = 'month' format = 'YYYY-MM' - } else if (config.type === 'datetime') { - mode = 'datetime' + } else if (config.precision === 'day') { + format = 'YYYY-MM-DD' + } else if (config.precision === 'hour') { + format = 'YYYY-MM-DD HH' + } else if (config.precision === 'minute') { + format = 'YYYY-MM-DD HH:mm' + } else if (config.precision === 'second') { format = 'YYYY-MM-DD HH:mm:ss' } + let value = config.initval || null if (value) { - value = moment(value, format) + value = moment(value, 'YYYY-MM-DD HH:mm:ss') } this.state = { @@ -49,9 +55,19 @@ } onChange = (val) => { - const { format } = this.state + const { config } = this.props + const { format, mode } = this.state + let _val = val ? moment(val).format(format) : '' - this.props.onChange(val ? moment(val).format(format) : '') + if (mode === 'date' && _val) { + if (config.precision === 'hour') { + _val = _val + ':00:00' + } else if (config.precision === 'minute') { + _val = _val + ':00' + } + } + + this.props.onChange(_val) } disabledDate = (current) => { @@ -72,14 +88,12 @@ render() { const { config } = this.props - const { value, mode } = this.state + const { value, mode, format } = this.state if (mode === 'date') { - return <DatePicker defaultValue={value} disabledDate={this.disabledDate} disabled={config.readonly} onChange={this.onChange}/> + return <DatePicker dropdownClassName={'mk-date-picker ' + config.precision} showTime={format !== 'YYYY-MM-DD'} format={format} defaultValue={value} disabledDate={this.disabledDate} disabled={config.readonly} onChange={this.onChange}/> } else if (mode === 'month') { return <MonthPicker defaultValue={value} disabled={config.readonly} onChange={this.onChange}/> - } else if (mode === 'datetime') { - return <DatePicker defaultValue={value} disabledDate={this.disabledDate} showTime disabled={config.readonly} onChange={this.onChange}/> } } } diff --git a/src/templates/modalconfig/dragelement/card.jsx b/src/templates/modalconfig/dragelement/card.jsx index 449c503..16f8b77 100644 --- a/src/templates/modalconfig/dragelement/card.jsx +++ b/src/templates/modalconfig/dragelement/card.jsx @@ -76,11 +76,19 @@ } else if (card.type === 'color') { formItem = (<ColorSketch value={card.initval || 'transparent'}/>) } else if (card.type === 'date') { - formItem = (<DatePicker value={card.initval ? moment().subtract(card.initval, 'days') : null} />) + let format = 'YYYY-MM-DD' + if (card.precision === 'hour') { + format = 'YYYY-MM-DD HH' + } else if (card.precision === 'minute') { + format = 'YYYY-MM-DD HH:mm' + } else if (card.precision === 'second') { + format = 'YYYY-MM-DD HH:mm:ss' + } + formItem = (<DatePicker format={format} value={card.initval ? moment().subtract(card.initval, 'days') : null} />) } else if (card.type === 'datemonth') { formItem = (<MonthPicker value={card.initval ? moment().subtract(card.initval, 'month') : null} />) } else if (card.type === 'datetime') { - formItem = (<DatePicker showTime value={card.initval ? moment().subtract(card.initval, 'days') : null} />) + formItem = (<DatePicker format='YYYY-MM-DD HH:mm:ss' value={card.initval ? moment().subtract(card.initval, 'days') : null} />) } else if (card.type === 'textarea') { formItem = (<TextArea value={card.initval} placeholder={card.placeholder || ''} autoSize={{ minRows: 2, maxRows: 6 }} />) } else if (card.type === 'brafteditor') { diff --git a/src/templates/modalconfig/source.jsx b/src/templates/modalconfig/source.jsx index 6588fed..deddd57 100644 --- a/src/templates/modalconfig/source.jsx +++ b/src/templates/modalconfig/source.jsx @@ -134,11 +134,11 @@ label: CommonDict['model.form.datemonth'], subType: 'datemonth', }, - { - type: 'form', - label: '鏃ユ湡锛堝垎/绉掞級', - subType: 'datetime', - }, + // { + // type: 'form', + // label: '鏃ユ湡锛堝垎/绉掞級', + // subType: 'datetime', + // }, { type: 'form', label: CommonDict['model.form.textarea'], diff --git a/src/templates/zshare/formconfig.jsx b/src/templates/zshare/formconfig.jsx index 65e24c3..c8e030c 100644 --- a/src/templates/zshare/formconfig.jsx +++ b/src/templates/zshare/formconfig.jsx @@ -2288,9 +2288,9 @@ }, { value: 'datemonth', text: Formdict['model.form.datemonth'] - }, { - value: 'datetime', - text: '鏃ユ湡锛堝垎/绉掞級' + // }, { + // value: 'datetime', + // text: '鏃ユ湡锛堝垎/绉掞級' }, { value: 'textarea', text: Formdict['model.form.textarea'] @@ -2353,9 +2353,9 @@ }, { value: 'datemonth', text: Formdict['model.form.datemonth'] - }, { - value: 'datetime', - text: '鏃ユ湡锛堝垎/绉掞級' + // }, { + // value: 'datetime', + // text: '鏃ユ湡锛堝垎/绉掞級' }, { value: 'textarea', text: Formdict['model.form.textarea'] @@ -2381,6 +2381,9 @@ _fieldlength = 512 } else if (['textarea', 'brafteditor'].includes(card.type)) { _fieldlength = 8000 + } else if (card.type === 'datetime') { + card.type = 'date' + card.precision = 'second' } let options = card.options || [] @@ -2779,6 +2782,25 @@ }] }, { + type: 'radio', + key: 'precision', + label: '绮剧‘搴�', + initVal: card.precision || 'day', + options: [{ + value: 'day', + text: '澶�' + }, { + value: 'hour', + text: '灏忔椂' + }, { + value: 'minute', + text: '鍒嗛挓' + }, { + value: 'second', + text: '绉�' + }] + }, + { type: 'number', key: 'fieldlength', min: 1, diff --git a/src/templates/zshare/modalform/index.jsx b/src/templates/zshare/modalform/index.jsx index feac0d9..26099fa 100644 --- a/src/templates/zshare/modalform/index.jsx +++ b/src/templates/zshare/modalform/index.jsx @@ -29,7 +29,7 @@ link: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'setAll', 'linkField', 'linkSubField', 'span', 'labelwidth', 'tooltip', 'extra', 'emptyText', 'enter', 'splitline', 'dropdown', 'marginTop', 'marginBottom'], fileupload: ['readonly', 'required', 'readin', 'fieldlength', 'maxfile', 'fileType', 'span', 'labelwidth', 'tooltip', 'extra', 'compress', 'splitline', 'marginTop', 'marginBottom'], switch: ['initval', 'openVal', 'closeVal', 'openText', 'closeText', 'readonly', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'extra', 'splitline', 'marginTop', 'marginBottom'], - date: ['initval', 'readonly', 'required', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'extra', 'declareType', 'mode', 'splitline', 'marginTop', 'marginBottom', 'minDate', 'maxDate'], + date: ['initval', 'readonly', 'required', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'extra', 'declareType', 'mode', 'splitline', 'marginTop', 'marginBottom', 'minDate', 'maxDate', 'precision'], datemonth: ['initval', 'readonly', 'required', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'extra', 'declareType', 'splitline', 'marginTop', 'marginBottom'], datetime: ['initval', 'readonly', 'required', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'extra', 'declareType', 'mode', 'splitline', 'marginTop', 'marginBottom', 'minDate', 'maxDate'], textarea: ['initval', 'readonly', 'required', 'hidden', 'readin', 'fieldlength', 'span', 'labelwidth', 'maxRows', 'encryption', 'interception', 'tooltip', 'extra', 'count', 'placeholder', 'marginTop', 'marginBottom', 'enterReplace'], -- Gitblit v1.8.0