@orca-fe/antd-plus
Version:
Transformer Container
136 lines (135 loc) • 5.63 kB
JavaScript
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
/**
* title: 日程精度(precision)
* description: 默认日程的精度为15分钟(不足15分钟的时间点向前取整,你可以调整精度查看日程的结束时间,以及日程并行的排列方式)
*/
import moment from 'moment';
import { WeeklyCalendar } from "../..";
import { DatePicker, Descriptions, Radio, Tooltip } from 'antd';
import React, { useState } from 'react';
import dayjs from 'dayjs';
import { jsx as _jsx } from "react/jsx-runtime";
import { jsxs as _jsxs } from "react/jsx-runtime";
var data = [{
title: 'task1',
color: '#FCC',
start: moment().hour(2).minute(0),
end: moment().hour(3).minute(0)
}, {
title: 'task2',
color: '#CFC',
start: moment().hour(2).minute(0),
end: moment().hour(3).minute(5)
}, {
title: 'task3',
color: '#CCF',
start: moment().hour(2).minute(0),
end: moment().hour(3).minute(10)
}, {
title: 'task4',
color: '#FFC',
start: moment().hour(2).minute(0),
end: moment().hour(3).minute(15)
}, {
title: 'task5',
color: '#CFF',
start: moment().hour(2).minute(0),
end: moment().hour(3).minute(35)
}, {
title: 'task6',
color: '#FCF',
start: moment().hour(3).minute(20),
end: moment().hour(4).minute(0)
}];
var Demo4 = () => {
var _useState = useState('week'),
_useState2 = _slicedToArray(_useState, 2),
mode = _useState2[0],
setMode = _useState2[1];
var _useState3 = useState(15),
_useState4 = _slicedToArray(_useState3, 2),
precision = _useState4[0],
setPrecision = _useState4[1];
var _useState5 = useState(dayjs()),
_useState6 = _slicedToArray(_useState5, 2),
current = _useState6[0],
setCurrent = _useState6[1];
var currentMoment = moment(current.toDate());
return /*#__PURE__*/_jsxs("div", {
children: [/*#__PURE__*/_jsxs(Descriptions, {
layout: "vertical",
column: 4,
children: [/*#__PURE__*/_jsx(Descriptions.Item, {
label: "\u5F53\u524D\u65F6\u95F4",
children: /*#__PURE__*/_jsx(DatePicker, {
value: current,
onChange: d => {
setCurrent(d || dayjs());
}
})
}), /*#__PURE__*/_jsx(Descriptions.Item, {
label: "\u89C6\u56FE\u5207\u6362",
children: /*#__PURE__*/_jsxs(Radio.Group, {
buttonStyle: "solid",
value: mode,
onChange: e => {
setMode(e.target.value);
},
children: [/*#__PURE__*/_jsx(Radio.Button, {
value: "week",
children: "\u5468\u89C6\u56FE"
}), /*#__PURE__*/_jsx(Radio.Button, {
value: "day",
children: "\u65E5\u89C6\u56FE"
})]
})
}), /*#__PURE__*/_jsx(Descriptions.Item, {
label: "\u65E5\u7A0B\u7CBE\u5EA6(precision)",
span: 2,
children: /*#__PURE__*/_jsxs(Radio.Group, {
buttonStyle: "solid",
value: precision,
onChange: e => {
setPrecision(e.target.value);
},
children: [/*#__PURE__*/_jsx(Radio.Button, {
value: 5,
children: "5\u5206\u949F"
}), /*#__PURE__*/_jsx(Radio.Button, {
value: 10,
children: "10\u5206\u949F"
}), /*#__PURE__*/_jsx(Radio.Button, {
value: 15,
children: "15\u5206\u949F"
}), /*#__PURE__*/_jsx(Radio.Button, {
value: 20,
children: "20\u5206\u949F"
}), /*#__PURE__*/_jsx(Radio.Button, {
value: 30,
children: "30\u5206\u949F"
}), /*#__PURE__*/_jsx(Radio.Button, {
value: 60,
children: "60\u5206\u949F"
})]
})
})]
}), /*#__PURE__*/_jsx(WeeklyCalendar, {
precision: precision,
data: data,
mode: mode,
current: currentMoment,
children: item => /*#__PURE__*/_jsx(Tooltip, {
title: `${item.start.format('MM-DD HH:mm')} -> ${item.end.format('MM-DD HH:mm')}`,
children: /*#__PURE__*/_jsx("div", {
children: item.title
})
})
})]
});
};
export default Demo4;