gy-ui-plus 1.0.0
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/README.md +0 -0
- package/dist/favicon.ico +0 -0
- package/dist/gy-ui-plus.es.js +41 -0
- package/dist/gy-ui-plus.umd.js +1 -0
- package/package.json +72 -0
- package/packages/index.ts +33 -0
- package/packages/j-button/index.ts +5 -0
- package/packages/j-button/src/index.vue +29 -0
- package/packages/j-table/index.ts +8 -0
- package/packages/j-table/src/ColumnSet.vue +170 -0
- package/packages/j-table/src/TTableColumn.vue +140 -0
- package/packages/j-table/src/index.vue +1205 -0
- package/packages/j-table/src/operator.vue +246 -0
- package/packages/j-table/src/renderCol.vue +24 -0
- package/packages/j-table/src/renderHeader.vue +18 -0
- package/packages/j-table/src/singleEdit.vue +406 -0
- package/packages/j-table/src/singleEditCell.vue +337 -0
- package/packages/j-table/src/tableProps.ts +174 -0
- package/packages/j-table/src/useExpose.ts +74 -0
- package/packages/j-table/src/useVirtualized.ts +70 -0
- package/packages/j-table/style/table.scss +368 -0
- package/packages/withInstall.ts +21 -0
package/README.md
ADDED
|
File without changes
|
package/dist/favicon.ico
ADDED
|
Binary file
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { defineComponent as m, ref as a, resolveComponent as u, createBlock as p, openBlock as f, mergeProps as d, withCtx as _, renderSlot as k } from "vue";
|
|
2
|
+
const C = {
|
|
3
|
+
name: "JButton"
|
|
4
|
+
}, w = /* @__PURE__ */ m({
|
|
5
|
+
...C,
|
|
6
|
+
props: {
|
|
7
|
+
time: {
|
|
8
|
+
type: Number,
|
|
9
|
+
default: 1e3
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
emits: ["click"],
|
|
13
|
+
setup(e, { emit: t }) {
|
|
14
|
+
const c = e, l = t, o = a(0), r = () => {
|
|
15
|
+
(/* @__PURE__ */ new Date()).getTime() - o.value > c.time && l("click"), o.value = (/* @__PURE__ */ new Date()).getTime();
|
|
16
|
+
};
|
|
17
|
+
return (n, b) => {
|
|
18
|
+
const i = u("el-button");
|
|
19
|
+
return f(), p(i, d(n.$attrs, { onClick: r }), {
|
|
20
|
+
default: _(() => [
|
|
21
|
+
k(n.$slots, "default")
|
|
22
|
+
]),
|
|
23
|
+
_: 3
|
|
24
|
+
}, 16);
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}), s = {
|
|
28
|
+
JButton: w
|
|
29
|
+
}, B = (e) => {
|
|
30
|
+
for (const t in s)
|
|
31
|
+
e.component(t, s[t]);
|
|
32
|
+
}, T = (e, t) => {
|
|
33
|
+
B(e);
|
|
34
|
+
}, h = {
|
|
35
|
+
// 导出的对象必须具有 install,才能被 Vue.use() 方法安装
|
|
36
|
+
install: T
|
|
37
|
+
};
|
|
38
|
+
export {
|
|
39
|
+
w as JButton,
|
|
40
|
+
h as default
|
|
41
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(t,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(t=typeof globalThis<"u"?globalThis:t||self,e(t["gy-ui-plus"]={},t.Vue))})(this,(function(t,e){"use strict";const u={name:"JButton"},s=e.defineComponent({...u,props:{time:{type:Number,default:1e3}},emits:["click"],setup(n,{emit:o}){const f=n,m=o,l=e.ref(0),p=()=>{new Date().getTime()-l.value>f.time&&m("click"),l.value=new Date().getTime()};return(i,k)=>{const a=e.resolveComponent("el-button");return e.openBlock(),e.createBlock(a,e.mergeProps(i.$attrs,{onClick:p}),{default:e.withCtx(()=>[e.renderSlot(i.$slots,"default")]),_:3},16)}}}),c={JButton:s},r=n=>{for(const o in c)n.component(o,c[o])},d={install:(n,o)=>{r(n)}};t.JButton=s,t.default=d,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
package/package.json
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "gy-ui-plus",
|
|
3
|
+
"publishConfig": {
|
|
4
|
+
"access": "public"
|
|
5
|
+
},
|
|
6
|
+
"version": "1.0.0",
|
|
7
|
+
"private": false,
|
|
8
|
+
"type": "module",
|
|
9
|
+
"main": "dist/gy-ui-plus.umd.js",
|
|
10
|
+
"module": "dist/gy-ui-plus.es.js",
|
|
11
|
+
"types": "dist/index.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"import": "./dist/gy-ui-plus.es.js",
|
|
15
|
+
"require": "./dist/gy-ui-plus.umd.js"
|
|
16
|
+
},
|
|
17
|
+
"./style.css": "./dist/style.css"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"packages"
|
|
22
|
+
],
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": "^20.19.0 || >=22.12.0"
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"lib": "vite build",
|
|
28
|
+
"deploy": "deploy.sh",
|
|
29
|
+
"dev": "vite",
|
|
30
|
+
"build": "run-p type-check \"build-only {@}\" --",
|
|
31
|
+
"preview": "vite preview",
|
|
32
|
+
"build-only": "vite build",
|
|
33
|
+
"type-check": "vue-tsc --build",
|
|
34
|
+
"lint:oxlint": "oxlint . --fix -D correctness --ignore-path .gitignore",
|
|
35
|
+
"lint:eslint": "eslint . --fix --cache",
|
|
36
|
+
"lint": "run-s lint:*",
|
|
37
|
+
"format": "prettier --write --experimental-cli src/"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"autofit.js": "^3.2.8",
|
|
41
|
+
"axios": "^1.13.2",
|
|
42
|
+
"element-plus": "^2.13.1",
|
|
43
|
+
"pinia": "^3.0.4",
|
|
44
|
+
"postcss-px-to-viewport": "^1.1.1",
|
|
45
|
+
"vue": "^3.5.25",
|
|
46
|
+
"vue-router": "^4.6.3"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@vitejs/plugin-vue": "^3.2.0",
|
|
50
|
+
"@vitejs/plugin-vue-jsx": "^2.0.1",
|
|
51
|
+
"vite-plugin-compression": "^0.5.1",
|
|
52
|
+
"vite-plugin-dts": "^1.7.3",
|
|
53
|
+
"vite-plugin-vue-setup-extend": "^0.4.0",
|
|
54
|
+
"@prettier/plugin-oxc": "^0.0.5",
|
|
55
|
+
"@tsconfig/node24": "^24.0.3",
|
|
56
|
+
"@types/node": "^24.10.1",
|
|
57
|
+
"@vue/eslint-config-prettier": "^10.2.0",
|
|
58
|
+
"@vue/tsconfig": "^0.8.1",
|
|
59
|
+
"eslint": "^9.39.1",
|
|
60
|
+
"eslint-plugin-oxlint": "~1.29.0",
|
|
61
|
+
"eslint-plugin-vue": "~10.5.1",
|
|
62
|
+
"jiti": "^2.6.1",
|
|
63
|
+
"npm-run-all2": "^8.0.4",
|
|
64
|
+
"oxlint": "~1.29.0",
|
|
65
|
+
"prettier": "3.6.2",
|
|
66
|
+
"sass": "^1.97.1",
|
|
67
|
+
"typescript": "~5.9.0",
|
|
68
|
+
"vite": "^7.2.4",
|
|
69
|
+
"vite-plugin-vue-devtools": "^8.0.5",
|
|
70
|
+
"vue-tsc": "^3.1.5"
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Component, App } from 'vue'
|
|
2
|
+
// import ElementPlus from 'element-plus'
|
|
3
|
+
// import 'element-plus/dist/index.css'
|
|
4
|
+
// import locale from 'element-plus/lib/locale/lang/zh-cn' // 因element-plus默认是英文,我们指定一下默认中文
|
|
5
|
+
import JButton from './j-button/src/index.vue'
|
|
6
|
+
|
|
7
|
+
// 存储组件列表
|
|
8
|
+
const components: {
|
|
9
|
+
[propName: string]: Component
|
|
10
|
+
} = {
|
|
11
|
+
JButton,
|
|
12
|
+
}
|
|
13
|
+
// 插件声明:声明所有插件
|
|
14
|
+
// 插件注册:在 Vue 项目的入口文件中,通过 ( app.use(插件) ) 进行注册
|
|
15
|
+
const installComponents: any = (app: App) => {
|
|
16
|
+
for (const key in components) {
|
|
17
|
+
app.component(key, components[key])
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
// vue插件
|
|
21
|
+
// - install:每个插件都有一个 install 方法
|
|
22
|
+
// - 参数:是通过 Vue.createApp() 创建的 app 实例
|
|
23
|
+
const install: any = (app: any, router?: any) => {
|
|
24
|
+
// !router && installRouter(app);
|
|
25
|
+
installComponents(app)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// 按需引入
|
|
29
|
+
export { JButton }
|
|
30
|
+
export default {
|
|
31
|
+
// 导出的对象必须具有 install,才能被 Vue.use() 方法安装
|
|
32
|
+
install,
|
|
33
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-button v-bind="$attrs" @click="handleClick">
|
|
3
|
+
<slot />
|
|
4
|
+
</el-button>
|
|
5
|
+
</template>
|
|
6
|
+
<script lang="ts">
|
|
7
|
+
export default {
|
|
8
|
+
name: 'JButton',
|
|
9
|
+
}
|
|
10
|
+
</script>
|
|
11
|
+
<script setup lang="ts">
|
|
12
|
+
import { ref } from 'vue'
|
|
13
|
+
const props = defineProps({
|
|
14
|
+
time: {
|
|
15
|
+
type: Number,
|
|
16
|
+
default: 1000,
|
|
17
|
+
},
|
|
18
|
+
})
|
|
19
|
+
// 抛出事件
|
|
20
|
+
const emits = defineEmits(['click'])
|
|
21
|
+
const record = ref(0)
|
|
22
|
+
const handleClick = () => {
|
|
23
|
+
const newTime = new Date()
|
|
24
|
+
if (newTime.getTime() - record.value > props.time) {
|
|
25
|
+
emits('click')
|
|
26
|
+
}
|
|
27
|
+
record.value = new Date().getTime()
|
|
28
|
+
}
|
|
29
|
+
</script>
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-dropdown trigger="click" popper-class="column_set">
|
|
3
|
+
<el-button v-bind="columnBind">{{ columnBind.btnTxt || "列设置" }}</el-button>
|
|
4
|
+
<template #dropdown>
|
|
5
|
+
<div class="title" v-if="columnBind.isShowTitle">{{ columnBind.title || "列设置" }}</div>
|
|
6
|
+
<el-dropdown-menu>
|
|
7
|
+
<el-dropdown-item :divided="columnBind.isShowTitle">
|
|
8
|
+
<el-tree
|
|
9
|
+
ref="treeRef"
|
|
10
|
+
class="t_table_column_setting_dropdown"
|
|
11
|
+
:data="state.columnSet"
|
|
12
|
+
node-key="prop"
|
|
13
|
+
:props="{ label: 'label', children: 'children', disabled: 'checkBoxDisabled' }"
|
|
14
|
+
show-checkbox
|
|
15
|
+
draggable
|
|
16
|
+
default-expand-all
|
|
17
|
+
check-strictly
|
|
18
|
+
:allow-drag="allowDrag"
|
|
19
|
+
:allow-drop="allowDrop"
|
|
20
|
+
:default-checked-keys="defaultCheckedKeys"
|
|
21
|
+
@check="onTreeCheck"
|
|
22
|
+
@node-drop="handleDrop"
|
|
23
|
+
>
|
|
24
|
+
</el-tree>
|
|
25
|
+
</el-dropdown-item>
|
|
26
|
+
</el-dropdown-menu>
|
|
27
|
+
</template>
|
|
28
|
+
</el-dropdown>
|
|
29
|
+
</template>
|
|
30
|
+
|
|
31
|
+
<script setup lang="ts">
|
|
32
|
+
import { watch, onMounted, reactive, computed, useAttrs, ref } from "vue"
|
|
33
|
+
defineOptions({
|
|
34
|
+
name: "ColumnSet"
|
|
35
|
+
})
|
|
36
|
+
export interface Column {
|
|
37
|
+
label: string
|
|
38
|
+
prop: string
|
|
39
|
+
checkBoxDisabled?: boolean
|
|
40
|
+
hidden?: boolean
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface ColumnSetProps {
|
|
44
|
+
columns: Column[]
|
|
45
|
+
title?: string
|
|
46
|
+
name?: string
|
|
47
|
+
columnSetBind?: Record<string, any>
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const props = withDefaults(defineProps<ColumnSetProps>(), {
|
|
51
|
+
columns: () => [],
|
|
52
|
+
title: "",
|
|
53
|
+
name: "",
|
|
54
|
+
columnSetBind: () => ({})
|
|
55
|
+
})
|
|
56
|
+
const treeRef = ref()
|
|
57
|
+
const $attrs: any = useAttrs()
|
|
58
|
+
const columnBind = computed(() => {
|
|
59
|
+
const columnSetBind = { btnTxt: "列设置", title: "列设置", ...props.columnSetBind }
|
|
60
|
+
return { size: "default", icon: "Setting", isShowTitle: true, ...$attrs, ...columnSetBind }
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
const emits = defineEmits(["columnSetting"])
|
|
64
|
+
const state = reactive({
|
|
65
|
+
columnSet: [] as Column[]
|
|
66
|
+
})
|
|
67
|
+
const defaultCheckedKeys = ref<string[]>([])
|
|
68
|
+
|
|
69
|
+
const getColumnSetCache = () => {
|
|
70
|
+
let value =
|
|
71
|
+
localStorage.getItem(`t-ui-plus:TTable.columnSet-${props.name || props.title}`) || "[]"
|
|
72
|
+
let columnOption = initColumnSet()
|
|
73
|
+
let valueArr = (JSON.parse(value) as any[]) || []
|
|
74
|
+
columnOption.forEach(item => {
|
|
75
|
+
let findEle = valueArr.find(
|
|
76
|
+
(ele: { label: any; prop: any }) => ele.label === item.label && ele.prop === item.prop
|
|
77
|
+
)
|
|
78
|
+
item.hidden = findEle ? findEle.hidden : false
|
|
79
|
+
})
|
|
80
|
+
value = JSON.stringify(valueArr.length ? valueArr : columnOption)
|
|
81
|
+
return value ? JSON.parse(value) : initColumnSet()
|
|
82
|
+
}
|
|
83
|
+
const initColumnSet = () => {
|
|
84
|
+
return props.columns.map((col: any) => ({
|
|
85
|
+
label: col.label,
|
|
86
|
+
prop: col.prop,
|
|
87
|
+
checkBoxDisabled: false,
|
|
88
|
+
hidden: false
|
|
89
|
+
}))
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
onMounted(() => {
|
|
93
|
+
state.columnSet = getColumnSetCache()
|
|
94
|
+
defaultCheckedKeys.value = state.columnSet.filter(c => !c.hidden).map(c => c.prop)
|
|
95
|
+
emits("columnSetting", state.columnSet)
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
watch(
|
|
99
|
+
() => state.columnSet,
|
|
100
|
+
val => {
|
|
101
|
+
emits("columnSetting", val)
|
|
102
|
+
localStorage.setItem(
|
|
103
|
+
`t-ui-plus:TTable.columnSet-${props.name || props.title}`,
|
|
104
|
+
JSON.stringify(val)
|
|
105
|
+
)
|
|
106
|
+
defaultCheckedKeys.value = state.columnSet.filter(c => !c.hidden).map(c => c.prop)
|
|
107
|
+
},
|
|
108
|
+
{ deep: true }
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
const reSetColumnSet = () => {
|
|
112
|
+
let value: any = localStorage.getItem(`t-ui-plus:TTable.columnSet-${props.name || props.title}`)
|
|
113
|
+
state.columnSet = JSON.parse(value)
|
|
114
|
+
defaultCheckedKeys.value = state.columnSet.filter(c => !c.hidden).map(c => c.prop)
|
|
115
|
+
emits("columnSetting", state.columnSet)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const onTreeCheck = () => {
|
|
119
|
+
// 获取最新勾选的key
|
|
120
|
+
const checkedKeys = treeRef.value?.getCheckedKeys() || []
|
|
121
|
+
state.columnSet.forEach(col => {
|
|
122
|
+
col.hidden = !checkedKeys.includes(col.prop)
|
|
123
|
+
})
|
|
124
|
+
// 至少保留一个可见列
|
|
125
|
+
const visibleCols = state.columnSet.filter(col => !col.hidden)
|
|
126
|
+
if (visibleCols.length < 2) {
|
|
127
|
+
visibleCols.forEach(col => (col.checkBoxDisabled = true))
|
|
128
|
+
} else {
|
|
129
|
+
state.columnSet.forEach(col => (col.checkBoxDisabled = false))
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
// 限制拖拽结点
|
|
133
|
+
const allowDrag = () => {
|
|
134
|
+
return true
|
|
135
|
+
}
|
|
136
|
+
const allowDrop = (draggingNode: any, dropNode: any, type: any) => {
|
|
137
|
+
// 只允许同级节点之间的拖拽
|
|
138
|
+
if (draggingNode.level !== dropNode.level) {
|
|
139
|
+
return false
|
|
140
|
+
}
|
|
141
|
+
// 如果是同级节点,还需要判断是否是前后节点的拖拽
|
|
142
|
+
if (type !== "prev" && type !== "next") {
|
|
143
|
+
return false
|
|
144
|
+
}
|
|
145
|
+
return true
|
|
146
|
+
}
|
|
147
|
+
// 拖拽排序
|
|
148
|
+
const handleDrop = (draggingNode: any, dropNode: any, dropType: string, ev: Event) => {
|
|
149
|
+
// 只允许拖拽到同级(禁止拖为子级)
|
|
150
|
+
if (dropType === "inner") {
|
|
151
|
+
ev.preventDefault()
|
|
152
|
+
return
|
|
153
|
+
}
|
|
154
|
+
const draggingIndex = state.columnSet.findIndex(col => col.prop === draggingNode.data.prop)
|
|
155
|
+
const dropIndex = state.columnSet.findIndex(col => col.prop === dropNode.data.prop)
|
|
156
|
+
if (draggingIndex === -1 || dropIndex === -1) return
|
|
157
|
+
const item = state.columnSet.splice(draggingIndex, 1)[0]
|
|
158
|
+
if (dropType === "before") {
|
|
159
|
+
// 如果拖拽项在目标项后面,直接插入;如果在前面,dropIndex要减1
|
|
160
|
+
const insertIndex = draggingIndex < dropIndex ? dropIndex - 1 : dropIndex
|
|
161
|
+
state.columnSet.splice(insertIndex, 0, item)
|
|
162
|
+
} else if (dropType === "after") {
|
|
163
|
+
state.columnSet.splice(dropIndex + 1, 0, item)
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
defineExpose({
|
|
168
|
+
reSetColumnSet
|
|
169
|
+
})
|
|
170
|
+
</script>
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-table-column
|
|
3
|
+
v-if="
|
|
4
|
+
typeof item.isShowCol == 'function'
|
|
5
|
+
? item.isShowCol(item)
|
|
6
|
+
: !item.isShowCol
|
|
7
|
+
"
|
|
8
|
+
:prop="item.prop"
|
|
9
|
+
:label="item.label"
|
|
10
|
+
:type="item.type"
|
|
11
|
+
:align="item.align || align"
|
|
12
|
+
:min-width="item['min-width'] || item.minWidth"
|
|
13
|
+
:width="item.width"
|
|
14
|
+
:fixed="item.fixed"
|
|
15
|
+
>
|
|
16
|
+
<template #header v-if="item.renderHeader">
|
|
17
|
+
<render-header :column="item" :render="item.renderHeader" />
|
|
18
|
+
</template>
|
|
19
|
+
<template v-for="(val, index) of item.children">
|
|
20
|
+
<t-table-column
|
|
21
|
+
v-if="val.children"
|
|
22
|
+
:key="index"
|
|
23
|
+
:item="val"
|
|
24
|
+
v-bind="$attrs"
|
|
25
|
+
>
|
|
26
|
+
<template v-for="(_index, name) in slots" v-slot:[name]="data">
|
|
27
|
+
<slot :name="name" v-bind="data"></slot>
|
|
28
|
+
</template>
|
|
29
|
+
</t-table-column>
|
|
30
|
+
<el-table-column
|
|
31
|
+
v-else
|
|
32
|
+
:key="val.prop"
|
|
33
|
+
:prop="val.prop"
|
|
34
|
+
:label="val.label"
|
|
35
|
+
:min-width="val['min-width'] || val.minWidth"
|
|
36
|
+
:width="val.width"
|
|
37
|
+
:sortable="val.sortable || val.sort || sortable"
|
|
38
|
+
:align="val.align || align"
|
|
39
|
+
:fixed="val.fixed"
|
|
40
|
+
:formatter="val.formatter"
|
|
41
|
+
v-if="
|
|
42
|
+
typeof val.isShowCol == 'function'
|
|
43
|
+
? val.isShowCol(val)
|
|
44
|
+
: !val.isShowCol
|
|
45
|
+
"
|
|
46
|
+
v-bind="{
|
|
47
|
+
'show-overflow-tooltip': true,
|
|
48
|
+
...val.bind,
|
|
49
|
+
...$attrs,
|
|
50
|
+
}"
|
|
51
|
+
>
|
|
52
|
+
<template #header v-if="val.renderHeader">
|
|
53
|
+
<render-header :column="val" :render="val.renderHeader" />
|
|
54
|
+
</template>
|
|
55
|
+
<template #default="scope">
|
|
56
|
+
<!-- render渲染 -->
|
|
57
|
+
<template v-if="val.render">
|
|
58
|
+
<render-col
|
|
59
|
+
:column="val"
|
|
60
|
+
:row="scope.row"
|
|
61
|
+
:render="val.render"
|
|
62
|
+
:index="scope.$index"
|
|
63
|
+
/>
|
|
64
|
+
</template>
|
|
65
|
+
<!-- 自定义插槽 -->
|
|
66
|
+
<template v-if="val.slotNameMerge">
|
|
67
|
+
<slot :name="val.slotNameMerge" :scope="scope"></slot>
|
|
68
|
+
</template>
|
|
69
|
+
<!-- 单个单元格编辑 -->
|
|
70
|
+
<template v-if="val.canEdit">
|
|
71
|
+
<single-edit-cell
|
|
72
|
+
:isShowRules="false"
|
|
73
|
+
:configEdit="val.configEdit"
|
|
74
|
+
v-model="scope.row[val.prop]"
|
|
75
|
+
:prop="val.prop"
|
|
76
|
+
:scope="scope"
|
|
77
|
+
@handleEvent="
|
|
78
|
+
({ type, val }) =>
|
|
79
|
+
emits(
|
|
80
|
+
'handleEvent',
|
|
81
|
+
type,
|
|
82
|
+
val,
|
|
83
|
+
scope.$index
|
|
84
|
+
)
|
|
85
|
+
"
|
|
86
|
+
v-bind="$attrs"
|
|
87
|
+
>
|
|
88
|
+
<template
|
|
89
|
+
v-for="(_index, name) in slots"
|
|
90
|
+
v-slot:[name]="data"
|
|
91
|
+
>
|
|
92
|
+
<slot :name="name" v-bind="data"></slot>
|
|
93
|
+
</template>
|
|
94
|
+
</single-edit-cell>
|
|
95
|
+
</template>
|
|
96
|
+
<div
|
|
97
|
+
v-if="
|
|
98
|
+
!val.render &&
|
|
99
|
+
!val.slotNameMerge &&
|
|
100
|
+
!val.canEdit &&
|
|
101
|
+
!val.formatter
|
|
102
|
+
"
|
|
103
|
+
>
|
|
104
|
+
{{ scope.row[val.prop] }}
|
|
105
|
+
</div>
|
|
106
|
+
</template>
|
|
107
|
+
</el-table-column>
|
|
108
|
+
</template>
|
|
109
|
+
</el-table-column>
|
|
110
|
+
</template>
|
|
111
|
+
|
|
112
|
+
<script setup lang="ts">
|
|
113
|
+
import SingleEditCell from "./singleEditCell.vue";
|
|
114
|
+
import RenderCol from "./renderCol.vue";
|
|
115
|
+
import RenderHeader from "./renderHeader.vue";
|
|
116
|
+
import { useSlots } from "vue";
|
|
117
|
+
defineOptions({
|
|
118
|
+
name: "TTableColumn",
|
|
119
|
+
});
|
|
120
|
+
defineProps({
|
|
121
|
+
item: {
|
|
122
|
+
type: Object,
|
|
123
|
+
default: () => {
|
|
124
|
+
return {};
|
|
125
|
+
},
|
|
126
|
+
required: true,
|
|
127
|
+
},
|
|
128
|
+
align: {
|
|
129
|
+
type: String,
|
|
130
|
+
default: "center",
|
|
131
|
+
},
|
|
132
|
+
sortable: {
|
|
133
|
+
type: [Boolean, String],
|
|
134
|
+
},
|
|
135
|
+
});
|
|
136
|
+
// 抛出事件
|
|
137
|
+
const emits = defineEmits(["handleEvent"]);
|
|
138
|
+
// 获取所有插槽
|
|
139
|
+
const slots = useSlots();
|
|
140
|
+
</script>
|