c90a057ab1445cae5a284e6d705585bf52361b76.svn-base 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. export default {
  2. name: 'JSelectBizQueryItem',
  3. props: {
  4. queryParam: Object,
  5. queryConfig: Array,
  6. },
  7. data() {
  8. return {}
  9. },
  10. methods: {
  11. renderQueryItem() {
  12. return this.queryConfig.map(queryItem => {
  13. const {key, label, placeholder, dictCode, props, customRender} = queryItem
  14. const options = {
  15. props: {},
  16. on: {
  17. pressEnter: () => this.$emit('pressEnter'),
  18. }
  19. }
  20. if (props != null) {
  21. Object.assign(options.props, props)
  22. }
  23. if (placeholder === undefined) {
  24. if (dictCode) {
  25. options.props['placeholder'] = `请选择${label}`
  26. } else {
  27. options.props['placeholder'] = `请输入${label}`
  28. }
  29. } else {
  30. options.props['placeholder'] = placeholder
  31. }
  32. let input
  33. if (typeof customRender === 'function') {
  34. input = customRender.call(this, {key, options, queryParam: this.queryParam})
  35. } else if (dictCode) {
  36. input = <j-dict-select-tag {...options} vModel={this.queryParam[key]} dictCode={dictCode} style="width:180px;"/>
  37. } else {
  38. input = <a-input {...options} vModel={this.queryParam[key]}/>
  39. }
  40. return <a-form-item key={key} label={label}>{input}</a-form-item>
  41. })
  42. },
  43. },
  44. render() {
  45. return <span>{this.renderQueryItem()}</span>
  46. },
  47. }