import * as React from 'react';
import {observable} from 'mobx';
import * as classNames from 'classnames';
import * as _ from 'lodash';
import {FormView} from '../formView';
import {Field} from '../field';
import {Face, PickFace} from '../face';
import {Control} from './control';
import { observer } from 'mobx-react';
export class PickControl extends Control {
protected face: PickFace;
@observable private caption: string|JSX.Element;
private onClick = async () => {
let {pick, fromPicked} = this.face;
let item = await pick(this.face, this.formView.props, this.formView.readValues());
if (item === undefined) {
this.value = undefined;
return;
}
let {id, caption} = fromPicked(item);
this.value = id;
this.caption = caption;
}
setInitValues(values: any) {
let v = values[this.field.name];
this.value = v;
}
/*
private controlContent():string|JSX.Element {
let {content: Content} = this.face;
if (this.value === undefined) {
return '请选择';
}
if (this.caption !== undefined) {
return this.caption;
}
return