@quansitech/antd-admin 1.1.37 → 1.1.40

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,6 +2,7 @@ import { ProFormColumnsType } from "@ant-design/pro-components";
2
2
  import type { FormSchema } from "@ant-design/pro-form/es/components/SchemaForm/typing";
3
3
  import React from "react";
4
4
  import { FormActionType } from "./Form/Action/types";
5
+ import "./Form.scss";
5
6
  type SubmitRequestType = {
6
7
  url: string;
7
8
  method?: string;
@@ -20,6 +20,7 @@ import customRule from "../lib/customRule";
20
20
  import { ModalContext } from "./ModalContext";
21
21
  import { TableContext } from "./TableContext";
22
22
  import { commonHandler } from "../lib/schemaHandler";
23
+ import "./Form.scss";
23
24
  export default function (props) {
24
25
  var formRef = useRef();
25
26
  var _useState = useState(false),
@@ -149,6 +150,7 @@ export default function (props) {
149
150
  }
150
151
  }, /*#__PURE__*/React.createElement(BetaSchemaForm, {
151
152
  columns: columns,
153
+ className: 'qs-form-container',
152
154
  colProps: props.colProps,
153
155
  readonly: props.readonly,
154
156
  grid: true,
@@ -0,0 +1,15 @@
1
+ .qs-form-container {
2
+ .qs-form-list-form_list {
3
+ .ant-pro-form-list-item {
4
+ border: 1px dashed #cccccc;
5
+ margin-top: 10px;
6
+ border-radius: 5px;
7
+ padding: 10px;
8
+
9
+ .ant-pro-form-list-container {
10
+ display: flex;
11
+ flex-wrap: wrap;
12
+ }
13
+ }
14
+ }
15
+ }
@@ -14,6 +14,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
14
14
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
15
15
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
16
16
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
17
+ // @ts-nocheck
17
18
  import { PageContainer, ProLayout, ProProvider } from "@ant-design/pro-components";
18
19
  import { Button, Dropdown, Menu, Space } from "antd";
19
20
  import { LayoutContext } from "../LayoutContext";
@@ -28,7 +28,7 @@ export default function (_ref) {
28
28
  props: _objectSpread({}, a)
29
29
  };
30
30
  }));
