组件演示

[{"title":"区块信息展示","id":"scene-card-demo-basic","tags":[],"filepath":"site/scene/card/demo/basic.md","directory":"scene/card/demo","filename":"basic","meta":{"title":"区块信息展示","description":"\n","order":"0","filepath":"site/scene/card/demo/basic.md","filename":"basic","directory":"scene/card/demo","id":"scene-card-demo-basic","template":"demos","html":"<script>(function(){'use strict';\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nvar _classnames = require('classnames');\n\nvar _classnames2 = _interopRequireDefault(_classnames);\n\nvar _uxcore = require('uxcore');\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\n;\nvar Input = _uxcore.Form.InputFormField,\n FormRow = _uxcore.Form.FormRow,\n FormRowTitle = _uxcore.Form.FormRowTitle,\n Validators = _uxcore.Form.Validators,\n OtherFormField = _uxcore.Form.OtherFormField,\n DateFormField = _uxcore.Form.DateFormField,\n CascadeSelectFormField = _uxcore.Form.CascadeSelectFormField,\n SelectFormField = _uxcore.Form.SelectFormField,\n CheckboxGroupFormField = _uxcore.Form.CheckboxGroupFormField;\n\n\nvar Item = CheckboxGroupFormField.Item;\n\nvar CardItem = function (_React$Component) {\n _inherits(CardItem, _React$Component);\n\n function CardItem(props) {\n _classCallCheck(this, CardItem);\n\n var _this = _possibleConstructorReturn(this, (CardItem.__proto__ || Object.getPrototypeOf(CardItem)).call(this, props));\n\n _this.state = {};\n return _this;\n }\n\n _createClass(CardItem, [{\n key: 'componentDidMount',\n value: function componentDidMount() {}\n }, {\n key: 'render',\n value: function render() {\n var me = this;\n var data = this.props.data;\n return React.createElement(\n 'div',\n { className: 'templateCardItemWrap' },\n React.createElement(\n 'div',\n { className: 'templateCardItemTitle' },\n data.title\n ),\n React.createElement(\n 'div',\n { className: 'templateCardItemContent' },\n data.content\n )\n );\n }\n }]);\n\n return CardItem;\n}(React.Component);\n\nvar Card = function (_React$Component2) {\n _inherits(Card, _React$Component2);\n\n function Card(props) {\n _classCallCheck(this, Card);\n\n var _this2 = _possibleConstructorReturn(this, (Card.__proto__ || Object.getPrototypeOf(Card)).call(this, props));\n\n _this2.state = {\n cardValues: {},\n showCardDialog: false,\n cardList: [{\n title: '阿里巴巴(中国)有限公司',\n content: '浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号',\n id: new Date().getTime(),\n active: true\n }, {\n title: '阿里巴巴(中国)有限公司阿里巴巴(中国)有限公司',\n content: '浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号',\n id: new Date().getTime() + 1\n }]\n };\n return _this2;\n }\n\n _createClass(Card, [{\n key: 'componentDidMount',\n value: function componentDidMount() {}\n }, {\n key: 'componentWillUnmount',\n value: function componentWillUnmount() {}\n }, {\n key: 'showNewCardDialog',\n value: function showNewCardDialog() {\n this.setState({\n action: 'add',\n showCardDialog: true,\n cardValues: {}\n });\n }\n }, {\n key: 'handleCard',\n value: function handleCard() {\n var data = this.refs.form.getValues();\n\n if (!data.pass) {\n return;\n }\n\n if (this.state.action === 'add') {\n this.state.cardList.push({\n title: data.values.cardTitle,\n content: data.values.cardContent,\n id: new Date().getTime()\n });\n } else {\n var editData = this.state.editData;\n this.state.cardList.map(function (item) {\n if (item.id === editData.id) {\n item.content = data.values.cardContent;\n item.title = data.values.cardTitle;\n return true;\n }\n });\n }\n\n this.state.showCardDialog = false;\n this.setState(this.state);\n }\n }, {\n key: 'handleCancel',\n value: function handleCancel() {\n this.setState({\n showCardDialog: false\n });\n }\n }, {\n key: 'onEditCard',\n value: function onEditCard(data) {\n this.state.cardValues.cardTitle = data.title;\n this.state.cardValues.cardContent = data.content;\n this.state.showCardDialog = true;\n this.state.action = 'edit';\n this.state.editData = data;\n this.setState(this.state);\n }\n }, {\n key: 'onRemoveCard',\n value: function onRemoveCard(data) {\n var _this3 = this;\n\n _uxcore.Dialog.confirm({\n title: '确定删除?',\n onOk: function onOk() {\n _this3.state.cardList.some(function (item, i) {\n if (item.id === data.id) {\n _this3.state.cardList.splice(i, 1);\n return true;\n }\n });\n _this3.setState(_this3.state);\n }\n });\n }\n }, {\n key: 'renderCardDialog',\n value: function renderCardDialog() {\n return React.createElement(\n _uxcore.Dialog,\n { ref: 'modal',\n visible: true,\n className: 'newCardDialog',\n title: '\\u6DFB\\u52A0\\u5361\\u7247', onCancel: this.handleCancel.bind(this),\n footer: [React.createElement(\n _uxcore.Button,\n { onClick: this.handleCard.bind(this) },\n '\\u63D0 \\u4EA4'\n ), React.createElement(\n _uxcore.Button,\n { onClick: this.handleCancel.bind(this) },\n '\\u53D6 \\u6D88'\n )]\n },\n React.createElement(\n _uxcore.Form,\n { ref: 'form', jsxvalues: this.state.cardValues },\n React.createElement(FormRowTitle, { jsxtitle: '\\u5361\\u7247\\u4FE1\\u606F' }),\n React.createElement(Input, {\n required: true,\n jsxname: 'cardTitle',\n jsxlabel: '\\u6807\\u9898',\n jsxrules: [{ validator: Validators.isNotEmpty, errMsg: '请填写标题' }]\n }),\n React.createElement(Input, {\n required: true,\n jsxname: 'cardContent',\n jsxlabel: '\\u5185\\u5BB9',\n jsxrules: [{ validator: Validators.isNotEmpty, errMsg: '请填写内容' }]\n })\n )\n );\n }\n }, {\n key: 'render',\n value: function render() {\n var me = this;\n return React.createElement(\n 'div',\n { className: 'pageDemo' },\n React.createElement(\n 'div',\n { className: 'templateCardWrap' },\n React.createElement(\n 'ul',\n { className: 'templateCardList clearfix' },\n me.state.cardList.map(function (item, i) {\n return React.createElement(\n 'li',\n { className: 'templateCardItem ' + (item.active ? 'active' : ''), key: 'templateCardItem' + i },\n React.createElement(CardItem, { data: item }),\n React.createElement(\n 'div',\n { className: 'templateCardEdit' },\n React.createElement(\n 'a',\n { href: 'javascript:void(0);', onClick: me.onEditCard.bind(me, item) },\n '\\u4FEE\\u6539'\n ),\n React.createElement(\n 'a',\n { href: 'javascript:void(0);', onClick: me.onRemoveCard.bind(me, item) },\n '\\u5220\\u9664'\n )\n )\n );\n }),\n React.createElement(\n 'li',\n { className: 'templateCardItem templateAddCard', onClick: me.showNewCardDialog.bind(this) },\n React.createElement(\n 'div',\n null,\n React.createElement('img', { src: 'https://img.alicdn.com/tps/TB14qDfPFXXXXclXXXXXXXXXXXX-200-200.png', className: 'templateAddCardBtn' })\n ),\n React.createElement(\n 'p',\n { className: 'templateCardTxt' },\n '\\u6DFB\\u52A0\\u5361\\u7247'\n )\n )\n )\n ),\n me.state.showCardDialog ? me.renderCardDialog() : null\n );\n }\n }]);\n\n return Card;\n}(React.Component);\n\nvar Demo = function (_React$Component3) {\n _inherits(Demo, _React$Component3);\n\n function Demo(props) {\n _classCallCheck(this, Demo);\n\n var _this4 = _possibleConstructorReturn(this, (Demo.__proto__ || Object.getPrototypeOf(Demo)).call(this, props));\n\n _this4.state = {};\n return _this4;\n }\n\n _createClass(Demo, [{\n key: 'render',\n value: function render() {\n var me = this;\n return React.createElement(\n 'div',\n { className: 'pageDemo' },\n React.createElement(Card, null)\n );\n }\n }]);\n\n return Demo;\n}(React.Component);\n\nReactDOM.render(React.createElement(Demo, null), document.getElementById('scene-card-demo-basic'));\n\n/* JS END CSS START*/})()</script><div class=\"highlight\"><pre><code class=\"javascript\"><span class=\"hljs-keyword\">import</span> classnames <span class=\"hljs-keyword\">from</span> <span class=\"hljs-string\">'classnames'</span>;;\n<span class=\"hljs-keyword\">import</span> { Form } <span class=\"hljs-keyword\">from</span> <span class=\"hljs-string\">'uxcore'</span>;\n<span class=\"hljs-keyword\">import</span> { Button } <span class=\"hljs-keyword\">from</span> <span class=\"hljs-string\">'uxcore'</span>;\n<span class=\"hljs-keyword\">import</span> { Dialog } <span class=\"hljs-keyword\">from</span> <span class=\"hljs-string\">'uxcore'</span>;\n<span class=\"hljs-keyword\">const</span> {\n InputFormField: Input,\n FormRow,\n FormRowTitle,\n Validators,\n OtherFormField,\n DateFormField,\n CascadeSelectFormField,\n SelectFormField,\n CheckboxGroupFormField,\n} = Form;\n\n<span class=\"hljs-keyword\">const</span> Item = CheckboxGroupFormField.Item;\n\n\n<span class=\"hljs-class\"><span class=\"hljs-keyword\">class</span> <span class=\"hljs-title\">CardItem</span> <span class=\"hljs-keyword\">extends</span> <span class=\"hljs-title\">React</span>.<span class=\"hljs-title\">Component</span> </span>{\n constructor(props) {\n <span class=\"hljs-keyword\">super</span>(props);\n <span class=\"hljs-keyword\">this</span>.state = {\n };\n }\n\n componentDidMount() {\n }\n\n render() {\n <span class=\"hljs-keyword\">const</span> me = <span class=\"hljs-keyword\">this</span>;\n <span class=\"hljs-keyword\">const</span> data = <span class=\"hljs-keyword\">this</span>.props.data;\n <span class=\"hljs-keyword\">return</span> (\n <span class=\"xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-title\">div</span> <span class=\"hljs-attribute\">className</span>=<span class=\"hljs-value\">\"templateCardItemWrap\"</span>&gt;</span>\n <span class=\"hljs-tag\">&lt;<span class=\"hljs-title\">div</span> <span class=\"hljs-attribute\">className</span>=<span class=\"hljs-value\">\"templateCardItemTitle\"</span>&gt;</span>{data.title}<span class=\"hljs-tag\">&lt;/<span class=\"hljs-title\">div</span>&gt;</span>\n <span class=\"hljs-tag\">&lt;<span class=\"hljs-title\">div</span> <span class=\"hljs-attribute\">className</span>=<span class=\"hljs-value\">\"templateCardItemContent\"</span>&gt;</span>{data.content}<span class=\"hljs-tag\">&lt;/<span class=\"hljs-title\">div</span>&gt;</span>\n <span class=\"hljs-tag\">&lt;/<span class=\"hljs-title\">div</span>&gt;</span>\n )</span>;\n }\n}\n\n<span class=\"hljs-class\"><span class=\"hljs-keyword\">class</span> <span class=\"hljs-title\">Card</span> <span class=\"hljs-keyword\">extends</span> <span class=\"hljs-title\">React</span>.<span class=\"hljs-title\">Component</span> </span>{\n constructor(props) {\n <span class=\"hljs-keyword\">super</span>(props);\n <span class=\"hljs-keyword\">this</span>.state = {\n cardValues: {},\n showCardDialog: <span class=\"hljs-literal\">false</span>,\n cardList: [{\n title: <span class=\"hljs-string\">'阿里巴巴(中国)有限公司'</span>,\n content: <span class=\"hljs-string\">'浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号'</span>,\n id: (<span class=\"hljs-keyword\">new</span> <span class=\"hljs-built_in\">Date</span>()).getTime(),\n active: <span class=\"hljs-literal\">true</span>,\n }, {\n title: <span class=\"hljs-string\">'阿里巴巴(中国)有限公司阿里巴巴(中国)有限公司'</span>,\n content: <span class=\"hljs-string\">'浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号'</span>,\n id: (<span class=\"hljs-keyword\">new</span> <span class=\"hljs-built_in\">Date</span>()).getTime() + <span class=\"hljs-number\">1</span>,\n }],\n };\n }\n\n componentDidMount() {\n }\n\n componentWillUnmount() {\n }\n\n showNewCardDialog() {\n <span class=\"hljs-keyword\">this</span>.setState({\n action: <span class=\"hljs-string\">'add'</span>,\n showCardDialog: <span class=\"hljs-literal\">true</span>,\n cardValues: {},\n });\n }\n\n handleCard() {\n <span class=\"hljs-keyword\">const</span> data = <span class=\"hljs-keyword\">this</span>.refs.form.getValues();\n\n <span class=\"hljs-keyword\">if</span> (!data.pass) {\n <span class=\"hljs-keyword\">return</span>;\n }\n\n <span class=\"hljs-keyword\">if</span> (<span class=\"hljs-keyword\">this</span>.state.action === <span class=\"hljs-string\">'add'</span>) {\n <span class=\"hljs-keyword\">this</span>.state.cardList.push({\n title: data.values.cardTitle,\n content: data.values.cardContent,\n id: (<span class=\"hljs-keyword\">new</span> <span class=\"hljs-built_in\">Date</span>()).getTime(),\n });\n } <span class=\"hljs-keyword\">else</span> {\n <span class=\"hljs-keyword\">const</span> editData = <span class=\"hljs-keyword\">this</span>.state.editData;\n <span class=\"hljs-keyword\">this</span>.state.cardList.map((item) =&gt; {\n <span class=\"hljs-keyword\">if</span> (item.id === editData.id) {\n item.content = data.values.cardContent;\n item.title = data.values.cardTitle;\n <span class=\"hljs-keyword\">return</span> <span class=\"hljs-literal\">true</span>;\n }\n });\n }\n\n <span class=\"hljs-keyword\">this</span>.state.showCardDialog = <span class=\"hljs-literal\">false</span>;\n <span class=\"hljs-keyword\">this</span>.setState(<span class=\"hljs-keyword\">this</span>.state);\n }\n\n handleCancel() {\n <span class=\"hljs-keyword\">this</span>.setState({\n showCardDialog: <span class=\"hljs-literal\">false</span>,\n });\n }\n\n onEditCard(data) {\n <span class=\"hljs-keyword\">this</span>.state.cardValues.cardTitle = data.title;\n <span class=\"hljs-keyword\">this</span>.state.cardValues.cardContent = data.content;\n <span class=\"hljs-keyword\">this</span>.state.showCardDialog = <span class=\"hljs-literal\">true</span>;\n <span class=\"hljs-keyword\">this</span>.state.action = <span class=\"hljs-string\">'edit'</span>;\n <span class=\"hljs-keyword\">this</span>.state.editData = data;\n <span class=\"hljs-keyword\">this</span>.setState(<span class=\"hljs-keyword\">this</span>.state);\n }\n\n onRemoveCard(data) {\n Dialog.confirm({\n title: <span class=\"hljs-string\">'确定删除?'</span>,\n onOk: () =&gt; {\n <span class=\"hljs-keyword\">this</span>.state.cardList.some((item, i) =&gt; {\n <span class=\"hljs-keyword\">if</span> (item.id === data.id) {\n <span class=\"hljs-keyword\">this</span>.state.cardList.splice(i, <span class=\"hljs-number\">1</span>);\n <span class=\"hljs-keyword\">return</span> <span class=\"hljs-literal\">true</span>;\n }\n });\n <span class=\"hljs-keyword\">this</span>.setState(<span class=\"hljs-keyword\">this</span>.state);\n },\n });\n }\n\n renderCardDialog() {\n <span class=\"hljs-keyword\">return</span> (<span class=\"xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-title\">Dialog</span> <span class=\"hljs-attribute\">ref</span>=<span class=\"hljs-value\">\"modal\"</span>\n <span class=\"hljs-attribute\">visible</span>\n <span class=\"hljs-attribute\">className</span>=<span class=\"hljs-value\">\"newCardDialog\"</span>\n <span class=\"hljs-attribute\">title</span>=<span class=\"hljs-value\">\"添加卡片\"</span> <span class=\"hljs-attribute\">onCancel</span>=<span class=\"hljs-value\">{this.handleCancel.bind(this)}</span>\n <span class=\"hljs-attribute\">footer</span>=<span class=\"hljs-value\">{[</span>\n &lt;<span class=\"hljs-attribute\">Button</span> <span class=\"hljs-attribute\">onClick</span>=<span class=\"hljs-value\">{this.handleCard.bind(this)}</span>&gt;</span>提 交<span class=\"hljs-tag\">&lt;/<span class=\"hljs-title\">Button</span>&gt;</span>,\n <span class=\"hljs-tag\">&lt;<span class=\"hljs-title\">Button</span> <span class=\"hljs-attribute\">onClick</span>=<span class=\"hljs-value\">{this.handleCancel.bind(this)}</span>&gt;</span>取 消<span class=\"hljs-tag\">&lt;/<span class=\"hljs-title\">Button</span>&gt;</span>,\n ]}\n &gt;\n <span class=\"hljs-tag\">&lt;<span class=\"hljs-title\">Form</span> <span class=\"hljs-attribute\">ref</span>=<span class=\"hljs-value\">\"form\"</span> <span class=\"hljs-attribute\">jsxvalues</span>=<span class=\"hljs-value\">{this.state.cardValues}</span>&gt;</span>\n <span class=\"hljs-tag\">&lt;<span class=\"hljs-title\">FormRowTitle</span> <span class=\"hljs-attribute\">jsxtitle</span>=<span class=\"hljs-value\">\"卡片信息\"</span> /&gt;</span>\n <span class=\"hljs-tag\">&lt;<span class=\"hljs-title\">Input</span>\n <span class=\"hljs-attribute\">required</span>\n <span class=\"hljs-attribute\">jsxname</span>=<span class=\"hljs-value\">\"cardTitle\"</span>\n <span class=\"hljs-attribute\">jsxlabel</span>=<span class=\"hljs-value\">\"标题\"</span>\n <span class=\"hljs-attribute\">jsxrules</span>=<span class=\"hljs-value\">{[</span>\n { <span class=\"hljs-attribute\">validator:</span> <span class=\"hljs-attribute\">Validators.isNotEmpty</span>, <span class=\"hljs-attribute\">errMsg:</span> '请填写标题' },\n ]}\n /&gt;</span>\n <span class=\"hljs-tag\">&lt;<span class=\"hljs-title\">Input</span>\n <span class=\"hljs-attribute\">required</span>\n <span class=\"hljs-attribute\">jsxname</span>=<span class=\"hljs-value\">\"cardContent\"</span>\n <span class=\"hljs-attribute\">jsxlabel</span>=<span class=\"hljs-value\">\"内容\"</span>\n <span class=\"hljs-attribute\">jsxrules</span>=<span class=\"hljs-value\">{[</span>\n { <span class=\"hljs-attribute\">validator:</span> <span class=\"hljs-attribute\">Validators.isNotEmpty</span>, <span class=\"hljs-attribute\">errMsg:</span> '请填写内容' },\n ]}\n /&gt;</span>\n <span class=\"hljs-tag\">&lt;/<span class=\"hljs-title\">Form</span>&gt;</span>\n <span class=\"hljs-tag\">&lt;/<span class=\"hljs-title\">Dialog</span>&gt;</span>)</span>;\n }\n\n render() {\n <span class=\"hljs-keyword\">const</span> me = <span class=\"hljs-keyword\">this</span>;\n <span class=\"hljs-keyword\">return</span> (\n <span class=\"xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-title\">div</span> <span class=\"hljs-attribute\">className</span>=<span class=\"hljs-value\">\"pageDemo\"</span>&gt;</span>\n <span class=\"hljs-tag\">&lt;<span class=\"hljs-title\">div</span> <span class=\"hljs-attribute\">className</span>=<span class=\"hljs-value\">\"templateCardWrap\"</span>&gt;</span>\n <span class=\"hljs-tag\">&lt;<span class=\"hljs-title\">ul</span> <span class=\"hljs-attribute\">className</span>=<span class=\"hljs-value\">\"templateCardList clearfix\"</span>&gt;</span>\n {\n me.state.cardList.map((item, i) =&gt; (<span class=\"hljs-tag\">&lt;<span class=\"hljs-title\">li</span> <span class=\"hljs-attribute\">className</span>=<span class=\"hljs-value\">{`templateCardItem</span> ${<span class=\"hljs-attribute\">item.active</span> ? '<span class=\"hljs-attribute\">active</span>' <span class=\"hljs-attribute\">:</span> ''}`} <span class=\"hljs-attribute\">key</span>=<span class=\"hljs-value\">{`templateCardItem${i}`}</span>&gt;</span>\n <span class=\"hljs-tag\">&lt;<span class=\"hljs-title\">CardItem</span> <span class=\"hljs-attribute\">data</span>=<span class=\"hljs-value\">{item}</span> /&gt;</span>\n <span class=\"hljs-tag\">&lt;<span class=\"hljs-title\">div</span> <span class=\"hljs-attribute\">className</span>=<span class=\"hljs-value\">\"templateCardEdit\"</span>&gt;</span>\n <span class=\"hljs-tag\">&lt;<span class=\"hljs-title\">a</span> <span class=\"hljs-attribute\">href</span>=<span class=\"hljs-value\">\"javascript:void(0);\"</span> <span class=\"hljs-attribute\">onClick</span>=<span class=\"hljs-value\">{me.onEditCard.bind(me,</span> <span class=\"hljs-attribute\">item</span>)}&gt;</span>修改<span class=\"hljs-tag\">&lt;/<span class=\"hljs-title\">a</span>&gt;</span>\n <span class=\"hljs-tag\">&lt;<span class=\"hljs-title\">a</span> <span class=\"hljs-attribute\">href</span>=<span class=\"hljs-value\">\"javascript:void(0);\"</span> <span class=\"hljs-attribute\">onClick</span>=<span class=\"hljs-value\">{me.onRemoveCard.bind(me,</span> <span class=\"hljs-attribute\">item</span>)}&gt;</span>删除<span class=\"hljs-tag\">&lt;/<span class=\"hljs-title\">a</span>&gt;</span>\n <span class=\"hljs-tag\">&lt;/<span class=\"hljs-title\">div</span>&gt;</span>\n <span class=\"hljs-tag\">&lt;/<span class=\"hljs-title\">li</span>&gt;</span>)</span>)\n }\n &lt;li className=<span class=\"hljs-string\">\"templateCardItem templateAddCard\"</span> onClick={me.showNewCardDialog.bind(<span class=\"hljs-keyword\">this</span>)}&gt;\n <span class=\"xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-title\">div</span>&gt;</span>\n <span class=\"hljs-tag\">&lt;<span class=\"hljs-title\">img</span> <span class=\"hljs-attribute\">src</span>=<span class=\"hljs-value\">{'https:</span>//<span class=\"hljs-attribute\">img.alicdn.com</span>/<span class=\"hljs-attribute\">tps</span>/<span class=\"hljs-attribute\">TB14qDfPFXXXXclXXXXXXXXXXXX-200-200.png</span>'} <span class=\"hljs-attribute\">className</span>=<span class=\"hljs-value\">\"templateAddCardBtn\"</span> /&gt;</span>\n <span class=\"hljs-tag\">&lt;/<span class=\"hljs-title\">div</span>&gt;</span>\n <span class=\"hljs-tag\">&lt;<span class=\"hljs-title\">p</span> <span class=\"hljs-attribute\">className</span>=<span class=\"hljs-value\">\"templateCardTxt\"</span>&gt;</span>添加卡片<span class=\"hljs-tag\">&lt;/<span class=\"hljs-title\">p</span>&gt;</span>\n <span class=\"hljs-tag\">&lt;/<span class=\"hljs-title\">li</span>&gt;</span>\n <span class=\"hljs-tag\">&lt;/<span class=\"hljs-title\">ul</span>&gt;</span>\n <span class=\"hljs-tag\">&lt;/<span class=\"hljs-title\">div</span>&gt;</span>\n {\n me.state.showCardDialog ? me.renderCardDialog() : null\n }\n <span class=\"hljs-tag\">&lt;/<span class=\"hljs-title\">div</span>&gt;</span>\n )</span>;\n }\n}\n\n<span class=\"hljs-class\"><span class=\"hljs-keyword\">class</span> <span class=\"hljs-title\">Demo</span> <span class=\"hljs-keyword\">extends</span> <span class=\"hljs-title\">React</span>.<span class=\"hljs-title\">Component</span> </span>{\n constructor(props) {\n <span class=\"hljs-keyword\">super</span>(props);\n <span class=\"hljs-keyword\">this</span>.state = {\n };\n }\n\n render() {\n <span class=\"hljs-keyword\">const</span> me = <span class=\"hljs-keyword\">this</span>;\n <span class=\"hljs-keyword\">return</span> (<span class=\"xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-title\">div</span> <span class=\"hljs-attribute\">className</span>=<span class=\"hljs-value\">\"pageDemo\"</span>&gt;</span>\n <span class=\"hljs-tag\">&lt;<span class=\"hljs-title\">Card</span> /&gt;</span>\n <span class=\"hljs-tag\">&lt;/<span class=\"hljs-title\">div</span>&gt;</span>)</span>;\n }\n}\n\nReactDOM.render(\n <span class=\"xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-title\">Demo</span> /&gt;</span>\n, document.getElementById('scene-card-demo-basic'));\n\n/* JS END CSS START*/</span></code></pre></div><style type=\"text/css\">.pageDemo {\n width: 1000px;\n margin: 0 auto;\n background: white;\n min-height: 300px;\n}\n\n.templateCardWrap {\n overflow: hidden;\n}\n.templateCardWrap .clearfix:after {\n content: \"\";\n display: block;\n clear: both;\n width: 0; \n}\n.templateCardWrap .templateCardList {\n width: calc(100% + 10px);\n margin-left: -10px;\n margin-top: -10px;\n}\n.templateCardWrap .templateCardItem {\n float: left;\n width: 270px;\n height: 158px;\n border: 1px solid #ccc;\n position: relative;\n margin-left: 20px;\n margin-top: 20px;\n padding: 20px 16px;\n}\n\n.templateCardWrap .templateCardItem.active {\n box-shadow: 0 2px 10px 0 rgba(0, 0, 0, 0.15);\n}\n.templateCardWrap .templateAddCardBtn {\n display: block;\n width: 66px;\n height: 66px;\n margin: 24px auto 12px;\n}\n.templateCardWrap .templateCardTxt {\n text-align: center;\n}\n.templateCardWrap .templateAddCard {\n cursor: pointer;\n}\n.templateCardWrap .templateCardEdit {\n position: absolute;\n bottom: 10px;\n right: 0;\n line-height: 1;\n}\n.templateCardWrap .templateCardEdit a {\n text-decoration: none;\n margin-right: 10px;\n color: #2599F2;\n}\n\n.templateCardItemTitle {\n color: #333;\n font-size: 14px;\n line-height: 1.5;\n}\n.templateCardItemContent {\n color: #999;\n margin-top: 10px;\n line-height: 1.5;\n}\n.templateCardItemWrap {\n height: calc(100% - 10px);\n overflow: hidden;\n}\n</style><div class=\"highlight\"><pre><code class=\"css\"><span class=\"hljs-class\">.pageDemo</span> <span class=\"hljs-rules\">{\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">width</span>:<span class=\"hljs-value\"> <span class=\"hljs-number\">1000px</span></span></span>;\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">margin</span>:<span class=\"hljs-value\"> <span class=\"hljs-number\">0</span> auto</span></span>;\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">background</span>:<span class=\"hljs-value\"> white</span></span>;\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">min-height</span>:<span class=\"hljs-value\"> <span class=\"hljs-number\">300px</span></span></span>;\n}</span>\n\n<span class=\"hljs-class\">.templateCardWrap</span> <span class=\"hljs-rules\">{\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">overflow</span>:<span class=\"hljs-value\"> hidden</span></span>;\n}</span>\n<span class=\"hljs-class\">.templateCardWrap</span> <span class=\"hljs-class\">.clearfix</span><span class=\"hljs-pseudo\">:after</span> <span class=\"hljs-rules\">{\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">content</span>:<span class=\"hljs-value\"> <span class=\"hljs-string\">\"\"</span></span></span>;\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">display</span>:<span class=\"hljs-value\"> block</span></span>;\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">clear</span>:<span class=\"hljs-value\"> both</span></span>;\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">width</span>:<span class=\"hljs-value\"> <span class=\"hljs-number\">0</span></span></span>; \n}</span>\n<span class=\"hljs-class\">.templateCardWrap</span> <span class=\"hljs-class\">.templateCardList</span> <span class=\"hljs-rules\">{\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">width</span>:<span class=\"hljs-value\"> <span class=\"hljs-function\">calc</span>(<span class=\"hljs-number\">100%</span> + <span class=\"hljs-number\">10px</span>)</span></span>;\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">margin-left</span>:<span class=\"hljs-value\"> -<span class=\"hljs-number\">10px</span></span></span>;\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">margin-top</span>:<span class=\"hljs-value\"> -<span class=\"hljs-number\">10px</span></span></span>;\n}</span>\n<span class=\"hljs-class\">.templateCardWrap</span> <span class=\"hljs-class\">.templateCardItem</span> <span class=\"hljs-rules\">{\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">float</span>:<span class=\"hljs-value\"> left</span></span>;\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">width</span>:<span class=\"hljs-value\"> <span class=\"hljs-number\">270px</span></span></span>;\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">height</span>:<span class=\"hljs-value\"> <span class=\"hljs-number\">158px</span></span></span>;\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">border</span>:<span class=\"hljs-value\"> <span class=\"hljs-number\">1px</span> solid <span class=\"hljs-hexcolor\">#ccc</span></span></span>;\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">position</span>:<span class=\"hljs-value\"> relative</span></span>;\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">margin-left</span>:<span class=\"hljs-value\"> <span class=\"hljs-number\">20px</span></span></span>;\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">margin-top</span>:<span class=\"hljs-value\"> <span class=\"hljs-number\">20px</span></span></span>;\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">padding</span>:<span class=\"hljs-value\"> <span class=\"hljs-number\">20px</span> <span class=\"hljs-number\">16px</span></span></span>;\n}</span>\n\n<span class=\"hljs-class\">.templateCardWrap</span> <span class=\"hljs-class\">.templateCardItem</span><span class=\"hljs-class\">.active</span> <span class=\"hljs-rules\">{\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">box-shadow</span>:<span class=\"hljs-value\"> <span class=\"hljs-number\">0</span> <span class=\"hljs-number\">2px</span> <span class=\"hljs-number\">10px</span> <span class=\"hljs-number\">0</span> <span class=\"hljs-function\">rgba</span>(<span class=\"hljs-number\">0</span>, <span class=\"hljs-number\">0</span>, <span class=\"hljs-number\">0</span>, <span class=\"hljs-number\">0.15</span>)</span></span>;\n}</span>\n<span class=\"hljs-class\">.templateCardWrap</span> <span class=\"hljs-class\">.templateAddCardBtn</span> <span class=\"hljs-rules\">{\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">display</span>:<span class=\"hljs-value\"> block</span></span>;\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">width</span>:<span class=\"hljs-value\"> <span class=\"hljs-number\">66px</span></span></span>;\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">height</span>:<span class=\"hljs-value\"> <span class=\"hljs-number\">66px</span></span></span>;\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">margin</span>:<span class=\"hljs-value\"> <span class=\"hljs-number\">24px</span> auto <span class=\"hljs-number\">12px</span></span></span>;\n}</span>\n<span class=\"hljs-class\">.templateCardWrap</span> <span class=\"hljs-class\">.templateCardTxt</span> <span class=\"hljs-rules\">{\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">text-align</span>:<span class=\"hljs-value\"> center</span></span>;\n}</span>\n<span class=\"hljs-class\">.templateCardWrap</span> <span class=\"hljs-class\">.templateAddCard</span> <span class=\"hljs-rules\">{\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">cursor</span>:<span class=\"hljs-value\"> pointer</span></span>;\n}</span>\n<span class=\"hljs-class\">.templateCardWrap</span> <span class=\"hljs-class\">.templateCardEdit</span> <span class=\"hljs-rules\">{\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">position</span>:<span class=\"hljs-value\"> absolute</span></span>;\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">bottom</span>:<span class=\"hljs-value\"> <span class=\"hljs-number\">10px</span></span></span>;\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">right</span>:<span class=\"hljs-value\"> <span class=\"hljs-number\">0</span></span></span>;\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">line-height</span>:<span class=\"hljs-value\"> <span class=\"hljs-number\">1</span></span></span>;\n}</span>\n<span class=\"hljs-class\">.templateCardWrap</span> <span class=\"hljs-class\">.templateCardEdit</span> <span class=\"hljs-tag\">a</span> <span class=\"hljs-rules\">{\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">text-decoration</span>:<span class=\"hljs-value\"> none</span></span>;\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">margin-right</span>:<span class=\"hljs-value\"> <span class=\"hljs-number\">10px</span></span></span>;\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">color</span>:<span class=\"hljs-value\"> <span class=\"hljs-hexcolor\">#2599F2</span></span></span>;\n}</span>\n\n<span class=\"hljs-class\">.templateCardItemTitle</span> <span class=\"hljs-rules\">{\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">color</span>:<span class=\"hljs-value\"> <span class=\"hljs-hexcolor\">#333</span></span></span>;\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">font-size</span>:<span class=\"hljs-value\"> <span class=\"hljs-number\">14px</span></span></span>;\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">line-height</span>:<span class=\"hljs-value\"> <span class=\"hljs-number\">1.5</span></span></span>;\n}</span>\n<span class=\"hljs-class\">.templateCardItemContent</span> <span class=\"hljs-rules\">{\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">color</span>:<span class=\"hljs-value\"> <span class=\"hljs-hexcolor\">#999</span></span></span>;\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">margin-top</span>:<span class=\"hljs-value\"> <span class=\"hljs-number\">10px</span></span></span>;\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">line-height</span>:<span class=\"hljs-value\"> <span class=\"hljs-number\">1.5</span></span></span>;\n}</span>\n<span class=\"hljs-class\">.templateCardItemWrap</span> <span class=\"hljs-rules\">{\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">height</span>:<span class=\"hljs-value\"> <span class=\"hljs-function\">calc</span>(<span class=\"hljs-number\">100%</span> - <span class=\"hljs-number\">10px</span>)</span></span>;\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">overflow</span>:<span class=\"hljs-value\"> hidden</span></span>;\n}</span>\n</code></pre></div>"},"status":"public","toc":""},{"title":"区块信息展示(可拖动)","id":"scene-card-demo-draggable","tags":[],"filepath":"site/scene/card/demo/draggable.md","directory":"scene/card/demo","filename":"draggable","meta":{"title":"区块信息展示(可拖动)","description":"\n","order":"1","filepath":"site/scene/card/demo/draggable.md","filename":"draggable","directory":"scene/card/demo","id":"scene-card-demo-draggable","template":"demos","html":"<script>(function(){'use strict';\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nvar _classnames = require('classnames');\n\nvar _classnames2 = _interopRequireDefault(_classnames);\n\nvar _uxcore = require('uxcore');\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\n;\nvar Input = _uxcore.Form.InputFormField,\n FormRow = _uxcore.Form.FormRow,\n FormRowTitle = _uxcore.Form.FormRowTitle,\n Validators = _uxcore.Form.Validators,\n OtherFormField = _uxcore.Form.OtherFormField,\n DateFormField = _uxcore.Form.DateFormField,\n CascadeSelectFormField = _uxcore.Form.CascadeSelectFormField,\n SelectFormField = _uxcore.Form.SelectFormField,\n CheckboxGroupFormField = _uxcore.Form.CheckboxGroupFormField;\n\n\nvar Item = CheckboxGroupFormField.Item;\n\nvar CardItem = function (_React$Component) {\n _inherits(CardItem, _React$Component);\n\n function CardItem(props) {\n _classCallCheck(this, CardItem);\n\n var _this = _possibleConstructorReturn(this, (CardItem.__proto__ || Object.getPrototypeOf(CardItem)).call(this, props));\n\n _this.state = {};\n return _this;\n }\n\n _createClass(CardItem, [{\n key: 'componentDidMount',\n value: function componentDidMount() {}\n }, {\n key: 'render',\n value: function render() {\n var me = this;\n var data = this.props.data;\n return React.createElement(\n 'div',\n { className: 'templateCardItemWrap' },\n React.createElement(\n 'div',\n { className: 'templateCardItemTitle' },\n data.title\n ),\n React.createElement(\n 'div',\n { className: 'templateCardItemContent' },\n data.content\n )\n );\n }\n }]);\n\n return CardItem;\n}(React.Component);\n\nvar Card = function (_React$Component2) {\n _inherits(Card, _React$Component2);\n\n function Card(props) {\n _classCallCheck(this, Card);\n\n var _this2 = _possibleConstructorReturn(this, (Card.__proto__ || Object.getPrototypeOf(Card)).call(this, props));\n\n _this2.state = {\n cardValues: {},\n showCardDialog: false,\n cardList: [{\n title: '阿里巴巴(中国)有限公司',\n content: '浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号',\n id: new Date().getTime()\n }, {\n title: '阿里巴巴(中国)有限公司阿里巴巴(中国)有限公司',\n content: '浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号',\n id: new Date().getTime() + 1\n }]\n };\n return _this2;\n }\n\n _createClass(Card, [{\n key: 'componentDidMount',\n value: function componentDidMount() {}\n }, {\n key: 'componentWillUnmount',\n value: function componentWillUnmount() {}\n }, {\n key: 'showNewCardDialog',\n value: function showNewCardDialog() {\n this.setState({\n action: 'add',\n showCardDialog: true,\n cardValues: {}\n });\n }\n }, {\n key: 'handleCard',\n value: function handleCard() {\n var data = this.refs.form.getValues();\n\n if (!data.pass) {\n return;\n }\n\n if (this.state.action === 'add') {\n this.state.cardList.push({\n title: data.values.cardTitle,\n content: data.values.cardContent,\n id: new Date().getTime()\n });\n } else {\n var editData = this.state.editData;\n this.state.cardList.map(function (item) {\n if (item.id === editData.id) {\n item.title = data.values.cardTitle;\n item.content = data.values.cardContent;\n return true;\n }\n });\n }\n\n this.state.showCardDialog = false;\n this.setState(this.state);\n }\n }, {\n key: 'handleCancel',\n value: function handleCancel() {\n this.setState({\n showCardDialog: false\n });\n }\n }, {\n key: 'onEditCard',\n value: function onEditCard(data) {\n this.state.cardValues.cardTitle = data.title;\n this.state.cardValues.cardContent = data.content;\n this.state.showCardDialog = true;\n this.state.action = 'edit';\n this.state.editData = data;\n this.setState(this.state);\n }\n }, {\n key: 'onRemoveCard',\n value: function onRemoveCard(data) {\n var _this3 = this;\n\n _uxcore.Dialog.confirm({\n title: '确定删除?',\n onOk: function onOk() {\n _this3.state.cardList.some(function (item, i) {\n if (item.id === data.id) {\n _this3.state.cardList.splice(i, 1);\n return true;\n }\n });\n _this3.setState(_this3.state);\n }\n });\n }\n }, {\n key: 'onDragStart',\n value: function onDragStart(data) {\n this.state.dragItemData = data;\n }\n }, {\n key: 'onDrop',\n value: function onDrop(data) {\n this.switchItem(this.state.dragItemData, data);\n }\n }, {\n key: 'onDragEnter',\n value: function onDragEnter(e) {\n e.target.classList.add('dragOver');\n }\n }, {\n key: 'onDragOver',\n value: function onDragOver(e) {\n e.preventDefault();\n }\n }, {\n key: 'onDragLeave',\n value: function onDragLeave(e) {\n e.preventDefault();\n e.target.classList.remove('dragOver');\n }\n }, {\n key: 'findItem',\n value: function findItem(data) {\n var index = -1;\n this.state.cardList.some(function (item, i) {\n if (item.id === data.id) {\n index = i;\n return true;\n }\n });\n return index;\n }\n }, {\n key: 'switchItem',\n value: function switchItem(dragItem, dropItem) {\n var cardList = this.state.cardList;\n var dragIndex = this.findItem(dragItem);\n var dropIndex = this.findItem(dropItem);\n\n if (dragIndex < 0 || dropIndex < 0) {\n // 'error';\n return;\n }\n\n var item = cardList[dragIndex];\n cardList.splice(dragIndex, 1);\n cardList.splice(dropIndex, 0, item);\n\n this.setState(this.state);\n }\n }, {\n key: 'renderCardDialog',\n value: function renderCardDialog() {\n return React.createElement(\n _uxcore.Dialog,\n { ref: 'modal',\n visible: true,\n className: 'newCardDialog',\n title: '\\u6DFB\\u52A0\\u5361\\u7247', onCancel: this.handleCancel.bind(this),\n footer: [React.createElement(\n _uxcore.Button,\n { onClick: this.handleCard.bind(this) },\n '\\u63D0 \\u4EA4'\n ), React.createElement(\n _uxcore.Button,\n { onClick: this.handleCancel.bind(this) },\n '\\u53D6 \\u6D88'\n )]\n },\n React.createElement(\n _uxcore.Form,\n { ref: 'form', jsxvalues: this.state.cardValues },\n React.createElement(FormRowTitle, { jsxtitle: '\\u5361\\u7247\\u4FE1\\u606F' }),\n React.createElement(Input, {\n required: true,\n jsxname: 'cardTitle',\n jsxlabel: '\\u6807\\u9898',\n jsxrules: [{ validator: Validators.isNotEmpty, errMsg: '请填写标题' }]\n }),\n React.createElement(Input, {\n required: true,\n jsxname: 'cardContent',\n jsxlabel: '\\u5185\\u5BB9',\n jsxrules: [{ validator: Validators.isNotEmpty, errMsg: '请填写内容' }]\n })\n )\n );\n }\n }, {\n key: 'render',\n value: function render() {\n var me = this;\n return React.createElement(\n 'div',\n { className: 'pageDemo1' },\n React.createElement(\n 'div',\n { className: 'templateCardWrap' },\n React.createElement(\n 'ul',\n { className: 'templateCardList clearfix' },\n me.state.cardList.map(function (item, i) {\n return React.createElement(\n 'li',\n { className: 'templateCardItem', draggable: true, onDragStart: me.onDragStart.bind(me, item), onDragEnter: me.onDragEnter, onDragOver: me.onDragOver, onDrop: me.onDrop.bind(me, item), onDragLeave: me.onDragLeave, key: 'templateCardItem' + i },\n React.createElement(CardItem, { data: item }),\n React.createElement(\n 'div',\n { className: 'templateCardEdit' },\n React.createElement(\n 'a',\n { href: 'javascript:void(0);', onClick: me.onEditCard.bind(me, item) },\n '\\u4FEE\\u6539'\n ),\n React.createElement(\n 'a',\n { href: 'javascript:void(0);', onClick: me.onRemoveCard.bind(me, item) },\n '\\u5220\\u9664'\n )\n )\n );\n }),\n React.createElement(\n 'li',\n { className: 'templateCardItem templateAddCard', onClick: me.showNewCardDialog.bind(this) },\n React.createElement(\n 'div',\n null,\n React.createElement('img', { src: 'https://img.alicdn.com/tps/TB14qDfPFXXXXclXXXXXXXXXXXX-200-200.png', className: 'templateAddCardBtn' })\n ),\n React.createElement(\n 'p',\n { className: 'templateCardTxt' },\n '\\u6DFB\\u52A0\\u5361\\u7247'\n )\n )\n )\n ),\n me.state.showCardDialog ? me.renderCardDialog() : null\n );\n }\n }]);\n\n return Card;\n}(React.Component);\n\nvar Demo = function (_React$Component3) {\n _inherits(Demo, _React$Component3);\n\n function Demo(props) {\n _classCallCheck(this, Demo);\n\n var _this4 = _possibleConstructorReturn(this, (Demo.__proto__ || Object.getPrototypeOf(Demo)).call(this, props));\n\n _this4.state = {};\n return _this4;\n }\n\n _createClass(Demo, [{\n key: 'render',\n value: function render() {\n var me = this;\n return React.createElement(\n 'div',\n { className: 'pageDemo' },\n React.createElement(Card, null)\n );\n }\n }]);\n\n return Demo;\n}(React.Component);\n\nReactDOM.render(React.createElement(Demo, null), document.getElementById('scene-card-demo-draggable'));\n\n/* JS END CSS START*/})()</script><div class=\"highlight\"><pre><code class=\"javascript\"><span class=\"hljs-keyword\">import</span> classnames <span class=\"hljs-keyword\">from</span> <span class=\"hljs-string\">'classnames'</span>;;\n<span class=\"hljs-keyword\">import</span> { Form } <span class=\"hljs-keyword\">from</span> <span class=\"hljs-string\">'uxcore'</span>;\n<span class=\"hljs-keyword\">import</span> { Button } <span class=\"hljs-keyword\">from</span> <span class=\"hljs-string\">'uxcore'</span>;\n<span class=\"hljs-keyword\">import</span> { Dialog } <span class=\"hljs-keyword\">from</span> <span class=\"hljs-string\">'uxcore'</span>;\n<span class=\"hljs-keyword\">const</span> {\n InputFormField: Input,\n FormRow,\n FormRowTitle,\n Validators,\n OtherFormField,\n DateFormField,\n CascadeSelectFormField,\n SelectFormField,\n CheckboxGroupFormField,\n} = Form;\n\n<span class=\"hljs-keyword\">const</span> Item = CheckboxGroupFormField.Item;\n\n\n<span class=\"hljs-class\"><span class=\"hljs-keyword\">class</span> <span class=\"hljs-title\">CardItem</span> <span class=\"hljs-keyword\">extends</span> <span class=\"hljs-title\">React</span>.<span class=\"hljs-title\">Component</span> </span>{\n constructor(props) {\n <span class=\"hljs-keyword\">super</span>(props);\n <span class=\"hljs-keyword\">this</span>.state = {\n };\n }\n\n componentDidMount() {\n }\n\n render() {\n <span class=\"hljs-keyword\">const</span> me = <span class=\"hljs-keyword\">this</span>;\n <span class=\"hljs-keyword\">const</span> data = <span class=\"hljs-keyword\">this</span>.props.data;\n <span class=\"hljs-keyword\">return</span> (\n <span class=\"xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-title\">div</span> <span class=\"hljs-attribute\">className</span>=<span class=\"hljs-value\">\"templateCardItemWrap\"</span>&gt;</span>\n <span class=\"hljs-tag\">&lt;<span class=\"hljs-title\">div</span> <span class=\"hljs-attribute\">className</span>=<span class=\"hljs-value\">\"templateCardItemTitle\"</span>&gt;</span>{data.title}<span class=\"hljs-tag\">&lt;/<span class=\"hljs-title\">div</span>&gt;</span>\n <span class=\"hljs-tag\">&lt;<span class=\"hljs-title\">div</span> <span class=\"hljs-attribute\">className</span>=<span class=\"hljs-value\">\"templateCardItemContent\"</span>&gt;</span>{data.content}<span class=\"hljs-tag\">&lt;/<span class=\"hljs-title\">div</span>&gt;</span>\n <span class=\"hljs-tag\">&lt;/<span class=\"hljs-title\">div</span>&gt;</span>\n )</span>;\n }\n}\n\n<span class=\"hljs-class\"><span class=\"hljs-keyword\">class</span> <span class=\"hljs-title\">Card</span> <span class=\"hljs-keyword\">extends</span> <span class=\"hljs-title\">React</span>.<span class=\"hljs-title\">Component</span> </span>{\n constructor(props) {\n <span class=\"hljs-keyword\">super</span>(props);\n <span class=\"hljs-keyword\">this</span>.state = {\n cardValues: {},\n showCardDialog: <span class=\"hljs-literal\">false</span>,\n cardList: [{\n title: <span class=\"hljs-string\">'阿里巴巴(中国)有限公司'</span>,\n content: <span class=\"hljs-string\">'浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号'</span>,\n id: (<span class=\"hljs-keyword\">new</span> <span class=\"hljs-built_in\">Date</span>()).getTime(),\n }, {\n title: <span class=\"hljs-string\">'阿里巴巴(中国)有限公司阿里巴巴(中国)有限公司'</span>,\n content: <span class=\"hljs-string\">'浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号'</span>,\n id: (<span class=\"hljs-keyword\">new</span> <span class=\"hljs-built_in\">Date</span>()).getTime() + <span class=\"hljs-number\">1</span>,\n }],\n };\n }\n\n componentDidMount() {\n }\n\n componentWillUnmount() {\n }\n\n showNewCardDialog() {\n <span class=\"hljs-keyword\">this</span>.setState({\n action: <span class=\"hljs-string\">'add'</span>,\n showCardDialog: <span class=\"hljs-literal\">true</span>,\n cardValues: {},\n });\n }\n\n handleCard() {\n <span class=\"hljs-keyword\">const</span> data = <span class=\"hljs-keyword\">this</span>.refs.form.getValues();\n\n <span class=\"hljs-keyword\">if</span> (!data.pass) {\n <span class=\"hljs-keyword\">return</span>;\n }\n\n <span class=\"hljs-keyword\">if</span> (<span class=\"hljs-keyword\">this</span>.state.action === <span class=\"hljs-string\">'add'</span>) {\n <span class=\"hljs-keyword\">this</span>.state.cardList.push({\n title: data.values.cardTitle,\n content: data.values.cardContent,\n id: (<span class=\"hljs-keyword\">new</span> <span class=\"hljs-built_in\">Date</span>()).getTime(),\n });\n } <span class=\"hljs-keyword\">else</span> {\n <span class=\"hljs-keyword\">const</span> editData = <span class=\"hljs-keyword\">this</span>.state.editData;\n <span class=\"hljs-keyword\">this</span>.state.cardList.map((item) =&gt; {\n <span class=\"hljs-keyword\">if</span> (item.id === editData.id) {\n item.title = data.values.cardTitle;\n item.content = data.values.cardContent;\n <span class=\"hljs-keyword\">return</span> <span class=\"hljs-literal\">true</span>;\n }\n });\n }\n\n <span class=\"hljs-keyword\">this</span>.state.showCardDialog = <span class=\"hljs-literal\">false</span>;\n <span class=\"hljs-keyword\">this</span>.setState(<span class=\"hljs-keyword\">this</span>.state);\n }\n\n handleCancel() {\n <span class=\"hljs-keyword\">this</span>.setState({\n showCardDialog: <span class=\"hljs-literal\">false</span>,\n });\n }\n\n onEditCard(data) {\n <span class=\"hljs-keyword\">this</span>.state.cardValues.cardTitle = data.title;\n <span class=\"hljs-keyword\">this</span>.state.cardValues.cardContent = data.content;\n <span class=\"hljs-keyword\">this</span>.state.showCardDialog = <span class=\"hljs-literal\">true</span>;\n <span class=\"hljs-keyword\">this</span>.state.action = <span class=\"hljs-string\">'edit'</span>;\n <span class=\"hljs-keyword\">this</span>.state.editData = data;\n <span class=\"hljs-keyword\">this</span>.setState(<span class=\"hljs-keyword\">this</span>.state);\n }\n\n onRemoveCard(data) {\n Dialog.confirm({\n title: <span class=\"hljs-string\">'确定删除?'</span>,\n onOk: () =&gt; {\n <span class=\"hljs-keyword\">this</span>.state.cardList.some((item, i) =&gt; {\n <span class=\"hljs-keyword\">if</span> (item.id === data.id) {\n <span class=\"hljs-keyword\">this</span>.state.cardList.splice(i, <span class=\"hljs-number\">1</span>);\n <span class=\"hljs-keyword\">return</span> <span class=\"hljs-literal\">true</span>;\n }\n });\n <span class=\"hljs-keyword\">this</span>.setState(<span class=\"hljs-keyword\">this</span>.state);\n },\n });\n }\n\n onDragStart(data) {\n <span class=\"hljs-keyword\">this</span>.state.dragItemData = data;\n }\n\n onDrop(data) {\n <span class=\"hljs-keyword\">this</span>.switchItem(<span class=\"hljs-keyword\">this</span>.state.dragItemData, data);\n }\n\n onDragEnter(e) {\n e.target.classList.add(<span class=\"hljs-string\">'dragOver'</span>);\n }\n onDragOver(e) {\n e.preventDefault();\n }\n\n onDragLeave(e) {\n e.preventDefault();\n e.target.classList.remove(<span class=\"hljs-string\">'dragOver'</span>);\n }\n\n findItem(data) {\n <span class=\"hljs-keyword\">let</span> index = -<span class=\"hljs-number\">1</span>;\n <span class=\"hljs-keyword\">this</span>.state.cardList.some((item, i) =&gt; {\n <span class=\"hljs-keyword\">if</span> (item.id === data.id) {\n index = i;\n <span class=\"hljs-keyword\">return</span> <span class=\"hljs-literal\">true</span>;\n }\n });\n <span class=\"hljs-keyword\">return</span> index;\n }\n\n switchItem(dragItem, dropItem) {\n <span class=\"hljs-keyword\">const</span> cardList = <span class=\"hljs-keyword\">this</span>.state.cardList;\n <span class=\"hljs-keyword\">const</span> dragIndex = <span class=\"hljs-keyword\">this</span>.findItem(dragItem);\n <span class=\"hljs-keyword\">const</span> dropIndex = <span class=\"hljs-keyword\">this</span>.findItem(dropItem);\n\n <span class=\"hljs-keyword\">if</span> (dragIndex &lt; <span class=\"hljs-number\">0</span> || dropIndex &lt; <span class=\"hljs-number\">0</span>) {\n <span class=\"hljs-comment\">// 'error';</span>\n <span class=\"hljs-keyword\">return</span>;\n }\n\n <span class=\"hljs-keyword\">const</span> item = cardList[dragIndex];\n cardList.splice(dragIndex, <span class=\"hljs-number\">1</span>);\n cardList.splice(dropIndex, <span class=\"hljs-number\">0</span>, item);\n\n <span class=\"hljs-keyword\">this</span>.setState(<span class=\"hljs-keyword\">this</span>.state);\n }\n\n renderCardDialog() {\n <span class=\"hljs-keyword\">return</span> (<span class=\"xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-title\">Dialog</span> <span class=\"hljs-attribute\">ref</span>=<span class=\"hljs-value\">\"modal\"</span>\n <span class=\"hljs-attribute\">visible</span>\n <span class=\"hljs-attribute\">className</span>=<span class=\"hljs-value\">\"newCardDialog\"</span>\n <span class=\"hljs-attribute\">title</span>=<span class=\"hljs-value\">\"添加卡片\"</span> <span class=\"hljs-attribute\">onCancel</span>=<span class=\"hljs-value\">{this.handleCancel.bind(this)}</span>\n <span class=\"hljs-attribute\">footer</span>=<span class=\"hljs-value\">{[</span>\n &lt;<span class=\"hljs-attribute\">Button</span> <span class=\"hljs-attribute\">onClick</span>=<span class=\"hljs-value\">{this.handleCard.bind(this)}</span>&gt;</span>提 交<span class=\"hljs-tag\">&lt;/<span class=\"hljs-title\">Button</span>&gt;</span>,\n <span class=\"hljs-tag\">&lt;<span class=\"hljs-title\">Button</span> <span class=\"hljs-attribute\">onClick</span>=<span class=\"hljs-value\">{this.handleCancel.bind(this)}</span>&gt;</span>取 消<span class=\"hljs-tag\">&lt;/<span class=\"hljs-title\">Button</span>&gt;</span>,\n ]}\n &gt;\n <span class=\"hljs-tag\">&lt;<span class=\"hljs-title\">Form</span> <span class=\"hljs-attribute\">ref</span>=<span class=\"hljs-value\">\"form\"</span> <span class=\"hljs-attribute\">jsxvalues</span>=<span class=\"hljs-value\">{this.state.cardValues}</span>&gt;</span>\n <span class=\"hljs-tag\">&lt;<span class=\"hljs-title\">FormRowTitle</span> <span class=\"hljs-attribute\">jsxtitle</span>=<span class=\"hljs-value\">\"卡片信息\"</span> /&gt;</span>\n <span class=\"hljs-tag\">&lt;<span class=\"hljs-title\">Input</span>\n <span class=\"hljs-attribute\">required</span>\n <span class=\"hljs-attribute\">jsxname</span>=<span class=\"hljs-value\">\"cardTitle\"</span>\n <span class=\"hljs-attribute\">jsxlabel</span>=<span class=\"hljs-value\">\"标题\"</span>\n <span class=\"hljs-attribute\">jsxrules</span>=<span class=\"hljs-value\">{[</span>\n { <span class=\"hljs-attribute\">validator:</span> <span class=\"hljs-attribute\">Validators.isNotEmpty</span>, <span class=\"hljs-attribute\">errMsg:</span> '请填写标题' },\n ]}\n /&gt;</span>\n <span class=\"hljs-tag\">&lt;<span class=\"hljs-title\">Input</span>\n <span class=\"hljs-attribute\">required</span>\n <span class=\"hljs-attribute\">jsxname</span>=<span class=\"hljs-value\">\"cardContent\"</span>\n <span class=\"hljs-attribute\">jsxlabel</span>=<span class=\"hljs-value\">\"内容\"</span>\n <span class=\"hljs-attribute\">jsxrules</span>=<span class=\"hljs-value\">{[</span>\n { <span class=\"hljs-attribute\">validator:</span> <span class=\"hljs-attribute\">Validators.isNotEmpty</span>, <span class=\"hljs-attribute\">errMsg:</span> '请填写内容' },\n ]}\n /&gt;</span>\n <span class=\"hljs-tag\">&lt;/<span class=\"hljs-title\">Form</span>&gt;</span>\n <span class=\"hljs-tag\">&lt;/<span class=\"hljs-title\">Dialog</span>&gt;</span>)</span>;\n }\n\n render() {\n <span class=\"hljs-keyword\">const</span> me = <span class=\"hljs-keyword\">this</span>;\n <span class=\"hljs-keyword\">return</span> (\n <span class=\"xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-title\">div</span> <span class=\"hljs-attribute\">className</span>=<span class=\"hljs-value\">\"pageDemo1\"</span>&gt;</span>\n <span class=\"hljs-tag\">&lt;<span class=\"hljs-title\">div</span> <span class=\"hljs-attribute\">className</span>=<span class=\"hljs-value\">\"templateCardWrap\"</span>&gt;</span>\n <span class=\"hljs-tag\">&lt;<span class=\"hljs-title\">ul</span> <span class=\"hljs-attribute\">className</span>=<span class=\"hljs-value\">\"templateCardList clearfix\"</span>&gt;</span>\n {\n me.state.cardList.map((item, i) =&gt; (<span class=\"hljs-tag\">&lt;<span class=\"hljs-title\">li</span> <span class=\"hljs-attribute\">className</span>=<span class=\"hljs-value\">\"templateCardItem\"</span> <span class=\"hljs-attribute\">draggable</span> <span class=\"hljs-attribute\">onDragStart</span>=<span class=\"hljs-value\">{me.onDragStart.bind(me,</span> <span class=\"hljs-attribute\">item</span>)} <span class=\"hljs-attribute\">onDragEnter</span>=<span class=\"hljs-value\">{me.onDragEnter}</span> <span class=\"hljs-attribute\">onDragOver</span>=<span class=\"hljs-value\">{me.onDragOver}</span> <span class=\"hljs-attribute\">onDrop</span>=<span class=\"hljs-value\">{me.onDrop.bind(me,</span> <span class=\"hljs-attribute\">item</span>)} <span class=\"hljs-attribute\">onDragLeave</span>=<span class=\"hljs-value\">{me.onDragLeave}</span> <span class=\"hljs-attribute\">key</span>=<span class=\"hljs-value\">{`templateCardItem${i}`}</span>&gt;</span>\n <span class=\"hljs-tag\">&lt;<span class=\"hljs-title\">CardItem</span> <span class=\"hljs-attribute\">data</span>=<span class=\"hljs-value\">{item}</span> /&gt;</span>\n <span class=\"hljs-tag\">&lt;<span class=\"hljs-title\">div</span> <span class=\"hljs-attribute\">className</span>=<span class=\"hljs-value\">\"templateCardEdit\"</span>&gt;</span>\n <span class=\"hljs-tag\">&lt;<span class=\"hljs-title\">a</span> <span class=\"hljs-attribute\">href</span>=<span class=\"hljs-value\">\"javascript:void(0);\"</span> <span class=\"hljs-attribute\">onClick</span>=<span class=\"hljs-value\">{me.onEditCard.bind(me,</span> <span class=\"hljs-attribute\">item</span>)}&gt;</span>修改<span class=\"hljs-tag\">&lt;/<span class=\"hljs-title\">a</span>&gt;</span>\n <span class=\"hljs-tag\">&lt;<span class=\"hljs-title\">a</span> <span class=\"hljs-attribute\">href</span>=<span class=\"hljs-value\">\"javascript:void(0);\"</span> <span class=\"hljs-attribute\">onClick</span>=<span class=\"hljs-value\">{me.onRemoveCard.bind(me,</span> <span class=\"hljs-attribute\">item</span>)}&gt;</span>删除<span class=\"hljs-tag\">&lt;/<span class=\"hljs-title\">a</span>&gt;</span>\n <span class=\"hljs-tag\">&lt;/<span class=\"hljs-title\">div</span>&gt;</span>\n <span class=\"hljs-tag\">&lt;/<span class=\"hljs-title\">li</span>&gt;</span>)</span>)\n }\n &lt;li className=<span class=\"hljs-string\">\"templateCardItem templateAddCard\"</span> onClick={me.showNewCardDialog.bind(<span class=\"hljs-keyword\">this</span>)}&gt;\n <span class=\"xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-title\">div</span>&gt;</span>\n <span class=\"hljs-tag\">&lt;<span class=\"hljs-title\">img</span> <span class=\"hljs-attribute\">src</span>=<span class=\"hljs-value\">{'https:</span>//<span class=\"hljs-attribute\">img.alicdn.com</span>/<span class=\"hljs-attribute\">tps</span>/<span class=\"hljs-attribute\">TB14qDfPFXXXXclXXXXXXXXXXXX-200-200.png</span>'} <span class=\"hljs-attribute\">className</span>=<span class=\"hljs-value\">\"templateAddCardBtn\"</span> /&gt;</span>\n <span class=\"hljs-tag\">&lt;/<span class=\"hljs-title\">div</span>&gt;</span>\n <span class=\"hljs-tag\">&lt;<span class=\"hljs-title\">p</span> <span class=\"hljs-attribute\">className</span>=<span class=\"hljs-value\">\"templateCardTxt\"</span>&gt;</span>添加卡片<span class=\"hljs-tag\">&lt;/<span class=\"hljs-title\">p</span>&gt;</span>\n <span class=\"hljs-tag\">&lt;/<span class=\"hljs-title\">li</span>&gt;</span>\n <span class=\"hljs-tag\">&lt;/<span class=\"hljs-title\">ul</span>&gt;</span>\n <span class=\"hljs-tag\">&lt;/<span class=\"hljs-title\">div</span>&gt;</span>\n {\n me.state.showCardDialog ? me.renderCardDialog() : null\n }\n <span class=\"hljs-tag\">&lt;/<span class=\"hljs-title\">div</span>&gt;</span>\n )</span>;\n }\n}\n\n<span class=\"hljs-class\"><span class=\"hljs-keyword\">class</span> <span class=\"hljs-title\">Demo</span> <span class=\"hljs-keyword\">extends</span> <span class=\"hljs-title\">React</span>.<span class=\"hljs-title\">Component</span> </span>{\n constructor(props) {\n <span class=\"hljs-keyword\">super</span>(props);\n <span class=\"hljs-keyword\">this</span>.state = {\n };\n }\n\n render() {\n <span class=\"hljs-keyword\">const</span> me = <span class=\"hljs-keyword\">this</span>;\n <span class=\"hljs-keyword\">return</span> (<span class=\"xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-title\">div</span> <span class=\"hljs-attribute\">className</span>=<span class=\"hljs-value\">\"pageDemo\"</span>&gt;</span>\n <span class=\"hljs-tag\">&lt;<span class=\"hljs-title\">Card</span> /&gt;</span>\n <span class=\"hljs-tag\">&lt;/<span class=\"hljs-title\">div</span>&gt;</span>)</span>;\n }\n}\n\nReactDOM.render(\n <span class=\"xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-title\">Demo</span> /&gt;</span>\n, document.getElementById('scene-card-demo-draggable'));\n\n/* JS END CSS START*/</span></code></pre></div><style type=\"text/css\">.pageDemo1 {\n width: 1000px;\n margin: 0 auto;\n background: white;\n min-height: 300px;\n}\n\n.templateCardWrap {\n overflow: hidden;\n}\n.templateCardWrap .clearfix:after {\n content: \"\";\n display: block;\n clear: both;\n width: 0; \n}\n.templateCardWrap .templateCardList {\n width: calc(100% + 10px);\n margin-left: -10px;\n margin-top: -10px;\n}\n.templateCardWrap .templateCardItem {\n float: left;\n width: 270px;\n height: 158px;\n border: 1px solid #ccc;\n position: relative;\n margin-left: 20px;\n margin-top: 20px;\n padding: 20px 16px;\n}\n.templateCardWrap .templateAddCardBtn {\n display: block;\n width: 66px;\n height: 66px;\n margin: 24px auto 12px;\n}\n.templateCardWrap .templateCardTxt {\n text-align: center;\n}\n.templateCardWrap .templateAddCard {\n cursor: pointer;\n}\n.templateCardWrap .templateCardEdit {\n position: absolute;\n bottom: 10px;\n right: 0;\n line-height: 1;\n}\n.templateCardWrap .templateCardEdit a {\n text-decoration: none;\n margin-right: 10px;\n color: #2599F2;\n}\n\n.templateCardItemWrap {\n height: calc(100% - 10px);\n overflow: hidden;\n}</style><div class=\"highlight\"><pre><code class=\"css\"><span class=\"hljs-class\">.pageDemo1</span> <span class=\"hljs-rules\">{\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">width</span>:<span class=\"hljs-value\"> <span class=\"hljs-number\">1000px</span></span></span>;\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">margin</span>:<span class=\"hljs-value\"> <span class=\"hljs-number\">0</span> auto</span></span>;\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">background</span>:<span class=\"hljs-value\"> white</span></span>;\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">min-height</span>:<span class=\"hljs-value\"> <span class=\"hljs-number\">300px</span></span></span>;\n}</span>\n\n<span class=\"hljs-class\">.templateCardWrap</span> <span class=\"hljs-rules\">{\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">overflow</span>:<span class=\"hljs-value\"> hidden</span></span>;\n}</span>\n<span class=\"hljs-class\">.templateCardWrap</span> <span class=\"hljs-class\">.clearfix</span><span class=\"hljs-pseudo\">:after</span> <span class=\"hljs-rules\">{\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">content</span>:<span class=\"hljs-value\"> <span class=\"hljs-string\">\"\"</span></span></span>;\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">display</span>:<span class=\"hljs-value\"> block</span></span>;\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">clear</span>:<span class=\"hljs-value\"> both</span></span>;\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">width</span>:<span class=\"hljs-value\"> <span class=\"hljs-number\">0</span></span></span>; \n}</span>\n<span class=\"hljs-class\">.templateCardWrap</span> <span class=\"hljs-class\">.templateCardList</span> <span class=\"hljs-rules\">{\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">width</span>:<span class=\"hljs-value\"> <span class=\"hljs-function\">calc</span>(<span class=\"hljs-number\">100%</span> + <span class=\"hljs-number\">10px</span>)</span></span>;\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">margin-left</span>:<span class=\"hljs-value\"> -<span class=\"hljs-number\">10px</span></span></span>;\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">margin-top</span>:<span class=\"hljs-value\"> -<span class=\"hljs-number\">10px</span></span></span>;\n}</span>\n<span class=\"hljs-class\">.templateCardWrap</span> <span class=\"hljs-class\">.templateCardItem</span> <span class=\"hljs-rules\">{\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">float</span>:<span class=\"hljs-value\"> left</span></span>;\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">width</span>:<span class=\"hljs-value\"> <span class=\"hljs-number\">270px</span></span></span>;\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">height</span>:<span class=\"hljs-value\"> <span class=\"hljs-number\">158px</span></span></span>;\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">border</span>:<span class=\"hljs-value\"> <span class=\"hljs-number\">1px</span> solid <span class=\"hljs-hexcolor\">#ccc</span></span></span>;\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">position</span>:<span class=\"hljs-value\"> relative</span></span>;\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">margin-left</span>:<span class=\"hljs-value\"> <span class=\"hljs-number\">20px</span></span></span>;\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">margin-top</span>:<span class=\"hljs-value\"> <span class=\"hljs-number\">20px</span></span></span>;\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">padding</span>:<span class=\"hljs-value\"> <span class=\"hljs-number\">20px</span> <span class=\"hljs-number\">16px</span></span></span>;\n}</span>\n<span class=\"hljs-class\">.templateCardWrap</span> <span class=\"hljs-class\">.templateAddCardBtn</span> <span class=\"hljs-rules\">{\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">display</span>:<span class=\"hljs-value\"> block</span></span>;\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">width</span>:<span class=\"hljs-value\"> <span class=\"hljs-number\">66px</span></span></span>;\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">height</span>:<span class=\"hljs-value\"> <span class=\"hljs-number\">66px</span></span></span>;\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">margin</span>:<span class=\"hljs-value\"> <span class=\"hljs-number\">24px</span> auto <span class=\"hljs-number\">12px</span></span></span>;\n}</span>\n<span class=\"hljs-class\">.templateCardWrap</span> <span class=\"hljs-class\">.templateCardTxt</span> <span class=\"hljs-rules\">{\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">text-align</span>:<span class=\"hljs-value\"> center</span></span>;\n}</span>\n<span class=\"hljs-class\">.templateCardWrap</span> <span class=\"hljs-class\">.templateAddCard</span> <span class=\"hljs-rules\">{\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">cursor</span>:<span class=\"hljs-value\"> pointer</span></span>;\n}</span>\n<span class=\"hljs-class\">.templateCardWrap</span> <span class=\"hljs-class\">.templateCardEdit</span> <span class=\"hljs-rules\">{\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">position</span>:<span class=\"hljs-value\"> absolute</span></span>;\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">bottom</span>:<span class=\"hljs-value\"> <span class=\"hljs-number\">10px</span></span></span>;\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">right</span>:<span class=\"hljs-value\"> <span class=\"hljs-number\">0</span></span></span>;\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">line-height</span>:<span class=\"hljs-value\"> <span class=\"hljs-number\">1</span></span></span>;\n}</span>\n<span class=\"hljs-class\">.templateCardWrap</span> <span class=\"hljs-class\">.templateCardEdit</span> <span class=\"hljs-tag\">a</span> <span class=\"hljs-rules\">{\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">text-decoration</span>:<span class=\"hljs-value\"> none</span></span>;\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">margin-right</span>:<span class=\"hljs-value\"> <span class=\"hljs-number\">10px</span></span></span>;\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">color</span>:<span class=\"hljs-value\"> <span class=\"hljs-hexcolor\">#2599F2</span></span></span>;\n}</span>\n\n<span class=\"hljs-class\">.templateCardItemWrap</span> <span class=\"hljs-rules\">{\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">height</span>:<span class=\"hljs-value\"> <span class=\"hljs-function\">calc</span>(<span class=\"hljs-number\">100%</span> - <span class=\"hljs-number\">10px</span>)</span></span>;\n <span class=\"hljs-rule\"><span class=\"hljs-attribute\">overflow</span>:<span class=\"hljs-value\"> hidden</span></span>;\n}</span></code></pre></div>"},"status":"public","toc":""}]
import classnames from 'classnames';;
import { Form } from 'uxcore';
import { Button } from 'uxcore';
import { Dialog } from 'uxcore';
const {
    InputFormField: Input,
    FormRow,
    FormRowTitle,
    Validators,
    OtherFormField,
    DateFormField,
    CascadeSelectFormField,
    SelectFormField,
    CheckboxGroupFormField,
} = Form;

