index.vue 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <template>
  2. <el-cascader
  3. style="width: 100%"
  4. v-model="state.path"
  5. :disabled="disabled"
  6. placeholder="勘验单位:"
  7. :options="state.options"
  8. :props="{ expandTrigger: 'hover', checkStrictly: true }"
  9. />
  10. </template>
  11. <script setup lang="ts">
  12. import { useTreeSelect, Props, TreeOption } from "@/hook/treeSelect";
  13. import { getOrganizationTree } from "./organization";
  14. import { watchEffect } from "vue";
  15. const emit = defineEmits<{
  16. (e: "update:data", data: TreeOption | null): void;
  17. (e: "update:modelValue", value: string): void;
  18. (e: "update:label", value: string): void;
  19. (e: "update:path", path: string[]): void;
  20. }>();
  21. const props = defineProps<Props>();
  22. const state = useTreeSelect(
  23. props,
  24. getOrganizationTree,
  25. (val) => emit("update:modelValue", val),
  26. {
  27. label: "name",
  28. level: "level",
  29. }
  30. );
  31. watchEffect(() => {
  32. emit("update:data", state.currentOption);
  33. });
  34. watchEffect(() => {
  35. emit("update:label", state.label);
  36. });
  37. watchEffect(() => {
  38. emit("update:path", state.path);
  39. });
  40. </script>
  41. <style scoped>
  42. .aaa::after {
  43. content: "";
  44. position: absolute;
  45. left: 0;
  46. right: 0;
  47. top: 0;
  48. bottom: 0;
  49. }
  50. </style>