list.js.vm 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #set($upperEntityPath=$table.entityPath.toUpperCase())
  2. import React, { PureComponent } from 'react';
  3. import { connect } from 'dva';
  4. import { Button, Col, Form, Input, Row } from 'antd';
  5. import Panel from '../../../components/Panel';
  6. import { $!{upperEntityPath}_LIST } from '../../../actions/$!{table.entityPath}';
  7. import Grid from '../../../components/Sword/Grid';
  8. const FormItem = Form.Item;
  9. @connect(({ $!{table.entityPath}, loading }) => ({
  10. $!{table.entityPath},
  11. loading: loading.models.$!{table.entityPath},
  12. }))
  13. @Form.create()
  14. class $!{entity} extends PureComponent {
  15. // ============ 查询 ===============
  16. handleSearch = params => {
  17. const { dispatch } = this.props;
  18. dispatch($!{upperEntityPath}_LIST(params));
  19. };
  20. // ============ 查询表单 ===============
  21. renderSearchForm = onReset => {
  22. const { form } = this.props;
  23. const { getFieldDecorator } = form;
  24. return (
  25. <Row gutter={{ md: 8, lg: 24, xl: 48 }}>
  26. <Col md={6} sm={24}>
  27. <FormItem label="查询名称">
  28. {getFieldDecorator('name')(<Input placeholder="查询名称" />)}
  29. </FormItem>
  30. </Col>
  31. <Col>
  32. <div style={{ float: 'right' }}>
  33. <Button type="primary" htmlType="submit">
  34. 查询
  35. </Button>
  36. <Button style={{ marginLeft: 8 }} onClick={onReset}>
  37. 重置
  38. </Button>
  39. </div>
  40. </Col>
  41. </Row>
  42. );
  43. };
  44. render() {
  45. const code = '$!{table.entityPath}';
  46. const {
  47. form,
  48. loading,
  49. $!{table.entityPath}: { data },
  50. } = this.props;
  51. const columns = [
  52. #foreach($field in $!{table.fields})
  53. #if($!{field.name}!=$!{cfg.tenantColumn})
  54. {
  55. title: '$!{field.comment}',
  56. dataIndex: '$!{field.propertyName}',
  57. },
  58. #end
  59. #end
  60. ];
  61. return (
  62. <Panel>
  63. <Grid
  64. code={code}
  65. form={form}
  66. onSearch={this.handleSearch}
  67. renderSearchForm={this.renderSearchForm}
  68. loading={loading}
  69. data={data}
  70. columns={columns}
  71. />
  72. </Panel>
  73. );
  74. }
  75. }
  76. export default $!{entity};