const Item = CheckboxGroupFormField.Item;


class CardItem extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
    };
  }

  componentDidMount() {
  }

  render() {
    const me = this;
    const data = this.props.data;
    return (
      <div className="templateCardItemWrap">
        <div className="templateCardItemTitle">{data.title}</div>
        <div className="templateCardItemContent">{data.content}</div>
      </div>
    );
  }
}

class Card extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      cardValues: {},
      showCardDialog: false,
      cardList: [{
        title: '阿里巴巴(中国)有限公司',
        content: '浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号',
        id: (new Date()).getTime(),
        active: true,
      }, {
        title: '阿里巴巴(中国)有限公司阿里巴巴(中国)有限公司',
        content: '浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号',
        id: (new Date()).getTime() + 1,
      }],
    };
  }

  componentDidMount() {
  }

  componentWillUnmount() {
  }

  showNewCardDialog() {
    this.setState({
      action: 'add',
      showCardDialog: true,
      cardValues: {},
    });
  }

  handleCard() {
    const data = this.refs.form.getValues();

    if (!data.pass) {
      return;
    }

    if (this.state.action === 'add') {
      this.state.cardList.push({
        title: data.values.cardTitle,
        content: data.values.cardContent,
        id: (new Date()).getTime(),
      });
    } else {
      const editData = this.state.editData;
      this.state.cardList.map((item) => {
        if (item.id === editData.id) {
          item.content = data.values.cardContent;
          item.title = data.values.cardTitle;
          return true;
        }
      });
    }

    this.state.showCardDialog = false;
    this.setState(this.state);
  }

  handleCancel() {
    this.setState({
      showCardDialog: false,
    });
  }

  onEditCard(data) {
    this.state.cardValues.cardTitle = data.title;
    this.state.cardValues.cardContent = data.content;
    this.state.showCardDialog = true;
    this.state.action = 'edit';
    this.state.editData = data;
    this.setState(this.state);
  }

  onRemoveCard(data) {
    Dialog.confirm({
      title: '确定删除?',
      onOk: () => {
        this.state.cardList.some((item, i) => {
          if (item.id === data.id) {
            this.state.cardList.splice(i, 1);
            return true;
          }
        });
        this.setState(this.state);
      },
    });
  }

  renderCardDialog() {
    return (<Dialog ref="modal"
      visible
      className="newCardDialog"
      title="添加卡片" onCancel={this.handleCancel.bind(this)}
      footer={[
        <Button onClick={this.handleCard.bind(this)}>提 交</Button>,
        <Button onClick={this.handleCancel.bind(this)}>取 消</Button>,
      ]}
    >
      <Form ref="form" jsxvalues={this.state.cardValues}>
        <FormRowTitle jsxtitle="卡片信息" />
        <Input
          required
          jsxname="cardTitle"
          jsxlabel="标题"
          jsxrules={[
                                { validator: Validators.isNotEmpty, errMsg: '请填写标题' },
          ]}
        />
        <Input
          required
          jsxname="cardContent"
          jsxlabel="内容"
          jsxrules={[
                                { validator: Validators.isNotEmpty, errMsg: '请填写内容' },
          ]}
        />
      </Form>
    </Dialog>);
  }

  render() {
    const me = this;
    return (
      <div className="pageDemo">
        <div className="templateCardWrap">
          <ul className="templateCardList clearfix">
            {
                            me.state.cardList.map((item, i) => (<li className={`templateCardItem ${item.active ? 'active' : ''}`} key={`templateCardItem${i}`}>
                              <CardItem data={item} />
                              <div className="templateCardEdit">
                                <a href="javascript:void(0);" onClick={me.onEditCard.bind(me, item)}>修改</a>
                                <a href="javascript:void(0);" onClick={me.onRemoveCard.bind(me, item)}>删除</a>
                              </div>
                            </li>))
                        }
            <li className="templateCardItem templateAddCard" onClick={me.showNewCardDialog.bind(this)}>
              <div>
                <img src={'https://img.alicdn.com/tps/TB14qDfPFXXXXclXXXXXXXXXXXX-200-200.png'} className="templateAddCardBtn" />
              </div>
              <p className="templateCardTxt">添加卡片</p>
            </li>
          </ul>
        </div>
        {
                    me.state.showCardDialog ? me.renderCardDialog() : null
                }
      </div>
    );
  }
}

