From 52503f76cc0501697f0c996dbb5e0053296fa005 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E8=99=B9=E7=9D=BF?= <297504645@qq.com> Date: Wed, 9 Aug 2023 13:53:31 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E7=89=B9=E6=AE=8A=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20=202=E3=80=81Sorting=EF=BC=9A=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E6=AE=B5=E5=80=92=E5=8F=99=203=E3=80=81=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E4=BD=8D=E7=BD=AE=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/currenButton/innerButton.vue | 7 +- Code/Fe/src/mixins/TableMixins.js | 78 ++++++++++++++++++- Code/Fe/src/utils/defaultButtons.js | 6 +- 3 files changed, 84 insertions(+), 7 deletions(-) diff --git a/Code/Fe/src/components/currenButton/innerButton.vue b/Code/Fe/src/components/currenButton/innerButton.vue index 5f08da7..9dab791 100644 --- a/Code/Fe/src/components/currenButton/innerButton.vue +++ b/Code/Fe/src/components/currenButton/innerButton.vue @@ -57,4 +57,9 @@ export default { } } } - \ No newline at end of file + + \ No newline at end of file diff --git a/Code/Fe/src/mixins/TableMixins.js b/Code/Fe/src/mixins/TableMixins.js index 2d7ad18..7f54736 100644 --- a/Code/Fe/src/mixins/TableMixins.js +++ b/Code/Fe/src/mixins/TableMixins.js @@ -163,7 +163,7 @@ export const tableMixins = { _data.forEach(item=>{ // 如果list接口存在数据 ,与list接口返回字段比较处理,list接口存在的话则追加 let _if = firstWordSizeChange(item.name) != 'details' - if(list && list.length > 0){ + if(list){ _if = firstWordSizeChange(item.name) in list && firstWordSizeChange(item.name) != 'details' } if(_if){ @@ -171,16 +171,83 @@ export const tableMixins = { } }) } + _Columns_Table = _Columns_Table.concat(this.specialAddColumns(list,titleName)) return _Columns_Table }, + // 添加特殊字段(api中没有的字段特殊处理) + specialAddColumns(list,titleName){ + let _apiName = titleName + let _special_list=[] + // creationTime + if('creationTime' in list){ + _special_list.push( + { + "name": "CreationTime", + "apiBaseType": "datetime", + "baseApiName": _apiName + 'CreationTime', + "label": zhApiColumnsLable(_apiName + 'CreationTime') || _apiName + 'CreationTime', + "prop": "creationTime", + } + ) + } + // creatorId + if('creatorId' in list){ + _special_list.push( + { + "name": "CreatorId", + "apiBaseType": "string", + "baseApiName": _apiName + 'CreatorId', + "label": zhApiColumnsLable(_apiName + 'CreatorId') || _apiName + 'CreatorId', + "prop": "creatorId", + } + ) + } + // lastModificationTime + if('lastModificationTime' in list){ + _special_list.push( + { + "name": "LastModificationTime", + "apiBaseType": "datetime", + "baseApiName": _apiName + 'LastModificationTime', + "label": zhApiColumnsLable(_apiName + 'LastModificationTime') || _apiName + 'LastModificationTime', + "prop": "lastModificationTime", + } + ) + } + // lastModifierId + if('lastModifierId' in list){ + _special_list.push( + { + "name": "LastModifierId", + "apiBaseType": "string", + "baseApiName": _apiName + 'LastModifierId', + "label": zhApiColumnsLable(_apiName + 'LastModifierId') || _apiName + 'LastModifierId', + "prop": "lastModifierId", + } + ) + } + // tenantId + if('tenantId' in list){ + _special_list.push( + { + "name": "TenantId", + "apiBaseType": "string", + "baseApiName": _apiName + 'TenantId', + "label": zhApiColumnsLable(_apiName + 'TenantId') || _apiName + 'TenantId', + "prop": "tenantId", + } + ) + } + return _special_list + }, //渲染数据 - paging(callback) { + paging(callback,repeat) { this.Loading.tableLoading = true; this.PageListParams.SkipCount = (this.oldSkipCount - 1) * this.PageListParams.MaxResultCount getPageList(this.PageListParams, this.URLOption_base) .then(res=>{ // 表头处理 - let _Columns = this.initApiColumnsForDto(res,this.$route.name) + let _Columns = this.initApiColumnsForDto(res.items[0],this.$route.name) this.apiColumns_Table = this.initTableColumns(_Columns) this.apiColumns_DesTions = _Columns // 页面数据处理 @@ -188,6 +255,11 @@ export const tableMixins = { this.tableData = res.items this.totalCount = res.totalCount } + // 如果返回数据中有creationTime,则默认按时间段倒叙重新查一遍 + if('creationTime' in res.items[0] && !repeat){ + this.PageListParams.Sorting = "CreationTime DESC" + this.paging(callback,true) + } this.pagingCallback(callback) }) .catch(err=>{ diff --git a/Code/Fe/src/utils/defaultButtons.js b/Code/Fe/src/utils/defaultButtons.js index d88391f..dc9a1fc 100644 --- a/Code/Fe/src/utils/defaultButtons.js +++ b/Code/Fe/src/utils/defaultButtons.js @@ -86,12 +86,12 @@ export function defaultFreshBtn(option) { // 筛选按钮 export function defaultFilterBtn(option) { return __defaultBtnOption(option,{ - type: "primary", + // type: "primary", icon: "el-icon-finished", label: i18n.t('btns.filter'), name: "filter", size: "mini", - float: 'right' + float: 'left' }) } @@ -103,7 +103,7 @@ export function defaultFilterForDetailBtn(option) { label: i18n.t('btns.DetailedQuery'), name: "filterForDetail", size: "mini", - float: 'right', + float: 'left', }) }