@dt-frames/ui 1.0.28 → 1.0.29
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/es/components/table/index.d.ts +2 -1
- package/es/components/table/src/components/editable/EditTableCell.d.ts +0 -6
- package/es/components/table/src/components/editable/index.d.ts +1 -1
- package/es/components/table/src/index.d.ts +10 -0
- package/es/components/table/src/props.d.ts +4 -0
- package/es/components/upload/src/upload.d.ts +10 -0
- package/es/index.js +283 -277
- package/package.json +2 -2
|
@@ -19,13 +19,11 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
19
19
|
editValueRefs: Recordable<import("vue").Ref<any>>;
|
|
20
20
|
} & Recordable<any>>>;
|
|
21
21
|
};
|
|
22
|
-
row: ObjectConstructor;
|
|
23
22
|
column: {
|
|
24
23
|
type: PropType<BasicColumn>;
|
|
25
24
|
default: () => BasicColumn;
|
|
26
25
|
};
|
|
27
26
|
index: NumberConstructor;
|
|
28
|
-
dataSource: PropType<Recordable<any>[]>;
|
|
29
27
|
}, {
|
|
30
28
|
props: Readonly<import("@vue/shared").LooseRequired<Readonly<import("vue").ExtractPropTypes<{
|
|
31
29
|
value: {
|
|
@@ -45,13 +43,11 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
45
43
|
editValueRefs: Recordable<import("vue").Ref<any>>;
|
|
46
44
|
} & Recordable<any>>>;
|
|
47
45
|
};
|
|
48
|
-
row: ObjectConstructor;
|
|
49
46
|
column: {
|
|
50
47
|
type: PropType<BasicColumn>;
|
|
51
48
|
default: () => BasicColumn;
|
|
52
49
|
};
|
|
53
50
|
index: NumberConstructor;
|
|
54
|
-
dataSource: PropType<Recordable<any>[]>;
|
|
55
51
|
}>> & {
|
|
56
52
|
[x: string & `on${string}`]: ((...args: any[]) => any) | ((...args: unknown[]) => any);
|
|
57
53
|
}>>;
|
|
@@ -80,13 +76,11 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
80
76
|
editValueRefs: Recordable<import("vue").Ref<any>>;
|
|
81
77
|
} & Recordable<any>>>;
|
|
82
78
|
};
|
|
83
|
-
row: ObjectConstructor;
|
|
84
79
|
column: {
|
|
85
80
|
type: PropType<BasicColumn>;
|
|
86
81
|
default: () => BasicColumn;
|
|
87
82
|
};
|
|
88
83
|
index: NumberConstructor;
|
|
89
|
-
dataSource: PropType<Recordable<any>[]>;
|
|
90
84
|
}>>, {
|
|
91
85
|
value: string;
|
|
92
86
|
column: BasicColumn;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BasicColumn } from "../../types/table.type";
|
|
2
|
-
declare function renderEditCell(column: BasicColumn
|
|
2
|
+
declare function renderEditCell(column: BasicColumn): ({ text: value, record, index }: {
|
|
3
3
|
text: any;
|
|
4
4
|
record: any;
|
|
5
5
|
index: any;
|
|
@@ -81,6 +81,10 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
81
81
|
type: BooleanConstructor;
|
|
82
82
|
default: boolean;
|
|
83
83
|
};
|
|
84
|
+
canResize: {
|
|
85
|
+
type: BooleanConstructor;
|
|
86
|
+
default: boolean;
|
|
87
|
+
};
|
|
84
88
|
pagination: {
|
|
85
89
|
type: import("vue").PropType<boolean | Partial<ExtractPropTypes<{
|
|
86
90
|
total: NumberConstructor;
|
|
@@ -386,6 +390,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
386
390
|
filterFn: (data: Partial<Recordable<string[]>>) => any;
|
|
387
391
|
templates: {};
|
|
388
392
|
ellipsis: boolean;
|
|
393
|
+
canResize: boolean;
|
|
389
394
|
onTableChange: Function;
|
|
390
395
|
showIndexColumn: boolean;
|
|
391
396
|
indexColumnProps: import("./types/table.type").BasicColumn[];
|
|
@@ -538,6 +543,10 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
538
543
|
type: BooleanConstructor;
|
|
539
544
|
default: boolean;
|
|
540
545
|
};
|
|
546
|
+
canResize: {
|
|
547
|
+
type: BooleanConstructor;
|
|
548
|
+
default: boolean;
|
|
549
|
+
};
|
|
541
550
|
pagination: {
|
|
542
551
|
type: import("vue").PropType<boolean | Partial<ExtractPropTypes<{
|
|
543
552
|
total: NumberConstructor;
|
|
@@ -696,6 +705,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
696
705
|
defSort: any;
|
|
697
706
|
templates: {};
|
|
698
707
|
ellipsis: boolean;
|
|
708
|
+
canResize: boolean;
|
|
699
709
|
onTableChange: Function;
|
|
700
710
|
showIndexColumn: boolean;
|
|
701
711
|
indexColumnProps: import("./types/table.type").BasicColumn[];
|
|
@@ -83,6 +83,10 @@ export declare const TableProps: {
|
|
|
83
83
|
type: BooleanConstructor;
|
|
84
84
|
default: boolean;
|
|
85
85
|
};
|
|
86
|
+
canResize: {
|
|
87
|
+
type: BooleanConstructor;
|
|
88
|
+
default: boolean;
|
|
89
|
+
};
|
|
86
90
|
pagination: {
|
|
87
91
|
type: PropType<boolean | Partial<import("vue").ExtractPropTypes<{
|
|
88
92
|
total: NumberConstructor;
|
|
@@ -1105,6 +1105,10 @@ declare const _sfc_main: import("vue").DefineComponent<{
|
|
|
1105
1105
|
type: BooleanConstructor;
|
|
1106
1106
|
default: boolean;
|
|
1107
1107
|
};
|
|
1108
|
+
canResize: {
|
|
1109
|
+
type: BooleanConstructor;
|
|
1110
|
+
default: boolean;
|
|
1111
|
+
};
|
|
1108
1112
|
pagination: {
|
|
1109
1113
|
type: import("vue").PropType<boolean | Partial<import("vue").ExtractPropTypes<{
|
|
1110
1114
|
total: NumberConstructor;
|
|
@@ -1410,6 +1414,7 @@ declare const _sfc_main: import("vue").DefineComponent<{
|
|
|
1410
1414
|
filterFn: (data: Partial<import("@dt-frames/core").Recordable<string[]>>) => any;
|
|
1411
1415
|
templates: {};
|
|
1412
1416
|
ellipsis: boolean;
|
|
1417
|
+
canResize: boolean;
|
|
1413
1418
|
onTableChange: Function;
|
|
1414
1419
|
showIndexColumn: boolean;
|
|
1415
1420
|
indexColumnProps: import("../../table/src/types/table.type").BasicColumn[];
|
|
@@ -1562,6 +1567,10 @@ declare const _sfc_main: import("vue").DefineComponent<{
|
|
|
1562
1567
|
type: BooleanConstructor;
|
|
1563
1568
|
default: boolean;
|
|
1564
1569
|
};
|
|
1570
|
+
canResize: {
|
|
1571
|
+
type: BooleanConstructor;
|
|
1572
|
+
default: boolean;
|
|
1573
|
+
};
|
|
1565
1574
|
pagination: {
|
|
1566
1575
|
type: import("vue").PropType<boolean | Partial<import("vue").ExtractPropTypes<{
|
|
1567
1576
|
total: NumberConstructor;
|
|
@@ -1720,6 +1729,7 @@ declare const _sfc_main: import("vue").DefineComponent<{
|
|
|
1720
1729
|
defSort: any;
|
|
1721
1730
|
templates: {};
|
|
1722
1731
|
ellipsis: boolean;
|
|
1732
|
+
canResize: boolean;
|
|
1723
1733
|
onTableChange: Function;
|
|
1724
1734
|
showIndexColumn: boolean;
|
|
1725
1735
|
indexColumnProps: import("../../table/src/types/table.type").BasicColumn[];
|
package/es/index.js
CHANGED
|
@@ -4498,6 +4498,248 @@ const _sfc_main$L = /* @__PURE__ */ defineComponent({
|
|
|
4498
4498
|
};
|
|
4499
4499
|
}
|
|
4500
4500
|
});
|
|
4501
|
+
const componentMap = /* @__PURE__ */ new Map();
|
|
4502
|
+
componentMap.set("Input", Input);
|
|
4503
|
+
componentMap.set("InputNumber", InputNumber);
|
|
4504
|
+
componentMap.set("Select", Select);
|
|
4505
|
+
componentMap.set("TreeSelect", TreeSelect);
|
|
4506
|
+
componentMap.set("Switch", Switch);
|
|
4507
|
+
componentMap.set("Checkbox", Checkbox);
|
|
4508
|
+
componentMap.set("DatePicker", DatePicker);
|
|
4509
|
+
componentMap.set("TimePicker", TimePicker);
|
|
4510
|
+
const CellComponent = ({
|
|
4511
|
+
component = "Input",
|
|
4512
|
+
rule = true,
|
|
4513
|
+
ruleMessage,
|
|
4514
|
+
popoverVisible,
|
|
4515
|
+
getPopupContainer: getPopupContainer2
|
|
4516
|
+
}, { attrs }) => {
|
|
4517
|
+
const Comp = componentMap.get(component);
|
|
4518
|
+
const DefaultComp = h(Comp, attrs);
|
|
4519
|
+
if (!rule)
|
|
4520
|
+
return DefaultComp;
|
|
4521
|
+
return h(Popover, {
|
|
4522
|
+
overlayClassName: "edit-cell-rule-popover",
|
|
4523
|
+
visible: !!popoverVisible,
|
|
4524
|
+
...getPopupContainer2 ? { getPopupContainer: getPopupContainer2 } : {}
|
|
4525
|
+
}, {
|
|
4526
|
+
default: () => DefaultComp,
|
|
4527
|
+
content: () => ruleMessage
|
|
4528
|
+
});
|
|
4529
|
+
};
|
|
4530
|
+
const tableKey = Symbol("dt-page");
|
|
4531
|
+
function createTableInstance(instance) {
|
|
4532
|
+
provide(tableKey, instance);
|
|
4533
|
+
}
|
|
4534
|
+
function getTableInstance() {
|
|
4535
|
+
return inject(tableKey);
|
|
4536
|
+
}
|
|
4537
|
+
var _sfc_main$K = defineComponent({
|
|
4538
|
+
name: "EditableCell",
|
|
4539
|
+
components: {
|
|
4540
|
+
Spin,
|
|
4541
|
+
CellComponent
|
|
4542
|
+
},
|
|
4543
|
+
props: {
|
|
4544
|
+
value: {
|
|
4545
|
+
type: [String, Number, Boolean, Object],
|
|
4546
|
+
default: ""
|
|
4547
|
+
},
|
|
4548
|
+
record: {
|
|
4549
|
+
type: Object
|
|
4550
|
+
},
|
|
4551
|
+
column: {
|
|
4552
|
+
type: Object,
|
|
4553
|
+
default: () => ({})
|
|
4554
|
+
},
|
|
4555
|
+
index: Number
|
|
4556
|
+
},
|
|
4557
|
+
setup(props) {
|
|
4558
|
+
const table = getTableInstance();
|
|
4559
|
+
ref();
|
|
4560
|
+
const {
|
|
4561
|
+
editRule,
|
|
4562
|
+
align = "left"
|
|
4563
|
+
} = props.column;
|
|
4564
|
+
const ruleMessage = ref("");
|
|
4565
|
+
const ruleVisible = ref(false);
|
|
4566
|
+
const optionsRef = ref([]);
|
|
4567
|
+
const currentValueRef = ref(props.value);
|
|
4568
|
+
const getComponent = computed(() => {
|
|
4569
|
+
var _a;
|
|
4570
|
+
return ((_a = props.column) == null ? void 0 : _a.editComponent) || "Input";
|
|
4571
|
+
});
|
|
4572
|
+
const getRuleVisible = computed(() => {
|
|
4573
|
+
return unref(ruleMessage) && unref(ruleVisible);
|
|
4574
|
+
});
|
|
4575
|
+
const getWrapperClass = computed(() => {
|
|
4576
|
+
return `edit-cell-align-${align}`;
|
|
4577
|
+
});
|
|
4578
|
+
const getIsCheckComp = computed(() => {
|
|
4579
|
+
const component = unref(getComponent);
|
|
4580
|
+
return ["Checkbox", "Switch"].includes(component);
|
|
4581
|
+
});
|
|
4582
|
+
const createPlaceholderMessage = (component) => {
|
|
4583
|
+
if (component.includes("Input")) {
|
|
4584
|
+
return "\u8BF7\u8F93\u5165";
|
|
4585
|
+
}
|
|
4586
|
+
return "\u8BF7\u9009\u62E9";
|
|
4587
|
+
};
|
|
4588
|
+
const setTableValue = () => {
|
|
4589
|
+
props.record[props.column.dataIndex] = unref(currentValueRef);
|
|
4590
|
+
};
|
|
4591
|
+
const getComponentProps = computed(() => {
|
|
4592
|
+
var _a, _b, _c;
|
|
4593
|
+
const isCheckValue = unref(getIsCheckComp);
|
|
4594
|
+
const valueField = isCheckValue ? "checked" : "value";
|
|
4595
|
+
const val = unref(currentValueRef);
|
|
4596
|
+
const value = isCheckValue ? isNumber(val) && isBoolean(val) ? val : !!val : val;
|
|
4597
|
+
let compProps = (_b = (_a = props.column) == null ? void 0 : _a.editComponentProps) != null ? _b : {};
|
|
4598
|
+
const {
|
|
4599
|
+
record,
|
|
4600
|
+
column,
|
|
4601
|
+
index
|
|
4602
|
+
} = props;
|
|
4603
|
+
if (isFunction$1(compProps)) {
|
|
4604
|
+
compProps = (_c = compProps({
|
|
4605
|
+
text: val,
|
|
4606
|
+
record,
|
|
4607
|
+
column,
|
|
4608
|
+
index
|
|
4609
|
+
})) != null ? _c : {};
|
|
4610
|
+
}
|
|
4611
|
+
return {
|
|
4612
|
+
size: "small",
|
|
4613
|
+
getPopupContainer: () => document.body,
|
|
4614
|
+
placeholder: createPlaceholderMessage(unref(getComponent)),
|
|
4615
|
+
...omit(compProps, "onChange"),
|
|
4616
|
+
[valueField]: value
|
|
4617
|
+
};
|
|
4618
|
+
});
|
|
4619
|
+
async function handleChange(e) {
|
|
4620
|
+
var _a, _b;
|
|
4621
|
+
const component = unref(getComponent);
|
|
4622
|
+
if (!e) {
|
|
4623
|
+
currentValueRef.value = e;
|
|
4624
|
+
} else if (component === "Checkbox") {
|
|
4625
|
+
currentValueRef.value = e.target.checked;
|
|
4626
|
+
} else if (component === "Switch") {
|
|
4627
|
+
currentValueRef.value = e;
|
|
4628
|
+
} else if ((e == null ? void 0 : e.target) && Reflect.has(e.target, "value")) {
|
|
4629
|
+
currentValueRef.value = e.target.value;
|
|
4630
|
+
} else if (isString(e) || isBoolean(e) || isNumber(e)) {
|
|
4631
|
+
currentValueRef.value = e;
|
|
4632
|
+
}
|
|
4633
|
+
const onChange = (_a = unref(getComponentProps)) == null ? void 0 : _a.onChange;
|
|
4634
|
+
if (onChange && isFunction$1(onChange))
|
|
4635
|
+
onChange(...arguments);
|
|
4636
|
+
setTableValue();
|
|
4637
|
+
(_b = table.emit) == null ? void 0 : _b.call(table, "edit-change", {
|
|
4638
|
+
column: props.column,
|
|
4639
|
+
value: unref(currentValueRef),
|
|
4640
|
+
record: toRaw(props.record),
|
|
4641
|
+
index: props.index
|
|
4642
|
+
});
|
|
4643
|
+
handleSubmitRule();
|
|
4644
|
+
}
|
|
4645
|
+
async function handleSubmitRule() {
|
|
4646
|
+
const {
|
|
4647
|
+
column,
|
|
4648
|
+
record
|
|
4649
|
+
} = props;
|
|
4650
|
+
const {
|
|
4651
|
+
editRule: editRule2
|
|
4652
|
+
} = column;
|
|
4653
|
+
const currentValue = unref(currentValueRef);
|
|
4654
|
+
if (editRule2) {
|
|
4655
|
+
if (isBoolean(editRule2) && !currentValue && !isNumber(currentValue)) {
|
|
4656
|
+
ruleVisible.value = true;
|
|
4657
|
+
const component = unref(getComponent);
|
|
4658
|
+
ruleMessage.value = createPlaceholderMessage(component);
|
|
4659
|
+
return false;
|
|
4660
|
+
}
|
|
4661
|
+
if (isFunction$1(editRule2)) {
|
|
4662
|
+
const res = await editRule2(currentValue, record);
|
|
4663
|
+
if (!!res) {
|
|
4664
|
+
ruleMessage.value = res;
|
|
4665
|
+
ruleVisible.value = true;
|
|
4666
|
+
return false;
|
|
4667
|
+
}
|
|
4668
|
+
}
|
|
4669
|
+
}
|
|
4670
|
+
ruleMessage.value = "";
|
|
4671
|
+
return true;
|
|
4672
|
+
}
|
|
4673
|
+
function handleOptionsChange(options) {
|
|
4674
|
+
optionsRef.value = options;
|
|
4675
|
+
}
|
|
4676
|
+
return {
|
|
4677
|
+
props,
|
|
4678
|
+
getComponentProps,
|
|
4679
|
+
getRuleVisible,
|
|
4680
|
+
editRule,
|
|
4681
|
+
ruleMessage,
|
|
4682
|
+
getWrapperClass,
|
|
4683
|
+
handleChange,
|
|
4684
|
+
handleOptionsChange
|
|
4685
|
+
};
|
|
4686
|
+
}
|
|
4687
|
+
});
|
|
4688
|
+
const _hoisted_1$t = { class: "editable-cell" };
|
|
4689
|
+
function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
|
|
4690
|
+
var _a;
|
|
4691
|
+
const _component_CellComponent = resolveComponent("CellComponent");
|
|
4692
|
+
return openBlock(), createElementBlock("div", _hoisted_1$t, [
|
|
4693
|
+
createVNode(_component_CellComponent, mergeProps({ ref: "elRef" }, _ctx.getComponentProps, {
|
|
4694
|
+
component: (_a = _ctx.column) == null ? void 0 : _a.editComponent,
|
|
4695
|
+
popoverVisible: _ctx.getRuleVisible,
|
|
4696
|
+
rule: _ctx.editRule,
|
|
4697
|
+
ruleMessage: _ctx.ruleMessage,
|
|
4698
|
+
class: _ctx.getWrapperClass,
|
|
4699
|
+
onChange: _ctx.handleChange,
|
|
4700
|
+
onOptionsChange: _ctx.handleOptionsChange
|
|
4701
|
+
}), null, 16, ["component", "popoverVisible", "rule", "ruleMessage", "class", "onChange", "onOptionsChange"])
|
|
4702
|
+
]);
|
|
4703
|
+
}
|
|
4704
|
+
var EditableCell = /* @__PURE__ */ _export_sfc(_sfc_main$K, [["render", _sfc_render$3]]);
|
|
4705
|
+
function renderEditCell(column) {
|
|
4706
|
+
return ({ text: value, record, index }) => {
|
|
4707
|
+
record.onValid = async () => {
|
|
4708
|
+
if (isArray$1(record == null ? void 0 : record.validCbs)) {
|
|
4709
|
+
const validFns = ((record == null ? void 0 : record.validCbs) || []).map((fn) => fn());
|
|
4710
|
+
const res = await Promise.all(validFns);
|
|
4711
|
+
return res.every((item) => !!item);
|
|
4712
|
+
}
|
|
4713
|
+
return false;
|
|
4714
|
+
};
|
|
4715
|
+
record.onEdit = async (edit, submit = false) => {
|
|
4716
|
+
var _a, _b;
|
|
4717
|
+
if (!submit) {
|
|
4718
|
+
record.editable = edit;
|
|
4719
|
+
}
|
|
4720
|
+
if (!edit && submit) {
|
|
4721
|
+
if (!await record.onValid())
|
|
4722
|
+
return false;
|
|
4723
|
+
const res = await ((_a = record.onSubmitEdit) == null ? void 0 : _a.call(record));
|
|
4724
|
+
if (res) {
|
|
4725
|
+
record.editable = false;
|
|
4726
|
+
return true;
|
|
4727
|
+
}
|
|
4728
|
+
return false;
|
|
4729
|
+
}
|
|
4730
|
+
if (!edit && !submit) {
|
|
4731
|
+
(_b = record.onCancelEdit) == null ? void 0 : _b.call(record);
|
|
4732
|
+
}
|
|
4733
|
+
return true;
|
|
4734
|
+
};
|
|
4735
|
+
return h(EditableCell, {
|
|
4736
|
+
value,
|
|
4737
|
+
record,
|
|
4738
|
+
column,
|
|
4739
|
+
index
|
|
4740
|
+
});
|
|
4741
|
+
};
|
|
4742
|
+
}
|
|
4501
4743
|
const codeMap = /* @__PURE__ */ new Map();
|
|
4502
4744
|
function useHeaderCode(code, templates = {}, changeColumns) {
|
|
4503
4745
|
const { appConf } = useAppStore();
|
|
@@ -4663,6 +4905,7 @@ const TableProps = {
|
|
|
4663
4905
|
ellipsis: { type: Boolean, default: true },
|
|
4664
4906
|
dataSource: { type: Array, default: null },
|
|
4665
4907
|
bordered: { type: Boolean, default: true },
|
|
4908
|
+
canResize: { type: Boolean, default: false },
|
|
4666
4909
|
pagination: {
|
|
4667
4910
|
type: [Object, Boolean],
|
|
4668
4911
|
default: {}
|
|
@@ -4975,7 +5218,7 @@ function useRowSelection(propsRef, emit) {
|
|
|
4975
5218
|
setSelectedRowKeys
|
|
4976
5219
|
};
|
|
4977
5220
|
}
|
|
4978
|
-
var _sfc_main$
|
|
5221
|
+
var _sfc_main$J = defineComponent({
|
|
4979
5222
|
name: "TableFormat",
|
|
4980
5223
|
props: {
|
|
4981
5224
|
column: {
|
|
@@ -4991,6 +5234,7 @@ var _sfc_main$K = defineComponent({
|
|
|
4991
5234
|
setup(props) {
|
|
4992
5235
|
let renderText = ref();
|
|
4993
5236
|
function renderCell() {
|
|
5237
|
+
var _a;
|
|
4994
5238
|
const {
|
|
4995
5239
|
column,
|
|
4996
5240
|
record,
|
|
@@ -5024,7 +5268,7 @@ var _sfc_main$K = defineComponent({
|
|
|
5024
5268
|
renderText = getDictValueByCode(text, dict);
|
|
5025
5269
|
}
|
|
5026
5270
|
if (date) {
|
|
5027
|
-
renderText.value = dayjs(text).format(date || "YYYY-MM-DD");
|
|
5271
|
+
renderText.value = (_a = text && dayjs(text).format(date || "YYYY-MM-DD")) != null ? _a : "";
|
|
5028
5272
|
}
|
|
5029
5273
|
if (number) {
|
|
5030
5274
|
renderText.value = formatNumber(text, number);
|
|
@@ -5056,253 +5300,10 @@ var _sfc_main$K = defineComponent({
|
|
|
5056
5300
|
return () => createVNode("span", null, [unref(renderText)]);
|
|
5057
5301
|
}
|
|
5058
5302
|
});
|
|
5059
|
-
const
|
|
5060
|
-
|
|
5061
|
-
|
|
5062
|
-
}
|
|
5063
|
-
function getTableInstance() {
|
|
5064
|
-
return inject(tableKey);
|
|
5065
|
-
}
|
|
5066
|
-
const componentMap = /* @__PURE__ */ new Map();
|
|
5067
|
-
componentMap.set("Input", Input);
|
|
5068
|
-
componentMap.set("InputNumber", InputNumber);
|
|
5069
|
-
componentMap.set("Select", Select);
|
|
5070
|
-
componentMap.set("TreeSelect", TreeSelect);
|
|
5071
|
-
componentMap.set("Switch", Switch);
|
|
5072
|
-
componentMap.set("Checkbox", Checkbox);
|
|
5073
|
-
componentMap.set("DatePicker", DatePicker);
|
|
5074
|
-
componentMap.set("TimePicker", TimePicker);
|
|
5075
|
-
const CellComponent = ({
|
|
5076
|
-
component = "Input",
|
|
5077
|
-
rule = true,
|
|
5078
|
-
ruleMessage,
|
|
5079
|
-
popoverVisible,
|
|
5080
|
-
getPopupContainer: getPopupContainer2
|
|
5081
|
-
}, { attrs }) => {
|
|
5082
|
-
const Comp = componentMap.get(component);
|
|
5083
|
-
const DefaultComp = h(Comp, attrs);
|
|
5084
|
-
if (!rule)
|
|
5085
|
-
return DefaultComp;
|
|
5086
|
-
return h(Popover, {
|
|
5087
|
-
overlayClassName: "edit-cell-rule-popover",
|
|
5088
|
-
visible: !!popoverVisible,
|
|
5089
|
-
...getPopupContainer2 ? { getPopupContainer: getPopupContainer2 } : {}
|
|
5090
|
-
}, {
|
|
5091
|
-
default: () => DefaultComp,
|
|
5092
|
-
content: () => ruleMessage
|
|
5093
|
-
});
|
|
5303
|
+
const _hoisted_1$s = {
|
|
5304
|
+
key: 0,
|
|
5305
|
+
class: "dt-table-action-btn"
|
|
5094
5306
|
};
|
|
5095
|
-
var _sfc_main$J = defineComponent({
|
|
5096
|
-
name: "EditableCell",
|
|
5097
|
-
components: {
|
|
5098
|
-
Spin,
|
|
5099
|
-
CellComponent
|
|
5100
|
-
},
|
|
5101
|
-
props: {
|
|
5102
|
-
value: {
|
|
5103
|
-
type: [String, Number, Boolean, Object],
|
|
5104
|
-
default: ""
|
|
5105
|
-
},
|
|
5106
|
-
record: {
|
|
5107
|
-
type: Object
|
|
5108
|
-
},
|
|
5109
|
-
row: Object,
|
|
5110
|
-
column: {
|
|
5111
|
-
type: Object,
|
|
5112
|
-
default: () => ({})
|
|
5113
|
-
},
|
|
5114
|
-
index: Number,
|
|
5115
|
-
dataSource: Array
|
|
5116
|
-
},
|
|
5117
|
-
setup(props) {
|
|
5118
|
-
const table = getTableInstance();
|
|
5119
|
-
ref();
|
|
5120
|
-
const {
|
|
5121
|
-
editRule,
|
|
5122
|
-
align = "left"
|
|
5123
|
-
} = props.column;
|
|
5124
|
-
const ruleMessage = ref("");
|
|
5125
|
-
const ruleVisible = ref(false);
|
|
5126
|
-
const optionsRef = ref([]);
|
|
5127
|
-
const currentValueRef = ref(props.value);
|
|
5128
|
-
const getComponent = computed(() => {
|
|
5129
|
-
var _a;
|
|
5130
|
-
return ((_a = props.column) == null ? void 0 : _a.editComponent) || "Input";
|
|
5131
|
-
});
|
|
5132
|
-
const getRuleVisible = computed(() => {
|
|
5133
|
-
return unref(ruleMessage) && unref(ruleVisible);
|
|
5134
|
-
});
|
|
5135
|
-
const getWrapperClass = computed(() => {
|
|
5136
|
-
return `edit-cell-align-${align}`;
|
|
5137
|
-
});
|
|
5138
|
-
const getIsCheckComp = computed(() => {
|
|
5139
|
-
const component = unref(getComponent);
|
|
5140
|
-
return ["Checkbox", "Switch"].includes(component);
|
|
5141
|
-
});
|
|
5142
|
-
const createPlaceholderMessage = (component) => {
|
|
5143
|
-
if (component.includes("Input")) {
|
|
5144
|
-
return "\u8BF7\u8F93\u5165";
|
|
5145
|
-
}
|
|
5146
|
-
return "\u8BF7\u9009\u62E9";
|
|
5147
|
-
};
|
|
5148
|
-
const setTableValue = () => {
|
|
5149
|
-
props.row[props.column.dataIndex] = unref(currentValueRef);
|
|
5150
|
-
};
|
|
5151
|
-
const getComponentProps = computed(() => {
|
|
5152
|
-
var _a, _b, _c;
|
|
5153
|
-
const isCheckValue = unref(getIsCheckComp);
|
|
5154
|
-
const valueField = isCheckValue ? "checked" : "value";
|
|
5155
|
-
const val = unref(currentValueRef);
|
|
5156
|
-
const value = isCheckValue ? isNumber(val) && isBoolean(val) ? val : !!val : val;
|
|
5157
|
-
let compProps = (_b = (_a = props.column) == null ? void 0 : _a.editComponentProps) != null ? _b : {};
|
|
5158
|
-
const {
|
|
5159
|
-
record,
|
|
5160
|
-
column,
|
|
5161
|
-
index
|
|
5162
|
-
} = props;
|
|
5163
|
-
if (isFunction$1(compProps)) {
|
|
5164
|
-
compProps = (_c = compProps({
|
|
5165
|
-
text: val,
|
|
5166
|
-
record,
|
|
5167
|
-
column,
|
|
5168
|
-
index
|
|
5169
|
-
})) != null ? _c : {};
|
|
5170
|
-
}
|
|
5171
|
-
return {
|
|
5172
|
-
size: "small",
|
|
5173
|
-
getPopupContainer: () => document.body,
|
|
5174
|
-
placeholder: createPlaceholderMessage(unref(getComponent)),
|
|
5175
|
-
...omit(compProps, "onChange"),
|
|
5176
|
-
[valueField]: value
|
|
5177
|
-
};
|
|
5178
|
-
});
|
|
5179
|
-
async function handleChange(e) {
|
|
5180
|
-
var _a, _b;
|
|
5181
|
-
const component = unref(getComponent);
|
|
5182
|
-
if (!e) {
|
|
5183
|
-
currentValueRef.value = e;
|
|
5184
|
-
} else if (component === "Checkbox") {
|
|
5185
|
-
currentValueRef.value = e.target.checked;
|
|
5186
|
-
} else if (component === "Switch") {
|
|
5187
|
-
currentValueRef.value = e;
|
|
5188
|
-
} else if ((e == null ? void 0 : e.target) && Reflect.has(e.target, "value")) {
|
|
5189
|
-
currentValueRef.value = e.target.value;
|
|
5190
|
-
} else if (isString(e) || isBoolean(e) || isNumber(e)) {
|
|
5191
|
-
currentValueRef.value = e;
|
|
5192
|
-
}
|
|
5193
|
-
const onChange = (_a = unref(getComponentProps)) == null ? void 0 : _a.onChange;
|
|
5194
|
-
if (onChange && isFunction$1(onChange))
|
|
5195
|
-
onChange(...arguments);
|
|
5196
|
-
setTableValue();
|
|
5197
|
-
(_b = table.emit) == null ? void 0 : _b.call(table, "edit-change", {
|
|
5198
|
-
column: props.column,
|
|
5199
|
-
value: unref(currentValueRef),
|
|
5200
|
-
record: toRaw(props.record),
|
|
5201
|
-
index: props.index
|
|
5202
|
-
});
|
|
5203
|
-
handleSubmitRule();
|
|
5204
|
-
}
|
|
5205
|
-
async function handleSubmitRule() {
|
|
5206
|
-
const {
|
|
5207
|
-
column,
|
|
5208
|
-
record
|
|
5209
|
-
} = props;
|
|
5210
|
-
const {
|
|
5211
|
-
editRule: editRule2
|
|
5212
|
-
} = column;
|
|
5213
|
-
const currentValue = unref(currentValueRef);
|
|
5214
|
-
if (editRule2) {
|
|
5215
|
-
if (isBoolean(editRule2) && !currentValue && !isNumber(currentValue)) {
|
|
5216
|
-
ruleVisible.value = true;
|
|
5217
|
-
const component = unref(getComponent);
|
|
5218
|
-
ruleMessage.value = createPlaceholderMessage(component);
|
|
5219
|
-
return false;
|
|
5220
|
-
}
|
|
5221
|
-
if (isFunction$1(editRule2)) {
|
|
5222
|
-
const res = await editRule2(currentValue, record);
|
|
5223
|
-
if (!!res) {
|
|
5224
|
-
ruleMessage.value = res;
|
|
5225
|
-
ruleVisible.value = true;
|
|
5226
|
-
return false;
|
|
5227
|
-
}
|
|
5228
|
-
}
|
|
5229
|
-
}
|
|
5230
|
-
ruleMessage.value = "";
|
|
5231
|
-
return true;
|
|
5232
|
-
}
|
|
5233
|
-
function handleOptionsChange(options) {
|
|
5234
|
-
optionsRef.value = options;
|
|
5235
|
-
}
|
|
5236
|
-
return {
|
|
5237
|
-
props,
|
|
5238
|
-
getComponentProps,
|
|
5239
|
-
getRuleVisible,
|
|
5240
|
-
editRule,
|
|
5241
|
-
ruleMessage,
|
|
5242
|
-
getWrapperClass,
|
|
5243
|
-
handleChange,
|
|
5244
|
-
handleOptionsChange
|
|
5245
|
-
};
|
|
5246
|
-
}
|
|
5247
|
-
});
|
|
5248
|
-
const _hoisted_1$t = { class: "editable-cell" };
|
|
5249
|
-
function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
|
|
5250
|
-
var _a;
|
|
5251
|
-
const _component_CellComponent = resolveComponent("CellComponent");
|
|
5252
|
-
return openBlock(), createElementBlock("div", _hoisted_1$t, [
|
|
5253
|
-
createVNode(_component_CellComponent, mergeProps({ ref: "elRef" }, _ctx.getComponentProps, {
|
|
5254
|
-
component: (_a = _ctx.column) == null ? void 0 : _a.editComponent,
|
|
5255
|
-
popoverVisible: _ctx.getRuleVisible,
|
|
5256
|
-
rule: _ctx.editRule,
|
|
5257
|
-
ruleMessage: _ctx.ruleMessage,
|
|
5258
|
-
class: _ctx.getWrapperClass,
|
|
5259
|
-
onChange: _ctx.handleChange,
|
|
5260
|
-
onOptionsChange: _ctx.handleOptionsChange
|
|
5261
|
-
}), null, 16, ["component", "popoverVisible", "rule", "ruleMessage", "class", "onChange", "onOptionsChange"])
|
|
5262
|
-
]);
|
|
5263
|
-
}
|
|
5264
|
-
var EditableCell = /* @__PURE__ */ _export_sfc(_sfc_main$J, [["render", _sfc_render$3]]);
|
|
5265
|
-
function renderEditCell(column, dataSource) {
|
|
5266
|
-
return ({ text: value, record, index }) => {
|
|
5267
|
-
record.onValid = async () => {
|
|
5268
|
-
if (isArray$1(record == null ? void 0 : record.validCbs)) {
|
|
5269
|
-
const validFns = ((record == null ? void 0 : record.validCbs) || []).map((fn) => fn());
|
|
5270
|
-
const res = await Promise.all(validFns);
|
|
5271
|
-
return res.every((item) => !!item);
|
|
5272
|
-
}
|
|
5273
|
-
return false;
|
|
5274
|
-
};
|
|
5275
|
-
record.onEdit = async (edit, submit = false) => {
|
|
5276
|
-
var _a, _b;
|
|
5277
|
-
if (!submit) {
|
|
5278
|
-
record.editable = edit;
|
|
5279
|
-
}
|
|
5280
|
-
if (!edit && submit) {
|
|
5281
|
-
if (!await record.onValid())
|
|
5282
|
-
return false;
|
|
5283
|
-
const res = await ((_a = record.onSubmitEdit) == null ? void 0 : _a.call(record));
|
|
5284
|
-
if (res) {
|
|
5285
|
-
record.editable = false;
|
|
5286
|
-
return true;
|
|
5287
|
-
}
|
|
5288
|
-
return false;
|
|
5289
|
-
}
|
|
5290
|
-
if (!edit && !submit) {
|
|
5291
|
-
(_b = record.onCancelEdit) == null ? void 0 : _b.call(record);
|
|
5292
|
-
}
|
|
5293
|
-
return true;
|
|
5294
|
-
};
|
|
5295
|
-
return h(EditableCell, {
|
|
5296
|
-
value,
|
|
5297
|
-
record,
|
|
5298
|
-
column,
|
|
5299
|
-
row: dataSource[index],
|
|
5300
|
-
index,
|
|
5301
|
-
dataSource
|
|
5302
|
-
});
|
|
5303
|
-
};
|
|
5304
|
-
}
|
|
5305
|
-
const _hoisted_1$s = { class: "dt-table-action-btn" };
|
|
5306
5307
|
const _hoisted_2$j = ["color", "onClick"];
|
|
5307
5308
|
const _sfc_main$I = /* @__PURE__ */ defineComponent({
|
|
5308
5309
|
__name: "TableActions",
|
|
@@ -5364,26 +5365,27 @@ const _sfc_main$I = /* @__PURE__ */ defineComponent({
|
|
|
5364
5365
|
return (_ctx, _cache) => {
|
|
5365
5366
|
const _directive_icon = resolveDirective("icon");
|
|
5366
5367
|
const _directive_auth = resolveDirective("auth");
|
|
5367
|
-
return props.expand ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(
|
|
5368
|
-
return openBlock(), createElementBlock(
|
|
5369
|
-
item.ifShow ? (openBlock(),
|
|
5370
|
-
|
|
5371
|
-
|
|
5372
|
-
|
|
5373
|
-
|
|
5374
|
-
|
|
5375
|
-
|
|
5376
|
-
|
|
5377
|
-
|
|
5378
|
-
|
|
5379
|
-
|
|
5380
|
-
|
|
5381
|
-
|
|
5382
|
-
|
|
5383
|
-
|
|
5384
|
-
|
|
5385
|
-
|
|
5386
|
-
|
|
5368
|
+
return props.expand ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(actionBtns.value, (item) => {
|
|
5369
|
+
return openBlock(), createElementBlock(Fragment, null, [
|
|
5370
|
+
item.ifShow ? withDirectives((openBlock(), createElementBlock("span", _hoisted_1$s, [
|
|
5371
|
+
createVNode(unref(Tooltip), { placement: "bottom" }, {
|
|
5372
|
+
title: withCtx(() => [
|
|
5373
|
+
createTextVNode(toDisplayString(item.title), 1)
|
|
5374
|
+
]),
|
|
5375
|
+
default: withCtx(() => [
|
|
5376
|
+
withDirectives(createElementVNode("span", {
|
|
5377
|
+
color: item.color,
|
|
5378
|
+
onClick: ($event) => handleAction(item)
|
|
5379
|
+
}, null, 8, _hoisted_2$j), [
|
|
5380
|
+
[_directive_icon, item.icon]
|
|
5381
|
+
])
|
|
5382
|
+
]),
|
|
5383
|
+
_: 2
|
|
5384
|
+
}, 1024)
|
|
5385
|
+
])), [
|
|
5386
|
+
[_directive_auth, item.auth]
|
|
5387
|
+
]) : createCommentVNode("", true)
|
|
5388
|
+
], 64);
|
|
5387
5389
|
}), 256)) : (openBlock(), createBlock(unref(Dropdown), {
|
|
5388
5390
|
key: 1,
|
|
5389
5391
|
getPopupContainer: getPopupContainer$1,
|
|
@@ -5574,7 +5576,7 @@ function useColumns(propsRef, getPaginationRef, tableElRef) {
|
|
|
5574
5576
|
const columns = cloneDeep(viewColumns);
|
|
5575
5577
|
return columns.filter((column) => isIfShow(column)).map((column) => {
|
|
5576
5578
|
if (column.edit) {
|
|
5577
|
-
column.customRender = renderEditCell(column
|
|
5579
|
+
column.customRender = renderEditCell(column);
|
|
5578
5580
|
}
|
|
5579
5581
|
return column;
|
|
5580
5582
|
});
|
|
@@ -6459,6 +6461,7 @@ function useTableHeader(propsRef, slots, handlers) {
|
|
|
6459
6461
|
function useTableScroll(propsRef, tableElRef, columnsRef, rowSelectionRef) {
|
|
6460
6462
|
const tableHeightRef = ref(0);
|
|
6461
6463
|
const filterSource = ref([]);
|
|
6464
|
+
const tableScrollTopRef = ref(null);
|
|
6462
6465
|
const debounceRedoHeight = useDebounceFn(redoHeight, 100);
|
|
6463
6466
|
watch(() => propsRef.value.dataSource, (v) => {
|
|
6464
6467
|
debounceRedoHeight();
|
|
@@ -6466,7 +6469,7 @@ function useTableScroll(propsRef, tableElRef, columnsRef, rowSelectionRef) {
|
|
|
6466
6469
|
deep: true,
|
|
6467
6470
|
flush: "post"
|
|
6468
6471
|
});
|
|
6469
|
-
windowResizeFn(calcTableHeight,
|
|
6472
|
+
windowResizeFn(calcTableHeight, 280);
|
|
6470
6473
|
function redoHeight() {
|
|
6471
6474
|
nextTick(() => {
|
|
6472
6475
|
calcTableHeight();
|
|
@@ -6502,7 +6505,6 @@ function useTableScroll(propsRef, tableElRef, columnsRef, rowSelectionRef) {
|
|
|
6502
6505
|
!tableEl.classList.contains("hide-scrollbar-x") && tableEl.classList.add("hide-scrollbar-x");
|
|
6503
6506
|
}
|
|
6504
6507
|
bodyEl.style.height = "unset";
|
|
6505
|
-
filterSource.value = [];
|
|
6506
6508
|
await nextTick();
|
|
6507
6509
|
let headerHeight = 0, paginationHeight = 2, footerHeight = 0, titleHeight = (_b = (_a = tableEl.querySelector(".ant-table-title")) == null ? void 0 : _a.offsetHeight) != null ? _b : 0, marginHeight = 15;
|
|
6508
6510
|
const headEl = tableEl.querySelector(".ant-table-thead ");
|
|
@@ -6556,7 +6558,7 @@ function useTableScroll(propsRef, tableElRef, columnsRef, rowSelectionRef) {
|
|
|
6556
6558
|
});
|
|
6557
6559
|
const getScrollRef = computed(() => {
|
|
6558
6560
|
const tableHeight = unref(tableHeightRef);
|
|
6559
|
-
const { scroll } = unref(propsRef);
|
|
6561
|
+
const { canResize, scroll } = unref(propsRef);
|
|
6560
6562
|
return {
|
|
6561
6563
|
x: unref(getScrollX),
|
|
6562
6564
|
y: tableHeight,
|
|
@@ -6597,11 +6599,15 @@ function useTableScroll(propsRef, tableElRef, columnsRef, rowSelectionRef) {
|
|
|
6597
6599
|
const { size } = unref(propsRef);
|
|
6598
6600
|
const rowHeight = TABLE_SIZE_HEIGHT[size];
|
|
6599
6601
|
const scrollTop = el.scrollTop;
|
|
6600
|
-
|
|
6602
|
+
if (tableScrollTopRef.value === scrollTop && scrollTop !== 0) {
|
|
6603
|
+
return;
|
|
6604
|
+
}
|
|
6605
|
+
tableScrollTopRef.value = scrollTop;
|
|
6606
|
+
const remainCount = 6;
|
|
6601
6607
|
const remainH = remainCount * rowHeight;
|
|
6602
6608
|
const minItemHeight = scrollTop > remainH ? Math.floor((scrollTop - remainH) / rowHeight) * rowHeight : 0;
|
|
6603
|
-
|
|
6604
|
-
const maxIndex = minIndex + Math.ceil(tableHeightRef.value / rowHeight) + (minItemHeight && remainCount)
|
|
6609
|
+
let minIndex = minItemHeight / rowHeight;
|
|
6610
|
+
const maxIndex = minIndex + Math.ceil(tableHeightRef.value / rowHeight) + (minItemHeight && remainCount);
|
|
6605
6611
|
bodyEl.querySelector("table").style.transform = `translateY(${minItemHeight}px)`;
|
|
6606
6612
|
filterSource.value = (_a = unref(propsRef)) == null ? void 0 : _a.dataSource.slice(minIndex, maxIndex);
|
|
6607
6613
|
}
|
|
@@ -6680,7 +6686,7 @@ const _sfc_main$A = defineComponent({
|
|
|
6680
6686
|
props: TableProps,
|
|
6681
6687
|
components: {
|
|
6682
6688
|
Table,
|
|
6683
|
-
TableRender: _sfc_main$
|
|
6689
|
+
TableRender: _sfc_main$J
|
|
6684
6690
|
},
|
|
6685
6691
|
emits: [
|
|
6686
6692
|
"register",
|
|
@@ -7902,7 +7908,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
7902
7908
|
}
|
|
7903
7909
|
}
|
|
7904
7910
|
},
|
|
7905
|
-
{ title: "\u5220\u9664", icon: "mdi:delete-outline", action: ({ row }) => {
|
|
7911
|
+
{ title: "\u5220\u9664", icon: "mdi:delete-outline", ifShow: true, action: ({ row }) => {
|
|
7906
7912
|
if (!row.status)
|
|
7907
7913
|
historyFilesRef.value = historyFilesRef.value.filter((it) => it.fileId !== row.fileId);
|
|
7908
7914
|
else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dt-frames/ui",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.29",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"ui",
|
|
6
6
|
"dt-ui"
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"registry": "https://registry.npmjs.org/"
|
|
11
11
|
},
|
|
12
12
|
"scripts": {
|
|
13
|
-
"dev": "vite
|
|
13
|
+
"dev": "vite build -w",
|
|
14
14
|
"build": "vite build"
|
|
15
15
|
},
|
|
16
16
|
"exports": {
|