class Demo extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
    };
  }

  render() {
    const me = this;
    return (<div className="pageDemo">
      <Card />
    </div>);
  }
}

ReactDOM.render(
  <Demo />
, document.getElementById('scene-card-demo-basic'));

/* JS END CSS START*/
.pageDemo {
  width: 1000px;
  margin: 0 auto;
  background: white;
  min-height: 300px;
}

.templateCardWrap {
    overflow: hidden;
}
.templateCardWrap .clearfix:after {
    content: "";
    display: block;
    clear: both;
    width: 0; 
}
.templateCardWrap .templateCardList {
    width: calc(100% + 10px);
    margin-left: -10px;
    margin-top: -10px;
}
.templateCardWrap .templateCardItem {
    float: left;
    width: 270px;
    height: 158px;
    border: 1px solid #ccc;
    position: relative;
    margin-left: 20px;
    margin-top: 20px;
    padding: 20px 16px;
}

.templateCardWrap .templateCardItem.active {
    box-shadow: 0 2px 10px 0 rgba(0, 0, 0, 0.15);
}
.templateCardWrap .templateAddCardBtn {
    display: block;
    width: 66px;
    height: 66px;
    margin: 24px auto 12px;
}
.templateCardWrap .templateCardTxt {
    text-align: center;
}
.templateCardWrap .templateAddCard {
    cursor: pointer;
}
.templateCardWrap .templateCardEdit {
    position: absolute;
    bottom: 10px;
    right: 0;
    line-height: 1;
}
.templateCardWrap .templateCardEdit a {
    text-decoration: none;
    margin-right: 10px;
    color: #2599F2;
}

