@funcho/ui 1.1.34 → 1.1.36

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.
@@ -152,15 +152,16 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
152
152
  const getIndex = (i) => {
153
153
  return (pagination.value.currentPage - 1) * pagination.value.pageSize + i + 1;
154
154
  };
155
- const tableData = vue.ref([]);
156
- const displayData = vue.computed(() => {
155
+ const requestTableData = vue.ref([]);
156
+ const tableData = vue.computed(() => {
157
157
  if (props.data !== void 0) {
158
158
  return props.data || [];
159
159
  }
160
- return tableData.value;
160
+ return requestTableData.value;
161
161
  });
162
162
  const tableLoading = vue.ref(false);
163
163
  const loadData = async () => {
164
+ if (props.data !== void 0) return;
164
165
  if (props.request) {
165
166
  if (tableLoading.value) {
166
167
  return;
@@ -171,7 +172,7 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
171
172
  const { data } = await props.request(
172
173
  props.isPagination ? { ...params, page: pagination.value.currentPage, size: pagination.value.pageSize } : params
173
174
  );
174
- tableData.value = Array.isArray(data) ? data : data.list || [];
175
+ requestTableData.value = Array.isArray(data) ? data : data.list || [];
175
176
  pagination.value.total = Array.isArray(data) ? data.length : data.total || 0;
176
177
  } catch (error) {
177
178
  console.log("获取数据失败", error);
@@ -223,7 +224,7 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
223
224
  }, vue.createSlots({
224
225
  body: vue.withCtx(({ height: bodyHeight }) => [
225
226
  vue.withDirectives((vue.openBlock(), vue.createBlock(vue.unref(index.FcTable), vue.mergeProps(_ctx.$attrs, {
226
- data: displayData.value,
227
+ data: tableData.value,
227
228
  border: "",
228
229
  "max-height": bodyHeight,
229
230
  onSelectionChange: handleSelectionChange
@@ -10,6 +10,7 @@ const Dialog_vue_vue_type_script_setup_true_lang = require('../../components/Dia
10
10
  const DataTable_vue_vue_type_script_setup_true_lang = require('../DataTable/DataTable.vue.js');
11
11
  ;/* empty css */
12
12
  const index = require('../../components/Notification/index.js');
13
+ const useNamespace = require('../../hooks/use-namespace.js');
13
14
 
14
15
  const _sfc_main = /* @__PURE__ */ vue.defineComponent({
15
16
  ...{
@@ -26,12 +27,14 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
26
27
  showCancelButton: { type: Boolean, default: true },
27
28
  showConfirmButton: { type: Boolean, default: true },
28
29
  isPagination: { type: Boolean, default: false },
30
+ selectable: { type: Boolean, default: false },
29
31
  submitApi: { type: Function, default: void 0 },
30
32
  successMessage: { default: "提交成功!" },
31
33
  showSuccessMessage: { type: Boolean, default: true }
32
34
  },
33
35
  emits: ["submit", "cancel"],
34
36
  setup(__props, { expose: __expose, emit: __emit }) {
37
+ const ns = useNamespace.useNamespace("pro-data-table-dialog");
35
38
  const tableRef = vue.ref();
36
39
  const props = __props;
37
40
  const containerHeight = vue.computed(() => {
@@ -43,6 +46,10 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
43
46
  const visible = vue.ref(false);
44
47
  const emits = __emit;
45
48
  const submitting = vue.ref(false);
49
+ const confirmBtnDisabled = vue.computed(() => {
50
+ if (!props.selectable) return false;
51
+ return !tableRef.value?.selectedRows || tableRef.value.selectedRows.length === 0;
52
+ });
46
53
  const handleConfirmClick = async () => {
47
54
  try {
48
55
  const tableData = tableRef.value?.tableData;
@@ -87,7 +94,11 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
87
94
  modelValue: visible.value,
88
95
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => visible.value = $event),
89
96
  title: __props.title,
90
- width: __props.width
97
+ width: __props.width,
98
+ class: vue.normalizeClass({
99
+ [vue.unref(ns).b()]: true,
100
+ [vue.unref(ns).is("no-body-padding-bottom")]: __props.showCancelButton || __props.showConfirmButton
101
+ })
91
102
  }, vue.createSlots({
92
103
  default: vue.withCtx(() => [
93
104
  vue.createElementVNode("div", {
@@ -96,7 +107,10 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
96
107
  vue.createVNode(DataTable_vue_vue_type_script_setup_true_lang.default, vue.mergeProps({
97
108
  ref_key: "tableRef",
98
109
  ref: tableRef
99
- }, _ctx.$attrs, { "is-pagination": __props.isPagination }), null, 16, ["is-pagination"])
110
+ }, _ctx.$attrs, {
111
+ "is-pagination": __props.isPagination,
112
+ selectable: __props.selectable
113
+ }), null, 16, ["is-pagination", "selectable"])
100
114
  ], 4)
101
115
  ]),
102
116
  _: 2
@@ -117,17 +131,18 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
117
131
  key: 1,
118
132
  type: "primary",
119
133
  loading: submitting.value,
134
+ disabled: confirmBtnDisabled.value,
120
135
  onClick: handleConfirmClick
121
136
  }, {
122
137
  default: vue.withCtx(() => [
123
138
  vue.createTextVNode(vue.toDisplayString(__props.confirmButtonText), 1)
124
139
  ]),
125
140
  _: 1
126
- }, 8, ["loading"])) : vue.createCommentVNode("", true)
141
+ }, 8, ["loading", "disabled"])) : vue.createCommentVNode("", true)
127
142
  ]),
128
143
  key: "0"
129
144
  } : void 0
130
- ]), 1032, ["modelValue", "title", "width"]);
145
+ ]), 1032, ["modelValue", "title", "width", "class"]);
131
146
  };
132
147
  }
133
148
  });
