fix: 更新日期组件版本和提取dateRender组件

This commit is contained in:
huyueb 2017-09-27 16:15:45 +08:00
parent b47bf89b11
commit 06e0091561
7 changed files with 83 additions and 38 deletions

View File

@ -24,11 +24,13 @@
.editable-cell-text-wrapper { .editable-cell-text-wrapper {
padding: 5px 24px 5px 5px; padding: 5px 24px 5px 5px;
height: 30px;
} }
.editable-cell-icon, .editable-cell-icon,
.editable-cell-icon-check { .editable-cell-icon-check {
position: absolute; position: absolute;
top: 0;
right: 0; right: 0;
width: 20px; width: 20px;
cursor: pointer; cursor: pointer;

View File

@ -24,6 +24,7 @@ import MonthPicker, { WeekPicker, RangePicker } from "bee-datepicker";
const format = "YYYY-MM-DD"; const format = "YYYY-MM-DD";
const format2 = "YYYY-MM"; const format2 = "YYYY-MM";
const format3 = "YYYY-MM-DD HH:mm:ss";
const dateInputPlaceholder = "选择日期"; const dateInputPlaceholder = "选择日期";
const dateInputPlaceholder2 = "选择年月"; const dateInputPlaceholder2 = "选择年月";
@ -37,25 +38,37 @@ class Demo15 extends React.Component {
key: "0", key: "0",
name: "沉鱼", name: "沉鱼",
age: "y", age: "y",
address: "96, 77, 89" address: "96, 77, 89",
datepicker: "2017-06-12",
MonthPicker: "2017-02",
TimePicker: "2017-09-15 15:24:48"
}, },
{ {
key: "1", key: "1",
name: "落雁", name: "落雁",
age: "y", age: "y",
address: "90, 70, 80" address: "90, 70, 80",
datepicker: "2017-06-12",
MonthPicker: "2017-02",
TimePicker: "2017-09-15 15:24:48"
}, },
{ {
key: "2", key: "2",
name: "闭月", name: "闭月",
age: "n", age: "n",
address: "80, 60, 80" address: "80, 60, 80",
datepicker: "2017-06-12",
MonthPicker: "2017-02",
TimePicker: "2017-09-15 15:24:48"
}, },
{ {
key: "3", key: "3",
name: "羞花", name: "羞花",
age: "y", age: "y",
address: "120, 60, 90" address: "120, 60, 90",
datepicker: "2017-06-12",
MonthPicker: "2017-02",
TimePicker: "2017-09-15 15:24:48"
} }
], ],
count: 4 count: 4
@ -109,16 +122,18 @@ class Demo15 extends React.Component {
} }
}, },
{ {
title: "", title: "年月日",
dataIndex: "datepicker", dataIndex: "datepicker",
key: "datepicker", key: "datepicker",
width: "200px", width: "200px",
render: () => { render: (text, record, index) => {
return ( return (
<DatePicker <DateRender
value={text}
isclickTrigger={true}
format={format} format={format}
onSelect={this.onSelect} onSelect={this.onDateSelect}
onChange={this.onChange} onChange={this.onDateChange}
placeholder={dateInputPlaceholder} placeholder={dateInputPlaceholder}
/> />
); );
@ -129,9 +144,11 @@ class Demo15 extends React.Component {
dataIndex: "MonthPicker", dataIndex: "MonthPicker",
key: "MonthPicker", key: "MonthPicker",
width: "200px", width: "200px",
render: () => { render: (text, record, index) => {
return ( return (
<MonthPicker <DateRender
value={text}
isclickTrigger={true}
format={format2} format={format2}
onSelect={this.onSelect} onSelect={this.onSelect}
onChange={this.onChange} onChange={this.onChange}
@ -141,11 +158,20 @@ class Demo15 extends React.Component {
} }
}, },
{ {
title: "周", title: "日期",
dataIndex: "WeekPicker", dataIndex: "TimePicker",
key: "WeekPicker", key: "TimePicker",
render: () => { render: (text, record, index) => {
return <WeekPicker placeholder="选择周" />; return (
<DateRender
value={text}
format={format3}
isclickTrigger={true}
onSelect={this.onDateSelect}
onChange={this.onDateChange}
placeholder={dateInputPlaceholder}
/>
);
} }
} }
]; ];
@ -168,6 +194,12 @@ class Demo15 extends React.Component {
onSelectChange = value => { onSelectChange = value => {
console.log(`selected ${value}`); console.log(`selected ${value}`);
}; };
onDateChange = d => {
console.log(d);
};
onDateSelect = d => {
console.log(d);
};
onDelete = index => { onDelete = index => {
return () => { return () => {
const dataSource = [...this.state.dataSource]; const dataSource = [...this.state.dataSource];
@ -200,15 +232,6 @@ class Demo15 extends React.Component {
</Animate> </Animate>
); );
}; };
onSelect = d => {
console.log(d);
};
onChange = d => {
console.log(d);
};
render() { render() {
const { dataSource } = this.state; const { dataSource } = this.state;
const columns = this.columns; const columns = this.columns;

File diff suppressed because one or more lines are too long

View File

@ -43,7 +43,7 @@
"bee-animate": "latest", "bee-animate": "latest",
"bee-button": "latest", "bee-button": "latest",
"bee-checkbox": "^0.2.4", "bee-checkbox": "^0.2.4",
"bee-datepicker": "^0.1.3", "bee-datepicker": "^0.1.7",
"bee-form-control": "^0.1.8", "bee-form-control": "^0.1.8",
"bee-icon": "0.0.5", "bee-icon": "0.0.5",
"bee-input-group": "^0.1.12", "bee-input-group": "^0.1.12",

View File

@ -93,8 +93,8 @@ $table-move-in-color: $bg-color-base;
} }
&-footer { &-footer {
padding: $vertical-padding $horizontal-padding; // padding: $vertical-padding $horizontal-padding;
border-bottom: 1px solid $table-border-color; // border-bottom: 1px solid $table-border-color;
} }
&-placeholder { &-placeholder {

View File

@ -1,6 +1,7 @@
import React, { Component } from "react"; import React, { Component } from "react";
import Icon from "bee-icon"; import Icon from "bee-icon";
import DatePicker from "bee-datepicker"; import DatePicker from "bee-datepicker";
import moment from "moment";
export default class DateRender extends Component { export default class DateRender extends Component {
state = { state = {
@ -8,9 +9,15 @@ export default class DateRender extends Component {
editable: false editable: false
}; };
handleChange = e => { handleChange = e => {
debugger; let { format } = this.props || "YYYY-MM-DD";
const value = e.target.value; const value = e.format(format);
this.setState({ value }); this.setState({ value });
if (this.props.onChange) {
this.props.onChange(this.state.value);
}
setTimeout(() => {
this.setState({ editable: false });
}, 0);
}; };
check = () => { check = () => {
this.setState({ editable: false }); this.setState({ editable: false });
@ -31,14 +38,28 @@ export default class DateRender extends Component {
const { value, editable } = this.state; const { value, editable } = this.state;
let { isclickTrigger } = this.props; let { isclickTrigger } = this.props;
let cellContent = ""; let cellContent = "";
let date_value = moment(value);
if (editable) { if (editable) {
cellContent = isclickTrigger ? ( cellContent = isclickTrigger ? (
<div className="editable-cell-input-wrapper"> <div className="editable-cell-input-wrapper">
<DatePicker onChange={this.handleChange} /> <DatePicker
{...this.props}
value={date_value}
onChange={this.handleChange}
/>
<Icon
type="uf-correct"
className="editable-cell-icon-check"
onClick={this.check}
/>
</div> </div>
) : ( ) : (
<div className="editable-cell-input-wrapper"> <div className="editable-cell-input-wrapper">
<DatePicker {...this.props} onChange={this.handleChange}/> <DatePicker
{...this.props}
value={date_value}
onChange={this.handleChange}
/>
<Icon <Icon
type="uf-correct" type="uf-correct"
className="editable-cell-icon-check" className="editable-cell-icon-check"

View File

@ -9,13 +9,12 @@ export default class SelectRender extends Component {
}; };
handleChange = e => { handleChange = e => {
const value = e; const value = e;
let self = this; if (this.props.onChange) {
if (self.props.onChange) { this.props.onChange(value);
self.props.onChange(value);
} }
this.setState({ value: value }); this.setState({ value: value });
setTimeout(function() { setTimeout(()=> {
self.setState({ editable: false }); this.setState({ editable: false });
}, 0); }, 0);
}; };
check = () => { check = () => {