Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小浣熊撸代码
uni-app
提交
65e1d7d0
U
uni-app
项目概览
小浣熊撸代码
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
65e1d7d0
编写于
12月 11, 2020
作者:
Q
qiang
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'dev' into alpha
上级
4c62076a
a15b2de8
变更
2
展开全部
显示空白变更内容
内联
并排
Showing
2 changed file
with
379 addition
and
333 deletion
+379
-333
packages/uni-cli-shared/components/unicloud-db.vue
packages/uni-cli-shared/components/unicloud-db.vue
+378
-332
packages/vue-cli-plugin-uni/packages/uni-cloud/dist/index.js
packages/vue-cli-plugin-uni/packages/uni-cloud/dist/index.js
+1
-1
未找到文件。
packages/uni-cli-shared/components/unicloud-db.vue
浏览文件 @
65e1d7d0
<
template
>
<view>
<slot
:options=
"options"
:data=
"dataList"
:pagination=
"paginationInternal"
:loading=
"loading"
:error=
"errorMessage"
/>
<slot
:options=
"options"
:data=
"dataList"
:pagination=
"paginationInternal"
:loading=
"loading"
:error=
"errorMessage"
/>
</view>
</
template
>
<
script
>
const
events
=
{
const
events
=
{
load
:
'
load
'
,
error
:
'
error
'
}
const
pageMode
=
{
}
const
pageMode
=
{
add
:
'
add
'
,
replace
:
'
replace
'
}
}
const
attrs
=
[
const
attrs
=
[
'
pageCurrent
'
,
'
pageSize
'
,
'
collection
'
,
...
...
@@ -29,9 +23,9 @@ const attrs = [
'
getcount
'
,
'
orderby
'
,
'
where
'
]
]
export
default
{
export
default
{
name
:
'
UniClouddb
'
,
props
:
{
options
:
{
...
...
@@ -85,7 +79,7 @@ export default {
default
:
false
}
},
data
()
{
data
()
{
return
{
loading
:
false
,
dataList
:
this
.
getone
?
{}
:
[],
...
...
@@ -97,7 +91,7 @@ export default {
errorMessage
:
''
}
},
created
()
{
created
()
{
this
.
_isEnded
=
false
this
.
$watch
(()
=>
{
...
...
@@ -172,7 +166,7 @@ export default {
}
},
// #ifdef H5
beforeDestroy
()
{
beforeDestroy
()
{
if
(
process
.
env
.
NODE_ENV
===
'
development
'
&&
window
.
unidev
)
{
var
cd
=
this
.
_debugDataList
var
dl
=
window
.
unidev
.
clientDB
.
data
...
...
@@ -186,7 +180,7 @@ export default {
},
// #endif
methods
:
{
loadData
(
args1
,
args2
)
{
loadData
(
args1
,
args2
)
{
let
callback
=
null
if
(
typeof
args1
===
'
object
'
)
{
if
(
args1
.
clear
)
{
...
...
@@ -205,26 +199,52 @@ export default {
this
.
_execLoadData
(
callback
)
},
loadMore
()
{
loadMore
()
{
if
(
this
.
_isEnded
)
{
return
}
this
.
_execLoadData
()
},
refresh
()
{
refresh
()
{
this
.
clear
()
this
.
_execLoadData
()
},
clear
()
{
clear
()
{
this
.
_isEnded
=
false
this
.
dataList
=
[]
},
reset
()
{
reset
()
{
this
.
paginationInternal
.
current
=
1
},
remove
(
id
,
{
add
(
value
,
{
toastTitle
,
success
,
fail
,
complete
}
=
{})
{
uni
.
showLoading
()
let
db
=
uniCloud
.
database
()
db
.
collection
(
this
.
collection
).
add
(
value
).
then
((
res
)
=>
{
success
&&
success
(
res
)
uni
.
showToast
({
title
:
toastTitle
||
'
新增成功
'
})
}).
catch
((
err
)
=>
{
fail
&&
fail
(
err
)
uni
.
showModal
({
content
:
err
.
message
,
showCancel
:
false
})
}).
finally
(()
=>
{
uni
.
hideLoading
()
complete
&&
complete
()
})
},
remove
(
id
,
{
action
,
callback
,
success
,
fail
,
complete
,
confirmTitle
,
confirmContent
}
=
{})
{
...
...
@@ -239,11 +259,35 @@ export default {
if
(
!
res
.
confirm
)
{
return
}
this
.
_execRemove
(
id
,
action
,
callback
)
this
.
_execRemove
(
id
,
action
,
success
,
fail
,
complete
)
}
})
},
_execLoadData
(
callback
)
{
update
(
id
,
value
,
{
toastTitle
,
success
,
fail
,
complete
}
=
{})
{
uni
.
showLoading
()
let
db
=
uniCloud
.
database
()
return
db
.
collection
(
this
.
collection
).
doc
(
id
).
update
(
value
).
then
((
res
)
=>
{
success
&&
success
(
res
)
uni
.
showToast
({
title
:
toastTitle
||
'
修改成功
'
})
}).
catch
((
err
)
=>
{
fail
&&
fail
(
err
)
uni
.
showModal
({
content
:
err
.
message
,
showCancel
:
false
})
}).
finally
(()
=>
{
uni
.
hideLoading
()
complete
&&
complete
()
})
},
_execLoadData
(
callback
)
{
if
(
this
.
loading
)
{
return
}
...
...
@@ -292,7 +336,7 @@ export default {
}
})
},
_getExec
()
{
_getExec
()
{
/* eslint-disable no-undef */
let
db
=
uniCloud
.
database
()
...
...
@@ -322,7 +366,7 @@ export default {
return
db
},
_execRemove
(
id
,
action
,
callback
)
{
_execRemove
(
id
,
action
,
success
,
fail
,
complete
)
{
if
(
!
this
.
collection
||
!
id
)
{
return
}
...
...
@@ -348,22 +392,24 @@ export default {
exec
.
collection
(
this
.
collection
).
where
({
_id
:
dbCmd
.
in
(
ids
)
}).
remove
().
then
((
res
)
=>
{
callback
&&
callback
(
res
.
result
)
success
&&
success
(
res
.
result
)
if
(
this
.
pageData
===
pageMode
.
replace
)
{
this
.
refresh
()
}
else
{
this
.
removeData
(
ids
)
}
}).
catch
((
err
)
=>
{
fail
&&
fail
(
err
)
uni
.
showModal
({
content
:
err
.
message
,
showCancel
:
false
})
}).
finally
(()
=>
{
uni
.
hideLoading
()
complete
&&
complete
()
})
},
removeData
(
ids
)
{
removeData
(
ids
)
{
const
il
=
ids
.
slice
(
0
)
const
dl
=
this
.
dataList
for
(
let
i
=
dl
.
length
-
1
;
i
>=
0
;
i
--
)
{
...
...
@@ -374,7 +420,7 @@ export default {
}
}
},
_dispatchEvent
(
type
,
data
)
{
_dispatchEvent
(
type
,
data
)
{
if
(
this
.
_changeDataFunction
)
{
this
.
_changeDataFunction
(
data
,
this
.
_isEnded
)
}
else
{
...
...
@@ -382,5 +428,5 @@ export default {
}
}
}
}
}
</
script
>
packages/vue-cli-plugin-uni/packages/uni-cloud/dist/index.js
浏览文件 @
65e1d7d0
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录