From 9508e4d1f14e58d270caa0237a7ff927ae25749b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E8=99=B9=E7=9D=BF?= <297504645@qq.com> Date: Fri, 21 Jul 2023 17:06:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9E=9A=E4=B8=BE=E6=9A=82=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Code/Fe/src/api/wms-interface.js | 18 ++++++++++ Code/Fe/src/mixins/TableMixins.js | 46 ++++++++++++++++++++++--- Code/Fe/src/store/modules/definition.js | 23 +++++++++++++ Code/Fe/src/store/modules/user.js | 2 +- Code/Fe/src/utils/index.js | 15 +++++++- 5 files changed, 97 insertions(+), 7 deletions(-) create mode 100644 Code/Fe/src/store/modules/definition.js diff --git a/Code/Fe/src/api/wms-interface.js b/Code/Fe/src/api/wms-interface.js index fdcdf4a..b3c0c07 100644 --- a/Code/Fe/src/api/wms-interface.js +++ b/Code/Fe/src/api/wms-interface.js @@ -22,6 +22,24 @@ export function getDefinitionMenu(IncludeTypes) { }) } + +// 获取枚举数据 +export async function getApiEnumList() { + return request({ + method:'get', + url: base_api + '/api/abp/api-definition', + params:{IncludeTypes:true} + }) +} + +// 获取dto列数据 +export async function getDtoColumnType(api) { + return request({ + method:'post', + url: base_api + '/api/'+ api +'/base/get-dto-column-type', + }) +} + // // 测试数据-明细-删除 // export function TestSchoolDetailList_delete(id) { // return request({ diff --git a/Code/Fe/src/mixins/TableMixins.js b/Code/Fe/src/mixins/TableMixins.js index 89ac45e..251c472 100644 --- a/Code/Fe/src/mixins/TableMixins.js +++ b/Code/Fe/src/mixins/TableMixins.js @@ -3,7 +3,9 @@ import { getDetailed, postDelete } from '@/api/wms-api' +import { initFromApiColumnsLable,firstWordSizeChange } from '@/utils/index' import * as allUrlOption from '@/utils/baseData/urlOption' +import { getDtoColumnType } from '@/api/wms-interface' export const tableMixins = { data() { return { @@ -56,7 +58,7 @@ export const tableMixins = { // 获取通过api的表头数据,不可以在初始化处理,因为接口返回问题 initApiColumns(table,des,detailsTable,detailsPage){ // 赋值表头数据 - if(table && table[this.$route.name])this.apiColumns_Table = this.initTableColumns(table[this.$route.name]) + // if(table && table[this.$route.name])this.apiColumns_Table = this.initTableColumns(table[this.$route.name]) if(des && des[this.$route.name])this.apiColumns_DesTions = des[this.$route.name] if(detailsTable && detailsTable[this.$route.name])this.apiColumns_DetailsTable = this.initTableColumns(detailsTable[this.$route.name],'detail_api') if(detailsPage && detailsPage[this.$route.name])this.apiColumns_DetailsPage = this.initTableColumns(detailsPage[this.$route.name],'detailPage_api') @@ -65,13 +67,47 @@ export const tableMixins = { paging(callback) { this.Loading.tableLoading = true; this.PageListParams.SkipCount = (this.oldSkipCount - 1) * this.PageListParams.MaxResultCount - getPageList(this.PageListParams, this.URLOption_base).then(res => { - this.tableData = res.items - this.totalCount = res.totalCount + Promise.all([ + getDtoColumnType(this.$route.name), + getPageList(this.PageListParams, this.URLOption_base) + ]).then((allData) => { + // 表头处理 + if(allData[0]){ + let _coloums = allData[0].filter(item=>{ + return item.dtoType == 'S' + }) + let _Columns_Table = [] + if(_coloums && _coloums.length > 0){ + let _data = _coloums[0].columnsTypes + _data.forEach(item=>{ + let _item = { + label:initFromApiColumnsLable(this.$route.name + item.z_ColumnName) || item.z_ColumnName, + prop:firstWordSizeChange(item.z_ColumnName), + apiType:item.z_ColumnType, + isEnum:item.isEnum + } + _Columns_Table.push(_item) + }) + } + this.apiColumns_Table = this.initTableColumns(_Columns_Table) + } + // 页面数据处理 + if(allData[1]){ + this.tableData = allData[1].items + this.totalCount = allData[1].totalCount + } this.pagingCallback(callback) - }).catch(err => { + console.log(111,this.apiColumns_Table,this.tableData) + }).catch(()=>{ this.Loading.tableLoading = false }) + // getPageList(this.PageListParams, this.URLOption_base).then(res => { + // this.tableData = res.items + // this.totalCount = res.totalCount + // this.pagingCallback(callback) + // }).catch(err => { + // this.Loading.tableLoading = false + // }) }, //接受排序信息并改变视图 sortChange(val) { diff --git a/Code/Fe/src/store/modules/definition.js b/Code/Fe/src/store/modules/definition.js new file mode 100644 index 0000000..7d8b791 --- /dev/null +++ b/Code/Fe/src/store/modules/definition.js @@ -0,0 +1,23 @@ +const state = { + enumList: [] +} + +const mutations = { + GET_ENUM_LIST: (state, log) => { + state.logs.push(log) + }, +} + +const actions = { + getEnumList({ commit }, log) { + commit('GET_ENUM_LIST', log) + }, +} + +export default { + namespaced: true, + state, + mutations, + actions +} + \ No newline at end of file diff --git a/Code/Fe/src/store/modules/user.js b/Code/Fe/src/store/modules/user.js index 3f8fbd4..3d3df06 100644 --- a/Code/Fe/src/store/modules/user.js +++ b/Code/Fe/src/store/modules/user.js @@ -220,7 +220,7 @@ const actions = { commit('SET_USERINFO', res) resolve(res) }else{ - reject('获取用户信息失败,请重试111') + reject('获取用户信息失败,请重试') } }) .catch(err => { diff --git a/Code/Fe/src/utils/index.js b/Code/Fe/src/utils/index.js index 257a8a8..cbb610e 100644 --- a/Code/Fe/src/utils/index.js +++ b/Code/Fe/src/utils/index.js @@ -557,7 +557,8 @@ export function createNewTabs (url) { window.open(url, "_blank") } -// 转义及读取api接口返回的表头信息 +// faster-new +// 转义及读取api接口返回的表头信息 export function initFromApiColumnsLable (data) { //todo:待定:重新获取全局从接口缓存的表头(如:接口监控看板) // import { getInterfaceBoard } from "@/api/wms-interface" @@ -577,3 +578,15 @@ export function initFromApiColumnsLable (data) { } return _Dashboard ? _Dashboard[data] : null } + +// 首字母转换 type='Lower'(小写,默认) Upper(大写) +export function firstWordSizeChange (str,type='Lower') { + switch(type){ + case 'Lower': + return str.substring(0,1).toLowerCase() + str.substring(1,str.length); + + case 'Upper': + return str.substring(0,1).toUpperCase() + str.substring(1,str.length); + + } +} \ No newline at end of file