CouponCardTemplateList.js 23.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/* eslint-disable */

import React, { PureComponent, Fragment } from 'react';
import { connect } from 'dva';
import {
  Card,
  Form,
  Input,
  Button,
  Modal,
  message,
  Table,
  Divider,
  Tree,
  Spin,
  Row,
  Col,
  Select,
  Icon,
  InputNumber,
21
  DatePicker, TreeSelect
22 23 24 25 26 27 28 29 30 31 32 33 34
} from 'antd';
import { checkTypeWithEnglishAndNumbers } from '../../../helpers/validator'
import PageHeaderWrapper from '@/components/PageHeaderWrapper';

import styles from './CouponCardTemplateList.less';
import moment from "moment";
import PaginationHelper from "../../../helpers/PaginationHelper";

const FormItem = Form.Item;
const SelectOption = Select.Option;
const { TreeNode } = Tree;
const RangePicker = DatePicker.RangePicker;
const status = ['未知', '正常', '禁用'];
35 36 37 38 39 40 41 42
const rangeType = {
  10: '所有可用',
  20: '部分商品可用',
  21: '部分商品不可用',
  30: '部分分类可用',
  31: '部分分类不可用'};
const preferentialType = ['未知', '代金卷', '折扣卷'];
const dateType = ['未知', '固定日期', '领取日期'];
43 44 45 46 47 48 49 50

// 列表
function List ({ dataSource, loading, pagination, searchParams, dispatch,
                 handleModalVisible}) {

  function handleStatus(record) {
    Modal.confirm({
      title: record.status === 1 ? '确认禁用' : '取消禁用',
51
      content: `${record.title}`,
52 53
      onOk() {
        dispatch({
54
          type: 'couponCardTemplateList/updateStatus',
55 56 57 58 59 60 61 62 63 64
          payload: {
            id: record.id,
            status: record.status === 1 ? 2 : 1,
          },
        });
      },
      onCancel() {},
    });
  }

65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
  // function handleDelete(record) {
  //   Modal.confirm({
  //     title: `确认删除?`,
  //     content: `${record.productSpuId}`,
  //     onOk() {
  //       dispatch({
  //         type: 'couponCardTemplateList/delete',
  //         payload: {
  //           id: record.id,
  //         },
  //       });
  //     },
  //     onCancel() {},
  //   });
  // }
80 81 82

  const columns = [
    {
83 84 85 86 87 88
      title: '名称',
      dataIndex: 'title',
    },
    {
      title: '类型',
      dataIndex: 'preferentialType',
89
      render(val) {
90
        return <span>{preferentialType[val]}</span>;
91 92 93
      },
    },
    {
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
      title: '优惠内容',
      render(val, record) {
        let content;
        // priceAvailable;
        if (record.priceAvailable === 0) {
          content = '无门槛,';
        } else {
          content = '满 ' + record.priceAvailable / 100 + ' 元,';
        }
        if (record.preferentialType === 1) {
          content += '减 ' + record.priceOff / 100 + ' 元';
        } else {
          content += '打' + record.percentOff / 100.0 + '折';
          if (record.discountPriceLimit) {
            content += ', 最多减 ' + record.discountPriceLimit / 100 + ' 元';
          }
        }
        return content;
      }
    },
    {
      title: '可使用商品',
      dataIndex: 'rangeType',
      render: val => <span>{rangeType[val]}</span>,
118 119
    },
    {
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
      title: '有效期',
      render(val, record) {
        let content = dateType[record.dateType] + ' ';
        // priceAvailable;
        if (record.dateType === 1) {
          content += moment(new Date(record.validStartTime)).format('YYYY-MM-DD')
            + '~' +  moment(new Date(record.validEndTime)).format('YYYY-MM-DD');
        } else if (record.dateType === 2) {
          content += record.fixedStartTerm + '-' + record.fixedEndTerm + ' 天';
        }
        return content;
      }
    },
    {
      title: '已领取/剩余',
      // 已使用 TODO 芋艿
      // 支付金额(元) TODO 芋艿
      // 客单价(元) TODO 芋艿
      render(val, record) {
139
        // debugger;
140 141
        return `${record.statFetchNum} / ` + (record.total - record.statFetchNum);
      }
142 143 144 145
    },
    {
      title: '状态',
      dataIndex: 'status',
146
      render: val => <span>{status[val]}</span>,
147
    },
148 149 150 151
    // {
    //   title: '使用说明',
    //   dataIndex: 'description',
    // },
152 153 154 155 156 157 158
    {
      title: '创建时间',
      dataIndex: 'createTime',
      render: val => <span>{moment(val).format('YYYY-MM-DD HH:mm')}</span>,
    },
    {
      title: '操作',
159
      width: 120,
160 161 162 163 164 165 166 167 168
      render: (text, record) => {
        const statusText = record.status === 1 ? '禁用' : '开启'; // TODO 芋艿,此处要改
        return (
          <Fragment>
            <a onClick={() => handleModalVisible(true, 'update', record)}>编辑</a>
            <Divider type="vertical" />
            <a className={styles.tableDelete} onClick={() => handleStatus(record)}>
              {statusText}
            </a>
169 170 171 172 173 174 175 176 177
            {/*{*/}
            {/*  record.status === 2 ?*/}
            {/*    <span>*/}
            {/*      <Divider type="vertical" />*/}
            {/*      <a className={styles.tableDelete} onClick={() => handleDelete(record)}>*/}
            {/*        删除*/}
            {/*      </a>*/}
            {/*    </span> : null*/}
            {/*}*/}
178 179 180 181 182 183 184 185
          </Fragment>
        );
      },
    },
  ];

  function onPageChange(page) { // 翻页
    dispatch({
186
      type: 'couponCardTemplateList/query',
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217
      payload: {
        pageNo: page.current,
        pageSize: page.pageSize,
        ...searchParams
      }
    })
  }

  return (
    <Table
      columns={columns}
      dataSource={dataSource}
      loading={loading}
      rowKey="id"
      pagination={pagination}
      onChange={onPageChange}
    />
  )
}

