| | |
| | | |
| | | // 重置时间插件时间滚动条 |
| | | .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); |
| | |
| | | } 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') { |
| | |
| | | subType: 'datemonth', |
| | | url: '' |
| | | }, |
| | | { |
| | | type: 'form', |
| | | label: '日期(分/秒)', |
| | | subType: 'datetime', |
| | | url: '' |
| | | }, |
| | | // { |
| | | // type: 'form', |
| | | // label: '日期(分/秒)', |
| | | // subType: 'datetime', |
| | | // url: '' |
| | | // }, |
| | | { |
| | | type: 'form', |
| | | label: CommonDict['model.form.textarea'], |
| | |
| | | } |
| | | 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' |
| | |
| | | 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') { |
| | |
| | | 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)) { |
| | | |
| | |
| | | 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' : '' |
| | |
| | | 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 = { |
| | |
| | | } |
| | | |
| | | 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) => { |
| | |
| | | |
| | | 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}/> |
| | | } |
| | | } |
| | | } |
| | |
| | | } 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') { |
| | |
| | | label: CommonDict['model.form.datemonth'], |
| | | subType: 'datemonth', |
| | | }, |
| | | { |
| | | type: 'form', |
| | | label: '日期(分/秒)', |
| | | subType: 'datetime', |
| | | }, |
| | | // { |
| | | // type: 'form', |
| | | // label: '日期(分/秒)', |
| | | // subType: 'datetime', |
| | | // }, |
| | | { |
| | | type: 'form', |
| | | label: CommonDict['model.form.textarea'], |
| | |
| | | }, { |
| | | value: 'datemonth', |
| | | text: Formdict['model.form.datemonth'] |
| | | }, { |
| | | value: 'datetime', |
| | | text: '日期(分/秒)' |
| | | // }, { |
| | | // value: 'datetime', |
| | | // text: '日期(分/秒)' |
| | | }, { |
| | | value: 'textarea', |
| | | text: Formdict['model.form.textarea'] |
| | |
| | | }, { |
| | | value: 'datemonth', |
| | | text: Formdict['model.form.datemonth'] |
| | | }, { |
| | | value: 'datetime', |
| | | text: '日期(分/秒)' |
| | | // }, { |
| | | // value: 'datetime', |
| | | // text: '日期(分/秒)' |
| | | }, { |
| | | value: 'textarea', |
| | | text: Formdict['model.form.textarea'] |
| | |
| | | _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 || [] |
| | |
| | | }] |
| | | }, |
| | | { |
| | | 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, |
| | |
| | | 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'], |