Commit a1ea1f83 authored by 涂伟's avatar 涂伟

fix: '1.表格样式优化2.添加按钮'

parent 955156cc
import React, { useCallback, useEffect, useMemo, useRef, useState,forwardRef,useImperativeHandle } from 'react'; import React, { useCallback, useEffect, useMemo, useRef, useState, forwardRef, useImperativeHandle } from 'react';
import { AudioOutlined } from '@ant-design/icons'; import { AudioOutlined } from '@ant-design/icons';
import { Row, import {
Row,
DatePicker, DatePicker,
Select, Select,
Button, Button,
...@@ -16,12 +17,13 @@ import { Row, ...@@ -16,12 +17,13 @@ import { Row,
Dropdown, Dropdown,
Menu, Menu,
Popover, Popover,
Form, } from 'antd'; Form,
} from 'antd';
import 'dayjs/locale/zh-cn'; import 'dayjs/locale/zh-cn';
import locale from 'antd/es/date-picker/locale/zh_CN'; import locale from 'antd/es/date-picker/locale/zh_CN';
import { import {
SnippetsOutlined, SnippetsOutlined,
PlusOutlined, PlusOutlined,
FormOutlined, FormOutlined,
...@@ -35,19 +37,18 @@ import locale from 'antd/es/date-picker/locale/zh_CN'; ...@@ -35,19 +37,18 @@ import locale from 'antd/es/date-picker/locale/zh_CN';
ExclamationCircleOutlined, ExclamationCircleOutlined,
QuestionCircleOutlined, QuestionCircleOutlined,
EditOutlined, EditOutlined,
DownOutlined DownOutlined,
} from '@ant-design/icons'; } from '@ant-design/icons';
import styles from './search.less'; import styles from './search.less';
import moment from 'moment'; import moment from 'moment';
const { Search } = Input; const { Search } = Input;
const { RangePicker } = DatePicker; const { RangePicker } = DatePicker;
const { Option } = Select; const { Option } = Select;
const dateFormat = 'YYYY-MM-DD'; const dateFormat = 'YYYY-MM-DD';
const SearchGroup = forwardRef((props, ref) => { const SearchGroup = forwardRef((props, ref) => {
useImperativeHandle(ref, () => ({ useImperativeHandle(ref, () => ({
getQueryInfo getQueryInfo,
})); }));
const [form] = Form.useForm(); const [form] = Form.useForm();
...@@ -55,20 +56,19 @@ const SearchGroup = forwardRef((props, ref) => { ...@@ -55,20 +56,19 @@ const SearchGroup = forwardRef((props, ref) => {
// fieldSearch // fieldSearch
// } = props.params; // } = props.params;
const [showPicker,setShowPicker] = useState(true) const [showPicker, setShowPicker] = useState(true);
const [dateArray, setDateArray] = useState([ const [dateArray, setDateArray] = useState([
// moment(moment().format('YYYY-MM-DD 00:00:00')).subtract(1, 'years'), // moment(moment().format('YYYY-MM-DD 00:00:00')).subtract(1, 'years'),
// moment(moment().format('YYYY-MM-DD 23:59:59')), // moment(moment().format('YYYY-MM-DD 23:59:59')),
]) ]);
const [formatterStr, setFormatterStr] = useState('YYYY-MM-DD HH:mm:ss') const [formatterStr, setFormatterStr] = useState('YYYY-MM-DD HH:mm:ss');
const [searchValues, setSearchValues] = useState('') const [searchValues, setSearchValues] = useState('');
// const [queryWheres, setQueryWheres] = useState([ // const [queryWheres, setQueryWheres] = useState([
// props.params.tempQueryWhere || {}, // props.params.tempQueryWhere || {},
// ]) // ])
const [queryWheres, setQueryWheres] = useState([{}]) const [queryWheres, setQueryWheres] = useState([{}]);
const [searchKey, setSearchKey] = useState(''); // 快速搜索字段名称 const [searchKey, setSearchKey] = useState(''); // 快速搜索字段名称
const [queryInfo,setQueryInfo] = useState({info: '',timeFrom: '',timeTo: ''}) const [queryInfo, setQueryInfo] = useState({ info: '', timeFrom: '', timeTo: '' });
const rangerOptions = useMemo(() => { const rangerOptions = useMemo(() => {
const todayRanger = [ const todayRanger = [
...@@ -168,7 +168,11 @@ const SearchGroup = forwardRef((props, ref) => { ...@@ -168,7 +168,11 @@ const SearchGroup = forwardRef((props, ref) => {
}, []); }, []);
const dateChange = (dateObj, dateString) => { const dateChange = (dateObj, dateString) => {
setDateArray(dateObj || ['', '']); setDateArray(dateObj || ['', '']);
setQueryInfo({...queryInfo, timeFrom: dateObj[0].format('YYYY-MM-DD HH:mm:ss') || '',timeTo: dateObj[1].format('YYYY-MM-DD HH:mm:ss') || ''}) setQueryInfo({
...queryInfo,
timeFrom: dateObj[0].format('YYYY-MM-DD HH:mm:ss') || '',
timeTo: dateObj[1].format('YYYY-MM-DD HH:mm:ss') || '',
});
}; };
const onSearch = e => { const onSearch = e => {
// if (fieldSearch) { // if (fieldSearch) {
...@@ -180,25 +184,28 @@ const SearchGroup = forwardRef((props, ref) => { ...@@ -180,25 +184,28 @@ const SearchGroup = forwardRef((props, ref) => {
// } else { // } else {
// getAccountData(); // getAccountData();
// } // }
setQueryInfo({...queryInfo,info: e}) setQueryInfo({ ...queryInfo, info: e });
getQueryInfo(form.getFieldsValue()) getQueryInfo(form.getFieldsValue());
}; };
const onValuesChange = (values) => { const onValuesChange = values => {
let keys = Object.keys(values) let keys = Object.keys(values);
if (keys.includes('info')) return if (keys.includes('info')) return;
getQueryInfo(form.getFieldsValue()) getQueryInfo(form.getFieldsValue());
} };
const getQueryInfo = (data) => { const getQueryInfo = data => {
let params = {} let params = {};
params.timeFrom = data.time&&data.time[0].format('YYYY-MM-DD HH:mm:ss') || '' params.timeFrom = (data.time && data.time[0].format('YYYY-MM-DD HH:mm:ss')) || '';
params.timeTo = data.time&&data.time[1].format('YYYY-MM-DD HH:mm:ss') || '' params.timeTo = (data.time && data.time[1].format('YYYY-MM-DD HH:mm:ss')) || '';
params.info = data.info params.info = data.info;
console.log(params,'666666666666666'); props && props.onChange(params);
props&&props.onChange(params) return params;
return params };
}
const btnsClick = type => {
props && props.btnsClick(type);
};
return ( return (
<div className={styles.accountFlexWrapper}> <div className={styles.accountFlexWrapper}>
...@@ -206,9 +213,9 @@ const SearchGroup = forwardRef((props, ref) => { ...@@ -206,9 +213,9 @@ const SearchGroup = forwardRef((props, ref) => {
<Form layout={'horizontal'} form={form} onValuesChange={onValuesChange}> <Form layout={'horizontal'} form={form} onValuesChange={onValuesChange}>
<Space className={styles.controlRowLeft} wrap> <Space className={styles.controlRowLeft} wrap>
{showPicker ? ( {showPicker ? (
<Form.Item label={`录入时间`} name='time' className={styles.noMarginBottom}> <Form.Item label={`录入时间`} name="time" className={styles.noMarginBottom}>
<RangePicker <RangePicker
size='middle' size="middle"
value={[...dateArray]} value={[...dateArray]}
locale={locale} locale={locale}
// defaultValue={rangerOptions[timeQuantumStr]} // defaultValue={rangerOptions[timeQuantumStr]}
...@@ -238,7 +245,7 @@ const SearchGroup = forwardRef((props, ref) => { ...@@ -238,7 +245,7 @@ const SearchGroup = forwardRef((props, ref) => {
</Select> </Select>
</Form.Item> </Form.Item>
))} */} ))} */}
<Form.Item label={'快捷搜索'} name='info' className={styles.noMarginBottom}> <Form.Item label={'快捷搜索'} name="info" className={styles.noMarginBottom}>
{/* {searchKey && fieldSearch ? <Select {/* {searchKey && fieldSearch ? <Select
style={{ maxWidth: '112px' }} style={{ maxWidth: '112px' }}
placeholder='请选择字段' placeholder='请选择字段'
...@@ -258,7 +265,7 @@ const SearchGroup = forwardRef((props, ref) => { ...@@ -258,7 +265,7 @@ const SearchGroup = forwardRef((props, ref) => {
// 1, // 1,
// -1, // -1,
// ) || ''}搜索`} // ) || ''}搜索`}
size='middle' size="middle"
// placeholder={`请输入${accountConfig?.searchFieldGroup?.slice( // placeholder={`请输入${accountConfig?.searchFieldGroup?.slice(
// 1, // 1,
// -1, // -1,
...@@ -266,9 +273,9 @@ const SearchGroup = forwardRef((props, ref) => { ...@@ -266,9 +273,9 @@ const SearchGroup = forwardRef((props, ref) => {
style={{ style={{
width: 320, width: 320,
verticalAlign: 'middle', verticalAlign: 'middle',
marginLeft: '10px' marginLeft: '10px',
}} }}
placeholder='请输入值' placeholder="请输入值"
// value={searchValues} // value={searchValues}
// onChange={e => setSearchValues(e.target.value)} // onChange={e => setSearchValues(e.target.value)}
onSearch={onSearch} onSearch={onSearch}
...@@ -277,17 +284,17 @@ const SearchGroup = forwardRef((props, ref) => { ...@@ -277,17 +284,17 @@ const SearchGroup = forwardRef((props, ref) => {
</Space> </Space>
</Form> </Form>
{/* 按钮区域 */} {/* 按钮区域 */}
{/* <div className={styles.controlRowRight}> <div className={styles.controlRowRight}>
{ {/* {
state !== 'special' ? <Dropdown.Button type={permission.includes('addBtn') ? '' : 'primary'} icon={<DownOutlined />} state !== 'special' ? <Dropdown.Button type={permission.includes('addBtn') ? '' : 'primary'} icon={<DownOutlined />}
overlay={menu}>其他操作</Dropdown.Button> : '' overlay={menu}>其他操作</Dropdown.Button> : ''
} }
{ {
bulkButton ? <Dropdown.Button style={{ "marginLeft": "20px" }} type={permission.includes('addBtn') ? '' : 'primary'} icon={<DownOutlined />} bulkButton ? <Dropdown.Button style={{ "marginLeft": "20px" }} type={permission.includes('addBtn') ? '' : 'primary'} icon={<DownOutlined />}
overlay={batchMenu}>批量操作</Dropdown.Button> : '' overlay={batchMenu}>批量操作</Dropdown.Button> : ''
} } */}
<div className={styles.controlBtns}> <div className={styles.controlBtns}>
{permission.includes('editBtn') && !bulkButton ? ( {/* {permission.includes('editBtn') && !bulkButton ? (
<Button <Button
type="primary" ghost type="primary" ghost
size='middle' size='middle'
...@@ -299,8 +306,8 @@ const SearchGroup = forwardRef((props, ref) => { ...@@ -299,8 +306,8 @@ const SearchGroup = forwardRef((props, ref) => {
</Button> </Button>
) : ( ) : (
'' ''
)} )} */}
{permission.includes('deleteBtn') && !bulkButton ? ( {/* {permission.includes('deleteBtn') && !bulkButton ? (
<Button <Button
type='primary' ghost type='primary' ghost
size='middle' size='middle'
...@@ -312,26 +319,25 @@ const SearchGroup = forwardRef((props, ref) => { ...@@ -312,26 +319,25 @@ const SearchGroup = forwardRef((props, ref) => {
</Button> </Button>
) : ( ) : (
'' ''
)} )} */}
{permission.includes('addBtn') ? ( {/* {permission.includes('addBtn') ? ( */}
<Button <Button
type='primary' type="primary"
size='middle' size="middle"
onClick={() => addNewRecord()} onClick={() => btnsClick('add')}
icon={<PlusOutlined />} icon={<PlusOutlined />}
style={{ marginLeft: 20 }} style={{ marginLeft: 20 }}
> >
添加 添加
</Button> </Button>
) : ( {/* ) : (
'' ''
)} )} */}
</div>
</div> </div>
</div> */}
</Row> </Row>
</div> </div>
) );
});
})
export default SearchGroup export default SearchGroup;
\ No newline at end of file
...@@ -24,5 +24,63 @@ ...@@ -24,5 +24,63 @@
} }
} }
} }
.ant-table.ant-table-bordered > .ant-table-container {
border-left: 1px solid #dbe7fb;
.ant-table-header > table {
border-top: 1px solid #dbe7fb;
}
}
// .ant-table.ant-table-bordered > .ant-table-container > .ant-table-header > table {
// border-top: 1px solid #dbe7fb;
// }
.@{ant-prefix}-table-thead > tr {
height: 40px;
th {
border-right: 1px solid #dbe7fb!important;
border-bottom: 1px solid #dbe7fb;
background: white;
}
th:last-child {
border-left: 1px solid #dbe7fb;
}
}
.ant-table-tbody > tr {
&:nth-child(2n-1) {
td {
background: #f6f9fe;
}
}
td {
border-bottom: 1px solid #dbe7fb;
border-right: 1px solid #dbe7fb!important;
&:last-child {
border-left: 1px solid #dbe7fb;
}
}
}
// .ant-table-tbody > tr > td:last-child {
// border-left: 1px solid #dbe7fb;
// }
.@{ant-prefix}-table-body {
overflow-x: scroll;
&::-webkit-scrollbar {
width: 0;
height: 12px;
}
&::-webkit-scrollbar {
width: 0; // height: 12px;
height: 6px;
}
&::-webkit-scrollbar-thumb {
// background: #c8c8c8;
background: rgb(41, 166, 255);
}
&::-webkit-scrollbar-track {
background: #f7f4f5;
padding: 0 3px;
}
}
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment