ct-component-plus 0.0.11 → 0.0.12

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,7 +1,7 @@
1
1
  {
2
2
  "name": "ct-component-plus",
3
3
  "private": false,
4
- "version": "0.0.11",
4
+ "version": "0.0.12",
5
5
  "type": "module",
6
6
  "main": "packages/components/index.js",
7
7
  "files": [
@@ -57,6 +57,7 @@ const install = function (app, options) {
57
57
  app.use(cingtaIcon)
58
58
  let serviceOptions = {}
59
59
  if (isObject(options)) {
60
+ const { tableEmptyDom } = options;
60
61
  if (!options.baseDao) {
61
62
  console.warn('当前使用的组件库没有配置baseDao')
62
63
  } else {
@@ -64,6 +65,7 @@ const install = function (app, options) {
64
65
  }
65
66
  if (isObject(options.serviceOptions)) serviceOptions = options.serviceOptions;
66
67
  if (isObject(options.searchBoxComponent)) app.provide('$userDefinedSearchComponent', options.searchBoxComponent)
68
+ if (isObject(tableEmptyDom)) app.provide('$tableEmptyDom', tableEmptyDom)
67
69
  }
68
70
  app.provide('$ctServiceConfig', { ...serviceConfig, ...serviceOptions })
69
71
  }
@@ -43,5 +43,9 @@ export const tableProps = {
43
43
  },
44
44
  pagination: {
45
45
  type: [Number, String],
46
- }
46
+ },
47
+ emptyText: {
48
+ type: String,
49
+ default: "暂无数据",
50
+ },
47
51
  }
@@ -75,6 +75,16 @@
75
75
  </el-table-column>
76
76
  </template>
77
77
  </el-table-column>
78
+ <template #empty>
79
+ <slot name="empty">
80
+ <component
81
+ :is="tableEmptyDom"
82
+ v-if="tableEmptyDom"
83
+ :text="emptyText"
84
+ ></component>
85
+ <span v-else>{{ emptyText }}</span>
86
+ </slot>
87
+ </template>
78
88
  </el-table>
79
89
  <ct-pagination
80
90
  :class="ns.e('pagination')"
@@ -92,21 +102,14 @@
92
102
  </template>
93
103
 
94
104
  <script setup>
95
- import {
96
- computed,
97
- defineAsyncComponent,
98
- nextTick,
99
- onMounted,
100
- reactive,
101
- ref,
102
- watch,
103
- } from "vue";
105
+ import { computed, inject, onMounted, ref, watch } from "vue";
104
106
  import { useNamespace } from "../../../hooks";
105
107
  import { copyObj } from "../../../utils";
106
108
  import { tableEmits, tableProps } from "./index";
107
109
  import TableSort from "./TableSort.vue";
108
110
  const props = defineProps(tableProps);
109
111
  const emit = defineEmits(tableEmits);
112
+ const tableEmptyDom = inject("$tableEmptyDom");
110
113
 
111
114
  const ns = useNamespace("table");
112
115
  const tableRef = ref(null);