component.ts 508 B

123456789101112131415161718192021222324
  1. import { parse } from "@/cool";
  2. import type { ClCascaderOption, ClListViewItem, ClTreeItem } from "../types";
  3. export function useListView(data: UTSJSONObject[]) {
  4. return data.map((e) => {
  5. return parse<ClListViewItem>({
  6. ...e,
  7. value: e
  8. })!;
  9. });
  10. }
  11. export function useCascader(data: UTSJSONObject[]) {
  12. return data.map((e) => parse<ClCascaderOption>(e)!);
  13. }
  14. export function useTree(data: UTSJSONObject[]) {
  15. return data.map((e) => {
  16. return parse<ClTreeItem>({
  17. ...e,
  18. value: e
  19. })!;
  20. });
  21. }