Blame view

src/FormItem/FormItem.js 1.25 KB
3a3ecabe   Imshann   init
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
  /**
   * 表单域
   *
   * @Author: Shann
   * @LastEditors: Shann
   * @Date: 2021-07-26 08:53:33
   * @LastEditTime: 2021-08-05 14:03:05
   * @FilePath: \angular-js-for-bootstrap\src\Essa\FormItem\FormItem.js
   * @Copyright: Copyright 2021-2021, all rights reserved. Essa.cn
   */
  import template from "./FormItem.html";
  
  class FormItem {
      props = {
          name: String,
          label: String,
          labelCol: Object,
          wrapperCol: Object,
          required: Boolean,
      };
      state = {
          labelCol: null,
          wrapperCol: null,
      };
  
      template = template;
  
81f8a467   Imshann   调整组件前缀
28
29
      constructor(antdForm) {
          this.antdForm = antdForm.getContext();
3a3ecabe   Imshann   init
30
31
32
33
  
          if (this.props.labelCol && this.props.labelCol.span) {
              this.state.labelCol = this.props.labelCol.span; 
          } else if (
81f8a467   Imshann   调整组件前缀
34
35
              this.antdForm.labelCol &&
              this.antdForm.labelCol.span
3a3ecabe   Imshann   init
36
          ) {
81f8a467   Imshann   调整组件前缀
37
              this.state.labelCol = this.antdForm.labelCol.span;
3a3ecabe   Imshann   init
38
39
40
41
42
          }
  
          if (this.props.wrapperCol && this.props.wrapperCol.span) {
              this.state.wrapperCol = this.props.wrapperCol.span;
          } else if (
81f8a467   Imshann   调整组件前缀
43
44
              this.antdForm.wrapperCol &&
              this.antdForm.wrapperCol.span
3a3ecabe   Imshann   init
45
          ) {
81f8a467   Imshann   调整组件前缀
46
              this.state.wrapperCol = this.antdForm.wrapperCol.span;
3a3ecabe   Imshann   init
47
48
49
          }
      }
  }