ant-design-vue/components/vc-calendar/demo/full-calendar.vue

76 lines
1.7 KiB
Vue
Raw Normal View History

2018-03-12 14:13:59 +00:00
<script>
/* eslint react/no-multi-comp:0, no-console:0 */
2019-01-12 03:33:27 +00:00
import '../assets/index.less';
import zhCN from '../src/locale/zh_CN';
import enUS from '../src/locale/en_US';
import '../../vc-time-picker/assets/index.less';
import BaseMixin from '@/components/_util/BaseMixin';
2018-03-12 14:13:59 +00:00
2019-01-12 03:33:27 +00:00
import FullCalendar from '@/components/vc-calendar/src/FullCalendar';
2018-03-12 14:13:59 +00:00
2019-01-12 03:33:27 +00:00
import '@/components/vc-select/assets/index.less';
import Select from '@/components/vc-select';
2018-03-12 14:13:59 +00:00
2019-01-12 03:33:27 +00:00
import moment from 'moment';
import 'moment/locale/zh-cn';
import 'moment/locale/en-gb';
2018-03-12 14:13:59 +00:00
2019-01-12 03:33:27 +00:00
const format = 'YYYY-MM-DD';
const cn = window.location.search.indexOf('cn') !== -1;
2018-03-12 14:13:59 +00:00
2019-01-12 03:33:27 +00:00
const now = moment();
2018-03-12 14:13:59 +00:00
if (cn) {
2019-01-12 03:33:27 +00:00
now.locale('zh-cn').utcOffset(8);
2018-03-12 14:13:59 +00:00
} else {
2019-01-12 03:33:27 +00:00
now.locale('en-gb').utcOffset(0);
2018-03-12 14:13:59 +00:00
}
2019-01-12 03:33:27 +00:00
const defaultCalendarValue = now.clone();
defaultCalendarValue.add(-1, 'month');
2018-03-12 14:13:59 +00:00
function onSelect (value) {
2019-01-12 03:33:27 +00:00
console.log('select', value.format(format));
2018-03-12 14:13:59 +00:00
}
export default {
mixins: [BaseMixin],
data () {
return {
type: 'month',
2019-01-12 03:33:27 +00:00
};
2018-03-12 14:13:59 +00:00
},
methods: {
onTypeChange (type) {
this.setState({
type,
2019-01-12 03:33:27 +00:00
});
2018-03-12 14:13:59 +00:00
},
},
render () {
return (
<div style={{ zIndex: 1000, position: 'relative' }}>
<FullCalendar
style={{ margin: '10px' }}
Select={Select}
fullscreen={false}
onSelect={onSelect}
defaultValue={now}
locale={cn ? zhCN : enUS}
/>
<FullCalendar
style={{ margin: '10px' }}
Select={Select}
fullscreen
defaultValue={now}
onSelect={onSelect}
type={this.type}
onTypeChange={this.onTypeChange}
locale={cn ? zhCN : enUS}
/>
</div>
2019-01-12 03:33:27 +00:00
);
2018-03-12 14:13:59 +00:00
},
2019-01-12 03:33:27 +00:00
};
2018-03-12 14:13:59 +00:00
</script>