sun-biz 0.0.4-beta.16 → 0.0.4-beta.17
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/components/index.js +73 -63
- package/dist/index.js +73 -63
- package/package.json +1 -1
package/dist/components/index.js
CHANGED
|
@@ -2281,10 +2281,10 @@ const pro_tablevue_type_script_lang_ts_setup_true_name_ProTable_hoisted_2 = {
|
|
|
2281
2281
|
key: 1,
|
|
2282
2282
|
class: "mt-5 flex items-center justify-between"
|
|
2283
2283
|
};
|
|
2284
|
-
const SELECTION =
|
|
2284
|
+
const SELECTION = "selection";
|
|
2285
2285
|
/**
|
|
2286
|
-
|
|
2287
|
-
|
|
2286
|
+
*获取参与排序的列表 索引 是否可以拖拽
|
|
2287
|
+
*/ /* ESM default export */ const pro_tablevue_type_script_lang_ts_setup_true_name_ProTable = /*@__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_vue__.defineComponent)({
|
|
2288
2288
|
__name: 'index',
|
|
2289
2289
|
props: {
|
|
2290
2290
|
columns: {
|
|
@@ -2301,7 +2301,7 @@ const SELECTION = 'selection';
|
|
|
2301
2301
|
default: void 0
|
|
2302
2302
|
},
|
|
2303
2303
|
componentNo: {
|
|
2304
|
-
default:
|
|
2304
|
+
default: ""
|
|
2305
2305
|
},
|
|
2306
2306
|
hiddenDefaultText: {
|
|
2307
2307
|
type: Boolean,
|
|
@@ -2323,6 +2323,7 @@ const SELECTION = 'selection';
|
|
|
2323
2323
|
type: Boolean,
|
|
2324
2324
|
default: false
|
|
2325
2325
|
},
|
|
2326
|
+
dragGroupName: {},
|
|
2326
2327
|
editable: {
|
|
2327
2328
|
type: Boolean,
|
|
2328
2329
|
default: false
|
|
@@ -2332,7 +2333,7 @@ const SELECTION = 'selection';
|
|
|
2332
2333
|
default: true
|
|
2333
2334
|
},
|
|
2334
2335
|
rowKey: {
|
|
2335
|
-
default:
|
|
2336
|
+
default: "id"
|
|
2336
2337
|
},
|
|
2337
2338
|
loading: {
|
|
2338
2339
|
type: Boolean,
|
|
@@ -2350,13 +2351,13 @@ const SELECTION = 'selection';
|
|
|
2350
2351
|
default: ()=>({})
|
|
2351
2352
|
},
|
|
2352
2353
|
layout: {
|
|
2353
|
-
default:
|
|
2354
|
+
default: "total, sizes, prev, pager, next"
|
|
2354
2355
|
},
|
|
2355
2356
|
formDisabled: {
|
|
2356
2357
|
type: Boolean
|
|
2357
2358
|
},
|
|
2358
2359
|
dragTips: {
|
|
2359
|
-
default:
|
|
2360
|
+
default: "温馨提示:您可通过拖动进行排序"
|
|
2360
2361
|
},
|
|
2361
2362
|
isShowDragTips: {
|
|
2362
2363
|
type: Boolean,
|
|
@@ -2366,7 +2367,7 @@ const SELECTION = 'selection';
|
|
|
2366
2367
|
default: {}
|
|
2367
2368
|
},
|
|
2368
2369
|
dragTipsClassName: {
|
|
2369
|
-
default:
|
|
2370
|
+
default: ""
|
|
2370
2371
|
}
|
|
2371
2372
|
},
|
|
2372
2373
|
emits: [
|
|
@@ -2380,7 +2381,7 @@ const SELECTION = 'selection';
|
|
|
2380
2381
|
const sortFieldList = (0, __WEBPACK_EXTERNAL_MODULE_vue__.ref)(void 0);
|
|
2381
2382
|
const exportFileFlag = (0, __WEBPACK_EXTERNAL_MODULE_vue__.ref)(__WEBPACK_EXTERNAL_MODULE__sun_toolkit_enums__.ENABLED_FLAG.NO);
|
|
2382
2383
|
const showSetting = (0, __WEBPACK_EXTERNAL_MODULE_vue__.ref)(false);
|
|
2383
|
-
const componentDesc = (0, __WEBPACK_EXTERNAL_MODULE_vue__.ref)(
|
|
2384
|
+
const componentDesc = (0, __WEBPACK_EXTERNAL_MODULE_vue__.ref)("文件");
|
|
2384
2385
|
let state = (0, __WEBPACK_EXTERNAL_MODULE_vue__.reactive)({
|
|
2385
2386
|
// 表格数据
|
|
2386
2387
|
tableData: props.data,
|
|
@@ -2406,7 +2407,7 @@ const SELECTION = 'selection';
|
|
|
2406
2407
|
const emit = __emit;
|
|
2407
2408
|
const attrs = (0, __WEBPACK_EXTERNAL_MODULE_vue__.useAttrs)();
|
|
2408
2409
|
// 提供静态数据
|
|
2409
|
-
(0, __WEBPACK_EXTERNAL_MODULE_vue__.provide)(
|
|
2410
|
+
(0, __WEBPACK_EXTERNAL_MODULE_vue__.provide)("hiddenDefaultText", props.hiddenDefaultText);
|
|
2410
2411
|
const tableRef = (0, __WEBPACK_EXTERNAL_MODULE_vue__.ref)();
|
|
2411
2412
|
const proTableRef = (0, __WEBPACK_EXTERNAL_MODULE_vue__.computed)(()=>tableRef.value?.proTableRef);
|
|
2412
2413
|
function getDragSortData(newIndex, data, startIndexObj, sortData, childrenKey) {
|
|
@@ -2423,8 +2424,8 @@ const SELECTION = 'selection';
|
|
|
2423
2424
|
return sortData;
|
|
2424
2425
|
}
|
|
2425
2426
|
/**
|
|
2426
|
-
|
|
2427
|
-
|
|
2427
|
+
* 获取拖拽排序数据结果
|
|
2428
|
+
*/ function getSortableResult(newIndex, oldIndex, evt, initialHTML) {
|
|
2428
2429
|
let data = [
|
|
2429
2430
|
...state.tableData
|
|
2430
2431
|
];
|
|
@@ -2455,7 +2456,7 @@ const SELECTION = 'selection';
|
|
|
2455
2456
|
return data;
|
|
2456
2457
|
}
|
|
2457
2458
|
// 生成每一行的唯一 path
|
|
2458
|
-
function getRowPath(row, data, rowKey, parentPath =
|
|
2459
|
+
function getRowPath(row, data, rowKey, parentPath = "", childrenKey) {
|
|
2459
2460
|
for(let i = 0; i < data.length; i++){
|
|
2460
2461
|
if (data[i][rowKey] === row[rowKey]) {
|
|
2461
2462
|
const currentPath = parentPath ? `${parentPath}-${i}` : `${i}`;
|
|
@@ -2463,49 +2464,49 @@ const SELECTION = 'selection';
|
|
|
2463
2464
|
}
|
|
2464
2465
|
if (childrenKey && Array.isArray(data[i][childrenKey])) {
|
|
2465
2466
|
const childPath = getRowPath(row, data[i][childrenKey], rowKey, parentPath ? `${parentPath}-${i}` : `${i}`, childrenKey);
|
|
2466
|
-
if (
|
|
2467
|
+
if ("" !== childPath) return childPath;
|
|
2467
2468
|
}
|
|
2468
2469
|
}
|
|
2469
|
-
return
|
|
2470
|
+
return "";
|
|
2470
2471
|
}
|
|
2471
2472
|
// 获取childrenKey的安全写法
|
|
2472
2473
|
function getSafeChildrenKeyFromAttrs(attrs) {
|
|
2473
|
-
const treePropsRaw = attrs[
|
|
2474
|
-
const treeProps =
|
|
2475
|
-
if (treeProps &&
|
|
2474
|
+
const treePropsRaw = attrs["tree-props"];
|
|
2475
|
+
const treeProps = "object" == typeof treePropsRaw && null !== treePropsRaw ? treePropsRaw : void 0;
|
|
2476
|
+
if (treeProps && "children" in treeProps) return treeProps.children;
|
|
2476
2477
|
}
|
|
2477
2478
|
// 兼容外部 row-class-name,自动适配参数类型
|
|
2478
2479
|
function rowClassNameWrapper(rowOrParams, rowIndexArg) {
|
|
2479
2480
|
let row, rowIndex;
|
|
2480
|
-
if (rowOrParams &&
|
|
2481
|
+
if (rowOrParams && "object" == typeof rowOrParams && "row" in rowOrParams && "rowIndex" in rowOrParams) {
|
|
2481
2482
|
row = rowOrParams.row;
|
|
2482
2483
|
rowIndex = rowOrParams.rowIndex;
|
|
2483
2484
|
} else {
|
|
2484
2485
|
row = rowOrParams;
|
|
2485
2486
|
rowIndex = rowIndexArg;
|
|
2486
2487
|
}
|
|
2487
|
-
let externalClass =
|
|
2488
|
-
const external = attrs[
|
|
2489
|
-
if (
|
|
2488
|
+
let externalClass = "";
|
|
2489
|
+
const external = attrs["row-class-name"];
|
|
2490
|
+
if ("function" == typeof external) externalClass = external({
|
|
2490
2491
|
row,
|
|
2491
2492
|
rowIndex
|
|
2492
2493
|
});
|
|
2493
|
-
else if (
|
|
2494
|
-
let pathClass =
|
|
2494
|
+
else if ("string" == typeof external) externalClass = external;
|
|
2495
|
+
let pathClass = "";
|
|
2495
2496
|
let childrenKey = getSafeChildrenKeyFromAttrs(attrs);
|
|
2496
|
-
let path = getRowPath(row, state.tableData, props.rowKey,
|
|
2497
|
+
let path = getRowPath(row, state.tableData, props.rowKey, "", childrenKey);
|
|
2497
2498
|
pathClass = `row-path-${path}`;
|
|
2498
2499
|
return [
|
|
2499
2500
|
externalClass,
|
|
2500
2501
|
pathClass
|
|
2501
|
-
].filter(Boolean).join(
|
|
2502
|
+
].filter(Boolean).join(" ");
|
|
2502
2503
|
}
|
|
2503
2504
|
/***
|
|
2504
|
-
|
|
2505
|
-
|
|
2505
|
+
* 表格拖拽排序
|
|
2506
|
+
**/ const initDragSort = ()=>{
|
|
2506
2507
|
const tbodyList = document.querySelectorAll(`#${uuid.value} tbody`);
|
|
2507
2508
|
const tbody = tbodyList[tbodyList.length - 1];
|
|
2508
|
-
let initialHTML =
|
|
2509
|
+
let initialHTML = "";
|
|
2509
2510
|
let crossLevelWarned = false;
|
|
2510
2511
|
// 新增:销毁旧的Sortable实例
|
|
2511
2512
|
// 新增:销毁旧的Sortable实例
|
|
@@ -2514,18 +2515,19 @@ const SELECTION = 'selection';
|
|
|
2514
2515
|
sortableInstance = null;
|
|
2515
2516
|
}
|
|
2516
2517
|
if (tbody) sortableInstance = __WEBPACK_EXTERNAL_MODULE_sortablejs__["default"].create(tbody, {
|
|
2517
|
-
handle:
|
|
2518
|
+
handle: ".cursor-move",
|
|
2519
|
+
group: props.dragGroupName,
|
|
2518
2520
|
animation: 300,
|
|
2519
2521
|
scroll: true,
|
|
2520
2522
|
scrollSensitivity: 80,
|
|
2521
2523
|
scrollSpeed: 10,
|
|
2522
2524
|
onMove (evt) {
|
|
2523
|
-
const draggedPath = evt.dragged?.className.match(/row-path-([\d-]+)/)?.[1] ||
|
|
2524
|
-
const relatedPath = evt.related?.className.match(/row-path-([\d-]+)/)?.[1] ||
|
|
2525
|
-
const getParent = (p)=>p.split(
|
|
2525
|
+
const draggedPath = evt.dragged?.className.match(/row-path-([\d-]+)/)?.[1] || "";
|
|
2526
|
+
const relatedPath = evt.related?.className.match(/row-path-([\d-]+)/)?.[1] || "";
|
|
2527
|
+
const getParent = (p)=>p.split("-").slice(0, -1).join("-");
|
|
2526
2528
|
if (draggedPath && relatedPath && getParent(draggedPath) !== getParent(relatedPath)) {
|
|
2527
2529
|
if (!crossLevelWarned) {
|
|
2528
|
-
__WEBPACK_EXTERNAL_MODULE_element_sun__.ElMessage.warning(
|
|
2530
|
+
__WEBPACK_EXTERNAL_MODULE_element_sun__.ElMessage.warning("暂不支持跨层级拖拽配置");
|
|
2529
2531
|
crossLevelWarned = true;
|
|
2530
2532
|
}
|
|
2531
2533
|
return false;
|
|
@@ -2534,12 +2536,20 @@ const SELECTION = 'selection';
|
|
|
2534
2536
|
},
|
|
2535
2537
|
onEnd (evt) {
|
|
2536
2538
|
const { newIndex, oldIndex } = evt;
|
|
2539
|
+
if (props.dragGroupName) {
|
|
2540
|
+
emit("drag-end", {
|
|
2541
|
+
crossGroup: evt.from !== evt.to,
|
|
2542
|
+
oldIndex,
|
|
2543
|
+
newIndex
|
|
2544
|
+
});
|
|
2545
|
+
return;
|
|
2546
|
+
}
|
|
2537
2547
|
const dragTr = evt.item;
|
|
2538
|
-
const match = dragTr.className.split(
|
|
2539
|
-
const fromPath = match ? match.replace(
|
|
2548
|
+
const match = dragTr.className.split(" ").find((cls)=>cls.startsWith("row-path-"));
|
|
2549
|
+
const fromPath = match ? match.replace("row-path-", "") : "";
|
|
2540
2550
|
let childrenKey = getSafeChildrenKeyFromAttrs(attrs);
|
|
2541
2551
|
const getPathByIndex = (targetIndex)=>{
|
|
2542
|
-
let path =
|
|
2552
|
+
let path = "";
|
|
2543
2553
|
let count = -1;
|
|
2544
2554
|
function dfs(arr, parent) {
|
|
2545
2555
|
for(let i = 0; i < arr.length; i++){
|
|
@@ -2555,13 +2565,13 @@ const SELECTION = 'selection';
|
|
|
2555
2565
|
}
|
|
2556
2566
|
return false;
|
|
2557
2567
|
}
|
|
2558
|
-
dfs(state.tableData,
|
|
2568
|
+
dfs(state.tableData, "");
|
|
2559
2569
|
return path;
|
|
2560
2570
|
};
|
|
2561
|
-
if (
|
|
2571
|
+
if ("number" != typeof newIndex || "number" != typeof oldIndex || newIndex === oldIndex) return;
|
|
2562
2572
|
const newPath = getPathByIndex(newIndex);
|
|
2563
2573
|
const oldPath = getPathByIndex(oldIndex);
|
|
2564
|
-
const getParent = (p)=>p.split(
|
|
2574
|
+
const getParent = (p)=>p.split("-").slice(0, -1).join("-");
|
|
2565
2575
|
if (getParent(newPath) !== getParent(oldPath)) // 这里不再需要回退DOM,onMove已阻止
|
|
2566
2576
|
return;
|
|
2567
2577
|
let data = getSortableResult(newIndex, oldIndex);
|
|
@@ -2574,7 +2584,7 @@ const SELECTION = 'selection';
|
|
|
2574
2584
|
initDragSort();
|
|
2575
2585
|
});
|
|
2576
2586
|
}
|
|
2577
|
-
emit(
|
|
2587
|
+
emit("drag-end", data, fromPath);
|
|
2578
2588
|
} else evt.from.innerHTML = initialHTML;
|
|
2579
2589
|
},
|
|
2580
2590
|
onStart (evt) {
|
|
@@ -2589,7 +2599,7 @@ const SELECTION = 'selection';
|
|
|
2589
2599
|
});
|
|
2590
2600
|
async function fetchDbgridComponent() {
|
|
2591
2601
|
let [, result] = await queryDbgridComponentByExample({
|
|
2592
|
-
componentNo: props.componentNo ||
|
|
2602
|
+
componentNo: props.componentNo || ""
|
|
2593
2603
|
});
|
|
2594
2604
|
if (result?.success) {
|
|
2595
2605
|
exportFileFlag.value = result.data.exportFileFlag;
|
|
@@ -2622,8 +2632,8 @@ const SELECTION = 'selection';
|
|
|
2622
2632
|
if (props.pagination && props?.fetchData && props.defaultQuery) fetchList();
|
|
2623
2633
|
});
|
|
2624
2634
|
/**
|
|
2625
|
-
|
|
2626
|
-
|
|
2635
|
+
* 获取列表
|
|
2636
|
+
*/ async function fetchList() {
|
|
2627
2637
|
state.loading = true;
|
|
2628
2638
|
let { total = 0, data = [] } = await (props.fetchData && props.fetchData(state.pageInfo)) || {};
|
|
2629
2639
|
state.pageInfo.total = Number(total);
|
|
@@ -2631,21 +2641,21 @@ const SELECTION = 'selection';
|
|
|
2631
2641
|
state.loading = false;
|
|
2632
2642
|
}
|
|
2633
2643
|
/**
|
|
2634
|
-
|
|
2635
|
-
|
|
2644
|
+
* 分页组件改变 pageNumber 事件
|
|
2645
|
+
*/ const handleSizeChange = (val)=>{
|
|
2636
2646
|
if (props.fetchData) {
|
|
2637
2647
|
state.pageInfo.pageNumber = 1;
|
|
2638
2648
|
state.pageInfo.pageSize = val;
|
|
2639
2649
|
fetchList();
|
|
2640
|
-
} else emit(
|
|
2650
|
+
} else emit("size-page-change", val);
|
|
2641
2651
|
};
|
|
2642
2652
|
/**
|
|
2643
|
-
|
|
2644
|
-
|
|
2653
|
+
* 分页组件改变 当前页数 事件
|
|
2654
|
+
*/ function changeCurrentPage(val) {
|
|
2645
2655
|
if (props.fetchData) {
|
|
2646
2656
|
state.pageInfo.pageNumber = val;
|
|
2647
2657
|
fetchList();
|
|
2648
|
-
} else emit(
|
|
2658
|
+
} else emit("current-page-change", val);
|
|
2649
2659
|
}
|
|
2650
2660
|
const selections = (0, __WEBPACK_EXTERNAL_MODULE_vue__.ref)();
|
|
2651
2661
|
// 设置当前行激活态
|
|
@@ -2655,8 +2665,8 @@ const SELECTION = 'selection';
|
|
|
2655
2665
|
// 分页配置信息
|
|
2656
2666
|
const paginationInfo = (0, __WEBPACK_EXTERNAL_MODULE_vue__.computed)(()=>props.pageInfo ?? state.pageInfo);
|
|
2657
2667
|
/**
|
|
2658
|
-
|
|
2659
|
-
|
|
2668
|
+
* 支持根据传递的filterObj完成过滤
|
|
2669
|
+
*/ const tableData = (0, __WEBPACK_EXTERNAL_MODULE_vue__.computed)(()=>{
|
|
2660
2670
|
let result = [
|
|
2661
2671
|
...state.tableData
|
|
2662
2672
|
];
|
|
@@ -2668,7 +2678,7 @@ const SELECTION = 'selection';
|
|
|
2668
2678
|
result = multiFieldSort(result, sortFieldList.value);
|
|
2669
2679
|
}
|
|
2670
2680
|
if (Object.keys(props.filterObj).length) return result.filter((item)=>Object.keys(props.filterObj).every((cur)=>!props.filterObj[cur] && [
|
|
2671
|
-
|
|
2681
|
+
"",
|
|
2672
2682
|
void 0,
|
|
2673
2683
|
null
|
|
2674
2684
|
].includes(props.filterObj[cur]) || item[cur] === props.filterObj[cur]));
|
|
@@ -2676,7 +2686,7 @@ const SELECTION = 'selection';
|
|
|
2676
2686
|
});
|
|
2677
2687
|
// 严格按用户要求递归赋值方法
|
|
2678
2688
|
function setDataByPath(path, data, childrenKey) {
|
|
2679
|
-
const indices = path.split(
|
|
2689
|
+
const indices = path.split("-").map((i)=>Number(i));
|
|
2680
2690
|
if (1 === indices.length) {
|
|
2681
2691
|
state.tableData = data;
|
|
2682
2692
|
return;
|
|
@@ -2720,15 +2730,15 @@ const SELECTION = 'selection';
|
|
|
2720
2730
|
rowClassName: rowClassNameWrapper
|
|
2721
2731
|
});
|
|
2722
2732
|
/**
|
|
2723
|
-
|
|
2724
|
-
|
|
2733
|
+
* 处理接口和本地的columns
|
|
2734
|
+
*/ const commonColumns = (0, __WEBPACK_EXTERNAL_MODULE_vue__.computed)(()=>{
|
|
2725
2735
|
let propsColumns = [
|
|
2726
2736
|
...props.columns
|
|
2727
2737
|
];
|
|
2728
2738
|
if (props.couldSortFieldList && props.couldSortFieldList?.length) propsColumns = propsColumns.map((item)=>{
|
|
2729
2739
|
let supportSort = !!(props.couldSortFieldList || []).find((cur)=>cur.fieldName === item.prop);
|
|
2730
2740
|
return {
|
|
2731
|
-
sortable: !!supportSort && (props.pagination ?
|
|
2741
|
+
sortable: !!supportSort && (props.pagination ? "custom" : supportSort),
|
|
2732
2742
|
...item
|
|
2733
2743
|
};
|
|
2734
2744
|
});
|
|
@@ -2757,8 +2767,8 @@ const SELECTION = 'selection';
|
|
|
2757
2767
|
}
|
|
2758
2768
|
});
|
|
2759
2769
|
/**
|
|
2760
|
-
|
|
2761
|
-
|
|
2770
|
+
* 表格渲染存在设置标志的情况 左边宽度加个40px
|
|
2771
|
+
*/ const tableColumns = (0, __WEBPACK_EXTERNAL_MODULE_vue__.computed)(()=>{
|
|
2762
2772
|
let result = [
|
|
2763
2773
|
...commonColumns.value
|
|
2764
2774
|
];
|
|
@@ -2779,14 +2789,14 @@ const SELECTION = 'selection';
|
|
|
2779
2789
|
return result.filter((item)=>!item.isHidden && !(props.componentNo && !serveColumns.value?.length && item.defaultDisplayFlag === __WEBPACK_EXTERNAL_MODULE__sun_toolkit_enums__.ENABLED_FLAG.NO));
|
|
2780
2790
|
});
|
|
2781
2791
|
/**
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2792
|
+
*
|
|
2793
|
+
* 是否展示当前拖拽提示
|
|
2794
|
+
*/ const draggableTips = (0, __WEBPACK_EXTERNAL_MODULE_vue__.computed)(()=>{
|
|
2785
2795
|
const isTips = !!props?.draggable && (!!props?.isShowDragTips || false);
|
|
2786
2796
|
return isTips;
|
|
2787
2797
|
});
|
|
2788
2798
|
function sortChange({ column, order, prop }) {
|
|
2789
|
-
if (!props.couldSortFieldList?.length) return emit(
|
|
2799
|
+
if (!props.couldSortFieldList?.length) return emit("sort-change", {
|
|
2790
2800
|
column,
|
|
2791
2801
|
order,
|
|
2792
2802
|
prop
|
package/dist/index.js
CHANGED
|
@@ -2317,10 +2317,10 @@ const pro_tablevue_type_script_lang_ts_setup_true_name_ProTable_hoisted_2 = {
|
|
|
2317
2317
|
key: 1,
|
|
2318
2318
|
class: "mt-5 flex items-center justify-between"
|
|
2319
2319
|
};
|
|
2320
|
-
const SELECTION =
|
|
2320
|
+
const SELECTION = "selection";
|
|
2321
2321
|
/**
|
|
2322
|
-
|
|
2323
|
-
|
|
2322
|
+
*获取参与排序的列表 索引 是否可以拖拽
|
|
2323
|
+
*/ /* ESM default export */ const pro_tablevue_type_script_lang_ts_setup_true_name_ProTable = /*@__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_vue__.defineComponent)({
|
|
2324
2324
|
__name: 'index',
|
|
2325
2325
|
props: {
|
|
2326
2326
|
columns: {
|
|
@@ -2337,7 +2337,7 @@ const SELECTION = 'selection';
|
|
|
2337
2337
|
default: void 0
|
|
2338
2338
|
},
|
|
2339
2339
|
componentNo: {
|
|
2340
|
-
default:
|
|
2340
|
+
default: ""
|
|
2341
2341
|
},
|
|
2342
2342
|
hiddenDefaultText: {
|
|
2343
2343
|
type: Boolean,
|
|
@@ -2359,6 +2359,7 @@ const SELECTION = 'selection';
|
|
|
2359
2359
|
type: Boolean,
|
|
2360
2360
|
default: false
|
|
2361
2361
|
},
|
|
2362
|
+
dragGroupName: {},
|
|
2362
2363
|
editable: {
|
|
2363
2364
|
type: Boolean,
|
|
2364
2365
|
default: false
|
|
@@ -2368,7 +2369,7 @@ const SELECTION = 'selection';
|
|
|
2368
2369
|
default: true
|
|
2369
2370
|
},
|
|
2370
2371
|
rowKey: {
|
|
2371
|
-
default:
|
|
2372
|
+
default: "id"
|
|
2372
2373
|
},
|
|
2373
2374
|
loading: {
|
|
2374
2375
|
type: Boolean,
|
|
@@ -2386,13 +2387,13 @@ const SELECTION = 'selection';
|
|
|
2386
2387
|
default: ()=>({})
|
|
2387
2388
|
},
|
|
2388
2389
|
layout: {
|
|
2389
|
-
default:
|
|
2390
|
+
default: "total, sizes, prev, pager, next"
|
|
2390
2391
|
},
|
|
2391
2392
|
formDisabled: {
|
|
2392
2393
|
type: Boolean
|
|
2393
2394
|
},
|
|
2394
2395
|
dragTips: {
|
|
2395
|
-
default:
|
|
2396
|
+
default: "温馨提示:您可通过拖动进行排序"
|
|
2396
2397
|
},
|
|
2397
2398
|
isShowDragTips: {
|
|
2398
2399
|
type: Boolean,
|
|
@@ -2402,7 +2403,7 @@ const SELECTION = 'selection';
|
|
|
2402
2403
|
default: {}
|
|
2403
2404
|
},
|
|
2404
2405
|
dragTipsClassName: {
|
|
2405
|
-
default:
|
|
2406
|
+
default: ""
|
|
2406
2407
|
}
|
|
2407
2408
|
},
|
|
2408
2409
|
emits: [
|
|
@@ -2416,7 +2417,7 @@ const SELECTION = 'selection';
|
|
|
2416
2417
|
const sortFieldList = (0, __WEBPACK_EXTERNAL_MODULE_vue__.ref)(void 0);
|
|
2417
2418
|
const exportFileFlag = (0, __WEBPACK_EXTERNAL_MODULE_vue__.ref)(__WEBPACK_EXTERNAL_MODULE__sun_toolkit_enums__.ENABLED_FLAG.NO);
|
|
2418
2419
|
const showSetting = (0, __WEBPACK_EXTERNAL_MODULE_vue__.ref)(false);
|
|
2419
|
-
const componentDesc = (0, __WEBPACK_EXTERNAL_MODULE_vue__.ref)(
|
|
2420
|
+
const componentDesc = (0, __WEBPACK_EXTERNAL_MODULE_vue__.ref)("文件");
|
|
2420
2421
|
let state = (0, __WEBPACK_EXTERNAL_MODULE_vue__.reactive)({
|
|
2421
2422
|
// 表格数据
|
|
2422
2423
|
tableData: props.data,
|
|
@@ -2442,7 +2443,7 @@ const SELECTION = 'selection';
|
|
|
2442
2443
|
const emit = __emit;
|
|
2443
2444
|
const attrs = (0, __WEBPACK_EXTERNAL_MODULE_vue__.useAttrs)();
|
|
2444
2445
|
// 提供静态数据
|
|
2445
|
-
(0, __WEBPACK_EXTERNAL_MODULE_vue__.provide)(
|
|
2446
|
+
(0, __WEBPACK_EXTERNAL_MODULE_vue__.provide)("hiddenDefaultText", props.hiddenDefaultText);
|
|
2446
2447
|
const tableRef = (0, __WEBPACK_EXTERNAL_MODULE_vue__.ref)();
|
|
2447
2448
|
const proTableRef = (0, __WEBPACK_EXTERNAL_MODULE_vue__.computed)(()=>tableRef.value?.proTableRef);
|
|
2448
2449
|
function getDragSortData(newIndex, data, startIndexObj, sortData, childrenKey) {
|
|
@@ -2459,8 +2460,8 @@ const SELECTION = 'selection';
|
|
|
2459
2460
|
return sortData;
|
|
2460
2461
|
}
|
|
2461
2462
|
/**
|
|
2462
|
-
|
|
2463
|
-
|
|
2463
|
+
* 获取拖拽排序数据结果
|
|
2464
|
+
*/ function getSortableResult(newIndex, oldIndex, evt, initialHTML) {
|
|
2464
2465
|
let data = [
|
|
2465
2466
|
...state.tableData
|
|
2466
2467
|
];
|
|
@@ -2491,7 +2492,7 @@ const SELECTION = 'selection';
|
|
|
2491
2492
|
return data;
|
|
2492
2493
|
}
|
|
2493
2494
|
// 生成每一行的唯一 path
|
|
2494
|
-
function getRowPath(row, data, rowKey, parentPath =
|
|
2495
|
+
function getRowPath(row, data, rowKey, parentPath = "", childrenKey) {
|
|
2495
2496
|
for(let i = 0; i < data.length; i++){
|
|
2496
2497
|
if (data[i][rowKey] === row[rowKey]) {
|
|
2497
2498
|
const currentPath = parentPath ? `${parentPath}-${i}` : `${i}`;
|
|
@@ -2499,49 +2500,49 @@ const SELECTION = 'selection';
|
|
|
2499
2500
|
}
|
|
2500
2501
|
if (childrenKey && Array.isArray(data[i][childrenKey])) {
|
|
2501
2502
|
const childPath = getRowPath(row, data[i][childrenKey], rowKey, parentPath ? `${parentPath}-${i}` : `${i}`, childrenKey);
|
|
2502
|
-
if (
|
|
2503
|
+
if ("" !== childPath) return childPath;
|
|
2503
2504
|
}
|
|
2504
2505
|
}
|
|
2505
|
-
return
|
|
2506
|
+
return "";
|
|
2506
2507
|
}
|
|
2507
2508
|
// 获取childrenKey的安全写法
|
|
2508
2509
|
function getSafeChildrenKeyFromAttrs(attrs) {
|
|
2509
|
-
const treePropsRaw = attrs[
|
|
2510
|
-
const treeProps =
|
|
2511
|
-
if (treeProps &&
|
|
2510
|
+
const treePropsRaw = attrs["tree-props"];
|
|
2511
|
+
const treeProps = "object" == typeof treePropsRaw && null !== treePropsRaw ? treePropsRaw : void 0;
|
|
2512
|
+
if (treeProps && "children" in treeProps) return treeProps.children;
|
|
2512
2513
|
}
|
|
2513
2514
|
// 兼容外部 row-class-name,自动适配参数类型
|
|
2514
2515
|
function rowClassNameWrapper(rowOrParams, rowIndexArg) {
|
|
2515
2516
|
let row, rowIndex;
|
|
2516
|
-
if (rowOrParams &&
|
|
2517
|
+
if (rowOrParams && "object" == typeof rowOrParams && "row" in rowOrParams && "rowIndex" in rowOrParams) {
|
|
2517
2518
|
row = rowOrParams.row;
|
|
2518
2519
|
rowIndex = rowOrParams.rowIndex;
|
|
2519
2520
|
} else {
|
|
2520
2521
|
row = rowOrParams;
|
|
2521
2522
|
rowIndex = rowIndexArg;
|
|
2522
2523
|
}
|
|
2523
|
-
let externalClass =
|
|
2524
|
-
const external = attrs[
|
|
2525
|
-
if (
|
|
2524
|
+
let externalClass = "";
|
|
2525
|
+
const external = attrs["row-class-name"];
|
|
2526
|
+
if ("function" == typeof external) externalClass = external({
|
|
2526
2527
|
row,
|
|
2527
2528
|
rowIndex
|
|
2528
2529
|
});
|
|
2529
|
-
else if (
|
|
2530
|
-
let pathClass =
|
|
2530
|
+
else if ("string" == typeof external) externalClass = external;
|
|
2531
|
+
let pathClass = "";
|
|
2531
2532
|
let childrenKey = getSafeChildrenKeyFromAttrs(attrs);
|
|
2532
|
-
let path = getRowPath(row, state.tableData, props.rowKey,
|
|
2533
|
+
let path = getRowPath(row, state.tableData, props.rowKey, "", childrenKey);
|
|
2533
2534
|
pathClass = `row-path-${path}`;
|
|
2534
2535
|
return [
|
|
2535
2536
|
externalClass,
|
|
2536
2537
|
pathClass
|
|
2537
|
-
].filter(Boolean).join(
|
|
2538
|
+
].filter(Boolean).join(" ");
|
|
2538
2539
|
}
|
|
2539
2540
|
/***
|
|
2540
|
-
|
|
2541
|
-
|
|
2541
|
+
* 表格拖拽排序
|
|
2542
|
+
**/ const initDragSort = ()=>{
|
|
2542
2543
|
const tbodyList = document.querySelectorAll(`#${uuid.value} tbody`);
|
|
2543
2544
|
const tbody = tbodyList[tbodyList.length - 1];
|
|
2544
|
-
let initialHTML =
|
|
2545
|
+
let initialHTML = "";
|
|
2545
2546
|
let crossLevelWarned = false;
|
|
2546
2547
|
// 新增:销毁旧的Sortable实例
|
|
2547
2548
|
// 新增:销毁旧的Sortable实例
|
|
@@ -2550,18 +2551,19 @@ const SELECTION = 'selection';
|
|
|
2550
2551
|
sortableInstance = null;
|
|
2551
2552
|
}
|
|
2552
2553
|
if (tbody) sortableInstance = __WEBPACK_EXTERNAL_MODULE_sortablejs__["default"].create(tbody, {
|
|
2553
|
-
handle:
|
|
2554
|
+
handle: ".cursor-move",
|
|
2555
|
+
group: props.dragGroupName,
|
|
2554
2556
|
animation: 300,
|
|
2555
2557
|
scroll: true,
|
|
2556
2558
|
scrollSensitivity: 80,
|
|
2557
2559
|
scrollSpeed: 10,
|
|
2558
2560
|
onMove (evt) {
|
|
2559
|
-
const draggedPath = evt.dragged?.className.match(/row-path-([\d-]+)/)?.[1] ||
|
|
2560
|
-
const relatedPath = evt.related?.className.match(/row-path-([\d-]+)/)?.[1] ||
|
|
2561
|
-
const getParent = (p)=>p.split(
|
|
2561
|
+
const draggedPath = evt.dragged?.className.match(/row-path-([\d-]+)/)?.[1] || "";
|
|
2562
|
+
const relatedPath = evt.related?.className.match(/row-path-([\d-]+)/)?.[1] || "";
|
|
2563
|
+
const getParent = (p)=>p.split("-").slice(0, -1).join("-");
|
|
2562
2564
|
if (draggedPath && relatedPath && getParent(draggedPath) !== getParent(relatedPath)) {
|
|
2563
2565
|
if (!crossLevelWarned) {
|
|
2564
|
-
__WEBPACK_EXTERNAL_MODULE_element_sun__.ElMessage.warning(
|
|
2566
|
+
__WEBPACK_EXTERNAL_MODULE_element_sun__.ElMessage.warning("暂不支持跨层级拖拽配置");
|
|
2565
2567
|
crossLevelWarned = true;
|
|
2566
2568
|
}
|
|
2567
2569
|
return false;
|
|
@@ -2570,12 +2572,20 @@ const SELECTION = 'selection';
|
|
|
2570
2572
|
},
|
|
2571
2573
|
onEnd (evt) {
|
|
2572
2574
|
const { newIndex, oldIndex } = evt;
|
|
2575
|
+
if (props.dragGroupName) {
|
|
2576
|
+
emit("drag-end", {
|
|
2577
|
+
crossGroup: evt.from !== evt.to,
|
|
2578
|
+
oldIndex,
|
|
2579
|
+
newIndex
|
|
2580
|
+
});
|
|
2581
|
+
return;
|
|
2582
|
+
}
|
|
2573
2583
|
const dragTr = evt.item;
|
|
2574
|
-
const match = dragTr.className.split(
|
|
2575
|
-
const fromPath = match ? match.replace(
|
|
2584
|
+
const match = dragTr.className.split(" ").find((cls)=>cls.startsWith("row-path-"));
|
|
2585
|
+
const fromPath = match ? match.replace("row-path-", "") : "";
|
|
2576
2586
|
let childrenKey = getSafeChildrenKeyFromAttrs(attrs);
|
|
2577
2587
|
const getPathByIndex = (targetIndex)=>{
|
|
2578
|
-
let path =
|
|
2588
|
+
let path = "";
|
|
2579
2589
|
let count = -1;
|
|
2580
2590
|
function dfs(arr, parent) {
|
|
2581
2591
|
for(let i = 0; i < arr.length; i++){
|
|
@@ -2591,13 +2601,13 @@ const SELECTION = 'selection';
|
|
|
2591
2601
|
}
|
|
2592
2602
|
return false;
|
|
2593
2603
|
}
|
|
2594
|
-
dfs(state.tableData,
|
|
2604
|
+
dfs(state.tableData, "");
|
|
2595
2605
|
return path;
|
|
2596
2606
|
};
|
|
2597
|
-
if (
|
|
2607
|
+
if ("number" != typeof newIndex || "number" != typeof oldIndex || newIndex === oldIndex) return;
|
|
2598
2608
|
const newPath = getPathByIndex(newIndex);
|
|
2599
2609
|
const oldPath = getPathByIndex(oldIndex);
|
|
2600
|
-
const getParent = (p)=>p.split(
|
|
2610
|
+
const getParent = (p)=>p.split("-").slice(0, -1).join("-");
|
|
2601
2611
|
if (getParent(newPath) !== getParent(oldPath)) // 这里不再需要回退DOM,onMove已阻止
|
|
2602
2612
|
return;
|
|
2603
2613
|
let data = getSortableResult(newIndex, oldIndex);
|
|
@@ -2610,7 +2620,7 @@ const SELECTION = 'selection';
|
|
|
2610
2620
|
initDragSort();
|
|
2611
2621
|
});
|
|
2612
2622
|
}
|
|
2613
|
-
emit(
|
|
2623
|
+
emit("drag-end", data, fromPath);
|
|
2614
2624
|
} else evt.from.innerHTML = initialHTML;
|
|
2615
2625
|
},
|
|
2616
2626
|
onStart (evt) {
|
|
@@ -2625,7 +2635,7 @@ const SELECTION = 'selection';
|
|
|
2625
2635
|
});
|
|
2626
2636
|
async function fetchDbgridComponent() {
|
|
2627
2637
|
let [, result] = await queryDbgridComponentByExample({
|
|
2628
|
-
componentNo: props.componentNo ||
|
|
2638
|
+
componentNo: props.componentNo || ""
|
|
2629
2639
|
});
|
|
2630
2640
|
if (result?.success) {
|
|
2631
2641
|
exportFileFlag.value = result.data.exportFileFlag;
|
|
@@ -2658,8 +2668,8 @@ const SELECTION = 'selection';
|
|
|
2658
2668
|
if (props.pagination && props?.fetchData && props.defaultQuery) fetchList();
|
|
2659
2669
|
});
|
|
2660
2670
|
/**
|
|
2661
|
-
|
|
2662
|
-
|
|
2671
|
+
* 获取列表
|
|
2672
|
+
*/ async function fetchList() {
|
|
2663
2673
|
state.loading = true;
|
|
2664
2674
|
let { total = 0, data = [] } = await (props.fetchData && props.fetchData(state.pageInfo)) || {};
|
|
2665
2675
|
state.pageInfo.total = Number(total);
|
|
@@ -2667,21 +2677,21 @@ const SELECTION = 'selection';
|
|
|
2667
2677
|
state.loading = false;
|
|
2668
2678
|
}
|
|
2669
2679
|
/**
|
|
2670
|
-
|
|
2671
|
-
|
|
2680
|
+
* 分页组件改变 pageNumber 事件
|
|
2681
|
+
*/ const handleSizeChange = (val)=>{
|
|
2672
2682
|
if (props.fetchData) {
|
|
2673
2683
|
state.pageInfo.pageNumber = 1;
|
|
2674
2684
|
state.pageInfo.pageSize = val;
|
|
2675
2685
|
fetchList();
|
|
2676
|
-
} else emit(
|
|
2686
|
+
} else emit("size-page-change", val);
|
|
2677
2687
|
};
|
|
2678
2688
|
/**
|
|
2679
|
-
|
|
2680
|
-
|
|
2689
|
+
* 分页组件改变 当前页数 事件
|
|
2690
|
+
*/ function changeCurrentPage(val) {
|
|
2681
2691
|
if (props.fetchData) {
|
|
2682
2692
|
state.pageInfo.pageNumber = val;
|
|
2683
2693
|
fetchList();
|
|
2684
|
-
} else emit(
|
|
2694
|
+
} else emit("current-page-change", val);
|
|
2685
2695
|
}
|
|
2686
2696
|
const selections = (0, __WEBPACK_EXTERNAL_MODULE_vue__.ref)();
|
|
2687
2697
|
// 设置当前行激活态
|
|
@@ -2691,8 +2701,8 @@ const SELECTION = 'selection';
|
|
|
2691
2701
|
// 分页配置信息
|
|
2692
2702
|
const paginationInfo = (0, __WEBPACK_EXTERNAL_MODULE_vue__.computed)(()=>props.pageInfo ?? state.pageInfo);
|
|
2693
2703
|
/**
|
|
2694
|
-
|
|
2695
|
-
|
|
2704
|
+
* 支持根据传递的filterObj完成过滤
|
|
2705
|
+
*/ const tableData = (0, __WEBPACK_EXTERNAL_MODULE_vue__.computed)(()=>{
|
|
2696
2706
|
let result = [
|
|
2697
2707
|
...state.tableData
|
|
2698
2708
|
];
|
|
@@ -2704,7 +2714,7 @@ const SELECTION = 'selection';
|
|
|
2704
2714
|
result = multiFieldSort(result, sortFieldList.value);
|
|
2705
2715
|
}
|
|
2706
2716
|
if (Object.keys(props.filterObj).length) return result.filter((item)=>Object.keys(props.filterObj).every((cur)=>!props.filterObj[cur] && [
|
|
2707
|
-
|
|
2717
|
+
"",
|
|
2708
2718
|
void 0,
|
|
2709
2719
|
null
|
|
2710
2720
|
].includes(props.filterObj[cur]) || item[cur] === props.filterObj[cur]));
|
|
@@ -2712,7 +2722,7 @@ const SELECTION = 'selection';
|
|
|
2712
2722
|
});
|
|
2713
2723
|
// 严格按用户要求递归赋值方法
|
|
2714
2724
|
function setDataByPath(path, data, childrenKey) {
|
|
2715
|
-
const indices = path.split(
|
|
2725
|
+
const indices = path.split("-").map((i)=>Number(i));
|
|
2716
2726
|
if (1 === indices.length) {
|
|
2717
2727
|
state.tableData = data;
|
|
2718
2728
|
return;
|
|
@@ -2756,15 +2766,15 @@ const SELECTION = 'selection';
|
|
|
2756
2766
|
rowClassName: rowClassNameWrapper
|
|
2757
2767
|
});
|
|
2758
2768
|
/**
|
|
2759
|
-
|
|
2760
|
-
|
|
2769
|
+
* 处理接口和本地的columns
|
|
2770
|
+
*/ const commonColumns = (0, __WEBPACK_EXTERNAL_MODULE_vue__.computed)(()=>{
|
|
2761
2771
|
let propsColumns = [
|
|
2762
2772
|
...props.columns
|
|
2763
2773
|
];
|
|
2764
2774
|
if (props.couldSortFieldList && props.couldSortFieldList?.length) propsColumns = propsColumns.map((item)=>{
|
|
2765
2775
|
let supportSort = !!(props.couldSortFieldList || []).find((cur)=>cur.fieldName === item.prop);
|
|
2766
2776
|
return {
|
|
2767
|
-
sortable: !!supportSort && (props.pagination ?
|
|
2777
|
+
sortable: !!supportSort && (props.pagination ? "custom" : supportSort),
|
|
2768
2778
|
...item
|
|
2769
2779
|
};
|
|
2770
2780
|
});
|
|
@@ -2793,8 +2803,8 @@ const SELECTION = 'selection';
|
|
|
2793
2803
|
}
|
|
2794
2804
|
});
|
|
2795
2805
|
/**
|
|
2796
|
-
|
|
2797
|
-
|
|
2806
|
+
* 表格渲染存在设置标志的情况 左边宽度加个40px
|
|
2807
|
+
*/ const tableColumns = (0, __WEBPACK_EXTERNAL_MODULE_vue__.computed)(()=>{
|
|
2798
2808
|
let result = [
|
|
2799
2809
|
...commonColumns.value
|
|
2800
2810
|
];
|
|
@@ -2815,14 +2825,14 @@ const SELECTION = 'selection';
|
|
|
2815
2825
|
return result.filter((item)=>!item.isHidden && !(props.componentNo && !serveColumns.value?.length && item.defaultDisplayFlag === __WEBPACK_EXTERNAL_MODULE__sun_toolkit_enums__.ENABLED_FLAG.NO));
|
|
2816
2826
|
});
|
|
2817
2827
|
/**
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2828
|
+
*
|
|
2829
|
+
* 是否展示当前拖拽提示
|
|
2830
|
+
*/ const draggableTips = (0, __WEBPACK_EXTERNAL_MODULE_vue__.computed)(()=>{
|
|
2821
2831
|
const isTips = !!props?.draggable && (!!props?.isShowDragTips || false);
|
|
2822
2832
|
return isTips;
|
|
2823
2833
|
});
|
|
2824
2834
|
function sortChange({ column, order, prop }) {
|
|
2825
|
-
if (!props.couldSortFieldList?.length) return emit(
|
|
2835
|
+
if (!props.couldSortFieldList?.length) return emit("sort-change", {
|
|
2826
2836
|
column,
|
|
2827
2837
|
order,
|
|
2828
2838
|
prop
|