ct-component-plus 0.0.21 → 0.0.23

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 CHANGED
@@ -1,17 +1,12 @@
1
1
  {
2
2
  "name": "ct-component-plus",
3
3
  "private": false,
4
- "version": "0.0.21",
4
+ "version": "0.0.23",
5
5
  "type": "module",
6
6
  "main": "packages/components/index.js",
7
7
  "files": [
8
8
  "packages"
9
9
  ],
10
- "exports": {
11
- ".": {
12
- "import": "./packages/components/index.js"
13
- }
14
- },
15
10
  "scripts": {
16
11
  "dev": "vite",
17
12
  "build": "vite build",
@@ -38,7 +38,6 @@ const showValue = computed({
38
38
  val = props.addTimestamp(val);
39
39
  } else if (isArray(val)) {
40
40
  if (isArray(props.addTimestamp)) {
41
- console.log(val);
42
41
  val = val.map((item, index) => {
43
42
  if (!item) return item;
44
43
  return +props.addTimestamp[index] + item;
@@ -18,6 +18,7 @@ import dialog from "./dialog";
18
18
  import messageBox from './message-box';
19
19
  import CtMessage from './message';
20
20
 
21
+ import CtLoading from './loading';
21
22
  import CtPage from './page';
22
23
 
23
24
  import ElementPlus from 'element-plus'
@@ -46,6 +47,7 @@ const components = [
46
47
  dialog,
47
48
  messageBox,
48
49
  CtMessage,
50
+ CtLoading,
49
51
  CtPage
50
52
  ]
51
53
 
@@ -0,0 +1,8 @@
1
+ import CtLoading from "./src/CtLoading.vue";
2
+
3
+ /* istanbul ignore next */
4
+ CtLoading.install = function (Vue) {
5
+ Vue.component('CtLoading', CtLoading);
6
+ };
7
+
8
+ export default CtLoading;
@@ -0,0 +1,75 @@
1
+ <template>
2
+ <div class="ct-loading">
3
+ <div class="ct-loading__main" v-show="showLoad">
4
+ <component :is="componentMap[type]" :is-load="isLoad"></component>
5
+ </div>
6
+ <!-- 默认插槽,放置显示内容 -->
7
+ <div v-show="!showLoad" class="slot-content">
8
+ <slot> </slot>
9
+ </div>
10
+ </div>
11
+ </template>
12
+
13
+ <script>
14
+ import beating from "./beating.vue";
15
+ import spinner from "./spinner.vue";
16
+ import CircleProgress from "./progress.vue";
17
+ export default {
18
+ props: {
19
+ type: {
20
+ type: String,
21
+ default: "beating", //beating,spinner,progress
22
+ },
23
+ isLoad: {
24
+ type: Boolean,
25
+ },
26
+ delay: {
27
+ type: [String, Number],
28
+ default: 500,
29
+ },
30
+ },
31
+ components: {
32
+ beating,
33
+ spinner,
34
+ CircleProgress,
35
+ },
36
+ data() {
37
+ return {
38
+ showLoad: false,
39
+ componentMap: {
40
+ beating: "beating",
41
+ spinner: "spinner",
42
+ progress: "CircleProgress",
43
+ },
44
+ };
45
+ },
46
+ created() {},
47
+ mounted() {},
48
+ methods: {},
49
+ watch: {
50
+ isLoad: {
51
+ handler(val) {
52
+ if (val) {
53
+ this.showLoad = val;
54
+ } else {
55
+ if (this.type == "progress") {
56
+ setTimeout(() => {
57
+ this.showLoad = val;
58
+ }, Number(this.delay));
59
+ } else {
60
+ this.showLoad = val;
61
+ }
62
+ }
63
+ },
64
+ immediate: true,
65
+ },
66
+ },
67
+ };
68
+ </script>
69
+ <style scoped lang='less'>
70
+ .ct-loading {
71
+ width: 100%;
72
+ min-height: 200px;
73
+ position: relative;
74
+ }
75
+ </style>
@@ -0,0 +1,72 @@
1
+ <template>
2
+ <!-- 跳动加载特效 -->
3
+ <div class="ct-loading__beating">
4
+ <div></div>
5
+ <div></div>
6
+ <div></div>
7
+ <div></div>
8
+ <div></div>
9
+ </div>
10
+ </template>
11
+ <script>
12
+ export default {};
13
+ </script>
14
+
15
+ <style lang="less" scoped>
16
+ .ct-loading__beating {
17
+ width: 40px;
18
+ height: 45px;
19
+ text-align: center;
20
+ font-size: 10px;
21
+ position: absolute;
22
+ left: 50%;
23
+ top: 50%;
24
+ transform: translate(-50%, -50%);
25
+ border-radius: 10px;
26
+ }
27
+
28
+ .ct-loading__beating > div {
29
+ background-color: var(--ct-color-primary, #2e65fd);
30
+ opacity: 0.8;
31
+ height: 100%;
32
+ width: 4px;
33
+ border-radius: 10px;
34
+ display: inline-block;
35
+ margin: 0 2px;
36
+ -webkit-animation: stretchdelay 1.2s infinite ease-in-out;
37
+ animation: stretchdelay 1.2s infinite ease-in-out;
38
+
39
+ &:nth-child(2) {
40
+ -webkit-animation-delay: -1.1s;
41
+ animation-delay: -1.1s;
42
+ }
43
+
44
+ &:nth-child(3) {
45
+ -webkit-animation-delay: -1s;
46
+ animation-delay: -1s;
47
+ }
48
+
49
+ &:nth-child(4) {
50
+ -webkit-animation-delay: -0.9s;
51
+ animation-delay: -0.9s;
52
+ }
53
+
54
+ &:nth-child(5) {
55
+ -webkit-animation-delay: -0.8s;
56
+ animation-delay: -0.8s;
57
+ }
58
+ }
59
+ @keyframes stretchdelay {
60
+ 0%,
61
+ 40%,
62
+ 100% {
63
+ transform: scaleY(0.4);
64
+ -webkit-transform: scaleY(0.4);
65
+ }
66
+
67
+ 20% {
68
+ transform: scaleY(1);
69
+ -webkit-transform: scaleY(1);
70
+ }
71
+ }
72
+ </style>
@@ -0,0 +1,121 @@
1
+ <template>
2
+ <svg class="ct-loading__progress" width="100" height="100">
3
+ <circle
4
+ cx="50"
5
+ cy="50"
6
+ r="45"
7
+ stroke="#F5F7FA"
8
+ stroke-width="6"
9
+ fill="none"
10
+ ></circle>
11
+ <circle
12
+ cx="50"
13
+ cy="50"
14
+ r="45"
15
+ :stroke="color"
16
+ class="circle"
17
+ id="ct-loading__progress"
18
+ ></circle>
19
+ <text x="50" y="55" fill="#141617" text-anchor="middle">
20
+ <tspan class="text">{{ currentPercentage }}</tspan>
21
+ <tspan class="percent">%</tspan>
22
+ </text>
23
+ </svg>
24
+ </template>
25
+
26
+ <script>
27
+ export default {
28
+ name: "CircleProgress",
29
+ props: {
30
+ color: {
31
+ default: "#2E65FD",
32
+ },
33
+ isLoad: {
34
+ type: Boolean,
35
+ },
36
+ },
37
+ data() {
38
+ return {
39
+ currentPercentage: 0,
40
+ progressLen: 282.6,
41
+ circleDom: null,
42
+ interval: null,
43
+ };
44
+ },
45
+ created() {},
46
+ mounted() {
47
+ this.circleDom = document.querySelector("#ct-loading__progress");
48
+ },
49
+ methods: {
50
+ setPercent(dom, num) {
51
+ if (num > 100) return;
52
+ dom.style["stroke-dashoffset"] =
53
+ this.progressLen - (this.progressLen / 100) * num;
54
+ },
55
+ },
56
+ watch: {
57
+ isLoad: {
58
+ handler(val) {
59
+ if (val) {
60
+ this.currentPercentage = 0;
61
+ this.interval = setInterval(() => {
62
+ if (this.currentPercentage <= 60) {
63
+ this.currentPercentage += Math.floor(Math.random() * 5 + 5);
64
+ } else {
65
+ this.currentPercentage += Math.floor(Math.random() * 5);
66
+ }
67
+ if (this.currentPercentage >= 99) this.currentPercentage = 99;
68
+ }, 250);
69
+ } else {
70
+ this.currentPercentage = 100;
71
+ }
72
+ },
73
+ immediate: true,
74
+ },
75
+ currentPercentage(val) {
76
+ this.setPercent(this.circleDom, val);
77
+ if (val == 100) {
78
+ clearInterval(this.interval);
79
+ }
80
+ },
81
+ },
82
+ beforeDestroy() {
83
+ clearInterval(this.interval);
84
+ },
85
+ };
86
+ </script>
87
+ <style scoped lang='less'>
88
+ .ct-loading__progress {
89
+ position: absolute;
90
+ left: 50%;
91
+ top: 50%;
92
+ transform: translate(-50%, -50%);
93
+ .circle {
94
+ fill: none;
95
+ stroke-width: 6;
96
+ stroke-dasharray: 282.6;
97
+ stroke-dashoffset: 282.6;
98
+ //animation: circle 3s infinite;
99
+ stroke-linecap: round;
100
+ transform: rotate(-90deg);
101
+ transform-origin: center;
102
+ transform-box: fill-box;
103
+ transition: all 0.5s;
104
+ }
105
+ @keyframes circle {
106
+ 100% {
107
+ stroke-dashoffset: 0;
108
+ }
109
+ }
110
+
111
+ .text,
112
+ .percent {
113
+ font-weight: 500;
114
+ }
115
+ text {
116
+ display: flex;
117
+ justify-content: center;
118
+ align-items: center;
119
+ }
120
+ }
121
+ </style>
@@ -0,0 +1,39 @@
1
+ <template>
2
+ <div class="ct-loading__spinner">
3
+ <img src="../../../assets/img/icon_load_circle.png" alt="" />
4
+ <slot name="text"></slot>
5
+ </div>
6
+ </template>
7
+
8
+ <script>
9
+ export default {
10
+ data() {
11
+ return {};
12
+ },
13
+ created() {},
14
+ mounted() {},
15
+ methods: {},
16
+ };
17
+ </script>
18
+ <style scoped lang='less'>
19
+ .ct-loading__spinner {
20
+ position: absolute;
21
+ left: 50%;
22
+ top: 50%;
23
+ transform: translate(-50%, -50%);
24
+
25
+ img {
26
+ width: 40px;
27
+ transform-origin: center;
28
+ animation: rotate 2s infinite linear;
29
+ }
30
+ @keyframes rotate {
31
+ 0% {
32
+ transform: rotate(0deg);
33
+ }
34
+ 100% {
35
+ transform: rotate(360deg);
36
+ }
37
+ }
38
+ }
39
+ </style>
@@ -0,0 +1,29 @@
1
+ <template>
2
+ <div type="border" class="download-button" @click="download">
3
+ <ct-icon name="download2_line"></ct-icon>
4
+ <span>下载</span>
5
+ </div>
6
+ </template>
7
+
8
+ <script setup>
9
+ import { reactive, onMounted, inject, watch, unref } from "vue";
10
+ const downloadLoading = inject("downloadLoading", false);
11
+ watch(
12
+ () => downloadLoading,
13
+ (val) => {
14
+ console.log("watch", val);
15
+ }
16
+ );
17
+ const emit = defineEmits(["download"]);
18
+ const download = () => {
19
+ console.log("download", unref(downloadLoading));
20
+ if (unref(downloadLoading)) return;
21
+ emit("download");
22
+ };
23
+ </script>
24
+ <style lang='less' scoped>
25
+ .download-button {
26
+ display: inline-flex;
27
+ align-items: center;
28
+ }
29
+ </style>
@@ -0,0 +1,148 @@
1
+ <template>
2
+ <div :class="[ns.b()]">
3
+ <div :class="[ns.e('container')]">
4
+ <div :class="[ns.e('left')]">
5
+ <slot name="table-title">
6
+ <ct-icon
7
+ :class="[ns.e('total-icon')]"
8
+ name="content-search_line"
9
+ ></ct-icon>
10
+ <span>查询结果:</span>
11
+ <span>共{{ total }}条记录</span>
12
+ <span>,每页显示{{ pageSize }}条</span>
13
+ <slot name="table-desc"></slot>
14
+ </slot>
15
+ </div>
16
+ <div :class="[ns.e('right')]">
17
+ <slot name="table-handle">
18
+ <slot name="table-handle-before"></slot>
19
+ <div :class="[ns.e('handle')]">
20
+ <div
21
+ :class="[ns.e('handle-item'), ns.is(item, true)]"
22
+ v-for="(item, index) in handleList"
23
+ :key="index"
24
+ >
25
+ <component
26
+ v-if="handleItemShow(item)"
27
+ :is="getHandleComponent(item)"
28
+ v-bind="handleOptionsBind(item)"
29
+ v-model:sortObj="modelSort"
30
+ @download="download"
31
+ />
32
+ </div>
33
+ </div>
34
+ <slot name="table-handle-after"></slot>
35
+ </slot>
36
+ </div>
37
+ </div>
38
+ </div>
39
+ </template>
40
+
41
+ <script setup>
42
+ import { reactive, onMounted, ref, computed } from "vue";
43
+ import { useNamespace } from "../../../../hooks";
44
+ import DownloadButton from "./DownloadButton.vue";
45
+ import TableSort from "../../../table/src/TableSort.vue";
46
+ const props = defineProps({
47
+ total: Number,
48
+ pageSize: Number,
49
+ handleList: {
50
+ type: Array,
51
+ default: () => {
52
+ return ["sort", "download"];
53
+ },
54
+ },
55
+ sortList: {
56
+ type: Array,
57
+ default: () => {
58
+ return [];
59
+ },
60
+ },
61
+ sortObj: {
62
+ type: Object,
63
+ default: () => {
64
+ return {};
65
+ },
66
+ },
67
+ });
68
+ const emit = defineEmits(["update:sortObj", "changeSort", "download"]);
69
+ const ns = useNamespace("page-table-title");
70
+ const modelSort = computed({
71
+ get() {
72
+ return props.sortObj;
73
+ },
74
+ set(val) {
75
+ emit("update:sortObj", val);
76
+ if (val.prop && val.order) {
77
+ emit("changeSort", val);
78
+ }
79
+ },
80
+ });
81
+ const getHandleComponent = (type) => {
82
+ const componentMap = {
83
+ sort: TableSort,
84
+ download: DownloadButton,
85
+ };
86
+ return componentMap[type] || "div";
87
+ };
88
+ const handleOptionsBind = (item) => {
89
+ if (item === "sort") {
90
+ return { sortList: props.sortList };
91
+ }
92
+ return {};
93
+ };
94
+ const download = () => {
95
+ emit("download");
96
+ };
97
+ const handleItemShow = (item) => {
98
+ if (item === "sort") {
99
+ return props.sortList.length > 0;
100
+ }
101
+ return true;
102
+ };
103
+ onMounted(() => {});
104
+ </script>
105
+ <style lang='less' scoped>
106
+ .ct-page-table-title {
107
+ &__container {
108
+ display: flex;
109
+ align-items: center;
110
+ justify-content: space-between;
111
+ height: 56px;
112
+ background-color: #fff;
113
+ }
114
+ &__left {
115
+ display: flex;
116
+ align-items: center;
117
+ justify-content: flex-start;
118
+ }
119
+ &__total-icon {
120
+ margin-right: 8px;
121
+ }
122
+ &__handle {
123
+ display: flex;
124
+ align-items: center;
125
+ justify-content: flex-end;
126
+ &-item {
127
+ &:not(:last-child) {
128
+ margin-right: 12px;
129
+ }
130
+ display: inline-flex;
131
+ align-items: center;
132
+ height: 28px;
133
+ padding: 0 9px;
134
+ color: var(--ct-color-primary);
135
+ border: 1px solid var(--ct-color-primary);
136
+ border-radius: 3px;
137
+ background-color: #fff;
138
+ cursor: pointer;
139
+ &:hover {
140
+ background-color: var(--ct-color-primary-bg);
141
+ }
142
+ :deep(.ct-icon) {
143
+ margin-right: 4px;
144
+ }
145
+ }
146
+ }
147
+ }
148
+ </style>
@@ -1,14 +1,92 @@
1
1
  <script>
2
- import { h, reactive, resolveComponent } from "vue";
2
+ import {
3
+ h,
4
+ reactive,
5
+ inject,
6
+ ref,
7
+ computed,
8
+ resolveComponent,
9
+ provide,
10
+ } from "vue";
3
11
  import { useNamespace } from "../../../hooks";
4
12
  import SearchBox from "../../search-box";
5
- import tableBox from "../../table";
13
+ import TableBox from "../../table";
14
+ import CtPagination from "../../pagination";
15
+ import CtLoading from "../../loading";
16
+ import TableTitle from "./modules/TableTitle.vue";
17
+ import { isFunction } from "../../../utils";
6
18
  export default {
7
19
  name: "PageComponent",
8
- props: {},
9
- setup(props, { emit, slots }) {
20
+ props: {
21
+ searchApi: {
22
+ type: String,
23
+ default: "",
24
+ },
25
+ searchConfig: {
26
+ type: Object,
27
+ default: () => {
28
+ return {};
29
+ },
30
+ },
31
+ pageSize: Number,
32
+ tableHandleList: {
33
+ type: Array,
34
+ default: () => {
35
+ return ["sort", "download"];
36
+ },
37
+ },
38
+ searchProps: {
39
+ type: Object,
40
+ default: () => {
41
+ return {};
42
+ },
43
+ },
44
+ tableProps: {
45
+ type: Object,
46
+ default: () => {
47
+ return {};
48
+ },
49
+ },
50
+ loadProps: {
51
+ type: Object,
52
+ default: () => {
53
+ return {};
54
+ },
55
+ },
56
+ paginationProps: {
57
+ type: Object,
58
+ default: () => {
59
+ return {};
60
+ },
61
+ },
62
+ cbs: {
63
+ type: Object,
64
+ default: () => {
65
+ return {};
66
+ },
67
+ },
68
+ },
69
+ setup(props, { emit, slots, expose }) {
70
+ const baseDao = inject("$ctBaseDao");
71
+ const serviceConfig = inject("$ctServiceConfig");
72
+ const searchMethod =
73
+ props.searchConfig.method || serviceConfig.defaultMethod || "post";
74
+ const downlaodMethod =
75
+ props.searchConfig.downlaodMethod ||
76
+ serviceConfig.defaultDownlaodMethod ||
77
+ "handlerDownload";
78
+ const state = reactive({
79
+ total: 0,
80
+ pageSize: props.pageSize,
81
+ pageNo: 1,
82
+ sortObj: {},
83
+ searchParams: {},
84
+ pageLoading: false,
85
+ downloadLoading: false,
86
+ });
87
+ const downloadLoading = ref(false);
88
+ provide("downloadLoading", downloadLoading);
10
89
  const getSelfSlots = (name) => {
11
- console.log(slots);
12
90
  if (!name) return null;
13
91
  const key = `_${name}-`;
14
92
  const res = {};
@@ -19,13 +97,67 @@ export default {
19
97
  });
20
98
  return res;
21
99
  };
100
+ // searchBox逻辑
101
+ const searchRef = ref(null);
102
+ const doSearch = (params) => {
103
+ console.log("doSearch", params);
104
+ state.searchParams = params;
105
+ state.pageNo = 1;
106
+ getPageData();
107
+ };
108
+ const getPageData = async (download = false) => {
109
+ let dataP = {
110
+ ...state.searchParams,
111
+ };
112
+ if (props.pageSize) {
113
+ dataP.pageSize = props.pageSize;
114
+ dataP.pageNo = state.pageNo;
115
+ }
116
+ state.pageLoading = true;
117
+ if (isFunction(props.cbs.doSearch)) {
118
+ await props.cbs.doSearch(dataP);
119
+ state.pageLoading = false;
120
+ return;
121
+ }
122
+ if (isFunction(props.cbs.beforeSearch)) {
123
+ const paramsHandle = await props.cbs.beforeSearch(dataP);
124
+ if (paramsHandle === false) return;
125
+ dataP = paramsHandle || dataP;
126
+ }
127
+ if (download) {
128
+ if (isFunction(props.cbs.doDownload)) {
129
+ await props.cbs.doDownload(dataP);
130
+ } else {
131
+ await baseDao[downlaodMethod](props.searchApi, dataP);
132
+ }
133
+ return;
134
+ }
135
+ await baseDao[searchMethod](props.searchApi, dataP)
136
+ .then(async (res) => {
137
+ let data = res || {};
138
+ if (isFunction(props.cbs.afterSearch)) {
139
+ const dataHandle = await props.cbs.afterSearch(data);
140
+ if (dataHandle) data = dataHandle;
141
+ }
142
+ const { total, tableData, columnData, list } = data;
143
+ state.total = total || 0;
144
+ if (columnData) {
145
+ tableProps.columnData = columnData;
146
+ }
147
+ tableProps.tableData = tableData || list || [];
148
+ })
149
+ .finally(() => {
150
+ state.pageLoading = false;
151
+ });
152
+ state.pageLoading = false;
153
+ };
154
+
155
+ const tableTitleRef = ref(null);
156
+ // tableBox逻辑
157
+ const tableRef = ref(null);
158
+ const paginationRef = ref(null);
22
159
  const tableProps = reactive({
23
- columnData: [
24
- { label: "序号", value: "index" },
25
- { label: "校验结果", value: "result" },
26
- { label: "处理状态", value: "status" },
27
- { label: "操作", value: "id" },
28
- ],
160
+ columnData: props.tableProps.columnData || [],
29
161
  tableData: [
30
162
  { index: 1, result: 3, status: "暂未处理" },
31
163
  { index: 2, result: 0, status: "无需处理" },
@@ -33,46 +165,157 @@ export default {
33
165
  { index: 4, result: 0, status: "处理完成" },
34
166
  ],
35
167
  });
168
+ const sortList = computed(() => {
169
+ const tableSortList = props.tableProps.columnData.filter((item) => {
170
+ return item.sortable;
171
+ });
172
+ return tableSortList || [];
173
+ });
174
+ const changeSort = (val) => {
175
+ state.pageNo = 1;
176
+ state.sortObj = val;
177
+ getPageData();
178
+ };
179
+ const changePageNo = (val) => {
180
+ console.log("changePageNo", val);
181
+ state.pageNo = val;
182
+ getPageData();
183
+ };
184
+ const doDownload = async () => {
185
+ downloadLoading.value = true;
186
+ try {
187
+ await getPageData(true);
188
+ } catch (error) {}
189
+ await new Promise((resolve) => {
190
+ setTimeout(() => {
191
+ resolve();
192
+ }, 3000);
193
+ });
194
+ downloadLoading.value = false;
195
+ };
36
196
 
37
- const tableDom = h(
38
- tableBox,
39
- {
40
- "table-props": tableProps,
41
- },
42
- { ...getSelfSlots("table") }
43
- );
44
- const searchDom = h(
45
- SearchBox,
46
- {
47
- "search-list": [],
48
- "have-reset": true,
49
- },
50
- { ...slots }
51
- );
52
197
  const ns = useNamespace("page-component");
198
+ expose({
199
+ searchMethod,
200
+ searchRef,
201
+ tableTitleRef,
202
+ tableRef,
203
+ paginationRef,
204
+ doSearch,
205
+ getPageData,
206
+ changePageNo,
207
+ changeSort,
208
+ });
53
209
  return () =>
54
210
  h("div", { class: ns.b() }, [
55
211
  h("div", { class: ns.e("container") }, [
56
212
  h("div", { class: ns.e("header") }, [
57
- h(
58
- "div",
59
- slots.header
60
- ? slots.header()
61
- : h("div", { class: ns.em("header", "default") }, [
62
- slots.headerBefore ? slots.headerBefore() : null,
63
- h("div", { class: ns.e("header-search") }, [searchDom]),
64
- slots.headerAfter ? slots.headerAfter() : null,
65
- ])
66
- ),
67
- // h('ct-search-box', {
68
- // searchList: searchList,
69
- // haveReset: true,
70
- // onDoSearch: doSearch
71
- // })
213
+ slots.header
214
+ ? slots.header()
215
+ : h("div", { class: ns.em("header", "default") }, [
216
+ slots.headerBefore ? slots.headerBefore() : null,
217
+ h("div", { class: ns.e("search") }, [
218
+ h(
219
+ SearchBox,
220
+ {
221
+ onDoSearch: doSearch,
222
+ ...props.searchProps,
223
+ ref: searchRef,
224
+ },
225
+ { ...getSelfSlots("search") }
226
+ ),
227
+ ]),
228
+ slots.headerAfter ? slots.headerAfter() : null,
229
+ ]),
230
+ ]),
231
+ h("div", { class: ns.e("content") }, [
232
+ slots.content
233
+ ? slots.content()
234
+ : h("div", { class: ns.em("content", "default") }, [
235
+ h(
236
+ CtLoading,
237
+ { "is-load": state.pageLoading, ...props.loadProps },
238
+ {
239
+ default: () => [
240
+ slots.contentBefore ? slots.contentBefore() : null,
241
+ slots.tableTop
242
+ ? slots.tableTitle()
243
+ : h(
244
+ TableTitle,
245
+ {
246
+ total: state.total,
247
+ pageSize: state.pageSize,
248
+ handleList: props.tableHandleList,
249
+ sortList: sortList.value,
250
+ sortObj: state.sortObj,
251
+ "onUpdate:sortObj": (val) => {
252
+ state.sortObj = val;
253
+ },
254
+ onChangeSort: changeSort,
255
+ onDownload: doDownload,
256
+ ref: tableTitleRef,
257
+ },
258
+ {
259
+ tableTitle: slots.tableTitle,
260
+ tableDesc: slots.tableDesc,
261
+ }
262
+ ),
263
+ h("div", { class: ns.e("table") }, [
264
+ h(
265
+ TableBox,
266
+ {
267
+ "table-props": tableProps,
268
+ ...props.tableProps,
269
+ ref: tableRef,
270
+ },
271
+ { ...getSelfSlots("table") }
272
+ ),
273
+ h(CtPagination, {
274
+ class: ns.e("pagination"),
275
+ pageSize: state.pageSize,
276
+ total: state.total,
277
+ "current-page": state.pageNo,
278
+ "onUpdate:current-page": changePageNo,
279
+ ...props.paginationProps,
280
+ ref: paginationRef,
281
+ }),
282
+ ]),
283
+ slots.contentAfter ? slots.contentAfter() : null,
284
+ ],
285
+ }
286
+ ),
287
+ ]),
72
288
  ]),
73
- h("div", { class: ns.e("content") }, [tableDom]),
74
289
  ]),
75
290
  ]);
76
291
  },
77
292
  };
78
- </script>
293
+ </script>
294
+ <style lang='less' scoped>
295
+ .ct-page-component {
296
+ --content-spacing-horizontal: 20px;
297
+ &__header {
298
+ background-color: #fff;
299
+ padding: var(--content-spacing-horizontal);
300
+ margin-bottom: 16px;
301
+ border-radius: var(--ct-border-radius);
302
+ :deep(.ct-search-box) {
303
+ margin-bottom: 0;
304
+ }
305
+ }
306
+ &__content {
307
+ background-color: #fff;
308
+ padding: 0 var(--content-spacing-horizontal)
309
+ var(--content-spacing-horizontal);
310
+ border-radius: var(--ct-border-radius);
311
+ :deep(.ct-table-box) {
312
+ margin-bottom: 0;
313
+ }
314
+ }
315
+ &__pagination {
316
+ justify-content: flex-end;
317
+ margin-top: 15px;
318
+ margin-bottom: 0;
319
+ }
320
+ }
321
+ </style>
@@ -114,8 +114,12 @@ const componentAll = computed(() => {
114
114
  };
115
115
  return componentMap;
116
116
  });
117
+ const buriedParams = ref({});
117
118
  const handleBuriedParams = (params) => {
118
- console.log(params);
119
+ const key = params.value;
120
+ if (key) {
121
+ buriedParams.value[key] = params;
122
+ }
119
123
  };
120
124
  const getComponentProps = (item) => {
121
125
  const bpKey = toFirstUpperCase(buriedParamsKey);
@@ -164,6 +168,7 @@ defineExpose({
164
168
  searchParamsCurrent,
165
169
  componentAll: componentAll.value,
166
170
  getComponent,
171
+ buriedParams,
167
172
  });
168
173
  onMounted(() => {});
169
174
  </script>
@@ -92,7 +92,7 @@ const showOptions = computed(() => {
92
92
  });
93
93
  const valueModel = computed({
94
94
  get() {
95
- return props.modelValue || (props.multiple ? [] : "");
95
+ return props.modelValue || (props.multiple ? [] : props.modelValue);
96
96
  },
97
97
  set(newValue) {
98
98
  emit("update:modelValue", newValue);
@@ -303,6 +303,9 @@ defineExpose({
303
303
  }
304
304
  }
305
305
  &__popper {
306
+ &.is-multiple {
307
+ min-width: 140px;
308
+ }
306
309
  .el-select-dropdown__wrap {
307
310
  max-height: unset;
308
311
  }
@@ -24,7 +24,7 @@ export const tableProps = {
24
24
  return []
25
25
  }
26
26
  },
27
- isMultiSelect: {
27
+ isMultiSelect: {//是否开启多选
28
28
  type: Boolean,
29
29
  default: false
30
30
  },
@@ -32,8 +32,16 @@ export const tableProps = {
32
32
  type: Array,
33
33
  default: [],
34
34
  },
35
+ multiSelectAttr: {
36
+ type: Object,
37
+ default: () => {
38
+ return {
39
+ width:'88'
40
+ }
41
+ }
42
+ },
35
43
  teleportDom: {
36
- type: String,
44
+ type:[String, Node],
37
45
  },
38
46
  defaultSort: {
39
47
  type: Object,
@@ -1,21 +1,17 @@
1
1
  <template>
2
2
  <div :class="[ns.b()]">
3
3
  <div :class="[ns.e('container')]">
4
- <el-table
5
- ref="tableRef"
4
+ <el-table ref="tableRef"
6
5
  :class="[ns.e('body')]"
7
6
  :data="showData"
8
7
  :span-method="spanMethod"
9
8
  @selection-change="handleSelectChange"
10
- row-key="rowKey"
11
- v-bind="$attrs"
12
- >
9
+ row-key="rowKey" v-bind="$attrs">
13
10
  <el-table-column
14
11
  v-if="isMultiSelect"
15
- type="selection"
16
- width="88"
17
- :reserve-selection="true"
18
- ></el-table-column>
12
+ type="selection" width="88"
13
+ v-bind="multiSelectAttr"
14
+ :reserve-selection="true"></el-table-column>
19
15
  <el-table-column
20
16
  v-for="(column, index) in columnData"
21
17
  :key="column.value + '-' + column.label"
@@ -28,25 +24,25 @@
28
24
  :align="column.align || 'center'"
29
25
  :fixed="column.fixed || false"
30
26
  show-overflow-tooltip
31
- v-bind="column.rawAttr || {}"
32
- >
33
- <template #header="scope" v-if="column.slotHeader">
27
+ v-bind="column.rawAttr || {}">
28
+ <template #header="scope"
29
+ v-if="column.slotHeader">
34
30
  <slot
35
31
  :name="column.value + 'Header'"
36
32
  v-bind="scope"
37
33
  :column="column"
38
34
  :label="column.label"
39
- :value="column.value"
40
- ></slot>
35
+ :value="column.value">
36
+ </slot>
41
37
  </template>
42
38
  <template #default="scope">
43
- <slot
44
- :name="column.value"
39
+ <slot :name="column.value"
45
40
  :value="scope.row[column.value]"
46
41
  v-bind="scope"
47
- :column="column"
48
- >
49
- <span>{{ scope.row[column.value] }}</span>
42
+ :column="column">
43
+ <span>{{
44
+ scope.row[column.value]
45
+ }}</span>
50
46
  </slot>
51
47
  <el-table-column
52
48
  v-for="(column1, index) in column.children"
@@ -60,16 +56,16 @@
60
56
  :align="column1.align || 'center'"
61
57
  :fixed="column1.fixed || false"
62
58
  show-overflow-tooltip
63
- v-bind="column1.rawAttr || {}"
64
- >
59
+ v-bind="column1.rawAttr || {}">
65
60
  <template #default="scope">
66
61
  <slot
67
62
  :name="column1.value"
68
63
  :value="scope.row[column1.value]"
69
64
  v-bind="scope"
70
- :column="column1"
71
- >
72
- <span>{{ scope.row[column1.value] }}</span>
65
+ :column="column1">
66
+ <span>{{
67
+ scope.row[column1.value]
68
+ }}</span>
73
69
  </slot>
74
70
  </template>
75
71
  </el-table-column>
@@ -77,12 +73,12 @@
77
73
  </el-table-column>
78
74
  <template #empty>
79
75
  <slot name="empty">
80
- <component
81
- :is="tableEmptyDom"
76
+ <component :is="tableEmptyDom"
82
77
  v-if="tableEmptyDom"
83
- :text="emptyText"
84
- ></component>
85
- <span v-else>{{ emptyText }}</span>
78
+ :text="emptyText">
79
+ </component>
80
+ <span v-else>{{ emptyText
81
+ }}</span>
86
82
  </slot>
87
83
  </template>
88
84
  </el-table>
@@ -92,11 +88,13 @@
92
88
  :total="total"
93
89
  :current-page="pageNo"
94
90
  v-if="pageSize"
95
- @current-change="handleCurrentChange"
96
- ></ct-pagination>
91
+ @current-change="handleCurrentChange"></ct-pagination>
97
92
  </div>
98
- <Teleport :to="`#${teleportDom}`" v-if="teleportDom && teleportStatus">
99
- <table-sort v-model:sort-obj="sortObj" :sort-list="sortList"></table-sort>
93
+ <Teleport :to="`#${teleportDom}`"
94
+ v-if="teleportDom && teleportStatus">
95
+ <table-sort
96
+ v-model:sort-obj="sortObj"
97
+ :sort-list="sortList"></table-sort>
100
98
  </Teleport>
101
99
  </div>
102
100
  </template>
@@ -245,6 +243,7 @@ const sortList = computed(() => {
245
243
  });
246
244
  onMounted(() => {
247
245
  teleportStatus.value = true; //直到dom挂载完毕再挂载teleport组件
246
+ console.log(props.teleportDom);
248
247
  });
249
248
 
250
249
  defineExpose({ tableRef });
@@ -253,6 +252,7 @@ defineExpose({ tableRef });
253
252
  .ct-table__body {
254
253
  width: 100%;
255
254
  }
255
+
256
256
  .ct-table__pagination {
257
257
  margin-top: 24px;
258
258
  display: flex;
@@ -26,7 +26,7 @@ export const useBarEcharts = (type, option, data) => {
26
26
  function update(data) {
27
27
  //数据更新方式
28
28
  if (data.length == 0) {
29
- console.log('用户没有传入图表数据,请在hooks外处理');
29
+ console.warn('用户没有传入图表数据,请在hooks外处理');
30
30
  return;
31
31
  }
32
32
  if (data.length > 1) {
@@ -59,13 +59,13 @@ export const useBarEcharts = (type, option, data) => {
59
59
  { deep: true, immediate: true }
60
60
  );
61
61
  // 灵活配置并入option
62
-
63
- watch(() => option, (val) => {
64
- objectMerge(barOption.value, option);
65
- },
66
- {
62
+
63
+ watch(() => option, (val) => {
64
+ objectMerge(barOption.value, option);
65
+ },
66
+ {
67
67
  deep: true, immediate: true
68
- })
68
+ })
69
69
  return {
70
70
  barOption,
71
71
  itemTemplate
@@ -30,7 +30,7 @@ export const useLineEcharts = (type, option, data) => {
30
30
  function update(data) {
31
31
  //数据更新方式
32
32
  if (data.length == 0) {
33
- console.log('用户没有传入图表数据,请在hooks外处理');
33
+ console.warn('用户没有传入图表数据,请在hooks外处理');
34
34
  return;
35
35
  }
36
36
  if (data.length > 1) {
@@ -78,7 +78,7 @@ export const useLineEcharts = (type, option, data) => {
78
78
  }, {
79
79
  deep: true, immediate: true
80
80
  })
81
-
81
+
82
82
  return {
83
83
  lineOption,
84
84
  itemTemplate