@hzab/list-render 1.6.0-bate1 → 1.6.0-bate2

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": "@hzab/list-render",
3
- "version": "1.6.0-bate1",
3
+ "version": "1.6.0-bate2",
4
4
  "description": "",
5
5
  "main": "src",
6
6
  "scripts": {
@@ -89,7 +89,7 @@ export function getDateVal(val, format) {
89
89
  return dayjs(val).format(format);
90
90
  }
91
91
 
92
- export function getFieldList(_schema, fieldList = [], opt = {}) {
92
+ export function getFieldList(_schema, fieldList = [], opt = {},isTableSortXIdex = false) {
93
93
  const schema = _schema?.schema || _schema;
94
94
 
95
95
  const { boxList = [] } = opt || {};
@@ -113,10 +113,11 @@ export function getFieldList(_schema, fieldList = [], opt = {}) {
113
113
  fieldList.push(field);
114
114
  }
115
115
  });
116
+ isTableSortXIdex && fieldList.sort((a, b) => a["x-index"] - b["x-index"]);
116
117
  return fieldList;
117
118
  }
118
119
 
119
- export function getFieldMap(_schema, fieldMap = {}, isTableSortXIdex = false) {
120
+ export function getFieldMap(_schema, fieldMap = {}) {
120
121
  // const fieldMap = _.keyBy(getFieldList(_schema), "name");
121
122
  const schema = _schema?.schema || _schema;
122
123
  schema?.properties &&
@@ -131,7 +132,6 @@ export function getFieldMap(_schema, fieldMap = {}, isTableSortXIdex = false) {
131
132
  }
132
133
  });
133
134
 
134
- isTableSortXIdex && fieldList.sort((a, b) => a["x-index"] - b["x-index"]);
135
135
  return fieldMap;
136
136
  }
137
137
 
@@ -37,7 +37,7 @@ const ListRender = forwardRef(function (props, parentRef) {
37
37
  const queryRef = useRef();
38
38
  const modelQueryRef = useRef({});
39
39
  const formQueryRef = useRef({});
40
- const paginationQueryRef = useRef({pageNum: 1, pageSize: 10});
40
+ const paginationQueryRef = useRef({ pageNum: 1, pageSize: 10 });
41
41
 
42
42
  useImperativeHandle(parentRef, () => ({
43
43
  getList,
@@ -56,7 +56,7 @@ const ListRender = forwardRef(function (props, parentRef) {
56
56
  if (model) {
57
57
  if (!model.query) {
58
58
  model.query = {};
59
- }else{
59
+ } else {
60
60
  modelQueryRef.current = model?.query;
61
61
  }
62
62
  model.query.pageNum = 1;
@@ -82,11 +82,11 @@ const ListRender = forwardRef(function (props, parentRef) {
82
82
  });
83
83
  };
84
84
 
85
- function getList(query = modelQueryRef.current || {}) {
85
+ function getList(query = modelQueryRef.current || {}) {
86
86
  if (!model?.getList && Array.isArray(props.list)) {
87
87
  setListLoading(true);
88
88
  const { list } = props;
89
- const { pageNum = 1, pageSize = 10 } = modelQueryRef.current || {};
89
+ const { pageNum = 1, pageSize = 10 } = modelQueryRef.current || {};
90
90
  setList(list.slice(pageSize * (pageNum - 1), pageNum * pageSize));
91
91
  setTotal(list.length);
92
92
  props.onGetListEnd && props.onGetListEnd({ list, pagination: { pageNum, pageSize } });
@@ -109,7 +109,7 @@ const ListRender = forwardRef(function (props, parentRef) {
109
109
  ..._q1,
110
110
  ..._q2,
111
111
  ..._q3
112
- };
112
+ };
113
113
 
114
114
  if (mergedQueries.$timerange !== undefined) {
115
115
  delete mergedQueries.$timerange;
@@ -139,7 +139,7 @@ const ListRender = forwardRef(function (props, parentRef) {
139
139
  }
140
140
  // model.query.pageNum = page;
141
141
  // model.query.pageSize = size;
142
- paginationQueryRef.current = {pageNum: page, pageSize: size};
142
+ paginationQueryRef.current = { pageNum: page, pageSize: size };
143
143
  getList();
144
144
  }
145
145
 
@@ -147,10 +147,13 @@ const ListRender = forwardRef(function (props, parentRef) {
147
147
  if (model && !model.query) {
148
148
  model.query = {};
149
149
  }
150
- model.query.pageNum = 1;
150
+ // model.query.pageNum = 1;
151
+ paginationQueryRef.current = { ...paginationQueryRef.current, pageNum: 1 };
152
+
151
153
  if (model && model.query && !model.query.pageSize) {
152
154
  model.query.pageSize = 10;
153
155
  }
156
+ formQueryRef.current = query;
154
157
  model.query = Object.assign(model.query, query);
155
158
  getList(query);
156
159
  }
@@ -172,7 +175,7 @@ const ListRender = forwardRef(function (props, parentRef) {
172
175
  return model
173
176
  ?.create(_data)
174
177
  .then((res) => {
175
- onSearch();
178
+ getList();
176
179
  message.success(res._message || "新增成功");
177
180
  props.onCreateSuc && props.onCreateSuc(res);
178
181
  })
@@ -274,7 +277,7 @@ const ListRender = forwardRef(function (props, parentRef) {
274
277
  .then((res) => {
275
278
  message.success(res._message || "删除成功");
276
279
  props.onDelSuc && props.onDelSuc(res);
277
- onSearch();
280
+ getList();
278
281
  })
279
282
  .catch((err) => {
280
283
  handleMessage(err._message);
@@ -296,9 +299,9 @@ const ListRender = forwardRef(function (props, parentRef) {
296
299
  queryFormInitialValues={
297
300
  queryFormIsExtendModelQuery
298
301
  ? {
299
- ...queryFormInitialValues,
300
- ...model.query,
301
- }
302
+ ...queryFormInitialValues,
303
+ ...model.query,
304
+ }
302
305
  : queryFormInitialValues
303
306
  }
304
307
  onSearch={onSearch}
@@ -324,8 +327,8 @@ const ListRender = forwardRef(function (props, parentRef) {
324
327
  </div>
325
328
  </div>
326
329
  {Slots.HeaderOthersSuffix && (
327
- <Slots.HeaderOthersSuffix onSearch={onSearch} getList={getList} />
328
- )}
330
+ <Slots.HeaderOthersSuffix onSearch={onSearch} getList={getList} />
331
+ )}
329
332
  <TableRender
330
333
  idKey={idKey}
331
334
  schema={schema?.schema}
@@ -350,7 +353,7 @@ const ListRender = forwardRef(function (props, parentRef) {
350
353
  <Pagination
351
354
  onChange={onPageChange}
352
355
  total={total}
353
- query={model?.query}
356
+ query={{ ...model?.query, ...paginationQueryRef.current }}
354
357
  config={props.paginationConf}
355
358
  i18n={i18n}
356
359
  />