@nokecy/qc-ui 1.1.93 → 1.1.95

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.
@@ -13,6 +13,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
13
13
  import dayjs from 'dayjs';
14
14
  import { cloneDeep } from 'lodash';
15
15
  import { GridifyQueryBuilder, ConditionalOperator as GridifyOp } from 'gridify-client';
16
+ import { findDateQueryColumn, getDateQueryPrecision, getDateQueryProps } from "./queryForm/datePrecision";
16
17
 
17
18
  // Gridify 值转义函数
18
19
  var esc = function esc(v) {
@@ -126,15 +127,21 @@ var getFilter = function getFilter(objectKey, value, colDef) {
126
127
  return "".concat(objectKey, " = ").concat(value);
127
128
  }
128
129
  if (value instanceof Array) {
129
- var _colDef$searchCompone, _colDef$searchCompone2;
130
- var format = (colDef === null || colDef === void 0 || (_colDef$searchCompone = colDef.searchComponentProps) === null || _colDef$searchCompone === void 0 ? void 0 : _colDef$searchCompone.format) || 'YYYY-MM-DD';
131
- var showTime = colDef === null || colDef === void 0 || (_colDef$searchCompone2 = colDef.searchComponentProps) === null || _colDef$searchCompone2 === void 0 ? void 0 : _colDef$searchCompone2.showTime;
130
+ var _getDateQueryProps = getDateQueryProps(colDef),
131
+ _getDateQueryProps$fo = _getDateQueryProps.format,
132
+ format = _getDateQueryProps$fo === void 0 ? 'YYYY-MM-DD' : _getDateQueryProps$fo,
133
+ showTime = _getDateQueryProps.showTime;
132
134
  // 处理时间数组
133
- if (value.length === 2 && (value.every(function (v) {
134
- return dayjs(v, 'YYYY-MM-DD').isValid();
135
- }) || value.every(function (v) {
136
- return dayjs(v, 'YYYY-MM-DD HH:mm:ss').isValid();
137
- }))) {
135
+ if (getDateQueryPrecision(colDef) && value.length === 2) {
136
+ // 允许单边区间;空边界不再被当成多选枚举或无效日期。@author nokecy
137
+ var bounds = value.map(function (v) {
138
+ return v !== null && v !== undefined && v !== '' && dayjs(v).isValid() ? dayjs(v) : null;
139
+ });
140
+ return [bounds[0] ? "".concat(objectKey, " >= ").concat(bounds[0].format(format)) : '', bounds[1] ? "".concat(objectKey, " ").concat(showTime ? '<=' : '<', " ").concat(showTime ? bounds[1].format(format) : bounds[1].add(1, 'days').format(format)) : ''].filter(Boolean).join(',');
141
+ }
142
+ if (value.length === 2 && value.every(function (v) {
143
+ return typeof v !== 'number' && v != null && v !== '' && dayjs(v).isValid();
144
+ })) {
138
145
  return "".concat(objectKey, " >= ").concat(dayjs(value[0]).format(format), " ,") + "".concat(objectKey, " <= ").concat(showTime ? dayjs(value[1]).format(format) : dayjs(value[1]).add(1, 'days').format(format));
139
146
  }
140
147
 
@@ -172,9 +179,7 @@ var convertFilterModel = function convertFilterModel(filterModel, colDefs) {
172
179
  var items = [];
173
180
  Object.keys(filterModel).map(function (key) {
174
181
  var value = filterModel[key];
175
- var colDef = colDefs.find(function (colDef) {
176
- return colDef.field == key;
177
- });
182
+ var colDef = findDateQueryColumn(colDefs, key);
178
183
  if (value !== undefined && value !== null && value !== "") {
179
184
  var filter = getFilter(key, value, colDef);
180
185
  if (filter && filter != "") {
@@ -225,7 +225,19 @@ var ArrayTableInner = observer(function (props) {
225
225
  */
226
226
  useEffect(function () {
227
227
  // 检查必要条件
228
- if (!props.gridKey || !gridApiState || !currentScheme) return;
228
+ if (!props.gridKey || !gridApiState) return;
229
+ // 方案被重置或删除后即时恢复基础列,保留表单实例与未保存的行值。@author nokecy
230
+ if (!currentScheme) {
231
+ if (lastAppliedSchemeRef.current.id) {
232
+ gridApiState.setGridOption('columnDefs', stableColumnDefs);
233
+ gridApiState.resetColumnState();
234
+ lastAppliedSchemeRef.current = {
235
+ id: null,
236
+ updatedAt: undefined
237
+ };
238
+ }
239
+ return;
240
+ }
229
241
  if (!currentScheme.columnConfig || currentScheme.columnConfig.length === 0) return;
230
242
 
231
243
  // 【关键修复】检查方案是否真正变化(比对 ID 和 updatedAt)
@@ -260,6 +272,11 @@ var ArrayTableInner = observer(function (props) {
260
272
  state: columnState,
261
273
  applyOrder: true
262
274
  });
275
+ // 在实际应用后立即记账,重置无需等后续 RAF 完成。@author nokecy
276
+ lastAppliedSchemeRef.current = {
277
+ id: currentScheme.id,
278
+ updatedAt: currentScheme.updatedAt
279
+ };
263
280
  }).then(function () {
264
281
  // 等待 Grid 状态稳定(使用 requestAnimationFrame 而非固定延迟)
265
282
  return new Promise(function (resolve) {
@@ -23,7 +23,7 @@ export var ARRAY_TABLE_ROW_HEIGHT = 38;
23
23
  */
24
24
  var arrayTableCellFit = createPart({
25
25
  feature: 'arrayTableCellFit',
26
- css: "\n .ag-cell .ag-cell-wrapper { height: 100%; }\n .ag-cell .ant-formily-item { margin-bottom: 0; }\n .ag-cell .ant-formily-item-help { position: absolute; }\n .ag-header-cell.qc-array-table-required .ag-header-cell-text::before {\n content: '*';\n color: var(--ag-invalid-color);\n margin-inline-end: 4px;\n }\n "
26
+ css: "\n .ag-cell .ag-cell-wrapper { height: 100%; }\n .ag-cell .ant-formily-item { margin-bottom: 0; }\n /* \u6807\u9898\u548C\u8BF4\u660E\u7531\u5217\u5934\u627F\u8F7D\uFF0ClabelWidth:0 \u672C\u8EAB\u4E0D\u4F1A\u9690\u85CF\u5B57\u6BB5\u6807\u9898\u3002@author nokecy */\n .ag-cell .ant-formily-item-label { display: none; }\n .ag-cell .ant-formily-item-control { flex: 1; min-width: 0; width: 100%; }\n .ag-cell .ant-formily-item-help { position: absolute; }\n .ag-header-cell.qc-array-table-required .ag-header-cell-text::before {\n content: '*';\n color: var(--ag-invalid-color);\n margin-inline-end: 4px;\n }\n "
27
27
  });
28
28
 
29
29
  /** 根据当前 antd 主题生成编辑态或阅读态明细表格主题。@author nokecy */
@@ -700,7 +700,7 @@ var applyNumberInputDefaults = function applyNumberInputDefaults(dataField) {
700
700
  var buildArrayTableColumns = function buildArrayTableColumns(dataSource, field, sources) {
701
701
  var arrayPattern = field === null || field === void 0 ? void 0 : field.pattern;
702
702
  return sources.reduce(function (buf, _ref7, key) {
703
- var _ref8, _getReadOnlyFormatter, _dataField$xComponen, _dataField$xComponen2;
703
+ var _dataField$xDecorato, _ref8, _getReadOnlyFormatter, _dataField$xComponen, _dataField$xComponen2;
704
704
  var name = _ref7.name,
705
705
  columnProps = _ref7.columnProps,
706
706
  schema = _ref7.schema,
@@ -736,6 +736,9 @@ var buildArrayTableColumns = function buildArrayTableColumns(dataSource, field,
736
736
  // 这里产出的仍是扁平列定义。@author nokecy
737
737
  var isSequenceColumn = containsIndexComponent(schema);
738
738
  var dataField = findDataFieldSchema(schema, name);
739
+ // 单元格不重复显示 FormItem 标签,字段说明统一由列头提示承载。@author nokecy
740
+ var fieldTooltip = dataField === null || dataField === void 0 || (_dataField$xDecorato = dataField['x-decorator-props']) === null || _dataField$xDecorato === void 0 ? void 0 : _dataField$xDecorato.tooltip;
741
+ if (!base.headerTooltip && typeof fieldTooltip === 'string' && !fieldTooltip.includes('{{')) base.headerTooltip = fieldTooltip;
739
742
  var readOnly = isColumnReadOnlyEligible(arrayPattern, dataField, columnProps);
740
743
  var emit = function emit(colDef) {
741
744
  return buf.concat(markHeaderGroup(isSequenceColumn ? withDisplaySequencePolicy(colDef) : withRequiredColumnHeader(colDef, isRequiredColumn(dataField, requiredMark), readOnly), isSequenceColumn ? undefined : headerGroup));