31
- }, []);
31
+ }, [actions]);
32
32
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Space, {
33
33
  wrap: true
34
34
  }, components.map(function (c) {
@@ -33,7 +33,7 @@ import { TabsContext } from "./TabsContext";
33
33
  export default function (props) {
34
34
  var request = /*#__PURE__*/function () {
35
35
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(params, sort, filter) {
36
- var data, only, res;
36
+ var data, res;
37
37
  return _regeneratorRuntime().wrap(function _callee$(_context) {
38
38
  while (1) switch (_context.prev = _context.next) {
39
39
  case 0:
@@ -47,26 +47,25 @@ export default function (props) {
47
47
  }
48
48
  setEditableKeys([]);
49
49
  setEditableValues([]);
50
+ setSelectedRows([]);
50
51
  if (modalContext.inModal) {
51
- _context.next = 9;
52
+ _context.next = 8;
52
53
  break;
53
54
  }
54
55
  // 如果不在 modal 中,则使用 routerNavigateTo
55
- only = ['dataSource', 'pagination', 'extraRenderValues'];
56
- if (tabsContext.inTabs) {
57
- only.push('tabs');
58
- }
56
+
59
57
  routerNavigateTo(searchUrl, {
60
58
  method: 'get',
61
59
  data: data,
62
60
  preserveScroll: true,
63
61
  preserveState: true,
64
- only: only,
65
62
  onSuccess: function onSuccess(e) {
66
63
  var props = e.props;
67
64
  if (tabsContext.inTabs) {
68
65
  props = getValueByPath(props, tabsContext.propsPath);
69
66
  }
67
+ setToolActions(props.actions);
68
+ setColumns(props.columns);
70
69
  setLastQuery(data);
71
70
  setDataSource(postData(props.dataSource));
72
71
  setExtraRenderValues(props.extraRenderValues);
@@ -77,16 +76,16 @@ export default function (props) {
77
76
  }
78
77
  });
79
78
  return _context.abrupt("return");
80
- case 9:
81
- _context.prev = 9;
82
- _context.next = 12;
79
+ case 8:
80
+ _context.prev = 8;
81
+ _context.next = 11;
83
82
  return http.get(searchUrl, {
84
83
  params: data,
85
84
  headers: {
86
85
  'X-Table-Search': '1'
87
86
  }
88
87
  });
89
- case 12:
88
+ case 11:
90
89
  res = _context.sent;
91
90
  if (res.data.pagination) {
92
91
  setPagination(_objectSpread(_objectSpread({}, res.data.pagination), {}, {
@@ -101,36 +100,25 @@ export default function (props) {
101
100
  data: res.data.dataSource || [],
102
101
  success: true
103
102
  });
104
- case 17:
105
- _context.prev = 17;
103
+ case 16:
104
+ _context.prev = 16;
106
105
  setLoading(false);
107
- return _context.finish(17);
108
- case 20:
106
+ return _context.finish(16);
107
+ case 19:
109
108
  case "end":
110
109
  return _context.stop();
111
110
  }
112
- }, _callee, null, [[9,, 17, 20]]);
111
+ }, _callee, null, [[8,, 16, 19]]);
113
112
  }));
114
113
  return function request(_x, _x2, _x3) {
115
114
  return _ref.apply(this, arguments);
116
115
  };
117
116
  }();
118
- var columns = useMemo(function () {
119
- var _cloneDeep;
120
- return (_cloneDeep = cloneDeep(props.columns)) === null || _cloneDeep === void 0 ? void 0 : _cloneDeep.map(function (c) {
121
- c.key = c.dataIndex;
122
- commonHandler(c);
123
- if (container.schemaHandler[c.valueType]) {
124
- return container.schemaHandler[c.valueType](c);
125
- }
126
- return c;
127
- });
128
- }, [props.columns]);
129
117
  var postData = function postData(data) {
130
118
  if (!isArray(data)) {
131
119
  return data;
132
120
  }
133
- columns.map(function (column) {
121
+ realColumns === null || realColumns === void 0 || realColumns.map(function (column) {
134
122
  switch (column.valueType) {
135
123
  case 'dateTime':
136
124
  data = data.map(function (row) {
@@ -195,6 +183,25 @@ export default function (props) {
195
183
  _useState20 = _slicedToArray(_useState19, 2),
196
184
  extraRenderValues = _useState20[0],
197
185
  setExtraRenderValues = _useState20[1];
186
+ var _useState21 = useState(props.actions),
187
+ _useState22 = _slicedToArray(_useState21, 2),
188
+ toolActions = _useState22[0],
189
+ setToolActions = _useState22[1];
190
+ var _useState23 = useState(props.columns),
191
+ _useState24 = _slicedToArray(_useState23, 2),
192
+ columns = _useState24[0],
193
+ setColumns = _useState24[1];
194
+ var realColumns = useMemo(function () {
195
+ var _cloneDeep;
196
+ return (_cloneDeep = cloneDeep(columns)) === null || _cloneDeep === void 0 ? void 0 : _cloneDeep.map(function (c) {
197
+ c.key = c.dataIndex;
198
+ commonHandler(c);
199
+ if (container.schemaHandler[c.valueType]) {
200
+ return container.schemaHandler[c.valueType](c);
201
+ }
202
+ return c;
203
+ });
204
+ }, [columns]);
198
205
  var modalContext = useContext(ModalContext);
199
206
  var tabsContext = useContext(TabsContext);
200
207
  useEffect(function () {
@@ -210,7 +217,7 @@ export default function (props) {
210
217
  if (!searchUrl) {
211
218
  var s = window.location.href;
212
219
  s = s.replace(/page=\d+&?/, '');
213
- columns.filter(function (c) {
220
+ realColumns.filter(function (c) {
214
221
  return c.search !== false;
215
222
  }).map(function (c) {
216
223
  s = s.replace(new RegExp("".concat(c.dataIndex, "=[^&]*&?")), '');
@@ -228,6 +235,7 @@ export default function (props) {
228
235
  }
229
236
  });
230
237
  (_formRef$current = formRef.current) === null || _formRef$current === void 0 || _formRef$current.setFieldsValue(query);
238
+ setLastQuery(query);
231
239
  }
232
240
  }
233
241
  }, []);
@@ -255,7 +263,7 @@ export default function (props) {
255
263
  }, /*#__PURE__*/React.createElement(ProTable, {
256
264
  rowKey: props.rowKey,
257
265
  tableClassName: 'qs-antd-table',
258
- columns: columns,
266
+ columns: realColumns,
259
267
  onDataSourceChange: setDataSource,
260
268
  dataSource: dataSource,
261
269
  pagination: pagination,
@@ -274,7 +282,7 @@ export default function (props) {
274
282
  initialValues: props.defaultSearchValue,
275
283
  onValuesChange: function onValuesChange(changedValues, allValues) {
276
284
  var _formRef$current2;
277
- var submit = columns.filter(function (c) {
285
+ var submit = realColumns.filter(function (c) {
278
286
  if (!c.searchOnChange) {
279
287
  return false;
280
288
  }
@@ -330,7 +338,7 @@ export default function (props) {
330
338
  toolBarRender: function toolBarRender(action) {
331
339
  return [/*#__PURE__*/React.createElement(ToolbarActions, {
332
340
  key: 'actions',
333
- actions: props.actions
341
+ actions: toolActions
334
342
  })];
335
343
  },
336
344
  editable: {
package/dist/lib/http.js CHANGED
@@ -33,6 +33,7 @@ http.interceptors.response.use(function (response) {
33
33
  }
34
34
  return true;
35
35
  };
36
+ // @ts-ignore
36
37
  if ((_response$config$fetc = response.config.fetchOptions) !== null && _response$config$fetc !== void 0 && _response$config$fetc.noHandle) {
37
38
  return response;
38
39
  }
@@ -211,5 +211,22 @@ export var schemaHandler = {
211
211
  });
212
212
  }
213
213
  return schema;
214
+ },
215
+ formList: function formList(schema) {
216
+ schema.columns = schema.columns.map(function (c) {
217
+ commonHandler(c);
218
+ if (container.schemaHandler[c.valueType]) {
219
+ return container.schemaHandler[c.valueType](c);
220
+ }
221
+ return c;
222
+ });
223
+ deepSet(schema, 'fieldProps.className', "qs-form-list-".concat(schema.mode));
224
+ switch (schema.mode) {
225
+ case 'form_list':
226
+ deepSet(schema, 'fieldProps.alwaysShowItemLabel', true);
227
+ break;
228
+ }
229
+ console.log(schema);
230
+ return schema;
214
231
  }
215
232
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quansitech/antd-admin",
3
- "version": "1.1.37",
3
+ "version": "1.1.40",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"
@@ -13,7 +13,6 @@
13
13
  "dependencies": {
14
14
  "@ant-design/pro-components": "^2.7.15",
15
15
  "@inertiajs/react": "^1.2.0 || ^2.0.0",
16
- "antd": "^5.20.5",
17
16
  "antd-img-crop": "^4.23.0",
18
17
  "axios": "^1.7.7",
19
18
  "es-toolkit": "^1.26.1",
@@ -21,6 +20,9 @@
21
20
  "react": "^18.3.0",
22
21
  "react-dom": "^18.3.0"
23
22
  },
23
+ "peerDependencies": {
24
+ "antd": "~5.24.9"
25
+ },
24
26
  "devDependencies": {
25
27
  "@types/react": "^18.3.0",
26
28
  "@types/react-dom": "^18.3.0",