流程控制
This commit is contained in:
parent
4239de74f8
commit
f374d4f529
@ -75,6 +75,17 @@ export async function getPadIndexInfoUsingGet(params: API.getPadIndexInfoUsingGE
|
||||
});
|
||||
}
|
||||
|
||||
/** 09、获取步骤列表 获取步骤列表,步骤监控中使用。 GET /car-inspection-rest/pad/getSteplist */
|
||||
export async function getStepListUsingGet(
|
||||
// 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
|
||||
params: API.getStepListUsingGETParams,
|
||||
) {
|
||||
return request<API.RListStepVo>('/car-inspection-rest/pad/getSteplist', {
|
||||
method: http.RequestMethod.GET,
|
||||
params
|
||||
});
|
||||
}
|
||||
|
||||
/** 01、上传图片接口【通用】 通用上传图片接口 POST /car-inspection-rest/device/uploadPhoto.do */
|
||||
export async function uploadPhotoUsingPost(body: API.UploadPhotoReq) {
|
||||
return request<API.RUploadPhotoRsp>('/car-inspection-rest/device/uploadPhoto.do', {
|
||||
|
||||
15
entry/src/main/ets/api/typings.d.ts
vendored
15
entry/src/main/ets/api/typings.d.ts
vendored
@ -92,6 +92,11 @@ declare namespace API {
|
||||
imei: string;
|
||||
};
|
||||
|
||||
type getStepListUsingGETParams = {
|
||||
/** lineId */
|
||||
lineId?: number;
|
||||
};
|
||||
|
||||
type ImageBase64Req = {
|
||||
/** Base64编码的图片 */
|
||||
imageBase64: string;
|
||||
@ -460,6 +465,12 @@ declare namespace API {
|
||||
msg?: string;
|
||||
};
|
||||
|
||||
type RListStepVo = {
|
||||
code?: number;
|
||||
data?: StepVo[];
|
||||
msg?: string;
|
||||
};
|
||||
|
||||
type RobotInspectionInfoReq = {
|
||||
/** 管理辖区 */
|
||||
administrativeJurisdiction?: string;
|
||||
@ -701,6 +712,8 @@ declare namespace API {
|
||||
stageName?: string;
|
||||
/** 步骤列表 */
|
||||
stepList?: StepVo[];
|
||||
/** pad业务额外字段 */
|
||||
count?: number
|
||||
};
|
||||
|
||||
type StepVo = {
|
||||
@ -709,6 +722,8 @@ declare namespace API {
|
||||
name?: string;
|
||||
orderNo?: number;
|
||||
stageId?: string;
|
||||
/** pad业务额外字段 */
|
||||
status?: string
|
||||
};
|
||||
|
||||
type UploadInspectReq = {
|
||||
|
||||
@ -3,7 +3,8 @@ zip:
|
||||
outName: date
|
||||
openApi:
|
||||
requestLibPath: import { request } from '../utils/Request'
|
||||
schemaPath: http://88.22.20.118:8080/car-inspection-rest/v3/api-docs
|
||||
# schemaPath: http://88.22.20.118:8080/car-inspection-rest/v3/api-docs
|
||||
schemaPath: https://testdevice.duolunxc.com/car-inspection-rest/v3/api-docs
|
||||
serversPath: ./test
|
||||
upload:
|
||||
serverType: linux
|
||||
|
||||
@ -23,9 +23,9 @@ class CusButtonModifier implements AttributeModifier<RowAttribute> {
|
||||
@Component
|
||||
export struct CusButton {
|
||||
@Prop text: string = ""
|
||||
@Prop style: ButtonStyle
|
||||
public normalImage?: Resource
|
||||
public activeImage?: Resource
|
||||
public style?: ButtonStyle
|
||||
private modifier: CusButtonModifier = new CusButtonModifier()
|
||||
|
||||
aboutToAppear(): void {
|
||||
|
||||
@ -3,7 +3,7 @@ import { Layout } from '../components/layout/Index'
|
||||
import { Title } from '../components/title/Index'
|
||||
import { CusMenuItem } from './components/MenuItem'
|
||||
import { RebootControl } from './utils/Control'
|
||||
import { router } from '@kit.ArkUI'
|
||||
import { promptAction, router } from '@kit.ArkUI'
|
||||
import { CommandCode, commandService } from '../../utils/CommandService'
|
||||
import Logger from '../../utils/Logger'
|
||||
|
||||
@ -27,9 +27,6 @@ function TouchEventWrapper(callback: Function) {
|
||||
|
||||
}
|
||||
|
||||
const button: string[][] =
|
||||
[["采集初始位置", "回到初始位置"], ["采集受理凭证位置", "回到受理凭证位置"], ["采集充电位置", "回到充电位置"]]
|
||||
|
||||
@Component
|
||||
@Entry
|
||||
struct Control {
|
||||
@ -63,11 +60,37 @@ struct Control {
|
||||
this.control.destroy()
|
||||
}
|
||||
|
||||
onCollectCommand() {
|
||||
onCollectCommand(type: number) {
|
||||
let command = [CommandCode.GetHomePosition, CommandCode.GetScanPosition, CommandCode.GetChargePosition]
|
||||
let name = ["采集初始位置", "采集扫码位置", "采集充电位置"]
|
||||
commandService.submitCommand(this.line[this.select].id!.toString(), command[type], name[type])
|
||||
.then(res => {
|
||||
promptAction.showToast({
|
||||
message: res.msg
|
||||
})
|
||||
})
|
||||
.catch((err: string) => {
|
||||
promptAction.showToast({
|
||||
message: err
|
||||
})
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
onMoveCommand() {
|
||||
onMoveCommand(type: number) {
|
||||
let command = [CommandCode.ToHomePosition, CommandCode.ToScanPosition, CommandCode.ToChargePosition,]
|
||||
let name = ["回到初始位置", "回到扫码位置", "回到充电位置"]
|
||||
commandService.submitCommand(this.line[this.select].id!.toString(), command[type], name[type])
|
||||
.then(res => {
|
||||
promptAction.showToast({
|
||||
message: res.msg
|
||||
})
|
||||
})
|
||||
.catch((err: string) => {
|
||||
promptAction.showToast({
|
||||
message: err
|
||||
})
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
@ -123,42 +146,42 @@ struct Control {
|
||||
text: "采集初始位置",
|
||||
style: { width: 160, height: 80, fontColor: 0x24F3FB }
|
||||
}).margin({ bottom: 24 }).onClick(() => {
|
||||
this.onCollectCommand()
|
||||
this.onCollectCommand(0)
|
||||
})
|
||||
CusButton({
|
||||
normalImage: $rawfile("images/control/button.png"),
|
||||
text: "回到初始位置",
|
||||
style: { width: 160, height: 80, fontColor: 0x24F3FB }
|
||||
}).margin({ bottom: 24 }).onClick(() => {
|
||||
this.onMoveCommand()
|
||||
this.onMoveCommand(0)
|
||||
})
|
||||
CusButton({
|
||||
normalImage: $rawfile("images/control/button.png"),
|
||||
text: "采集扫码位置",
|
||||
style: { width: 160, height: 80, fontColor: 0x24F3FB }
|
||||
}).margin({ bottom: 24 }).onClick(() => {
|
||||
this.onCollectCommand()
|
||||
this.onCollectCommand(1)
|
||||
})
|
||||
CusButton({
|
||||
normalImage: $rawfile("images/control/button.png"),
|
||||
text: "回到扫码位置",
|
||||
style: { width: 160, height: 80, fontColor: 0x24F3FB }
|
||||
}).margin({ bottom: 24 }).onClick(() => {
|
||||
this.onMoveCommand()
|
||||
this.onMoveCommand(1)
|
||||
})
|
||||
CusButton({
|
||||
normalImage: $rawfile("images/control/button.png"),
|
||||
text: "采集充电位置",
|
||||
style: { width: 160, height: 80, fontColor: 0x24F3FB }
|
||||
}).margin({ bottom: 24 }).onClick(() => {
|
||||
this.onCollectCommand()
|
||||
this.onCollectCommand(2)
|
||||
})
|
||||
CusButton({
|
||||
normalImage: $rawfile("images/control/button.png"),
|
||||
text: "回到充电位置",
|
||||
style: { width: 160, height: 80, fontColor: 0x24F3FB }
|
||||
}).margin({ bottom: 24 }).onClick(() => {
|
||||
this.onMoveCommand()
|
||||
this.onMoveCommand(2)
|
||||
})
|
||||
CusButton({
|
||||
normalImage: $rawfile("images/control/button.png"),
|
||||
@ -166,6 +189,16 @@ struct Control {
|
||||
style: { width: 160, height: 80, fontColor: 0x24F3FB }
|
||||
}).margin({ bottom: 24 }).onClick(() => {
|
||||
commandService.submitCommand(this.line[this.select].id!.toString(), CommandCode.Restart, "重新开始查验")
|
||||
.then(res => {
|
||||
promptAction.showToast({
|
||||
message: res.msg
|
||||
})
|
||||
})
|
||||
.catch((err: string) => {
|
||||
promptAction.showToast({
|
||||
message: err
|
||||
})
|
||||
})
|
||||
})
|
||||
CusButton({
|
||||
normalImage: $rawfile("images/control/button.png"),
|
||||
@ -173,6 +206,16 @@ struct Control {
|
||||
style: { width: 160, height: 80, fontColor: 0x24F3FB }
|
||||
}).margin({ bottom: 24 }).onClick(() => {
|
||||
commandService.submitCommand(this.line[this.select].id!.toString(), CommandCode.Reset, "重置机器人")
|
||||
.then(res => {
|
||||
promptAction.showToast({
|
||||
message: res.msg
|
||||
})
|
||||
})
|
||||
.catch((err: string) => {
|
||||
promptAction.showToast({
|
||||
message: err
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
.layoutWeight(1)
|
||||
|
||||
@ -153,7 +153,15 @@ struct Home {
|
||||
LineCard({
|
||||
label: item.lineName?.toString(),
|
||||
select: this.select === index,
|
||||
data: item
|
||||
data: item,
|
||||
onMonitor: () => {
|
||||
router.pushUrl({
|
||||
url: "pages/process/Index",
|
||||
params: {
|
||||
lineId: item.lineId
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}.width("100%").constraintSize({ minHeight: 100 }).onClick(() => {
|
||||
this.select = index
|
||||
@ -270,7 +278,7 @@ struct Home {
|
||||
|
||||
}.layoutWeight(1).width("100%")
|
||||
|
||||
Footer()
|
||||
Footer({ select: this.select, lineId: this.line[this.select]?.lineId })
|
||||
}.layoutWeight(1).width("100%").padding(24)
|
||||
}
|
||||
.width("100%")
|
||||
|
||||
@ -1,9 +1,14 @@
|
||||
import { CusButton } from '../../components/button/Index'
|
||||
import { router } from '@kit.ArkUI'
|
||||
|
||||
const Four_Button_Height = 58
|
||||
const Five_Button_Height = 46
|
||||
|
||||
@Component
|
||||
export struct Footer {
|
||||
@State mediaWidth: number = 0
|
||||
@Prop select: number
|
||||
@Prop lineId: number
|
||||
|
||||
@Builder
|
||||
buildMenu() {
|
||||
@ -19,6 +24,7 @@ export struct Footer {
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
//
|
||||
// MenuItem() {
|
||||
// CusButton({
|
||||
@ -60,11 +66,27 @@ export struct Footer {
|
||||
Text("版本:1.0.0").fontSize(12).fontColor(0xffffff)
|
||||
}.layoutWeight(1.2).margin({ right: 8 }).alignItems(HorizontalAlign.Start)
|
||||
|
||||
// if (this.select > -1) {
|
||||
// CusButton({
|
||||
// // normalImage: $rawfile("images/home/vehicle.png"),
|
||||
// // activeImage: $rawfile("images/home/vehicle_active.png"),
|
||||
// text: "流程控制",
|
||||
// style: { height: this.select > -1 ? Five_Button_Height : Four_Button_Height }
|
||||
// }).layoutWeight(1).margin({ left: 4, right: 4 }).onClick(() => {
|
||||
// router.pushUrl({
|
||||
// url: "pages/process/Index",
|
||||
// params: {
|
||||
// lineId: this.lineId
|
||||
// }
|
||||
// })
|
||||
// })
|
||||
// }
|
||||
|
||||
|
||||
CusButton({
|
||||
normalImage: $rawfile("images/home/vehicle.png"),
|
||||
activeImage: $rawfile("images/home/vehicle_active.png"),
|
||||
style: { height: 58 }
|
||||
style: { height: this.select > -1 ? Five_Button_Height : Four_Button_Height }
|
||||
}).layoutWeight(1).margin({ left: 4, right: 4 }).onClick(() => {
|
||||
router.pushUrl({
|
||||
url: "pages/vehicle/Index"
|
||||
@ -74,7 +96,7 @@ export struct Footer {
|
||||
CusButton({
|
||||
normalImage: $rawfile("images/home/robot.png"),
|
||||
activeImage: $rawfile("images/home/robot_active.png"),
|
||||
style: { height: 58 }
|
||||
style: { height: this.select > -1 ? Five_Button_Height : Four_Button_Height }
|
||||
}).layoutWeight(1).margin({ left: 4, right: 4 }).onClick(() => {
|
||||
router.pushUrl({
|
||||
url: "pages/control/Index"
|
||||
@ -84,7 +106,7 @@ export struct Footer {
|
||||
CusButton({
|
||||
normalImage: $rawfile("images/home/result.png"),
|
||||
activeImage: $rawfile("images/home/result_active.png"),
|
||||
style: { height: 58 }
|
||||
style: { height: this.select > -1 ? Five_Button_Height : Four_Button_Height }
|
||||
}).layoutWeight(1).margin({ left: 4, right: 4 }).onClick(() => {
|
||||
router.pushUrl({
|
||||
url: "pages/result/Index"
|
||||
@ -94,7 +116,7 @@ export struct Footer {
|
||||
CusButton({
|
||||
normalImage: $rawfile("images/home/setting.png"),
|
||||
activeImage: $rawfile("images/home/setting_active.png"),
|
||||
style: { height: 58 }
|
||||
style: { height: this.select > -1 ? Five_Button_Height : Four_Button_Height }
|
||||
}).layoutWeight(1).margin({ left: 8 }).bindMenu(this.buildMenu, {
|
||||
borderRadius: 3,
|
||||
}).onSizeChange((_, area) => {
|
||||
|
||||
149
entry/src/main/ets/pages/process/Index.ets
Normal file
149
entry/src/main/ets/pages/process/Index.ets
Normal file
@ -0,0 +1,149 @@
|
||||
import { CusButton } from '../components/button/Index'
|
||||
import { Layout } from '../components/layout/Index'
|
||||
import { Title } from '../components/title/Index'
|
||||
import { promptAction, router } from '@kit.ArkUI'
|
||||
import { getStepListUsingGet } from '../../api/padController'
|
||||
import { CusMenuItem } from './components/MenuItem'
|
||||
import { CommandCode, commandService } from '../../utils/CommandService'
|
||||
import Logger from '../../utils/Logger'
|
||||
|
||||
interface RouterParams {
|
||||
lineId: number
|
||||
}
|
||||
|
||||
@Component
|
||||
@Entry
|
||||
struct Process {
|
||||
@State process: API.StepVo[] = []
|
||||
@State select: number = -1
|
||||
@State currentStep: number = 6
|
||||
private lineId: number = -1
|
||||
|
||||
aboutToAppear(): void {
|
||||
const params = router.getParams() as RouterParams;
|
||||
this.lineId = params.lineId
|
||||
getStepListUsingGet({ lineId: this.lineId }).then(res => {
|
||||
this.process = res.data || []
|
||||
})
|
||||
// getStageAndStepInfoUsingGet().then(res => {
|
||||
// let len = 0
|
||||
// this.process = (res.data || []).map((item) => {
|
||||
// let result: API.StageAndStepRsp = {
|
||||
// stageCode: item.stageCode,
|
||||
// stageId: item.stageId,
|
||||
// stageName: item.stageName,
|
||||
// stepList: item.stepList?.map((sub, index) => {
|
||||
// return {
|
||||
// code: sub.code,
|
||||
// id: sub.id,
|
||||
// name: sub.name,
|
||||
// orderNo: sub.orderNo,
|
||||
// stageId: sub.stageId,
|
||||
// index: len + index + 1
|
||||
// } as API.StepVo
|
||||
// }),
|
||||
// count: len
|
||||
// }
|
||||
// len += item.stepList?.length || 0
|
||||
// return result
|
||||
// })
|
||||
// if (this.process.length > 0) {
|
||||
// this.select = this.process[0].stepList?.[0]?.id || -1
|
||||
// }
|
||||
// })
|
||||
}
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
Layout({ mode: 2 }) {
|
||||
Column() {
|
||||
Row() {
|
||||
Title({ title: "流程控制" })
|
||||
CusButton({ normalImage: $rawfile("images/back.png"), style: { width: 120, height: 50 } })
|
||||
.margin({ left: 24 }).onClick(() => {
|
||||
router.back()
|
||||
})
|
||||
}.margin({ bottom: 18 })
|
||||
|
||||
|
||||
Row() {
|
||||
Column() {
|
||||
Row() {
|
||||
Text("查验流程").fontFamily("Alimama").fontColor(0xffffff).fontSize(24)
|
||||
}
|
||||
.backgroundImage($rawfile("images/control/header.png"))
|
||||
.backgroundImageSize({ width: "100%", height: "100%" })
|
||||
.width("100%")
|
||||
.height(48)
|
||||
.padding({ left: 48 })
|
||||
.margin({ bottom: 24 })
|
||||
|
||||
Scroll() {
|
||||
Column() {
|
||||
ForEach(this.process, (step: API.StepVo, index: number) => {
|
||||
CusMenuItem({
|
||||
step: step,
|
||||
index: index + 1,
|
||||
// onSelect: (id) => {
|
||||
// this.select = id
|
||||
// }
|
||||
})
|
||||
})
|
||||
}.width("100%").padding({ left: 24, right: 24 })
|
||||
}.width("100%").layoutWeight(1).align(Alignment.Top)
|
||||
}
|
||||
.width("25%")
|
||||
.height("100%")
|
||||
.margin({ right: 24 })
|
||||
.backgroundColor(0xf4f4f5)
|
||||
.border({ width: 1, color: 0xf1f1f1 })
|
||||
.borderRadius(5)
|
||||
|
||||
Column() {
|
||||
CusButton({
|
||||
normalImage: $rawfile("images/control/button.png"),
|
||||
text: "跳过当前步骤",
|
||||
style: { width: 160, height: 80, fontColor: 0x24F3FB }
|
||||
}).margin({ bottom: 24 }).onClick(() => {
|
||||
commandService.submitCommand(this.lineId.toString(), CommandCode.SkipStep, "跳过当前步骤").then(res => {
|
||||
promptAction.showToast({
|
||||
message: res.msg
|
||||
})
|
||||
Logger.info("指令执行结果", res)
|
||||
}).catch((err: string) => {
|
||||
promptAction.showToast({
|
||||
message: err
|
||||
})
|
||||
Logger.error("指令执行结果", err)
|
||||
})
|
||||
// this.onMoveCommand()
|
||||
})
|
||||
CusButton({
|
||||
normalImage: $rawfile("images/control/button.png"),
|
||||
text: "重做当前步骤",
|
||||
style: { width: 160, height: 80, fontColor: 0x24F3FB }
|
||||
}).margin({ bottom: 24 }).onClick(() => {
|
||||
commandService.submitCommand(this.lineId.toString(), CommandCode.redoStep, "重做当前步骤").then(res => {
|
||||
promptAction.showToast({
|
||||
message: res.msg
|
||||
})
|
||||
Logger.info("指令执行结果", res)
|
||||
}).catch((err: string) => {
|
||||
promptAction.showToast({
|
||||
message: err
|
||||
})
|
||||
Logger.error("指令执行结果", err)
|
||||
})
|
||||
// this.onMoveCommand()
|
||||
})
|
||||
// CusButton({ text: "跳过当前步骤" })
|
||||
// CusButton({ text: "重做当前步骤" })
|
||||
}.layoutWeight(1).height("100%").justifyContent(FlexAlign.Center)
|
||||
|
||||
}.width("100%").layoutWeight(1).padding({ left: 12, right: 12 }).alignItems(VerticalAlign.Center)
|
||||
|
||||
}.width("100%").height("100%").padding(18)
|
||||
}
|
||||
}.width("100%").height("100%")
|
||||
}
|
||||
}
|
||||
133
entry/src/main/ets/pages/process/components/MenuItem.ets
Normal file
133
entry/src/main/ets/pages/process/components/MenuItem.ets
Normal file
@ -0,0 +1,133 @@
|
||||
@Component
|
||||
export struct CusMenuItem {
|
||||
@State active: boolean = false
|
||||
// @Prop menu: API.StageAndStepRsp
|
||||
@Prop step: API.StepVo
|
||||
@Prop index: number
|
||||
// @Prop @Watch("setupActive") select: number = -1
|
||||
// @Prop @Watch("setupStatus") currentStep: number
|
||||
onSelect?: (id: number) => void
|
||||
|
||||
aboutToAppear(): void {
|
||||
// this.setupStatus()
|
||||
// this.setupActive()
|
||||
}
|
||||
|
||||
// setupStatus() {
|
||||
// for (let i = 0; i < this.menu.stepList?.length!; i++) {
|
||||
// if (this.currentStep > this.menu.count! + i + 1) {
|
||||
// this.menu.stepList![i].status = 3
|
||||
// } else if (this.currentStep === this.menu.count! + i + 1) {
|
||||
// this.menu.stepList![i].status = 2
|
||||
// } else {
|
||||
// this.menu.stepList![i].status = 1
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// setupActive() {
|
||||
// this.active = this.menu.stepList!.some(item => item.id === this.select)
|
||||
// }
|
||||
|
||||
getTextColor(type: number, item?: API.StepVo) {
|
||||
// let labelColor = [0x000000, 0xffffff, 0x1D2B80]
|
||||
let itemColor = [0x989898, 0xffffff, 0x1D2B80]
|
||||
// if (type === 1) {
|
||||
// if (this.currentStep > this.menu.count! + this.menu.stepList!.length) {
|
||||
// return this.active ? labelColor[1] : labelColor[2]
|
||||
// } else {
|
||||
// return this.active ? labelColor[1] : labelColor[0]
|
||||
// }
|
||||
// } else {
|
||||
// if (this.currentStep > item?.index!) {
|
||||
// return this.select === item?.id ? itemColor[1] : itemColor[2]
|
||||
// } else {
|
||||
// return this.select === item?.id ? itemColor[1] : itemColor[0]
|
||||
// }
|
||||
if (this.step.status === "0") {
|
||||
return itemColor[0]
|
||||
// return this.select === item?.id ? itemColor[1] : itemColor[2]
|
||||
} else if (this.step.status === "1") {
|
||||
return itemColor[2]
|
||||
// return this.select === item?.id ? itemColor[1] : itemColor[0]
|
||||
} else {
|
||||
return itemColor[1]
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
getBackgroundColor(type: number, item?: API.StepVo): number | [ResourceColor, number][] {
|
||||
// let labelColor: Array<number | Array<[ResourceColor, number]>> =
|
||||
// [[[0xffffff, 0.0], [0xffffff, 1.0]], [[0x2684FF, 0.0], [0X0747A6, 1.0]], [[0xdcdde7, 0.0], [0xdcdde7, 1.0]]]
|
||||
let itemColor = [Color.Transparent, 0xf6b509, Color.Transparent]
|
||||
// if (type === 1) {
|
||||
// if (this.currentStep > this.menu.count! + this.menu.stepList!.length) {
|
||||
// return this.active ? labelColor[1] : labelColor[2]
|
||||
// } else {
|
||||
// return this.active ? labelColor[1] : labelColor[0]
|
||||
// }
|
||||
// } else {
|
||||
if (this.step.status === "0") {
|
||||
return itemColor[0]
|
||||
// return this.select === item?.id ? itemColor[1] : itemColor[2]
|
||||
} else if (this.step.status === "1") {
|
||||
return itemColor[2]
|
||||
// return this.select === item?.id ? itemColor[1] : itemColor[0]
|
||||
} else {
|
||||
return itemColor[1]
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
// getBorderColor() {
|
||||
// let labelColor = [0xD2D2D2, Color.Transparent, 0x1D2B80]
|
||||
// if (this.currentStep > this.menu.count! + this.menu.stepList!.length) {
|
||||
// return this.active ? labelColor[1] : labelColor[2]
|
||||
// } else {
|
||||
// return this.active ? labelColor[1] : labelColor[0]
|
||||
// }
|
||||
// }
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
// Row() {
|
||||
// Text(this.menu.stageName).fontColor(this.getTextColor(1)).fontSize(20)
|
||||
// }
|
||||
// .border({ width: 1, color: this.getBorderColor(), radius: 15 })
|
||||
// .linearGradient({
|
||||
// direction: GradientDirection.Bottom,
|
||||
// colors: this.getBackgroundColor(1) as [ResourceColor, number][]
|
||||
// })
|
||||
// .padding({
|
||||
// left: 16,
|
||||
// top: 12,
|
||||
// right: 16,
|
||||
// bottom: 12
|
||||
// })
|
||||
// .width("100%")
|
||||
// .margin({ bottom: 18 })
|
||||
|
||||
// ForEach(this.menu.stepList, (item: API.StepVo, index: number) => {
|
||||
Text(`${this.index}.${this.step.name}`)
|
||||
.fontColor(this.getTextColor(2))
|
||||
.backgroundColor(this.getBackgroundColor(2) as number)
|
||||
.fontSize(16)
|
||||
.padding({
|
||||
left: 16,
|
||||
top: 12,
|
||||
right: 16,
|
||||
bottom: 12
|
||||
})
|
||||
.margin({
|
||||
bottom: 18
|
||||
})
|
||||
.borderRadius(15)
|
||||
.width("100%")
|
||||
.onClick(() => {
|
||||
// this.onSelect?.(item.id!)
|
||||
})
|
||||
// })
|
||||
}.width("100%")
|
||||
|
||||
}
|
||||
}
|
||||
@ -29,7 +29,8 @@ interface ResponseMessage {
|
||||
|
||||
enum CommandType {
|
||||
HandleAlarm = "handleAlarm",
|
||||
PostCmd = "postCmd"
|
||||
PostCmd = "postCmd",
|
||||
PostCmdRsp = "postCmdRsp"
|
||||
}
|
||||
|
||||
export enum CommandCode {
|
||||
@ -40,7 +41,10 @@ export enum CommandCode {
|
||||
GetScanPosition = 'getScanPosition',
|
||||
ToScanPosition = 'toScanPosition',
|
||||
Restart = "restart",
|
||||
Reset = "reset"
|
||||
Reset = "reset",
|
||||
|
||||
SkipStep = "skipStep",
|
||||
redoStep = "redoSkip"
|
||||
}
|
||||
|
||||
export class CommandService {
|
||||
@ -53,7 +57,9 @@ export class CommandService {
|
||||
|
||||
constructor(url: string) {
|
||||
if (!CommandService.instance) {
|
||||
this.service = new WebsocketClient(url, this.deal)
|
||||
this.service = new WebsocketClient(url, (message: string) => {
|
||||
this.deal(message)
|
||||
})
|
||||
CommandService.instance = this
|
||||
}
|
||||
return CommandService.instance
|
||||
@ -66,8 +72,9 @@ export class CommandService {
|
||||
} else {
|
||||
try {
|
||||
let response: Message<ResponseMessage> = JSON.parse(message)
|
||||
if (response.type === CommandType.PostCmd) {
|
||||
this.commandCallback.get(response.reqCode)?.(response.body)
|
||||
if (response.type === CommandType.PostCmdRsp) {
|
||||
let cb = this.commandCallback.get(response.reqCode)
|
||||
cb?.(response.body, response.body.code !== "200" ? response.body.msg : "")
|
||||
this.commandCallback.delete(response.reqCode)
|
||||
}
|
||||
return message
|
||||
@ -82,7 +89,10 @@ export class CommandService {
|
||||
return new Promise<void | ResponseMessage>((resolve, reject) => {
|
||||
this.taskPool.add({
|
||||
execute: () => {
|
||||
return this.service!.send(JSON.stringify(message))
|
||||
|
||||
if (message.type === CommandType.PostCmd) {
|
||||
|
||||
return new Promise<boolean>((_resolve, _reject) => {
|
||||
this.service!.send(JSON.stringify(message)).then(() => {
|
||||
this.commandCallback.set(message.reqCode, (res: ResponseMessage) => resolve(res))
|
||||
@ -97,10 +107,20 @@ export class CommandService {
|
||||
return this.service!.reconnect();
|
||||
},
|
||||
success: () => {
|
||||
if (message.type === CommandType.PostCmd) {
|
||||
this.commandCallback.set(message.reqCode, (res: ResponseMessage, err: string) => {
|
||||
if (err) {
|
||||
reject(err)
|
||||
} else {
|
||||
resolve(res)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
resolve()
|
||||
}
|
||||
},
|
||||
error: () => {
|
||||
reject()
|
||||
reject("发送消息失败")
|
||||
},
|
||||
retryCount: 5
|
||||
})
|
||||
|
||||
@ -134,19 +134,19 @@ export default class Logger {
|
||||
}
|
||||
}
|
||||
|
||||
static info(...message: Object[]) {
|
||||
static info(...message: ESObject[]) {
|
||||
Logger.print(LoggerLevel.Info, ...message)
|
||||
}
|
||||
|
||||
static warn(...message: Object[]) {
|
||||
static warn(...message: ESObject[]) {
|
||||
Logger.print(LoggerLevel.Warn, ...message)
|
||||
}
|
||||
|
||||
static error(...message: Object[]) {
|
||||
static error(...message: ESObject[]) {
|
||||
Logger.print(LoggerLevel.Error, ...message)
|
||||
}
|
||||
|
||||
static debug(...message: Object[]) {
|
||||
static debug(...message: ESObject[]) {
|
||||
Logger.print(LoggerLevel.Debug, ...message)
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,6 +12,7 @@
|
||||
"pages/result/Detail",
|
||||
"pages/setting/Index",
|
||||
"pages/filing/Index",
|
||||
"pages/vehicle/Add"
|
||||
"pages/vehicle/Add",
|
||||
"pages/process/Index"
|
||||
]
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user