From 2d0fc59fc78276112a74ecefed87b5f8f14763c2 Mon Sep 17 00:00:00 2001 From: RuoYi <yzz_ivy@163.com> Date: 星期日, 27 四月 2025 13:43:28 +0800 Subject: [PATCH] 添加页签openPage支持传递参数 --- src/views/tool/gen/index.vue | 207 +++++++++++++++++++++++++++------------------------ 1 files changed, 108 insertions(+), 99 deletions(-) diff --git a/src/views/tool/gen/index.vue b/src/views/tool/gen/index.vue index 77e8a80..d179f09 100644 --- a/src/views/tool/gen/index.vue +++ b/src/views/tool/gen/index.vue @@ -87,33 +87,18 @@ <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar> </el-row> - <el-table v-loading="loading" :data="tableList" @selection-change="handleSelectionChange"> + <el-table ref="genRef" v-loading="loading" :data="tableList" @selection-change="handleSelectionChange" :default-sort="defaultSort" @sort-change="handleSortChange"> <el-table-column type="selection" align="center" width="55"></el-table-column> <el-table-column label="搴忓彿" type="index" width="50" align="center"> <template #default="scope"> <span>{{(queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1}}</span> </template> </el-table-column> - <el-table-column - label="琛ㄥ悕绉�" - align="center" - prop="tableName" - :show-overflow-tooltip="true" - /> - <el-table-column - label="琛ㄦ弿杩�" - align="center" - prop="tableComment" - :show-overflow-tooltip="true" - /> - <el-table-column - label="瀹炰綋" - align="center" - prop="className" - :show-overflow-tooltip="true" - /> - <el-table-column label="鍒涘缓鏃堕棿" align="center" prop="createTime" width="160" /> - <el-table-column label="鏇存柊鏃堕棿" align="center" prop="updateTime" width="160" /> + <el-table-column label="琛ㄥ悕绉�" align="center" prop="tableName" :show-overflow-tooltip="true" /> + <el-table-column label="琛ㄦ弿杩�" align="center" prop="tableComment" :show-overflow-tooltip="true" /> + <el-table-column label="瀹炰綋" align="center" prop="className" :show-overflow-tooltip="true" /> + <el-table-column label="鍒涘缓鏃堕棿" align="center" prop="createTime" width="160" sortable="custom" :sort-orders="['descending', 'ascending']" /> + <el-table-column label="鏇存柊鏃堕棿" align="center" prop="updateTime" width="160" sortable="custom" :sort-orders="['descending', 'ascending']" /> <el-table-column label="鎿嶄綔" align="center" width="330" class-name="small-padding fixed-width"> <template #default="scope"> <el-tooltip content="棰勮" placement="top"> @@ -161,31 +146,34 @@ </template> <script setup name="Gen"> -import { listTable, previewTable, delTable, genCode, synchDb } from "@/api/tool/gen"; -import router from "@/router"; -import importTable from "./importTable"; -import createTable from "./createTable"; +import { listTable, previewTable, delTable, genCode, synchDb } from "@/api/tool/gen" +import router from "@/router" +import importTable from "./importTable" +import createTable from "./createTable" -const route = useRoute(); -const { proxy } = getCurrentInstance(); +const route = useRoute() +const { proxy } = getCurrentInstance() -const tableList = ref([]); -const loading = ref(true); -const showSearch = ref(true); -const ids = ref([]); -const single = ref(true); -const multiple = ref(true); -const total = ref(0); -const tableNames = ref([]); -const dateRange = ref([]); -const uniqueId = ref(""); +const tableList = ref([]) +const loading = ref(true) +const showSearch = ref(true) +const ids = ref([]) +const single = ref(true) +const multiple = ref(true) +const total = ref(0) +const tableNames = ref([]) +const dateRange = ref([]) +const uniqueId = ref("") +const defaultSort = ref({ prop: "createTime", order: "descending" }) const data = reactive({ queryParams: { pageNum: 1, pageSize: 10, tableName: undefined, - tableComment: undefined + tableComment: undefined, + orderByColumn: defaultSort.value.prop, + isAsc: defaultSort.value.order }, preview: { open: false, @@ -193,107 +181,128 @@ data: {}, activeName: "domain.java" } -}); +}) -const { queryParams, preview } = toRefs(data); +const { queryParams, preview } = toRefs(data) onActivated(() => { - const time = route.query.t; + const time = route.query.t if (time != null && time != uniqueId.value) { - uniqueId.value = time; - queryParams.value.pageNum = Number(route.query.pageNum); - dateRange.value = []; - proxy.resetForm("queryForm"); - getList(); + uniqueId.value = time + queryParams.value.pageNum = Number(route.query.pageNum) + dateRange.value = [] + proxy.resetForm("queryForm") + getList() } }) /** 鏌ヨ琛ㄩ泦鍚� */ function getList() { - loading.value = true; + loading.value = true listTable(proxy.addDateRange(queryParams.value, dateRange.value)).then(response => { - tableList.value = response.rows; - total.value = response.total; - loading.value = false; - }); + tableList.value = response.rows + total.value = response.total + loading.value = false + }) } + /** 鎼滅储鎸夐挳鎿嶄綔 */ function handleQuery() { - queryParams.value.pageNum = 1; - getList(); + queryParams.value.pageNum = 1 + getList() } + /** 鐢熸垚浠g爜鎿嶄綔 */ function handleGenTable(row) { - const tbNames = row.tableName || tableNames.value; + const tbNames = row.tableName || tableNames.value if (tbNames == "") { - proxy.$modal.msgError("璇烽�夋嫨瑕佺敓鎴愮殑鏁版嵁"); - return; + proxy.$modal.msgError("璇烽�夋嫨瑕佺敓鎴愮殑鏁版嵁") + return } if (row.genType === "1") { genCode(row.tableName).then(response => { - proxy.$modal.msgSuccess("鎴愬姛鐢熸垚鍒拌嚜瀹氫箟璺緞锛�" + row.genPath); - }); + proxy.$modal.msgSuccess("鎴愬姛鐢熸垚鍒拌嚜瀹氫箟璺緞锛�" + row.genPath) + }) } else { - proxy.$download.zip("/tool/gen/batchGenCode?tables=" + tbNames, "ruoyi.zip"); + proxy.$download.zip("/tool/gen/batchGenCode?tables=" + tbNames, "ruoyi.zip") } } + /** 鍚屾鏁版嵁搴撴搷浣� */ function handleSynchDb(row) { - const tableName = row.tableName; + const tableName = row.tableName proxy.$modal.confirm('纭瑕佸己鍒跺悓姝�"' + tableName + '"琛ㄧ粨鏋勫悧锛�').then(function () { - return synchDb(tableName); + return synchDb(tableName) }).then(() => { - proxy.$modal.msgSuccess("鍚屾鎴愬姛"); - }).catch(() => {}); + proxy.$modal.msgSuccess("鍚屾鎴愬姛") + }).catch(() => {}) } + /** 鎵撳紑瀵煎叆琛ㄥ脊绐� */ function openImportTable() { - proxy.$refs["importRef"].show(); + proxy.$refs["importRef"].show() } + /** 鎵撳紑鍒涘缓琛ㄥ脊绐� */ function openCreateTable() { - proxy.$refs["createRef"].show(); + proxy.$refs["createRef"].show() } + /** 閲嶇疆鎸夐挳鎿嶄綔 */ function resetQuery() { - dateRange.value = []; - proxy.resetForm("queryRef"); - handleQuery(); + dateRange.value = [] + proxy.resetForm("queryRef") + queryParams.value.pageNum = 1 + proxy.$refs["genRef"].sort(defaultSort.value.prop, defaultSort.value.order) } + /** 棰勮鎸夐挳 */ function handlePreview(row) { previewTable(row.tableId).then(response => { - preview.value.data = response.data; - preview.value.open = true; - preview.value.activeName = "domain.java"; - }); -} -/** 澶嶅埗浠g爜鎴愬姛 */ -function copyTextSuccess() { - proxy.$modal.msgSuccess("澶嶅埗鎴愬姛"); -} -// 澶氶�夋閫変腑鏁版嵁 -function handleSelectionChange(selection) { - ids.value = selection.map(item => item.tableId); - tableNames.value = selection.map(item => item.tableName); - single.value = selection.length != 1; - multiple.value = !selection.length; -} -/** 淇敼鎸夐挳鎿嶄綔 */ -function handleEditTable(row) { - const tableId = row.tableId || ids.value[0]; - router.push({ path: "/tool/gen-edit/index/" + tableId, query: { pageNum: queryParams.value.pageNum } }); -} -/** 鍒犻櫎鎸夐挳鎿嶄綔 */ -function handleDelete(row) { - const tableIds = row.tableId || ids.value; - proxy.$modal.confirm('鏄惁纭鍒犻櫎琛ㄧ紪鍙蜂负"' + tableIds + '"鐨勬暟鎹」锛�').then(function () { - return delTable(tableIds); - }).then(() => { - getList(); - proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛"); - }).catch(() => {}); + preview.value.data = response.data + preview.value.open = true + preview.value.activeName = "domain.java" + }) } -getList(); +/** 澶嶅埗浠g爜鎴愬姛 */ +function copyTextSuccess() { + proxy.$modal.msgSuccess("澶嶅埗鎴愬姛") +} + +// 澶氶�夋閫変腑鏁版嵁 +function handleSelectionChange(selection) { + ids.value = selection.map(item => item.tableId) + tableNames.value = selection.map(item => item.tableName) + single.value = selection.length != 1 + multiple.value = !selection.length +} + +/** 鎺掑簭瑙﹀彂浜嬩欢 */ +function handleSortChange(column, prop, order) { + queryParams.value.orderByColumn = column.prop + queryParams.value.isAsc = column.order + getList() +} + +/** 淇敼鎸夐挳鎿嶄綔 */ +function handleEditTable(row) { + const tableId = row.tableId || ids.value[0] + const tableName = row.tableName || tableNames.value[0] + const params = { pageNum: queryParams.value.pageNum } + proxy.$tab.openPage("淇敼[" + tableName + "]鐢熸垚閰嶇疆", '/tool/gen-edit/index/' + tableId, params) +} + +/** 鍒犻櫎鎸夐挳鎿嶄綔 */ +function handleDelete(row) { + const tableIds = row.tableId || ids.value + proxy.$modal.confirm('鏄惁纭鍒犻櫎琛ㄧ紪鍙蜂负"' + tableIds + '"鐨勬暟鎹」锛�').then(function () { + return delTable(tableIds) + }).then(() => { + getList() + proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛") + }).catch(() => {}) +} + +getList() </script> -- Gitblit v1.9.3