ludc
2023-03-16 86b6157299a50579f454e4fb45a09ff21d252dab
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
#set($upperEntityPath=$table.entityPath.toUpperCase())
#set($editId="$" + "{" + "id" + "}")
import React, { PureComponent } from 'react';
import router from 'umi/router';
import { Form, Card, Button } from 'antd';
import { connect } from 'dva';
import Panel from '../../../components/Panel';
import styles from '../../../layouts/Sword.less';
import { $!{upperEntityPath}_DETAIL } from '../../../actions/$!{table.entityPath}';
 
const FormItem = Form.Item;
 
@connect(({ $!{table.entityPath} }) => ({
  $!{table.entityPath},
}))
@Form.create()
class $!{entity}View extends PureComponent {
  componentWillMount() {
    const {
      dispatch,
      match: {
        params: { id },
      },
    } = this.props;
    dispatch($!{upperEntityPath}_DETAIL(id));
  }
 
  handleEdit = () => {
    const {
      match: {
        params: { id },
      },
    } = this.props;
    router.push(`/$!{servicePackage}/$!{table.entityPath}/edit/$!{editId}`);
  };
 
  render() {
    const {
      $!{table.entityPath}: { detail },
    } = this.props;
 
    const formItemLayout = {
      labelCol: {
        xs: { span: 24 },
        sm: { span: 7 },
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 12 },
        md: { span: 10 },
      },
    };
 
    const action = (
      <Button type="primary" onClick={this.handleEdit}>
        修改
      </Button>
    );
 
    return (
      <Panel title="查看" back="/$!{servicePackage}/$!{table.entityPath}" action={action}>
        <Form hideRequiredMark style={{ marginTop: 8 }}>
          <Card className={styles.card} bordered={false}>
#foreach($field in $!{table.fields})
#if($!{field.name}!=$!{tenantColumn})
            <FormItem {...formItemLayout} label="$!{field.comment}">
              <span>{detail.$!{field.propertyName}}</span>
            </FormItem>
#end
#end
          </Card>
        </Form>
      </Panel>
    );
  }
}
export default $!{entity}View;