import React from "react"; import {Button, Card, Form as AntdForm, FormInstance, message, Tabs, Tooltip} from "antd"; import {DtmplBaseProps, DtmplConfig, DtmplData} from "../../tmpl/interface"; import { ReloadOutlined, ScheduleOutlined, EditOutlined, BankOutlined, } from "@ant-design/icons"; import HCDataSource from "../../tmpl/hc-data-source"; import "../dtmpl.css"; import SnapshotTimeline from "./snapshot-timeline"; import DtmplView from "./dtmpl-view"; import Units from "../../units"; import ToolTipBar from "../tooltipbar"; import {LocaleContext} from "../../locale/LocaleProvider"; import Action from "../../controls/action"; import HcserviceV3 from "../../tmpl/hcservice-v3"; import LtmplTable from "../../module/ltmpl-table"; import ActionUtils from "../../controls/action/utils"; export interface ActDtmplViewProps extends DtmplBaseProps { versionId?: number; goBackToLtmpl?: () => void, title?: any; showHeader?: boolean; } export interface ActDtmplViewStat { loading?: boolean; dtmplConfig?: DtmplConfig; premisesTitle?: string; snapshotOpen?: boolean; layout?: object; refreshCode?: string; actionDtmplData?:DtmplData; } class TabActDtmplView extends React.PureComponent< ActDtmplViewProps, ActDtmplViewStat > { static defaultProps = { showRightNav: true, rightBarPositionRight: 15, showHeader: true, }; formRef = React.createRef(); static contextType = LocaleContext; context: React.ContextType; state = { loading: true, dtmplConfig: undefined, snapshotOpen: false, premisesTitle: "默认字段", layout: { labelCol: {span: 8}, wrapperCol: {span: 16}, }, refreshCode: undefined, actionDtmplData:undefined, }; async componentDidMount() { const {sourceId,code, serverKey} = this.props; let dtmplConfig = await HCDataSource.requestViewDtmplConfig( serverKey, sourceId ); await this.loadActionDtmplData(dtmplConfig); this.setState({ dtmplConfig, }); } loadActionDtmplData = async (dtmplConfig:DtmplConfig) => { let actionDtmplData=undefined; const {sourceId,code, serverKey} = this.props; if(dtmplConfig?.viewActions && dtmplConfig?.viewActions.length>0){ actionDtmplData = await HcserviceV3.requestViewDtmplData( serverKey, sourceId, code,null ); } this.setState({ actionDtmplData, }); }; doRefresh = async () => { const {dtmplConfig} = this.state; await this.loadActionDtmplData(dtmplConfig); this.setState({ refreshCode: Units.getRandomNum(6), }); }; goEdit = () => { const {goDtmpl, code} = this.props; goDtmpl(code); }; showSnapshot = () => { this.setState({ snapshotOpen: true, }); }; onSnapshotClose = () => { this.setState({ snapshotOpen: false, }); }; toSnapshot = () => { }; onSubmit = async (values: any) => { this.setState({ loading: true, }); const { sourceId, code, serverKey } = this.props; if (code) { //有code是修改,没有是新增实体模板 values["唯一编码"] = code; } let res = await HcserviceV3.postDtmplData( serverKey, sourceId, values, message ); this.setState({ loading: false, }); if (res.status === "success") { if(this.props.goBackToLtmpl){ this.props.goBackToLtmpl(); }else{ this.doRefresh(); } } }; doSubmit = (actionId?: number, codes?: string[], params?: object) => { const { mainCode } = this.props; //if (actionId) { this.formRef.current.setFieldsValue({ actionId: actionId }); // } if (mainCode) { this.formRef.current.setFieldsValue({ mainCode: mainCode }); } if (params) { this.formRef.current.setFieldsValue(params); } this.formRef.current.submit(); }; render() { const { showRightNav, rightBarPositionRight, code, sourceId, goDtmpl, serverKey, codeSource, title, showHeader } = this.props; const { dtmplConfig, snapshotOpen, refreshCode,actionDtmplData, } = this.state; const {translate} = this.context; const buttons = dtmplConfig ? dtmplConfig.buttons : undefined; //const premises = dtmplConfig ? dtmplConfig.premises : undefined; let showRightNav_ = showRightNav; if (dtmplConfig && dtmplConfig.groups.length < 4) { showRightNav_ = false; } let items=[]; items.push( { label: , key: 'main', children: , }) if(code && dtmplConfig?.viewRactions){ dtmplConfig.viewRactions.forEach(r=>{ if(ActionUtils.isShow( r?.preposes, [actionDtmplData], undefined )){ items.push( { label: r.title, key: r.id, children: , }); } }) } return (
{translate("${" + (title ? title : "详情") + "}")} {dtmplConfig ? : null}, right:
{buttons && buttons.includes("dtmplEdit") && goDtmpl && !dtmplConfig.editAction ? ( ) : ( "" )} {dtmplConfig?.viewActions?.map((ac) => { return () })} {buttons && buttons.includes("history") ? ( ) : ( "" )}
} } items={items} />
); } } export default TabActDtmplView;