Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
basic-vue-admin
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Basic
basic-vue-admin
Commits
8c5e6c66
提交
8c5e6c66
authored
3月 30, 2023
作者:
方治民
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: 添加表字段行操作,包括复制、删除、上/下移
上级
e5c00823
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
93 行增加
和
14 行删除
+93
-14
TableAction.vue
src/components/Table/src/components/TableAction.vue
+3
-3
data.tsx
src/views/demo/tools/online/form/data.tsx
+11
-3
edit.vue
src/views/demo/tools/online/form/edit.vue
+79
-8
没有找到文件。
src/components/Table/src/components/TableAction.vue
浏览文件 @
8c5e6c66
...
@@ -61,7 +61,7 @@
...
@@ -61,7 +61,7 @@
.
map
((
action
)
=>
{
.
map
((
action
)
=>
{
const
{
popConfirm
}
=
action
const
{
popConfirm
}
=
action
return
{
return
{
getPopupContainer
:
()
=>
unref
((
table
as
any
)?.
wrapRef
.
value
)
??
document
.
body
,
getPopupContainer
:
()
=>
unref
((
table
as
any
)?.
wrapRef
)
??
document
.
body
,
type
:
'link'
,
type
:
'link'
,
size
:
'small'
,
size
:
'small'
,
...
action
,
...
action
,
...
@@ -93,12 +93,12 @@
...
@@ -93,12 +93,12 @@
const
getAlign
=
computed
(()
=>
{
const
getAlign
=
computed
(()
=>
{
const
columns
=
(
table
as
TableActionType
)?.
getColumns
?.()
||
[]
const
columns
=
(
table
as
TableActionType
)?.
getColumns
?.()
||
[]
const
actionColumn
=
columns
.
find
((
item
)
=>
item
.
flag
===
ACTION_COLUMN_FLAG
)
const
actionColumn
=
columns
.
find
((
item
)
=>
item
.
flag
===
ACTION_COLUMN_FLAG
)
return
actionColumn
?.
align
??
'
left
'
return
actionColumn
?.
align
??
'
center
'
})
})
function
getTooltip
(
data
:
string
|
TooltipProps
):
TooltipProps
{
function
getTooltip
(
data
:
string
|
TooltipProps
):
TooltipProps
{
return
{
return
{
getPopupContainer
:
()
=>
unref
((
table
as
any
)?.
wrapRef
.
value
)
??
document
.
body
,
getPopupContainer
:
()
=>
unref
((
table
as
any
)?.
wrapRef
)
??
document
.
body
,
placement
:
'bottom'
,
placement
:
'bottom'
,
...(
isString
(
data
)
?
{
title
:
data
}
:
data
),
...(
isString
(
data
)
?
{
title
:
data
}
:
data
),
}
}
...
...
src/views/demo/tools/online/form/data.tsx
浏览文件 @
8c5e6c66
...
@@ -268,7 +268,8 @@ export const fieldTypeOptions: SelectProps['options'] = [
...
@@ -268,7 +268,8 @@ export const fieldTypeOptions: SelectProps['options'] = [
},
},
]
]
export
interface
DataSourceSchema
{
export
interface
DatabaseSchema
{
id
?:
string
field
?:
string
field
?:
string
comment
?:
string
comment
?:
string
type
?:
FieldType
type
?:
FieldType
...
@@ -286,7 +287,7 @@ export interface DataSourceSchema {
...
@@ -286,7 +287,7 @@ export interface DataSourceSchema {
* 获取数据源字段列表
* 获取数据源字段列表
* @returns Column[]
* @returns Column[]
*/
*/
export
function
getData
Sourc
eSchemaColumns
():
VxeGridPropTypes
.
Columns
{
export
function
getData
bas
eSchemaColumns
():
VxeGridPropTypes
.
Columns
{
return
[
return
[
{
{
type
:
'html'
,
type
:
'html'
,
...
@@ -380,10 +381,17 @@ export function getDataSourceSchemaColumns(): VxeGridPropTypes.Columns {
...
@@ -380,10 +381,17 @@ export function getDataSourceSchemaColumns(): VxeGridPropTypes.Columns {
},
},
},
},
},
},
{
title
:
'操作'
,
align
:
'center'
,
fixed
:
'right'
,
width
:
150
,
slots
:
{
default
:
'action'
},
},
]
]
}
}
export
function
getDefaultSchemaFieldDataSourcesByType
(
type
:
string
):
Data
Sourc
eSchema
[]
{
export
function
getDefaultSchemaFieldDataSourcesByType
(
type
:
string
):
Data
bas
eSchema
[]
{
if
(
type
===
'SingleGeneral'
)
{
if
(
type
===
'SingleGeneral'
)
{
return
[
return
[
{
{
...
...
src/views/demo/tools/online/form/edit.vue
浏览文件 @
8c5e6c66
<
script
lang=
"ts"
setup
>
<
script
lang=
"ts"
setup
>
import
type
{
ActionItem
}
from
'/@/components/Table'
import
type
{
BasicTableProps
,
VxeGridInstance
}
from
'/@/components/VxeTable'
import
{
nanoid
}
from
'nanoid'
import
{
nanoid
}
from
'nanoid'
import
{
TabPane
,
Tabs
}
from
'ant-design-vue'
import
{
TabPane
,
Tabs
}
from
'ant-design-vue'
import
{
databaseTypeOptions
,
getDataSourceSchemaColumns
,
getDefaultSchemaFieldDataSourcesByType
}
from
'./data'
import
type
{
DatabaseSchema
}
from
'./data'
import
{
databaseTypeOptions
,
getDatabaseSchemaColumns
,
getDefaultSchemaFieldDataSourcesByType
}
from
'./data'
import
{
Icon
}
from
'@/components/Icon'
import
{
Icon
}
from
'@/components/Icon'
import
{
BasicForm
,
useForm
}
from
'/@/components/Form'
import
{
BasicForm
,
useForm
}
from
'/@/components/Form'
import
type
{
BasicTableProps
,
VxeGridInstance
}
from
'/@/components/Vxe
Table'
import
{
TableAction
}
from
'/@/components/
Table'
import
{
VxeBasicTable
}
from
'/@/components/VxeTable'
import
{
VxeBasicTable
}
from
'/@/components/VxeTable'
import
{
BasicModal
,
useModalInner
}
from
'/@/components/Modal'
import
{
BasicModal
,
useModalInner
}
from
'/@/components/Modal'
import
{
useSortable
}
from
'/@/hooks/web/useSortable'
import
{
useSortable
}
from
'/@/hooks/web/useSortable'
...
@@ -75,13 +78,15 @@
...
@@ -75,13 +78,15 @@
const
databaseSchemaTable
=
ref
<
VxeGridInstance
>
()
const
databaseSchemaTable
=
ref
<
VxeGridInstance
>
()
const
databaseSchemaTableOptions
=
reactive
<
BasicTableProps
>
({
const
databaseSchemaTableOptions
=
reactive
<
BasicTableProps
>
({
id
:
nanoid
(),
id
:
nanoid
(),
// FIXME: 修复表格高度自适应问题
// height: 'auto',
autoResize
:
true
,
autoResize
:
true
,
stripe
:
false
,
stripe
:
false
,
keepSource
:
true
,
keepSource
:
true
,
showOverflow
:
true
,
showOverflow
:
true
,
rowConfig
:
{
useKey
:
true
,
keyField
:
'id'
},
rowConfig
:
{
useKey
:
true
,
keyField
:
'id'
},
checkboxConfig
:
{
checkMethod
:
({
row
})
=>
!
row
.
disabled
},
checkboxConfig
:
{
checkMethod
:
({
row
})
=>
!
row
.
disabled
},
columns
:
getData
Sourc
eSchemaColumns
(),
columns
:
getData
bas
eSchemaColumns
(),
data
:
getDefaultSchemaFieldDataSourcesByType
(
defaultTableType
),
data
:
getDefaultSchemaFieldDataSourcesByType
(
defaultTableType
),
editConfig
:
{
trigger
:
'click'
,
mode
:
'cell'
,
showStatus
:
false
,
beforeEditMethod
:
({
row
})
=>
!
row
.
disabled
},
editConfig
:
{
trigger
:
'click'
,
mode
:
'cell'
,
showStatus
:
false
,
beforeEditMethod
:
({
row
})
=>
!
row
.
disabled
},
editRules
:
{
editRules
:
{
...
@@ -147,7 +152,7 @@
...
@@ -147,7 +152,7 @@
await
table
?.
removeCheckboxRow
()
await
table
?.
removeCheckboxRow
()
await
table
?.
updateData
()
await
table
?.
updateData
()
onCheckboxChange
()
on
DatabaseSchema
CheckboxChange
()
},
},
},
},
},
},
...
@@ -156,10 +161,72 @@
...
@@ -156,10 +161,72 @@
},
},
})
})
const
onCheckboxChange
=
()
=>
{
const
on
DatabaseSchema
CheckboxChange
=
()
=>
{
const
checkedRecords
=
databaseSchemaTable
.
value
?.
getCheckboxRecords
()
const
checkedRecords
=
databaseSchemaTable
.
value
?.
getCheckboxRecords
()
databaseSchemaTableOptions
.
toolbarConfig
.
buttons
[
1
].
buttonRender
.
props
.
disabled
=
!
checkedRecords
?.
length
databaseSchemaTableOptions
.
toolbarConfig
.
buttons
[
1
].
buttonRender
.
props
.
disabled
=
!
checkedRecords
?.
length
}
}
const
createDatabaseSchemaTableActions
=
(
record
:
DatabaseSchema
)
=>
{
const
actions
:
ActionItem
[]
=
[
{
icon
:
'carbon:arrow-up'
,
onClick
:
async
()
=>
{
const
table
=
databaseSchemaTable
.
value
const
source
=
table
?.
getRowById
(
record
.
id
)
const
oldIndex
=
table
?.
getRowIndex
(
source
)
const
newIndex
=
oldIndex
-
1
<
0
?
0
:
oldIndex
-
1
const
currRow
=
table
.
data
.
splice
(
oldIndex
,
1
)[
0
]
table
.
data
.
splice
(
newIndex
,
0
,
currRow
)
databaseSchemaTableOptions
.
data
=
[...
table
.
data
]
await
table
?.
updateData
()
},
},
{
icon
:
'carbon:arrow-down'
,
onClick
:
async
()
=>
{
const
table
=
databaseSchemaTable
.
value
const
source
=
table
?.
getRowById
(
record
.
id
)
const
oldIndex
=
table
?.
getRowIndex
(
source
)
const
newIndex
=
oldIndex
+
1
>
table
.
data
.
length
-
1
?
table
.
data
.
length
-
1
:
oldIndex
+
1
const
currRow
=
table
.
data
.
splice
(
oldIndex
,
1
)[
0
]
table
.
data
.
splice
(
newIndex
,
0
,
currRow
)
databaseSchemaTableOptions
.
data
=
[...
table
.
data
]
await
table
?.
updateData
()
},
},
{
icon
:
'carbon:copy'
,
tooltip
:
'复制'
,
onClick
:
async
()
=>
{
const
table
=
databaseSchemaTable
.
value
const
source
=
table
?.
getRowById
(
record
.
id
)
const
index
=
table
?.
getRowIndex
(
source
)
const
{
row
}
=
await
table
?.
insertAt
({
...
record
,
id
:
nanoid
()
},
source
)
databaseSchemaTableOptions
.
data
.
splice
(
index
+
1
,
0
,
row
)
await
table
?.
updateData
()
await
table
?.
setEditCell
(
row
,
'field'
)
},
},
{
icon
:
'carbon:trash-can'
,
tooltip
:
'删除'
,
color
:
'error'
,
popConfirm
:
{
title
:
'是否确认删除'
,
confirm
:
async
()
=>
{
const
table
=
databaseSchemaTable
.
value
// 更新数据
databaseSchemaTableOptions
.
data
=
databaseSchemaTableOptions
.
data
.
filter
(
(
item
)
=>
record
.
id
!==
item
.
id
,
)
await
table
?.
updateData
()
},
},
},
]
return
record
.
field
===
'id'
?
[]
:
actions
}
</
script
>
</
script
>
<
template
>
<
template
>
...
@@ -179,9 +246,13 @@
...
@@ -179,9 +246,13 @@
<VxeBasicTable
<VxeBasicTable
ref=
"databaseSchemaTable"
ref=
"databaseSchemaTable"
v-bind=
"databaseSchemaTableOptions"
v-bind=
"databaseSchemaTableOptions"
@
checkbox-change=
"onCheckboxChange"
@
checkbox-change=
"onDatabaseSchemaCheckboxChange"
@
checkbox-all=
"onCheckboxChange"
@
checkbox-all=
"onDatabaseSchemaCheckboxChange"
/>
>
<
template
#
action=
"{ row }"
>
<TableAction
outside
:actions=
"createDatabaseSchemaTableActions(row)"
/>
</
template
>
</VxeBasicTable>
</TabPane>
</TabPane>
<TabPane
key=
"db-foreign-key"
>
<TabPane
key=
"db-foreign-key"
>
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论