From c98e45bfac25e9110ad0383faac54a54d98ea9d5 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 18 十一月 2021 20:47:04 +0800 Subject: [PATCH] 2021-11-18 --- src/menu/components/share/searchcomponent/dragsearch/card.jsx | 43 +++++++++++++++++++++++++++---------------- 1 files changed, 27 insertions(+), 16 deletions(-) diff --git a/src/menu/components/share/searchcomponent/dragsearch/card.jsx b/src/menu/components/share/searchcomponent/dragsearch/card.jsx index 6e023ff..7ba8496 100644 --- a/src/menu/components/share/searchcomponent/dragsearch/card.jsx +++ b/src/menu/components/share/searchcomponent/dragsearch/card.jsx @@ -1,12 +1,13 @@ import React from 'react' import { useDrag, useDrop } from 'react-dnd' -import { Icon, Select, DatePicker, Input, Popover } from 'antd' +import { Icon, Select, DatePicker, Input, Popover, Form } from 'antd' import moment from 'moment' -import DateGroup from '../dategroup' +import DateGroup from '@/menu/components/search/main-search/dategroup' import './index.scss' const { MonthPicker, WeekPicker, RangePicker } = DatePicker +const { Search } = Input const Card = ({ id, card, moveCard, findCard, copyCard, editCard, delCard }) => { const originalIndex = findCard(id).index @@ -19,17 +20,15 @@ const [, drop] = useDrop({ accept: 'search', canDrop: () => true, - drop: () => {}, - hover({ id: draggedId }) { + drop: ({ id: draggedId }) => { if (!draggedId || draggedId === id) return const { index: originIndex } = findCard(draggedId) - if (originIndex === -1) return const { index: overIndex } = findCard(id) moveCard(draggedId, overIndex) - }, + } }) const opacity = isDragging ? 0 : 1 @@ -44,15 +43,19 @@ _defaultValue = '' } } else if (card.setAll === 'true') { - _defaultValue = 'All' + _defaultValue = '鍏ㄩ儴' } } else if (card.type === 'daterange') { _defaultValue = [null, null] - if (card.initval) { + if (card.initval === 'week') { + _defaultValue = [moment().startOf('week'), moment().endOf('week')] + } else if (card.initval === 'month') { + _defaultValue = [moment().startOf('month'), moment().endOf('month')] + } else if (card.initval) { try { let _initval = JSON.parse(card.initval) _defaultValue = [moment().subtract(_initval[0], 'days'), moment().subtract(_initval[1], 'days')] - } catch { + } catch (e) { _defaultValue = [null, null] } } @@ -61,16 +64,24 @@ return ( <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ <div className="mk-popover-control"> - <Icon className="edit" title="edit" type="edit" onClick={() => editCard(id)} /> - <Icon className="copy" title="copy" type="copy" onClick={() => copyCard(id)} /> - <Icon className="close" title="delete" type="close" onClick={() => delCard(id)} /> + <Icon className="edit" title="缂栬緫" type="edit" onClick={() => editCard(id)} /> + <Icon className="copy" title="澶嶅埗" type="copy" onClick={() => copyCard(id)} /> + <Icon className="close" title="鍒犻櫎" type="close" onClick={() => delCard(id)} /> </div> } trigger="hover"> - <div className="page-card" style={{ opacity: opacity}}> + <div className={'page-card ' + (card.labelShow || '')} style={{ opacity: opacity}}> <div ref={node => drag(drop(node))}> - <div className="ant-form-item"> - {card.type === 'text' ? + <Form.Item + labelCol={{xs: { span: 24 }, sm: { span: 8 }}} + wrapperCol = {{xs: { span: 24 }, sm: { span: 16 }}} + label={card.labelShow !== 'false' ? card.label : ''} + required={card.required === 'true'} + > + {card.type === 'text' && card.inputType !== 'search' ? <Input placeholder={card.label} value={card.initval} /> : null + } + {card.type === 'text' && card.inputType === 'search' ? + <Search placeholder={card.label} value={card.initval} enterButton/> : null } {(card.type === 'multiselect' || card.type === 'select' || card.type === 'link') ? <Select placeholder={card.label} value={_defaultValue}></Select> : null @@ -93,7 +104,7 @@ /> : null } {card.type === 'group' ? <DateGroup card={card} /> : null } - </div> + </Form.Item> </div> </div> </Popover> -- Gitblit v1.8.0