index.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. import React, { PureComponent } from 'react';
  2. import { connect } from 'dva';
  3. import { routerRedux } from 'dva/router';
  4. import { Card, Table, Form, Spin, Input, Button, Icon } from 'antd';
  5. import PageHeaderLayout from '../../../layouts/PageHeaderLayout';
  6. import ProductSelectModal from './product';
  7. @Form.create()
  8. @connect(state => ({
  9. comboDetail: state.comboDetail,
  10. product: state.product,
  11. }))
  12. export default class PackageProfile extends PureComponent {
  13. handleEditProuctClick = () => {
  14. this.props.dispatch({ type: 'comboDetail/showModal' });
  15. this.props.dispatch({ type: 'product/query' });
  16. }
  17. handleProductModalOk = () => {
  18. }
  19. handleProductModalCancel = () => {
  20. this.props.dispatch({ type: 'comboDetail/hideModal' });
  21. }
  22. handleProductModalSearch = () => {
  23. }
  24. handleProductModalTableChange = () => {
  25. }
  26. render() {
  27. const { form, comboDetail, product } = this.props;
  28. const { modalShow, currentItem, itemLoading } = comboDetail;
  29. const { list, listLoading, pagination } = product;
  30. const { products } = currentItem;
  31. const { getFieldDecorator } = form;
  32. const formItemLayout = {
  33. labelCol: { span: 7 },
  34. wrapperCol: { span: 12 },
  35. };
  36. const submitFormLayout = {
  37. wrapperCol: {
  38. xs: { span: 24, offset: 0 },
  39. sm: { span: 10, offset: 7 },
  40. },
  41. };
  42. const tableFormLayout = {
  43. wrapperCol: { offset: 7, span: 12 },
  44. };
  45. const columns = [{
  46. title: '产品封面',
  47. dataIndex: 'coverUrl',
  48. key: 'coverUrl',
  49. render: (text, record) => {},
  50. },{
  51. title: '产品编号',
  52. dataIndex: 'code',
  53. key: 'code',
  54. },{
  55. title: '产品名称',
  56. dataIndex: 'name',
  57. key: 'name',
  58. },{
  59. title: '供应商',
  60. dataIndex: 'cpName',
  61. key: 'cpName',
  62. },{
  63. title: '供应商价格',
  64. dataIndex: 'cpPrice',
  65. key: 'cpPrice',
  66. }];
  67. return (
  68. <PageHeaderLayout>
  69. <Spin spinning={itemLoading}>
  70. <Card>
  71. <Form layout="horizontal">
  72. <Form.Item label="产品包编号" { ...formItemLayout }>
  73. {getFieldDecorator('code', {
  74. rules: [{ required: true, type: 'string', message: '编号为必填项!' }],
  75. })(<Input placeholder="请输入" />)}
  76. </Form.Item>
  77. <Form.Item label="产品包名称" { ...formItemLayout }>
  78. {getFieldDecorator('name', {
  79. rules: [{ required: true, type: 'string', message: '名称为必填项!' }],
  80. })(<Input placeholder="请输入" />)}
  81. </Form.Item>
  82. <Form.Item label="选择产品" { ...formItemLayout }>
  83. <Button onClick={this.handleEditProuctClick} type="primary" size="small" icon="select">选择</Button>
  84. </Form.Item>
  85. <Form.Item { ...tableFormLayout }>
  86. <Table
  87. simple
  88. bordered
  89. columns={columns}
  90. dataSource={[]}
  91. pagination={false}
  92. rowKey={record => record.id}
  93. locale={{
  94. emptyText: <span style={{ color: "#C6D0D6" }}>&nbsp;&nbsp;<Icon type="frown-o"/>
  95. 该产品包内暂无相关产品,请选择!</span>
  96. }}
  97. />
  98. </Form.Item>
  99. <Form.Item { ...submitFormLayout } style={{ marginTop: 32 }}>
  100. <Button onClick={this.handlePageCancel}>取消</Button>
  101. <Button type="primary" style={{ marginLeft: 35 }} htmlType="submit">提交</Button>
  102. </Form.Item>
  103. </Form>
  104. {/*产品选择模态框*/}
  105. <ProductSelectModal
  106. rowKeyName="id"
  107. modalVisible={modalShow}
  108. selTableData={products || []}
  109. style={{ top: 20 }}
  110. fsTableDataSource={list}
  111. fsTableLoading={listLoading}
  112. fsTablePagination={pagination}
  113. onOk={this.handleProductModalOk}
  114. onCancel={this.handleProductModalCancel}
  115. onSearch={this.handleProductModalSearch}
  116. fsTableOnChange={this.handleProductModalTableChange}
  117. />
  118. </Card>
  119. </Spin>
  120. </PageHeaderLayout>
  121. );
  122. }
  123. }