Detail

/*
 * @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>
            </>
        )
    }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值