view.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { computed, h, defineAsyncComponent } from 'vue'
  2. import { formInputViewProps } from '../../form-input-props'
  3. import { setOptionWritable } from './util'
  4. export default {
  5. components: {
  6. CipTable: () => import('@cip/components/cip-table')
  7. },
  8. props: formInputViewProps,
  9. emits: ['statusChange', 'update:modelValue'],
  10. setup (props, { emit }) {
  11. const options = computed(() => {
  12. const o = props.config.options || []
  13. return setOptionWritable(o, false)
  14. })
  15. return () => {
  16. // hideOnEmpty为true时判断 值是否存在
  17. if (props.config.hideOnEmpty && (!props.modelValue || props.modelValue?.length === 0)) {
  18. emit('statusChange', false)
  19. return null
  20. }
  21. emit('statusChange', true)
  22. return h(defineAsyncComponent(() => import('@cip/components/cip-table')), {
  23. data: props.modelValue,
  24. columns: options.value,
  25. rowKey: props.config.rowKey,
  26. treeProps: props.config.treeProps || {},
  27. offset: 0,
  28. hideIndex: props.config.hideIndex,
  29. dependOnValues: props.dependOnValues,
  30. border: true,
  31. stripe: true,
  32. showSummary: props.config.showSummary,
  33. tableHeaderLabel: props.config.tableHeaderLabel,
  34. size: 'small'
  35. })
  36. }
  37. }
  38. }