Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hls-easy-ui
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
easyUI
hls-easy-ui
Commits
c516f0af
Commit
c516f0af
authored
Sep 19, 2024
by
王纵
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
表格改造、表单增加bind显示
parent
d3559ae3
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
608 additions
and
228 deletions
+608
-228
index.vue
src/Dynamic/ConfigRenderComponent/DForm/index.vue
+6
-12
DTableDetail.vue
src/Dynamic/ConfigRenderComponent/DTable/DTableDetail.vue
+160
-0
DTablePopup.vue
src/Dynamic/ConfigRenderComponent/DTable/DTablePopup.vue
+80
-0
DTableRender.vue
src/Dynamic/ConfigRenderComponent/DTable/DTableRender.vue
+204
-0
DTableTd.jsx
src/Dynamic/ConfigRenderComponent/DTable/DTableTd.jsx
+13
-4
index.vue
src/Dynamic/ConfigRenderComponent/DTable/index.vue
+117
-210
utils.js
src/Dynamic/utils/utils.js
+28
-2
No files found.
src/Dynamic/ConfigRenderComponent/DForm/index.vue
View file @
c516f0af
...
...
@@ -2,7 +2,7 @@
* @Author: zong.wang01@hand-china.com
* @Date: 2024-07-29 10:51:56
* @LastEditors: zong.wang01@hand-china.com
* @LastEditTime: 2024-09-19 1
5:57:20
* @LastEditTime: 2024-09-19 1
6:19:17
* @Version: 1.0.0
* @Description: 表单渲染
* @Copyright: Copyright (c) 2021, Hand-RongJing
...
...
@@ -139,6 +139,7 @@ import DCheckbox from './FormItem/DCheckbox';
import
DUrl
from
'./FormItem/DUrl'
;
import
DTitle
from
'../DTitle'
;
import
{
getFormData
}
from
'../../service'
;
import
{
getBindValue
,
setBindValue
}
from
'../../utils/utils'
;
export
default
{
name
:
'DForm'
,
...
...
@@ -237,18 +238,11 @@ export default {
if
(
item
.
validationTypeDisplay
===
'CentField'
&&
this
.
fieldsObj
[
item
.
columnName
])
{
this
.
fieldsObj
[
item
.
columnName
]
=
this
.
fieldsObj
[
item
.
columnName
]
*
100
;
}
if
(
item
.
bind
&&
this
.
fieldsObj
[
item
.
columnName
])
{
// 主要处理lov绑定字段
const
bindField
=
item
.
bind
.
split
(
'.'
);
if
(
bindField
.
length
>
1
)
{
if
(
this
.
fieldsObj
[
bindField
[
0
]])
{
this
.
fieldsObj
[
bindField
[
0
]][
bindField
[
1
]]
=
this
.
fieldsObj
[
item
.
columnName
];
}
else
{
this
.
fieldsObj
[
bindField
[
0
]]
=
{
[
bindField
[
1
]]:
this
.
fieldsObj
[
item
.
columnName
]
};
}
if
(
item
.
bind
)
{
if
(
this
.
fieldsObj
[
item
.
columnName
])
{
setBindValue
(
item
.
bind
,
this
.
fieldsObj
,
item
.
columnName
);
}
else
{
this
.
fieldsObj
[
bindField
[
0
]]
=
this
.
fieldsObj
[
item
.
columnName
]
;
this
.
fieldsObj
[
item
.
columnName
]
=
getBindValue
(
item
.
bind
,
this
.
fieldsObj
)
;
}
}
})
...
...
src/Dynamic/ConfigRenderComponent/DTable/DTableDetail.vue
0 → 100644
View file @
c516f0af
<!--
* @Author: zong.wang01@hand-china.com
* @Date: 2024-07-29 10:51:56
* @LastEditors: zong.wang01@hand-china.com
* @LastEditTime: 2024-09-19 16:15:12
* @Version: 1.0.0
* @Description: 表格渲染
* @Copyright: Copyright (c) 2021, Hand-RongJing
-->
<
template
>
<van-popup
v-model=
"visible"
position=
"right"
class=
"d-table-form-popup"
get-container=
"body"
safe-area-inset-top
style=
"width: 100%; height: 100%; display: flex; flex-direction: column;"
>
<div
class=
"form-content"
>
<d-form
v-if=
"visible"
:fields=
"columns"
:originFields=
"originColumns"
ref=
"dformRef"
:record=
"record"
formType=
"tableForm"
/>
</div>
<div
class=
"van-safe-area-bottom d-table-form-footer"
>
<div
class=
"d-table-form-footer-content"
>
<van-button
round
type=
""
@
click=
"cancelRecord"
>
{{
showEdit
?
"取消"
:
"关闭"
}}
</van-button>
<van-button
v-if=
"showEdit"
type=
"primary"
round
@
click=
"saveRecord"
>
保存
</van-button>
</div>
</div>
</van-popup>
</
template
>
<
script
>
import
DForm
from
'../DForm'
;
import
{
Popup
,
Button
,
Toast
}
from
'vant'
;
import
{
saveTableRecord
,
updateTableRecord
}
from
'../../service'
;
export
default
{
name
:
'DTableDetail'
,
components
:
{
DForm
,
[
Button
.
name
]:
Button
,
[
Popup
.
name
]:
Popup
,
[
Toast
.
name
]:
Toast
,
},
props
:
{
visible
:
{
type
:
Boolean
,
default
:
false
},
tabInfo
:
{
// 配置信息
type
:
Object
,
default
:
()
=>
({})
},
record
:
{
type
:
Object
,
default
:
()
=>
({})
},
columns
:
{
type
:
Array
,
default
:
()
=>
[],
},
originColumns
:
{
type
:
Array
,
default
:
()
=>
[],
},
showEdit
:
{
type
:
Boolean
,
default
:
false
},
queryParams
:
{
type
:
Object
,
default
:
()
=>
({})
}
},
data
()
{
return
{
}
},
methods
:
{
async
saveRecord
()
{
//表格数据保存
if
(
!
this
.
tabInfo
.
createUrl
)
{
Toast
.
fail
(
'保存接口未配置,请检查配置'
);
return
;
}
const
{
allValues
}
=
await
this
.
$refs
.
dformRef
.
validate
();
let
method
=
saveTableRecord
;
// 默认新增
let
url
=
this
.
tabInfo
.
createUrl
;
const
data
=
[{
...
allValues
,
...
this
.
queryParams
}]
if
(
allValues
.
_status
===
'update'
)
{
// 更新
url
=
this
.
tabInfo
.
updateUrl
method
=
updateTableRecord
;
}
method
(
url
,
data
).
then
(()
=>
{
this
.
cancelRecord
();
Toast
.
success
(
'保存成功!'
);
this
.
$emit
(
'init'
);
})
},
cancelRecord
()
{
this
.
$emit
(
"cancelRecord"
)
},
},
}
</
script
>
<
style
lang=
"less"
>
@import '../../index.less';
.d-table-form-popup {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
box-sizing: border-box;
.form-content {
flex: 1;
overflow: auto;
&::-webkit-scrollbar {
display: none;
}
}
.d-table-form-footer {
background: #fafafa;
box-shadow: 0 -.533vw 2.4vw 0 #e2e2e2;
.d-table-form-footer-content {
display: flex;
justify-content: space-between;
padding: 10px 16px;
.van-button {
// width: 48%;
flex-grow: 1;
font-size: 16px;
font-weight: 600;
& + .van-button {
margin-left: 12px;
}
}
}
}
}
</
style
>
src/Dynamic/ConfigRenderComponent/DTable/DTablePopup.vue
0 → 100644
View file @
c516f0af
<!--
* @Author: zong.wang01@hand-china.com
* @Date: 2024-07-29 10:51:56
* @LastEditors: zong.wang01@hand-china.com
* @LastEditTime: 2024-09-19 16:14:56
* @Version: 1.0.0
* @Description: 表格渲染
* @Copyright: Copyright (c) 2021, Hand-RongJing
-->
<
template
>
<van-popup
v-model=
"visible"
position=
"right"
class=
"d-table-popup"
get-container=
"body"
safe-area-inset-top
>
<slot
name=
"title"
/>
<slot
/>
<div
class=
"van-safe-area-bottom d-table-popup-footer"
>
<div
class=
"d-table-footer-content"
>
<van-button
round
type=
""
@
click=
"close"
>
关闭
</van-button>
</div>
</div>
</van-popup>
</
template
>
<
script
>
import
{
Popup
,
Button
}
from
'vant'
;
export
default
{
name
:
'DTablePopup'
,
components
:
{
[
Popup
.
name
]:
Popup
,
[
Button
.
name
]:
Button
},
props
:
{
visible
:
{
type
:
Boolean
,
default
:
false
},
},
methods
:
{
close
()
{
this
.
$emit
(
'closeMore'
);
}
}
}
</
script
>
<
style
lang=
"less"
>
.d-table-popup {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
box-sizing: border-box;
background-color: #fafafa;
.d-table-popup-footer {
background: #fafafa;
box-shadow: 0 -.533vw 2.4vw 0 #e2e2e2;
.d-table-footer-content {
display: flex;
justify-content: space-between;
padding: 10px 16px;
.van-button {
// width: 48%;
flex-grow: 1;
font-size: 16px;
font-weight: 600;
}
}
}
}
</
style
>
src/Dynamic/ConfigRenderComponent/DTable/DTableRender.vue
0 → 100644
View file @
c516f0af
<!--
* @Author: zong.wang01@hand-china.com
* @Date: 2024-07-29 10:51:56
* @LastEditors: zong.wang01@hand-china.com
* @LastEditTime: 2024-09-13 13:48:06
* @Version: 1.0.0
* @Description: 表格数据展示
* @Copyright: Copyright (c) 2021, Hand-RongJing
-->
<
template
>
<van-checkbox-group
v-model=
"checkResult"
@
change=
"checkChange"
>
<div
v-for=
"(item, pIndex) in tableData"
:key=
"item[tabInfo.primaryKey]"
class=
"d-table"
>
<fragment
v-for=
"(column, index) in showColumns"
:key=
"column.columnName"
>
<div
v-if=
"index === 0"
class=
"d-table-th"
>
<van-checkbox
:name=
"item[tabInfo.primaryKey]"
v-if=
"!readOnly"
>
{{
column
.
description
}}
:
<d-table-td
:column=
"column"
:tdRender=
"column.renderer"
:columnName=
"column.columnName"
:index=
"pIndex"
:record=
"item"
/>
</van-checkbox>
<div
v-else
>
{{
column
.
description
}}
:
<d-table-td
:column=
"column"
:tdRender=
"column.renderer"
:columnName=
"column.columnName"
:index=
"pIndex"
:record=
"item"
/>
</div>
<img
src=
"../../assets/edit.png"
class=
"td-edit"
@
click=
"showRecord(item, pIndex)"
/>
</div>
<div
v-else
class=
"d-table-tr"
>
<span>
{{
column
.
description
}}
</span>
<d-table-td
:column=
"column"
:tdRender=
"column.renderer"
:columnName=
"column.columnName"
:record=
"item"
:index=
"pIndex"
:typeDisplay=
"column.validationTypeDisplay"
>
<template
#
default
v-if=
"dateType[column.dataType] || booleanType.includes(column.validationTypeDisplay)"
>
<fragment
v-if=
"booleanType.includes(column.validationTypeDisplay)"
>
{{
booleanDisplay
[
getTdValue
(
column
,
item
)]
||
'--'
}}
</fragment>
<fragment
v-if=
"dateType[column.dataType]"
>
{{
dateDescription
(
dateType
[
column
.
dataType
],
getTdValue
(
column
,
item
))
||
'--'
}}
</fragment>
</
template
>
<!-- {{(column.validationTypeDisplay === 'Switch' ? (item[column.columnName] ? '是' : '否' ) : item[column.columnName]) || '--'}} -->
</d-table-td>
</div>
</fragment>
</div>
</van-checkbox-group>
</template>
<
script
>
import
DTableTd
from
'./DTableTd.jsx'
;
import
{
Checkbox
,
CheckboxGroup
,
Toast
}
from
'vant'
;
import
{
dateFormat
,
getBindValue
}
from
'../../utils/utils'
;
export
default
{
name
:
'DTableRender'
,
components
:
{
DTableTd
,
[
Checkbox
.
name
]:
Checkbox
,
[
CheckboxGroup
.
name
]:
CheckboxGroup
,
[
Toast
.
name
]:
Toast
,
},
props
:
{
tabInfo
:
{
// 配置信息
type
:
Object
,
default
:
()
=>
{}
},
tableData
:
{
type
:
Array
,
default
:
()
=>
[]
},
columns
:
{
type
:
Array
,
default
:
()
=>
[],
},
showEdit
:
{
type
:
Boolean
,
default
:
false
},
readOnly
:
{
type
:
Boolean
,
default
:
true
},
checkResult
:
{
type
:
Array
,
default
:
()
=>
[],
}
},
data
()
{
return
{
dateType
:
{
dateTime
:
'datetime'
,
time
:
'datetime'
,
month
:
'year-month'
,
year
:
'year-month'
,
week
:
'date'
,
date
:
'date'
,
},
booleanType
:
[
'Switch'
,
'Radio'
,
'CheckBox'
],
booleanDisplay
:
{
1
:
'是'
,
0
:
'否'
},
showColumns
:
[],
}
},
mounted
()
{
this
.
init
();
},
activated
()
{
this
.
init
();
},
methods
:
{
init
()
{
this
.
$nextTick
(()
=>
{
this
.
showColumns
=
this
.
columns
.
length
>
6
?
this
.
columns
.
slice
(
0
,
6
)
:
this
.
columns
;
})
},
getTdValue
(
column
,
item
)
{
if
(
column
.
bind
)
{
return
getBindValue
(
column
.
bind
,
item
);
}
else
{
return
item
[
column
.
columnName
];
}
},
showRecord
(
res
,
index
)
{
this
.
$emit
(
'showRecord'
,
res
,
index
);
},
dateDescription
(
type
,
val
)
{
if
(
val
)
{
const
res
=
dateFormat
(
type
,
new
Date
(
val
));
return
res
.
description
;
}
return
val
;
},
checkChange
(
val
)
{
this
.
$emit
(
'checkChange'
,
val
)
}
},
}
</
script
>
<
style
lang=
"less"
>
@import '../../index.less';
.d-table {
margin: 0 15px 10px 15px;
padding: 4px 8px 12px 8px;
background-color: #fff;
border-radius: 8px;
.d-table-tr {
display: flex;
justify-content: space-between;
padding: 10px 16px 0 16px;
font-family: PingFangSC-Regular;
font-size: 14px;
color: #a3a3a3;
span:nth-child(1){
min-width: 60px;
& + span {
padding-left: 15px;
color: #383F45;
}
}
}
.d-table-th {
display: flex;
justify-content: space-between;
align-items: center;
padding: 8px 0 12px 8px;
border-bottom: 1px solid #F3F3F7;;
font-family: PingFangSC-Semibold;
font-size: 14px;
color: #4B4A4B;
font-weight: 600;
.van-checkbox__icon {
font-size: 16px;
// margin-top: 2px;
}
// :deep(.van-checkbox__icon) {
// font-size: 16px;
// // margin-top: 2px;
// }
.td-edit {
width: 14px;
}
}
}
</
style
>
src/Dynamic/ConfigRenderComponent/DTable/DTableTd.jsx
View file @
c516f0af
...
...
@@ -2,17 +2,22 @@
* @Author: zong.wang01@hand-china.com
* @Date: 2024-07-30 09:41:54
* @LastEditors: zong.wang01@hand-china.com
* @LastEditTime: 2024-0
8-19 11:46:32
* @LastEditTime: 2024-0
9-19 16:16:19
* @Version: 1.0.0
* @Description: 表格列渲染
* @Copyright: Copyright (c) 2021, Hand-RongJing
*/
import
Vue
from
'vue'
;
import
{
getBindValue
}
from
'../../utils/utils'
const
DTableTd
=
{
components
:
{
},
props
:
{
column
:
{
type
:
Object
,
default
:
()
=>
({})
},
record
:
{
// 数据
type
:
Object
,
default
:
()
=>
({})
...
...
@@ -40,10 +45,14 @@ const DTableTd = {
},
methods
:
{
columnValue
()
{
if
(
[
'Lov'
,
'Select'
].
includes
(
this
.
typeDisplay
)
)
{
return
this
.
record
[
`
${
this
.
columnName
}
Name`
]
||
this
.
record
[
`
${
this
.
columnName
}
N`
]
||
this
.
record
[
this
.
columnName
];
if
(
this
.
column
.
bind
)
{
return
getBindValue
(
this
.
column
.
bind
,
this
.
record
)
}
else
{
return
this
.
record
[
this
.
columnName
];
if
([
'Lov'
,
'Select'
].
includes
(
this
.
typeDisplay
))
{
return
this
.
record
[
`
${
this
.
columnName
}
Name`
]
||
this
.
record
[
`
${
this
.
columnName
}
N`
]
||
this
.
record
[
this
.
columnName
];
}
else
{
return
this
.
record
[
this
.
columnName
];
}
}
}
},
...
...
src/Dynamic/ConfigRenderComponent/DTable/index.vue
View file @
c516f0af
...
...
@@ -2,7 +2,7 @@
* @Author: zong.wang01@hand-china.com
* @Date: 2024-07-29 10:51:56
* @LastEditors: zong.wang01@hand-china.com
* @LastEditTime: 2024-09-1
9 15:30:46
* @LastEditTime: 2024-09-1
3 15:25:03
* @Version: 1.0.0
* @Description: 表格渲染
* @Copyright: Copyright (c) 2021, Hand-RongJing
...
...
@@ -16,109 +16,88 @@
:showBtns=
"!readOnly"
/>
<d-scroll
ref=
"scroll"
:pullUp=
"true"
:pull-down=
"true"
@
pullingUp=
"getList"
@
pullingDown=
"getList"
>
<van-checkbox-group
v-model=
"checkResult"
>
<div
v-for=
"(item, pIndex) in tableData"
:key=
"item[tabInfo.primaryKey]"
class=
"d-table"
>
<fragment
v-for=
"(column, index) in showColumns"
:key=
"column.columnName"
>
<div
v-if=
"index === 0"
class=
"d-table-th"
>
<van-checkbox
:name=
"item[tabInfo.primaryKey]"
v-if=
"showEdit"
>
{{
column
.
description
}}
:
<d-table-td
:tdRender=
"column.renderer"
:columnName=
"column.columnName"
:index=
"pIndex"
:record=
"item"
/>
</van-checkbox>
<div
v-else
>
{{
column
.
description
}}
:
<d-table-td
:tdRender=
"column.renderer"
:columnName=
"column.columnName"
:index=
"pIndex"
:record=
"item"
/>
</div>
<img
src=
"../../assets/edit.png"
class=
"td-edit"
@
click=
"showRecord(item, pIndex)"
/>
</div>
<div
v-else
class=
"d-table-tr"
>
<span>
{{
column
.
description
}}
</span>
<d-table-td
:tdRender=
"column.renderer"
:columnName=
"column.columnName"
:record=
"item"
:index=
"pIndex"
:typeDisplay=
"column.validationTypeDisplay"
>
<template
#
default
v-if=
"dateType[column.dataType] || booleanType.includes(column.validationTypeDisplay)"
>
<fragment
v-if=
"booleanType.includes(column.validationTypeDisplay)"
>
{{
booleanDisplay
[
item
[
column
.
columnName
]]
||
'--'
}}
</fragment>
<fragment
v-if=
"dateType[column.dataType]"
>
{{
dateDescription
(
dateType
[
column
.
dataType
],
item
[
column
.
columnName
])
||
'--'
}}
</fragment>
</
template
>
<!-- {{(column.validationTypeDisplay === 'Switch' ? (item[column.columnName] ? '是' : '否' ) : item[column.columnName]) || '--'}} -->
</d-table-td>
</div>
</fragment>
</div>
</van-checkbox-group>
<div>
<d-table-render
:tableData=
"tableSizeData"
:tabInfo=
"tabInfo"
:columns=
"columns"
:showEdit=
"showEdit"
:readOnly=
"readOnly"
:checkResult=
"checkResult"
@
showRecord=
"showRecord"
@
checkChange=
"checkChange"
/>
<div
v-if=
"totalElement > tableSizeData.length"
@
click=
"showMore"
class=
"d-table-more"
>
更多数据
<img
src=
"../../assets/more.png"
/>
</div>
<div
v-if=
"!loading && totalElement === tableSizeData.length"
class=
"d-table-no-more"
>
没有更多了
</div>
</div>
<van-popup
v-model=
"visible"
position=
"top"
class=
"d-table-form-popup van-safe-area-bottom"
get-container=
"body"
>
<div
class=
"form-content"
>
<d-form
v-if=
"visible"
:fields=
"columns"
:originFields=
"originColumns"
ref=
"dformRef"
:record=
"record"
formType=
"tableForm"
/>
</div>
<div
class=
"d-table-form-footer"
>
<van-button
round
@
click
.
native=
"cancelRecord"
>
{{showEdit ? "取消" : "关闭"}}
</van-button>
<van-button
type=
"info"
v-if=
"showEdit"
round
@
click
.
native=
"saveRecord"
>
保存
</van-button>
<d-table-popup
:visible=
"tableMore"
@
closeMore=
"closeMore"
>
<template
#
title
>
<DTitle
:title=
"tabInfo.description"
:tabButtons=
"tabInfo.tabButtons || []"
:buttonsFun=
"buttonsClick"
:showBtns=
"!readOnly"
/>
</
template
>
<van-list
v-model=
"loading"
:finished=
"finished"
:immediateCheck=
"false"
finished-text=
"没有更多了"
@
load=
"getList"
style=
"overflow: auto;"
>
<d-table-render
:tableData=
"tableData"
:tabInfo=
"tabInfo"
:columns=
"columns"
:showEdit=
"showEdit"
:readOnly=
"readOnly"
:checkResult=
"checkResult"
@
showRecord=
"showRecord"
@
checkChange=
"checkChange"
/>
</van-list>
</d-table-popup>
</div>
</van-popup>
</d-scroll>
<d-table-detail
:tabInfo=
"tabInfo"
:visible=
"visible"
:columns=
"columns"
:originColumns=
"originColumns"
:record=
"record"
:showEdit=
"showEdit"
:queryParams=
"dynamicConfigInfo.queryParams"
@
cancelRecord=
"cancelRecord"
@
init=
"init"
ref=
"tableDetailRef"
/>
</fragment>
</template>
<
script
>
import
{
DScroll
}
from
'../../LayoutComponents'
;
import
DTitle
from
'../DTitle'
;
import
DForm
from
'../DForm'
;
import
DTableTd
from
'./DTableTd.jsx'
;
import
{
Checkbox
,
CheckboxGroup
,
Popup
,
Button
,
Icon
,
Toast
}
from
'vant'
;
import
{
getTableData
,
saveTableRecord
,
deleteTableRecords
,
updateTableRecord
}
from
'../../service'
;
import
{
getDataSetName
,
dateFormat
}
from
'../../utils/utils'
;
import
DTableRender
from
'./DTableRender'
;
import
DTableDetail
from
'./DTableDetail'
;
import
DTablePopup
from
'./DTablePopup'
;
import
{
Toast
,
List
}
from
'vant'
;
import
{
getTableData
,
deleteTableRecords
}
from
'../../service'
;
import
{
getDataSetName
}
from
'../../utils/utils'
;
import
EventBus
from
'../../utils/eventBus'
;
export
default
{
name
:
'DTable'
,
components
:
{
DTitle
,
DForm
,
DTableTd
,
DScroll
,
[
Button
.
name
]:
Button
,
[
Checkbox
.
name
]:
Checkbox
,
[
CheckboxGroup
.
name
]:
CheckboxGroup
,
[
Popup
.
name
]:
Popup
,
[
Icon
.
name
]:
Icon
,
DTableRender
,
DTablePopup
,
DTableDetail
,
[
Toast
.
name
]:
Toast
,
[
List
.
name
]:
List
},
props
:
{
tabInfo
:
{
// 配置信息
...
...
@@ -141,32 +120,23 @@ export default {
inject
:
[
'dynamicInfo'
,
'dataLoadHandle'
,
'addRef'
],
data
()
{
return
{
dateType
:
{
dateTime
:
'datetime'
,
time
:
'datetime'
,
month
:
'year-month'
,
year
:
'year-month'
,
week
:
'date'
,
date
:
'date'
,
},
booleanType
:
[
'Switch'
,
'Radio'
,
'CheckBox'
],
booleanDisplay
:
{
1
:
'是'
,
0
:
'否'
},
page
:
0
,
size
:
10
,
showColumns
:
[]
,
totalElement
:
0
,
queryParams
:
{},
tableSizeData
:
[],
// 表格前10条数据
tableData
:
[],
// 表格数据
checkResult
:
[],
visible
:
false
,
tableMore
:
false
,
showEdit
:
false
,
readOnly
:
true
,
record
:
{},
// 操作记录
recordIndex
:
-
1
,
buttonsFun
:
{},
dynamicConfigInfo
:
{},
loading
:
false
,
finished
:
false
,
}
},
mounted
()
{
...
...
@@ -190,7 +160,6 @@ export default {
EventBus
.
$on
(
'tableQuery'
,
this
.
listenHandle
);
}
this
.
refresh
();
this
.
showColumns
=
this
.
columns
.
length
>
6
?
this
.
columns
.
slice
(
0
,
6
)
:
this
.
columns
;
this
.
readOnly
=
this
.
dynamicConfigInfo
.
queryParams
.
readOnly
;
// 设置是否可以编辑
if
(
this
.
dynamicConfigInfo
.
queryParams
.
readOnly
)
{
...
...
@@ -218,17 +187,21 @@ export default {
...
this
.
queryParams
,
...
this
.
dynamicConfigInfo
.
queryParams
,
}
this
.
loading
=
true
getTableData
(
this
.
tabInfo
.
readUrl
,
params
).
then
(
res
=>
{
this
.
tableData
=
this
.
tableData
.
concat
(
res
.
content
||
[]);
this
.
dataLoadHandle
(
this
.
tableData
,
this
.
tabInfo
.
tabCode
)
this
.
dataLoadHandle
(
this
.
tableData
,
this
.
tabInfo
.
tabCode
);
this
.
tableSizeData
=
this
.
tableData
.
length
>
this
.
size
?
this
.
tableData
.
slice
(
0
,
this
.
size
)
:
this
.
tableData
;
// EventBus.$on('dataLoad', this.tableData, this.tabInfo.tabCode); // 将查询的数据
this
.
totalElement
=
res
.
totalElements
;
if
(
res
.
totalElements
>
this
.
tableData
.
length
)
{
this
.
page
=
this
.
page
+
1
;
this
.
$refs
.
scroll
.
update
(
false
)
this
.
finished
=
false
}
else
{
this
.
$refs
.
scroll
.
update
(
true
)
this
.
finished
=
true
}
}).
finally
(()
=>
{
this
.
loading
=
false
})
},
showRecord
(
res
,
index
)
{
...
...
@@ -236,38 +209,12 @@ export default {
this
.
recordIndex
=
index
;
this
.
visible
=
true
;
},
dateDescription
(
type
,
val
)
{
if
(
val
)
{
const
res
=
dateFormat
(
type
,
new
Date
(
val
));
return
res
.
description
;
}
return
val
;
},
async
saveRecord
()
{
//表格数据保存
if
(
!
this
.
tabInfo
.
createUrl
)
{
Toast
.
fail
(
'保存接口未配置,请检查配置'
);
return
;
}
const
{
allValues
}
=
await
this
.
$refs
.
dformRef
.
validate
();
let
method
=
saveTableRecord
;
// 默认新增
let
url
=
this
.
tabInfo
.
createUrl
;
const
data
=
[{
...
allValues
,
...
this
.
dynamicConfigInfo
.
queryParams
}]
if
(
allValues
.
_status
===
'update'
)
{
// 更新
url
=
this
.
tabInfo
.
updateUrl
method
=
updateTableRecord
;
}
method
(
url
,
data
).
then
(()
=>
{
this
.
visible
=
false
;
Toast
.
success
(
'保存成功!'
);
this
.
init
();
})
},
cancelRecord
()
{
this
.
visible
=
false
;
},
checkChange
(
val
)
{
this
.
checkResult
=
val
;
},
// 删除
deleteRecords
()
{
let
result
=
this
.
tableData
.
filter
(
o
=>
this
.
checkResult
.
includes
(
o
[
this
.
tabInfo
.
primaryKey
]));
...
...
@@ -293,92 +240,52 @@ export default {
case
'query'
:
this
.
refresh
();
break
;
//
case 'export':
//
console.log('导出')
//
break;
case
'export'
:
console
.
log
(
'导出'
)
break
;
case
'remove'
:
this
.
deleteRecords
();
break
;
// case 'save':
//
console.log('保存')
//
this.save();
// break;
default
:
}
}
},
showMore
()
{
this
.
tableMore
=
true
;
},
closeMore
()
{
this
.
tableMore
=
false
;
this
.
checkResult
=
[];
},
getFormRef
()
{
return
this
.
$refs
.
tableDetailRef
.
$refs
.
dformRef
;
}
},
}
</
script
>
<
style
lang=
"less"
>
@import '../../index.less';
.d-table {
margin: 0 15px 10px 15px;
padding: 4px 8px 12px 8px;
background-color: #fff;
border-radius: 4px;
.d-table-tr {
display: flex;
justify-content: space-between;
padding: 10px 16px 0 16px;
font-family: PingFangSC-Regular;
font-size: 14px;
color: #a3a3a3;
span:nth-child(1){
min-width: 60px;
& + span {
padding-left: 15px;
color: #383F45;
}
}
}
.d-table-th {
display: flex;
justify-content: space-between;
align-items: center;
padding: 8px 0 12px 8px;
border-bottom: 1px solid #F3F3F7;;
font-family: PingFangSC-Semibold;
font-size: 14px;
color: #4B4A4B;
font-weight: 600;
:deep(.van-checkbox__icon) {
font-size: 16px;
}
.td-edit {
width: 14px;
}
<
style
lang=
"less"
scoped
>
.d-table-more {
margin: 8px 15px 8px 15px;
background: #FFFFFF;
border-radius: 8px;
font-family: PingFangSC-Regular;
font-size: 14px;
color: rgba(75,74,75,0.60);
line-height: 30px;
text-align: center;
img {
width: 10px;
margin-left: 10px;
}
}
.d-table-form-popup {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
.form-content {
flex: 1;
overflow: auto;
&::-webkit-scrollbar {
display: none;
}
}
.d-table-form-footer {
display: flex;
justify-content: space-between;
padding: 10px 16px;
background: #fafafa;
box-shadow: 0 -.533vw 2.4vw 0 #e2e2e2;
.van-button {
// width: 48%;
flex-grow: 1;
font-size: 16px;
font-weight: 600;
& + .van-button {
margin-left: 12px;
}
}
}
.d-table-no-more {
color: #969799;;
font-size: 14px;
line-height: 50px;
text-align: center;
}
</
style
>
src/Dynamic/utils/utils.js
View file @
c516f0af
...
...
@@ -2,7 +2,7 @@
* @Author: zong.wang01@hand-china.com
* @Date: 2024-07-30 14:39:47
* @LastEditors: zong.wang01@hand-china.com
* @LastEditTime: 2024-09-19 1
5:45:12
* @LastEditTime: 2024-09-19 1
6:16:57
* @Version: 1.0.0
* @Description: 工具类
* @Copyright: Copyright (c) 2021, Hand-RongJing
...
...
@@ -284,6 +284,30 @@ const reloadData = (dataSets, type = 'all') => {
}
const
getBindValue
=
(
bindStr
,
record
)
=>
{
const
bindArr
=
bindStr
.
split
(
'.'
);
if
(
bindArr
.
length
>
1
)
{
return
record
[
bindArr
[
0
]][
bindArr
[
1
]];
}
else
{
return
record
[
bindArr
[
0
]];
}
}
const
setBindValue
=
(
bindStr
,
record
,
columnName
)
=>
{
const
bindField
=
bindStr
.
split
(
'.'
);
if
(
bindField
.
length
>
1
)
{
if
(
record
[
bindField
[
0
]])
{
record
[
bindField
[
0
]][
bindField
[
1
]]
=
record
[
columnName
];
}
else
{
record
[
bindField
[
0
]]
=
{
[
bindField
[
1
]]:
record
[
columnName
]
};
}
}
else
{
record
[
bindField
[
0
]]
=
record
[
columnName
];
}
}
export
{
getCustomizedProp
,
...
...
@@ -298,5 +322,7 @@ export {
getCurrentUser
,
isTenantRoleLevel
,
getLayoutSaveData
,
reloadData
reloadData
,
getBindValue
,
setBindValue
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment