@nokecy/qc-ui 1.1.65 → 1.1.66

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.
@@ -12,6 +12,7 @@ var _antd = require("antd");
12
12
  var _classnames = _interopRequireDefault(require("classnames"));
13
13
  var _react2 = _interopRequireWildcard(require("react"));
14
14
  var _queryForm = _interopRequireDefault(require("./queryForm"));
15
+ var _schemaKey = require("./schemaKey");
15
16
  var _boolSelect = _interopRequireDefault(require("../_utils/boolSelect"));
16
17
  require("./index.less");
17
18
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
@@ -203,8 +204,19 @@ var FormRender = function FormRender(props) {
203
204
  // 【新增】用于追踪是否已完成首次初始化
204
205
  var initializedRef = (0, _react2.useRef)(false);
205
206
  (0, _react2.useEffect)(function () {
207
+ var _new_schema$propertie, _new_schema$propertie2;
206
208
  var new_schema = getSchema(onReset);
207
209
  setSchema(new_schema);
210
+ // Formily 只在字段首次创建时读取 schema:已有查询项要把新标题、组件属性(如下拉选项)写回字段。@author nokecy
211
+ Object.entries((_new_schema$propertie = (_new_schema$propertie2 = new_schema.properties) === null || _new_schema$propertie2 === void 0 || (_new_schema$propertie2 = _new_schema$propertie2.queryForm) === null || _new_schema$propertie2 === void 0 ? void 0 : _new_schema$propertie2.properties) !== null && _new_schema$propertie !== void 0 ? _new_schema$propertie : {}).forEach(function (_ref) {
212
+ var _ref2 = _slicedToArray(_ref, 2),
213
+ name = _ref2[0],
214
+ fieldSchema = _ref2[1];
215
+ form.query(name).take(function (field) {
216
+ field.title = fieldSchema.title;
217
+ field.setComponentProps(fieldSchema['x-component-props']);
218
+ });
219
+ });
208
220
 
209
221
  // 【修复】在 schema 设置完成后调用 onInit
210
222
  // 使用 setTimeout 确保 Formily 有时间处理 schema 并应用默认值
@@ -217,11 +229,7 @@ var FormRender = function FormRender(props) {
217
229
  }, 0);
218
230
  });
219
231
  }
