From ce437617b37586a5c2678c571929272127a3d4fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=9C=9F=E8=B1=86=E5=93=A5?= Date: Sun, 31 Jul 2022 10:54:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=EF=BC=9A=E9=83=A8=E9=97=A8?= =?UTF-8?q?=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/launch.json | 2 +- src/components/QuickCrud/index.vue | 26 ++++++++++++++++++++------ src/views/dept/index.vue | 7 +++++-- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 60bb23d..bb16074 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -8,7 +8,7 @@ "type": "pwa-chrome", "request": "launch", "name": "Launch Chrome against localhost", - "url": "http://localhost:3001", + "url": "http://localhost:3101", "webRoot": "${workspaceFolder}" } ] diff --git a/src/components/QuickCrud/index.vue b/src/components/QuickCrud/index.vue index 988e241..ddfaa17 100644 --- a/src/components/QuickCrud/index.vue +++ b/src/components/QuickCrud/index.vue @@ -68,6 +68,10 @@ const props = defineProps({ type: [Boolean, Object], default: false, }, + leftTreeRefresh: { + type: Boolean, + default: false, + }, tableData: { type: Array, default: () => { @@ -100,6 +104,7 @@ const { searchFormModel, searchFormItems, leftTree, + leftTreeRefresh, tableData, tableColumns, tableActionbar, @@ -115,6 +120,7 @@ const { formModel: Ref formItems: Ref leftTree: Ref + leftTreeRefresh: Ref tableData: Ref tableColumns: Ref tableActionbar: Ref @@ -169,6 +175,7 @@ const treeRef = ref>() /** * 加载数据 */ + const load = () => { const { current, size } = page.value const params = { ...searchFormModel.value, current, size } @@ -190,6 +197,12 @@ const treeLoad = () => { load() }) } +const refresh = () => { + if (leftTree.value && leftTreeRefresh.value) { + treeLoad() + } else { + } +} /** * 搜索 */ @@ -224,7 +237,7 @@ const handleEdit = (row: any) => { } const handleDelete = (row: any) => { emits('onDelete', row, () => { - load() + refresh() }) } const handleDetail = (row: any) => { @@ -257,7 +270,7 @@ const handleSubmit = (formRef: FormInstance | undefined) => { } emits('onFormSubmit', formModel.value, () => { dialogFormVisible.value = false - load() + refresh() }) return true }) @@ -308,7 +321,7 @@ const handleBatchDelete = () => { }) .join(',') emits('onBatchDelete', { checkDataList, ids }, () => { - load() + refresh() }) } const handleImport = () => { @@ -321,7 +334,7 @@ const handleImport = () => { } console.log('handleImport') emits('onImport', () => { - load() + refresh() }) } const handleExport = () => { @@ -349,6 +362,7 @@ const handlePrint = () => { const handleRefresh = () => { console.log('handleRefresh') load() + // emits('onRefresh', () => { // load() // }) @@ -407,9 +421,8 @@ const handleTbaleRef = (tableRef: any): void => { onMounted(() => { if (leftTree.value) { treeLoad() - } else { - load() } + load() // if (autoReFefresh.value) { // timeCount.value = setInterval(() => { // load() @@ -432,6 +445,7 @@ onActivated(() => { :props="defaultTreeProps" node-key="id" :highlight-current="true" + :expand-on-click-node="false" @node-click="handleTreeNodeClick" > diff --git a/src/views/dept/index.vue b/src/views/dept/index.vue index 2756aaf..ae8d311 100644 --- a/src/views/dept/index.vue +++ b/src/views/dept/index.vue @@ -235,6 +235,7 @@ const leftTree = reactive({ const treeLoad = (done: any) => { getDeptList().then((res: any) => { const { data: deptList } = res + deptDdataListTemp.length = 0 deptDdataListTemp.push(...deptList) const data = deptTreeFormat(deptList) console.log(`pid`, data) @@ -246,8 +247,9 @@ const treeLoad = (done: any) => { dicTypeList.length = 0 dicTypeList.push(...data1) console.log('data1', data1) - - currentTreeData.value.id = data[0].id + if (!currentTreeData.value.id) { + currentTreeData.value.id = data[0].id + } done(currentTreeData.value.id) }) } @@ -267,6 +269,7 @@ const handleTreeClick = (data: Tree, done: any) => { :table-toolbar="tableToolbar" dialog-titles="dialogTitles" :left-tree="leftTree" + :left-tree-refresh="true" @on-edit="handleEdit" @on-load="load" @on-tree-load="treeLoad" -- Gitee