BladeX/blade-ops/blade-develop/target/classes/templates/sword/view.js.vm
2019-01-30 17:06:23 +08:00

75 lines
1.8 KiB
Plaintext

#set($upperEntityPath=$table.entityPath.toUpperCase())
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(`/$!{cfg.servicePackage}/$!{table.entityPath}/edit/${id}`);
};
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="/$!{cfg.servicePackage}/$!{table.entityPath}" action={action}>
<Form hideRequiredMark style={{ marginTop: 8 }}>
<Card className={styles.card} bordered={false}>
#foreach($field in $!{table.fields})
<FormItem {...formItemLayout} label="$!{field.comment}">
<span>{detail.$!{field.propertyName}}</span>
</FormItem>
#end
</Card>
</Form>
</Panel>
);
}
}
export default $!{entity}View;