修改 传入参数方式

This commit is contained in:
GGJ
2024-08-01 13:58:32 +08:00
parent d7a9b1023e
commit 78dfa759ed
3 changed files with 10 additions and 4 deletions

View File

@@ -227,14 +227,16 @@ function getPendingKey(config: AxiosRequestConfig) {
/** /**
* 根据请求方法组装请求数据/参数 * 根据请求方法组装请求数据/参数
*/ */
export function requestPayload(method: Method, data: anyObj) { export function requestPayload(method: Method, data: anyObj, paramsPOST: boolean) {
if (method == 'GET') { if (method == 'GET') {
return { return {
params: data params: data
} }
} else if (method == 'POST') { } else if (method == 'POST') {
return { if (paramsPOST) {
data: data return { params: data }
} else {
return { data: data }
} }
} }
} }

View File

@@ -12,6 +12,7 @@ interface TableStoreParams {
method?: Method method?: Method
isWebPaging?: boolean // 是否前端分页 isWebPaging?: boolean // 是否前端分页
showPage?: boolean showPage?: boolean
paramsPOST?: boolean
publicHeight?: number publicHeight?: number
resetCallback?: () => void resetCallback?: () => void
loadCallback?: () => void loadCallback?: () => void
@@ -24,6 +25,7 @@ export default class TableStore {
public method: Method public method: Method
public initData: any = null public initData: any = null
public isWebPaging = false public isWebPaging = false
public paramsPOST = true
public showPage = true public showPage = true
public table: CnTable = reactive({ public table: CnTable = reactive({
ref: null, ref: null,
@@ -47,6 +49,7 @@ export default class TableStore {
constructor(public options: TableStoreParams) { constructor(public options: TableStoreParams) {
this.url = options.url this.url = options.url
this.pk = options.pk || 'id' this.pk = options.pk || 'id'
this.paramsPOST = options.paramsPOST || false
this.isWebPaging = options.isWebPaging || false this.isWebPaging = options.isWebPaging || false
this.method = options.method || 'GET' this.method = options.method || 'GET'
this.table.column = options.column this.table.column = options.column
@@ -73,7 +76,7 @@ export default class TableStore {
url: this.url, url: this.url,
method: this.method method: this.method
}, },
requestPayload(this.method, this.table.params) requestPayload(this.method, this.table.params, this.paramsPOST)
) )
).then((res: any) => { ).then((res: any) => {
if (res.data) { if (res.data) {

View File

@@ -31,6 +31,7 @@ const tableStore = new TableStore({
publicHeight: 65, publicHeight: 65,
method: 'POST', method: 'POST',
isWebPaging: true, isWebPaging: true,
paramsPOST: true,
column: [ column: [
{ field: 'substationName', title: '变电站名称', minWidth: 100 }, { field: 'substationName', title: '变电站名称', minWidth: 100 },
{ {