“react“: “^16.14.0“,打开弹窗数据发生变化

编程入门 行业动态 更新时间:2024-10-25 06:30:23

“react“: “^16.14.0“,打开弹窗数据<a href=https://www.elefans.com/category/jswz/34/1771449.html style=发生变化"/>

“react“: “^16.14.0“,打开弹窗数据发生变化

“react”: “^16.14.0”,

弹窗

打开弹窗数据发生变化

// 这里对比changeHistoryVisible是否发生改变调用后端方法改变数据componentDidUpdate(prevProps) {if (prevProps.changeHistoryVisible !== this.props.changeHistoryVisible && this.props.changeHistoryVisible) {this.getStockLogList()}}componentDidMount() {this.getStockLogList()}
<Modaltitle={'变更记录'}visible={changeHistoryVisible}onCancel={() => this.changeHistoryCancel()}footer={false}width={800}><ModelCom changeHistoryVisible={changeHistoryVisible} ref={this.ModelCom} id={id} type={type}></ModelCom></Modal>
import React, { Component, useEffect } from 'react';
import { connect } from 'dva';
import PropTypes from 'prop-types';
import { Button, Card, Form, Table, message, Modal } from 'antd';
import moment from 'moment';
import { enterStockTypeStatus, orderTypeNewRetail } from '@/utils/enumType'@connect((RetailGoodsInBound) => ({...RetailGoodsInBound,
}))
// 变更记录弹窗
export default class ModelCom extends Component {static propTypes = {dispatch: PropTypes.func,match: PropTypes.shape,}static defaultProps = {dispatch: PropTypes.dispatch,match: PropTypes.match,}state = {// changeHistoryVisible: false,loadingLog: false,currentObj: {},params: {currentPage: 1,pageSize: 10,id: ''}}columns = [{title: '变更用户',dataIndex: 'operatorName',key: 'operatorName',},{title: '变更时间',dataIndex: 'gmtCreate',key: 'gmtCreate',render: (text) => <>{text ? moment(text).format('YYYY-MM-DD') : ''}</>},{title: '条码',dataIndex: 'oldData',key: 'oldData',},{title: '操作',dataIndex: 'orderType',key: 'orderType',render: (text, record) => <><span>{`${orderTypeNewRetail(record.orderType)}${enterStockTypeStatus(record.type)}`}</span></>},]componentDidUpdate(prevProps) {if (prevProps.changeHistoryVisible !== this.props.changeHistoryVisible && this.props.changeHistoryVisible) {this.getStockLogList()}}componentDidMount() {this.getStockLogList()}columnsFilter() { }getStockLogList = () => {const { dispatch } = this.propsthis.state.params.id = this.props.idconst currentObj = {type: this.props.type,id: this.props.id,}this.setState({currentObj})this.setState({loadingLog: true})dispatch({type: 'RetailGoodsInBound/getGoodsUpdateLog',payload: { ...this.state.params },}).then(res => {if (res.code === 20000) {this.setState({loadingLog: false})}})}// 改变每页条数&下一页 上一页pageChange = (current, pageSize) => {this.state.params.currentPage = current;this.state.params.pageSize = pageSize;this.getStockLogList();};render() {const { RetailGoodsInBound: { stockLogList } } = this.props;const { changeHistoryVisible, loadingLog } = this.statereturn (// <Modal//   title={'变更记录'}//   visible={changeHistoryVisible}//   onCancel={() => this.changeHistoryCancel()}//   footer={false}//   width={800}// ><div className="contentModel"><TablerowKey="barCode"columns={this.columns}dataSource={stockLogList.rows ? stockLogList.rows : []}borderedloading={loadingLog}scroll={{ y: 400 }}pagination={{showSizeChanger: true,showQuickJumper: true,current: stockLogList.currentPage, // 当前页pageSize: stockLogList.pageSize, // 每页几条total: stockLogList.totalCount, // 总共条数onShowSizeChange: (current, pageSize) => {this.pageChange(current, pageSize);},onChange: (current, pageSize) => {this.pageChange(current, pageSize);},showTotal: (total) => `共 ${total} 条记录    第${stockLogList.currentPage ? stockLogList.currentPage : 1}/${stockLogList.totalPage ? stockLogList.totalPage : 1}页`}}/></div>// </Modal>)}
}

更多推荐

“react“: “^16.14.0“,打开弹窗数据发生变化

本文发布于:2023-12-06 19:37:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1668616.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:发生   数据   react

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!