view.jsx 1.4 KB

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