// 搜索表单
// TODO 芋艿,有没办法换成上面那种写法
const SearchForm = Form.create()(props => {
  const {
    form,
    form: { getFieldDecorator },
    dispatch
  } = props;

  function search() {
    dispatch({
218
      type: 'couponCardTemplateList/query',
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266
      payload: {
        ...PaginationHelper.defaultPayload,
        ...form.getFieldsValue()
      }
    })
  }

  // 提交搜索
  function handleSubmit(e) {
    // 阻止默认事件
    e.preventDefault();
    // 提交搜索
    search();
  }

  // 重置搜索
  function handleReset() {
    // 重置表单
    form.resetFields();
    // 执行搜索
    search();
  }

  return (
    <Form onSubmit={handleSubmit} layout="inline">
      <Row gutter={{ md: 8, lg: 24, xl: 48 }}>
        <Col md={8} sm={24}>
          <FormItem label="标题">
            {getFieldDecorator('title')(<Input placeholder="请输入" />)}
          </FormItem>
        </Col>
        <Col md={8} sm={24}>
            <span className={styles.submitButtons}>
              <Button type="primary" htmlType="submit">
                查询
              </Button>
              <Button style={{ marginLeft: 8 }} onClick={handleReset}>
                重置
              </Button>
            </span>
        </Col>
      </Row>
    </Form>
  );
});

