| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220 |
- import ProcessRequest from '../../common/util/request/ProcessRequest'
- import ProcessCheck from '../../viewmodel/process/ProcessCheck'
- import ProcessInfo from '../../viewmodel/process/ProcessInfo'
- import RequestParamModel from '../../viewmodel/RequestParamModel'
- import promptAction from '@ohos.promptAction'
- import PageInfo from '../../viewmodel/PageInfo'
- import DictValue from '../../viewmodel/DictValue'
- import ProcessDeviceDailyCheck from '../../viewmodel/process/ProcessDeviceDailyCheck'
- import HashMap from '@ohos.util.HashMap'
- import TimeUtil from '../../common/util/TimeUtil'
- import CommonConstants from '../../common/constants/CommonConstants'
- // 设备点检工序
- @Component
- export struct DeviceCheckView {
- // 设备每日点检
- @State deviceChecks: ProcessDeviceDailyCheck[] = [
- {
- id: '1',
- stationIp: '192.168.1.100',
- deviceNo: 'DEV001',
- deviceName: '数控机床A型',
- deviceType: '001',
- meteringDate: '2024-12-31',
- meteringState: 1,
- warrantyPeriod: '2025-06-30',
- warrantyState: 1,
- created: Date.now()
- },
- {
- id: '2',
- stationIp: '192.168.1.101',
- deviceNo: 'DEV002',
- deviceName: '激光切割机B型',
- deviceType: '002',
- meteringDate: '2024-10-15',
- meteringState: 0,
- warrantyPeriod: '2024-12-31',
- warrantyState: 0,
- created: Date.now()
- },
- {
- id: '3',
- stationIp: '192.168.1.102',
- deviceNo: 'DEV003',
- deviceName: '注塑机C型',
- deviceType: '003',
- meteringDate: '2025-03-20',
- meteringState: 1,
- warrantyPeriod: '2025-09-15',
- warrantyState: 1,
- created: Date.now()
- },
- {
- id: '4',
- stationIp: '192.168.1.103',
- deviceNo: 'DEV004',
- deviceName: '冲压机D型',
- deviceType: '001',
- meteringDate: '2024-08-10',
- meteringState: 0,
- warrantyPeriod: '长期有效',
- warrantyState: 1,
- created: Date.now()
- },
- {
- id: '5',
- stationIp: '192.168.1.104',
- deviceNo: 'DEV005',
- deviceName: '磨床E型',
- deviceType: '002',
- meteringDate: '长期有效',
- meteringState: 1,
- warrantyPeriod: '2024-11-30',
- warrantyState: 0,
- created: Date.now()
- }
- ]
- //查找设备编码
- @State queryDeviceNo: string = 'test000'
- // 设备类型(key为数据字典值,value为数据字典标签)
- @State deviceTypes: HashMap<string, string> = new HashMap()
- // 当前工位IP
- @Consume('stationIp') stationIp: string
- deviceTypeDictCode: string = 'device_type'
- private scrollerDevice: Scroller = new Scroller()
- build() {
- Column() {
- Text("扫描设备 ")
- .fontColor($r('app.color.FFFFFF'))
- .fontSize($r('app.float.fontSize_24'))
- .height('7.9%')
- .width('97.2%')
- 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:'0.7%'})
- // 扫码输入框
- }
- .height('100%')
- .width('27.2%')
- .borderRadius($r('app.float.virtualSize_16'))
- .backgroundColor($r('app.color.000000'))
- Text(TimeUtil.getCurrentDate())
- .fontColor($r('app.color.FFFFFF'))
- .fontSize($r('app.float.fontSize_16'))
- .margin({left:'3%'})
- }
- .height('7.1%')
- .width('97.2%')
- Column() {
- List({scroller: this.scrollerDevice }) {
- ForEach(this.deviceChecks, (item: ProcessDeviceDailyCheck) => {
- 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.deviceNo && item.deviceName ? item.deviceName : '')
- .fontSize($r('app.float.fontSize_16'))
- .fontColor($r('app.color.FFFFFF'))
- .fontWeight(FontWeight.Lighter)
- .margin({top:'2%',bottom:'1%'})
- Text('编码:' + item.deviceNo ? 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)
- if ( item.deviceNo) {
- 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)
- if ( item.deviceNo) {
- 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)
- }
- .height('90%')
- .width('97%')
- .justifyContent(FlexAlign.Start)
- }
- .height('17%')
- .width('100%')
- .margin({ bottom: 8})
- .borderRadius($r('app.float.virtualSize_16'))
- .backgroundColor($r('app.color.10FFFFFF'))
- })
- }
- .height('94%')
- .width('100%')
- }
- .justifyContent(FlexAlign.Center)
- .height('85%')
- .width('97.2%')
- }
- .width('100%')
- .height('100%')
- }
- }
|