t20-common-lib 0.15.6 → 0.15.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -111,41 +111,39 @@ export default {
|
|
|
111
111
|
return item
|
|
112
112
|
})
|
|
113
113
|
},
|
|
114
|
-
setDeepValue(target, path, value) {
|
|
115
|
-
const keys = String(path || '').split('.').filter(Boolean)
|
|
116
|
-
if (keys.length === 0) return
|
|
117
|
-
let cur = target
|
|
118
|
-
for (let i = 0; i < keys.length - 1; i += 1) {
|
|
119
|
-
const key = keys[i]
|
|
120
|
-
if (!cur[key] || typeof cur[key] !== 'object' || Array.isArray(cur[key])) {
|
|
121
|
-
cur[key] = {}
|
|
122
|
-
}
|
|
123
|
-
cur = cur[key]
|
|
124
|
-
}
|
|
125
|
-
cur[keys[keys.length - 1]] = value
|
|
126
|
-
},
|
|
127
114
|
buildPagingParams(params, apiConfig) {
|
|
128
115
|
const pageConfig = apiConfig?.page || {}
|
|
116
|
+
const method = String(apiConfig?.requestMethod || '').toUpperCase()
|
|
129
117
|
const currentKey = pageConfig.current || 'current'
|
|
130
118
|
const sizeKey = pageConfig.size || 'size'
|
|
131
119
|
const currentVal = params.current
|
|
132
120
|
const sizeVal = params.size
|
|
133
121
|
|
|
134
|
-
//
|
|
135
|
-
if (
|
|
122
|
+
// GET: 直接按配置 key 传查询参数(支持 page.current/page.size)
|
|
123
|
+
if (method === 'GET') {
|
|
124
|
+
return {
|
|
125
|
+
[currentKey]: currentVal,
|
|
126
|
+
[sizeKey]: sizeVal
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// POST: 如果配置是 page.current/page.size,则转为 { page: { current, size } }
|
|
131
|
+
const currentParts = String(currentKey).split('.')
|
|
132
|
+
const sizeParts = String(sizeKey).split('.')
|
|
133
|
+
if (currentParts.length === 2 && sizeParts.length === 2 && currentParts[0] === sizeParts[0]) {
|
|
136
134
|
return {
|
|
137
|
-
[
|
|
138
|
-
[
|
|
139
|
-
[
|
|
135
|
+
[currentParts[0]]: {
|
|
136
|
+
[currentParts[1]]: currentVal,
|
|
137
|
+
[sizeParts[1]]: sizeVal
|
|
140
138
|
}
|
|
141
139
|
}
|
|
142
140
|
}
|
|
143
141
|
|
|
144
|
-
//
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
142
|
+
// POST 兜底:平铺参数
|
|
143
|
+
return {
|
|
144
|
+
[currentKey]: currentVal,
|
|
145
|
+
[sizeKey]: sizeVal
|
|
146
|
+
}
|
|
149
147
|
},
|
|
150
148
|
async fetchByApiConfig(params = {}) {
|
|
151
149
|
const apiConfig = this.items?.api || {}
|