import * as React from 'react' import { Modal, Form } from 'antd' import { ModalProps } from 'antd/lib/modal' import cx from 'classnames' import './index.scss' import { optimizePic } from '@/shared/common/utils' import { PriceModalType } from './type' import { limitWord } from '@/shared/common/utils' import { ChannelProduct } from '@xmly/cbp-spec/lib/portal/service/oss/ChannelStrategyService' import { FormComponentProps } from 'antd/lib/form' type P = ModalProps & FormComponentProps & { type: PriceModalType visible: boolean currentRole?: any dataSource: Array columns: any } type S = {} // 设置特殊价、价盘价弹窗 class PriceModal extends React.Component { readonly state: S = {} renderTableHead = () => { const { columns } = this.props return columns.map((item, index) => { return (
{item.title}
) }) } renderTableBody = () => { const { dataSource, type, columns } = this.props const lastColumn = columns[columns.length - 1] const lastKey = lastColumn.dataIndex return ( dataSource && dataSource.map((spu, spuIndex: number) => { const skuList = spu.items return (
{/*
{columns.map((column: any, index) => { const key = column.dataIndex; if (index === 0) { return (
{spu.productName}
); } else { return index <= columns.length - 1 ? (
{column.render ? column.render(spu[key], spu, index) : spu[key]}
) : null; } })}
*/} {skuList.map((sku: any, index: number) => { return (
{columns.map((column, index) => { const key = column.dataIndex if (index === 0) { return (
{sku.itemName ? limitWord(sku.itemName, 18) : '无'}
商品ID:{sku.itemId}
) } else { const renderLimit = type === PriceModalType.SPECIAL ? index < columns.length - 1 : index <= columns.length - 1 return renderLimit ? (
{column.render ? column.render(sku[key], sku, index) : sku[key]}
) : null } })} {type === PriceModalType.SPECIAL && (
{lastColumn.render ? lastColumn.render(spu[lastKey], spu, spuIndex) : spu[lastKey]}
)}
) })}
) }) ) } render() { const { visible, title, width = 800, onCancel, currentRole, type } = this.props return (
角色: {currentRole && currentRole.name}
{this.renderTableHead()}
{this.renderTableBody()}
) } } export default Form.create

()(PriceModal)