From f7acd7922c1db53e4eb5d97a3d1e3fc996efbb2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=99=93=E9=9D=99?= <17600756968@163.com> Date: Mon, 7 Dec 2020 15:17:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=A1=A8=E6=A0=BC=E5=A4=B4?= =?UTF-8?q?=E9=83=A8=E8=87=AA=E5=AE=9A=E4=B9=89dom?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/DataView/index.js | 59 +++++++++++++++++--------------- components/SearchView/index.less | 12 +++---- 2 files changed, 37 insertions(+), 34 deletions(-) diff --git a/components/DataView/index.js b/components/DataView/index.js index 75a4746..c6a2d1c 100644 --- a/components/DataView/index.js +++ b/components/DataView/index.js @@ -4,6 +4,7 @@ import React from 'react'; import { Modal, message } from 'antd'; import moment from 'moment'; import _ from 'lodash'; +import classNames from 'classnames'; // ant_components 组件 import BITable from '@/ant_components/BITable'; import BIButton from '@/ant_components/BIButton'; @@ -14,7 +15,6 @@ import SelfPagination from '@/components/SelfPagination'; import ButtonAuth from '@/components/AuthButton'; import IconFont from '@/components/CustomIcon/IconFont'; // 样式 -import styles from './index.less'; // 工具 import antiAssign from '@/utils/anti-assign'; import { DATE_FORMAT, PAGINATION } from '@/utils/constants'; @@ -23,6 +23,7 @@ import { getSift } from '@/services/comment'; import { getOptionName, replacePageNum } from '@/utils/utils'; import { SIFT_TYPE } from '@/utils/enum'; import storage from '@/utils/storage'; /* eslint-disable react/sort-comp */ // 关闭下划线变量检测 // 关闭方法排序检测 // 多维数组降维成一维数组 +import styles from './index.less'; /** * @@ -155,7 +156,7 @@ export function formatSelect(val, options) { } const selectObj = options.find((item) => { return item.id === val; - }) || {} + }) || {}; return selectObj; } @@ -274,7 +275,7 @@ export default class DataView extends React.Component { current: (page && page.current) || PAGINATION.current, onChange: (nextPage) => { this.fetchPage(nextPage); - this.fetch(); + // this.fetch(); window.history.replaceState({ pageNum: nextPage }, '', `?pageNum=${nextPage}`); }, onShowSizeChange: this.fetchPageSize, @@ -309,16 +310,15 @@ export default class DataView extends React.Component { const { pageData: { list, page }, } = nextProps; - const newPage = - page.total > 0 - ? { - current: page.pageNum, - total: page.total, - } - : { - current: PAGINATION.current, - total: PAGINATION.total, - }; + const newPage = page.total > 0 + ? { + current: page.pageNum, + total: page.total, + } + : { + current: PAGINATION.current, + total: PAGINATION.total, + }; const newData = _.assign({}, data, { origin: list }); this.setState({ pagination: _.assign({}, pagination, newPage), @@ -384,13 +384,13 @@ export default class DataView extends React.Component { message.error(res && res.message); } } - initView = () => { // 该方法用于回调子空间的initView方法,只会执行一次 + + initView = () => { // 该方法用于回调子空间的initView方法,只会执行一次 const { initView } = this.props; const { searchForm } = this.state; if (initView) { initView({ searchForm, instance: this, form: this.props.form }); } - } // eslint-disable-next-line react/sort-comp @@ -528,10 +528,9 @@ export default class DataView extends React.Component { result = {}; } else { const siftDataArr = Array.isArray(this.state.siftDataArr) ? this.state.siftDataArr : []; - const obj = - siftDataArr.find((item) => { - return item.queryLabelId === index; - }) || {}; + const obj = siftDataArr.find((item) => { + return item.queryLabelId === index; + }) || {}; try { result = JSON.parse(obj.queryLabelValue); result = this.rebackDate(result); @@ -568,6 +567,7 @@ export default class DataView extends React.Component { } return data; }; + filterSubComChangeParams = (key) => { const { searchCols, advancedSearchCols } = this.props; const sumSearchCols = [...(searchCols || []), ...(advancedSearchCols || [])]; @@ -581,22 +581,22 @@ export default class DataView extends React.Component { fn = onChangeParams; return; } - } if (Array.isArray(data)) { - data.map(ls => filterFun(ls)); + data.map((ls) => { return filterFun(ls); }); } - } + }; filterFun(sumSearchCols); return fn; } + // 更改查询条件 _changeSearchForm = async (props, changedValues, allValues) => { let newData = changeDateRange(props, changedValues, allValues); // 回调配置项里面changeParams方法 const onChangeParams = this.filterSubComChangeParams(Object.keys(changedValues)[0]); if (onChangeParams) { - newData = await onChangeParams(changedValues, newData) || newData + newData = await onChangeParams(changedValues, newData) || newData; } await this.setState({ searchForm: newData, @@ -639,9 +639,9 @@ export default class DataView extends React.Component { // 回调配置项里面changeParams方法 const onChangeParams = this.filterSubComChangeParams(values.key); if (onChangeParams) { - const obj = {} + const obj = {}; obj[values.key] = undefined; - formData = await onChangeParams(obj, formData) || formData + formData = await onChangeParams(obj, formData) || formData; } this.setState( { @@ -706,7 +706,9 @@ export default class DataView extends React.Component { return (
{btns.map((item, i) => { - const { label, onClick, authority, download, iconBtnSrc, type } = item; + const { + label, onClick, authority, download, iconBtnSrc, type, + } = item; const style = { marginLeft: '10px', }; @@ -819,7 +821,7 @@ export default class DataView extends React.Component { // }; render() { - const { style, hideForm, tips } = this.props; + const { style, hideForm, tips, selfCom, selfTableWrap } = this.props; const { loading } = this.state; return (
@@ -828,6 +830,7 @@ export default class DataView extends React.Component { <>
{/* 筛选条件 */} + {selfCom || null} {this._renderSearchForm()} {/* 高级搜索 */} {/* {advancedStatus ? this.renderAdvanced() : null} */} @@ -837,7 +840,7 @@ export default class DataView extends React.Component {
)} -
+
{tips ? this._renderTips() : this._renderBtns()} {this._renderData()} {this._renderPagination()} diff --git a/components/SearchView/index.less b/components/SearchView/index.less index 3ad753d..f94d2a6 100644 --- a/components/SearchView/index.less +++ b/components/SearchView/index.less @@ -53,7 +53,7 @@ .label { color: @textPrimaryColor; margin-right: 25px; - width: 66px; + min-width: 66px; text-align: right; } @@ -83,7 +83,7 @@ } } } - .modalRowWrap{ + .modalRowWrap { margin-bottom: 0px; } } @@ -94,14 +94,14 @@ //background-color: blue; //border-top: 1px solid red; } -.formItem{ +.formItem { display: flex; align-items: center; justify-content: flex-start; - :global .ant-form-item-control{ + :global .ant-form-item-control { line-height: 1.2; } } -.timeStyle{ +.timeStyle { max-width: 320px; -} \ No newline at end of file +} -- 2.21.0