@ys-knife-crud/vue 0.0.15 → 0.0.16
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/dist/index.cjs +38 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -6
- package/dist/index.d.ts +11 -6
- package/dist/index.js +20 -5
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -413,7 +413,7 @@ function useExportExcel({
|
|
|
413
413
|
return (0, import_core.createConsoleExportApiFunc)()();
|
|
414
414
|
}
|
|
415
415
|
function exportRowValues(row) {
|
|
416
|
-
return columns.value.map((c) =>
|
|
416
|
+
return columns.value.map((c) => (0, import_core.formatCellValue)(c, row));
|
|
417
417
|
}
|
|
418
418
|
async function doExport(scope) {
|
|
419
419
|
exportDialogVisible.value = false;
|
|
@@ -516,6 +516,7 @@ function useExportExcel({
|
|
|
516
516
|
|
|
517
517
|
// src/table/collectData.ts
|
|
518
518
|
var import_vue6 = require("vue");
|
|
519
|
+
var import_core2 = require("@ys-knife-crud/core");
|
|
519
520
|
function useCollectData({
|
|
520
521
|
props,
|
|
521
522
|
selectable,
|
|
@@ -525,6 +526,7 @@ function useCollectData({
|
|
|
525
526
|
totalKnown,
|
|
526
527
|
collectPageSize,
|
|
527
528
|
hasMorePage,
|
|
529
|
+
columns,
|
|
528
530
|
pageScopeLabel
|
|
529
531
|
}) {
|
|
530
532
|
function maxCount() {
|
|
@@ -554,6 +556,17 @@ function useCollectData({
|
|
|
554
556
|
return opts;
|
|
555
557
|
});
|
|
556
558
|
const collectDialogVisible = (0, import_vue6.ref)(false);
|
|
559
|
+
const formatValues = (0, import_vue6.ref)(true);
|
|
560
|
+
function formatRows(rows) {
|
|
561
|
+
if (!formatValues.value) return rows;
|
|
562
|
+
const cols = columns.value.filter((c) => c.formatter || (0, import_core2.getDefaultFormatter)(c));
|
|
563
|
+
if (cols.length === 0) return rows;
|
|
564
|
+
return rows.map((row) => {
|
|
565
|
+
const out = { ...row };
|
|
566
|
+
for (const c of cols) out[c.propertyPath] = (0, import_core2.formatCellValue)(c, row);
|
|
567
|
+
return out;
|
|
568
|
+
});
|
|
569
|
+
}
|
|
557
570
|
const collecting = (0, import_vue6.ref)(false);
|
|
558
571
|
const collectFetched = (0, import_vue6.ref)(0);
|
|
559
572
|
const collectTotal = (0, import_vue6.ref)(0);
|
|
@@ -583,8 +596,9 @@ function useCollectData({
|
|
|
583
596
|
return Math.min(100, Math.round(collectFetched.value / collectTotal.value * 100));
|
|
584
597
|
return collectFetched.value > 0 ? 99 : 0;
|
|
585
598
|
});
|
|
586
|
-
function onCollectClick() {
|
|
599
|
+
function onCollectClick(options) {
|
|
587
600
|
if (!props.collectorFunc) return;
|
|
601
|
+
formatValues.value = options?.format !== false;
|
|
588
602
|
const enabled = collectOptions.value.filter((o) => !o.disabled);
|
|
589
603
|
if (enabled.length === 1) {
|
|
590
604
|
void doCollect(enabled[0].value);
|
|
@@ -604,7 +618,7 @@ function useCollectData({
|
|
|
604
618
|
const max = maxCount();
|
|
605
619
|
const truncated = source.length > max;
|
|
606
620
|
const rows = (truncated ? source.slice(0, max) : source).slice();
|
|
607
|
-
await collector(rows, { scope, truncated, maxCount: max });
|
|
621
|
+
await collector(formatRows(rows), { scope, truncated, maxCount: max });
|
|
608
622
|
}
|
|
609
623
|
async function collectAllStreaming(collector) {
|
|
610
624
|
collecting.value = true;
|
|
@@ -652,7 +666,7 @@ function useCollectData({
|
|
|
652
666
|
collectAbort = null;
|
|
653
667
|
}
|
|
654
668
|
if (collectCancelled) return;
|
|
655
|
-
await collector(collected, { scope: "all", truncated, maxCount: max });
|
|
669
|
+
await collector(formatRows(collected), { scope: "all", truncated, maxCount: max });
|
|
656
670
|
}
|
|
657
671
|
function cancelCollect() {
|
|
658
672
|
collectCancelled = true;
|
|
@@ -1232,8 +1246,8 @@ function useEnumFilterItem(props) {
|
|
|
1232
1246
|
// src/advancedFilter/advancedFilter.ts
|
|
1233
1247
|
var import_vue15 = require("vue");
|
|
1234
1248
|
var import_ys_knife_query6 = require("ys.knife.query.js");
|
|
1235
|
-
var import_core2 = require("@ys-knife-crud/core");
|
|
1236
1249
|
var import_core3 = require("@ys-knife-crud/core");
|
|
1250
|
+
var import_core4 = require("@ys-knife-crud/core");
|
|
1237
1251
|
function useAdvancedFilter(props) {
|
|
1238
1252
|
let seq = 0;
|
|
1239
1253
|
function nextId(prefix) {
|
|
@@ -1244,7 +1258,7 @@ function useAdvancedFilter(props) {
|
|
|
1244
1258
|
for (const col of props.columns) {
|
|
1245
1259
|
map.set(
|
|
1246
1260
|
col.propertyPath,
|
|
1247
|
-
(0,
|
|
1261
|
+
(0, import_core4.inferColumnFieldType)(col, props.optionSources?.[col.propertyPath] !== void 0)
|
|
1248
1262
|
);
|
|
1249
1263
|
}
|
|
1250
1264
|
return map;
|
|
@@ -1253,12 +1267,12 @@ function useAdvancedFilter(props) {
|
|
|
1253
1267
|
return fieldTypeMap.value.get(propertyPath) ?? "string";
|
|
1254
1268
|
}
|
|
1255
1269
|
function operatorsOf(propertyPath) {
|
|
1256
|
-
return
|
|
1270
|
+
return import_core4.FIELD_TYPE_OPERATORS[fieldTypeOf(propertyPath)];
|
|
1257
1271
|
}
|
|
1258
1272
|
function emptyValue(type, op) {
|
|
1259
|
-
if ((0,
|
|
1260
|
-
if ((0,
|
|
1261
|
-
if ((0,
|
|
1273
|
+
if ((0, import_core3.isNullOperator)(op)) return null;
|
|
1274
|
+
if ((0, import_core4.isRangeOperator)(op)) return [null, null];
|
|
1275
|
+
if ((0, import_core4.isMultiValueOperator)(op)) return [];
|
|
1262
1276
|
void type;
|
|
1263
1277
|
return null;
|
|
1264
1278
|
}
|
|
@@ -1266,7 +1280,7 @@ function useAdvancedFilter(props) {
|
|
|
1266
1280
|
const first = props.columns[0];
|
|
1267
1281
|
const propertyPath = first?.propertyPath ?? "";
|
|
1268
1282
|
const type = first ? fieldTypeOf(propertyPath) : "string";
|
|
1269
|
-
const op = (0,
|
|
1283
|
+
const op = (0, import_core4.defaultOperatorForType)(type);
|
|
1270
1284
|
return {
|
|
1271
1285
|
id: nextId("leaf"),
|
|
1272
1286
|
propertyPath,
|
|
@@ -1289,7 +1303,7 @@ function useAdvancedFilter(props) {
|
|
|
1289
1303
|
function findNode2(id, group = rootGroup.value) {
|
|
1290
1304
|
for (const child of group.children) {
|
|
1291
1305
|
if (child.id === id) return child;
|
|
1292
|
-
if ((0,
|
|
1306
|
+
if ((0, import_core3.isConditionGroup)(child)) {
|
|
1293
1307
|
const found = findNode2(id, child);
|
|
1294
1308
|
if (found) return found;
|
|
1295
1309
|
}
|
|
@@ -1299,7 +1313,7 @@ function useAdvancedFilter(props) {
|
|
|
1299
1313
|
function findParentGroup(id, group = rootGroup.value) {
|
|
1300
1314
|
for (const child of group.children) {
|
|
1301
1315
|
if (child.id === id) return group;
|
|
1302
|
-
if ((0,
|
|
1316
|
+
if ((0, import_core3.isConditionGroup)(child)) {
|
|
1303
1317
|
const found = findParentGroup(id, child);
|
|
1304
1318
|
if (found) return found;
|
|
1305
1319
|
}
|
|
@@ -1308,7 +1322,7 @@ function useAdvancedFilter(props) {
|
|
|
1308
1322
|
}
|
|
1309
1323
|
function addLeaf(parentId, index) {
|
|
1310
1324
|
const parent = parentId === rootGroup.value.id ? rootGroup.value : findNode2(parentId);
|
|
1311
|
-
if (!parent || !(0,
|
|
1325
|
+
if (!parent || !(0, import_core3.isConditionGroup)(parent)) return;
|
|
1312
1326
|
const leaf = newLeaf();
|
|
1313
1327
|
if (typeof index === "number") {
|
|
1314
1328
|
parent.children.splice(index, 0, leaf);
|
|
@@ -1318,7 +1332,7 @@ function useAdvancedFilter(props) {
|
|
|
1318
1332
|
}
|
|
1319
1333
|
function addNestedGroup(parentId, index) {
|
|
1320
1334
|
const parent = parentId === rootGroup.value.id ? rootGroup.value : findNode2(parentId);
|
|
1321
|
-
if (!parent || !(0,
|
|
1335
|
+
if (!parent || !(0, import_core3.isConditionGroup)(parent)) return;
|
|
1322
1336
|
const childCombinator = parent.combinator === "and" ? "or" : "and";
|
|
1323
1337
|
const sub = newGroup(childCombinator);
|
|
1324
1338
|
if (typeof index === "number") {
|
|
@@ -1336,31 +1350,31 @@ function useAdvancedFilter(props) {
|
|
|
1336
1350
|
}
|
|
1337
1351
|
function changeField(id, propertyPath) {
|
|
1338
1352
|
const node = findNode2(id);
|
|
1339
|
-
if (!node || (0,
|
|
1353
|
+
if (!node || (0, import_core3.isConditionGroup)(node)) return;
|
|
1340
1354
|
node.propertyPath = propertyPath;
|
|
1341
1355
|
const type = fieldTypeOf(propertyPath);
|
|
1342
|
-
node.op = (0,
|
|
1356
|
+
node.op = (0, import_core4.defaultOperatorForType)(type);
|
|
1343
1357
|
node.value = emptyValue(type, node.op);
|
|
1344
1358
|
}
|
|
1345
1359
|
function changeOperator(id, op) {
|
|
1346
1360
|
const node = findNode2(id);
|
|
1347
|
-
if (!node || (0,
|
|
1361
|
+
if (!node || (0, import_core3.isConditionGroup)(node)) return;
|
|
1348
1362
|
node.op = op;
|
|
1349
1363
|
node.value = emptyValue(fieldTypeOf(node.propertyPath), op);
|
|
1350
1364
|
}
|
|
1351
1365
|
function setGroupCombinator(groupId, comb) {
|
|
1352
1366
|
const node = groupId === rootGroup.value.id ? rootGroup.value : findNode2(groupId);
|
|
1353
|
-
if (node && (0,
|
|
1367
|
+
if (node && (0, import_core3.isConditionGroup)(node)) node.combinator = comb;
|
|
1354
1368
|
}
|
|
1355
1369
|
function isConditionEmpty(row) {
|
|
1356
|
-
if ((0,
|
|
1370
|
+
if ((0, import_core3.isNullOperator)(row.op)) return false;
|
|
1357
1371
|
const type = fieldTypeOf(row.propertyPath);
|
|
1358
1372
|
const v = row.value;
|
|
1359
|
-
if ((0,
|
|
1373
|
+
if ((0, import_core4.isRangeOperator)(row.op)) {
|
|
1360
1374
|
if (!Array.isArray(v) || v.length !== 2) return true;
|
|
1361
1375
|
return v[0] === null || v[0] === void 0 || v[0] === "" || v[1] === null || v[1] === void 0 || v[1] === "";
|
|
1362
1376
|
}
|
|
1363
|
-
if ((0,
|
|
1377
|
+
if ((0, import_core4.isMultiValueOperator)(row.op)) {
|
|
1364
1378
|
return !Array.isArray(v) || v.length === 0;
|
|
1365
1379
|
}
|
|
1366
1380
|
if (type === "boolean") {
|
|
@@ -1420,7 +1434,7 @@ function useAdvancedFilter(props) {
|
|
|
1420
1434
|
);
|
|
1421
1435
|
}
|
|
1422
1436
|
function buildNodeFilter(node) {
|
|
1423
|
-
if ((0,
|
|
1437
|
+
if ((0, import_core3.isConditionGroup)(node)) {
|
|
1424
1438
|
const items = node.children.map(buildNodeFilter).filter((f) => f !== null);
|
|
1425
1439
|
if (items.length === 0) return null;
|
|
1426
1440
|
if (items.length === 1) return items[0];
|
|
@@ -1454,7 +1468,7 @@ function useAdvancedFilter(props) {
|
|
|
1454
1468
|
changeOperator,
|
|
1455
1469
|
setGroupCombinator,
|
|
1456
1470
|
isConditionEmpty,
|
|
1457
|
-
isConditionGroup:
|
|
1471
|
+
isConditionGroup: import_core3.isConditionGroup,
|
|
1458
1472
|
filter: filterInfo,
|
|
1459
1473
|
reset
|
|
1460
1474
|
};
|