// import router from '@ohos.router' // import CommonConstants from '../common/constants/CommonConstants' // import JGRequest from '../common/util/request/Request' // import { getToken, getUserInfo } from '../common/util/request/RequestInstance' // import AssistantSetModel from '../model/database/AssistantSetModel' // import UserAuthModel from '../model/database/UserAuthModel'; // import UserInfo from '../model/UserInfo' // import process from '@ohos.process' // import RequestParamModel from '../viewmodel/RequestParamModel' // // export const stationDictValue: string = '' // // @Entry // @Component // struct LoginPage { // controller: TextInputController = new TextInputController() // //1是拣选,2是装配,3是测试,4是维修站,5是入库,6是出库 // @State stationDictValue: string = '' // @State loginName: string = 'admin' // @State password: string = '123456' // @State dept: DeptInfo = { deptName: '仿真中心' } // @State workstation: WorkstationInfo = {} // @State productionLine: ProductionLine = { name: '仿真中心电装产线' } // @State deptArray: DeptInfo[] = [] // @State lineArray: ProductionLine[] = [] // @State workstationArray: WorkstationInfo[] = [{ name: '入库工位', stationDictValue: "5" }, // { name: '预齐套工位', stationDictValue: "6" }, // { name: '装配工位', stationDictValue: "3" }] // // 部门选择弹框 // selectDeptController: CustomDialogController = new CustomDialogController({ // builder: SelectDeptDialog({ // dept: this.dept, // deptArray: this.deptArray // }), // autoCancel: true, // alignment: DialogAlignment.Center, // // gridCount: 3, // customStyle: true, // }) // // 产线选择弹框 // selectProductionLineController: CustomDialogController = new CustomDialogController({ // builder: ProductionLineDialog({ // productionLine: this.productionLine, // workstationArray: this.workstationArray, // workstation: this.workstation, // lineArray: this.lineArray, // }), // autoCancel: true, // alignment: DialogAlignment.Center, // // gridCount: 3, // customStyle: true, // }) // // 工位选择弹框 // selectWorkstationController: CustomDialogController = new CustomDialogController({ // builder: SelectWorkstationDialog({ // stationDictValue: this.stationDictValue, // workstation: this.workstation, // workstationArray: this.workstationArray, // lineCode: this.productionLine.code, // }), // autoCancel: true, // alignment: DialogAlignment.Center, // // gridCount: 3, // customStyle: true, // }) // // async aboutToAppear() { // this.controller.stopEditing() // let userInfo = await UserAuthModel.getLast() // //登录时,查询部门、 // // this.deptArray = await JGRequest.get("/api/v1/sys/dept/orgList", {}) as DeptInfo[] // if (this.deptArray && this.deptArray.length > 0) { // this.dept = this.deptArray[0] // } // //查询产线 // this.lineArray = await JGRequest.post("/api/v1/base/productionLine/list/list", { // } as RequestParamModel) as ProductionLine[] // if (this.lineArray && this.lineArray.length > 0) { // this.productionLine = this.lineArray[0] // // 根据产线查询工位 // this.workstationArray = await JGRequest.get("/api/v1/base/station/getStationList/" + this.productionLine.code + "/1", { // }) as WorkstationInfo[] // if (this.workstationArray && this.workstationArray.length > 0) { // this.workstation = this.workstationArray[0] // CommonConstants.stationDictValue = this.workstationArray[0].stationDictValue! // } // } // // if (userInfo) { // this.loginName = userInfo.userName ? userInfo.userName : '' // this.password = userInfo.password ? userInfo.password : '' // if (!userInfo.isLogin) { // return // } // } // // if (userInfo && userInfo.maintainLoginStatus === 1) { // CommonConstants.STATION_NANE = userInfo.stationName! // CommonConstants.STATION_ID = userInfo.stationId! // await getToken(userInfo.userName as string, userInfo.password as string, userInfo.orgId as number, userInfo?.stationId!.toString()) // .then(token => { // if (token && token.length > 0) { // CommonConstants.AUTH_TOKEN = token // } // }) // let user = await getUserInfo() as UserInfo // if (null != user) { // CommonConstants.USER_ID = user.id! // CommonConstants.USER_NAME = user.userName! // CommonConstants.USER_AVATAR = user.avatar! // CommonConstants.USER_AVATAR = user.avatar! // CommonConstants.LOGIN_OUT = false // CommonConstants.STATION_CODE = user.stationCode! // CommonConstants.STATION_IP = user.stationIp! // } // if (CommonConstants.AUTH_TOKEN && CommonConstants.AUTH_TOKEN.length > 0) { // if (CommonConstants.stationDictValue === '5') { // router.pushUrl({ // url: 'pages/Menu', // params: { // userName: CommonConstants.USER_NAME as UserInfo, // avatar: CommonConstants.USER_AVATAR as UserInfo, // stationId: CommonConstants.STATION_NANE as WorkstationInfo // } // }) // } else if (CommonConstants.stationDictValue === '6') { // router.pushUrl({ // url: 'pages/Menu', // params: { // userName: CommonConstants.USER_NAME as UserInfo, // avatar: CommonConstants.USER_AVATAR as UserInfo, // stationId: CommonConstants.STATION_NANE as WorkstationInfo // } // }) // } // // } // } // } // // build() { // Column() { // Column() { // Row() { // // Image($r('app.media.hjzx')) // // .width(px2vp(610)) // // .height(px2vp(40)) // } // .height('18.3%') // .width('88.5%') // .alignItems(VerticalAlign.Center) // .justifyContent(FlexAlign.Start) // // TextInput({ placeholder: '账号', text: this.loginName, controller: this.controller }) // //.placeholderColor($r('app.color.0A84FF')) // //.placeholderFont({ size: $r('app.float.set_card_font_size'), weight: FontWeight.Medium }) // .fontColor($r('app.color.000000')) // .fontWeight(FontWeight.Medium) // .fontSize($r('app.float.fontSize_28')) // .width('90.4%') // .enableKeyboardOnFocus(false) // .height('10.6%') // //.opacity($r('app.float.general_font_opacity')) // .borderRadius($r('app.float.virtualSize_6_4')) // .backgroundColor('#BCC2C9') // .onChange((value: string) => { // this.loginName = value // }) // Row() { // }.height('4%') // // TextInput({ placeholder: '密码', text: this.password }) // // .placeholderColor($r('app.color.login_text_input_placeholder_color')) // //.placeholderFont({ size: $r('app.float.set_card_font_size'), weight: FontWeight.Medium }) // .fontColor($r('app.color.000000')) // .width('90.4%') // .height('10.6%') // .enableKeyboardOnFocus(false) // .fontWeight(FontWeight.Medium) // .fontSize($r('app.float.fontSize_28')) // .type(InputType.Password) // .borderRadius($r('app.float.virtualSize_6_4')) // .backgroundColor('#BCC2C9') // .onChange((value: string) => { // this.password = value // }) // // Row() { // }.height('2.65%') // // // 部门、产线选择 // Row() { // Row() { // Text('部门') // .fontColor($r('app.color.FFFFFF')) // .fontSize($r('app.float.fontSize_19_2')) // } // .width('47.8%') // .height('100%') // .alignItems(VerticalAlign.Top) // // Blank() // Row() { // Text('产线') // .fontColor($r('app.color.FFFFFF')) // .fontSize($r('app.float.fontSize_19_2')) // } // .alignItems(VerticalAlign.Top) // .width('47.8%') // .height('100%') // } // .height('4.5%') // .width('90.4%') // // // 部门选择 // Row() { // Row() { // Text(this.dept ? this.dept.deptName : '') // .fontWeight(FontWeight.Medium) // .fontSize($r('app.float.fontSize_28')) // .fontColor($r('app.color.000000')) // //.opacity($r('app.float.general_font_opacity')) // Blank() // Row() { // Image($r('app.media.subscript_space')) // .height($r('app.float.virtualSize_16_8')) // .width($r('app.float.virtualSize_16_8')) // } // .alignItems(VerticalAlign.Bottom) // .justifyContent(FlexAlign.End) // .width('20%') // .height('100%') // } // .width('47.8%') // .height('100%') // .padding({ left: 10 }) // .backgroundColor($r('app.color.FFFFFF')) // .borderRadius($r('app.float.virtualSize_6_4')) // .onClick(async () => { // this.deptArray = await JGRequest.get("/api/v1/sys/dept/orgList", {}) as DeptInfo[] // if (this.deptArray && this.deptArray.length > 0) { // this.dept = this.deptArray[0] // } // // 查询工位 // this.workstationArray = await JGRequest.get("/api/v1/base/station/queryStationList", { // }) as WorkstationInfo[] // if (this.workstationArray && this.workstationArray.length > 0) { // this.workstation = this.workstationArray[0] // CommonConstants.stationDictValue = this.workstationArray[0].stationDictValue! // // } // this.selectDeptController.open() // }) // // Blank() // // // 产线选择 // Row() { // Text(this.productionLine ? this.productionLine.name : '') // .fontWeight(FontWeight.Medium) // .fontSize($r('app.float.fontSize_28')) // .fontColor($r('app.color.000000')) // //.opacity($r('app.float.general_font_opacity')) // Blank() // Row() { // Image($r('app.media.subscript_space')) // .height($r('app.float.virtualSize_16_8')) // .width($r('app.float.virtualSize_16_8')) // } // .alignItems(VerticalAlign.Bottom) // .justifyContent(FlexAlign.End) // .width('20%') // .height('100%') // } // .width('47.8%') // .height('100%') // .padding({ left: 10 }) // .backgroundColor($r('app.color.FFFFFF')) // .borderRadius($r('app.float.virtualSize_6_4')) // .onClick(async () => { // this.deptArray = await JGRequest.get("/api/v1/sys/dept/orgList", {}) as DeptInfo[] // if (this.deptArray && this.deptArray.length > 0) { // this.dept = this.deptArray[0] // } // // 查询工位 // this.workstationArray = await JGRequest.get("/api/v1/base/station/queryStationList", { // }) as WorkstationInfo[] // if (this.workstationArray && this.workstationArray.length > 0) { // this.workstation = this.workstationArray[0] // CommonConstants.stationDictValue = this.workstationArray[0].stationDictValue! // // } // this.selectProductionLineController.open() // }) // } // .width('90.4%') // .height('10.6%') // // Row() { // }.height('2.65%') // // if (JSON.stringify(this.productionLine) === '{}') { // Row() { // }.height('15.1%') // } else { // // 工位选择 // Row() { // Text('工位选择') // .fontColor($r('app.color.FFFFFF')) // .fontSize($r('app.float.fontSize_19_2')) // } // .height('4.5%') // .width('90.4%') // .justifyContent(FlexAlign.Start) // .alignItems(VerticalAlign.Top) // // Row() { // Text(!this.workstationArray || this.workstationArray.length <= 0 ? '无数据' : (this.workstation ? this.workstation.name : '')) // .fontWeight(FontWeight.Medium) // .fontSize($r('app.float.fontSize_28')) // .fontColor($r('app.color.000000')) // //.opacity(!this.workstationArray || this.workstationArray.length <= 0 ? $r('app.float.zero_point_two_font_opacity') : $r('app.float.general_font_opacity')) // Blank() // Row() { // Image($r('app.media.subscript_space')) // .height($r('app.float.virtualSize_16_8')) // .width($r('app.float.virtualSize_16_8')) // } // .alignItems(VerticalAlign.Bottom) // .justifyContent(FlexAlign.End) // .width('20%') // .height('100%') // } // .width('90.4%') // .height('10.6%') // .backgroundColor($r('app.color.FFFFFF')) // .borderRadius($r('app.float.virtualSize_6_4')) // .padding({ left: 10 }) // .onClick(() => { // if (!this.workstationArray || this.workstationArray.length <= 0) { // return // } // this.selectWorkstationController.open() // }) // } // // Column() { // Row().height('35%') // Text('登录') // .fontWeight(FontWeight.Medium) // .fontSize($r('app.float.fontSize_28')) // .fontColor($r('app.color.FFFFFF')) // .textAlign(TextAlign.Center) // .width(px2vp(608)) // .height(px2vp(80)) // .backgroundColor($r('app.color.0A59F7')) // .borderRadius($r('app.float.virtualSize_23')) // //.opacity(this.loginName && this.loginName.length > 0 && this.password && this.password.length > 0 && JSON.stringify(this.dept) != '{}' && JSON.stringify(this.workstation) != '{}' ? 1 : $r('app.float.card_font_default_opacity')) // } // .width('90.4%') // .layoutWeight(1) // .alignItems(HorizontalAlign.Center) // .justifyContent(FlexAlign.Start) // .onClick(async () => { // // console.log("tesTag1" + '+++++++++++++++' + this.workstation.stationDictValue) // if (this.loginName && this.loginName.length > 0 && this.password && this.password.length > 0) { // await getToken(this.loginName, this.password, this.dept?.id ? this.dept.id : 0, this.workstation?.id ? this.workstation.id : '0') // .then(token => { // if (token && token.length > 0) { // CommonConstants.AUTH_TOKEN = token // } // }) // if (CommonConstants.AUTH_TOKEN.length <= 0) { // return // } // let userInfo = await getUserInfo() as UserInfo // CommonConstants.USER_ID = userInfo.id! // CommonConstants.USER_NAME = userInfo.userName! // CommonConstants.USER_AVATAR = userInfo.avatar! // CommonConstants.STATION_CODE = userInfo.stationCode! // CommonConstants.STATION_IP = userInfo.stationIp! // CommonConstants.STATION_NANE = this.workstation && this.workstation.name ? this.workstation.name : '' // CommonConstants.STATION_ID = this.workstation && this.workstation.id ? Number.parseInt(this.workstation.id) : 0 // let user = await UserAuthModel.getByUserId(userInfo.id ? userInfo.id : 0) // if (!user || !user.id) { // // 将后端数据库id作为userId, 默认是保持登录 // user = { // userId: userInfo.id, // userName: this.loginName, // password: this.password, // orgId: this.dept ? this.dept.id : 0, // stationId: this.workstation ? Number.parseInt(this.workstation.id!) : 0, // stationName: this.workstation && this.workstation.name ? this.workstation.name : '', // stationDictValue: this.workstation?.stationDictValue ? this.workstation.stationDictValue! : '', // avatar: userInfo.avatar, // maintainLoginStatus: 1, // updateTime: new Date().getTime(), // isLogin: true, // } // let res = await UserAuthModel.addUser(user) // res = await AssistantSetModel.addAssistantSet({ // userId: userInfo.id, // voiceWakeUp: 1, // timbre: 2, // wakeFree: 2, // promptBroadcast: 1, // voiceVolume: 0, // // }) // } // CommonConstants.LOGIN_OUT = false // // if (this.workstation.stationDictValue === '5') { // router.pushUrl({ // url: 'pages/Menu', // params: { // userName: CommonConstants.USER_NAME as UserInfo, // avatar: CommonConstants.USER_AVATAR as UserInfo, // stationId: CommonConstants.STATION_NANE as WorkstationInfo // } // }) // } else if (this.workstation.stationDictValue === '6') { // router.pushUrl({ // url: 'pages/Menu', // params: { // userName: CommonConstants.USER_NAME as UserInfo, // avatar: CommonConstants.USER_AVATAR as UserInfo, // stationId: CommonConstants.STATION_NANE as WorkstationInfo // } // }) // } // // } // }) // } // .width('35%') // .height('70%') // .backgroundColor($r('app.color.A0A8B2')) // .borderRadius($r('app.float.virtualSize_6_4')) // .margin({ right: '8.25%' }) // // Row() { // Image($r('app.media.shutdown')) // .width($r('app.float.virtualSize_36')) // .height($r('app.float.virtualSize_36')) // } // .height('19%') // .width('100%') // .alignItems(VerticalAlign.Bottom) // .justifyContent(FlexAlign.End) // .margin({ bottom: '1%', right: '1%' }) // .onClick(() => { // let pro = new process.ProcessManager(); // pro.exit(0); // }) // } // .width('100%') // .height('100%') // .backgroundImage($r('app.media.login_backgroundImage')) // .backgroundImageSize({ width: '100%', height: '100%' }) // .alignItems(HorizontalAlign.End) // .justifyContent(FlexAlign.End) // // } // } // // // 部门选择弹框 // @CustomDialog // struct SelectDeptDialog { // @Link dept: DeptInfo // @State deptArray: DeptInfo[] = [{ deptName: '仿真中心', id: 111, orgId: 112 }] // controller?: CustomDialogController // cancel: () => void = () => { // } // confirm: () => void = () => { // } // // async aboutToAppear() { // if (!this.deptArray || this.deptArray.length <= 0) { // this.deptArray = await JGRequest.get("/api/v1/sys/dept/orgList", {}) as DeptInfo[] // if (this.deptArray && this.deptArray.length > 0) { // this.dept = this.deptArray[0] // } // } // } // // build() { // Column() { // Row() { // Text('选择部门') // .fontSize($r('app.float.fontSize_38')) // .fontWeight(FontWeight.Medium) // .fontColor($r('app.color.000000')) // //.opacity($r('app.float.general_font_opacity')) // } // .height('20%') // .justifyContent(FlexAlign.Center) // // Column() { // List({ space: 10 }) { // ForEach(this.deptArray, (item: DeptInfo) => { // ListItem() { // Row() { // Text(item.deptName) // .fontSize($r('app.float.fontSize_28')) // .fontWeight(FontWeight.Medium) // .fontColor(this.dept && this.dept.id === item.id ? $r('app.color.FFFFFF') : $r('app.color.000000')) // //.opacity($r('app.float.general_font_opacity')) // } // .height('15%') // .width('80%') // .backgroundColor(this.dept && this.dept.id === item.id ? $r('app.color.0A59F7') : $r('app.color.FFFFFF')) // .borderRadius($r('app.float.virtualSize_6_4')) // .padding({ left: 10 }) // .onClick(() => { // this.dept = item // if (this.controller != undefined) { // this.controller.close() // } // }) // } // }) // } // .alignListItem(ListItemAlign.Center) // } // .height('70%') // .width('80%') // .justifyContent(FlexAlign.Start) // } // .width('48%') // .height('63%') // .backgroundColor($r('app.color.F1F3F5')) // .justifyContent(FlexAlign.Start) // .borderRadius($r('app.float.virtualSize_6_4')) // } // } // // // 产线选择弹框 // @CustomDialog // struct ProductionLineDialog { // @Link productionLine: ProductionLine // @State lineArray: ProductionLine[] = [] // @Link workstation: WorkstationInfo // @Link workstationArray: WorkstationInfo[] // controller?: CustomDialogController // cancel: () => void = () => { // } // confirm: () => void = () => { // } // // async aboutToAppear() { // if (this.lineArray && this.lineArray.length > 0) { // return // } // // 查询产线 // this.lineArray = await JGRequest.post("/api/v1/base/productionLine/list/list", { // } as RequestParamModel) as ProductionLine[] // if (this.lineArray && this.lineArray.length > 0) { // this.productionLine = this.lineArray[0] // // 根据产线查询工位 // this.workstationArray = await JGRequest.get("/api/v1/base/station/getStationList/" + this.productionLine.code + "/1", { // }) as WorkstationInfo[] // console.log("====================1234567890" + "成功+++++" + this.workstationArray[0]) // if (this.workstationArray && this.workstationArray.length > 0) { // this.workstation = this.workstationArray[0] // console.log("====================1234567890" + "成功" + this.workstation) // } // } // } // // build() { // Column() { // Row() { // Text('选择产线') // .fontSize($r('app.float.fontSize_38')) // .fontWeight(FontWeight.Medium) // .fontColor($r('app.color.000000')) // //.opacity($r('app.float.general_font_opacity')) // } // .height('20%') // .justifyContent(FlexAlign.Center) // // Column() { // List({ space: 10 }) { // ForEach(this.lineArray, (item: ProductionLine) => { // ListItem() { // Row() { // Text(item.name) // .fontSize($r('app.float.fontSize_28')) // .fontWeight(FontWeight.Medium) // .fontColor(this.productionLine && this.productionLine.id === item.id ? $r('app.color.FFFFFF') : $r('app.color.000000')) // //.opacity($r('app.float.general_font_opacity')) // } // .height('15%') // .width('80%') // .backgroundColor(this.productionLine && this.productionLine.id === item.id ? $r('app.color.0A59F7') : $r('app.color.FFFFFF')) // .borderRadius($r('app.float.virtualSize_6_4')) // .padding({ left: 10 }) // .onClick(async () => { // this.productionLine = item // // 根据产线查询工位 // this.workstationArray = await JGRequest.get("/api/v1/base/station/getStationList/" + this.productionLine.code + "/1", { // }) as WorkstationInfo[] // if (this.workstationArray && this.workstationArray.length > 0) { // this.workstation = this.workstationArray[0] // } else { // this.workstation = {} // } // if (this.controller != undefined) { // this.controller.close() // } // }) // } // }) // } // .alignListItem(ListItemAlign.Center) // } // .height('70%') // .width('80%') // .justifyContent(FlexAlign.Start) // } // .width('48%') // .height('63%') // .backgroundColor($r('app.color.F1F3F5')) // .justifyContent(FlexAlign.Start) // .borderRadius($r('app.float.virtualSize_6_4')) // } // } // // // 工位选择弹框 // @CustomDialog // struct SelectWorkstationDialog { // @Link stationDictValue: string // @Link workstation: WorkstationInfo // // 产线编码 // private lineCode: string = '' // @Link workstationArray: WorkstationInfo[] // controller?: CustomDialogController // cancel: () => void = () => { // } // confirm: () => void = () => { // } // // async aboutToAppear() { // if (this.workstationArray && this.workstationArray.length > 0) { // return // } // if (!this.lineCode || this.lineCode.length <= 0) { // return // } // // 根据产线查询工位 // this.workstationArray = await JGRequest.get("/api/v1/base/station/getStationList/" + this.lineCode + "/1", { // }) as WorkstationInfo[] // if (this.workstationArray && this.workstationArray.length > 0) { // this.workstation = this.workstationArray[0] // } // } // // build() { // Column() { // Row() { // Text('选择工位') // .fontSize($r('app.float.fontSize_38')) // .fontWeight(FontWeight.Medium) // .fontColor($r('app.color.000000')) // //.opacity($r('app.float.general_font_opacity')) // } // .height('20%') // .justifyContent(FlexAlign.Center) // // Column() { // List({ space: 10 }) { // ForEach(this.workstationArray, (item: WorkstationInfo, index: number) => { // ListItem() { // Row() { // Text(item.name) // .fontSize($r('app.float.fontSize_28')) // .fontWeight(FontWeight.Medium) // .fontColor(this.workstation && this.workstation.id === item.id ? $r('app.color.FFFFFF') : $r('app.color.000000')) // //.opacity($r('app.float.general_font_opacity')) // } // .height('15%') // .width('80%') // .backgroundColor(this.workstation && this.workstation.id === item.id ? $r('app.color.0A59F7') : $r('app.color.FFFFFF')) // .borderRadius($r('app.float.virtualSize_6_4')) // .padding({ left: 10 }) // .onClick(() => { // this.workstation = item // this.stationDictValue = item.stationDictValue! // CommonConstants.stationDictValue = this.workstationArray[index].stationDictValue! // // // if (this.controller != undefined) { // this.controller.close() // } // }) // } // }) // } // .alignListItem(ListItemAlign.Center) // } // .height('70%') // .width('80%') // .justifyContent(FlexAlign.Start) // } // .width('48%') // .height('63%') // .backgroundColor($r('app.color.F1F3F5')) // .justifyContent(FlexAlign.Start) // .borderRadius($r('app.float.virtualSize_6_4')) // } // } // // export class DeptInfo { // id?: number // // 部门名称 // deptName?: string // // 组织id // orgId?: number // } // // export class WorkstationInfo { // id?: string // // 工位名称 // name?: string // //工位类型 // stationDictValue?: string // } // // class ProductionLine { // // 产线code // code?: string // // 创建时间 // created?: string // // 创建人 // creato?: string // // 是否删除 // deleted?: number // // 部门ID // deptId?: string // // 主键 // id?: string // // 数级结构层级 // level?: string // // 产线管理者 // manager?: string // // 产线名称 // name?: string // // 组织ID // orgId?: string // // 所属车间code // parentCode?: string // // 产线位置 // position?: string // // 产线描述 // remark?: string // // 修改时间 // updated?: string // // 上次修改人 // updator?: string // // 所属车间 // workShopName?: string // }