Commit 87a166c8 by huangqy

FORM表单

parent 70171f25
import { generalInitList, scanInitList, systemList, UniListItem } from '@ohos/system/src/main/ets/model/UniInitList'
import { TitleBar } from '../../view/title/TitleBar'
import { BasicDialog } from '../../view/BasicDialog/BasicDialog'
import promptAction from '@ohos.promptAction'
import { GeneralDialog } from '../../view/GeneralDialog/GeneralDialog'
@Extend(Button) function CommonButtonStyle() {
.borderWidth(2)
......@@ -74,7 +74,7 @@ export struct General {
}
dialogController: CustomDialogController = new CustomDialogController({
builder: BasicDialog({
builder: GeneralDialog({
cancel: this.onCancel,
confirm: this.onSubmit,
clickItem: $clickItem,
......@@ -93,9 +93,6 @@ export struct General {
console.info('------确认------')
}
existApp() {
console.info('Click the callback in the blank area')
}
build() {
Column() {
......
......@@ -9,38 +9,33 @@ import { UniListItem } from '@ohos/system/src/main/ets/model/UniInitList';
.stateEffect(true)
}
@Observed
class UniList {
title: string; // 标题
showExtraIcon: boolean; // 是否显示额外的图标
showArrow: boolean; // 右边箭头
extraIcon?: Resource; // 图标本体
url?: string; // 跳转的URL
targetValue?: string; // 右侧的值
description?: string; // 描述
constructor(title, showExtraIcon, showArrow, extraIcon, url, targetValue, description) {
this.title = title;
this.showExtraIcon = showExtraIcon;
this.showArrow = showArrow;
this.extraIcon = extraIcon;
this.url = url;
this.targetValue = targetValue;
this.description = description;
}
// 需要提交的表单
interface FormData {
httpURL: string,
httpPORT: string,
scoketURL: string,
scoketPORT: string,
themeName: string,
themeColor: string,
reconnection_mode: boolean,
push_mode: boolean,
transmission_mode: string,
continue_scan_mode: boolean,
scan_read_mode: string,
scanning_mode: string,
broadcastKey: string,
power: string
}
@CustomDialog
@Component
export struct GeneralDialog {
// @ObjectLink uniList: UniList
@Link formData: FormData;
@Link clickItem: UniListItem
controller: CustomDialogController
cancel: () => void
confirm: () => void
@BuilderParam container: () => void
textController: TextInputController = new TextInputController()
build() {
Column() {
......@@ -53,24 +48,60 @@ export struct GeneralDialog {
.color('#19ac88')
.opacity(0.6)
.margin({ left: 8, right: 8 })
Text('').fontSize(20)
Text(this.clickItem.title).fontSize(20)
}
.padding({ top: 10, bottom: 10 })
}
Column() {
TextInput({ text: '', controller: this.textController })
if (this.clickItem.key == "transmission_mode") {
Select([{ value: "文件传输" }, { value: "网络传输" }])
.value('请选择数据传输方式')
.borderWidth(1)
.borderRadius(4)
.height(40)
.borderColor("#e5e5e5")
.onSelect((index: number, value?: string) => {
this.formData[this.clickItem?.key] = value
})
} else if (this.clickItem.key == "reconnection_mode") {
Select([{ value: "自动5s重连" }, { value: "手动重连" }])
.value('请选择模式连接方式')
.borderWidth(1)
.borderRadius(4)
.height(40)
.borderColor("#e5e5e5")
.onSelect((index: number, value?: string) => {
this.formData[this.clickItem?.key] = value
})
} else if (this.clickItem.key == "push_mode") {
Select([{ value: "自动推送" }, { value: "手动推送" }])
.value('请选择模式推送方式')
.borderWidth(1)
.borderRadius(4)
.height(35)
.height(40)
.borderColor("#e5e5e5")
.onSelect((index: number, value?: string) => {
this.formData[this.clickItem?.key] = value
})
} else if (this.clickItem.key == "scanning_mode") {
Select([{ value: "手持机终端" }, { value: "手持APP终端" }])
.value('请选择读取类型')
.borderWidth(1)
.borderRadius(4)
.height(40)
.borderColor("#e5e5e5")
.onSelect((index: number, value?: string) => {
this.formData[this.clickItem?.key] = value
})
}
else {
TextInput({ placeholder: '', text: this.formData[this.clickItem?.key] }).height(40).width('90%').borderRadius(4)
.onChange((value: string) => {
this.formData[this.clickItem?.key] = value
})
}
.padding({ left: 10, right: 10 })
.width('100%')
.height(35)
}
Flex({ justifyContent: FlexAlign.SpaceAround }) {
Button('确认')
......@@ -80,6 +111,7 @@ export struct GeneralDialog {
}).CommonButtonStyle()
Button('取消')
.onClick(() => {
this.formData[this.clickItem?.key] = ''
this.controller.close()
this.cancel()
}).CommonButtonStyle()
......
......@@ -193,6 +193,7 @@ export const generalInitList: UniListItem[] = [
export const scanInitList: UniListItem[] = [
{
title: '扫描模式',
key: 'scanning_mode',
showExtraIcon: true,
showArrow: true,
//extraIcon: '',
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论