ct-component-plus 0.0.23 → 0.0.25
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/package.json +1 -1
- package/packages/components/page/src/modules/DownloadButton.vue +1 -8
- package/packages/components/page/src/modules/TableTitle.vue +1 -0
- package/packages/components/page/src/page.vue +18 -3
- package/packages/components/search-box/src/search-box.vue +1 -0
- package/packages/components/select/src/select.vue +21 -4
- package/packages/components/table/src/table.vue +33 -29
package/package.json
CHANGED
|
@@ -6,17 +6,10 @@
|
|
|
6
6
|
</template>
|
|
7
7
|
|
|
8
8
|
<script setup>
|
|
9
|
-
import {
|
|
9
|
+
import { inject, unref } from "vue";
|
|
10
10
|
const downloadLoading = inject("downloadLoading", false);
|
|
11
|
-
watch(
|
|
12
|
-
() => downloadLoading,
|
|
13
|
-
(val) => {
|
|
14
|
-
console.log("watch", val);
|
|
15
|
-
}
|
|
16
|
-
);
|
|
17
11
|
const emit = defineEmits(["download"]);
|
|
18
12
|
const download = () => {
|
|
19
|
-
console.log("download", unref(downloadLoading));
|
|
20
13
|
if (unref(downloadLoading)) return;
|
|
21
14
|
emit("download");
|
|
22
15
|
};
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
computed,
|
|
8
8
|
resolveComponent,
|
|
9
9
|
provide,
|
|
10
|
+
nextTick,
|
|
10
11
|
} from "vue";
|
|
11
12
|
import { useNamespace } from "../../../hooks";
|
|
12
13
|
import SearchBox from "../../search-box";
|
|
@@ -22,6 +23,10 @@ export default {
|
|
|
22
23
|
type: String,
|
|
23
24
|
default: "",
|
|
24
25
|
},
|
|
26
|
+
needInit: {
|
|
27
|
+
type: Boolean,
|
|
28
|
+
default: true,
|
|
29
|
+
},
|
|
25
30
|
searchConfig: {
|
|
26
31
|
type: Object,
|
|
27
32
|
default: () => {
|
|
@@ -100,7 +105,6 @@ export default {
|
|
|
100
105
|
// searchBox逻辑
|
|
101
106
|
const searchRef = ref(null);
|
|
102
107
|
const doSearch = (params) => {
|
|
103
|
-
console.log("doSearch", params);
|
|
104
108
|
state.searchParams = params;
|
|
105
109
|
state.pageNo = 1;
|
|
106
110
|
getPageData();
|
|
@@ -177,7 +181,6 @@ export default {
|
|
|
177
181
|
getPageData();
|
|
178
182
|
};
|
|
179
183
|
const changePageNo = (val) => {
|
|
180
|
-
console.log("changePageNo", val);
|
|
181
184
|
state.pageNo = val;
|
|
182
185
|
getPageData();
|
|
183
186
|
};
|
|
@@ -193,7 +196,18 @@ export default {
|
|
|
193
196
|
});
|
|
194
197
|
downloadLoading.value = false;
|
|
195
198
|
};
|
|
196
|
-
|
|
199
|
+
const clickSearch = () => {
|
|
200
|
+
if (searchRef.value && isFunction(searchRef.value.doSearch)) {
|
|
201
|
+
searchRef.value.doSearch();
|
|
202
|
+
} else {
|
|
203
|
+
doSearch({});
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
if (props.needInit) {
|
|
207
|
+
nextTick(() => {
|
|
208
|
+
clickSearch();
|
|
209
|
+
});
|
|
210
|
+
}
|
|
197
211
|
const ns = useNamespace("page-component");
|
|
198
212
|
expose({
|
|
199
213
|
searchMethod,
|
|
@@ -202,6 +216,7 @@ export default {
|
|
|
202
216
|
tableRef,
|
|
203
217
|
paginationRef,
|
|
204
218
|
doSearch,
|
|
219
|
+
clickSearch,
|
|
205
220
|
getPageData,
|
|
206
221
|
changePageNo,
|
|
207
222
|
changeSort,
|
|
@@ -138,6 +138,9 @@ const emptyText = computed(() => {
|
|
|
138
138
|
? props.noMatchText || "暂无匹配数据"
|
|
139
139
|
: props.noDataText || "暂无数据";
|
|
140
140
|
});
|
|
141
|
+
const getUseLabel = (label) => {
|
|
142
|
+
return typeof label === "string" ? label : String(label);
|
|
143
|
+
};
|
|
141
144
|
|
|
142
145
|
watch(
|
|
143
146
|
() => selectText.value,
|
|
@@ -170,7 +173,7 @@ watchEffect(async () => {
|
|
|
170
173
|
noFilterOptions.value = true;
|
|
171
174
|
}
|
|
172
175
|
});
|
|
173
|
-
|
|
176
|
+
const watchServiceHandle = async () => {
|
|
174
177
|
// 通过api获取数据,会监听api以及serviceParams的改变(收集到的依赖改变)都会触发重新查询
|
|
175
178
|
const cbs = props.cbs || {};
|
|
176
179
|
if (props.api && baseDao) {
|
|
@@ -194,11 +197,11 @@ watchEffect(async () => {
|
|
|
194
197
|
}
|
|
195
198
|
data = data.map((item) => {
|
|
196
199
|
if (self) {
|
|
197
|
-
return { label: item, value: item };
|
|
200
|
+
return { label: getUseLabel(item), value: item };
|
|
198
201
|
}
|
|
199
202
|
return {
|
|
200
203
|
...item,
|
|
201
|
-
label: item[label],
|
|
204
|
+
label: getUseLabel(item[label]),
|
|
202
205
|
value: item[value],
|
|
203
206
|
};
|
|
204
207
|
});
|
|
@@ -221,7 +224,21 @@ watchEffect(async () => {
|
|
|
221
224
|
}
|
|
222
225
|
} catch (error) {}
|
|
223
226
|
}
|
|
224
|
-
}
|
|
227
|
+
};
|
|
228
|
+
watch(
|
|
229
|
+
[
|
|
230
|
+
() => props.api,
|
|
231
|
+
() => props.serviceParams,
|
|
232
|
+
() => props.serviceMethod,
|
|
233
|
+
() => props.mapObj,
|
|
234
|
+
],
|
|
235
|
+
(newVal, oldVal) => {
|
|
236
|
+
watchServiceHandle();
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
immediate: true,
|
|
240
|
+
}
|
|
241
|
+
);
|
|
225
242
|
const checkedAll = useCheckedAll(filterOptions, valueModel, {
|
|
226
243
|
onCheckedAll: (falg) => {
|
|
227
244
|
if (!keyword.value && !falg) {
|
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div :class="[ns.b()]">
|
|
3
3
|
<div :class="[ns.e('container')]">
|
|
4
|
-
<el-table
|
|
4
|
+
<el-table
|
|
5
|
+
ref="tableRef"
|
|
5
6
|
:class="[ns.e('body')]"
|
|
6
7
|
:data="showData"
|
|
7
8
|
:span-method="spanMethod"
|
|
8
9
|
@selection-change="handleSelectChange"
|
|
9
|
-
row-key="rowKey"
|
|
10
|
+
row-key="rowKey"
|
|
11
|
+
v-bind="$attrs"
|
|
12
|
+
>
|
|
10
13
|
<el-table-column
|
|
11
14
|
v-if="isMultiSelect"
|
|
12
|
-
type="selection"
|
|
15
|
+
type="selection"
|
|
16
|
+
width="88"
|
|
13
17
|
v-bind="multiSelectAttr"
|
|
14
|
-
:reserve-selection="true"
|
|
18
|
+
:reserve-selection="true"
|
|
19
|
+
></el-table-column>
|
|
15
20
|
<el-table-column
|
|
16
21
|
v-for="(column, index) in columnData"
|
|
17
22
|
:key="column.value + '-' + column.label"
|
|
@@ -24,25 +29,26 @@
|
|
|
24
29
|
:align="column.align || 'center'"
|
|
25
30
|
:fixed="column.fixed || false"
|
|
26
31
|
show-overflow-tooltip
|
|
27
|
-
v-bind="column.rawAttr || {}"
|
|
28
|
-
|
|
29
|
-
|
|
32
|
+
v-bind="column.rawAttr || {}"
|
|
33
|
+
>
|
|
34
|
+
<template #header="scope" v-if="column.slotHeader">
|
|
30
35
|
<slot
|
|
31
36
|
:name="column.value + 'Header'"
|
|
32
37
|
v-bind="scope"
|
|
33
38
|
:column="column"
|
|
34
39
|
:label="column.label"
|
|
35
|
-
:value="column.value"
|
|
40
|
+
:value="column.value"
|
|
41
|
+
>
|
|
36
42
|
</slot>
|
|
37
43
|
</template>
|
|
38
44
|
<template #default="scope">
|
|
39
|
-
<slot
|
|
45
|
+
<slot
|
|
46
|
+
:name="column.value"
|
|
40
47
|
:value="scope.row[column.value]"
|
|
41
48
|
v-bind="scope"
|
|
42
|
-
:column="column"
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}}</span>
|
|
49
|
+
:column="column"
|
|
50
|
+
>
|
|
51
|
+
<span>{{ scope.row[column.value] }}</span>
|
|
46
52
|
</slot>
|
|
47
53
|
<el-table-column
|
|
48
54
|
v-for="(column1, index) in column.children"
|
|
@@ -56,16 +62,16 @@
|
|
|
56
62
|
:align="column1.align || 'center'"
|
|
57
63
|
:fixed="column1.fixed || false"
|
|
58
64
|
show-overflow-tooltip
|
|
59
|
-
v-bind="column1.rawAttr || {}"
|
|
65
|
+
v-bind="column1.rawAttr || {}"
|
|
66
|
+
>
|
|
60
67
|
<template #default="scope">
|
|
61
68
|
<slot
|
|
62
69
|
:name="column1.value"
|
|
63
70
|
:value="scope.row[column1.value]"
|
|
64
71
|
v-bind="scope"
|
|
65
|
-
:column="column1"
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}}</span>
|
|
72
|
+
:column="column1"
|
|
73
|
+
>
|
|
74
|
+
<span>{{ scope.row[column1.value] }}</span>
|
|
69
75
|
</slot>
|
|
70
76
|
</template>
|
|
71
77
|
</el-table-column>
|
|
@@ -73,12 +79,13 @@
|
|
|
73
79
|
</el-table-column>
|
|
74
80
|
<template #empty>
|
|
75
81
|
<slot name="empty">
|
|
76
|
-
<component
|
|
82
|
+
<component
|
|
83
|
+
:is="tableEmptyDom"
|
|
77
84
|
v-if="tableEmptyDom"
|
|
78
|
-
:text="emptyText"
|
|
85
|
+
:text="emptyText"
|
|
86
|
+
>
|
|
79
87
|
</component>
|
|
80
|
-
<span v-else>{{ emptyText
|
|
81
|
-
}}</span>
|
|
88
|
+
<span v-else>{{ emptyText }}</span>
|
|
82
89
|
</slot>
|
|
83
90
|
</template>
|
|
84
91
|
</el-table>
|
|
@@ -88,13 +95,11 @@
|
|
|
88
95
|
:total="total"
|
|
89
96
|
:current-page="pageNo"
|
|
90
97
|
v-if="pageSize"
|
|
91
|
-
@current-change="handleCurrentChange"
|
|
98
|
+
@current-change="handleCurrentChange"
|
|
99
|
+
></ct-pagination>
|
|
92
100
|
</div>
|
|
93
|
-
<Teleport :to="`#${teleportDom}`"
|
|
94
|
-
v-
|
|
95
|
-
<table-sort
|
|
96
|
-
v-model:sort-obj="sortObj"
|
|
97
|
-
:sort-list="sortList"></table-sort>
|
|
101
|
+
<Teleport :to="`#${teleportDom}`" v-if="teleportDom && teleportStatus">
|
|
102
|
+
<table-sort v-model:sort-obj="sortObj" :sort-list="sortList"></table-sort>
|
|
98
103
|
</Teleport>
|
|
99
104
|
</div>
|
|
100
105
|
</template>
|
|
@@ -243,7 +248,6 @@ const sortList = computed(() => {
|
|
|
243
248
|
});
|
|
244
249
|
onMounted(() => {
|
|
245
250
|
teleportStatus.value = true; //直到dom挂载完毕再挂载teleport组件
|
|
246
|
-
console.log(props.teleportDom);
|
|
247
251
|
});
|
|
248
252
|
|
|
249
253
|
defineExpose({ tableRef });
|