Commit a0643bc402e2ccf24c90e7ceb47e9fa4d578c789
Merge branch 'sqy_dev' into 'main'
refactor:调整组织树公共组件 See merge request huang/yun-teng-iot-front!211
Showing
2 changed files
with
19 additions
and
44 deletions
| ... | ... | @@ -8,51 +8,31 @@ |
| 8 | 8 | :clickRowToExpand="false" |
| 9 | 9 | :treeData="treeData" |
| 10 | 10 | :replaceFields="{ key: 'id', title: 'name' }" |
| 11 | - v-model:expandedKeys="expandedKeys" | |
| 12 | - v-model:selectedKeys="selectedKeys" | |
| 11 | + :selectedKeys="selectedKeys" | |
| 13 | 12 | @select="handleSelect" |
| 14 | - :defaultExpandAll="true" | |
| 15 | 13 | /> |
| 16 | 14 | </div> |
| 17 | 15 | </template> |
| 18 | -<script lang="ts"> | |
| 19 | - import { defineComponent, onMounted, ref } from 'vue'; | |
| 20 | - | |
| 16 | +<script lang="ts" setup name="OrganizationIdTree"> | |
| 17 | + import { onMounted, ref } from 'vue'; | |
| 21 | 18 | import { BasicTree, TreeItem } from '/@/components/Tree'; |
| 22 | 19 | import { getOrganizationList } from '/@/api/system/system'; |
| 20 | + const emit = defineEmits(['select']); | |
| 21 | + const treeData = ref<TreeItem[]>([]); | |
| 22 | + const selectedKeys = ref<string[]>(); | |
| 23 | + | |
| 24 | + function handleSelect(keys) { | |
| 25 | + emit('select', keys[0]); | |
| 26 | + } | |
| 23 | 27 | |
| 24 | - export default defineComponent({ | |
| 25 | - name: 'OrganizationIdTree', | |
| 26 | - components: { BasicTree }, | |
| 27 | - | |
| 28 | - emits: ['select'], | |
| 29 | - setup(_, { emit }) { | |
| 30 | - const getTreeRef: any = ref(null); | |
| 31 | - const treeData = ref<TreeItem[]>([]); | |
| 32 | - const selectedKeys = ref<string[]>(); | |
| 33 | - const expandedKeys = ref<string[]>(); | |
| 34 | - async function fetch() { | |
| 35 | - treeData.value = (await getOrganizationList()) as unknown as TreeItem[]; | |
| 36 | - } | |
| 28 | + function resetOrganization() { | |
| 29 | + selectedKeys.value = []; | |
| 30 | + } | |
| 37 | 31 | |
| 38 | - function handleSelect(keys) { | |
| 39 | - emit('select', keys[0]); | |
| 40 | - } | |
| 41 | - function resetOrganization() { | |
| 42 | - selectedKeys.value = []; | |
| 43 | - } | |
| 44 | - | |
| 45 | - onMounted(() => { | |
| 46 | - fetch(); | |
| 47 | - }); | |
| 48 | - return { | |
| 49 | - treeData, | |
| 50 | - handleSelect, | |
| 51 | - resetOrganization, | |
| 52 | - selectedKeys, | |
| 53 | - expandedKeys, | |
| 54 | - getTreeRef, | |
| 55 | - }; | |
| 56 | - }, | |
| 32 | + onMounted(async () => { | |
| 33 | + treeData.value = (await getOrganizationList()) as unknown as TreeItem[]; | |
| 34 | + }); | |
| 35 | + defineExpose({ | |
| 36 | + resetOrganization, | |
| 57 | 37 | }); |
| 58 | 38 | </script> | ... | ... |
| ... | ... | @@ -68,7 +68,7 @@ |
| 68 | 68 | </template> |
| 69 | 69 | |
| 70 | 70 | <script lang="ts"> |
| 71 | - import { defineComponent, reactive, ref, nextTick } from 'vue'; | |
| 71 | + import { defineComponent, reactive, nextTick } from 'vue'; | |
| 72 | 72 | import { BasicTable, useTable, TableAction } from '/@/components/Table'; |
| 73 | 73 | import { PageWrapper } from '/@/components/Page'; |
| 74 | 74 | import { useDrawer } from '/@/components/Drawer'; |
| ... | ... | @@ -95,11 +95,6 @@ |
| 95 | 95 | }, |
| 96 | 96 | setup() { |
| 97 | 97 | const { VITE_GLOB_CONFIGURATION } = getAppEnvConfig(); |
| 98 | - let selectedRowIds = ref<string[]>([]); | |
| 99 | - // 复选框事件 | |
| 100 | - const onSelectRowChange = (selectedRowKeys: string[]) => { | |
| 101 | - selectedRowIds.value = selectedRowKeys; | |
| 102 | - }; | |
| 103 | 98 | const searchInfo = reactive<Recordable>({}); |
| 104 | 99 | const { organizationIdTreeRef, resetFn } = useResetOrganizationTree(searchInfo); |
| 105 | 100 | // 表格hooks | ... | ... |