ct-component-plus 0.0.11 → 0.0.13

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.13",
5
5
  "type": "module",
6
6
  "main": "packages/components/index.js",
7
7
  "files": [
@@ -12,6 +12,7 @@
12
12
  :show-all-levels="showAllLevels"
13
13
  :filterable="filterable"
14
14
  :clearable="clearable"
15
+ :disabled="disabled"
15
16
  :popper-class="popperClassShow"
16
17
  v-bind="{ ...$attrs, ...rawAttr }"
17
18
  />
@@ -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
  }
@@ -124,13 +124,15 @@ const getComponentProps = (item) => {
124
124
  param: item.param,
125
125
  label: item.label,
126
126
  options: item.list,
127
- placeholder: item.placeholder,
128
127
  multiple: item.multiple,
128
+ api: item.api,
129
+ placeholder: item.placeholder,
129
130
  clearable: item.clearable,
130
131
  disabled: item.disabled,
131
132
  range: item.range,
132
133
  mapObj: item.mapObj,
133
134
  name: item.param, //用作插槽名
135
+ rawAttr: item.rawAttr,
134
136
 
135
137
  ["on" + bpKey]: handleBuriedParams,
136
138
  };
@@ -78,13 +78,13 @@ const serviceConfig = inject("$ctServiceConfig");
78
78
  const props = defineProps(selectProps);
79
79
  const emit = defineEmits(selectEmits);
80
80
 
81
- const getBuriedContent = () => {
82
- const select = selectObj.value;
83
- if (isArray(select)) {
84
- return select.map((item) => item.label);
85
- }
86
- return select.label;
87
- };
81
+ // const getBuriedContent = () => {
82
+ // const select = selectObj.value;
83
+ // if (isArray(select)) {
84
+ // return select.map((item) => item.label);
85
+ // }
86
+ // return select.label;
87
+ // };
88
88
  const ns = useNamespace("select");
89
89
  const optionsByApi = ref([]);
90
90
  const showOptions = computed(() => {
@@ -107,12 +107,21 @@ const selectLength = computed(() => {
107
107
  });
108
108
  const filterOptions = ref([]);
109
109
  const noFilterOptions = ref(false);
110
- const selectObj = computed(() => {
111
- if (!props.multiple)
112
- return showOptions.value.find((item) => item.value === valueModel.value);
113
- return showOptions.value.filter((item) => {
114
- return valueModel.value.includes(item.value);
115
- });
110
+ const selectObj = computed({
111
+ get() {
112
+ if (!props.multiple)
113
+ return showOptions.value.find((item) => item.value === valueModel.value);
114
+ return showOptions.value.filter((item) => {
115
+ return valueModel.value.includes(item.value);
116
+ });
117
+ },
118
+ set(newValue) {
119
+ if (!props.multiple) {
120
+ valueModel.value = newValue.value;
121
+ } else {
122
+ valueModel.value = newValue.map((item) => item.value);
123
+ }
124
+ },
116
125
  });
117
126
  const selectText = computed(() => {
118
127
  if (!props.multiple) return "";
@@ -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);