view.jsx 911 B

123456789101112131415161718192021222324252627282930
  1. import { formInputViewProps } from '../../form-input-props'
  2. import { useFormView, useInputProps } from '@cip/components/hooks/form-input'
  3. import CipTable from '@cip/components/cip-table'
  4. import { computed } from 'vue'
  5. import { useMultiple } from './use-multiple'
  6. export default {
  7. props: formInputViewProps,
  8. setup (props) {
  9. const { securityConfig, width } = useFormView(props)
  10. const inputProps = useInputProps(props, [
  11. ['tableColumns', 'columns'],
  12. 'optionProps'
  13. ])
  14. const multiple = useMultiple(securityConfig)
  15. const viewValue = computed(() => {
  16. if (multiple.value !== false) return props.modelValue || []
  17. if (!props.modelValue) return []
  18. return [props.modelValue]
  19. })
  20. return () => <CipTable
  21. {...inputProps.value}
  22. style={{ width: width.value }}
  23. data={viewValue.value}
  24. columns={securityConfig.value.tableColumns}
  25. />
  26. }
  27. }