quisk.ts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import { mount } from "@/utils";
  2. import Materials from "./index.vue";
  3. import Materials1 from "./loc-upload.vue";
  4. import { Material } from "@/api/material";
  5. import { reactive } from "vue";
  6. export const selectMaterials = async (props: {
  7. uploadFormat?: string[],
  8. format?: string[];
  9. isSystem?: number,
  10. maxSize?: number;
  11. count?: number
  12. readonly?: boolean;
  13. groupIds?: number[]
  14. useType?: string
  15. } = {}) => {
  16. return new Promise<Material[] | null>((resolve) => {
  17. const mprops = reactive({
  18. ...props,
  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. };
  35. export const selectMaterials1 = async (props: {
  36. uploadFormat?: string[],
  37. format?: string[];
  38. isSystem?: number,
  39. maxSize?: number;
  40. count?: number
  41. readonly?: boolean;
  42. groupIds?: number[]
  43. useType?: string
  44. } = {}) => {
  45. return new Promise<Material[] | null>((resolve) => {
  46. const mprops = reactive({
  47. ...props,
  48. visible: true,
  49. onSelectMaterials: (val: Material[]) => {
  50. resolve(val);
  51. mprops.visible = false
  52. },
  53. "onUpdate:visible": () => {
  54. mprops.visible = false
  55. resolve(null);
  56. },
  57. afterClose() {
  58. umMount();
  59. }
  60. })
  61. const umMount = mount(document.querySelector("#app")!, Materials1, mprops);
  62. });
  63. };