Commit 87a166c8 by huangqy

FORM表单

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