gy-ui-plus 1.0.9 → 1.0.10

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.
@@ -1,301 +0,0 @@
1
- <template>
2
- <component
3
- :is="isShowRules ? 'el-form-item' : 'div'"
4
- :prop="prop"
5
- :rules="configEdit.rules"
6
- :class="[
7
- configEdit.className,
8
- { single_edit_cell_rules: configEdit.rules },
9
- 'single_edit_cell'
10
- ]"
11
- v-bind="$attrs"
12
- >
13
- <!-- 编辑组件自定义插槽 -->
14
- <template v-if="configEdit.editSlotName">
15
- <div :class="[prop, 'slot_edit_name']" @keyup="keyUpHandle">
16
- <slot :name="configEdit.editSlotName" :scope="scope" />
17
- </div>
18
- </template>
19
- <template v-if="configEdit.isSelfCom">
20
- <component
21
- v-if="configEdit.editComponent === 't-select-table'"
22
- :ref="(el:any) => handleRef(el,configEdit)"
23
- :is="configEdit.editComponent"
24
- :placeholder="configEdit.placeholder || getPlaceholder(configEdit)"
25
- v-bind="
26
- typeof configEdit.bind == 'function'
27
- ? configEdit.bind(scope)
28
- : { clearable: true, filterable: true, ...configEdit.bind }
29
- "
30
- :style="{ width: configEdit.width || '100%' }"
31
- v-on="cEvent(configEdit, 't-select-table')"
32
- />
33
- <component
34
- v-else
35
- :is="configEdit.editComponent"
36
- v-model="childValue"
37
- :placeholder="configEdit.placeholder || getPlaceholder(configEdit)"
38
- :ref="(el: any) => getRefs(el, configEdit)"
39
- v-bind="
40
- typeof configEdit.bind == 'function'
41
- ? configEdit.bind(scope)
42
- : { clearable: true, filterable: true, ...configEdit.bind }
43
- "
44
- @change="handleEvent(configEdit.event)"
45
- :style="{ width: configEdit.width || '100%' }"
46
- v-on="cEvent(configEdit)"
47
- />
48
- </template>
49
- <component
50
- v-if="!configEdit.editSlotName && !configEdit.isSelfCom"
51
- :is="configEdit.editComponent || 'el-input'"
52
- v-model="childValue"
53
- :type="configEdit.type"
54
- :placeholder="configEdit.placeholder || getPlaceholder(configEdit)"
55
- :ref="(el: any) => getRefs(el, configEdit)"
56
- :class="prop"
57
- @change="handleEvent(configEdit.event)"
58
- @keyup="keyUpHandle"
59
- :style="{ width: configEdit.width || '100%' }"
60
- v-on="cEvent(configEdit)"
61
- v-bind="
62
- typeof configEdit.bind == 'function'
63
- ? configEdit.bind(scope)
64
- : { clearable: true, filterable: true, ...configEdit.bind }
65
- "
66
- >
67
- <!-- 前置文本 -->
68
- <template #prepend v-if="configEdit.prepend">{{ configEdit.prepend }}</template>
69
- <!-- 后置文本 -->
70
- <template #append v-if="configEdit.append">{{ configEdit.append }}</template>
71
- <!-- 子组件自定义插槽 -->
72
- <!-- <template v-if="configEdit.childSlotName">
73
- <slot />
74
- </template>-->
75
- <template v-if="!configEdit.editComponent.includes('date')">
76
- <component
77
- :is="compChildName(configEdit)"
78
- v-for="(value, key) in selectListType(configEdit)"
79
- :key="key"
80
- :disabled="value.disabled"
81
- :label="compChildLabel(configEdit, value)"
82
- :value="compChildValue(configEdit, value, key)"
83
- >{{ compChildShowLabel(configEdit, value) }}</component
84
- >
85
- </template>
86
- </component>
87
- </component>
88
- </template>
89
-
90
- <script setup lang="ts">
91
- import { computed, ref, watch } from "vue"
92
- defineOptions({
93
- name: "SingleEditCell"
94
- })
95
- const props = defineProps({
96
- /** 编辑配置项说明
97
- * label: '爱好', // placeholder显示
98
- * editComponent: 'el-select', // 组件
99
- * type: 'select-arr', // option显示
100
- * list: 'hobbyList', // 下拉选择数据源
101
- * arrLabel: 'label', // 下拉选择中文显示
102
- * arrKey: 'value' // 下拉选择number显示(最终传后台)
103
- * bind:{} // 组件衍生属性(即第三方组件属性)
104
- */
105
- configEdit: {
106
- type: Object as any,
107
- default: () => ({})
108
- },
109
- // 下拉选择数据源
110
- listTypeInfo: {
111
- type: Object,
112
- default: () => ({})
113
- },
114
- scope: {
115
- type: Object,
116
- default: () => ({})
117
- },
118
- prop: {
119
- type: String,
120
- default: "prop"
121
- },
122
- // 是否走表单验证(表头合并不校验)
123
- isShowRules: {
124
- type: Boolean,
125
- default: true
126
- },
127
- modelValue: {
128
- type: [String, Number, Array, Boolean, Date, Object]
129
- },
130
- // 列for index
131
- indexColumns: [String, Number]
132
- })
133
- // 抛出事件
134
- const emits = defineEmits(["handleEvent", "update:modelValue", "keyupHandle", "getRefs"])
135
- // vue3 v-model简写
136
- let childValue: any = computed({
137
- get() {
138
- return props?.modelValue
139
- },
140
- set(val) {
141
- emits("update:modelValue", val)
142
- }
143
- })
144
- watch(
145
- () => props.modelValue,
146
- data => {
147
- childValue.value = data
148
- }
149
- )
150
- // 绑定的相关事件
151
- const handleEvent = (type: string) => {
152
- setTimeout(() => {
153
- // console.log("组件", type, childValue.value)
154
- emits("handleEvent", { type, val: childValue.value })
155
- }, 0)
156
- }
157
- // 键盘事件
158
- const keyUpHandle = ($event: any) => {
159
- emits("keyupHandle", $event, props.scope.$index, props.prop)
160
- }
161
- // 引用第三方事件
162
- const cEvent: any = computed(() => {
163
- return ({ eventHandle }: any, type = "") => {
164
- let event = { ...eventHandle }
165
- let changeEvent = {} as any
166
- Object.keys(event).forEach(v => {
167
- changeEvent[v] = (e: any, ids: any) => {
168
- if (type === "t-select-table") {
169
- const argument = {
170
- row: e,
171
- ids: ids,
172
- prop: props.prop,
173
- scope: props.scope
174
- }
175
- event[v] && event[v](argument)
176
- } else {
177
- if ((typeof e === "number" && e === 0) || e) {
178
- event[v] && event[v]({ val: e, prop: props.prop, scope: props.scope })
179
- } else {
180
- event[v] && event[v]({ prop: props.prop, scope: props.scope })
181
- }
182
- }
183
- }
184
- })
185
- return { ...changeEvent }
186
- }
187
- })
188
-
189
- const selectListType = computed(() => {
190
- return (item: { list: string | number }) => {
191
- if (props.listTypeInfo) {
192
- return props.listTypeInfo[item.list]
193
- } else {
194
- return []
195
- }
196
- }
197
- })
198
- // 子组件名称
199
- const compChildName = computed(() => {
200
- return (configEdit: { type: any }) => {
201
- switch (configEdit.type) {
202
- case "checkbox":
203
- return "el-checkbox"
204
- case "radio":
205
- return "el-radio"
206
- case "select-arr":
207
- case "select-obj":
208
- return "el-option"
209
- }
210
- }
211
- })
212
- // 子子组件label
213
- const compChildLabel = computed(() => {
214
- return (configEdit: { type: any; arrLabel: any }, value: { [x: string]: any; value: any }) => {
215
- switch (configEdit.type) {
216
- case "radio":
217
- case "checkbox":
218
- return value[configEdit.arrLabel || "label"]
219
- case "el-select-multiple":
220
- case "select-arr":
221
- return value[configEdit.arrLabel || "label"]
222
- case "select-obj":
223
- return value
224
- }
225
- }
226
- })
227
- // 子子组件value
228
- const compChildValue = computed(() => {
229
- return (
230
- configEdit: { type: any; arrKey: any },
231
- value: { [x: string]: any; value: any },
232
- key: any
233
- ) => {
234
- switch (configEdit.type) {
235
- case "radio":
236
- case "checkbox":
237
- return value[configEdit.arrKey || "key"]
238
- case "el-select-multiple":
239
- case "select-arr":
240
- return value[configEdit.arrKey || "key"]
241
- case "select-obj":
242
- return key
243
- }
244
- }
245
- })
246
- // 子子组件文字展示
247
- const compChildShowLabel = computed(() => {
248
- return (configEdit: { type: any; arrLabel: any }, value: { [x: string]: any; label: any }) => {
249
- switch (configEdit.type) {
250
- case "radio":
251
- case "checkbox":
252
- return value[configEdit.arrLabel || "label"]
253
- case "el-select-multiple":
254
- case "select-arr":
255
- return value[configEdit.arrLabel || "label"]
256
- case "select-obj":
257
- return value
258
- }
259
- }
260
- })
261
- // 获取所有ref
262
- const getRefs = (el: any, item: any) => {
263
- emits("getRefs", el, item)
264
- }
265
- // 下拉选择表格组件 ref
266
- const tselecttableref: any = ref({})
267
- // 下拉选择表格组件 动态ref
268
- const handleRef = (el: any, item: any) => {
269
- emits("getRefs", el, item)
270
- if (el) {
271
- tselecttableref.value[`tselecttableref-${props.indexColumns}`] = el
272
- }
273
- }
274
- // 重置下拉表格
275
- const resetTselectTableFields = () => {
276
- // 获取所有下拉选择表格组件
277
- const refList = Object.keys(tselecttableref.value).filter(item =>
278
- item.includes("tselecttableref")
279
- )
280
- if (refList.length > 0 && tselecttableref.value) {
281
- refList.map(val => {
282
- tselecttableref.value[val].clear()
283
- })
284
- }
285
- }
286
- // placeholder的显示
287
- const getPlaceholder = (row: any) => {
288
- if (!row.editComponent || typeof row.editComponent !== "string") {
289
- return row.label
290
- }
291
- const componentType = row.editComponent.toLowerCase()
292
- if (componentType.includes("input")) {
293
- return "请输入" + row.label
294
- } else if (componentType.includes("select") || componentType.includes("date")) {
295
- return "请选择" + row.label
296
- }
297
- return row.label
298
- }
299
-
300
- defineExpose({ resetTselectTableFields })
301
- </script>
@@ -1,146 +0,0 @@
1
- import type { PropType, ExtractPropTypes } from "vue"
2
- export const tableProps = {
3
- // table所需数据
4
- table: {
5
- type: Object,
6
- default: () => {
7
- return {}
8
- },
9
- required: true
10
- },
11
- // 表头数据
12
- columns: {
13
- type: Array,
14
- default: () => {
15
- return []
16
- }
17
- // required: true
18
- },
19
- // 按钮权限数据集
20
- btnPermissions: {
21
- type: Array,
22
- default: () => {
23
- return []
24
- }
25
- },
26
- // 表格标题
27
- title: {
28
- type: String
29
- },
30
- tableTitle: String,
31
- // table对齐方式
32
- align: {
33
- type: String as PropType<"left" | "center" | "right">,
34
- default: "center"
35
- },
36
- // 是否开启Tree-table
37
- isTree: {
38
- type: Boolean,
39
- default: false
40
- },
41
- // 是否开启行拖拽
42
- isRowSort: {
43
- type: Boolean,
44
- default: false
45
- },
46
- // 开启行拖拽,第一列是否显示拖拽图标
47
- isRowSortIcon: {
48
- type: Boolean,
49
- default: false
50
- },
51
- // 显示拖拽列的配置
52
- rowSortIconBind: {
53
- type: Object,
54
- default: () => {
55
- return {}
56
- }
57
- },
58
- // 是否复制单元格
59
- isCopy: {
60
- type: Boolean,
61
- default: false
62
- },
63
- // 是否开启点击整行选中单选框
64
- rowClickRadio: {
65
- type: Boolean,
66
- default: true
67
- },
68
- // 设置默认选中项(单选)defaultRadioCol值必须大于0!
69
- defaultRadioCol: Number,
70
- // 序列号显示是否分页累加
71
- isPaginationCumulative: {
72
- type: Boolean,
73
- default: false
74
- },
75
- // 是否显示分页
76
- isShowPagination: {
77
- type: Boolean,
78
- default: true
79
- },
80
- // 是否开启编辑保存按钮
81
- isShowFooterBtn: {
82
- type: Boolean,
83
- default: false
84
- },
85
- // 是否显示设置(隐藏/显示列)
86
- columnSetting: {
87
- type: Boolean,
88
- default: false
89
- },
90
- // 是否高亮选中行
91
- highlightCurrentRow: {
92
- type: Boolean,
93
- default: false
94
- },
95
- // 如果设置为 'custom',则代表用户希望远程排序,需要监听 Table 的 sort-change 事件
96
- sortable: {
97
- type: [Boolean, String]
98
- },
99
- // 单元格编辑是否开启键盘事件
100
- isKeyup: {
101
- type: Boolean,
102
- default: false
103
- },
104
- // TAdaptivePage组件是否使用了Toolbar插槽
105
- isSlotToolbar: Boolean,
106
- // TAdaptivePage组件是否使用了title插槽
107
- isSlotTitle: Boolean,
108
- // 是否开启边框
109
- border: {
110
- type: Boolean,
111
- default: false
112
- },
113
- // table loading
114
- tableLoading: {
115
- type: Boolean,
116
- default: false
117
- },
118
- loadingTxt: {
119
- type: String,
120
- default: "加载中..."
121
- },
122
- // 是否开启虚拟列表
123
- useVirtual: Boolean,
124
- // 虚拟列表的渲染行数
125
- virtualShowSize: {
126
- type: Number,
127
- default: 30
128
- },
129
- footerBtnAlign: {
130
- type: String,
131
- default: "right"
132
- },
133
- /**
134
- * 空数据时表头是否显示校验红点
135
- */
136
- isEmptyDataRequired: {
137
- type: Boolean,
138
- default: false
139
- },
140
- saveBtnTxt: {
141
- type: String,
142
- default: "保存"
143
- }
144
- }
145
-
146
- export type TTableProps = ExtractPropTypes<typeof tableProps>
@@ -1,74 +0,0 @@
1
- import { ref } from "vue"
2
-
3
- export function useExpose() {
4
- // 获取el-table ref
5
- const GyTable = ref<HTMLElement | any>(null)
6
- // 清空复选框
7
- const clearSelection = () => {
8
- return GyTable.value.clearSelection()
9
- }
10
- // 返回当前选中的行
11
- const getSelectionRows = () => {
12
- return GyTable.value.getSelectionRows()
13
- }
14
- // 取消某一项选中项
15
- const toggleRowSelection = (row: any, selected = false) => {
16
- return GyTable.value.toggleRowSelection(row, selected)
17
- }
18
- // 全部选中
19
- const toggleAllSelection = () => {
20
- return GyTable.value.toggleAllSelection()
21
- }
22
- // 用于可扩展的表格或树表格,如果某行被扩展,则切换。 使用第二个参数,您可以直接设置该行应该被扩展或折叠。
23
- const toggleRowExpansion = (row: any, expanded: any) => {
24
- return GyTable.value.toggleRowExpansion(row, expanded)
25
- }
26
- // 用于单选表格,设定某一行为选中行, 如果调用时不加参数,则会取消目前高亮行的选中状态。
27
- const setCurrentRow = (row: any) => {
28
- return GyTable.value.setCurrentRow(row)
29
- }
30
- // 清空排序条件
31
- const clearSort = () => {
32
- return GyTable.value.clearSort()
33
- }
34
- // 传入由columnKey 组成的数组以清除指定列的过滤条件。 如果没有参数,清除所有过滤器
35
- const clearFilter = (columnKey: any) => {
36
- return GyTable.value.clearFilter(columnKey)
37
- }
38
- // Table 进行重新布局
39
- const doLayout = (columnKey: any) => {
40
- return GyTable.value.doLayout(columnKey)
41
- }
42
- // 手动排序表格。 参数 prop 属性指定排序列,order 指定排序顺序。
43
- const sort = (prop: string, order: string) => {
44
- return GyTable.value.sort(prop, order)
45
- }
46
- // 滚动到一组特定坐标。
47
- const scrollTo = (options: any, yCoord: any) => {
48
- return GyTable.value.scrollTo(options, yCoord)
49
- }
50
- // 设置垂直滚动位置
51
- const setScrollTop = (top: any) => {
52
- return GyTable.value.setScrollTop(top)
53
- }
54
- // 设置水平滚动位置
55
- const setScrollLeft = (left: any) => {
56
- return GyTable.value.setScrollLeft(left)
57
- }
58
- return {
59
- GyTable,
60
- clearSelection,
61
- getSelectionRows,
62
- toggleRowSelection,
63
- toggleAllSelection,
64
- toggleRowExpansion,
65
- setCurrentRow,
66
- clearSort,
67
- clearFilter,
68
- doLayout,
69
- sort,
70
- scrollTo,
71
- setScrollTop,
72
- setScrollLeft
73
- }
74
- }
@@ -1,70 +0,0 @@
1
- import { nextTick, ref } from "vue"
2
- import type { Ref } from "vue"
3
- export function useVirtualized() {
4
- // 渲染实际高度的容器
5
- const actualHeightContainerEl = ref<HTMLElement | any>(null)
6
- // 用于偏移的元素选择器
7
- const translateContainerEl = ref<HTMLElement | any>(null)
8
- // 滚动容器的元素选择器
9
- const scrollContainerEl = ref<HTMLElement | any>(null)
10
- // 所有数据
11
- const saveDATA: Ref<any[]> = ref([])
12
- // 缓存已渲染元素的高度
13
- const RenderedItemsCache: any = {}
14
- // 获取dom元素
15
- const getDom = () => {
16
- actualHeightContainerEl.value = document.querySelector(
17
- ".t_table_use_virtual .el-scrollbar__view"
18
- )
19
- translateContainerEl.value = document.querySelector(".t_table_use_virtual .el-table__body")
20
- scrollContainerEl.value = document.querySelector(".t_table_use_virtual .el-scrollbar__wrap")
21
- }
22
- // 获取缓存高度,无缓存,取配置项的 itemHeight
23
- const getItemHeightFromCache = (index: number | string) => {
24
- const val = RenderedItemsCache[index]
25
- return val === void 0 ? 50 : val
26
- }
27
- // 更新实际高度
28
- const updateActualHeight = () => {
29
- let actualHeight = 0
30
- saveDATA.value.forEach((_, i) => {
31
- actualHeight += getItemHeightFromCache(i)
32
- })
33
- actualHeightContainerEl.value!.style.height = actualHeight + "px"
34
- }
35
- // 更新偏移值
36
- const updateOffset = (offset: number) => {
37
- if (translateContainerEl.value && translateContainerEl.value.style) {
38
- translateContainerEl.value!.style.transform = `translateY(${offset}px)`
39
- }
40
- }
41
- // 更新已渲染列表项的缓存高度
42
- const updateRenderedItemCache = (index: number) => {
43
- // 当所有元素的实际高度更新完毕,就不需要重新计算高度
44
- const shouldUpdate = Object.keys(RenderedItemsCache).length < saveDATA.value.length
45
- if (!shouldUpdate) return
46
- nextTick(() => {
47
- // 获取所有列表项元素
48
- const Items: HTMLElement[] = Array.from(
49
- document.querySelectorAll(".t_table_use_virtual .el-table__row")
50
- )
51
- // 进行缓存
52
- Items.forEach(el => {
53
- if (!RenderedItemsCache[index]) {
54
- RenderedItemsCache[index] = el.offsetHeight
55
- }
56
- index++
57
- })
58
- // 更新实际高度
59
- updateActualHeight()
60
- })
61
- }
62
- return {
63
- scrollContainerEl,
64
- updateRenderedItemCache,
65
- updateOffset,
66
- getDom,
67
- getItemHeightFromCache,
68
- saveDATA
69
- }
70
- }
@@ -1 +0,0 @@
1
- import "./table.scss"