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
7f2823df
Commit
7f2823df
authored
Sep 06, 2024
by
王纵
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
页面按钮默认方法提取到Dynamic组件
parent
47298b37
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
188 additions
and
85 deletions
+188
-85
index.vue
src/Dynamic/ConfigRenderComponent/DForm/index.vue
+2
-2
index.vue
src/Dynamic/LayoutButtons/index.vue
+80
-76
index.vue
src/Dynamic/index.vue
+25
-5
utils.js
src/Dynamic/utils/utils.js
+81
-2
No files found.
src/Dynamic/ConfigRenderComponent/DForm/index.vue
View file @
7f2823df
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
* @Author: zong.wang01@hand-china.com
* @Author: zong.wang01@hand-china.com
* @Date: 2024-07-29 10:51:56
* @Date: 2024-07-29 10:51:56
* @LastEditors: zong.wang01@hand-china.com
* @LastEditors: zong.wang01@hand-china.com
* @LastEditTime: 2024-0
8-21 15:43:2
5
* @LastEditTime: 2024-0
9-06 15:14:4
5
* @Version: 1.0.0
* @Version: 1.0.0
* @Description: 表单渲染
* @Description: 表单渲染
* @Copyright: Copyright (c) 2021, Hand-RongJing
* @Copyright: Copyright (c) 2021, Hand-RongJing
...
@@ -235,7 +235,7 @@ export default {
...
@@ -235,7 +235,7 @@ export default {
this
.
fieldsObj
=
res
.
content
.
length
?
res
.
content
[
0
]
:
{};
this
.
fieldsObj
=
res
.
content
.
length
?
res
.
content
[
0
]
:
{};
this
.
dataLoadHandle
(
this
.
fieldsObj
,
this
.
tabInfo
.
tabCode
);
// 数据查询后的回调
this
.
dataLoadHandle
(
this
.
fieldsObj
,
this
.
tabInfo
.
tabCode
);
// 数据查询后的回调
this
.
setDataSetData
(
this
.
tabInfo
.
tabCode
,
{...
this
.
fieldsObj
});
// 保存一份原始数据
this
.
setDataSetData
(
this
.
tabInfo
.
tabCode
,
{...
this
.
fieldsObj
});
// 保存一份原始数据
this
.
status
=
'upd
ate'
;
this
.
status
=
res
.
content
.
length
?
'update'
:
'cre
ate'
;
}
else
{
}
else
{
this
.
status
=
'create'
;
this
.
status
=
'create'
;
}
}
...
...
src/Dynamic/LayoutButtons/index.vue
View file @
7f2823df
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
* @Author: zong.wang01@hand-china.com
* @Author: zong.wang01@hand-china.com
* @Date: 2024-07-31 15:09:30
* @Date: 2024-07-31 15:09:30
* @LastEditors: zong.wang01@hand-china.com
* @LastEditors: zong.wang01@hand-china.com
* @LastEditTime: 2024-0
8-22 11:24:20
* @LastEditTime: 2024-0
9-06 15:15:19
* @Version: 1.0.0
* @Version: 1.0.0
* @Description: 页面按钮渲染
* @Description: 页面按钮渲染
* @Copyright: Copyright (c) 2021, Hand-RongJing
* @Copyright: Copyright (c) 2021, Hand-RongJing
...
@@ -73,6 +73,10 @@ export default {
...
@@ -73,6 +73,10 @@ export default {
type
:
Array
,
type
:
Array
,
default
:
()
=>
[]
default
:
()
=>
[]
},
},
layoutButtonsDefaultFun
:
{
// 默认按钮方法 - 从父组件传入,是为了方便暴露给外层页面调用
type
:
Array
,
default
:
()
=>
[]
},
},
},
data
()
{
data
()
{
return
{
return
{
...
@@ -92,10 +96,10 @@ export default {
...
@@ -92,10 +96,10 @@ export default {
query
:
'search'
query
:
'search'
},
},
allFuns
:
[
allFuns
:
[
{
//
{
name
:
'save'
,
//
name: 'save',
clickFunction
:
this
.
saveFunction
,
//
clickFunction: this.saveFunction,
},
//
},
// {
// {
// name: 'query',
// name: 'query',
// clickFunction: this.query,
// clickFunction: this.query,
...
@@ -113,7 +117,7 @@ export default {
...
@@ -113,7 +117,7 @@ export default {
mounted
()
{
mounted
()
{
this
.
configInfo
=
this
.
dynamicInfo
().
config
;
this
.
configInfo
=
this
.
dynamicInfo
().
config
;
this
.
readOnly
=
this
.
dynamicInfo
().
queryParams
.
readOnly
;
this
.
readOnly
=
this
.
dynamicInfo
().
queryParams
.
readOnly
;
const
funcs
=
[...
this
.
allFuns
,
...
this
.
headerButtons
,
...
this
.
layoutButtonsFun
];
// 综合按钮方法
const
funcs
=
[...
this
.
layoutButtonsDefaultFun
,
...
this
.
headerButtons
,
...
this
.
layoutButtonsFun
];
// 综合按钮方法
this
.
allFuns
=
[...
new
Map
(
funcs
.
map
(
item
=>
[
item
.
name
,
item
])).
values
()];
this
.
allFuns
=
[...
new
Map
(
funcs
.
map
(
item
=>
[
item
.
name
,
item
])).
values
()];
this
.
layoutButtons
=
(
this
.
configInfo
.
layoutButtons
||
[]).
concat
(
this
.
headerButtons
).
filter
(
o
=>
this
.
allFuns
.
some
(
e
=>
e
.
name
===
o
.
name
));
this
.
layoutButtons
=
(
this
.
configInfo
.
layoutButtons
||
[]).
concat
(
this
.
headerButtons
).
filter
(
o
=>
this
.
allFuns
.
some
(
e
=>
e
.
name
===
o
.
name
));
this
.
init
();
this
.
init
();
...
@@ -145,77 +149,77 @@ export default {
...
@@ -145,77 +149,77 @@ export default {
// remove() {
// remove() {
// },
// },
async
saveFunction
()
{
//
async saveFunction() {
const
saveDataSet
=
this
.
dynamicInfo
().
dataSetObject
;
//
const saveDataSet = this.dynamicInfo().dataSetObject;
const
dataSets
=
{...
saveDataSet
};
//
const dataSets = {...saveDataSet};
for
(
let
key
in
dataSets
)
{
//
for (let key in dataSets) {
if
(
dataSets
.
hasOwnProperty
(
key
)
&&
dataSets
[
key
].
t
ype
===
'Form'
)
{
// 确保key是对象自身的属性
// if (dataSets.hasOwnProperty(key) && dataSets[key].tabT
ype==='Form') { // 确保key是对象自身的属性
const
{
instanceRef
}
=
dataSets
[
key
];
//
const {instanceRef} = dataSets[key];
if
(
instanceRef
)
{
//
if(instanceRef) {
const
values
=
await
instanceRef
.
validate
();
//
const values = await instanceRef.validate();
dataSets
[
key
].
submitValues
=
values
;
//
dataSets[key].submitValues = values;
}
//
}
}
//
}
}
//
}
const
{
layoutCode
,
metaKeys
,
dataSetMap
}
=
this
.
getDataSets
(
dataSets
);
//
const {layoutCode, metaKeys, dataSetMap} = this.getDataSets(dataSets);
save
([{
layoutCode
,
metaKeys
,
...
dataSetMap
}]).
then
(
res
=>
{
//
save([{layoutCode, metaKeys, ...dataSetMap}]).then(res => {
Toast
.
success
(
'保存成功!'
);
//
Toast.success('保存成功!');
})
//
})
},
//
},
getDataSets
(
dataSetTree
)
{
//
getDataSets(dataSetTree) {
const
{
layoutCode
}
=
this
.
dynamicInfo
().
config
;
//
const { layoutCode } = this.dynamicInfo().config;
const
metaKeys
=
{
top
:
[]
};
//
const metaKeys = { top: [] };
const
dataSetMap
=
{};
//
const dataSetMap = {};
const
serverNames
=
{};
//
const serverNames = {};
const
saveCheckUrls
=
{};
//
const saveCheckUrls = {};
const
delChackUrls
=
{};
//
const delChackUrls = {};
Object
.
values
(
dataSetTree
).
forEach
(
config
=>
{
//
Object.values(dataSetTree).forEach(config => {
const
{
parentDataSetName
,
dataSetName
,
baseTable
,
parentTable
,
submitValues
,
savedCheckApi
}
=
config
;
//
const { parentDataSetName, dataSetName, baseTable, parentTable, submitValues, savedCheckApi } = config;
if
(
baseTable
!==
parentTable
)
{
// 不是同一数据源
//
if (baseTable !== parentTable) { // 不是同一数据源
if
(
parentDataSetName
)
{
//
if (parentDataSetName) {
if
(
dataSetMap
[
parentDataSetName
])
{
// 存在值
//
if (dataSetMap[parentDataSetName]) { // 存在值
let
currentVal
=
dataSetMap
[
parentDataSetName
][
0
];
//
let currentVal = dataSetMap[parentDataSetName][0];
currentVal
[
dataSetName
]
=
submitValues
?
[
submitValues
.
allValues
]
:
[];
//
currentVal[dataSetName] = submitValues ? [submitValues.allValues] : [];
dataSetMap
[
parentDataSetName
]
=
[
currentVal
];
//
dataSetMap[parentDataSetName] = [currentVal];
}
else
{
//
} else {
dataSetMap
[
parentDataSetName
]
=
[{
//
dataSetMap[parentDataSetName] = [{
[
dataSetName
]:
submitValues
?
[
submitValues
.
allValues
]
:
[]
//
[dataSetName]: submitValues ? [submitValues.allValues] : []
}]
//
}]
}
//
}
metaKeys
[
parentDataSetName
].
push
(
dataSetName
);
//
metaKeys[parentDataSetName].push(dataSetName);
metaKeys
[
dataSetName
]
=
[];
//
metaKeys[dataSetName] = [];
}
else
{
//
} else {
if
(
dataSetMap
[
dataSetName
])
{
// 存在值
//
if (dataSetMap[dataSetName]) { // 存在值
let
currentVal
=
dataSetMap
[
dataSetName
][
0
];
//
let currentVal = dataSetMap[dataSetName][0];
currentVal
=
{...(
submitValues
?
submitValues
.
allValues
:
{}),
...
currentVal
};
//
currentVal = {...(submitValues ? submitValues.allValues : {}), ...currentVal};
if
(
currentVal
.
childrenDs
)
{
//
if (currentVal.childrenDs) {
const
childs
=
[...
currentVal
.
childrenDs
];
//
const childs = [...currentVal.childrenDs];
delete
currentVal
.
childrenDs
;
//
delete currentVal.childrenDs;
childs
.
forEach
(
item
=>
{
//
childs.forEach(item => {
currentVal
=
{...
currentVal
,
...
item
};
//
currentVal = {...currentVal, ...item};
})
//
})
}
//
}
dataSetMap
[
dataSetName
]
=
[
currentVal
];
//
dataSetMap[dataSetName] = [currentVal];
}
else
{
//
} else {
dataSetMap
[
dataSetName
]
=
submitValues
?
[
submitValues
.
allValues
]
:
[]
//
dataSetMap[dataSetName] = submitValues ? [submitValues.allValues] : []
}
//
}
metaKeys
.
top
.
push
(
dataSetName
);
//
metaKeys.top.push(dataSetName);
metaKeys
[
dataSetName
]
=
[];
//
metaKeys[dataSetName] = [];
}
//
}
}
else
if
(
baseTable
)
{
// 复用数据源
//
} else if (baseTable) { // 复用数据源
if
(
dataSetMap
[
parentDataSetName
])
{
//
if (dataSetMap[parentDataSetName]) {
let
currentVal
=
dataSetMap
[
parentDataSetName
][
0
];
//
let currentVal = dataSetMap[parentDataSetName][0];
dataSetMap
[
parentDataSetName
]
=
[{...
currentVal
,
...(
submitValues
?
submitValues
.
formValues
:
{})}];
//
dataSetMap[parentDataSetName] = [{...currentVal, ...(submitValues ? submitValues.formValues : {})}];
}
else
{
//
} else {
dataSetMap
[
parentDataSetName
]
=
[{
childrenDs
:
submitValues
?
submitValues
.
formValues
:
{}}]
//
dataSetMap[parentDataSetName] = [{childrenDs: submitValues ? submitValues.formValues : {}}]
}
//
}
}
//
}
});
//
});
return
{
//
return {
layoutCode
,
metaKeys
,
dataSetMap
,
serverNames
,
saveCheckUrls
,
delChackUrls
//
layoutCode, metaKeys, dataSetMap, serverNames, saveCheckUrls, delChackUrls
}
//
}
},
//
},
}
}
}
}
</
script
>
</
script
>
...
...
src/Dynamic/index.vue
View file @
7f2823df
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
* @Author: zong.wang01@hand-china.com
* @Author: zong.wang01@hand-china.com
* @Date: 2024-07-29 10:51:56
* @Date: 2024-07-29 10:51:56
* @LastEditors: zong.wang01@hand-china.com
* @LastEditors: zong.wang01@hand-china.com
* @LastEditTime: 2024-0
8-21 16:52:03
* @LastEditTime: 2024-0
9-06 15:26:18
* @Version: 1.0.0
* @Version: 1.0.0
* @Description:
* @Description:
* @Copyright: Copyright (c) 2021, Hand-RongJing
* @Copyright: Copyright (c) 2021, Hand-RongJing
...
@@ -30,24 +30,27 @@
...
@@ -30,24 +30,27 @@
v-if=
"configDatas.id"
v-if=
"configDatas.id"
:layoutButtonsFun=
"layoutButtons"
:layoutButtonsFun=
"layoutButtons"
:headerButtons=
"headerButtons"
:headerButtons=
"headerButtons"
:layoutButtonsDefaultFun=
"layoutButtonsDefaultFun"
/>
/>
</d-view>
</d-view>
</
template
>
</
template
>
<
script
>
<
script
>
import
{
NavBar
,
Loading
}
from
'vant'
;
import
{
NavBar
,
Loading
,
Toast
}
from
'vant'
;
import
{
DView
,
DHeader
,
DContent
,
DScroll
}
from
'./LayoutComponents'
;
import
{
DView
,
DHeader
,
DContent
,
DScroll
}
from
'./LayoutComponents'
;
import
LayoutButtons
from
'./LayoutButtons'
;
import
LayoutButtons
from
'./LayoutButtons'
;
import
ConfigRenderComponent
from
'./ConfigRenderComponent/index.jsx'
;
import
ConfigRenderComponent
from
'./ConfigRenderComponent/index.jsx'
;
import
{
query
,
queryRoute
}
from
'./service'
import
{
query
,
queryRoute
,
save
}
from
'./service'
import
'./index.less'
import
'./index.less'
import
EventBus
from
'./utils/eventBus'
;
import
EventBus
from
'./utils/eventBus'
;
import
{
getLayoutSaveData
}
from
'./utils/utils'
;
export
default
{
export
default
{
name
:
'Dynamic'
,
name
:
'Dynamic'
,
components
:
{
components
:
{
[
Loading
.
name
]:
Loading
,
[
Loading
.
name
]:
Loading
,
[
NavBar
.
name
]:
NavBar
,
[
NavBar
.
name
]:
NavBar
,
[
Toast
.
name
]:
Toast
,
LayoutButtons
,
LayoutButtons
,
ConfigRenderComponent
,
ConfigRenderComponent
,
DView
,
DView
,
...
@@ -105,7 +108,13 @@ export default {
...
@@ -105,7 +108,13 @@ export default {
configDatas
:
{},
// 页面配置信息
configDatas
:
{},
// 页面配置信息
params
:
{},
// 页面路由参数
params
:
{},
// 页面路由参数
dataSetObject
:
{},
// 页面配置信息的dataset
dataSetObject
:
{},
// 页面配置信息的dataset
duplicateDs
:
{}
duplicateDs
:
{},
layoutButtonsDefaultFun
:
[
{
name
:
'save'
,
clickFunction
:
this
.
layoutSave
,
},
]
}
}
},
},
provide
()
{
provide
()
{
...
@@ -140,7 +149,7 @@ export default {
...
@@ -140,7 +149,7 @@ export default {
this
.
loading
=
true
;
this
.
loading
=
true
;
let
readOnly
=
false
let
readOnly
=
false
// eslint-disable-next-line eqeqeq
// eslint-disable-next-line eqeqeq
if
(
this
.
params
.
readOnly
===
"YES"
||
this
.
params
.
readOnly
==
'
true'
)
{
if
(
this
.
params
.
readOnly
===
"YES"
||
this
.
params
.
readOnly
==
'
Y'
||
this
.
params
.
readOnly
==
'true'
||
this
.
params
.
readOnly
===
true
)
{
readOnly
=
true
readOnly
=
true
}
}
...
@@ -196,6 +205,17 @@ export default {
...
@@ -196,6 +205,17 @@ export default {
// componentRenderers: this.componentRenderers // 组件渲染内容
// componentRenderers: this.componentRenderers // 组件渲染内容
}
}
},
},
// 布局按钮保存
async
layoutSave
()
{
const
data
=
await
getLayoutSaveData
(
this
.
getDynamicInfo
());
try
{
const
res
=
await
save
(
data
);
Toast
.
success
(
'保存成功!'
);
return
true
;
}
catch
(
err
)
{
throw
new
Error
(
"保存失败"
);
}
},
backClick
()
{
backClick
()
{
if
(
this
.
$attrs
[
'onGoBack'
])
{
if
(
this
.
$attrs
[
'onGoBack'
])
{
this
.
$emit
(
'goBack'
);
this
.
$emit
(
'goBack'
);
...
...
src/Dynamic/utils/utils.js
View file @
7f2823df
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
* @Author: zong.wang01@hand-china.com
* @Author: zong.wang01@hand-china.com
* @Date: 2024-07-30 14:39:47
* @Date: 2024-07-30 14:39:47
* @LastEditors: zong.wang01@hand-china.com
* @LastEditors: zong.wang01@hand-china.com
* @LastEditTime: 2024-0
8-21 15:45:48
* @LastEditTime: 2024-0
9-06 15:24:17
* @Version: 1.0.0
* @Version: 1.0.0
* @Description: 工具类
* @Description: 工具类
* @Copyright: Copyright (c) 2021, Hand-RongJing
* @Copyright: Copyright (c) 2021, Hand-RongJing
...
@@ -182,6 +182,84 @@ const isTenantRoleLevel = () => {
...
@@ -182,6 +182,84 @@ const isTenantRoleLevel = () => {
}
}
/**
* 获取页面布局保存数据
*/
const
getLayoutSaveData
=
async
(
dynamicInfo
)
=>
{
const
saveDataSet
=
dynamicInfo
.
dataSetObject
;
const
dataSets
=
{...
saveDataSet
};
for
(
let
key
in
dataSets
)
{
if
(
dataSets
.
hasOwnProperty
(
key
)
&&
dataSets
[
key
].
tabType
===
'Form'
)
{
// 确保key是对象自身的属性
const
{
instanceRef
}
=
dataSets
[
key
];
if
(
instanceRef
)
{
const
values
=
await
instanceRef
.
validate
();
dataSets
[
key
].
submitValues
=
values
;
}
}
}
const
{
layoutCode
,
metaKeys
,
dataSetMap
}
=
getDataSets
(
dynamicInfo
,
dataSets
);
return
[{
layoutCode
,
metaKeys
,
...
dataSetMap
}];
// save([{layoutCode, metaKeys, ...dataSetMap}]).then(res => {
// saveCallBack(res);
// })
}
const
getDataSets
=
(
dynamicInfo
,
dataSetTree
)
=>
{
const
{
layoutCode
}
=
dynamicInfo
.
config
;
const
metaKeys
=
{
top
:
[]
};
const
dataSetMap
=
{};
const
serverNames
=
{};
const
saveCheckUrls
=
{};
const
delChackUrls
=
{};
Object
.
values
(
dataSetTree
).
forEach
(
config
=>
{
const
{
parentDataSetName
,
dataSetName
,
baseTable
,
parentTable
,
submitValues
,
savedCheckApi
}
=
config
;
if
(
baseTable
!==
parentTable
)
{
// 不是同一数据源
if
(
parentDataSetName
)
{
if
(
dataSetMap
[
parentDataSetName
])
{
// 存在值
let
currentVal
=
dataSetMap
[
parentDataSetName
][
0
];
currentVal
[
dataSetName
]
=
submitValues
?
[
submitValues
.
allValues
]
:
[];
dataSetMap
[
parentDataSetName
]
=
[
currentVal
];
}
else
{
dataSetMap
[
parentDataSetName
]
=
[{
[
dataSetName
]:
submitValues
?
[
submitValues
.
allValues
]
:
[]
}]
}
metaKeys
[
parentDataSetName
].
push
(
dataSetName
);
metaKeys
[
dataSetName
]
=
[];
}
else
{
if
(
dataSetMap
[
dataSetName
])
{
// 存在值
let
currentVal
=
dataSetMap
[
dataSetName
][
0
];
currentVal
=
{...(
submitValues
?
submitValues
.
allValues
:
{}),
...
currentVal
};
if
(
currentVal
.
childrenDs
)
{
const
childs
=
[...
currentVal
.
childrenDs
];
delete
currentVal
.
childrenDs
;
childs
.
forEach
(
item
=>
{
currentVal
=
{...
currentVal
,
...
item
};
})
}
dataSetMap
[
dataSetName
]
=
[
currentVal
];
}
else
{
dataSetMap
[
dataSetName
]
=
submitValues
?
[
submitValues
.
allValues
]
:
[]
}
metaKeys
.
top
.
push
(
dataSetName
);
metaKeys
[
dataSetName
]
=
[];
}
}
else
if
(
baseTable
)
{
// 复用数据源
if
(
dataSetMap
[
parentDataSetName
])
{
let
currentVal
=
dataSetMap
[
parentDataSetName
][
0
];
dataSetMap
[
parentDataSetName
]
=
[{...
currentVal
,
...(
submitValues
?
submitValues
.
formValues
:
{})}];
}
else
{
dataSetMap
[
parentDataSetName
]
=
[{
childrenDs
:
submitValues
?
submitValues
.
formValues
:
{}}]
}
}
});
return
{
layoutCode
,
metaKeys
,
dataSetMap
,
serverNames
,
saveCheckUrls
,
delChackUrls
}
}
export
{
export
{
getCustomizedProp
,
getCustomizedProp
,
getCustomized
,
getCustomized
,
...
@@ -193,5 +271,6 @@ export {
...
@@ -193,5 +271,6 @@ export {
getRefByTabCode
,
getRefByTabCode
,
getOrganizationId
,
getOrganizationId
,
getCurrentUser
,
getCurrentUser
,
isTenantRoleLevel
isTenantRoleLevel
,
getLayoutSaveData
};
};
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