.templateCardItemTitle {
    color: #333;
    font-size: 14px;
    line-height: 1.5;
}
.templateCardItemContent {
    color: #999;
    margin-top: 10px;
    line-height: 1.5;
}
.templateCardItemWrap {
    height: calc(100% - 10px);
    overflow: hidden;
}
import classnames from 'classnames';;
import { Form } from 'uxcore';
import { Button } from 'uxcore';
import { Dialog } from 'uxcore';
const {
    InputFormField: Input,
    FormRow,
    FormRowTitle,
    Validators,
    OtherFormField,
    DateFormField,
    CascadeSelectFormField,
    SelectFormField,
    CheckboxGroupFormField,
} = Form;

const Item = CheckboxGroupFormField.Item;


class CardItem extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
    };
  }

  componentDidMount() {
  }

  render() {
    const me = this;
    const data = this.props.data;
    return (
      <div className="templateCardItemWrap">
        <div className="templateCardItemTitle">{data.title}</div>
        <div className="templateCardItemContent">{data.content}</div>
      </div>
    );
  }
}

class Card extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      cardValues: {},
      showCardDialog: false,
      cardList: [{
        title: '阿里巴巴(中国)有限公司',
        content: '浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号',
        id: (new Date()).getTime(),
      }, {
        title: '阿里巴巴(中国)有限公司阿里巴巴(中国)有限公司',
        content: '浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号浙江省杭州市余杭区文一西路969号',
        id: (new Date()).getTime() + 1,
      }],
    };
  }

  componentDidMount() {
  }

  componentWillUnmount() {
  }

  showNewCardDialog() {
    this.setState({
      action: 'add',
      showCardDialog: true,
      cardValues: {},
    });
  }

  handleCard() {
    const data = this.refs.form.getValues();

    if (!data.pass) {
      return;
    }

    if (this.state.action === 'add') {
      this.state.cardList.push({
        title: data.values.cardTitle,
        content: data.values.cardContent,
        id: (new Date()).getTime(),
      });
    } else {
      const editData = this.state.editData;
      this.state.cardList.map((item) => {
        if (item.id === editData.id) {
          item.title = data.values.cardTitle;
          item.content = data.values.cardContent;
          return true;
        }
      });
    }

    this.state.showCardDialog = false;
    this.setState(this.state);
  }

  handleCancel() {
    this.setState({
      showCardDialog: false,
    });
  }

  onEditCard(data) {
    this.state.cardValues.cardTitle = data.title;
    this.state.cardValues.cardContent = data.content;
    this.state.showCardDialog = true;
    this.state.action = 'edit';
    this.state.editData = data;
    this.setState(this.state);
  }

  onRemoveCard(data) {
    Dialog.confirm({
      title: '确定删除?',
      onOk: () => {
        this.state.cardList.some((item, i) => {
          if (item.id === data.id) {
            this.state.cardList.splice(i, 1);
            return true;
          }
        });
        this.setState(this.state);
      },
    });
  }

  onDragStart(data) {
    this.state.dragItemData = data;
  }

  onDrop(data) {
    this.switchItem(this.state.dragItemData, data);
  }

  onDragEnter(e) {
    e.target.classList.add('dragOver');
  }
  onDragOver(e) {
    e.preventDefault();
  }

  onDragLeave(e) {
    e.preventDefault();
    e.target.classList.remove('dragOver');
  }

  findItem(data) {
    let index = -1;
    this.state.cardList.some((item, i) => {
      if (item.id === data.id) {
        index = i;
        return true;
      }
    });
    return index;
  }

  switchItem(dragItem, dropItem) {
    const cardList = this.state.cardList;
    const dragIndex = this.findItem(dragItem);
    const dropIndex = this.findItem(dropItem);

    if (dragIndex < 0 || dropIndex < 0) {
            // 'error';
      return;
    }

    const item = cardList[dragIndex];
    cardList.splice(dragIndex, 1);
    cardList.splice(dropIndex, 0, item);

    this.setState(this.state);
  }

  renderCardDialog() {
    return (<Dialog ref="modal"
      visible
      className="newCardDialog"
      title="添加卡片" onCancel={this.handleCancel.bind(this)}
      footer={[
        <Button onClick={this.handleCard.bind(this)}>提 交</Button>,
        <Button onClick={this.handleCancel.bind(this)}>取 消</Button>,
      ]}
    >
      <Form ref="form" jsxvalues={this.state.cardValues}>
        <FormRowTitle jsxtitle="卡片信息" />
        <Input
          required
          jsxname="cardTitle"
          jsxlabel="标题"
          jsxrules={[
                                { validator: Validators.isNotEmpty, errMsg: '请填写标题' },
          ]}
        />
        <Input
          required
          jsxname="cardContent"
          jsxlabel="内容"
          jsxrules={[
                                { validator: Validators.isNotEmpty, errMsg: '请填写内容' },
          ]}
        />
      </Form>
    </Dialog>);
  }

  render() {
    const me = this;
    return (
      <div className="pageDemo1">
        <div className="templateCardWrap">
          <ul className="templateCardList clearfix">
            {
                            me.state.cardList.map((item, i) => (<li className="templateCardItem" draggable onDragStart={me.onDragStart.bind(me, item)} onDragEnter={me.onDragEnter} onDragOver={me.onDragOver} onDrop={me.onDrop.bind(me, item)} onDragLeave={me.onDragLeave} key={`templateCardItem${i}`}>
                              <CardItem data={item} />
                              <div className="templateCardEdit">
                                <a href="javascript:void(0);" onClick={me.onEditCard.bind(me, item)}>修改</a>
                                <a href="javascript:void(0);" onClick={me.onRemoveCard.bind(me, item)}>删除</a>
                              </div>
                            </li>))
                        }
            <li className="templateCardItem templateAddCard" onClick={me.showNewCardDialog.bind(this)}>
              <div>
                <img src={'https://img.alicdn.com/tps/TB14qDfPFXXXXclXXXXXXXXXXXX-200-200.png'} className="templateAddCardBtn" />
              </div>
              <p className="templateCardTxt">添加卡片</p>
            </li>
          </ul>
        </div>
        {
                    me.state.showCardDialog ? me.renderCardDialog() : null
                }
      </div>
    );
  }
}

