@next-libs/cmdb-instances 7.29.12 → 7.29.13

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.
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
3
  import _objectSpread from "@babel/runtime/helpers/objectSpread2";
4
4
  import React, { useEffect, useReducer, useState, useRef, useMemo, useCallback } from "react";
5
- import { difference, isEmpty, isEqual, isString, map, uniq, union, filter, reject, sortBy, uniqueId, findIndex, find, startsWith, compact, omit, keyBy, isNil, get, isArray } from "lodash";
5
+ import { difference, isEmpty, isEqual, isString, map, uniq, union, filter, reject, uniqueId, find, startsWith, compact, omit, keyBy, isNil, get, isArray } from "lodash";
6
6
  import { BrickAsComponent, getRuntime, handleHttpError, useProvider } from "@next-core/brick-kit";
7
7
  import i18n from "i18next";
8
8
  import { K, NS_LIBS_CMDB_INSTANCES } from "../i18n/constants";
@@ -415,7 +415,7 @@ export function LegacyInstanceList(props) {
415
415
  };
416
416
  };
417
417
 
418
- // 根据用户预定义的 presetConfigs.fieldIds 进行排序,如果不在预定义的字段,则根据 modelData.view.attr_order 进行排序
418
+ // 根据用户预定义的 presetConfigs.fieldIds 进行排序,如果不在预定义的字段,则根据 fieldIds 进行排序
419
419
  var _sortFieldIds = fieldIds => {
420
420
  var _props$presetConfigs2;
421
421
  var frontFields = [];
@@ -423,14 +423,7 @@ export function LegacyInstanceList(props) {
423
423
  if ((_props$presetConfigs2 = props.presetConfigs) !== null && _props$presetConfigs2 !== void 0 && _props$presetConfigs2.fieldIds) {
424
424
  frontFields = filter(props.presetConfigs.fieldIds, id => fieldIds.includes(id));
425
425
  }
426
- restFields = sortBy(reject(fieldIds, id => frontFields.includes(id)), fieldId => {
427
- var foundIndex = findIndex(modelData.view.attr_order, orderId => orderId === fieldId);
428
- if (foundIndex === -1) {
429
- return null;
430
- } else {
431
- return foundIndex;
432
- }
433
- });
426
+ restFields = reject(fieldIds, id => frontFields.includes(id));
434
427
  return [...frontFields, ...restFields];
435
428
  };
436
429
  // istanbul ignore next
@@ -1124,24 +1117,26 @@ export function LegacyInstanceList(props) {
1124
1117
  handleHttpError(e);
1125
1118
  }
1126
1119
  } else {
1120
+ var _sortFields2 = mergeFields(state.sortFields, fields);
1127
1121
  setState({
1128
- fieldIds: _sortFieldIds(fields)
1122
+ fieldIds: _sortFieldIds(fields),
1123
+ sortFields: _sortFields2
1129
1124
  });
1130
- jsonLocalStorage.setItem("".concat(modelData.objectId, "-selectAttrIds"), fields);
1125
+ jsonLocalStorage.setItem("".concat(modelData.objectId, "-selectAttrIds"), _sortFieldIds(fields));
1131
1126
  }
1132
1127
  props.onFieldsModalConfirm(fields);
1133
1128
  } else {
1134
1129
  // 点击【默认显示】按钮触发,不影响当前列表显示。
1135
1130
  try {
1136
1131
  // istanbul ignore next
1137
- var _sortFields2 = mergeFields(state.sortFields, fields);
1132
+ var _sortFields3 = mergeFields(state.sortFields, fields);
1138
1133
  yield updateFieldsProvider.query([props.objectId, {
1139
- sortFields: _sortFields2,
1134
+ sortFields: _sortFields3,
1140
1135
  isDefault: true
1141
1136
  }]);
1142
1137
  message.success(i18n.t("".concat(NS_LIBS_CMDB_INSTANCES, ":").concat(K.SET_DEFAULT_DISPLAY_SUCCESS)));
1143
1138
  setState({
1144
- backendDefaultFields: _sortFields2
1139
+ backendDefaultFields: _sortFields3
1145
1140
  });
1146
1141
  } catch (e) {
1147
1142
  handleHttpError(e);