Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
vk-uni
vk-unicloud-admin
提交
eb00412e
vk-unicloud-admin
项目概览
vk-uni
/
vk-unicloud-admin
9 个月 前同步成功
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
vk-unicloud-admin
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
eb00412e
编写于
4月 21, 2023
作者:
VK1688
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
优化动态组件数据管理页面
上级
aba5b386
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
142 addition
and
50 deletion
+142
-50
pages_plugs/system_uni/vk-components-dynamic.vue
pages_plugs/system_uni/vk-components-dynamic.vue
+80
-11
uniCloud-aliyun/cloudfunctions/router/service/admin/system_uni/components-dynamic/sys/add.js
...er/service/admin/system_uni/components-dynamic/sys/add.js
+23
-15
uniCloud-aliyun/cloudfunctions/router/service/admin/system_uni/components-dynamic/sys/update.js
...service/admin/system_uni/components-dynamic/sys/update.js
+39
-24
未找到文件。
pages_plugs/system_uni/vk-components-dynamic.vue
浏览文件 @
eb00412e
...
...
@@ -28,7 +28,12 @@
@
delete=
"deleteBtn"
@
current-change=
"currentChange"
@
selection-change=
"selectionChange"
></vk-data-table>
>
<!-- 排序值 -->
<
template
v-slot:sort=
"{ row, column, index }"
>
<el-input
v-model=
"row.sort"
size=
"mini"
@
change=
"sortChange($event, row)"
/>
</
template
>
</vk-data-table>
<!-- 表格组件结束 -->
<!-- 添加或编辑的弹窗开始 -->
...
...
@@ -60,6 +65,17 @@ var that; // 当前页面对象
var
vk
=
uni
.
vk
;
// vk实例
var
originalForms
=
{};
// 表单初始化数据
var
typeData
=
[
{
value
:
"
image
"
,
label
:
"
图片
"
},
{
value
:
"
swiper
"
,
label
:
"
图片轮播
"
},
{
value
:
"
grid-btn
"
,
label
:
"
宫格按钮
"
},
{
value
:
"
notice
"
,
label
:
"
通知
"
},
{
value
:
"
text
"
,
label
:
"
文本
"
},
{
value
:
"
rich-text
"
,
label
:
"
富文本
"
},
{
value
:
"
button
"
,
label
:
"
按钮
"
},
{
value
:
"
custom
"
,
label
:
"
自定义
"
}
];
export
default
{
data
()
{
// 页面数据变量
...
...
@@ -74,10 +90,36 @@ export default {
action
:
"
admin/system_uni/components-dynamic/sys/getList
"
,
// 表格字段显示规则
columns
:
[
{
key
:
"
sort
"
,
title
:
"
排序值
"
,
type
:
"
number
"
,
width
:
100
,
sortable
:
"
custom
"
},
{
key
:
"
data_id
"
,
title
:
"
组件数据id
"
,
type
:
"
text
"
,
width
:
200
},
{
key
:
"
title
"
,
title
:
"
数据标题
"
,
type
:
"
text
"
,
width
:
200
},
{
key
:
"
description
"
,
title
:
"
数据描述
"
,
type
:
"
textarea
"
},
{
key
:
"
data
"
,
title
:
"
组件数据
"
,
type
:
"
json
"
,
width
:
200
},
{
key
:
"
show
"
,
title
:
"
是否显示
"
,
type
:
"
switch
"
,
activeValue
:
true
,
inactiveValue
:
false
,
width
:
80
,
watch
:
(
res
)
=>
{
let
{
value
,
row
,
change
}
=
res
;
vk
.
callFunction
({
url
:
"
admin/system_uni/components-dynamic/sys/update
"
,
title
:
"
请求中...
"
,
data
:
{
_id
:
row
.
_id
,
show
:
value
},
success
:
data
=>
{
change
(
value
);
// 这一步是让表格行内的开关改变显示状态
}
});
}
},
{
key
:
"
type
"
,
title
:
"
type
"
,
type
:
"
select
"
,
width
:
120
,
data
:
typeData
},
{
key
:
"
name
"
,
title
:
"
name
"
,
type
:
"
text
"
,
width
:
120
},
{
key
:
"
_add_time
"
,
title
:
"
添加时间
"
,
type
:
"
time
"
,
width
:
200
},
{
key
:
"
_add_time
"
,
title
:
"
距离现在
"
,
type
:
"
dateDiff
"
,
width
:
120
}
],
...
...
@@ -94,15 +136,24 @@ export default {
formData
:
{},
// 查询表单的字段规则 fieldName:指定数据库字段名,不填默认等于key
columns
:
[
{
key
:
"
data_id
"
,
title
:
"
组件数据ID
"
,
type
:
"
text
"
,
mode
:
"
%%
"
},
{
key
:
"
title
"
,
title
:
"
数据标题
"
,
type
:
"
text
"
,
mode
:
"
%%
"
},
{
key
:
"
_add_time
"
,
title
:
"
添加时间
"
,
type
:
"
datetimerange
"
,
width
:
400
,
mode
:
"
[]
"
}
{
key
:
"
data_id
"
,
title
:
"
组件数据ID
"
,
type
:
"
text
"
,
width
:
180
,
mode
:
"
%%
"
},
{
key
:
"
title
"
,
title
:
"
数据标题
"
,
type
:
"
text
"
,
width
:
180
,
mode
:
"
%%
"
},
{
key
:
"
type
"
,
title
:
"
type
"
,
type
:
"
select
"
,
width
:
160
,
mode
:
"
=
"
,
data
:
[
{
value
:
""
,
label
:
"
全部
"
},
...
typeData
]
},
{
key
:
"
name
"
,
title
:
"
name
"
,
type
:
"
text
"
,
width
:
160
,
mode
:
"
%%
"
},
{
key
:
"
_add_time
"
,
title
:
"
添加时间
"
,
type
:
"
datetimerange
"
,
width
:
380
,
mode
:
"
[]
"
}
]
},
form1
:
{
// 表单请求数据,此处可以设置默认值
data
:
{
sort
:
0
,
show
:
true
},
// 表单属性
props
:
{
...
...
@@ -110,10 +161,19 @@ export default {
action
:
""
,
// 表单字段显示规则
columns
:
[
{
key
:
""
,
title
:
"
基础
"
,
type
:
"
bar-title
"
},
{
key
:
"
data_id
"
,
title
:
"
组件数据id
"
,
type
:
"
text
"
,
show
:
[
"
add
"
]
},
{
key
:
"
title
"
,
title
:
"
数据标题
"
,
type
:
"
text
"
},
{
key
:
"
data
"
,
title
:
"
组件数据
"
,
type
:
"
json
"
},
{
key
:
"
description
"
,
title
:
"
数据描述
"
,
type
:
"
textarea
"
}
{
key
:
"
description
"
,
title
:
"
数据描述
"
,
type
:
"
textarea
"
},
{
key
:
""
,
title
:
"
扩展
"
,
type
:
"
bar-title
"
},
{
key
:
"
sort
"
,
title
:
"
排序值
"
,
type
:
"
number
"
},
{
key
:
"
show
"
,
title
:
"
是否显示
"
,
type
:
"
switch
"
,
activeValue
:
true
,
inactiveValue
:
false
},
{
key
:
"
type
"
,
title
:
"
type
"
,
type
:
"
select
"
,
data
:
typeData
},
{
key
:
"
name
"
,
title
:
"
name
"
,
type
:
"
text
"
,
tips
:
"
同一页面可以设置相同的name
"
},
],
// 表单验证规则
rules
:
{
...
...
@@ -200,13 +260,22 @@ export default {
_id
:
item
.
_id
}
});
}
},
watch
:
{
},
// 修改排序值
sortChange
(
sort
,
item
){
vk
.
callFunction
({
url
:
'
admin/system_uni/components-dynamic/sys/update
'
,
data
:
{
_id
:
item
.
_id
,
sort
:
Number
(
sort
)
},
success
:
(
data
)
=>
{
}
});
},
},
// 过滤器
filters
:
{
watch
:
{
},
// 计算属性
...
...
uniCloud-aliyun/cloudfunctions/router/service/admin/system_uni/components-dynamic/sys/add.js
浏览文件 @
eb00412e
...
...
@@ -12,39 +12,47 @@ module.exports = {
*/
main
:
async
(
event
)
=>
{
let
{
data
=
{},
userInfo
,
util
,
filterResponse
,
originalParam
}
=
event
;
let
{
customUtil
,
uniID
,
config
,
pubFun
,
vk
,
db
,
_
}
=
util
;
let
{
customUtil
,
uniID
,
config
,
pubFun
,
vk
,
db
,
_
}
=
util
;
let
{
uid
}
=
data
;
let
res
=
{
code
:
0
,
msg
:
''
};
let
res
=
{
code
:
0
,
msg
:
''
};
// 业务逻辑开始-----------------------------------------------------------
let
{
let
{
data_id
,
data
:
dynamicData
,
title
,
description
,
data
:
components_dynamic_data
type
,
sort
=
0
,
show
=
true
,
name
}
=
data
;
// 参数非空检测
if
(
vk
.
pubfn
.
isNullOne
(
data_id
,
data
)){
return
{
code
:
-
1
,
msg
:
'
参数错误
'
};
}
if
(
vk
.
pubfn
.
isNull
(
data_id
))
return
{
code
:
-
1
,
msg
:
'
data_id不能为空
'
};
let
dbName
=
"
vk-components-dynamic
"
;
// 检测key是否已存在
let
num
=
await
vk
.
baseDao
.
count
({
dbName
:
dbName
,
whereJson
:{
dbName
:
dbName
,
whereJson
:
{
data_id
,
}
});
if
(
num
>
0
)
{
return
{
code
:
-
1
,
msg
:
`组件数据id不能重复!`
};
if
(
num
>
0
)
{
return
{
code
:
-
1
,
msg
:
`组件数据id不能重复!`
};
}
// 执行数据库API请求
res
.
id
=
await
vk
.
baseDao
.
add
({
dbName
:
dbName
,
dataJson
:{
data
:
components_dynamic_d
ata
,
dbName
,
dataJson
:
{
data
:
dynamicD
ata
,
data_id
,
title
,
description
description
,
type
,
sort
,
show
,
name
}
});
return
res
;
...
...
uniCloud-aliyun/cloudfunctions/router/service/admin/system_uni/components-dynamic/sys/update.js
浏览文件 @
eb00412e
...
...
@@ -13,38 +13,53 @@ module.exports = {
*/
main
:
async
(
event
)
=>
{
let
{
data
=
{},
userInfo
,
util
,
filterResponse
,
originalParam
}
=
event
;
let
{
customUtil
,
uniID
,
config
,
pubFun
,
vk
,
db
,
_
}
=
util
;
let
{
customUtil
,
uniID
,
config
,
pubFun
,
vk
,
db
,
_
}
=
util
;
let
{
uid
}
=
data
;
let
res
=
{
code
:
0
,
msg
:
''
};
let
res
=
{
code
:
0
,
msg
:
''
};
// 业务逻辑开始-----------------------------------------------------------
let
{
data_id
,
title
,
_id
,
description
}
=
data
;
let
components_dynamic_data
=
data
.
data
;
let
{
_id
,
data_id
,
data
:
dynamicData
,
title
,
description
,
type
,
sort
,
show
,
name
}
=
data
;
// 参数非空检测
if
(
vk
.
pubfn
.
isNullOne
(
_id
,
data_id
)){
return
{
code
:
-
1
,
msg
:
'
参数错误
'
};
}
if
(
vk
.
pubfn
.
isNull
(
_id
))
return
{
code
:
-
1
,
msg
:
'
id不能为空
'
};
let
dbName
=
"
vk-components-dynamic
"
;
// 检测data_id是否已存在
let
num
=
await
vk
.
baseDao
.
count
({
dbName
:
dbName
,
whereJson
:{
data_id
,
_id
:
_
.
neq
(
_id
)
if
(
vk
.
pubfn
.
isNotNull
(
data_id
))
{
// 检测data_id是否已存在
let
num
=
await
vk
.
baseDao
.
count
({
dbName
,
whereJson
:
{
data_id
,
_id
:
_
.
neq
(
_id
)
}
});
if
(
num
>
0
)
{
return
{
code
:
-
1
,
msg
:
`组件数据id不能重复!`
};
}
});
if
(
num
>
0
){
return
{
code
:
-
1
,
msg
:
`组件数据id不能重复!`
};
}
// 执行数据库API请求
res
.
num
=
await
vk
.
baseDao
.
update
({
dbName
:
dbName
,
whereJson
:{
_id
},
dataJson
:{
data
:
components_dynamic_data
,
data_id
,
title
,
description
res
.
num
=
await
vk
.
baseDao
.
updateById
({
dbName
,
id
:
_id
,
dataJson
:
{
data
:
dynamicData
,
data_id
,
title
,
description
,
type
,
sort
,
show
,
name
}
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录