AddPersonDialog.ets 1.7 KB
import { companyAdd, beanType } from '../api/user'
import { addType } from '../api/userType'
import { promptAction } from '@kit.ArkUI'
import { AxiosResponse } from '@ohos/axios'

@CustomDialog
export default struct AddPersonDialog {
  controller: CustomDialogController = new CustomDialogController({builder: ''})
  @State addForm : addType = {
    personName: '',
    idNo: ''
  }
  build() {
    Column(){
      Text('添加人员').margin({top: 20})
      Row(){
        Row(){
          Image($r('app.media.require')).width(20)
          Text('姓名')
        }.width(90)
        TextInput({placeholder: '请输入姓名', text: $$this.addForm.personName})
          .backgroundColor('#fff').layoutWeight(1)
      }.border({width: {bottom: 1}, color: '#eee'}).padding({top: 10, bottom: 10})
      Row(){
        Row(){
          Image($r('app.media.require')).width(20)
          Text('身份证号')
        }.width(90)
        TextInput({placeholder: '请输入身份证号', text: $$this.addForm.idNo})
          .backgroundColor('#fff').layoutWeight(1)
      }.border({width: {bottom: 1}, color: '#eee'}).padding({top: 10, bottom: 10})
      Row(){
        Text('取消').layoutWeight(1).fontSize(16).height(60).fontColor('#606266')
          .textAlign(TextAlign.Center)
          .onClick(() => {
            this.controller.close()
          })
        Text('确定').layoutWeight(1).fontSize(16).height(60).fontColor('#1890ff')
          .textAlign(TextAlign.Center)
          .onClick(async () => {
            const res: AxiosResponse<beanType> =  await companyAdd(this.addForm)
            promptAction.showToast({message: res.data.msg})
            this.controller.close()
          })
      }
    }.width('100%').backgroundColor('#fff')
  }
}