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