@@ -2,6 +2,6 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const version = "1.1.34";
5
+ const version = "1.1.36";
6
6
 
7
7
  exports.version = version;
@@ -148,15 +148,16 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
148
148
  const getIndex = (i) => {
149
149
  return (pagination.value.currentPage - 1) * pagination.value.pageSize + i + 1;
150
150
  };
151
- const tableData = ref([]);
152
- const displayData = computed(() => {
151
+ const requestTableData = ref([]);
152
+ const tableData = computed(() => {
153
153
  if (props.data !== void 0) {
154
154
  return props.data || [];
155
155
  }
156
- return tableData.value;
156
+ return requestTableData.value;
157
157
  });
158
158
  const tableLoading = ref(false);
159
159
  const loadData = async () => {
160
+ if (props.data !== void 0) return;
160
161
  if (props.request) {
161
162
  if (tableLoading.value) {
162
163
  return;
@@ -167,7 +168,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
167
168
  const { data } = await props.request(
168
169
  props.isPagination ? { ...params, page: pagination.value.currentPage, size: pagination.value.pageSize } : params
169
170
  );
170
- tableData.value = Array.isArray(data) ? data : data.list || [];
171
+ requestTableData.value = Array.isArray(data) ? data : data.list || [];
171
172
  pagination.value.total = Array.isArray(data) ? data.length : data.total || 0;
172
173
  } catch (error) {
173
174
  console.log("获取数据失败", error);
@@ -219,7 +220,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
219
220
  }, createSlots({
220
221
  body: withCtx(({ height: bodyHeight }) => [
221
222
  withDirectives((openBlock(), createBlock(unref(FcTable), mergeProps(_ctx.$attrs, {
222
- data: displayData.value,
223
+ data: tableData.value,
223
224
  border: "",
224
225
  "max-height": bodyHeight,
225
226
  onSelectionChange: handleSelectionChange
@@ -1,4 +1,4 @@
1
- import { defineComponent, ref, computed, createBlock, openBlock, createSlots, withCtx, createElementVNode, normalizeStyle, createVNode, mergeProps, createCommentVNode, createTextVNode, toDisplayString } from 'vue';
1
+ import { defineComponent, ref, computed, createBlock, openBlock, normalizeClass, unref, createSlots, withCtx, createElementVNode, normalizeStyle, createVNode, mergeProps, createCommentVNode, createTextVNode, toDisplayString } from 'vue';
2
2
  import _sfc_main$3 from '../../components/Button/Button.vue.mjs';
3
3
  /* empty css */
4
4
  import _sfc_main$1 from '../../components/Dialog/Dialog.vue.mjs';
@@ -6,6 +6,7 @@ import _sfc_main$1 from '../../components/Dialog/Dialog.vue.mjs';
6
6
  import _sfc_main$2 from '../DataTable/DataTable.vue.mjs';
7
7
  /* empty css */
8
8
  import { FcNotification } from '../../components/Notification/index.mjs';
9
+ import { useNamespace } from '../../hooks/use-namespace.mjs';
9
10
 
10
11
  const _sfc_main = /* @__PURE__ */ defineComponent({
11
12
  ...{
@@ -22,12 +23,14 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
22
23
  showCancelButton: { type: Boolean, default: true },
23
24
  showConfirmButton: { type: Boolean, default: true },
24
25
  isPagination: { type: Boolean, default: false },
26
+ selectable: { type: Boolean, default: false },
25
27
  submitApi: { type: Function, default: void 0 },
26
28
  successMessage: { default: "提交成功!" },
27
29
  showSuccessMessage: { type: Boolean, default: true }
28
30
  },
29
31
  emits: ["submit", "cancel"],
30
32
  setup(__props, { expose: __expose, emit: __emit }) {
33
+ const ns = useNamespace("pro-data-table-dialog");
31
34
  const tableRef = ref();
32
35
  const props = __props;
33
36
  const containerHeight = computed(() => {
@@ -39,6 +42,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
39
42
  const visible = ref(false);
40
43
  const emits = __emit;
41
44
  const submitting = ref(false);
45
+ const confirmBtnDisabled = computed(() => {
46
+ if (!props.selectable) return false;
47
+ return !tableRef.value?.selectedRows || tableRef.value.selectedRows.length === 0;
48
+ });
42
49
  const handleConfirmClick = async () => {
43
50
  try {
44
51
  const tableData = tableRef.value?.tableData;
@@ -83,7 +90,11 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
83
90
  modelValue: visible.value,
84
91
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => visible.value = $event),
85
92
  title: __props.title,
86
- width: __props.width
93
+ width: __props.width,
94
+ class: normalizeClass({
95
+ [unref(ns).b()]: true,
96
+ [unref(ns).is("no-body-padding-bottom")]: __props.showCancelButton || __props.showConfirmButton
97
+ })
87
98
  }, createSlots({
88
99
  default: withCtx(() => [
89
100
  createElementVNode("div", {
@@ -92,7 +103,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
92
103
  createVNode(_sfc_main$2, mergeProps({
93
104
  ref_key: "tableRef",
94
105
  ref: tableRef
95
- }, _ctx.$attrs, { "is-pagination": __props.isPagination }), null, 16, ["is-pagination"])
106
+ }, _ctx.$attrs, {
107
+ "is-pagination": __props.isPagination,
108
+ selectable: __props.selectable
109
+ }), null, 16, ["is-pagination", "selectable"])
96
110
  ], 4)
97
111
  ]),
98
112
  _: 2
@@ -113,17 +127,18 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
113
127
  key: 1,
114
128
  type: "primary",
115
129
  loading: submitting.value,
130
+ disabled: confirmBtnDisabled.value,
116
131
  onClick: handleConfirmClick
117
132
  }, {
118
133
  default: withCtx(() => [
119
134
  createTextVNode(toDisplayString(__props.confirmButtonText), 1)
120
135
  ]),
121
136
  _: 1
122
- }, 8, ["loading"])) : createCommentVNode("", true)
137
+ }, 8, ["loading", "disabled"])) : createCommentVNode("", true)
123
138
  ]),
124
139
  key: "0"
125
140
  } : void 0
126
- ]), 1032, ["modelValue", "title", "width"]);
141
+ ]), 1032, ["modelValue", "title", "width", "class"]);
127
142
  };
128
143
  }
