Blame view

ant-design-vue-jeecg/src/components/jeecgbiz/JSelectBizComponent/JSelectBizQueryItem.js 1.39 KB
肖超群 authored
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
28
29
30
31
32
33
34
35
36
export default {
  name: 'JSelectBizQueryItem',
  props: {
    queryParam: Object,
    queryConfig: Array,
  },
  data() {
    return {}
  },
  methods: {
    renderQueryItem() {
      return this.queryConfig.map(queryItem => {
        const {key, label, placeholder, dictCode, props, customRender} = queryItem
        const options = {
          props: {},
          on: {
            pressEnter: () => this.$emit('pressEnter'),
          }
        }
        if (props != null) {
          Object.assign(options.props, props)
        }
        if (placeholder === undefined) {
          if (dictCode) {
            options.props['placeholder'] = `请选择${label}`
          } else {
            options.props['placeholder'] = `请输入${label}`
          }
        } else {
          options.props['placeholder'] = placeholder
        }

        let input
        if (typeof customRender === 'function') {
          input = customRender.call(this, {key, options, queryParam: this.queryParam})
        } else if (dictCode) {
肖超群 authored
37
38
          input =
            <j-dict-select-tag {...options} vModel={this.queryParam[key]} dictCode={dictCode} style="width:180px;"/>
肖超群 authored
39
40
41
42
43
44
45
46
47
48
49
        } else {
          input = <a-input {...options} vModel={this.queryParam[key]}/>
        }
        return <a-form-item key={key} label={label}>{input}</a-form-item>
      })
    },
  },
  render() {
    return <span>{this.renderQueryItem()}</span>
  },
}