xianniu-ui 0.8.39 → 0.8.41

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xianniu-ui",
3
- "version": "0.8.39",
3
+ "version": "0.8.41",
4
4
  "private": false,
5
5
  "main": "lib/xianniu-ui.umd.min.js",
6
6
  "scripts": {
package/src/area/index.js CHANGED
@@ -3676,6 +3676,10 @@ export default [{
3676
3676
  'cityName': '临安区',
3677
3677
  'cityCode': '330112'
3678
3678
  },
3679
+ {
3680
+ 'cityName': '临平区',
3681
+ 'cityCode': '330113'
3682
+ },
3679
3683
  {
3680
3684
  'cityName': '桐庐县',
3681
3685
  'cityCode': '330122'
@@ -198,7 +198,32 @@ export const toCamelCase = (string)=> {
198
198
  return camelCaseString;
199
199
  }
200
200
 
201
+ export function assignValues(form, apiResponse) {
202
+ function isEmpty(value) {
203
+ return (
204
+ (Array.isArray(value) && value.length === 0) ||
205
+ (typeof value === 'object' && Object.keys(value).length === 0)
206
+ )
207
+ }
208
+
209
+ const updatedForm = Array.isArray(form) ? [...form] : { ...form }
210
+
211
+ for (const key in form) {
212
+ if (Object.hasOwnProperty.call(form, key)) {
213
+ const apiValue = apiResponse[key]
214
+
215
+ // 检查 apiValue 是否是一个对象,如果是,则递归
216
+ if (typeof apiValue === 'object' && apiValue !== null && !Array.isArray(apiValue)) {
217
+ updatedForm[key] = assignValues(form[key], apiValue)
218
+ } else if (apiValue !== null && apiValue !== undefined && apiValue !== '' && !isEmpty(apiValue)) {
219
+ // 如果 apiValue 不是空值及不是空的对象或数组,更新 updatedForm
220
+ updatedForm[key] = apiValue
221
+ }
222
+ }
223
+ }
201
224
 
225
+ return updatedForm
226
+ }
202
227
  export default {
203
228
  isEmpty,
204
229
  isImg,
@@ -209,5 +234,6 @@ export default {
209
234
  isBlank,
210
235
  toCamelCase,
211
236
  checkFile,
212
- isAV
237
+ isAV,
238
+ assignValues
213
239
  }