import React, { Component } from 'react'; import { Card, Modal, Form, Button, Tag, Icon } from 'antd'; import { connect } from 'dva'; import { routerRedux } from 'dva/router'; import TableForm from './TableForm'; import FooterToolbar from '../../../components/FooterToolbar'; import Selector from '../../../components/AXTableSelector/Selector'; import { addRowKey } from '../../../utils/utils'; import { Hotax } from '../../../utils/config'; @connect(({ loading, shelves, tag }) => ({ tag, shelves, tLoading: loading.models.tag, submitting: loading.models.shelves, })) @Form.create() export default class PackageEdit extends Component { constructor(props) { super(props); const { location } = props; const { state } = location; const { merchantId, pid, productType } = state; this.state = { pid, merchantId, productType, tagSelectorDestroy: true, }; } componentDidMount() { const { merchantId, pid } = this.state; this.props.dispatch({ type: 'shelves/fetchItemDetail', payload: { pid, merchantId, }, }); } handleGoodsCreate=(data) => { const { pid, merchantId } = this.state; this.props.dispatch({ type: 'shelves/createItemPrice', payload: { ...data, ...this.state, productType: Hotax.PRODUCT_PACKAGE, status: Hotax.STATUS_NORMAL, }, states: { pid, merchantId, }, }); }; handleGoodsUpdate=(data) => { const { pid, merchantId } = this.state; this.props.dispatch({ type: 'shelves/updateItemPrice', payload: { ...data, ...this.state, }, states: { pid, merchantId, }, }); }; handleGoodsDelete=(data) => { const { pid, merchantId } = this.state; this.props.dispatch({ type: 'shelves/deleteItemPrice', payload: data, states: { pid, merchantId, }, }); }; handleTagClose=(index) => { const { pid, merchantId } = this.state; const { shelves } = this.props; const { currentItem } = shelves; const { tags } = currentItem; const newTags = tags.filter((item, location) => location !== index); const newTagIds = newTags.map(item => item.id); this.props.dispatch({ type: 'shelves/updateItemTags', payload: { pid, merchantId, tags: newTagIds, }, states: { pid, merchantId, }, }); }; handleTagSelectorModalShow = () => { this.setState({ tagSelectorDestroy: false, }); const { merchantId } = this.state; this.props.dispatch({ type: 'tag/fetchTagList', payload: { merchantId }, }); }; handleTagSelectorCancel = () => { this.setState({ tagSelectorDestroy: true, }); }; handleTagSelectorChange = (params) => { const { merchantId } = this.state; this.props.dispatch({ type: 'tag/fetchTagList', payload: { merchantId, ...params }, }); }; handleTagSelectorFinish = (rows) => { const { pid, merchantId } = this.state; const newTagIds = (rows || []).map(row => row.id); this.props.dispatch({ type: 'shelves/updateItemTags', payload: { pid, merchantId, tags: newTagIds, }, states: { pid, merchantId, }, }); this.setState({ tagSelectorDestroy: true, }); }; handlePageBack=() => { this.props.dispatch(routerRedux.push({ pathname: '/shelves/package', state: this.props.location.state, })); }; render() { const { tagSelectorDestroy } = this.state; const { submitting, tLoading, shelves, tag, form } = this.props; const { getFieldDecorator } = form; const { currentItem } = shelves; const { goods, tags } = currentItem; return (