当前位置: 首页 > news >正文

织梦手机网站有广告位域名备案信息查询官网

织梦手机网站有广告位,域名备案信息查询官网,怎样制作公司的网页,对百度网站进行分析效果图:如下 效果说明: 1. 点击“选择”按钮,打开弹窗 2. 左侧数据是调接口回显来的 3. 点击左侧某条数据,这条被点击的数据就会被添加到右侧 4. 右侧的数据可以上下拖动换位置 5. 右侧有数据时,点击"确定"…

效果图:如下

效果说明:

        1. 点击“选择”按钮,打开弹窗

        2. 左侧数据是调接口回显来的

        3. 点击左侧某条数据,这条被点击的数据就会被添加到右侧

        4. 右侧的数据可以上下拖动换位置

        5.  右侧有数据时,点击"确定" 按钮,数据就会以字符串拼接形式回显到TextArea框里,以顿号(、)分割 

        6. antd3里面的拖拽组件用的 react-dnd的

<DndProvider backend={HTML5Backend}> 。但在我这项目里DndProvider就不适用(项目react版本16.8.6),换一种react-dnd的低版本的写法即DragDropContext

        7. 还有一些样式的问题,没写全,需要细调

         

        

代码难免会涉及到业务需求,展示部分代码,全部复制不能实现效果,仅供参考

1. 父

import React, { PureComponent } from 'react'
import { Row, Input, Button, Modal, Spin } from 'antd'
import DragSortingTable from './DragSortingTable' // 拖拽组件const TextArea = Input.TextArea;class SelectProject extends PureComponent {constructor(props){super(props)this.state= {modalVisible: false,loading: false,disabled: false,rightList: [],leftList: [],value: '',}}// 打开弹窗openModal = () => {this.setState({ modalVisible: true })}// 关闭弹窗onCloseModal = () => {this.setState({ modalVisible: false })}// 确定onOkModal = () => {const { rightList } = this.state;let stringData = ''rightList && rightList.forEach((item, index) => {if(index < rightList.length -1){stringData += `${item.destOrgName}`} else {stringData += item.destOrgName}})this.setState({ modalVisible: false, value: stringData })}// 点击左侧数据okDataClick = (item) => {const { rightList } = this.state;let list = JSON.parse(JSON.stringify(rightList))if(JSON.stringify(list).indexOf(JSON.stringify(item)) > -1){message.warning(`已选择${item.destOrgName}`)return false;}list.push(item)this.setState({ rightList: list })}// 左侧数据展示treeLeftList = () => {const { leftList } = this.state;const radioLeftList = []if(leftList[0]){leftList.forEach(item => {radioLeftList.push(<div onClick={() => this.okDataClick(item)} style={{ lineHeight: '24px', padding: '4px 0', cursor: 'pointer' }}>{item.destOrgName}</div>)})}return radioLeftList}// 拖拽后,更新右侧数据updataSetState = (newData) => {this.setState({ rightList: newData })}// 删除当前行数据clearHang = (item) => {const { rightList } = this.state;const radioLeftList = []rightList.map(subItem => {if(subItem.destOrgName !== item.destOrgName){radioLeftList.push(subItem)}})this.setState({ rightList: radioLeftList })}// 左右两列整体展示buttonForm = () => {const { rightList } = this.state;return (<div><Row><Col span={12}><span>选择xx</span><div>{this.treeLeftList()}</div></Col><Col span={12}><div><span>已选中xx</span><a>清空</a></div><div><DragSortingTable2 rightList={rightList} updata={this.updataSetState} clearHang={this.clearHang} /> // 重点:用的antd3的表格可拖拽</div></Col></Row></div>)}render () {return (<div><Row><TextArea autoSize disabled={} value={this.state.value} /><Button onClick={() => {this.setState({ modalVisible: true,loading: true,}); this.openModal()}}disabled={this.state.disabled}>选择</Button></Row>{ this.state.modalVisible ?<Modal title='' visible={this.state.modalVisible} maskCloseable={false}width='60%' onCancel={this.onCloseModal} footer={<div style={{ textAlign: 'center'}}><Button onClick={this.onOkModal} type='primary'>确定</Button><Button onClick={this.onCloseModal}>关闭</Button></div>}><Spin spin={this.state.loading} tip='Loading'>{this.buttonForm()}</Spin></Modal> : null}</div>)}}export default SelectProject

拖拽子组件

相当于拖拽的table组件全部复制过来,然后主要改动是moveRow,和render里面的。

        1. 至于table有表格样式,就把表格样式设置border: 0   

        2. 页码不显示pagination={false}

        3. 当table没数据时,会显示一个空数据的图标,把空数据图标隐藏起来:z-index: -2

