quisk.ts 863 B

1234567891011121314151617181920212223242526272829303132333435
  1. import { mount } from "@/utils";
  2. import Materials from "./index.vue";
  3. import { Material } from "@/api/material";
  4. import { reactive } from "vue";
  5. export const selectMaterials = async (props: {
  6. uploadFormat?: string[],
  7. format?: string[];
  8. isSystem?: number,
  9. maxSize?: number;
  10. count?: number
  11. readonly?: boolean;
  12. groupIds?: number[]
  13. useType?: string
  14. } = {}) => {
  15. return new Promise<Material[] | null>((resolve) => {
  16. const mprops = reactive({
  17. ...props,
  18. count: 3,
  19. visible: true,
  20. onSelectMaterials: (val: Material[]) => {
  21. resolve(val);
  22. mprops.visible = false
  23. },
  24. "onUpdate:visible": () => {
  25. mprops.visible = false
  26. resolve(null);
  27. },
  28. afterClose() {
  29. umMount();
  30. }
  31. })
  32. const umMount = mount(document.querySelector("#app")!, Materials, mprops);
  33. });
  34. };