220
- }, [columnStates === null || columnStates === void 0 ? void 0 : columnStates.map(function (c) {
221
- return c.colId;
222
- }).join('|'), colDefs === null || colDefs === void 0 ? void 0 : colDefs.map(function (c) {
223
- return "".concat(c.field, "|").concat(c.headerName);
224
- }).join('|')]);
232
+ }, [(0, _schemaKey.queryFormSchemaKey)(columnStates, colDefs)]);
225
233
  return /*#__PURE__*/_react2.default.createElement("div", {
226
234
  className: (0, _classnames.default)(className, "ag-grid-table-search ag-grid-table-search-query-filter"),
227
235
  style: {
@@ -0,0 +1,20 @@
1
+ type ColumnStateLike = {
2
+ colId?: string | null;
3
+ };
4
+ type QueryColumnLike = {
5
+ field?: string;
6
+ headerName?: string;
7
+ searchComponentProps?: {
8
+ options?: readonly {
9
+ value?: unknown;
10
+ label?: unknown;
11
+ }[];
12
+ };
13
+ };
14
+ /**
15
+ * 查询区 schema 的重建键:列(id、字段、标题)或下拉选项变了才重建。
16
+ * 下拉选项常在首帧之后才到(如从基础资料接口取名称),只看列与标题时选项停在首帧。
17
+ * @author nokecy
18
+ */
19
+ export declare const queryFormSchemaKey: (columnStates?: readonly ColumnStateLike[] | null, colDefs?: readonly QueryColumnLike[] | null) => string;
20
+ export {};
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.queryFormSchemaKey = void 0;
7
+ var optionsSignature = function optionsSignature(options) {
8
+ return Array.isArray(options) ? options.map(function (option) {
9
+ return "".concat(String(option === null || option === void 0 ? void 0 : option.value), "=").concat(String(option === null || option === void 0 ? void 0 : option.label));
10
+ }).join(',') : '';
11
+ };
12
+
13
+ /**
14
+ * 查询区 schema 的重建键:列(id、字段、标题)或下拉选项变了才重建。
15
+ * 下拉选项常在首帧之后才到(如从基础资料接口取名称),只看列与标题时选项停在首帧。
16
+ * @author nokecy
17
+ */
18
+ var queryFormSchemaKey = exports.queryFormSchemaKey = function queryFormSchemaKey(columnStates, colDefs) {
19
+ return [columnStates === null || columnStates === void 0 ? void 0 : columnStates.map(function (column) {
20
+ return column.colId;
21
+ }).join('|'), colDefs === null || colDefs === void 0 ? void 0 : colDefs.map(function (column) {
22
+ var _column$searchCompone;
23
+ return "".concat(column.field, "|").concat(column.headerName, "|").concat(optionsSignature((_column$searchCompone = column.searchComponentProps) === null || _column$searchCompone === void 0 ? void 0 : _column$searchCompone.options));
24
+ }).join('|')].join('#');
25
+ };
@@ -18,6 +18,7 @@ import { Button, theme } from 'antd';
18
18
  import classNames from 'classnames';
19
19
  import React, { useEffect, useMemo, useRef, useState } from 'react';
20
20
  import QueryForm from "./queryForm";
21
+ import { queryFormSchemaKey } from "./schemaKey";
21
22
  import BoolSelect from "../_utils/boolSelect";
22
23
  import "./index.less";
23
24
  var FormRender = function FormRender(props) {
@@ -195,8 +196,19 @@ var FormRender = function FormRender(props) {
195
196
  // 【新增】用于追踪是否已完成首次初始化
196
197
  var initializedRef = useRef(false);
197
198
  useEffect(function () {
199
+ var _new_schema$propertie, _new_schema$propertie2;
198
200
  var new_schema = getSchema(onReset);
199
201
  setSchema(new_schema);
202
+ // Formily 只在字段首次创建时读取 schema:已有查询项要把新标题、组件属性(如下拉选项)写回字段。@author nokecy
203
+ Object.entries((_new_schema$propertie = (_new_schema$propertie2 = new_schema.properties) === null || _new_schema$propertie2 === void 0 || (_new_schema$propertie2 = _new_schema$propertie2.queryForm) === null || _new_schema$propertie2 === void 0 ? void 0 : _new_schema$propertie2.properties) !== null && _new_schema$propertie !== void 0 ? _new_schema$propertie : {}).forEach(function (_ref) {
204
+ var _ref2 = _slicedToArray(_ref, 2),
205
+ name = _ref2[0],
206
+ fieldSchema = _ref2[1];
207
+ form.query(name).take(function (field) {
208
+ field.title = fieldSchema.title;
209
+ field.setComponentProps(fieldSchema['x-component-props']);
210
+ });
211
+ });
200
212
 
201
213
  // 【修复】在 schema 设置完成后调用 onInit
202
214
  // 使用 setTimeout 确保 Formily 有时间处理 schema 并应用默认值
@@ -209,11 +221,7 @@ var FormRender = function FormRender(props) {
209
221
  }, 0);
210
222
  });
211
223
  }
212
- }, [columnStates === null || columnStates === void 0 ? void 0 : columnStates.map(function (c) {
213
- return c.colId;
214
- }).join('|'), colDefs === null || colDefs === void 0 ? void 0 : colDefs.map(function (c) {
215
- return "".concat(c.field, "|").concat(c.headerName);
216
- }).join('|')]);
224
+ }, [queryFormSchemaKey(columnStates, colDefs)]);
217
225
  return /*#__PURE__*/React.createElement("div", {
218
226
  className: classNames(className, "ag-grid-table-search ag-grid-table-search-query-filter"),
219
227
  style: {
@@ -0,0 +1,20 @@
1
+ type ColumnStateLike = {
2
+ colId?: string | null;
3
+ };
4
+ type QueryColumnLike = {
5
+ field?: string;
6
+ headerName?: string;
7
+ searchComponentProps?: {
8
+ options?: readonly {
9
+ value?: unknown;
10
+ label?: unknown;
11
+ }[];
12
+ };
13
+ };
14
+ /**
15
+ * 查询区 schema 的重建键:列(id、字段、标题)或下拉选项变了才重建。
16
+ * 下拉选项常在首帧之后才到(如从基础资料接口取名称),只看列与标题时选项停在首帧。
17
+ * @author nokecy
18
+ */
19
+ export declare const queryFormSchemaKey: (columnStates?: readonly ColumnStateLike[] | null, colDefs?: readonly QueryColumnLike[] | null) => string;
20
+ export {};
@@ -0,0 +1,19 @@
1
+ var optionsSignature = function optionsSignature(options) {
2
+ return Array.isArray(options) ? options.map(function (option) {
3
+ return "".concat(String(option === null || option === void 0 ? void 0 : option.value), "=").concat(String(option === null || option === void 0 ? void 0 : option.label));
4
+ }).join(',') : '';
5
+ };
6
+
7
+ /**
8
+ * 查询区 schema 的重建键:列(id、字段、标题)或下拉选项变了才重建。
9
+ * 下拉选项常在首帧之后才到(如从基础资料接口取名称),只看列与标题时选项停在首帧。
10
+ * @author nokecy
11
+ */
12
+ export var queryFormSchemaKey = function queryFormSchemaKey(columnStates, colDefs) {
13
+ return [columnStates === null || columnStates === void 0 ? void 0 : columnStates.map(function (column) {
14
+ return column.colId;
15
+ }).join('|'), colDefs === null || colDefs === void 0 ? void 0 : colDefs.map(function (column) {
16
+ var _column$searchCompone;
17
+ return "".concat(column.field, "|").concat(column.headerName, "|").concat(optionsSignature((_column$searchCompone = column.searchComponentProps) === null || _column$searchCompone === void 0 ? void 0 : _column$searchCompone.options));
18
+ }).join('|')].join('#');
19
+ };