|
@@ -10,6 +10,7 @@ import {
|
|
|
Form,
|
|
|
Table,
|
|
|
Button,
|
|
|
+ Radio,
|
|
|
Input,
|
|
|
InputNumber,
|
|
|
Select,
|
|
@@ -33,6 +34,7 @@ export default class CreateOrder extends Component {
|
|
|
userInfo: {}, // 记录终端用户信息
|
|
|
products: [], // 记录选择的产品
|
|
|
tableDatas: [], // 记录选择的商品
|
|
|
+ isFromCart: false, // 记录商品从哪里选择的<购物车?产品库>
|
|
|
};
|
|
|
|
|
|
// 终端选择弹框,显示 -> 加载数据
|
|
@@ -102,39 +104,56 @@ export default class CreateOrder extends Component {
|
|
|
}
|
|
|
|
|
|
// 产品选择弹框
|
|
|
- handleProductSelectBtnClick = () => {
|
|
|
+ handleProductSelectBtnClick = (isFromCart) => {
|
|
|
const { userInfo } = this.state;
|
|
|
- const { merchantId } = userInfo;
|
|
|
+ const { merchantId, uid } = userInfo;
|
|
|
+ this.setState({ isFromCart });
|
|
|
this.props.dispatch({ type: 'orderDetail/showProductModal' });
|
|
|
- this.props.dispatch({
|
|
|
- type: 'mproduct/query',
|
|
|
- payload: {
|
|
|
- pageNo: 1,
|
|
|
- pageSize,
|
|
|
- merchantId,
|
|
|
- },
|
|
|
- });
|
|
|
+ if (isFromCart) {
|
|
|
+ this.props.dispatch({
|
|
|
+ type: 'mproduct/queryBuyMsg',
|
|
|
+ payload: {
|
|
|
+ pageSize,
|
|
|
+ userId: uid,
|
|
|
+ pageNo: 1,
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ this.props.dispatch({
|
|
|
+ type: 'mproduct/query',
|
|
|
+ payload: {
|
|
|
+ pageNo: 1,
|
|
|
+ pageSize,
|
|
|
+ merchantId,
|
|
|
+ },
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
handleProductModalSearch = (data) => {
|
|
|
- const { userInfo } = this.state;
|
|
|
- const { merchantId } = userInfo;
|
|
|
+ const { userInfo, isFromCart } = this.state;
|
|
|
+ const { merchantId, id } = userInfo;
|
|
|
const newData = { ...data };
|
|
|
if (newData.keyword) {
|
|
|
newData[newData.field] = newData.keyword;
|
|
|
}
|
|
|
delete newData.field;
|
|
|
delete newData.keyword;
|
|
|
- this.props.dispatch({
|
|
|
- type: 'mproduct/query',
|
|
|
- payload: { ...newData, merchantId, pageNo: 1, pageSize },
|
|
|
- });
|
|
|
+ if (isFromCart) {
|
|
|
+ console.log('购物车内商品暂不支持查找...');
|
|
|
+ } else {
|
|
|
+ this.props.dispatch({
|
|
|
+ type: 'mproduct/query',
|
|
|
+ payload: { ...newData, merchantId, pageNo: 1, pageSize },
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
handleProductModalTableChange = (pagination, filterArgs, filters) => {
|
|
|
- const { userInfo } = this.state;
|
|
|
+ const { userInfo, isFromCart } = this.state;
|
|
|
const { merchantId } = userInfo;
|
|
|
const newFilters = { ...filters };
|
|
|
+ if (isFromCart) {return;}
|
|
|
if (newFilters.keyword) {
|
|
|
newFilters[newFilters.field] = newFilters.keyword;
|
|
|
}
|
|
@@ -259,7 +278,7 @@ export default class CreateOrder extends Component {
|
|
|
|
|
|
handlePageSubmit = () => {
|
|
|
const { form, dispatch, orderDetail } = this.props;
|
|
|
- const { userInfo, tableDatas } = this.state;
|
|
|
+ const { userInfo, tableDatas, isFromCart } = this.state;
|
|
|
const { getFieldsValue, validateFields } = form;
|
|
|
const { filters } = orderDetail;
|
|
|
const { uid } = userInfo;
|
|
@@ -277,6 +296,7 @@ export default class CreateOrder extends Component {
|
|
|
postData.goods = detailList;
|
|
|
postData.adjustPrice = 0;
|
|
|
postData.orderStatus = Codes.CODE_UNPAID;
|
|
|
+ postData.isFromCart = isFromCart;
|
|
|
dispatch({
|
|
|
type: 'orderDetail/create',
|
|
|
payload: postData,
|
|
@@ -299,7 +319,10 @@ export default class CreateOrder extends Component {
|
|
|
let rowSort = 1;
|
|
|
const formatedData = [];
|
|
|
const rowDataMaker = (item) => {
|
|
|
- const first = item.goods[0];
|
|
|
+ let first = item.goods[0]; //默认选中第一个
|
|
|
+ if (item.goods.filter(a => a.isInCart)[0]) {
|
|
|
+ first = item.goods.filter(a => a.isInCart)[0];
|
|
|
+ }
|
|
|
return {
|
|
|
name: item.name,
|
|
|
code: item.code,
|
|
@@ -310,6 +333,7 @@ export default class CreateOrder extends Component {
|
|
|
price3: first.terminalPrice,
|
|
|
rowSum: first.merchantPrice,
|
|
|
chargeUnit: first.chargeUnit,
|
|
|
+ isFromCart: this.state.isFromCart,
|
|
|
};
|
|
|
};
|
|
|
data.map((item) => {
|
|
@@ -543,22 +567,23 @@ export default class CreateOrder extends Component {
|
|
|
<Form>
|
|
|
<Form.Item label="选择终端" {...formItemLayout}>
|
|
|
<Button onClick={this.handleTerminalSelectBtnClick} type="primary" size="small" icon="plus-circle-o">选择</Button>
|
|
|
- {userInfo.userCode ?
|
|
|
+ {
|
|
|
+ userInfo.userCode ?
|
|
|
(
|
|
|
<List
|
|
|
- size="small"
|
|
|
- bordered
|
|
|
- style={{ width: '50%' }}
|
|
|
- dataSource={[
|
|
|
- `终端编号: ${userInfo.userCode}`,
|
|
|
- `终端名称: ${userInfo.userName}`,
|
|
|
- `所属校区: ${userInfo.campusName}`,
|
|
|
- `所属渠道: ${userInfo.merchantName}`,
|
|
|
- ]}
|
|
|
- renderItem={item => <List.Item>{item}</List.Item>}
|
|
|
-/>
|
|
|
-)
|
|
|
- : null}
|
|
|
+ size="small"
|
|
|
+ bordered
|
|
|
+ style={{ width: '50%' }}
|
|
|
+ dataSource={[
|
|
|
+ `终端编号: ${userInfo.userCode}`,
|
|
|
+ `终端名称: ${userInfo.userName}`,
|
|
|
+ `所属校区: ${userInfo.campusName}`,
|
|
|
+ `所属渠道: ${userInfo.merchantName}`,
|
|
|
+ ]}
|
|
|
+ renderItem={item => <List.Item>{item}</List.Item>}
|
|
|
+ />
|
|
|
+ ) : null
|
|
|
+ }
|
|
|
</Form.Item>
|
|
|
<Form.Item label="收货人" {...formItemLayout}>
|
|
|
{getFieldDecorator('name', {
|
|
@@ -591,25 +616,32 @@ export default class CreateOrder extends Component {
|
|
|
<Input.TextArea style={{ width: '50%' }} placeholder="请输入(选填)" />
|
|
|
)}
|
|
|
</Form.Item>
|
|
|
- <Form.Item label="添加商品" {...formItemLayout}>
|
|
|
- {userInfo.merchantId ?
|
|
|
- <Button onClick={this.handleProductSelectBtnClick} type="primary" size="small" icon="plus-circle-o">添加</Button>
|
|
|
- :
|
|
|
- (
|
|
|
- <Tooltip title="先选择终端">
|
|
|
- <Button onClick={this.handleProductSelectBtnClick} disabled type="primary" size="small" icon="plus-circle-o">添加</Button>
|
|
|
- </Tooltip>
|
|
|
- )
|
|
|
- }
|
|
|
- <Table
|
|
|
- bordered
|
|
|
- scroll={{ x: 1250 }}
|
|
|
- pagination={false}
|
|
|
- columns={columns}
|
|
|
- dataSource={listData}
|
|
|
- footer={() => <strong>{`价格总计: ${total}元`}</strong>}
|
|
|
- />
|
|
|
- </Form.Item>
|
|
|
+ {userInfo.merchantId &&
|
|
|
+ <Form.Item label="添加商品" {...formItemLayout}>
|
|
|
+ <Button.Group size="small">
|
|
|
+ <Button
|
|
|
+ type={this.state.isFromCart ? 'default' : 'primary'}
|
|
|
+ onClick={() => this.handleProductSelectBtnClick(false)}
|
|
|
+ >
|
|
|
+ 产品库
|
|
|
+ </Button>
|
|
|
+ <Button
|
|
|
+ type={this.state.isFromCart? 'primary' : 'default'}
|
|
|
+ onClick={() => this.handleProductSelectBtnClick(true)}
|
|
|
+ >
|
|
|
+ 购物车
|
|
|
+ </Button>
|
|
|
+ </Button.Group>
|
|
|
+ <Table
|
|
|
+ bordered
|
|
|
+ scroll={{ x: 1250 }}
|
|
|
+ pagination={false}
|
|
|
+ columns={columns}
|
|
|
+ dataSource={listData}
|
|
|
+ footer={() => <strong>{`价格总计: ${total}元`}</strong>}
|
|
|
+ />
|
|
|
+ </Form.Item>
|
|
|
+ }
|
|
|
</Form>
|
|
|
{/* 终端选择弹框 */}
|
|
|
<TerminalSelectModal
|