123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274 |
- //设备点检
- import ProcessRequest from '../common/util/request/ProcessRequest'
- import ProcessDeviceDailyCheck from '../viewmodel/process/ProcessDeviceDailyCheck'
- import DictValue from '../viewmodel/DictValue'
- import promptAction from '@ohos.promptAction'
- import HashMap from '@ohos.util.HashMap'
- import RequestParamModel from '../viewmodel/RequestParamModel'
- import TimeUtil from '../common/util/TimeUtil'
- @CustomDialog
- export struct DeviceInspectionDialog {
- private scrollerDevice: Scroller = new Scroller()
- //查找设备编码
- @State queryDeviceNo: string = 'test000'
- //当前日期
- @State currentDate: string = ''
- // 设备点检列表
- @Link deviceChecks: ProcessDeviceDailyCheck[]
- //选中设备索引
- @State selectDeviceIndex: number=-1
- // 设备类型(key为数据字典值,value为数据字典标签)
- @State deviceTypes: HashMap<string, string> = new HashMap()
- deleteIds: string[] = []
- @Consume('stationIp') stationIp: string
- controller: CustomDialogController
- onConfirm: () => void = () => {}
- deviceTypeDictCode: string = 'device_type'
- async aboutToAppear() {
- this.deleteIds = []
- let deviceDicts: DictValue[] = await ProcessRequest.get(`/api/v1/sys/dictData/queryByType/${this.deviceTypeDictCode}`)
- if (deviceDicts) {
- for (const dict of deviceDicts) {
- this.deviceTypes.set(dict.dictValue!, dict.dictLabel!);
- }
- }
- this.deviceChecks = await ProcessRequest.post('/api/v1/process/deviceDailyCheck/list', {
- stationIp: this.stationIp,
- createDate: TimeUtil.getCurrentDate()
- } as RequestParamModel)
- }
- build() {
- Column() {
- Column() {
- Text("设备点检")
- .fontColor($r('app.color.FFFFFF'))
- .fontSize($r('app.float.fontSize_30'))
- }
- .height('8%')
- .width('100%')
- .justifyContent(FlexAlign.Center)
- Column() {
- Text("扫描设备 ")
- .fontColor($r('app.color.FFFFFF'))
- .fontSize($r('app.float.fontSize_24'))
- Row(){
- Row() {
- // 左侧二维码图标
- Image($r('app.media.material_qr_code'))
- .width($r('app.float.virtualSize_32'))
- .height($r('app.float.virtualSize_32'))
- .fillColor($r('app.color.FFFFFF'))
- .objectFit(ImageFit.Contain)
- .margin({left:'2%'})
- // 扫码输入框
- TextInput({text:this.queryDeviceNo, placeholder: '请扫描设备编码' })
- .type(InputType.Normal)
- .placeholderFont({ size: $r('app.float.fontSize_16') })
- .placeholderColor($r('app.color.30FFFFFF'))
- .fontSize($r('app.float.fontSize_16'))
- .fontColor($r('app.color.FFFFFF'))
- .enableKeyboardOnFocus(false)
- .onSubmit(async () => {
- if (this.deviceChecks) {
- for (const element of this.deviceChecks) {
- if (element.deviceNo === this.queryDeviceNo) {
- promptAction.showToast({
- message: `设备今日已点检,无需重复点检!`,
- duration: 1500,
- bottom: 100
- })
- return
- }
- }
- }
- let check: ProcessDeviceDailyCheck = await ProcessRequest.get(`/api/v1/process/deviceDailyCheck/getServiceLifeByDeviceNo/${this.queryDeviceNo}`)
- this.deviceChecks.unshift(check)
- })
- .onChange((value: string) => {
- this.queryDeviceNo = value;
- //this.onQueryDeviceCode()
- })
- }
- .height('100%')
- .width('65%')
- .borderRadius($r('app.float.virtualSize_16'))
- .backgroundColor($r('app.color.000000'))
- Text(this.currentDate)
- .fontColor($r('app.color.FFFFFF'))
- .fontSize($r('app.float.fontSize_16'))
- .margin({left:'3%'})
- }
- .height('8%')
- .width('50%')
- .margin({bottom:'1%',top:'1%'})
- List({scroller: this.scrollerDevice }) {
- ForEach(this.deviceChecks, (item: ProcessDeviceDailyCheck, index) => {
- ListItem() {
- Row() {
- Column(){
- Text(this.deviceTypes && item.deviceType && this.deviceTypes.hasKey(item.deviceType) ? this.deviceTypes.get(item.deviceType) : '')
- .fontSize($r('app.float.fontSize_24'))
- .fontColor($r('app.color.FFFFFF'))
- Text(`名称:${item.deviceName!}`)
- .fontSize($r('app.float.fontSize_16'))
- .fontColor($r('app.color.FFFFFF'))
- .fontWeight(FontWeight.Lighter)
- .margin({top:'2%',bottom:'1%'})
- Text(`编码:${item.deviceNo!}`)
- .fontSize($r('app.float.fontSize_16'))
- .fontColor($r('app.color.FFFFFF'))
- .fontWeight(FontWeight.Lighter)
- }
- .width('30%')
- .height('100%')
- .justifyContent(FlexAlign.Center)
- .alignItems(HorizontalAlign.Start)
- .margin({right:'16%'})
- Column({space:5}){
- Text(`计量有效期:`)
- .fontSize($r('app.float.fontSize_16'))
- .fontColor($r('app.color.FFFFFF'))
- .fontWeight(FontWeight.Lighter)
- Row(){
- Image(item.meteringState! === 1 ? $r('app.media.device_normal') : $r('app.media.device_expire'))
- .width($r('app.float.virtualSize_24'))
- .height($r('app.float.virtualSize_24'))
- .margin({left:'2%'})
- Text(item.meteringDate ? `${item.meteringDate}` : '长期有效')
- .fontSize($r('app.float.fontSize_16'))
- .fontColor(item.meteringState! === 1 ? $r('app.color.30D158') : $r('app.color.FF453A'))
- .margin({left:'2%'})
- }
- .width('65%')
- .borderRadius($r('app.float.virtualSize_16'))
- .backgroundColor($r('app.color.000000'))
- .height('25%')
- .alignItems(VerticalAlign.Center)
- }
- .width('22%')
- .height('100%')
- .justifyContent(FlexAlign.Center)
- .alignItems(HorizontalAlign.Start)
- Column({space:5}){
- Text(`维保有效期:`)
- .fontSize($r('app.float.fontSize_16'))
- .fontColor($r('app.color.FFFFFF'))
- .fontWeight(FontWeight.Lighter)
- Row(){
- Image(item.warrantyState! === 1 ? $r('app.media.device_normal') :$r('app.media.device_expire'))
- .width($r('app.float.virtualSize_24'))
- .height($r('app.float.virtualSize_24'))
- .margin({left:'2%'})
- Text(item.warrantyPeriod ? `${item.warrantyPeriod}` : '长期有效')
- .fontSize($r('app.float.fontSize_16'))
- .fontColor(item.warrantyState! === 1 ? $r('app.color.30D158') : $r('app.color.FF453A'))
- .margin({left:'2%'})
- }
- .width('65%')
- .borderRadius($r('app.float.virtualSize_16'))
- .backgroundColor($r('app.color.000000'))
- .height('25%')
- .alignItems(VerticalAlign.Center)
- }
- .width('22%')
- .height('100%')
- .justifyContent(FlexAlign.Center)
- .alignItems(HorizontalAlign.Start)
- Column(){
- Image($r('app.media.process_delete_seq'))
- .width($r('app.float.virtualSize_48'))
- .height($r('app.float.virtualSize_48'))
- .fillColor($r('app.color.FF453A'))
- .onClick(()=>{
- let deleteCheck: ProcessDeviceDailyCheck = this.deviceChecks.splice(index, 1)[0];
- if (deleteCheck.id) {
- this.deleteIds.push(deleteCheck.id)
- }
- })
- }
- .width('10%')
- .height('100%')
- .justifyContent(FlexAlign.Center)
- }
- .height('90%')
- .width('95%')
- .justifyContent(FlexAlign.Start)
- }
- .height('18%')
- .width('100%')
- .margin({ bottom: 8})
- .borderRadius($r('app.float.virtualSize_16'))
- .backgroundColor($r('app.color.10FFFFFF'))
- })
- }.height('82%')
- }
- .width('96%')
- .height('84%')
- .alignItems(HorizontalAlign.Start)
- .justifyContent(FlexAlign.Start)
- .margin({left:'2%',right:'2%'})
- Column() {
- Divider()
- .vertical(false)
- .strokeWidth(1)
- .color($r('app.color.15FFFFFF'))
- Row() {
- Row() {
- Text('取消')
- .fontColor($r('app.color.60FFFFFF'))
- .fontSize($r('app.float.fontSize_30'))
- }
- .justifyContent(FlexAlign.Center)
- .width('50%')
- .onClick(() => this.controller.close())
- Divider()
- .vertical(true)
- .strokeWidth(1)
- .color($r('app.color.15FFFFFF'))
- Row() {
- Text('确定')
- .fontColor($r('app.color.007AFF'))
- .fontSize($r('app.float.fontSize_30'))
- }
- .justifyContent(FlexAlign.Center)
- .width('50%')
- .onClick(async () => {
- if (this.deleteIds && this.deleteIds.length > 0) {
- await ProcessRequest.post('/api/v1/process/deviceDailyCheck/batchDel', {
- ids: this.deleteIds
- } as RequestParamModel)
- this.deleteIds = []
- }
- if (!this.deviceChecks || this.deviceChecks.length <= 0) {
- this.controller.close();
- return
- }
- for (const check of this.deviceChecks) {
- check.stationIp = this.stationIp
- }
- await ProcessRequest.post('/api/v1/process/deviceDailyCheck/batchSave', this.deviceChecks)
- this.controller.close();
- })
- }
- }
- .width('100%')
- .height('8%')
- }
- .height('71%')
- .width('62%')
- .backgroundColor($r('app.color.2A2A2A'))
- .justifyContent(FlexAlign.End)
- .alignItems(HorizontalAlign.Start)
- .borderColor($r('app.color.000000'))
- .borderWidth(1)
- .borderRadius($r('app.float.virtualSize_16'))
- }
- }
|