// 添加 or 修改 Form 表单
const AddOrUpdateForm = Form.create()(props => {
267 268
  const { dispatch, modalVisible, form, handleModalVisible, modalType, formVals,
    searchProductSpuList, formSpuValues, categoryTree} = props;
269 270 271 272

  const okHandle = () => {
    form.validateFields((err, fields) => {
      if (err) return;
273
      let newFields = {
274
        ...fields,
275 276 277 278
        priceAvailable: fields.priceAvailable ? parseInt(fields.priceAvailable * 100) : undefined,
        priceOff: fields.priceOff ? parseInt(fields.priceOff * 100) : undefined,
        discountPriceLimit: fields.discountPriceLimit ? parseInt(fields.discountPriceLimit * 100) : undefined,
        validStartTime: fields.validStartTime ? fields.validStartTime.format('YYYY-MM-DD') : undefined,
279 280
        validEndTime: fields.validEndTime ? fields.validEndTime.format('YYYY-MM-DD') : undefined,
        rangeValues: fields.rangeValues && fields.rangeValues.length > 0 ?  fields.rangeValues.join(',') : undefined,
281
      };
282 283 284 285 286 287
      // 添加表单
      if (modalType === 'add') {
        dispatch({
          type: 'couponCardTemplateList/add',
          payload: {
            body: {
288
              ...newFields,
289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306
            },
            callback: () => {
              // 清空表单
              form.resetFields();
              // 提示
              message.success('添加成功');
              // 关闭弹窗
              handleModalVisible();
            },
          },
        });
        // 修改表单
      } else {
        dispatch({
          type: 'couponCardTemplateList/update',
          payload: {
            body: {
              id: formVals.id,
307
              ...newFields,
308 309 310 311 312 313 314 315 316 317
              priceAvailable: undefined,
              dateType: undefined,
              validStartTime: undefined,
              validEndTime: undefined,
              fixedStartTerm: undefined,
              fixedEndTerm: undefined,
              preferentialType: undefined,
              priceOff: undefined,
              percentOff: undefined,
              discountPriceLimit: undefined,
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344
            },
            callback: () => {
              // 清空表单
              form.resetFields();
              // 提示
              message.success('更新成功');
              // 关闭弹窗
              handleModalVisible();
            },
          },
        });
      }
    });
  };

  function onRangeTypeChange(value) {
    formVals.rangeType = parseInt(value);
  }

  function onDateTypeChange(value) {
    formVals.dateType = parseInt(value);
  }

  function onPreferentialTypeChange(value) {
    formVals.preferentialType = parseInt(value);
  }

345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380
  const searchProductSpu = (value) => {
    if (!value) {
      dispatch({
        type: 'couponCardTemplateList/setAll',
        payload: {
          searchProductSpuList: [],
        },
      });
      return;
    }
    dispatch({
      type: 'couponCardTemplateList/searchProductSpu',
      payload: {
        name: value,
      },
    });
  };

  // 处理分类筛选
  const buildSelectTree = (list) => {
    return list.map(item => {
      let children = [];
      if (item.children) {
        children = buildSelectTree(item.children);
      }
      return {
        title: item.name,
        value: item.id,
        key: item.id,
        children,
        selectable: item.pid > 0
      };
    });
  };
  let categoryTreeSelect = buildSelectTree(categoryTree);

381 382 383 384 385 386 387 388 389 390 391 392 393
  const title = modalType === 'add' ? '新建优惠劵' : '更新优惠劵';
  return (
    <Modal
      destroyOnClose
      title={title}
      visible={modalVisible}
      onOk={okHandle}
      okText='保存'
      onCancel={() => handleModalVisible()}
      width={720}
    >
      <FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="标题">
        {form.getFieldDecorator('title', {
394 395
          rules: [{ required: true, message: '请输入标题!' },
            {max: 16, min:2, message: '长度为 2-16 位'},],
396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432
          initialValue: formVals.title,
        })(<Input placeholder="请输入" />)}
      </FormItem>
      <FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="使用说明">
        {form.getFieldDecorator('description', {
          rules: [{ required: false, message: '请输入使用说明!' },
            {max: 255, message: '最大长度为 255 位'},
          ],
          initialValue: formVals.description,
        })(<Input.TextArea placeholder="请输入" />)}
      </FormItem>
      <FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="限领次数">
        {form.getFieldDecorator('quota', {
          rules: [{ required: true, message: '请选择每人限领次数!'},
          ],
          initialValue: formVals.quota,
        })(
          <Select placeholder="请选择" style={{ maxWidth: 200, width: '100%' }}>
            <SelectOption value="1">1 </SelectOption>
            <SelectOption value="2">2 </SelectOption>
            <SelectOption value="3">3 </SelectOption>
            <SelectOption value="4">4 </SelectOption>
            <SelectOption value="5">5 </SelectOption>
            <SelectOption value="10">10 </SelectOption>
          </Select>
        )}
      </FormItem>
      <FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="发放总量">
        {form.getFieldDecorator('total', {
          rules: [{ required: true, message: '请输入发放总量!' },
            {min: 1, type: 'number', message: '最小值为 1'}],
          initialValue: formVals.total,
        })(<InputNumber placeholder="请输入" />)}
      </FormItem>
      <FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="使用金额门槛">
        {form.getFieldDecorator('priceAvailable', {
          rules: [{ required: true, message: '请输入使用金额门槛!' },],
433
          initialValue: formVals.priceAvailable ? formVals.priceAvailable / 100.0 : undefined,
434
        })(<InputNumber disabled={modalType != 'add'} placeholder="请输入" />)} 
435 436 437 438 439
      </FormItem>
      <FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="可用范围">
        {form.getFieldDecorator('rangeType', {
          rules: [{ required: true, message: '请选择可用范围!'}, // TODO 芋艿,需要修改
          ],
440
          initialValue: formVals.rangeType ? formVals.rangeType + '' : undefined,
441 442 443 444 445 446 447 448 449 450
        })(
          <Select placeholder="请选择" style={{ maxWidth: 200, width: '100%' }} onChange={onRangeTypeChange} >
            <SelectOption value="10">所有可用</SelectOption>
            <SelectOption value="20">部分商品可用</SelectOption>
            <SelectOption value="21">部分商品不可用</SelectOption>
            <SelectOption value="30">部分分类可用</SelectOption>
            <SelectOption value="31">部分分类不可用</SelectOption>
          </Select>
        )}
      </FormItem>
451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489
      {/*{*/}
      {/*  formVals.rangeType == 20 || formVals.rangeType == 21*/}
      {/*  || formVals.rangeType == 30 || formVals.rangeType == 31 ?*/}
      {/*  <FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="具体范围">*/}
      {/*      {form.getFieldDecorator('rangeValues', {*/}
      {/*        rules: [{ required: true, message: '请输入具体范围!' }, // TODO 芋艿,做成搜索*/}
      {/*          {maxlength: 255, message: '最大长度为 255 位'},*/}
      {/*        ],*/}
      {/*        initialValue: formVals.rangeValues,*/}
      {/*      })(<Input.TextArea placeholder="请输入" />)}*/}
      {/*    </FormItem>*/}
      {/*  : ''*/}
      {/*}*/}
      {
        formVals.rangeType == 20 || formVals.rangeType == 21?
          <FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="选择商品">
            {form.getFieldDecorator('rangeValues', {
              rules: [{ required: true, message: '请选择商品!' },
              ],
              initialValue: formVals.rangeValues ? formVals.rangeValues.split(',') : undefined,
            })(
              <Select
                // labelInValue
                // value={formVals.productSpuId}
                mode={"multiple"}
                placeholder="请搜索商品"
                onSearch={searchProductSpu}
                showSearch={true}
                filterOption={false}
                style={{ width: '100%' }}
              >
                {searchProductSpuList.map(d => <Option key={d.id} value={d.id + ''}>{d.name}</Option>)}
                {searchProductSpuList.length === 0 && formSpuValues.length > 0 ?
                  formSpuValues.map(d => <Option key={d.id} value={d.id + ''}>{d.name}</Option>) : ''}
              </Select>
            )}
          </FormItem>
          : ''
      }
490
      {
491 492
        formVals.rangeType == 30 || formVals.rangeType == 31 ?
          <FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="选择分类">
493
            {form.getFieldDecorator('rangeValues', {
494
              rules: [{ required: true, message: '请选择分类!' },
495
              ],
496 497 498 499 500 501 502 503 504 505 506
              initialValue: formVals.rangeValues ? formVals.rangeValues.split(',') : undefined,
            })(
              <TreeSelect
                showSearch
                multiple
                style={{ width: 200 }}
                dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
                treeData={categoryTreeSelect}
                placeholder="请选择分类"
              />
            )}
507
          </FormItem>
508
          : ''
509 510 511 512 513
      }
      <FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="生效日期类型">
        {form.getFieldDecorator('dateType', {
          rules: [{ required: true, message: '请选择可用范围!'}, // TODO 芋艿,需要修改
          ],
514
          initialValue: formVals.dateType ? formVals.dateType + '' : undefined,
515
        })(
516 517
          <Select disabled={modalType != 'add'} placeholder="请选择" style={{ maxWidth: 200, width: '100%' }} onChange={onDateTypeChange}>
            <SelectOption value="1">固定日期</SelectOption>
518 519 520 521 522 523 524 525 526
            <SelectOption value="2">领取日期</SelectOption>
          </Select>
        )}
      </FormItem>
      {
        formVals.dateType == 1 ?
          <FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="固定日期">
            {form.getFieldDecorator('validStartTime', {
              rules: [{ required: true, message: '请输入固定日期!' },],
527 528
              initialValue: formVals.validStartTime ? moment(formVals.validStartTime) : undefined,
            })(<DatePicker disabled={modalType != 'add'} format="YYYY-MM-DD" />)}
529 530 531
            &nbsp;-&nbsp;
            {form.getFieldDecorator('validEndTime', {
              rules: [{ required: true, message: '请输入固定日期!' },],
532 533
              initialValue: formVals.validEndTime ? moment(formVals.validEndTime) : undefined,
            })(<DatePicker disabled={modalType != 'add'} format="YYYY-MM-DD" />)}
534 535 536 537 538
          </FormItem> : ''
      }
      {
        formVals.dateType == 2 ?
          <FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="领取日期">
539
            {form.getFieldDecorator('fixedStartTerm', {
540 541
              rules: [{ required: true, message: '请输入固定日期!' },
                {min: 1, type: 'number', message: '最小值为 1'}],
542 543
              initialValue: formVals.fixedStartTerm,
            })(<InputNumber disabled={modalType != 'add'} placeholder="请输入" />)}
544 545
            &nbsp;-&nbsp;
            {form.getFieldDecorator('fixedEndTerm', {
546 547
              rules: [{ required: true, message: '请输入固定日期!' },
                {min: 1, type: 'number', message: '最小值为 1'}],
548
              initialValue: formVals.fixedEndTerm,
549
            })(<InputNumber disabled={modalType != 'add'} placeholder="请输入" />)} 
550 551 552 553 554 555 556
          </FormItem> : ''
      }

      <FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="优惠类型">
        {form.getFieldDecorator('preferentialType', {
          rules: [{ required: true, message: '请选择优惠类型!'}, // TODO 芋艿,需要修改
          ],
557
          initialValue: formVals.preferentialType ? formVals.preferentialType + '' : undefined,
558
        })(
559
          <Select disabled={modalType != 'add'} placeholder="请选择" style={{ maxWidth: 200, width: '100%' }} onChange={onPreferentialTypeChange}>
560 561 562 563 564 565 566 567 568 569 570
            <SelectOption value="1">代金卷</SelectOption>
            <SelectOption value="2">折扣卷</SelectOption>
          </Select>
        )}
      </FormItem>
      {
        formVals.preferentialType == 1 ?
          <FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="优惠金额">
            {form.getFieldDecorator('priceOff', {
              rules: [{ required: true, message: '请输入优惠金额!' },
                {min: 0.01, type: 'number', message: '最小值为 0.01'}],
571 572
              initialValue: formVals.priceOff ? formVals.priceOff / 100.0 : undefined,
            })(<InputNumber disabled={modalType != 'add'} placeholder="请输入" />)}
573 574 575 576 577 578 579 580 581 582 583
          </FormItem> : ''
      }
      {
        formVals.preferentialType == 2 ?
          <span>
            <FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="折扣百分比">
              {form.getFieldDecorator('percentOff', {
                rules: [{ required: true, message: '请输入折扣百分比!' },
                  {min: 1, max: 99, type: 'number', message: '范围为 [1, 99]'},
                ],
                initialValue: formVals.percentOff,
584
              })(<InputNumber disabled={modalType != 'add'} placeholder="请输入" />)}%
585 586 587 588 589 590
            </FormItem>
            <FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="最多优惠">
              {form.getFieldDecorator('discountPriceLimit', {
                rules: [{ required: false, message: '请输入最多优惠!' },
                  {min: 0.01, type: 'number', message: '最小值为 0.01'},
                ],
591 592
                initialValue: formVals.discountPriceLimit ? formVals.discountPriceLimit / 100.0 : undefineds,
              })(<InputNumber disabled={modalType != 'add'} placeholder="请输入" />)}
593 594 595 596 597 598 599
            </FormItem>
          </span> : ''
      }
    </Modal>
  );
});

