sctj-components 1.0.62 → 1.0.64
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/lib/sctj-components.es.js +185 -27
- package/lib/sctj-components.umd.js +1 -1
- package/lib/style.css +1 -1
- package/package.json +1 -1
|
@@ -1290,7 +1290,7 @@ const _sfc_main$p = {
|
|
|
1290
1290
|
};
|
|
1291
1291
|
}
|
|
1292
1292
|
};
|
|
1293
|
-
const
|
|
1293
|
+
const index_vue_vue_type_style_index_0_scoped_7b45925b_lang = "";
|
|
1294
1294
|
const _hoisted_1$i = { class: "el-tree-select" };
|
|
1295
1295
|
const _sfc_main$o = {
|
|
1296
1296
|
__name: "index",
|
|
@@ -1311,9 +1311,22 @@ const _sfc_main$o = {
|
|
|
1311
1311
|
return false;
|
|
1312
1312
|
}
|
|
1313
1313
|
},
|
|
1314
|
+
multiple: {
|
|
1315
|
+
type: Boolean,
|
|
1316
|
+
default: false
|
|
1317
|
+
},
|
|
1318
|
+
checkStrictly: {
|
|
1319
|
+
type: Boolean,
|
|
1320
|
+
default: false
|
|
1321
|
+
},
|
|
1322
|
+
valueFormat: {
|
|
1323
|
+
type: String,
|
|
1324
|
+
default: "string",
|
|
1325
|
+
validator: (value) => ["array", "string"].includes(value)
|
|
1326
|
+
},
|
|
1314
1327
|
modelValue: {
|
|
1315
|
-
type: [String, Number],
|
|
1316
|
-
default:
|
|
1328
|
+
type: [String, Number, Array],
|
|
1329
|
+
default: () => null
|
|
1317
1330
|
},
|
|
1318
1331
|
options: {
|
|
1319
1332
|
type: Array,
|
|
@@ -1328,36 +1341,127 @@ const _sfc_main$o = {
|
|
|
1328
1341
|
setup(__props, { emit }) {
|
|
1329
1342
|
const props = __props;
|
|
1330
1343
|
const { proxy } = getCurrentInstance();
|
|
1344
|
+
const TREE_OPTION_VALUE = "__SCTJ_TREE_SELECT__";
|
|
1345
|
+
function stringToArray(str) {
|
|
1346
|
+
if (typeof str !== "string")
|
|
1347
|
+
return [];
|
|
1348
|
+
return str.split(",").map((item) => item.trim()).filter((item) => item !== "");
|
|
1349
|
+
}
|
|
1350
|
+
function arrayToString(arr) {
|
|
1351
|
+
if (!Array.isArray(arr))
|
|
1352
|
+
return "";
|
|
1353
|
+
return arr.join(",");
|
|
1354
|
+
}
|
|
1331
1355
|
const valueId = computed$1({
|
|
1332
|
-
get: () =>
|
|
1356
|
+
get: () => {
|
|
1357
|
+
if (props.multiple) {
|
|
1358
|
+
if (Array.isArray(props.modelValue)) {
|
|
1359
|
+
return props.modelValue;
|
|
1360
|
+
} else if (typeof props.modelValue === "string") {
|
|
1361
|
+
return stringToArray(props.modelValue);
|
|
1362
|
+
} else if (props.modelValue !== null && props.modelValue !== void 0 && props.modelValue !== "") {
|
|
1363
|
+
return [props.modelValue];
|
|
1364
|
+
} else {
|
|
1365
|
+
return [];
|
|
1366
|
+
}
|
|
1367
|
+
} else {
|
|
1368
|
+
if (props.modelValue === null || props.modelValue === void 0 || props.modelValue === "") {
|
|
1369
|
+
return "";
|
|
1370
|
+
}
|
|
1371
|
+
return String(props.modelValue);
|
|
1372
|
+
}
|
|
1373
|
+
},
|
|
1333
1374
|
set: (val) => {
|
|
1334
|
-
|
|
1375
|
+
if (props.multiple) {
|
|
1376
|
+
if (props.valueFormat === "string") {
|
|
1377
|
+
emit("update:modelValue", arrayToString(val));
|
|
1378
|
+
} else {
|
|
1379
|
+
emit("update:modelValue", val);
|
|
1380
|
+
}
|
|
1381
|
+
} else {
|
|
1382
|
+
emit("update:modelValue", val === null || val === void 0 || val === "" ? "" : String(val));
|
|
1383
|
+
}
|
|
1335
1384
|
}
|
|
1336
1385
|
});
|
|
1337
1386
|
const valueTitle = ref$1("");
|
|
1387
|
+
const selectedOptions = ref$1([]);
|
|
1338
1388
|
const defaultExpandedKey = ref$1([]);
|
|
1339
1389
|
function initHandle() {
|
|
1340
1390
|
nextTick(() => {
|
|
1391
|
+
if (!proxy.$refs.selectTree)
|
|
1392
|
+
return;
|
|
1341
1393
|
const selectedValue = valueId.value;
|
|
1342
|
-
if (
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1394
|
+
if (props.multiple) {
|
|
1395
|
+
if (Array.isArray(selectedValue) && selectedValue.length > 0) {
|
|
1396
|
+
const titles = [];
|
|
1397
|
+
const opts = [];
|
|
1398
|
+
const expandedKeys = [];
|
|
1399
|
+
selectedValue.forEach((val) => {
|
|
1400
|
+
const node = proxy.$refs.selectTree.getNode(val);
|
|
1401
|
+
if (node) {
|
|
1402
|
+
const label = node.data[props.objMap.label];
|
|
1403
|
+
titles.push(label);
|
|
1404
|
+
opts.push({ value: val, label });
|
|
1405
|
+
expandedKeys.push(val);
|
|
1406
|
+
} else {
|
|
1407
|
+
opts.push({ value: val, label: String(val) });
|
|
1408
|
+
}
|
|
1409
|
+
});
|
|
1410
|
+
valueTitle.value = titles.join(",");
|
|
1411
|
+
selectedOptions.value = opts;
|
|
1412
|
+
proxy.$refs.selectTree.setCheckedKeys(selectedValue);
|
|
1413
|
+
defaultExpandedKey.value = expandedKeys;
|
|
1414
|
+
} else {
|
|
1415
|
+
valueTitle.value = "";
|
|
1416
|
+
selectedOptions.value = [];
|
|
1417
|
+
proxy.$refs.selectTree.setCheckedKeys([]);
|
|
1418
|
+
defaultExpandedKey.value = [];
|
|
1348
1419
|
}
|
|
1349
1420
|
} else {
|
|
1350
|
-
|
|
1421
|
+
if (selectedValue !== null && typeof selectedValue !== "undefined" && selectedValue !== "") {
|
|
1422
|
+
const node = proxy.$refs.selectTree.getNode(selectedValue);
|
|
1423
|
+
if (node) {
|
|
1424
|
+
valueTitle.value = node.data[props.objMap.label];
|
|
1425
|
+
proxy.$refs.selectTree.setCurrentKey(selectedValue);
|
|
1426
|
+
defaultExpandedKey.value = [selectedValue];
|
|
1427
|
+
}
|
|
1428
|
+
} else {
|
|
1429
|
+
clearHandle();
|
|
1430
|
+
}
|
|
1351
1431
|
}
|
|
1352
1432
|
});
|
|
1353
1433
|
}
|
|
1354
|
-
function handleNodeClick(node) {
|
|
1355
|
-
|
|
1356
|
-
|
|
1434
|
+
function handleNodeClick(data, node) {
|
|
1435
|
+
if (props.multiple) {
|
|
1436
|
+
return;
|
|
1437
|
+
}
|
|
1438
|
+
valueTitle.value = data[props.objMap.label];
|
|
1439
|
+
const nodeValue = data[props.objMap.value];
|
|
1440
|
+
valueId.value = nodeValue === null || nodeValue === void 0 ? "" : String(nodeValue);
|
|
1357
1441
|
defaultExpandedKey.value = [];
|
|
1358
1442
|
proxy.$refs.treeSelect.blur();
|
|
1359
1443
|
selectFilterData("");
|
|
1360
1444
|
}
|
|
1445
|
+
function handleCheck(data, checkedInfo) {
|
|
1446
|
+
if (!props.multiple)
|
|
1447
|
+
return;
|
|
1448
|
+
const checkedKeys = checkedInfo.checkedKeys || [];
|
|
1449
|
+
const titles = [];
|
|
1450
|
+
const opts = [];
|
|
1451
|
+
checkedKeys.forEach((key) => {
|
|
1452
|
+
const node = proxy.$refs.selectTree.getNode(key);
|
|
1453
|
+
if (node) {
|
|
1454
|
+
const label = node.data[props.objMap.label];
|
|
1455
|
+
titles.push(label);
|
|
1456
|
+
opts.push({ value: key, label });
|
|
1457
|
+
} else {
|
|
1458
|
+
opts.push({ value: key, label: String(key) });
|
|
1459
|
+
}
|
|
1460
|
+
});
|
|
1461
|
+
valueId.value = checkedKeys;
|
|
1462
|
+
valueTitle.value = titles.join(",");
|
|
1463
|
+
selectedOptions.value = opts;
|
|
1464
|
+
}
|
|
1361
1465
|
function selectFilterData(val) {
|
|
1362
1466
|
proxy.$refs.selectTree.filter(val);
|
|
1363
1467
|
}
|
|
@@ -1367,8 +1471,17 @@ const _sfc_main$o = {
|
|
|
1367
1471
|
return data[props.objMap["label"]].indexOf(value) !== -1;
|
|
1368
1472
|
}
|
|
1369
1473
|
function clearHandle() {
|
|
1370
|
-
|
|
1371
|
-
|
|
1474
|
+
if (props.multiple) {
|
|
1475
|
+
valueTitle.value = "";
|
|
1476
|
+
valueId.value = [];
|
|
1477
|
+
selectedOptions.value = [];
|
|
1478
|
+
if (proxy.$refs.selectTree) {
|
|
1479
|
+
proxy.$refs.selectTree.setCheckedKeys([]);
|
|
1480
|
+
}
|
|
1481
|
+
} else {
|
|
1482
|
+
valueTitle.value = "";
|
|
1483
|
+
valueId.value = "";
|
|
1484
|
+
}
|
|
1372
1485
|
defaultExpandedKey.value = [];
|
|
1373
1486
|
clearSelected();
|
|
1374
1487
|
}
|
|
@@ -1379,12 +1492,15 @@ const _sfc_main$o = {
|
|
|
1379
1492
|
onMounted$1(() => {
|
|
1380
1493
|
initHandle();
|
|
1381
1494
|
});
|
|
1495
|
+
watch(() => props.modelValue, () => {
|
|
1496
|
+
initHandle();
|
|
1497
|
+
}, { immediate: true });
|
|
1382
1498
|
watch(valueId, () => {
|
|
1383
1499
|
initHandle();
|
|
1384
1500
|
});
|
|
1385
1501
|
return (_ctx, _cache) => {
|
|
1386
|
-
const _component_el_tree = resolveComponent("el-tree");
|
|
1387
1502
|
const _component_el_option = resolveComponent("el-option");
|
|
1503
|
+
const _component_el_tree = resolveComponent("el-tree");
|
|
1388
1504
|
const _component_el_select = resolveComponent("el-select");
|
|
1389
1505
|
return openBlock(), createElementBlock("div", _hoisted_1$i, [
|
|
1390
1506
|
createVNode(_component_el_select, {
|
|
@@ -1394,14 +1510,31 @@ const _sfc_main$o = {
|
|
|
1394
1510
|
ref: "treeSelect",
|
|
1395
1511
|
filterable: true,
|
|
1396
1512
|
clearable: true,
|
|
1513
|
+
multiple: __props.multiple,
|
|
1514
|
+
"collapse-tags": "",
|
|
1515
|
+
"collapse-tags-tooltip": "",
|
|
1397
1516
|
onClear: clearHandle,
|
|
1398
1517
|
"filter-method": selectFilterData,
|
|
1399
1518
|
placeholder: __props.placeholder
|
|
1400
1519
|
}, {
|
|
1401
1520
|
default: withCtx(() => [
|
|
1402
|
-
|
|
1521
|
+
__props.multiple ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(selectedOptions.value, (opt) => {
|
|
1522
|
+
return openBlock(), createBlock(_component_el_option, {
|
|
1523
|
+
key: String(opt.value),
|
|
1524
|
+
value: opt.value,
|
|
1525
|
+
label: opt.label,
|
|
1526
|
+
style: { "display": "none" }
|
|
1527
|
+
}, null, 8, ["value", "label"]);
|
|
1528
|
+
}), 128)) : (openBlock(), createBlock(_component_el_option, {
|
|
1529
|
+
key: 1,
|
|
1403
1530
|
value: unref(valueId),
|
|
1404
|
-
label: valueTitle.value
|
|
1531
|
+
label: valueTitle.value,
|
|
1532
|
+
style: { "display": "none" }
|
|
1533
|
+
}, null, 8, ["value", "label"])),
|
|
1534
|
+
createVNode(_component_el_option, {
|
|
1535
|
+
value: TREE_OPTION_VALUE,
|
|
1536
|
+
label: "",
|
|
1537
|
+
disabled: true
|
|
1405
1538
|
}, {
|
|
1406
1539
|
default: withCtx(() => [
|
|
1407
1540
|
createVNode(_component_el_tree, {
|
|
@@ -1414,19 +1547,22 @@ const _sfc_main$o = {
|
|
|
1414
1547
|
"expand-on-click-node": false,
|
|
1415
1548
|
"default-expanded-keys": defaultExpandedKey.value,
|
|
1416
1549
|
"filter-node-method": filterNode,
|
|
1417
|
-
|
|
1418
|
-
|
|
1550
|
+
"show-checkbox": __props.multiple,
|
|
1551
|
+
"check-strictly": __props.checkStrictly,
|
|
1552
|
+
onNodeClick: handleNodeClick,
|
|
1553
|
+
onCheck: handleCheck
|
|
1554
|
+
}, null, 8, ["accordion", "data", "props", "node-key", "default-expanded-keys", "show-checkbox", "check-strictly"])
|
|
1419
1555
|
]),
|
|
1420
1556
|
_: 1
|
|
1421
|
-
}
|
|
1557
|
+
})
|
|
1422
1558
|
]),
|
|
1423
1559
|
_: 1
|
|
1424
|
-
}, 8, ["modelValue", "placeholder"])
|
|
1560
|
+
}, 8, ["modelValue", "multiple", "placeholder"])
|
|
1425
1561
|
]);
|
|
1426
1562
|
};
|
|
1427
1563
|
}
|
|
1428
1564
|
};
|
|
1429
|
-
const SCTJTreeSelect = /* @__PURE__ */ _export_sfc(_sfc_main$o, [["__scopeId", "data-v-
|
|
1565
|
+
const SCTJTreeSelect = /* @__PURE__ */ _export_sfc(_sfc_main$o, [["__scopeId", "data-v-7b45925b"]]);
|
|
1430
1566
|
const _sfc_main$n = {
|
|
1431
1567
|
__name: "index",
|
|
1432
1568
|
props: {
|
|
@@ -1442,6 +1578,11 @@ const _sfc_main$n = {
|
|
|
1442
1578
|
type: Boolean,
|
|
1443
1579
|
default: false
|
|
1444
1580
|
},
|
|
1581
|
+
valueFormat: {
|
|
1582
|
+
type: String,
|
|
1583
|
+
default: "string",
|
|
1584
|
+
validator: (value) => ["array", "string"].includes(value)
|
|
1585
|
+
},
|
|
1445
1586
|
valueProp: {
|
|
1446
1587
|
type: String,
|
|
1447
1588
|
default: "value"
|
|
@@ -1457,13 +1598,28 @@ const _sfc_main$n = {
|
|
|
1457
1598
|
const selectValue = computed$1({
|
|
1458
1599
|
get() {
|
|
1459
1600
|
if (props.multiple) {
|
|
1460
|
-
|
|
1601
|
+
if (Array.isArray(props.modelValue)) {
|
|
1602
|
+
return props.modelValue;
|
|
1603
|
+
} else if (typeof props.modelValue === "string") {
|
|
1604
|
+
return props.modelValue.split(",").filter((item) => item !== "");
|
|
1605
|
+
} else if (props.modelValue != null && props.modelValue !== void 0) {
|
|
1606
|
+
return [props.modelValue];
|
|
1607
|
+
}
|
|
1608
|
+
return [];
|
|
1461
1609
|
} else {
|
|
1462
1610
|
return props.modelValue;
|
|
1463
1611
|
}
|
|
1464
1612
|
},
|
|
1465
1613
|
set(val) {
|
|
1466
|
-
|
|
1614
|
+
if (props.multiple) {
|
|
1615
|
+
if (props.valueFormat === "array") {
|
|
1616
|
+
emit("update:modelValue", Array.isArray(val) ? val : val ? [val] : []);
|
|
1617
|
+
} else {
|
|
1618
|
+
emit("update:modelValue", Array.isArray(val) ? val.join(",") : val != null ? val : "");
|
|
1619
|
+
}
|
|
1620
|
+
} else {
|
|
1621
|
+
emit("update:modelValue", val);
|
|
1622
|
+
}
|
|
1467
1623
|
}
|
|
1468
1624
|
});
|
|
1469
1625
|
return (_ctx, _cache) => {
|
|
@@ -1473,6 +1629,8 @@ const _sfc_main$n = {
|
|
|
1473
1629
|
modelValue: unref(selectValue),
|
|
1474
1630
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(selectValue) ? selectValue.value = $event : null),
|
|
1475
1631
|
placeholder: "\u8BF7\u9009\u62E9",
|
|
1632
|
+
"collapse-tags": "",
|
|
1633
|
+
"collapse-tags-tooltip": "",
|
|
1476
1634
|
multiple: __props.multiple,
|
|
1477
1635
|
filterable: "",
|
|
1478
1636
|
clearable: ""
|