_createAttrsHoc.tsx 845 B

1234567891011121314151617181920212223242526272829303132333435
  1. import { Input } from "ant-design-vue";
  2. import { get } from "lodash";
  3. import { defineComponent } from "vue";
  4. import { any } from "vue-types";
  5. export function createAttrsHoc(
  6. options: { label: string; dataIndex?: string }[]
  7. ) {
  8. return defineComponent({
  9. props: {
  10. value: any(),
  11. },
  12. emits: ["update:value"],
  13. setup(props, { emit }) {
  14. return () => (
  15. <div>
  16. {options.map((d) => {
  17. const val = d.dataIndex
  18. ? get(props.value, d.dataIndex)
  19. : props.value;
  20. return (
  21. <div>
  22. <div>{d.label}</div>
  23. <Input
  24. value={val}
  25. onChange={(e) => emit("update:value", e.target.value)}
  26. />
  27. </div>
  28. );
  29. })}
  30. </div>
  31. );
  32. },
  33. });
  34. }