600
@connect(({ couponCardTemplateList, productCategoryList }) => ({
601 602
  // list: productRecommend.list,
  // pagination: productRecommend.pagination,
603
  ...couponCardTemplateList,
604
  categoryTree: productCategoryList.list,
605 606 607 608 609 610 611 612
}))

// 主界面
@Form.create()
class CouponCardTemplateLists extends PureComponent {

  componentDidMount() {
    const { dispatch } = this.props;
613
    // 获得优惠劵列表
614
    dispatch({
615
      type: 'couponCardTemplateList/query',
616 617 618 619 620 621 622 623
      payload: {
        ...PaginationHelper.defaultPayload
      },
    });
  }

  handleModalVisible = (modalVisible, modalType, record) => {
    const { dispatch } = this.props;
624
    // 弹窗,并清空一些缓存
625
    dispatch({
626
      type: 'couponCardTemplateList/setAll',
627 628 629
      payload: {
        modalVisible,
        modalType,
630 631 632
        formVals: record || {},
        searchProductSpuList: [],
        formSpuValues: [],
633 634
      },
    });
635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650
    // 如果是指定商品,则获得商品列表
    if (record && record.rangeType &&
      (record.rangeType === 20 || record.rangeType === 21)) {
      dispatch({
        type: 'couponCardTemplateList/getProductSpuList',
        payload: {
          ids: record.rangeValues,
        },
      });
    }
    // 获得商品分类,因为后续可能使用到
    // 获得商品分类
    dispatch({
      type: 'productCategoryList/tree',
      payload: {},
    });
651 652 653 654 655 656
  };

