import * as React from 'react'; import { FA } from 'tonva-react-form'; import { Page } from 'tonva-tools'; import { VForm } from '../form'; import { VEntity } from '../CVEntity'; import { CTuidMain, TuidUI } from './cTuid'; import { TuidMain, Tuid } from '../../entities'; export type TypeVTuidEdit = typeof VTuidEdit; export class VTuidEdit extends VEntity { private vForm: VForm; private id: number; async open(param?:any):Promise { this.vForm = this.createForm(this.onSubmit, param); if (param !== undefined) { this.id = param.id; } this.openPage(this.editView); } protected get editView() { return () => {this.vForm.render('py-3')} ; } protected next = async () => { this.vForm.reset(); this.closePage(); } protected finish = () => { this.closePage(2); this.event('edit-end'); } protected resetForm() { this.vForm.reset(); } protected onSubmit = async () => { let values = this.vForm.getValues(); let ret = await this.controller.entity.save(this.id, values); let {id} = ret; if (id < 0) { let {unique} = this.controller.entity; if (unique !== undefined) { for (let u of unique) { this.vForm.setError(u, '不能重复'); } } return; } if (this.controller.isCalling) { this.returnCall(id); this.closePage(); return; } this.openPageElement(
成功提交!
); this.event('item-changed', {id: this.id, values: values}); return; } //protected view = TuidNewPage; } /* const TuidNewPage = observer(({vm}:{vm:VmTuidEdit}) => { let {label, id, vmForm} = vm; return {vmForm.render('mx-3 my-2')} ; }); */