当前位置: 网站首页>小程序开发>网络推广

成都网站制作|成都网站推广专家_成都网站建设服务中心

发表日期: 2021-06-06 12:31:30 浏览次数:100

成都网站制作|成都网站推广专家_成都网站建设服务中心


网站建设.jpg


成都,简称“蓉”,别称蓉城、锦城,四川省辖地级市,是四川省省会、副省级市 [192]  、特大城市 [182]  、成渝地区双城经济圈核心城市,国务院批复确定的中国西部地区重要的中心城市,国家重要的高新技术产业基地、商贸物流中心和综合交通枢纽 [1]  。截至2019年,全市下辖12个市辖区、3个县、代管5个县级市,总面积14335平方千米 [2-3]  截至2020年末,成都常住人口2093.8万人。 [193] 

成都地处中国西南地区、四川盆地西部、成都平原腹地,境内地势平坦、河网纵横、物产丰富、农业发达,属亚热带季风性湿润气候,自古有“天府之国”的美誉 [4]  ,是中国人民解放军西部战区机关驻地 [5]  ,作为重要的电子信息产业基地 [6-7]  ,有国家级科研机构30家,国家级研发平台67个 [8]  ,高校65所, [64]  2019年世界500强企业落户301家 [9]  。

成都是全国十大古都和首批国家历史文化名城 [10]  ,古蜀文明发祥地 [11]  。境内金沙遗址有3000年历史 [12]  ,周太王以“一年成聚,二年成邑,三年成都” [13]  ,故名成都 [14]  ;蜀汉、成汉、前蜀、后蜀等政权先后在此建都;一直是各朝代的州郡治所;汉为全国五大都会之一;唐为中国最发达工商业城市之一,史称“扬一益二”;北宋是汴京外第二大都会,发明世界上第一种纸币交子。拥有都江堰、武侯祠、杜甫草堂等名胜古迹,是中国最佳旅游城市 [15]  。

2020年,成都实现地区生产总值(GDP)17716.7亿元,按可比价格计算,比上年增长4.0%。 [64] 


前言

antd 的table表格拖拽列,会导致触发排序问题,解决方案如下,相当于加一个点击的事件判断,如果是拖拽,则不触发。

解决代码如下:

import { Resizable } from 'react-resizable'class ResizeableTitle extends React.Component {
  render() {
    const { onResize, width, onClick, ...restProps } = this.props;
    return (
      <Resizable
        width={width}
        height={0}
        onResizeStart={() => (this.resizing = true)}
        onResizeStop={() => {
          setTimeout(() => {
            this.resizing = false;
          });
        }}
        onResize={onResize}
      >
        <th
          onClick={(...args) => {
            if (!this.resizing && onClick) {
              onClick(...args);
            }
          }}
          {...restProps}
        />
      </Resizable>
    );
  }}

在拖拽表格中使用

components = {
    header: {
      cell: ResizeableTitle
    }
  }

完整代码

import React from 'react'import listCSS  from "./listTable.less"import 'antd/dist/antd.css'import zhCN from 'antd/lib/locale/zh_CN'import PropTypes from 'prop-types'import { Table,ConfigProvider } from 'antd'import { Resizable } from 'react-resizable'class ResizeableTitle extends React.Component {
  render() {
    const { onResize, width, onClick, ...restProps } = this.props;
    return (
      <Resizable
        width={width}
        height={0}
        onResizeStart={() => (this.resizing = true)}
        onResizeStop={() => {
          setTimeout(() => {
            this.resizing = false;
          });
        }}
        onResize={onResize}
      >
        <th
          onClick={(...args) => {
            if (!this.resizing && onClick) {
              onClick(...args);
            }
          }}
          {...restProps}
        />
      </Resizable>
    );
  }
}


class ResizeableTable extends React.PureComponent {
  constructor(props) {
    super(props);

    this.state = {
      columns: props.columns
    };
  }

