Lov弹出选择输入框

表单控件。

何时使用

代码演示

Lov 弹出选择输入框 - 图1

数据源

绑定数据源。

  1. import { DataSet, Lov, Row, Col } from 'choerodon-ui/pro';
  2. function handleDataSetChange({ record, name, value, oldValue }) {
  3. console.log(
  4. '[dataset]',
  5. value,
  6. '[oldValue]',
  7. oldValue,
  8. `[record.get('${name}')]`,
  9. record.get(name),
  10. );
  11. }
  12. class App extends React.Component {
  13. ds = new DataSet({
  14. autoCreate: true,
  15. fields: [
  16. {
  17. name: 'code',
  18. textField: 'code',
  19. type: 'object',
  20. lovCode: 'LOV_CODE',
  21. lovPara: { code: '111' },
  22. required: true,
  23. },
  24. {
  25. name: 'code_string',
  26. type: 'string',
  27. lovCode: 'LOV_CODE',
  28. required: true,
  29. defaultValue: 'SYS.TIME_ZONE',
  30. },
  31. { name: 'code_code', type: 'string', bind: 'code.code' },
  32. { name: 'code_description', type: 'string', bind: 'code.description' },
  33. ],
  34. events: {
  35. update: handleDataSetChange,
  36. },
  37. });
  38. render() {
  39. return (
  40. <Row gutter={10}>
  41. <Col span={12}>
  42. <Lov dataSet={this.ds} name="code" noCache />
  43. </Col>
  44. <Col span={12}>
  45. <Lov dataSet={this.ds} name="code_string" />
  46. </Col>
  47. </Row>
  48. );
  49. }
  50. }
  51. ReactDOM.render(<App />, mountNode);

Lov 弹出选择输入框 - 图2

LOV级联

LOV 级联。

  1. import { DataSet, Lov, Select, Row, Col } from 'choerodon-ui/pro';
  2. function handleDataSetChange({ record, value, oldValue }) {
  3. console.log(
  4. '[dataset newValue]',
  5. value,
  6. '[oldValue]',
  7. oldValue,
  8. '[record.toJSONData()]',
  9. record.toJSONData(),
  10. );
  11. }
  12. class App extends React.Component {
  13. ds = new DataSet({
  14. fields: [
  15. {
  16. name: 'mySex',
  17. type: 'string',
  18. label: '性别',
  19. lookupCode: 'HR.EMPLOYEE_GENDER',
  20. },
  21. {
  22. name: 'code',
  23. type: 'object',
  24. label: 'LOV',
  25. lovCode: 'LOV_CODE',
  26. cascadeMap: { sex: 'mySex' },
  27. },
  28. ],
  29. events: {
  30. update: handleDataSetChange,
  31. },
  32. });
  33. render() {
  34. return (
  35. <Row gutter={10}>
  36. <Col span={12}>
  37. <Select dataSet={this.ds} name="mySex" />
  38. </Col>
  39. <Col span={12}>
  40. <Lov dataSet={this.ds} name="code" />
  41. </Col>
  42. </Row>
  43. );
  44. }
  45. }
  46. ReactDOM.render(<App />, mountNode);

Lov 弹出选择输入框 - 图3

多值

通过属性multiple设置为多值。

  1. import { DataSet, Lov } from 'choerodon-ui/pro';
  2. function handleDataSetChange({ record, name, value, oldValue }) {
  3. console.log('[dataset multiple]', value, '[oldValue]', oldValue, `[record.get('${name}')]`, record.get(name));
  4. }
  5. class App extends React.Component {
  6. ds = new DataSet({
  7. autoCreate: true,
  8. fields: [
  9. { name: 'code', type: 'object', lovCode: 'LOV_CODE', multiple: true, required: true, defaultValue: [{}] },
  10. ],
  11. events: {
  12. update: handleDataSetChange,
  13. },
  14. });
  15. render() {
  16. return <Lov dataSet={this.ds} name="code" placeholder="复选LOV" />;
  17. }
  18. }
  19. ReactDOM.render(
  20. <App />,
  21. mountNode
  22. );

Lov 弹出选择输入框 - 图4

按钮

按钮。

  1. import { DataSet, Lov, Output, Row, Col } from 'choerodon-ui/pro';
  2. function handleDataSetChange({ record, name, value, oldValue }) {
  3. console.log(
  4. '[dataset]',
  5. value,
  6. '[oldValue]',
  7. oldValue,
  8. `[record.get('${name}')]`,
  9. record.get(name),
  10. );
  11. }
  12. class App extends React.Component {
  13. ds = new DataSet({
  14. autoCreate: true,
  15. fields: [
  16. {
  17. name: 'code',
  18. type: 'object',
  19. lovCode: 'LOV_CODE',
  20. lovPara: { code: '111' },
  21. required: true,
  22. },
  23. {
  24. name: 'code_string',
  25. type: 'string',
  26. lovCode: 'LOV_CODE',
  27. required: true,
  28. defaultValue: 'SYS.TIME_ZONE',
  29. },
  30. { name: 'code_code', type: 'string', bind: 'code.code' },
  31. { name: 'code_description', type: 'string', bind: 'code.description' },
  32. ],
  33. events: {
  34. update: handleDataSetChange,
  35. },
  36. });
  37. render() {
  38. const { ds } = this;
  39. return (
  40. <Row gutter={10}>
  41. <Col span={6}>
  42. <Lov dataSet={ds} name="code" mode="button" clearButton={false} icon="check">
  43. 请选择
  44. </Lov>
  45. </Col>
  46. <Col span={6}>
  47. <Output dataSet={ds} name="code_code" />
  48. </Col>
  49. <Col span={6}>
  50. <Output dataSet={ds} name="code_description" />
  51. </Col>
  52. <Col span={6}>
  53. <Lov dataSet={ds} name="code_string" mode="button" placeholder="请选择" />
  54. </Col>
  55. </Row>
  56. );
  57. }
  58. }
  59. ReactDOM.render(<App />, mountNode);

API

Lov

弹出选择输入框

参数说明类型默认值
modalProps弹窗属性,详见ModalPropsobject
noCache弹窗时自动重新查询string| booleanfalse
mode显示模式,可选值: default buttonstringdefault

更多属性请参考 TextField, Button