129
144
  });
@@ -1,3 +1,3 @@
1
- const version = "1.1.34";
1
+ const version = "1.1.36";
2
2
 
3
3
  export { version };
package/dist/style.css CHANGED
@@ -17302,4 +17302,6 @@ to {
17302
17302
  }
17303
17303
  .fc-mkui-pro-vertical-layout__ghost-body {
17304
17304
  flex: 1;
17305
+ }.fc-mkui-pro-data-table-dialog.is-no-body-padding-bottom .fc-ui-dialog__body {
17306
+ padding-bottom: 0;
17305
17307
  }
@@ -1471,7 +1471,7 @@ declare function __VLS_template(): {
1471
1471
  type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
1472
1472
  declare const __VLS_component: import('vue').DefineComponent<TFcProDataTableProps, {
1473
1473
  loadData: () => Promise<void>;
1474
- tableData: import('vue').Ref<any[], any[]>;
1474
+ tableData: import('vue').ComputedRef<any[]>;
1475
1475
  reload: () => void;
1476
1476
  resetSearch: () => void;
1477
1477
  selectedRows: import('vue').Ref<any[], any[]>;
@@ -1,7 +1,7 @@
1
1
  export declare const FcProDataTable: {
2
2
  new (...args: any[]): import('vue').CreateComponentPublicInstanceWithMixins<Readonly<import('./DataTable.types').TFcProDataTableProps> & Readonly<{}>, {
3
3
  loadData: () => Promise<void>;
4
- tableData: import('vue').Ref<any[], any[]>;
4
+ tableData: import('vue').ComputedRef<any[]>;
5
5
  reload: () => void;
6
6
  resetSearch: () => void;
7
7
  selectedRows: import('vue').Ref<any[], any[]>;
@@ -1492,7 +1492,7 @@ export declare const FcProDataTable: {
1492
1492
  Defaults: {};
1493
1493
  }, Readonly<import('./DataTable.types').TFcProDataTableProps> & Readonly<{}>, {
1494
1494
  loadData: () => Promise<void>;
1495
- tableData: import('vue').Ref<any[], any[]>;
1495
+ tableData: import('vue').ComputedRef<any[]>;
1496
1496
  reload: () => void;
1497
1497
  resetSearch: () => void;
1498
1498
  selectedRows: import('vue').Ref<any[], any[]>;
@@ -1519,7 +1519,7 @@ export declare const FcProDataTable: {
1519
1519
  __isSuspense?: never;
1520
1520
  } & import('vue').ComponentOptionsBase<Readonly<import('./DataTable.types').TFcProDataTableProps> & Readonly<{}>, {
1521
1521
  loadData: () => Promise<void>;
1522
- tableData: import('vue').Ref<any[], any[]>;
1522
+ tableData: import('vue').ComputedRef<any[]>;
1523
1523
  reload: () => void;
1524
1524
  resetSearch: () => void;
1525
1525
  selectedRows: import('vue').Ref<any[], any[]>;
@@ -7,6 +7,7 @@ type __VLS_Props = {
7
7
  showCancelButton?: boolean;
8
8
  showConfirmButton?: boolean;
9
9
  isPagination?: boolean;
10
+ selectable?: boolean;
10
11
  submitApi?: (tableData: any, selectedRows: any) => Promise<{
11
12
  data: {};
12
13
  }>;
@@ -28,6 +29,7 @@ declare const _default: import('vue').DefineComponent<__VLS_Props, {
28
29
  cancelButtonText: string;
29
30
  width: string | number;
30
31
  height: string | number;
32
+ selectable: boolean;
31
33
  isPagination: boolean;
32
34
  submitApi: (tableData: any, selectedRows: any) => Promise<{
33
35
  data: {};
@@ -1535,7 +1537,7 @@ declare const _default: import('vue').DefineComponent<__VLS_Props, {
1535
1537
  $el: any;
1536
1538
  $options: import('vue').ComponentOptionsBase<Readonly<import('..').TFcProDataTableProps> & Readonly<{}>, {
1537
1539
  loadData: () => Promise<void>;
1538
- tableData: import('vue').Ref<any[], any[]>;
1540
+ tableData: import('vue').ComputedRef<any[]>;
1539
1541
  reload: () => void;
1540
1542
  resetSearch: () => void;
1541
1543
  selectedRows: import('vue').Ref<any[], any[]>;
@@ -1595,7 +1597,7 @@ declare const _default: import('vue').DefineComponent<__VLS_Props, {
1595
1597
  actionsWidth: number;
1596
1598
  }> & Omit<Readonly<import('..').TFcProDataTableProps> & Readonly<{}>, "loadData" | "tableData" | "reload" | "resetSearch" | "selectedRows" | ("data" | "height" | "fields" | "tools" | "columns" | "selectable" | "hasIndex" | "isPagination" | "request" | "actions" | "actionsWidth")> & import('vue').ShallowUnwrapRef<{
1597
1599
  loadData: () => Promise<void>;
1598
- tableData: import('vue').Ref<any[], any[]>;
1600
+ tableData: import('vue').ComputedRef<any[]>;
1599
1601
  reload: () => void;
1600
1602
  resetSearch: () => void;
1601
1603
  selectedRows: import('vue').Ref<any[], any[]>;
@@ -8,6 +8,7 @@ export declare const FcProDataTableDialog: {
8
8
  showCancelButton?: boolean;
9
9
  showConfirmButton?: boolean;
10
10
  isPagination?: boolean;
11
+ selectable?: boolean;
11
12
  submitApi?: (tableData: any, selectedRows: any) => Promise<{
12
13
  data: {};
13
14
  }>;
@@ -28,6 +29,7 @@ export declare const FcProDataTableDialog: {
28
29
  cancelButtonText: string;
29
30
  width: string | number;
30
31
  height: string | number;
32
+ selectable: boolean;
31
33
  isPagination: boolean;
32
34
  submitApi: (tableData: any, selectedRows: any) => Promise<{
33
35
  data: {};
@@ -1535,7 +1537,7 @@ export declare const FcProDataTableDialog: {
1535
1537
  $el: any;
1536
1538
  $options: import('vue').ComponentOptionsBase<Readonly<import('..').TFcProDataTableProps> & Readonly<{}>, {
1537
1539
  loadData: () => Promise<void>;
1538
- tableData: import('vue').Ref<any[], any[]>;
1540
+ tableData: import('vue').ComputedRef<any[]>;
1539
1541
  reload: () => void;
1540
1542
  resetSearch: () => void;
1541
1543
  selectedRows: import('vue').Ref<any[], any[]>;
@@ -1595,7 +1597,7 @@ export declare const FcProDataTableDialog: {
1595
1597
  actionsWidth: number;
1596
1598
  }> & Omit<Readonly<import('..').TFcProDataTableProps> & Readonly<{}>, "loadData" | "tableData" | "reload" | "resetSearch" | "selectedRows" | ("data" | "height" | "fields" | "tools" | "columns" | "selectable" | "hasIndex" | "isPagination" | "request" | "actions" | "actionsWidth")> & import('vue').ShallowUnwrapRef<{
1597
1599
  loadData: () => Promise<void>;
1598
- tableData: import('vue').Ref<any[], any[]>;
1600
+ tableData: import('vue').ComputedRef<any[]>;
1599
1601
  reload: () => void;
1600
1602
  resetSearch: () => void;
1601
1603
  selectedRows: import('vue').Ref<any[], any[]>;
@@ -1620,6 +1622,7 @@ export declare const FcProDataTableDialog: {
1620
1622
  showCancelButton?: boolean;
1621
1623
  showConfirmButton?: boolean;
1622
1624
  isPagination?: boolean;
1625
+ selectable?: boolean;
1623
1626
  submitApi?: (tableData: any, selectedRows: any) => Promise<{
1624
1627
  data: {};
1625
1628
  }>;
@@ -1637,6 +1640,7 @@ export declare const FcProDataTableDialog: {
1637
1640
  cancelButtonText: string;
1638
1641
  width: string | number;
1639
1642
  height: string | number;
1643
+ selectable: boolean;
1640
1644
  isPagination: boolean;
1641
1645
  submitApi: (tableData: any, selectedRows: any) => Promise<{
1642
1646
  data: {};
@@ -1658,6 +1662,7 @@ export declare const FcProDataTableDialog: {
1658
1662
  showCancelButton?: boolean;
1659
1663
  showConfirmButton?: boolean;
1660
1664
  isPagination?: boolean;
1665
+ selectable?: boolean;
1661
1666
  submitApi?: (tableData: any, selectedRows: any) => Promise<{
1662
1667
  data: {};
1663
1668
  }>;
@@ -1678,6 +1683,7 @@ export declare const FcProDataTableDialog: {
1678
1683
  cancelButtonText: string;
1679
1684
  width: string | number;
1680
1685
  height: string | number;
1686
+ selectable: boolean;
1681
1687
  isPagination: boolean;
1682
1688
  submitApi: (tableData: any, selectedRows: any) => Promise<{
1683
1689
  data: {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@funcho/ui",
3
3
  "description": "@funcho ui library",
4
- "version": "1.1.34",
4
+ "version": "1.1.36",
5
5
  "type": "module",
6
6
  "main": "dist/cjs/index.js",
7
7
  "module": "dist/esm/index.mjs",
@@ -46,8 +46,8 @@
46
46
  "vite-plugin-dts": "^4.5.4",
47
47
  "vitest": "^4.0.7",
48
48
  "vue": "^3.5.22",
49
- "@funcho/icons-vue": "1.0.3",
50
- "@funcho/typescript-config": "0.0.1"
49
+ "@funcho/typescript-config": "0.0.1",
50
+ "@funcho/icons-vue": "1.0.3"
51
51
  },
52
52
  "peerDependencies": {
53
53
  "vue": "^3.5.22",