/*
* @Author: guoshuai.jiang@hand-china.com
* @Date: 2021-08-07 9:32:18
* @LastEditTime: 2021-09-26 16:44:00
* @LastEditors: zhipeng.zhao@hand-china.com
* @Description:
*/
import React, { Component } from 'react';
import { Card, Icon } from 'choerodon-ui';
import { Header, Content } from "components/Page";
import { IntlField, Output, TextField, NumberField, Switch, Form, DataSet, Table, Button, Lov, Modal, Select,CheckBox } from 'choerodon-ui/pro';
import getLovViewDetailDsProps from '../store/getLovViewDetailProps';
import getLovViewLineDsProps from '../store/getLovViewLineDsProps';
import { enableRender, yesOrNoRender } from "hzero-front/lib/utils/renderer";
import notification from 'utils/notification'
export default class LovViewDetail extends Component {
constructor(props) {
super(props)
}
state = {
ifDisable: true
}
LovViewDetailDs = new DataSet(getLovViewDetailDsProps(parseInt(this.props.match.params.id)))
LovViewLineDs = new DataSet(getLovViewLineDsProps(parseInt(this.props.match.params.id)))
buttons = ['delete',
<Button onClick={() => this.handleOpenModal(this.LovViewLineDs.create({}))}>
{intl.get('hzero.common.button.create').d('新建')}
</Button>]
/**
* @description: 编辑回调
* @param {*}
* @return {*}
*/
editRender = ({ record }) => {
return <a className='active' onClick={() => this.handleOpenModal(record)}>{intl.get('hzero.common.button.edit').d('编辑')}</a>
}
/**
* @description: 返回
* @param {*}
* @return {*}
*/
back = () => {
this.props.history.push('/hzero-32945/lov-view/lov-view-list')
}
/**
* @description: 新增和编辑表格字段
* @param {*}record
* @return {*}
*/
handleOpenModal = (record) => {
const handleok = () => {
this.LovViewLineDs.current.set('lovId', this.LovViewDetailDs.records[0].get('lovId'))
this.LovViewLineDs.submit().then(
res => {
if (res) {
this.LovViewLineDs.query()
}
}
)
}
const handleCancel = (record) => {
if (!record) {
this.LovViewLineDs.remove(record);
this.LovViewLineDs.query()
}
};
Modal.open({
title: intl.get('hpfm.lov.view.message.description.detail').d('列详情'),
drawerBorder: false,
drawer: true,
destroyOnClose: true,
drawerTransitionName: 'slide-left',
closable: true,
onOk: handleok,
onCancel: handleCancel,
children: (
<Form useColon record={record} dataSet={this.LovViewLineDs} >
<TextField name="fieldName" style={{ width: 250 }} required />
<IntlField name="display" style={{ width: 250 }} required />
<NumberField step={1} name="tableFieldWidth" style={{ width: 150 }} required />
<NumberField step={1} name="orderSeq" style={{ width: 150 }} required />
<Select name='dataType' style={{ width: 250 }}></Select>
<Switch name="queryFieldFlag" />
<Switch name="tableFieldFlag" />
<CheckBox name="enabledFlag" />
<div style=
{{ height: '200px' }}></div>
</Form>
),
});
}
/**
* @description: 保存值集视图配置
* @param {*}
* @return {*}
*/
handleLovViewSave = async () => {
const res = await this.LovViewDetailDs.submit()
this.LovViewLineDs.submit();
//如果保存成功,查询刷新页面
if (res) {
this.LovViewLineDs.query()
}
}
columns = [
{
name: 'fieldName',
},
{
name: 'display',
},
{
name: 'tableFieldWidth',
},
{
name: 'orderSeq',
},
{
name: 'dataType',
},
{
name: 'queryFieldFlag',
renderer: ({ value }) => yesOrNoRender(value),
},
{
name: 'tableFieldFlag',
renderer: ({ value }) => yesOrNoRender(value),
},
{
name: 'enabledFlag',
renderer: ({ value }) => enableRender(value),
},
{
header: intl.get('hzero.common.button.edit').d('编辑'),
renderer: this.editRender,
align:'center'
}
]
render() {
return (
<>
<Header title={intl.get('hpfm.lov.view.message.title.lovSetting').d('值集视图配置')} backPath= "/hzero-32945/lov-view/lov-view-list">
<Button icon='save' size="large" onClick={this.handleLovViewSave} style={{ backgroundColor: 'rgb(30,50,85)', color: 'white' }}>{intl.get('hzero.common.button.save').d('保存')}</Button>
</Header>
<Content>
<Card title={intl.get('hzero.common.lovConfigure').d('值集配置')} >
<Form dataSet={this.LovViewDetailDs} columns={3} labelAlign='left '>
<Output name='viewCode' width={100} />
<IntlField name='viewName' style={{ width: '249px' }} />
<Output name='tenantName' />
<TextField name='valueField' style={{ width: '249px' }} />
<TextField name='displayField' style={{ width: '249px' }} />
<Lov name='lovObj' style={{ width: '249px' }} />
<TextField name='childrenFieldName' style={{ width: '249px' }} />
<IntlField name='title' style={{ width: '249px' }} />
<TextField name='pageSize' style={{ width: '249px', textAlign: 'left' }} step={1} />;
<TextField name='height' style={{ width: '249px' }} />
<Switch name="delayLoadFlag" />
<Switch name="enabledFlag" />
</Form>
</Card>
<Card title={intl.get('hzero.common.valueField').d('值字段名')} >
<Table buttons={this.buttons} columns={this.columns} dataSet={this.LovViewLineDs}>
</Table>
</Card>
</Content>
</>
)
}
}
Detail
最新推荐文章于 2024-11-10 19:36:25 发布