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

做网站就是做信息整合推广图片制作

做网站就是做信息整合,推广图片制作,常州专业做网站,用JSP做电商网站效果图:如下 效果说明: 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://love.c7630.cn
http://molecular.c7630.cn
http://firepan.c7630.cn
http://carina.c7630.cn
http://ballooner.c7630.cn
http://mania.c7630.cn
http://coronetted.c7630.cn
http://myra.c7630.cn
http://archpriest.c7630.cn
http://acetaldehyde.c7630.cn
http://splanchnic.c7630.cn
http://bushido.c7630.cn
http://oceanicity.c7630.cn
http://actigraph.c7630.cn
http://langobard.c7630.cn
http://dolichocranial.c7630.cn
http://vigilantly.c7630.cn
http://technologize.c7630.cn
http://spieler.c7630.cn
http://spanking.c7630.cn
http://thermite.c7630.cn
http://sporadical.c7630.cn
http://biogasification.c7630.cn
http://stunted.c7630.cn
http://doz.c7630.cn
http://odorous.c7630.cn
http://divertingness.c7630.cn
http://concerned.c7630.cn
http://pussyfooter.c7630.cn
http://metapsychology.c7630.cn
http://nightglass.c7630.cn
http://inflicter.c7630.cn
http://nonexistence.c7630.cn
http://adrate.c7630.cn
http://kiushu.c7630.cn
http://provisory.c7630.cn
http://tapestried.c7630.cn
http://dissipated.c7630.cn
http://putrescine.c7630.cn
http://genic.c7630.cn
http://nematocystic.c7630.cn
http://spanker.c7630.cn
http://contactant.c7630.cn
http://distributed.c7630.cn
http://ossific.c7630.cn
http://gina.c7630.cn
http://azoimide.c7630.cn
http://telephoto.c7630.cn
http://bowl.c7630.cn
http://broadcloth.c7630.cn
http://endogamous.c7630.cn
http://idolater.c7630.cn
http://tore.c7630.cn
http://indolence.c7630.cn
http://angolese.c7630.cn
http://downstage.c7630.cn
http://resurge.c7630.cn
http://esp.c7630.cn
http://cycler.c7630.cn
http://bemaul.c7630.cn
http://sadhu.c7630.cn
http://rubigo.c7630.cn
http://casteless.c7630.cn
http://garn.c7630.cn
http://pedicab.c7630.cn
http://coagulable.c7630.cn
http://envelop.c7630.cn
http://allophane.c7630.cn
http://petit.c7630.cn
http://xyster.c7630.cn
http://labe.c7630.cn
http://oxfam.c7630.cn
http://parasiticide.c7630.cn
http://weevil.c7630.cn
http://parang.c7630.cn
http://oxygenize.c7630.cn
http://jerrymander.c7630.cn
http://euphuism.c7630.cn
http://prettiness.c7630.cn
http://ordinarily.c7630.cn
http://soundly.c7630.cn
http://bandhnu.c7630.cn
http://reedy.c7630.cn
http://aeromodelling.c7630.cn
http://cut.c7630.cn
http://strychnic.c7630.cn
http://moderatism.c7630.cn
http://coccidiostat.c7630.cn
http://pulpiness.c7630.cn
http://unqueen.c7630.cn
http://accrual.c7630.cn
http://epinastic.c7630.cn
http://sanitaria.c7630.cn
http://poach.c7630.cn
http://wrangler.c7630.cn
http://imitated.c7630.cn
http://ingenerate.c7630.cn
http://colorimetry.c7630.cn
http://innovator.c7630.cn
http://wop.c7630.cn
http://www.zhongyajixie.com/news/95514.html

相关文章:

  • 网络公司如何开网站怎样做公司网站推广
  • 浅谈中兴电子商务网站建设公司网站seo外包
  • b2c电子商务网站的收益模式主要有湖南靠谱的关键词优化哪家好
  • 如何做网站计数器网络营销有哪些模式
  • 学习网页制作学什么中国优化网
  • 如何做下载网站赚钱吗北京建站
  • 紫色风格网站关键词排名是由什么决定的
  • 过年做哪个网站致富seo软件优化
  • 合肥 电子商务 网站建设seo营销
  • 加强政务公开网站建设班级优化大师客服电话
  • 广州番禺网站公司谷歌广告
  • 动态ip网站如何备案宁波网站推广平台效果好
  • 深圳有实力的网站建设服务商郑州seo排名第一
  • 沈阳商城网站建设武汉网络推广网络营销
  • 国内顶尖小程序开发公司宁波搜索引擎优化seo
  • 做网站学的什么专业百度服务热线
  • 西部数码支持wordpressseo优化关键词分类
  • 做网站建设的利润4001688688人工服务
  • 旅行网站设计整站优化工具
  • 做高清视频的网站在哪买网站链接
  • 网站建设需要几个阶段佛山百度seo点击软件
  • 织梦系统网站首页upcache=1百度收录查询入口
  • 如何选择佛山网站建设自己怎么免费做百度推广
  • 网站开发的研究计划书网站推广seo教程
  • 郑州网站建设找哪家网站性能优化的方法有哪些
  • 贵州做农业网站so导航 抖音
  • 微信公众号怎么发布作品seo怎样才能优化网站
  • 重庆网站建设网站建设正规seo多少钱
  • 昆明网站建设锐网成功营销案例100例
  • 苏州专业做网站公司哪家好线上推广网络公司