diff --git a/.env.development b/.env.development index b58a810..8d3955a 100644 --- a/.env.development +++ b/.env.development @@ -7,12 +7,12 @@ VITE_PUBLIC_PATH = / # 开发环境路由历史模式(Hash模式传"hash"、HTML5模式传"h5"、Hash模式带base参数传"hash,base参数"、HTML5模式带base参数传"h5,base参数") VITE_ROUTER_HISTORY = "hash" -# # 接口地址 -# VITE_API_BASEURL = "http://192.168.2.33:5199/api" -# #数据中心后台地址 -# VITE_API_USERCENTER_URL = "https://dca.w.23544.com:8843/api" - # 接口地址 -VITE_API_BASEURL = "https://learn-archives-admin-dev.23544.com/api" +VITE_API_BASEURL = "http://192.168.2.33:5199/api" #数据中心后台地址 VITE_API_USERCENTER_URL = "https://dca.w.23544.com:8843/api" + +# # 接口地址 +# VITE_API_BASEURL = "https://learn-archives-admin-dev.23544.com/api" +# #数据中心后台地址 +# VITE_API_USERCENTER_URL = "https://dca.w.23544.com:8843/api" diff --git a/src/components/hTable/hTable.ts b/src/components/hTable/hTable.ts index 449063d..5738664 100644 --- a/src/components/hTable/hTable.ts +++ b/src/components/hTable/hTable.ts @@ -181,7 +181,7 @@ export class TableColumnSearch { * @param searchType 查询时候的值比较类型 */ constructor(yes: boolean = false, - searchType: ConditionalType = ConditionalType.Like,sort: boolean = false,){ + searchType: ConditionalType = ConditionalType.Like,sort: boolean = false){ this.yes = yes; this.sort = sort; this.searchType = searchType; diff --git a/src/components/hTable/index.vue b/src/components/hTable/index.vue index ab7339b..a09887f 100644 --- a/src/components/hTable/index.vue +++ b/src/components/hTable/index.vue @@ -15,7 +15,7 @@ import { } from "vue"; import { Search } from "@element-plus/icons-vue"; -import { ElMessage, ElMessageBox } from "element-plus"; +import { ElMessage, ElMessageBox, TableColumnCtx } from "element-plus"; import { defineAsyncComponent, AsyncComponentLoader } from "vue"; import { ButtonCustomConfig, @@ -77,6 +77,7 @@ let Api: hTableAPI = null; const init = ref(false); const tableHeight = ref(0); +let defaultOrderBy = null; const dialog = ref({ visible: false, @@ -251,6 +252,21 @@ function pageIndexChange(o) { table.value.search.PageIndex = o - 1; fetchPagedData(); } + +/** + * 排序变化时 + * @param selection + */ +function sortChange(data: { column: TableColumnCtx; prop: string; order: any }) { + if (data.order == undefined) { + table.value.search.OrderBy = defaultOrderBy.OrderBy; + table.value.search.OrderByType = defaultOrderBy.OrderByType; + } else { + table.value.search.OrderBy = data.prop; + table.value.search.OrderByType = data.order === "ascending" ? 1 : 0; + } + handleReloadPaged(); +} // 勾选 function handleSelectionChange(selection) { console.log("selection-change", selection); @@ -272,6 +288,12 @@ function searchReload() { } // 查询 function handleReloadPaged(reload = true) { + if (defaultOrderBy == null) { + defaultOrderBy = { + OrderBy: table.value.search.OrderBy, + OrderByType: table.value.search.OrderByType, + }; + } if (table.value.search === undefined || table.value.search.PageIndex === undefined) { table.value.search.PageIndex = 0; table.value.search.PageSize = 20; @@ -358,7 +380,7 @@ function fetchPagedData() {
- +