|
@@ -0,0 +1,227 @@
|
|
|
+import React, { Component } from 'react';
|
|
|
+import { Card, List, Form, Table, Button, Input } from 'antd';
|
|
|
+import { connect } from 'dva';
|
|
|
+import { routerRedux } from 'dva/router';
|
|
|
+
|
|
|
+import PageHeaderLayout from '../../../layouts/PageHeaderLayout';
|
|
|
+import FooterToolbar from '../../../components/FooterToolbar';
|
|
|
+import TerminalSelectModal from './terminal';
|
|
|
+import MerchantProductSelectModal from './product';
|
|
|
+// import GoodsSelectModal from './product';
|
|
|
+import { pageSize } from '../../../utils/config';
|
|
|
+
|
|
|
+@Form.create()
|
|
|
+@connect(state => ({
|
|
|
+ terminal: state.terminal,
|
|
|
+ orderItem: state.orderDetail,
|
|
|
+ mproduct: state.mproduct,
|
|
|
+}))
|
|
|
+export default class CreateOrder extends Component {
|
|
|
+
|
|
|
+ // 终端选择弹框相关的回调方法
|
|
|
+ handleTerminalSelectBtnClick = () => {
|
|
|
+ this.props.dispatch({ type: 'orderDetail/showTerminalModal' });
|
|
|
+ this.props.dispatch({
|
|
|
+ type: 'terminal/query',
|
|
|
+ payload: {
|
|
|
+ pageNo: 1,
|
|
|
+ pageSize,
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ handleTerminalModalOk = (record) => {
|
|
|
+ this.props.dispatch({
|
|
|
+ type: 'orderDetail/savePickedTerminal',
|
|
|
+ payload: {
|
|
|
+ userCode: record.code,
|
|
|
+ userName: record.name,
|
|
|
+ campusName: record.campusName,
|
|
|
+ merchantName: record.merchantName,
|
|
|
+ merchantId: record.merchantId,
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ handleTerminalModalCancel = () => {
|
|
|
+ this.props.dispatch({ type: 'orderDetail/hideTerminalModal' });
|
|
|
+ }
|
|
|
+
|
|
|
+ handleTerminalModalSearch = () => {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ handleTerminalModalTableChange = () => {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ // 产品选择弹框相关的回调方法
|
|
|
+ handleProductSelectBtnClick = () => {
|
|
|
+ const { orderItem } = this.props;
|
|
|
+ const { currentItem } = orderItem;
|
|
|
+ const { merchantId } = currentItem;
|
|
|
+ this.props.dispatch({ type: 'orderDetail/showProductModal' });
|
|
|
+ this.props.dispatch({
|
|
|
+ type: 'mproduct/query',
|
|
|
+ payload: {
|
|
|
+ pageNo: 1,
|
|
|
+ pageSize,
|
|
|
+ merchantId,
|
|
|
+ },
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ handleProductModalSearch = () => {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ handleProductModalTableChange = () => {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ handleProductModalOk = (data) => {
|
|
|
+ this.props.dispatch({
|
|
|
+ type: 'orderDetail/savePickedProducts',
|
|
|
+ payload: data,
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ handleProductModalCancel = () => {
|
|
|
+ this.props.dispatch({ type: 'orderDetail/hideProductModal' });
|
|
|
+ }
|
|
|
+
|
|
|
+ render() {
|
|
|
+ const { orderItem, terminal, mproduct, form } = this.props;
|
|
|
+ const { terminalModalShow, productModalShow, currentItem } = orderItem;
|
|
|
+ const { userCode, userName, campusName, merchantName, merchantId, goods } = currentItem;
|
|
|
+
|
|
|
+ const formItemLayout = {
|
|
|
+ labelCol: {
|
|
|
+ xs: { span: 24 },
|
|
|
+ sm: { span: 2 },
|
|
|
+ },
|
|
|
+ wrapperCol: {
|
|
|
+ xs: { span: 24 },
|
|
|
+ sm: { span: 12 },
|
|
|
+ md: { span: 22 },
|
|
|
+ },
|
|
|
+ };
|
|
|
+
|
|
|
+ const columns = [{
|
|
|
+ title: '产品图片',
|
|
|
+ dataIndex: 'coverUrl',
|
|
|
+ key: 0,
|
|
|
+ },{
|
|
|
+ title: '产品编号',
|
|
|
+ dataIndex: 'code',
|
|
|
+ key: 1,
|
|
|
+ },{
|
|
|
+ title: '产品名称',
|
|
|
+ dataIndex: 'name',
|
|
|
+ key: 2,
|
|
|
+ },{
|
|
|
+ title: '产品类型',
|
|
|
+ dataIndex: 'type',
|
|
|
+ key: 3,
|
|
|
+ },{
|
|
|
+ title: '产品价格',
|
|
|
+ dataIndex: 'goods',
|
|
|
+ key: 4,
|
|
|
+ },{
|
|
|
+ title: '优惠价格',
|
|
|
+ dataIndex: 'adjustPrice',
|
|
|
+ key: 5,
|
|
|
+ },{
|
|
|
+ title: '实际售价',
|
|
|
+ dataIndex: 'finalPrice',
|
|
|
+ key: 6,
|
|
|
+ },{
|
|
|
+ title: '数量',
|
|
|
+ dataIndex: 'quantity',
|
|
|
+ key: 7,
|
|
|
+ },{
|
|
|
+ title: '单位',
|
|
|
+ dataIndex: 'chargeUnit',
|
|
|
+ key: 8,
|
|
|
+ }];
|
|
|
+
|
|
|
+ return (
|
|
|
+ <PageHeaderLayout>
|
|
|
+ <Card>
|
|
|
+ <Form>
|
|
|
+ <Form.Item label="选择终端" {...formItemLayout}>
|
|
|
+ <Button onClick={this.handleTerminalSelectBtnClick} type="primary" size="small" icon="plus-circle-o">选择</Button>
|
|
|
+ {userCode ?
|
|
|
+ <List
|
|
|
+ size="small"
|
|
|
+ bordered
|
|
|
+ style={{ width: '50%' }}
|
|
|
+ dataSource={[`终端编号: ${userCode}`, `终端名称: ${userName}`, `所属校区: ${campusName}`, `所属渠道: ${merchantName}`]}
|
|
|
+ renderItem={item => <List.Item>{item}</List.Item>}
|
|
|
+ />
|
|
|
+ : null}
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item label="收货地址" {...formItemLayout}>
|
|
|
+ <Input.TextArea style={{ width: "50%" }} placeholder="请填写或使用默认地址"/>
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item label="添加备注" {...formItemLayout}>
|
|
|
+ <Input.TextArea style={{ width: "50%" }} placeholder="请输入(选填)" />
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item label="添加商品" {...formItemLayout}>
|
|
|
+ <Button onClick={this.handleProductSelectBtnClick} disabled={merchantId ? false : true} type="primary" size="small" icon="plus-circle-o">添加</Button>
|
|
|
+ <Table
|
|
|
+ rowKey={record => record.id}
|
|
|
+ pagination={false}
|
|
|
+ columns={columns}
|
|
|
+ dataSource={goods}
|
|
|
+ />
|
|
|
+ </Form.Item>
|
|
|
+ </Form>
|
|
|
+ {/*终端选择弹框*/}
|
|
|
+ <TerminalSelectModal
|
|
|
+ rowKeyName="id"
|
|
|
+ modalVisible={terminalModalShow}
|
|
|
+ style={{ top: 20 }}
|
|
|
+ width={660}
|
|
|
+ onOk={this.handleTerminalModalOk}
|
|
|
+ onCancel={this.handleTerminalModalCancel}
|
|
|
+ onSearch={this.handleTerminalModalSearch}
|
|
|
+ fsTableDataSource={terminal.list || []}
|
|
|
+ fsTableLoading={terminal.listLoading}
|
|
|
+ fsTablePagination={terminal.pagination}
|
|
|
+ fsTableOnChange={this.handleTerminalModalTableChange}
|
|
|
+ />
|
|
|
+ <MerchantProductSelectModal
|
|
|
+ rowKeyName="id"
|
|
|
+ modalVisible={productModalShow}
|
|
|
+ selTableData={goods || []}
|
|
|
+ style={{ top: 20 }}
|
|
|
+ width={660}
|
|
|
+ fsTableDataSource={mproduct.list}
|
|
|
+ fsTableLoading={mproduct.listLoading}
|
|
|
+ fsTablePagination={mproduct.pagination}
|
|
|
+ onOk={this.handleProductModalOk}
|
|
|
+ onCancel={this.handleProductModalCancel}
|
|
|
+ onSearch={this.handleProductModalSearch}
|
|
|
+ fsTableOnChange={this.handleProductModalTableChange}
|
|
|
+ />
|
|
|
+ {/*
|
|
|
+ <GoodsSelectModal
|
|
|
+ style={{ top: 20 }}
|
|
|
+ width={800}
|
|
|
+ modalVisible={productModalShow}
|
|
|
+ onOk={this.handleProductModalOk}
|
|
|
+ onCancel={this.handleProductModalCancel}
|
|
|
+ pagination={mproduct.pagination}
|
|
|
+ dataSource={mproduct.list}
|
|
|
+ />
|
|
|
+ */}
|
|
|
+ </Card>
|
|
|
+ <FooterToolbar>
|
|
|
+ <Button>取消</Button>
|
|
|
+ <Button type="primary">完成</Button>
|
|
|
+ </FooterToolbar>
|
|
|
+ </PageHeaderLayout>
|
|
|
+ );
|
|
|
+ }
|
|
|
+}
|