class Demo extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
    };
  }

  render() {
    const me = this;
    return (<div className="pageDemo">
      <Card />
    </div>);
  }
}

ReactDOM.render(
  <Demo />
, document.getElementById('scene-card-demo-draggable'));

/* JS END CSS START*/
.pageDemo1 {
  width: 1000px;
  margin: 0 auto;
  background: white;
  min-height: 300px;
}

.templateCardWrap {
    overflow: hidden;
}
.templateCardWrap .clearfix:after {
    content: "";
    display: block;
    clear: both;
    width: 0; 
}
.templateCardWrap .templateCardList {
    width: calc(100% + 10px);
    margin-left: -10px;
    margin-top: -10px;
}
.templateCardWrap .templateCardItem {
    float: left;
    width: 270px;
    height: 158px;
    border: 1px solid #ccc;
    position: relative;
    margin-left: 20px;
    margin-top: 20px;
    padding: 20px 16px;
}
.templateCardWrap .templateAddCardBtn {
    display: block;
    width: 66px;
    height: 66px;
    margin: 24px auto 12px;
}
.templateCardWrap .templateCardTxt {
    text-align: center;
}
.templateCardWrap .templateAddCard {
    cursor: pointer;
}
.templateCardWrap .templateCardEdit {
    position: absolute;
    bottom: 10px;
    right: 0;
    line-height: 1;
}
.templateCardWrap .templateCardEdit a {
    text-decoration: none;
    margin-right: 10px;
    color: #2599F2;
}

.templateCardItemWrap {
    height: calc(100% - 10px);
    overflow: hidden;
}