2. 子

import { Table } from 'antd';
import { DragDropContext, DragSource, DropTarget } from 'react-dnd';
import { HTML5Backend } from 'react-dnd-html5-backend';let dragingIndex = -1;class DragSortingTable extends PureComponent {render() {const { isOver, connectDragSource, connectDropTarget, moveRow, ...restProps } = this.props;const style = { ...restProps.style, cursor: 'move' };let { className } = restProps;if (isOver) {if (restProps.index > dragingIndex) {className += ' drop-over-downward';}if (restProps.index < dragingIndex) {className += ' drop-over-upward';}}return connectDragSource(connectDropTarget(<tr {...restProps} className={className} style={style} />),);}
}const rowSource = {beginDrag(props) {dragingIndex = props.index;return {index: props.index,};},
};const rowTarget = {drop(props, monitor) {const dragIndex = monitor.getItem().index;const hoverIndex = props.index;// Don't replace items with themselvesif (dragIndex === hoverIndex) {return;}// Time to actually perform the actionprops.moveRow(dragIndex, hoverIndex);// Note: we're mutating the monitor item here!// Generally it's better to avoid mutations,// but it's good here for the sake of performance// to avoid expensive index searches.monitor.getItem().index = hoverIndex;},
};const DragableBodyRow = DropTarget('row', rowTarget, (connect, monitor) => ({connectDropTarget: connect.dropTarget(),isOver: monitor.isOver(),
}))(DragSource('row', rowSource, connect => ({connectDragSource: connect.dragSource(),}))(BodyRow),
);class DragSortingTable extends React.Component {components = {body: {row: DragableBodyRow,},};// 拖拽moveRow = (dragIndex, hoverIndex) => {const {rightList, updataSetState} = this.props;const dragRow = rightList[dragIndex];const newDataList = [...rightList]newDataList.splice(dragIndex, 1)newDataList.splice(hoverIndex, 0, dragRow)updataSetState(newDataList)};render() {const columns = [{title: <span style={{fontSize:'12px', color: '#71bbff'}}>{'长按可拖动排序'}</span>,dataIndex: 'destOrgName',key: 'destOrgName',render: (text, record) => {return (<span>{text}</span><a onClick={() => this.props.clearHang(record)} style={{ float:'right'}}>x</a>)}}];return (<Tablecolumns={columns}dataSource={this.props.rightList} // 父级传过来的components={this.components}onRow={(record, index) => ({index,moveRow: this.moveRow,})}pagination={false} // 不显示页码className='dataListTable'/>);}
}}const DragSortingTable2 = DragDropContext(HTML5Backend)(DragSortingTable)
export default DragSortingTable2

http://www.15wanjia.com/news/163472.html

相关文章:

  • 廊坊网站制作建在线教育网站需要多少钱
  • 上海一家做服饰包鞋穿上用品的网站云南省网站建设收费调查报告论文
  • 宁波优化网站排名软件做音乐的网站
  • 微网站制作网站开发现在网络推广哪家好
  • 标书制作教程视频网站wordpress twilight saga 主题
  • 建设网站的市场环境怎么样网创是什么
  • 昆明网站建设云集创怎么做系部网站首页
  • 有哪些做公司网站的南通专业网站排名推广
  • 阿里云做网站需要些什么模板网站和插件
  • 网站建设费要摊销网络工程就业方向及就业前景
  • 上海免费推广网站有哪些阿里巴巴网站建设基础服务
  • 河北华宇建设集团有限公司网站wordpress恢复备份数据库
  • 深圳勘察设计协会新乡优化
  • 成都网站系统开发电商设计包括什么
  • 门户网站开发难点wordpress 下载按钮插件
  • 深圳建网站的公司朗润装饰成都装修公司官网
  • 模板建站和定制建站室内设计师联盟app
  • 多作者wordpress插件专业网站优化公司排名
  • 重庆seo整站优化系统深圳展览设计网站建设
  • 制作一个网站难吗彩票网站做一级代理犯法吗
  • js写的网站怎么做seo沈阳淘宝网站建设
  • 企业网站建设栏目结构图做网页的软件w
  • 网站刷单账务处理怎么做php网站后台怎么进
  • 网站建设主机配置百度seo关键词报价
  • 福建省建设工程职业注册网站网站建设服装项目设计书
  • 获取网站访客qq信息徐汇网站制作设计
  • 如何批量做网站接网站建设外包的工作
  • 网站制作及维护合同大连营销策划公司排名
  • 网站详情页用哪个软件做如何分析一个网站建设策划案
  • 学做网站初入门教程中国建设网官网网站