|
@@ -1,211 +0,0 @@
|
|
-import React, { PureComponent } from 'react';
|
|
|
|
-import { Divider, Table, Form, Card, Button, Tag } from 'antd';
|
|
|
|
-import { connect } from 'dva';
|
|
|
|
-import { routerRedux } from 'dva/router';
|
|
|
|
-import queryString from 'query-string';
|
|
|
|
-import PageHeaderLayout from '../../../layouts/PageHeaderLayout';
|
|
|
|
-import FooterToolbar from '../../../components/FooterToolbar';
|
|
|
|
-import DescriptionList from '../../../components/DescriptionList';
|
|
|
|
-import NewPriceModal from './price';
|
|
|
|
-import TagSelectModal from './tags';
|
|
|
|
-import { pageSize, productType, Codes } from '../../../utils/config';
|
|
|
|
-
|
|
|
|
-const { Description } = DescriptionList;
|
|
|
|
-
|
|
|
|
-@Form.create()
|
|
|
|
-@connect(state => ({ mproductDetail: state.mproductDetail }))
|
|
|
|
-export default class MerchantProductEdit extends PureComponent {
|
|
|
|
- handleAddPriceClick = () => {
|
|
|
|
- this.props.dispatch({
|
|
|
|
- type: 'goodsModel/showModal',
|
|
|
|
- payload: { operation: 'createItem' },
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- handleEditPriceClick = (record) => {
|
|
|
|
- this.props.dispatch({
|
|
|
|
- type: 'goodsModel/showModal',
|
|
|
|
- payload: {
|
|
|
|
- operation: 'updateItem',
|
|
|
|
- goodsItem: record,
|
|
|
|
- },
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- handleDelPriceClick = (record) => {
|
|
|
|
- const { dispatch, location } = this.props;
|
|
|
|
- const { search } = location;
|
|
|
|
- confirm({
|
|
|
|
- title: '您确定要删除此定价?',
|
|
|
|
- onOk() {
|
|
|
|
- dispatch({
|
|
|
|
- type: 'goodsModel/removeItem',
|
|
|
|
- payload: { id: record.id },
|
|
|
|
- callback: () => {
|
|
|
|
- dispatch(routerRedux.push({
|
|
|
|
- pathname: '/goods/edit',
|
|
|
|
- search,
|
|
|
|
- }));
|
|
|
|
- },
|
|
|
|
- });
|
|
|
|
- },
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- handleEditTagClick = () => {
|
|
|
|
- const { location } = this.props;
|
|
|
|
- const { search } = location;
|
|
|
|
- const { merchantId, pid } = queryString.parse(search);
|
|
|
|
- this.props.dispatch({
|
|
|
|
- type: 'goodsModel/showTagModal',
|
|
|
|
- });
|
|
|
|
- this.props.dispatch({
|
|
|
|
- type: 'tagModel/query',
|
|
|
|
- payload: {
|
|
|
|
- pageNo: 1,
|
|
|
|
- pageSize,
|
|
|
|
- status: Codes.CODE_NORMAL,
|
|
|
|
- merchantId,
|
|
|
|
- },
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- handleTagModalCancel = () => {
|
|
|
|
- this.props.dispatch({
|
|
|
|
- type: 'goodsModel/hideTagModal',
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- handleTagModalOk = (data) => {
|
|
|
|
- const { location } = this.props;
|
|
|
|
- const { search } = location;
|
|
|
|
- const { merchantId, pid } = queryString.parse(search);
|
|
|
|
- this.props.dispatch({
|
|
|
|
- type: 'goodsModel/bundleTags',
|
|
|
|
- payload: { pid, merchantId, tags: data.map(item => item.id) },
|
|
|
|
- callback: () => {
|
|
|
|
- this.props.dispatch(routerRedux.push({
|
|
|
|
- pathname: '/goods/edit',
|
|
|
|
- search,
|
|
|
|
- }));
|
|
|
|
- },
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- handleTagModalSearch = (data) => {
|
|
|
|
- const { location } = this.props;
|
|
|
|
- const { search } = location;
|
|
|
|
- const { merchantId, pid } = queryString.parse(search);
|
|
|
|
- const newData = { ...data };
|
|
|
|
- if (newData.keyword) {
|
|
|
|
- newData[newData.field] = newData.keyword;
|
|
|
|
- }
|
|
|
|
- delete newData.field;
|
|
|
|
- delete newData.keyword;
|
|
|
|
-
|
|
|
|
- this.props.dispatch({
|
|
|
|
- type: 'tagModel/query',
|
|
|
|
- payload: {
|
|
|
|
- ...newData,
|
|
|
|
- pageNo: 1,
|
|
|
|
- pageSize,
|
|
|
|
- status: Codes.CODE_NORMAL,
|
|
|
|
- merchantId,
|
|
|
|
- },
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- handlePageExit = () => {
|
|
|
|
- const { dispatch, mproductDetail } = this.props;
|
|
|
|
- const { filters } = mproductDetail;
|
|
|
|
- dispatch(routerRedux.push({
|
|
|
|
- pathname: '/products',
|
|
|
|
- search: queryString.stringify(filters),
|
|
|
|
- }));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- handleTagModalTableChange = (pagination) => {
|
|
|
|
- const { location, dispatch, mproductDetail } = this.props;
|
|
|
|
- const { filters } = mproductDetail;
|
|
|
|
- const { search } = location;
|
|
|
|
- const { merchantId, pid } = queryString.parse(search);
|
|
|
|
-
|
|
|
|
- const newFilters = { ...filters };
|
|
|
|
- if (newFilters.keyword) {
|
|
|
|
- newFilters[newFilters.field] = newFilters.keyword;
|
|
|
|
- }
|
|
|
|
- delete newFilters.field;
|
|
|
|
- delete newFilters.keyword;
|
|
|
|
-
|
|
|
|
- const data = {
|
|
|
|
- ...newFilters,
|
|
|
|
- pageNo: pagination.current,
|
|
|
|
- pageSize: pagination.pageSize,
|
|
|
|
- status: Codes.CODE_NORMAL,
|
|
|
|
- merchantId,
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- Object.keys(data).map(key => (data[key] ? null : delete data[key]));
|
|
|
|
- dispatch({ type: 'tagModel/query', payload: { ...data } });
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- render() {
|
|
|
|
- const { mproductDetail } = this.props;
|
|
|
|
- const { currentItem } = mproductDetail;
|
|
|
|
- const { goods, tags, type, code, name, merchantName } = currentItem;
|
|
|
|
-
|
|
|
|
- const listTableProps = {
|
|
|
|
- simple: true,
|
|
|
|
- bordered: true,
|
|
|
|
- pagination: false,
|
|
|
|
- rowKey: record => record.id,
|
|
|
|
- dataSource: goods,
|
|
|
|
- columns: [{
|
|
|
|
- title: '计价单位',
|
|
|
|
- dataIndex: 'chargeUnit',
|
|
|
|
- key: 'chargeUnit',
|
|
|
|
- }, {
|
|
|
|
- title: '渠道售卖价格(¥)',
|
|
|
|
- dataIndex: 'merchantPrice',
|
|
|
|
- key: 'merchantPrice',
|
|
|
|
- }, {
|
|
|
|
- title: '终端显示价格(¥)',
|
|
|
|
- dataIndex: 'terminalPrice',
|
|
|
|
- key: 'terminalPrice',
|
|
|
|
- }],
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- return (
|
|
|
|
- <PageHeaderLayout>
|
|
|
|
- <Card
|
|
|
|
- bordered={false}
|
|
|
|
- title="产品详情"
|
|
|
|
- style={{ marginBottom: 15 }}
|
|
|
|
- >
|
|
|
|
- <DescriptionList size="large" col={3} style={{ marginBottom: 32 }}>
|
|
|
|
- <Description term="商品编号">{code}</Description>
|
|
|
|
- <Description term="商品名称">{name}</Description>
|
|
|
|
- <Description term="商品类型">{productType[type]}</Description>
|
|
|
|
- </DescriptionList>
|
|
|
|
- </Card>
|
|
|
|
- <Card
|
|
|
|
- bordered={false}
|
|
|
|
- title="价格类型"
|
|
|
|
- style={{ marginBottom: 15 }}
|
|
|
|
- >
|
|
|
|
- <Table {...listTableProps} />
|
|
|
|
- </Card>
|
|
|
|
- <Card
|
|
|
|
- bordered={false}
|
|
|
|
- title="已上架标签"
|
|
|
|
- style={{ marginBottom: 15 }}
|
|
|
|
- >
|
|
|
|
- {tags ? tags.map(item => <Tag color="#f50">{item.name}</Tag>) : null}
|
|
|
|
- </Card>
|
|
|
|
- <FooterToolbar>
|
|
|
|
- <Button onClick={this.handlePageExit} type="primary">返回产品列表</Button>
|
|
|
|
- </FooterToolbar>
|
|
|
|
- </PageHeaderLayout>
|
|
|
|
- );
|
|
|
|
- }
|
|
|
|
-}
|
|
|