Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
90d4c398
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
6007
Star
91
Fork
164
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
18
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
18
Issue
18
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
90d4c398
编写于
11月 07, 2023
作者:
H
hdx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
unicloud-db-contacts: 表单组件 value 已支持 any,将性别类型调整为 number, 和数据库保持一致
上级
86f06b18
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
20 addition
and
17 deletion
+20
-17
pages/component/unicloud-db-contacts/add.uvue
pages/component/unicloud-db-contacts/add.uvue
+3
-4
pages/component/unicloud-db-contacts/detail.uvue
pages/component/unicloud-db-contacts/detail.uvue
+3
-3
pages/component/unicloud-db-contacts/edit.uvue
pages/component/unicloud-db-contacts/edit.uvue
+4
-4
pages/component/unicloud-db-contacts/list.uvue
pages/component/unicloud-db-contacts/list.uvue
+6
-2
pages/component/unicloud-db-contacts/types.uts
pages/component/unicloud-db-contacts/types.uts
+4
-4
未找到文件。
pages/component/unicloud-db-contacts/add.uvue
浏览文件 @
90d4c398
<template>
<view class="page">
<unicloud-db ref="udb" v-slot:default="{error}" :collection="collection" loadtime="manual">
<view v-if="error!=null" class="error">{{error.errMsg}}</view>
</unicloud-db>
<unicloud-db ref="udb" :collection="collection" loadtime="manual"></unicloud-db>
<form @submit="onFormSubmit">
<view class="form-item">
<text class="form-item-label">姓名</text>
...
...
@@ -51,7 +49,8 @@
methods: {
onFormSubmit: function (e : FormSubmitEvent) {
const formData = e.detail.value
formData['gender'] = parseInt(formData['gender'] as string)
const genderString = formData['gender'] as string
formData['gender'] = (genderString.length > 0) ? parseInt(genderString) : -1
this.$uniCloudElement!.add(formData, {
showToast: false,
needLoading: true,
...
...
pages/component/unicloud-db-contacts/detail.uvue
浏览文件 @
90d4c398
...
...
@@ -23,7 +23,7 @@
</view>
<view class="form-item">
<text class="form-item-label">性别</text>
<text class="form-item-input">{{displayGender(data[0]
['gender']
)}}</text>
<text class="form-item-input">{{displayGender(data[0]
.getNumber('gender')
)}}</text>
</view>
<button class="btn-update" type="default" @click="gotoUpdatePage(data[0].getString('_id'))">编辑</button>
</view>
...
...
@@ -60,8 +60,8 @@
this.$uniCloudElement!.loadData()
},
methods: {
displayGender(value :
any
| null) : string {
const str =
(value ?? 0).toString()
displayGender(value :
number
| null) : string {
const str =
value ?? -1
return (GenderList as GenderType[]).find((item : GenderType) : boolean => {
return item.value == str
})!.text;
...
...
pages/component/unicloud-db-contacts/edit.uvue
浏览文件 @
90d4c398
...
...
@@ -62,7 +62,7 @@
where: '',
username: "",
mobile: "",
gender:
''
,
gender:
-1
,
comment: "",
email: "",
genderList: GenderList as GenderType[],
...
...
@@ -80,12 +80,12 @@
},
methods: {
radioChange(e : RadioGroupChangeEvent) {
this.gender =
e.detail.value
this.gender =
parseInt(e.detail.value)
},
update() {
const value = {
username: this.username,
gender:
parseInt(this.gender)
,
gender:
this.gender
,
mobile: this.mobile,
comment: this.comment,
email: this.email,
...
...
@@ -144,7 +144,7 @@
const data1 = data[0];
this.username = data1.getString('username') ?? "";
this.mobile = data1.getString('mobile') ?? "";
this.gender = data1.getNumber('gender')
?.toString() ?? '0'
;
this.gender = data1.getNumber('gender')
?? -1
;
this.comment = data1.getString('comment') ?? "";
this.email = data1.getString('email') ?? "";
}
...
...
pages/component/unicloud-db-contacts/list.uvue
浏览文件 @
90d4c398
<template>
<view class="page">
<unicloud-db ref="udb"
v-slot:default="{data, pagination, loading, hasMore, error}" :collection="collection
"
:
page-size="10
" :getcount="true" loadtime="manual">
<unicloud-db ref="udb"
class="udb" v-slot:default="{data, pagination, loading, hasMore, error}
"
:
collection="collection" :page-size="15
" :getcount="true" loadtime="manual">
<view v-if="error!=null" class="error">{{error.errMsg}}</view>
<list-view ref="listView" class="list-view" :scroll-y="true" @scrolltolower="loadMore()">
<list-item class="list-item" v-for="(item, _) in data" @click="gotoDetailPage(item['_id'] as string)">
...
...
@@ -95,6 +95,10 @@
padding: 20px;
}
.udb {
flex: 1;
}
.list-view {
flex: 1;
flex-direction: column;
...
...
pages/component/unicloud-db-contacts/types.uts
浏览文件 @
90d4c398
...
...
@@ -2,21 +2,21 @@ export const COLLECTION_NAME = 'opendb-contacts'
export type GenderType = {
text : string,
value :
string
,
value :
number
,
}
export const GenderList = [
{
text: "未知",
value:
"0"
value:
0
},
{
text: "男",
value:
"1"
value:
1
},
{
text: "女",
value:
"2"
value:
2
},
] as GenderType[]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录