  render() {
    // let that = this;
    const { dispatch,
      list, listLoading, searchParams, pagination,
657
      modalVisible, modalType, formVals, searchProductSpuList, formSpuValues, categoryTree,
658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681
      confirmLoading,  } = this.props;

    // 列表属性
    const listProps = {
      dataSource: list,
      pagination,
      searchParams,
      dispatch,
      loading: listLoading,
      confirmLoading,
      handleModalVisible: this.handleModalVisible, // Function
    };

    // 搜索表单属性
    const searchFormProps = {
      dispatch,
    };

    // 添加 or 更新表单属性
    const addOrUpdateFormProps = {
      modalVisible,
      modalType,
      formVals,
      dispatch,
682 683 684
      searchProductSpuList,
      formSpuValues,
      categoryTree,
685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715
      handleModalVisible: this.handleModalVisible, // Function
    };

    return (
      <PageHeaderWrapper>
        <Card bordered={false}>
          <div className={styles.tableList}>
            <div className={styles.tableListForm}>
              <SearchForm {...searchFormProps} />
            </div>
            <div className={styles.tableListOperator}>
              <Button
                icon="plus"
                type="primary"
                onClick={() => this.handleModalVisible(true, 'add', {})}
              >
                新建优惠劵
              </Button>
            </div>
          </div>
          <List {...listProps} />
        </Card>

        <AddOrUpdateForm {...addOrUpdateFormProps} />

      </PageHeaderWrapper>
    );
  }
}

export default CouponCardTemplateLists;