|
@@ -0,0 +1,305 @@
|
|
|
+import ProcessRequest from '../common/util/request/ProcessRequest'
|
|
|
+import { MessageInfo, MessagePage } from '../viewmodel/MessageInfo'
|
|
|
+import RequestParamModel from '../viewmodel/RequestParamModel'
|
|
|
+
|
|
|
+@CustomDialog
|
|
|
+export struct StationInfoDialog{
|
|
|
+ private scrollerList: Scroller = new Scroller()
|
|
|
+ //当前工位
|
|
|
+ @State currentStation:string = ''
|
|
|
+ //当前用户
|
|
|
+ @State currentUser:string = ''
|
|
|
+ //全部已读按钮缩放
|
|
|
+ @State allReadClick:number = 1
|
|
|
+ //消息列表
|
|
|
+ @State messages: MessageInfo[] = [
|
|
|
+ {
|
|
|
+ readState: "1", // 未读
|
|
|
+ content: "您有新的工单待处理:WX-20230001",
|
|
|
+ created: "2023-08-15 09:30:25"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ readState: "0", // 已读
|
|
|
+ content: "物料ASF-100已入库成功",
|
|
|
+ created: "2023-08-14 14:15:33"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ readState: "1", // 未读
|
|
|
+ content: "警告:料箱V-1024库存不足",
|
|
|
+ created: "2023-08-14 11:05:47"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ readState: "0", // 已读
|
|
|
+ content: "工序OP-20报工完成",
|
|
|
+ created: "2023-08-13 16:45:12"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ readState: "1", // 未读
|
|
|
+ content: "紧急:设备E-05需要维护",
|
|
|
+ created: "2023-08-13 10:20:18"
|
|
|
+ }
|
|
|
+ ];
|
|
|
+
|
|
|
+ controller: CustomDialogController
|
|
|
+ loadStationMessage=async ()=>{
|
|
|
+ let res = await ProcessRequest.post('/api/v1/sys/message/stationMessage', {
|
|
|
+ } as RequestParamModel) as MessagePage;
|
|
|
+ this.messages=res?.records??[]
|
|
|
+ this.messages = [...this.messages].sort((a, b) => {
|
|
|
+ const stateA = a.readState ?? '1';
|
|
|
+ const stateB = b.readState ?? '1';
|
|
|
+ return parseInt(stateA) - parseInt(stateB);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 标记消息为已读
|
|
|
+ markAsRead = async (item: MessageInfo) => {
|
|
|
+ if (item.readState === '1') return // 已经是已读状态
|
|
|
+ try {
|
|
|
+ await ProcessRequest.post('http://192.168.1.3:20010/api/v1/sys/message/confirmMessage', {
|
|
|
+ ids:[item.id]
|
|
|
+ } as RequestParamModel);
|
|
|
+ //this.loadStationMessage();
|
|
|
+ item.readState = '1'
|
|
|
+ this.messages = [...this.messages].sort((a, b) => {
|
|
|
+ const stateA = a.readState ?? '1';
|
|
|
+ const stateB = b.readState ?? '1';
|
|
|
+ return parseInt(stateA) - parseInt(stateB);
|
|
|
+ });
|
|
|
+ } catch (e) {
|
|
|
+ console.error('标记已读失败:', e)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ markAllAsRead = async () => {
|
|
|
+ try {
|
|
|
+ const messageIds = this.messages
|
|
|
+ .filter(item => item.readState === '0' && item.id)
|
|
|
+ .map(item => item.id);
|
|
|
+ if (messageIds.length === 0) return;
|
|
|
+ await ProcessRequest.post('http://192.168.1.3:20010/api/v1/sys/message/confirmMessage', {
|
|
|
+ ids:messageIds as string[]
|
|
|
+ } as RequestParamModel);
|
|
|
+ //this.loadStationMessage();
|
|
|
+ this.messages = this.messages.map(item => {
|
|
|
+ return {
|
|
|
+ readState: '1',
|
|
|
+ content: item.content,
|
|
|
+ created: item.created,
|
|
|
+ } as MessageInfo;
|
|
|
+ });
|
|
|
+ this.messages = this.messages.slice().sort((a, b) => {
|
|
|
+ const stateA = a.readState ?? '1';
|
|
|
+ const stateB = b.readState ?? '1';
|
|
|
+ return parseInt(stateA) - parseInt(stateB);
|
|
|
+ });
|
|
|
+ } catch (e) {
|
|
|
+ console.error('全部已读操作失败:', e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ aboutToAppear(): void {
|
|
|
+ this.loadStationMessage()
|
|
|
+ }
|
|
|
+
|
|
|
+ build() {
|
|
|
+ Column() {
|
|
|
+ Column() {
|
|
|
+ Text("工位信息")
|
|
|
+ .fontColor($r('app.color.FFFFFF'))
|
|
|
+ .fontSize($r('app.float.fontSize_38'))
|
|
|
+ }
|
|
|
+ .height('8%')
|
|
|
+ .width('100%')
|
|
|
+ .justifyContent(FlexAlign.Center)
|
|
|
+
|
|
|
+ Row(){
|
|
|
+ Column(){
|
|
|
+ Text("当前工位")
|
|
|
+ .fontColor($r('app.color.FFFFFF'))
|
|
|
+ .fontSize($r('app.float.fontSize_16'))
|
|
|
+ .margin({left:'2%',bottom:'2%'})
|
|
|
+ .width('60%')
|
|
|
+ .textAlign(TextAlign.Start)
|
|
|
+ Row(){
|
|
|
+ Text("1#装配工位")
|
|
|
+ .fontColor($r('app.color.FFFFFF'))
|
|
|
+ .fontSize($r('app.float.fontSize_24'))
|
|
|
+ .margin({left:'8%'})
|
|
|
+ .width('82%')
|
|
|
+ .textAlign(TextAlign.Start)
|
|
|
+ Text(">")
|
|
|
+ .fontColor($r('app.color.FFFFFF'))
|
|
|
+ .fontSize($r('app.float.fontSize_24'))
|
|
|
+ .textAlign(TextAlign.Start)
|
|
|
+ .width('10%')
|
|
|
+ }
|
|
|
+ .justifyContent(FlexAlign.Start)
|
|
|
+ .borderRadius($r('app.float.virtualSize_16'))
|
|
|
+ .width('60%')
|
|
|
+ .height('10%')
|
|
|
+ .backgroundColor($r('app.color.20FFFFFF'))
|
|
|
+ Text("当前用户")
|
|
|
+ .fontColor($r('app.color.FFFFFF'))
|
|
|
+ .fontSize($r('app.float.fontSize_16'))
|
|
|
+ .margin({left:'2%',bottom:'2%',top:'8%'})
|
|
|
+ .width('60%')
|
|
|
+ .textAlign(TextAlign.Start)
|
|
|
+ Row(){
|
|
|
+ Text("王德发")
|
|
|
+ .fontColor($r('app.color.FFFFFF'))
|
|
|
+ .fontSize($r('app.float.fontSize_24'))
|
|
|
+ .margin({left:'8%'})
|
|
|
+ .width('82%')
|
|
|
+ .textAlign(TextAlign.Start)
|
|
|
+ Text(">")
|
|
|
+ .fontColor($r('app.color.FFFFFF'))
|
|
|
+ .fontSize($r('app.float.fontSize_24'))
|
|
|
+ .textAlign(TextAlign.Start)
|
|
|
+ .width('10%')
|
|
|
+ }
|
|
|
+ .justifyContent(FlexAlign.Center)
|
|
|
+ .borderRadius($r('app.float.virtualSize_16'))
|
|
|
+ .width('60%')
|
|
|
+ .height('10%')
|
|
|
+ .backgroundColor($r('app.color.20FFFFFF'))
|
|
|
+ .margin({bottom:'20%'})
|
|
|
+ }
|
|
|
+ .justifyContent(FlexAlign.Center)
|
|
|
+ .alignItems(HorizontalAlign.Center)
|
|
|
+ .height('100%')
|
|
|
+ .width('46%')
|
|
|
+ Divider()
|
|
|
+ .vertical(true)
|
|
|
+ .strokeWidth(1)
|
|
|
+ .color($r('app.color.15FFFFFF'))
|
|
|
+ .margin({ bottom: '2%'})
|
|
|
+ Column(){
|
|
|
+ Row(){
|
|
|
+ Text('工位通知')
|
|
|
+ .fontColor($r('app.color.FFFFFF'))
|
|
|
+ .fontSize($r('app.float.fontSize_24'))
|
|
|
+ .textAlign(TextAlign.Start)
|
|
|
+ .width('80%')
|
|
|
+ Row(){
|
|
|
+ Text('全部已读')
|
|
|
+ .fontColor($r('app.color.FFFFFF'))
|
|
|
+ .fontSize($r('app.float.fontSize_16'))
|
|
|
+ }
|
|
|
+ .backgroundColor($r('app.color.20FFFFFF'))
|
|
|
+ .width('20%')
|
|
|
+ .height('80%')
|
|
|
+ .borderRadius($r('app.float.virtualSize_16'))
|
|
|
+ .justifyContent(FlexAlign.Center)
|
|
|
+ .scale({ x: this.allReadClick, y: this.allReadClick })
|
|
|
+ .animation({
|
|
|
+ duration: 200,
|
|
|
+ curve: Curve.Linear
|
|
|
+ })
|
|
|
+ .onClick(()=>{
|
|
|
+ this.allReadClick = 0.9;
|
|
|
+ setTimeout(() => {
|
|
|
+ this.allReadClick = 1;
|
|
|
+ this.markAllAsRead()
|
|
|
+ }, 200);
|
|
|
+ })
|
|
|
+ }
|
|
|
+ .width('100%')
|
|
|
+ .height('8%')
|
|
|
+ Column(){
|
|
|
+ List({scroller:this.scrollerList}) {
|
|
|
+ ForEach(this.messages, (item:MessageInfo) => {
|
|
|
+ ListItem() {
|
|
|
+ Row() {
|
|
|
+ Column(){
|
|
|
+ Text(item.content)
|
|
|
+ .fontSize($r('app.float.fontSize_16'))
|
|
|
+ .fontColor($r('app.color.FFFFFF'))
|
|
|
+ .width('85%')
|
|
|
+ .textAlign(TextAlign.Start)
|
|
|
+ Text(item.created)
|
|
|
+ .fontSize($r('app.float.fontSize_12'))
|
|
|
+ .fontColor($r('app.color.FFFFFF'))
|
|
|
+ .width('85%')
|
|
|
+ .textAlign(TextAlign.Start)
|
|
|
+ .margin({top:'1%'})
|
|
|
+ .fontWeight(FontWeight.Lighter)
|
|
|
+ }
|
|
|
+ Row(){
|
|
|
+ Text(item.readState=='1'?`已读`:'已读确认')
|
|
|
+ .fontSize($r('app.float.fontSize_16'))
|
|
|
+ .fontColor(item.readState=='1'?$r('app.color.FFFFFF'):$r('app.color.0A84FF'))
|
|
|
+ .width('15%')
|
|
|
+ .textAlign(TextAlign.End)
|
|
|
+ .onClick(() => this.markAsRead(item))
|
|
|
+ }
|
|
|
+ }.width('100%').justifyContent(FlexAlign.SpaceEvenly)
|
|
|
+ .padding(5)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ .width('100%')
|
|
|
+ .height('100%')
|
|
|
+ .divider({
|
|
|
+ strokeWidth: 1,
|
|
|
+ color: $r('app.color.20FFFFFF')
|
|
|
+ })
|
|
|
+ }
|
|
|
+ .height('90%')
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ .width('46%')
|
|
|
+ .height('100%')
|
|
|
+ }
|
|
|
+ .justifyContent(FlexAlign.SpaceEvenly)
|
|
|
+ .width('100%')
|
|
|
+ .height('81%')
|
|
|
+ .margin({ top: '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(() => {
|
|
|
+ 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'))
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|