  components = {
    header: {
      cell: ResizeableTitle
    }
  }
  calculateColumsWidthSum = (columns = [], firstColWidth = 0, lastColWidth = 0)=> {
    const arrReducer = (accumulator, currentValue) => {
      if (!currentValue || !currentValue.width) {
        return accumulator
      }

      let width = currentValue.width
      if (typeof width === 'string') {
        if (width.endsWith('px')) {
          width = parseFloat(width.split('px')[0])
        } else {
          return accumulator
        }
      } else if (typeof width === 'number') {
        width = parseFloat(width)
      } else {
        return accumulator
      }
      return accumulator + width
    }
    return columns.reduce(arrReducer, 0) + firstColWidth + lastColWidth
  }

  componentDidMount() {
  }

  render() { 
    const {className,tableLayout,rowKey,components,scrollToFirstRowOnChange,locale,columns,lastColumnWidth,firstColumnWidth, ...restProps} = this.props
    const _columns = this.state.columns.map((col, index) => ({
      ...col,
      onHeaderCell: (column) => ({
        width: column.width,
        onResize: this.handleResize(index)
      })
    }))
    let tableScrollWidth = this.calculateColumsWidthSum(_columns, firstColumnWidth, lastColumnWidth)
    const _components = Object.assign({},components,this.components)
    return <ConfigProvider locale={locale || zhCN}>
        <div className={`${className} listBox`} style={{ marginTop: '15px' }}>
            <style dangerouslySetInnerHTML={{ __html: {listCSS} }} />
            <Table bordered tableLayout={tableLayout || 'fixed'} className="lat_list_tablestyle" columns={_columns} components={_components} rowKey={rowKey || 'lat_global_table'} scroll={{ x: tableScrollWidth }}  {...restProps} scrollToFirstRowOnChange={scrollToFirstRowOnChange || true}/>
        </div>
     </ConfigProvider>
  }

  handleResize = (index) => (e, { size }) => {
    e.stopImmediatePropagation();
    this.setState(({ columns }) => {
      const nextColumns = [...columns];
      nextColumns[index] = {
        ...nextColumns[index],
        width: size.width      };
      return { columns: nextColumns }
    })
  }}ResizeableTable.propTypes = {
  sticky: PropTypes.object,
  columns: PropTypes.array,
  dataSource: PropTypes.array,
  onChange:PropTypes.func,
  firstColumnWidth:PropTypes.number,
  lastColumnWidth:PropTypes.number,
  scroll:PropTypes.object}ResizeableTable.defaultProps ={
  sticky:{offsetHeader:56},
  columns:[],
  dataSource:[],
  firstColumnWidth:65,
  lastColumnWidth:150}export default ResizeableTable

github仓库

github 组件仓库地址 https://github.com/confidence68/ResizeableTable




成都网站制作|成都网站推广专家_成都网站建设服务中心

400-111-6878
服务热线
顶部

备案号: 苏ICP备11067224号

CopyRight © 2011 书生商友信息科技 All Right Reserved

24小时服务热线:400-111-6878   E-MAIL:1120768800@qq.com   QQ:1120768800

  网址: http://www.768800.com  网站建设上往建站

关键词: 网站建设| 域名邮箱| 服务器空间| 网站推广| 上往建站| 网站制作| 网站设计| 域名注册| 网络营销| 网站维护|

企业邮箱| 虚拟主机| 网络建站| 网站服务| 网页设计| 网店美工设计| 网站定制| 企业建站| 网站设计制作| 网页制作公司|

400电话办理| 书生商友软件| 葬花网| 调温纤维| 海洋馆运营维护| 北京保安公司| 殡仪馆服务| 殡葬服务| 苏州殡葬一条龙| 朝阳殡葬| 苏州殡葬服务|

预约专家

欢迎您免费咨询,请填写以下信息,我们收到后会尽快与您联系

  

服务热线:400-111-6878