作者 xiaoqiu

优化了各项校验功能,修复了添加和修改维保记录的部分bug

@@ -125,7 +125,7 @@ export interface personCertificateRow { @@ -125,7 +125,7 @@ export interface personCertificateRow {
125 validEndTime?: null; 125 validEndTime?: null;
126 issueDate?: string; 126 issueDate?: string;
127 certificateImg?: string; 127 certificateImg?: string;
128 - memo?: null; 128 + memo?: string;
129 state?: string; 129 state?: string;
130 } 130 }
131 131
@@ -5,7 +5,7 @@ import { personData, personCertificateRow, companyWalletTest, companyWalletRow, @@ -5,7 +5,7 @@ import { personData, personCertificateRow, companyWalletTest, companyWalletRow,
5 import baseUrl from '../utils/baseUrl' 5 import baseUrl from '../utils/baseUrl'
6 import { getCompanyPersonList } from '../api/originalRecords' 6 import { getCompanyPersonList } from '../api/originalRecords'
7 import { companyPersonTest, companyPersonRow } from '../api/recordsType' 7 import { companyPersonTest, companyPersonRow } from '../api/recordsType'
8 -import { getCompanyWallet, updateState } from '../api/user' 8 +import { getCompanyWallet, updateState, getPay, beanType } from '../api/user'
9 import { AxiosResponse } from '@ohos/axios' 9 import { AxiosResponse } from '@ohos/axios'
10 import { promptAction } from '@kit.ArkUI' 10 import { promptAction } from '@kit.ArkUI'
11 import LoadingDialog from '../dialog/LoadingDialog' 11 import LoadingDialog from '../dialog/LoadingDialog'
@@ -20,6 +20,7 @@ function textRight() { @@ -20,6 +20,7 @@ function textRight() {
20 .fontSize(14).lineHeight(19).fontColor('#999') 20 .fontSize(14).lineHeight(19).fontColor('#999')
21 } 21 }
22 22
  23 +// 定义离职状态
23 let getTextInfo = (state: string | null) => { 24 let getTextInfo = (state: string | null) => {
24 if(state == '0') { 25 if(state == '0') {
25 return '已离职' 26 return '已离职'
@@ -47,11 +48,18 @@ export default struct MainPage { @@ -47,11 +48,18 @@ export default struct MainPage {
47 }) 48 })
48 @Link userInfo: personData 49 @Link userInfo: personData
49 @Link companyInfo: companyData 50 @Link companyInfo: companyData
  51 + @Link isEdit: boolean
50 @Link personCertificateInfo: personCertificateRow 52 @Link personCertificateInfo: personCertificateRow
51 @State walletData: companyWalletRow | null = null 53 @State walletData: companyWalletRow | null = null
52 @State companyData: companyPersonRow | null = null 54 @State companyData: companyPersonRow | null = null
53 - @Link isEdit: boolean 55 + @State isShowPay: boolean = false
  56 + timer: number = 0
54 roleName = preferencesUtil.get('XF_ROLE_NAME', '') 57 roleName = preferencesUtil.get('XF_ROLE_NAME', '')
  58 + // 获取是否显示充值
  59 + getShowPay = async () => {
  60 + const payInfo: AxiosResponse<beanType> = await getPay()
  61 + this.isShowPay = payInfo.data.msg === "true"
  62 + }
55 async aboutToAppear() { 63 async aboutToAppear() {
56 let personId = preferencesUtil.get('XF_PERSON_ID', 0) 64 let personId = preferencesUtil.get('XF_PERSON_ID', 0)
57 let companyId = preferencesUtil.get('XF_COMPANY_ID', 0) 65 let companyId = preferencesUtil.get('XF_COMPANY_ID', 0)
@@ -63,10 +71,21 @@ export default struct MainPage { @@ -63,10 +71,21 @@ export default struct MainPage {
63 const companyInfo: AxiosResponse<companyPersonTest> = await getCompanyPersonList({pageNum: 1, pageSize: 10, personId: Number(personId)}) 71 const companyInfo: AxiosResponse<companyPersonTest> = await getCompanyPersonList({pageNum: 1, pageSize: 10, personId: Number(personId)})
64 this.companyData = companyInfo.data.rows[0] 72 this.companyData = companyInfo.data.rows[0]
65 } 73 }
  74 + if(this.roleName == 'company') {
  75 + this.timer = setInterval(async () => {
  76 + await this.getShowPay()
  77 + }, 60000)
  78 + }
66 // 获取公司钱包信息 79 // 获取公司钱包信息
67 const walletInfo: AxiosResponse<companyWalletTest> = await getCompanyWallet({pageNum: 1, pageSize: 10, companyId: Number(companyId)}) 80 const walletInfo: AxiosResponse<companyWalletTest> = await getCompanyWallet({pageNum: 1, pageSize: 10, companyId: Number(companyId)})
68 this.walletData = walletInfo.data.rows[0] 81 this.walletData = walletInfo.data.rows[0]
69 - 82 + }
  83 + // 组件销毁时关闭定时任务
  84 + aboutToDisappear() {
  85 + if(this.timer !== 0) {
  86 + clearInterval(this.timer)
  87 + this.timer = 0
  88 + }
70 } 89 }
71 build() { 90 build() {
72 Stack(){ 91 Stack(){
@@ -88,7 +107,7 @@ export default struct MainPage { @@ -88,7 +107,7 @@ export default struct MainPage {
88 router.pushUrl({ 107 router.pushUrl({
89 url: "pages/MyWallet" 108 url: "pages/MyWallet"
90 }) 109 })
91 - }) 110 + }).visibility(this.roleName == 'company' && this.isShowPay ? Visibility.Visible: Visibility.None)
92 }.width('100%').padding({left: 10,right: 10}).margin({top: 44}) 111 }.width('100%').padding({left: 10,right: 10}).margin({top: 44})
93 .visibility(this.roleName == 'company' ? Visibility.Visible: Visibility.None) 112 .visibility(this.roleName == 'company' ? Visibility.Visible: Visibility.None)
94 }.width('100%').height(256).padding({left: 15,right: 15}) 113 }.width('100%').height(256).padding({left: 15,right: 15})
@@ -34,6 +34,10 @@ interface comprehensiveType { @@ -34,6 +34,10 @@ interface comprehensiveType {
34 } 34 }
35 let params = router.getParams() as routerParams 35 let params = router.getParams() as routerParams
36 let reportId: number | undefined = params?.reportId 36 let reportId: number | undefined = params?.reportId
  37 +let personId = preferencesUtil.get('XF_PERSON_ID', 0)
  38 +let companyId: number = preferencesUtil.get('XF_COMPANY_ID', 0) as number
  39 +let roleName = preferencesUtil.get('XF_ROLE_NAME', '')
  40 +
37 41
38 // 查看原始记录编号是否存在 42 // 查看原始记录编号是否存在
39 let queryReportNo = async (reportNo: string) => { 43 let queryReportNo = async (reportNo: string) => {
@@ -59,7 +63,10 @@ function searchByIndexOf(keyWord: string, list: equipmentType[]){ @@ -59,7 +63,10 @@ function searchByIndexOf(keyWord: string, list: equipmentType[]){
59 63
60 // 提取的富文本内容分别赋值 64 // 提取的富文本内容分别赋值
61 function multiply(range: string, facility: string, existingProblem: string,cumulativeIssues:string, correctedProblems: string, ...other: string[]){ 65 function multiply(range: string, facility: string, existingProblem: string,cumulativeIssues:string, correctedProblems: string, ...other: string[]){
62 - let otherValue: string = other.length > 1 ? other?.slice(1).join('、') : other[0].slice(3) 66 + let otherValue: string = ''
  67 + if(Array.isArray(other)) {
  68 + otherValue = other.length > 1 ? other?.slice(1).join('、') : other[0].slice(3)
  69 + }
63 let newObj:comprehensiveType = { 70 let newObj:comprehensiveType = {
64 range: range.split(':')[1], 71 range: range.split(':')[1],
65 facility: facility.split(':')[1], 72 facility: facility.split(':')[1],
@@ -68,20 +75,42 @@ function multiply(range: string, facility: string, existingProblem: string,cumul @@ -68,20 +75,42 @@ function multiply(range: string, facility: string, existingProblem: string,cumul
68 correctedProblems: correctedProblems.split(':')[1], 75 correctedProblems: correctedProblems.split(':')[1],
69 other: otherValue 76 other: otherValue
70 } 77 }
71 - return newObj 78 + return newObj
72 } 79 }
73 80
74 // 提取富文本中的内容解析后导出 81 // 提取富文本中的内容解析后导出
75 -function extractRichText(str: string): comprehensiveType{  
76 - let richText = str.replace(/<.*?>/g, '?')  
77 - let arrValue: string[] = richText.split('?').filter(item => item !== '')  
78 - let otherArr: string[] = []  
79 - if(arrValue.length > 5){  
80 - for (let index = 5; index < arrValue.length; index++) {  
81 - otherArr.push(arrValue[index]) 82 +function extractRichText(str: string | null): comprehensiveType{
  83 + if(str === null) {
  84 + return {
  85 + range: '',
  86 + facility: '',
  87 + existingProblem: '',
  88 + cumulativeIssues: '',
  89 + correctedProblems: '',
  90 + other: '',
  91 + }
  92 + } else {
  93 + let richText = str.replace(/<.*?>/g, '?')
  94 + let arrValue: string[] = richText.split('?').filter(item => item !== '')
  95 + let otherArr: string[] = []
  96 + if(arrValue.length > 5){
  97 + for (let index = 5; index < arrValue.length; index++) {
  98 + otherArr.push(arrValue[index])
  99 + }
  100 + return multiply(arrValue[0], arrValue[1], arrValue[2], arrValue[3], arrValue[4], ...otherArr)
  101 + } else if(arrValue.length === 5) {
  102 + return multiply(arrValue[0], arrValue[1], arrValue[2], arrValue[3], arrValue[4], '其他:')
  103 + } else {
  104 + return {
  105 + range: '',
  106 + facility: '',
  107 + existingProblem: '',
  108 + cumulativeIssues: '',
  109 + correctedProblems: '',
  110 + other: str.replace(/<.*?>/g, ''),
  111 + }
82 } 112 }
83 } 113 }
84 - return multiply(arrValue[0], arrValue[1], arrValue[2], arrValue[3], arrValue[4], ...otherArr)  
85 } 114 }
86 115
87 // 提交修改时合并富文本内容 116 // 提交修改时合并富文本内容
@@ -101,6 +130,11 @@ function mergeRichText(comprehensive: comprehensiveType): string{ @@ -101,6 +130,11 @@ function mergeRichText(comprehensive: comprehensiveType): string{
101 .border({width: 1, color: '#eee'}).backgroundColor(Color.Transparent) 130 .border({width: 1, color: '#eee'}).backgroundColor(Color.Transparent)
102 .placeholderColor('#999').borderRadius(4).placeholderFont({size: 14}) 131 .placeholderColor('#999').borderRadius(4).placeholderFont({size: 14})
103 } 132 }
  133 +@Extend(TextArea) function TextAreaReview () {
  134 + .width('100%').fontSize(14).fontColor('#999').lineHeight(20)
  135 + .border({width: 1, color: '#eee'}).backgroundColor(Color.Transparent)
  136 + .placeholderColor('#999').borderRadius(4).placeholderFont({size: 14})
  137 +}
104 138
105 @Entry 139 @Entry
106 @Component 140 @Component
@@ -108,8 +142,6 @@ struct AddRecords { @@ -108,8 +142,6 @@ struct AddRecords {
108 @Builder indicatorBuilder(icon: ResourceStr) { 142 @Builder indicatorBuilder(icon: ResourceStr) {
109 Image(icon) 143 Image(icon)
110 } 144 }
111 - personId = preferencesUtil.get('XF_PERSON_ID', 0)  
112 - flag: boolean = true  
113 // 添加维保记录类型参数 145 // 添加维保记录类型参数
114 @State addForm: addParamsType = { 146 @State addForm: addParamsType = {
115 reportName: '', 147 reportName: '',
@@ -161,59 +193,6 @@ struct AddRecords { @@ -161,59 +193,6 @@ struct AddRecords {
161 @State initEquipmentList: equipmentType[] = [] 193 @State initEquipmentList: equipmentType[] = []
162 @State errorMsg: string = '' 194 @State errorMsg: string = ''
163 @State text: string = "请选择维保记录类型" 195 @State text: string = "请选择维保记录类型"
164 - async aboutToAppear() {  
165 - // reportId等于undefined为编辑状态  
166 - this.isEdit = reportId !== undefined  
167 - this.addForm.city = this.pickerValue[1]  
168 - this.addForm.county = this.pickerValue[2]  
169 - if(reportId){  
170 - this.addForm.reportId = reportId  
171 - const res: AxiosResponse<reportDetailTest> = await getReportDetail(reportId)  
172 - let result: reportDetailData = res.data.data  
173 - this.addForm.reportName = result.reportName  
174 - this.addForm.applyCompanyName = result.applyCompanyName  
175 - this.addForm.reportNo = result.reportNo  
176 - this.addForm.reportType = result.reportType  
177 - this.addForm.maintenanceTime = result.maintenanceTime  
178 - this.addForm.maintenanceEndTime = result.maintenanceEndTime  
179 - this.addForm.equipmentList = result.equipment.split(',')  
180 - this.addForm.fireFacilities = result.fireFacilities  
181 - this.addForm.maintenancePeople = result.maintenancePeople  
182 - this.addForm.result = result.result.replace(/<.*?>/g, '')  
183 - this.addForm.state = result.state  
184 - this.addForm.technicalDirectorId = result.technicalDirectorId  
185 - this.addForm.maintenancePeopleList = result.technicalDirectorId?.split(',')  
186 - this.addForm.city = result.city  
187 - this.addForm.county = result.county  
188 - this.addForm.approvePersonId = result.approvePersonId as number  
189 - this.addForm.projectList = result.projectList.map(item => {  
190 - return { projectId: item.projectId } as projectType  
191 - })  
192 - this.fireFacilitiesList = this.addForm.fireFacilities.split('、')  
193 - this.viewEquipmentList = result.equipment.split(',')  
194 - this.PeopleList = result.technicalDirectorId?.split(',') || []  
195 - this.pickerValue = ['广西壮族自治区', result.city as string, result.county as string]  
196 - this.comprehensiveReview = extractRichText(result.result)  
197 - }  
198 - // 获取项目的类型列表  
199 - getMaintenanceType().then((res: AxiosResponse<quarterTest>) => {  
200 - this.recordsType = res.data.data  
201 - })  
202 - // 获取消防设施  
203 - getLatestProjectList(this.addForm.reportType as string).then((res: AxiosResponse<LatestProjectTest>) => {  
204 - this.latestProjectList = res.data.data  
205 - })  
206 - const companyId: number = preferencesUtil.get('XF_COMPANY_ID', 0) as number  
207 - this.addForm.companyId = companyId  
208 - // 获取仪器设备  
209 - getEquipmentList({pageNum: 1, pageSize: 500, companyId: companyId }).then((res: AxiosResponse<equipmentTest>) => {  
210 - this.equipmentList = res.data.rows  
211 - this.initEquipmentList = res.data.rows  
212 - })  
213 - getCompanyPersonList({pageNum: 1, pageSize: 200, companyId: companyId, state: '2' }).then((res: AxiosResponse<companyPersonTest>) => {  
214 - this.companyPersonList = res.data.rows  
215 - })  
216 - }  
217 // 搜索框实例 196 // 搜索框实例
218 searchController: SearchController = new SearchController() 197 searchController: SearchController = new SearchController()
219 198
@@ -241,60 +220,114 @@ struct AddRecords { @@ -241,60 +220,114 @@ struct AddRecords {
241 autoCancel: false 220 autoCancel: false
242 }) 221 })
243 222
  223 + // 初始化数据
  224 + initData = () => {
  225 + // 获取项目的类型列表
  226 + getMaintenanceType().then((res: AxiosResponse<quarterTest>) => {
  227 + this.recordsType = res.data.data
  228 + })
  229 + // 获取消防设施
  230 + getLatestProjectList(this.addForm.reportType as string).then((res: AxiosResponse<LatestProjectTest>) => {
  231 + this.latestProjectList = res.data.data
  232 + })
  233 + this.addForm.companyId = companyId
  234 + // 获取仪器设备
  235 + getEquipmentList({pageNum: 1, pageSize: 500, companyId: companyId }).then((res: AxiosResponse<equipmentTest>) => {
  236 + this.equipmentList = res.data.rows
  237 + this.initEquipmentList = res.data.rows
  238 + })
  239 + getCompanyPersonList({pageNum: 1, pageSize: 200, companyId: companyId, state: '2' }).then((res: AxiosResponse<companyPersonTest>) => {
  240 + this.companyPersonList = res.data.rows
  241 + })
  242 + }
  243 +
244 // 获取维保记录类型 244 // 获取维保记录类型
245 getReportType = async (dictValue: string) => { 245 getReportType = async (dictValue: string) => {
  246 + this.loadingController.open()
246 this.addForm.reportType = dictValue 247 this.addForm.reportType = dictValue
247 - if(this.flag) {  
248 - this.addForm.projectList = []  
249 - this.fireFacilitiesList = []  
250 - this.addForm.fireFacilities = ''  
251 - this.flag = false  
252 - let result: AxiosResponse<LatestProjectTest> = await getLatestProjectList(dictValue)  
253 - this.latestProjectList = result.data.data  
254 - this.flag = true  
255 - } 248 + this.addForm.projectList = []
  249 + this.fireFacilitiesList = []
  250 + this.addForm.fireFacilities = ''
  251 + let result: AxiosResponse<LatestProjectTest> = await getLatestProjectList(dictValue)
  252 + this.latestProjectList = result.data.data
  253 + this.loadingController.close()
  254 + }
  255 + // 添加记录方法
  256 + addReport = async () => {
  257 + this.loadingController.open()
  258 + this.addForm.maintenanceDate = [this.addForm.maintenanceTime as string, this.addForm.maintenanceEndTime as string]
  259 + await addRecords(this.addForm)
  260 + this.loadingController.close()
  261 + promptAction.showToast({ message: '添加成功' })
  262 + router.back()
256 } 263 }
  264 +
  265 + // 更新记录方法
  266 + uploadReport = async () => {
  267 + this.loadingController.open()
  268 + await updateRecords(this.addForm)
  269 + this.loadingController.close()
  270 + promptAction.showToast({ message: '更新成功' })
  271 + }
  272 +
257 // 提交表单 273 // 提交表单
258 submitForm = async () => { 274 submitForm = async () => {
259 - if(this.addForm.reportName == '') {  
260 - return promptAction.showToast({message: '项目名称为必填项'})  
261 - } else if(this.addForm.reportNo == '') {  
262 - return promptAction.showToast({message: '项目编号为必填项'})  
263 - } else if(this.addForm.applyCompanyName == ''){  
264 - return promptAction.showToast({message: '消防设施管理单位为必填项'})  
265 - } else if(this.addForm.maintenanceTime == '请选择起始日期' || this.addForm.maintenanceEndTime == '请选择结束日期'){  
266 - return promptAction.showToast({message: '维保日期为必填项'})  
267 - } else if(this.addForm.fireFacilities == ''){  
268 - return promptAction.showToast({message: '至少选择一下消防设施'})  
269 - } else if(this.addForm.maintenancePeople == ''){  
270 - return promptAction.showToast({message: '请选择维保人员'}) 275 + this.addForm.result = mergeRichText(this.comprehensiveReview)
  276 + if(this.addForm.reportName === '' || this.addForm.reportNo === '' || this.addForm.applyCompanyName === '' || this.addForm.maintenanceTime === '请选择起始日期' || this.addForm.maintenanceEndTime === '请选择结束日期' || this.addForm.fireFacilities === '' || this.addForm.maintenancePeople === '') {
  277 + return promptAction.showToast({message: '* 号为必填项'})
  278 + }
  279 + if(this.comprehensiveReview.range === '' || this.comprehensiveReview.existingProblem === '' || this.comprehensiveReview.cumulativeIssues === '' || this.comprehensiveReview.correctedProblems === ''){
  280 + return promptAction.showToast({message: '综合评述带 * 号必填'})
271 } 281 }
272 if(this.errorMsg !== '') { 282 if(this.errorMsg !== '') {
273 - return promptAction.showToast({message: '校验失败'}) 283 + return promptAction.showToast({message: '校验失败,编号已被使用'})
274 } 284 }
275 - if(!this.addForm.maintenancePeopleList?.includes(this.personId.toString())){ 285 + if(roleName === 'person' && !this.addForm.maintenancePeopleList?.includes(personId.toString())){
276 return promptAction.showToast({message: '本人必须在维护人员中'}) 286 return promptAction.showToast({message: '本人必须在维护人员中'})
277 } 287 }
278 - this.addForm.result = mergeRichText(this.comprehensiveReview)  
279 - if(this.isEdit){  
280 - this.loadingController.open()  
281 - await updateRecords(this.addForm)  
282 - this.loadingController.close()  
283 - promptAction.showToast({  
284 - message: '更新成功'  
285 - })  
286 - } else {  
287 - this.loadingController.open()  
288 - this.addForm.maintenanceDate = [this.addForm.maintenanceTime as string, this.addForm.maintenanceEndTime as string]  
289 - await addRecords(this.addForm)  
290 - this.loadingController.close()  
291 - promptAction.showToast({  
292 - message: '添加成功' 288 + this.isEdit ? await this.uploadReport() : await this.addReport()
  289 + }
  290 +
  291 + // 页面加载时调用
  292 + async aboutToAppear() {
  293 + this.initData()
  294 + // reportId不等于undefined为编辑状态
  295 + this.isEdit = reportId !== undefined
  296 + this.addForm.city = this.pickerValue[1]
  297 + this.addForm.county = this.pickerValue[2]
  298 + if(reportId){
  299 + this.addForm.reportId = reportId
  300 + const res: AxiosResponse<reportDetailTest> = await getReportDetail(reportId)
  301 + let result: reportDetailData = res.data.data
  302 + this.addForm.reportName = result.reportName
  303 + this.addForm.applyCompanyName = result.applyCompanyName
  304 + this.addForm.reportNo = result.reportNo
  305 + this.addForm.reportType = result.reportType
  306 + this.addForm.maintenanceTime = result.maintenanceTime
  307 + this.addForm.maintenanceEndTime = result.maintenanceEndTime
  308 + this.addForm.equipmentList = result.equipment?.split(',')
  309 + this.addForm.fireFacilities = result.fireFacilities
  310 + this.addForm.maintenancePeople = result.maintenancePeople
  311 + this.addForm.result = result.result?.replace(/<.*?>/g, '')
  312 + this.fireFacilitiesList = result.fireFacilities?.split('、') || []
  313 + this.addForm.state = result.state
  314 + this.addForm.technicalDirectorId = result.technicalDirectorId || ''
  315 + this.addForm.maintenancePeopleList = result.technicalDirectorId?.split(',') || []
  316 + this.addForm.city = result.city || '南宁市'
  317 + this.addForm.county = result.county || '青秀区'
  318 + this.addForm.approvePersonId = result.approvePersonId as number
  319 + this.addForm.projectList = result.projectList.map(item => {
  320 + return { projectId: item.projectId } as projectType
293 }) 321 })
294 - router.back() 322 + this.viewEquipmentList = result.equipment?.split(',') || []
  323 + this.PeopleList = result.technicalDirectorId?.split(',') || []
  324 + this.pickerValue = ['广西壮族自治区', result.city as string || '南宁市', result.county as string || '青秀区']
  325 + this.comprehensiveReview = extractRichText(result.result)
  326 + // 获取消防设施
  327 + let LatestRes: AxiosResponse<LatestProjectTest> = await getLatestProjectList(this.addForm.reportType as string)
  328 + this.latestProjectList = LatestRes.data.data
295 } 329 }
296 } 330 }
297 -  
298 build() { 331 build() {
299 Column(){ 332 Column(){
300 NavHeader({title: '添加原始记录'}) 333 NavHeader({title: '添加原始记录'})
@@ -345,7 +378,7 @@ struct AddRecords { @@ -345,7 +378,7 @@ struct AddRecords {
345 Image($r('app.media.require')).width(20) 378 Image($r('app.media.require')).width(20)
346 Text('维保起始日期') 379 Text('维保起始日期')
347 }.width(120) 380 }.width(120)
348 - Text(this.addForm.maintenanceTime).padding({top: 8, bottom: 8, left: 16, right: 16}) 381 + Text(this.addForm.maintenanceTime || '请选择日期').padding({top: 8, bottom: 8, left: 16, right: 16})
349 .backgroundColor('#fff').layoutWeight(1).fontColor('#000').onClick(() => { 382 .backgroundColor('#fff').layoutWeight(1).fontColor('#000').onClick(() => {
350 CalendarPickerDialog.show({ 383 CalendarPickerDialog.show({
351 onAccept: (value) => { 384 onAccept: (value) => {
@@ -359,7 +392,7 @@ struct AddRecords { @@ -359,7 +392,7 @@ struct AddRecords {
359 Image($r('app.media.require')).width(20) 392 Image($r('app.media.require')).width(20)
360 Text('维保结束日期') 393 Text('维保结束日期')
361 }.width(120) 394 }.width(120)
362 - Text(this.addForm.maintenanceEndTime).padding({top: 8, bottom: 8, left: 16, right: 16}) 395 + Text(this.addForm.maintenanceEndTime || '请选择日期').padding({top: 8, bottom: 8, left: 16, right: 16})
363 .backgroundColor('#fff').layoutWeight(1).fontColor('#000').onClick(() => { 396 .backgroundColor('#fff').layoutWeight(1).fontColor('#000').onClick(() => {
364 CalendarPickerDialog.show({ 397 CalendarPickerDialog.show({
365 onAccept: (value) => { 398 onAccept: (value) => {
@@ -368,6 +401,17 @@ struct AddRecords { @@ -368,6 +401,17 @@ struct AddRecords {
368 }) 401 })
369 }) 402 })
370 }.border({width: {bottom: 1}, color: '#eee'}).padding({top: 10, bottom: 10}) 403 }.border({width: {bottom: 1}, color: '#eee'}).padding({top: 10, bottom: 10})
  404 + Row(){
  405 + Row(){
  406 + Image($r('app.media.require')).width(20)
  407 + Text('项目区域')
  408 + }.width(90)
  409 + Text(this.pickerValue.join(' ')).layoutWeight(1).padding({top: 8, bottom: 8, left: 16, right: 16})
  410 + .backgroundColor('#fff').textOverflow({overflow: TextOverflow.Ellipsis}).maxLines(2)
  411 + .onClick(() => {
  412 + this.areaController?.open()
  413 + })
  414 + }.border({width: {bottom: 1}, color: '#eee'}).padding({top: 10, bottom: 10})
371 Column({space: 10}){ 415 Column({space: 10}){
372 Row(){ 416 Row(){
373 Image($r('app.media.require')).width(20) 417 Image($r('app.media.require')).width(20)
@@ -422,7 +466,10 @@ struct AddRecords { @@ -422,7 +466,10 @@ struct AddRecords {
422 .shape(CheckBoxShape.ROUNDED_SQUARE) 466 .shape(CheckBoxShape.ROUNDED_SQUARE)
423 .onChange((value: boolean) => { 467 .onChange((value: boolean) => {
424 if(value){ 468 if(value){
425 - this.addForm.maintenancePeopleList?.push(children.personId.toString()) 469 + // 如果选择的人员列表中不存在此人员列表中,则添加
  470 + if(!this.addForm.maintenancePeopleList?.includes(children.personId.toString())){
  471 + this.addForm.maintenancePeopleList?.push(children.personId.toString())
  472 + }
426 }else { 473 }else {
427 this.addForm.maintenancePeopleList = this.addForm.maintenancePeopleList?.filter((item: string) => item !== children.personId.toString()) 474 this.addForm.maintenancePeopleList = this.addForm.maintenancePeopleList?.filter((item: string) => item !== children.personId.toString())
428 } 475 }
@@ -450,17 +497,6 @@ struct AddRecords { @@ -450,17 +497,6 @@ struct AddRecords {
450 TextInput({placeholder: '请输入消防设施管理单位', text: $$this.addForm.applyCompanyName}) 497 TextInput({placeholder: '请输入消防设施管理单位', text: $$this.addForm.applyCompanyName})
451 .backgroundColor('#fff') 498 .backgroundColor('#fff')
452 }.border({width: {bottom: 1}, color: '#eee'}).padding({top: 10}) 499 }.border({width: {bottom: 1}, color: '#eee'}).padding({top: 10})
453 - Row(){  
454 - Row(){  
455 - Image($r('app.media.require')).width(20)  
456 - Text('项目区域')  
457 - }.width(90)  
458 - Text(this.pickerValue.join(' ')).layoutWeight(1).padding({top: 8, bottom: 8, left: 16, right: 16})  
459 - .backgroundColor('#fff').textOverflow({overflow: TextOverflow.Ellipsis}).maxLines(2)  
460 - .onClick(() => {  
461 - this.areaController?.open()  
462 - })  
463 - }.border({width: {bottom: 1}, color: '#eee'}).padding({top: 10, bottom: 10})  
464 Column(){ 500 Column(){
465 Row(){ 501 Row(){
466 Image($r('app.media.require')).width(20) 502 Image($r('app.media.require')).width(20)
@@ -511,10 +547,11 @@ struct AddRecords { @@ -511,10 +547,11 @@ struct AddRecords {
511 Row(){ 547 Row(){
512 Checkbox({ name: children.projectName, group: 'checkboxGroup' }) 548 Checkbox({ name: children.projectName, group: 'checkboxGroup' })
513 .selectedColor('#1890ff') 549 .selectedColor('#1890ff')
514 - .select(this.fireFacilitiesList.includes(children.projectName)) 550 + .select(this.fireFacilitiesList?.includes(children.projectName))
515 .shape(CheckBoxShape.ROUNDED_SQUARE) 551 .shape(CheckBoxShape.ROUNDED_SQUARE)
516 .onChange((value) => { 552 .onChange((value) => {
517 if(value){ 553 if(value){
  554 + if(this.addForm.projectList?.some((item) => item.projectId === children.projectId)) return
518 this.addForm.projectList?.push({ projectId: children.projectId }) 555 this.addForm.projectList?.push({ projectId: children.projectId })
519 } else { 556 } else {
520 this.addForm.projectList = this.addForm.projectList?.filter((item) => item.projectId !== children.projectId) 557 this.addForm.projectList = this.addForm.projectList?.filter((item) => item.projectId !== children.projectId)
@@ -582,7 +619,7 @@ struct AddRecords { @@ -582,7 +619,7 @@ struct AddRecords {
582 Row(){ 619 Row(){
583 Checkbox({ name: children.equipmentName, group: 'checkboxGroup2' }) 620 Checkbox({ name: children.equipmentName, group: 'checkboxGroup2' })
584 .selectedColor('#1890ff') 621 .selectedColor('#1890ff')
585 - .select(this.viewEquipmentList.includes(children.equipmentName)) 622 + .select(this.viewEquipmentList?.includes(children.equipmentName))
586 .shape(CheckBoxShape.ROUNDED_SQUARE) 623 .shape(CheckBoxShape.ROUNDED_SQUARE)
587 .mark({ 624 .mark({
588 strokeColor:Color.White, 625 strokeColor:Color.White,
@@ -606,29 +643,44 @@ struct AddRecords { @@ -606,29 +643,44 @@ struct AddRecords {
606 }.padding({left: 10}) 643 }.padding({left: 10})
607 Column({space: 10}){ 644 Column({space: 10}){
608 Column({space: 10}){ 645 Column({space: 10}){
609 - Text('本月维保范围').TitleReview() 646 + Row({space: 5}){
  647 + Image($r('app.media.require')).width(20)
  648 + Text('本月维保范围').TitleReview()
  649 + }.width('100%')
610 TextInput({placeholder: '请输入本月维保范围(填写楼层)', text: $$this.comprehensiveReview.range}).TextInputReview() 650 TextInput({placeholder: '请输入本月维保范围(填写楼层)', text: $$this.comprehensiveReview.range}).TextInputReview()
611 }.width('100%').alignItems(HorizontalAlign.Start) 651 }.width('100%').alignItems(HorizontalAlign.Start)
612 Column({space: 10}){ 652 Column({space: 10}){
613 - Text('消防设施包含').TitleReview()  
614 - Text(this.comprehensiveReview.facility || '勾选主要消防设施').width('100%').height(40).fontSize(14).padding({top: 8, bottom: 8, left: 16, right: 16}) 653 + Row({space: 5}){
  654 + Image($r('app.media.require')).width(20)
  655 + Text('消防设施包含').TitleReview()
  656 + }.width('100%')
  657 + Text(this.comprehensiveReview.facility || '勾选主要消防设施').width('100%').height('auto').fontSize(14).padding({top: 8, bottom: 8, left: 16, right: 16})
615 .border({width: 1, color: '#eee'}).borderRadius(4).fontColor('#999').textAlign(TextAlign.Start) 658 .border({width: 1, color: '#eee'}).borderRadius(4).fontColor('#999').textAlign(TextAlign.Start)
616 }.width('100%').alignItems(HorizontalAlign.Start) 659 }.width('100%').alignItems(HorizontalAlign.Start)
617 Column({space: 10}){ 660 Column({space: 10}){
618 - Text('存在问题').TitleReview()  
619 - TextInput({placeholder: '请输入存在问题', text: this.comprehensiveReview.existingProblem}).TextInputReview() 661 + Row({space: 5}){
  662 + Image($r('app.media.require')).width(20)
  663 + Text('存在问题').TitleReview()
  664 + }.width('100%')
  665 + TextArea({ placeholder: '请输入存在问题', text: $$this.comprehensiveReview.existingProblem }).TextAreaReview()
620 }.width('100%').alignItems(HorizontalAlign.Start) 666 }.width('100%').alignItems(HorizontalAlign.Start)
621 Column({space: 10}){ 667 Column({space: 10}){
622 - Text('累计问题').TitleReview()  
623 - TextInput({placeholder: '请输入累计问题', text: $$this.comprehensiveReview.cumulativeIssues}).TextInputReview() 668 + Row({space: 5}){
  669 + Image($r('app.media.require')).width(20)
  670 + Text('累计问题').TitleReview()
  671 + }.width('100%')
  672 + TextArea({ placeholder: '请输入累计问题', text: $$this.comprehensiveReview.cumulativeIssues }).TextAreaReview()
624 }.width('100%').alignItems(HorizontalAlign.Start) 673 }.width('100%').alignItems(HorizontalAlign.Start)
625 Column({space: 10}){ 674 Column({space: 10}){
626 - Text('已整改问题').TitleReview()  
627 - TextInput({placeholder: '请输入已整改问题', text: $$this.comprehensiveReview.correctedProblems}).TextInputReview() 675 + Row({space: 5}){
  676 + Image($r('app.media.require')).width(20)
  677 + Text('已整改问题').TitleReview()
  678 + }.width('100%')
  679 + TextArea({ placeholder: '请输入已整改问题', text: $$this.comprehensiveReview.correctedProblems }).TextAreaReview()
628 }.width('100%').alignItems(HorizontalAlign.Start) 680 }.width('100%').alignItems(HorizontalAlign.Start)
629 Column({space: 10}){ 681 Column({space: 10}){
630 Text('其他').TitleReview() 682 Text('其他').TitleReview()
631 - TextInput({placeholder: '其他内容', text: $$this.comprehensiveReview.other}).TextInputReview() 683 + TextArea({ placeholder: '请输入其他内容', text: $$this.comprehensiveReview.other }).TextAreaReview()
632 }.width('100%').alignItems(HorizontalAlign.Start) 684 }.width('100%').alignItems(HorizontalAlign.Start)
633 } 685 }
634 }.width('100%').alignItems(HorizontalAlign.Start).margin({top: 20}).padding({bottom: 30}) 686 }.width('100%').alignItems(HorizontalAlign.Start).margin({top: 20}).padding({bottom: 30})
@@ -645,6 +697,7 @@ struct AddRecords { @@ -645,6 +697,7 @@ struct AddRecords {
645 }.width('100%').height('100%').backgroundColor('#f2f3f7') 697 }.width('100%').height('100%').backgroundColor('#f2f3f7')
646 } 698 }
647 699
  700 + // 退出动画
648 pageTransition() { 701 pageTransition() {
649 // 该页面退出动画时长为1200ms,尽量与另一页面的进入动画时长匹配 702 // 该页面退出动画时长为1200ms,尽量与另一页面的进入动画时长匹配
650 PageTransitionExit({ duration: 500 }) 703 PageTransitionExit({ duration: 500 })
@@ -21,6 +21,7 @@ struct EditUser { @@ -21,6 +21,7 @@ struct EditUser {
21 certificateId: 1, 21 certificateId: 1,
22 certificateImg: '', 22 certificateImg: '',
23 issueDate: '选择日期', 23 issueDate: '选择日期',
  24 + memo: '无',
24 personId 25 personId
25 } 26 }
26 @State selectValue: string = '请选择证书类型' 27 @State selectValue: string = '请选择证书类型'
@@ -116,6 +117,7 @@ struct EditUser { @@ -116,6 +117,7 @@ struct EditUser {
116 }.border({width: {bottom: 1}, color: '#eee'}).padding({top: 10, bottom: 10}) 117 }.border({width: {bottom: 1}, color: '#eee'}).padding({top: 10, bottom: 10})
117 Row(){ 118 Row(){
118 Row(){ 119 Row(){
  120 + Image($r('app.media.require')).width(20)
119 Text('备注') 121 Text('备注')
120 }.width(100) 122 }.width(100)
121 TextArea({ 123 TextArea({
@@ -4,15 +4,12 @@ import { BusinessError } from '@ohos.base'; @@ -4,15 +4,12 @@ import { BusinessError } from '@ohos.base';
4 import { promptAction, router } from '@kit.ArkUI' 4 import { promptAction, router } from '@kit.ArkUI'
5 import { common } from '@kit.AbilityKit'; 5 import { common } from '@kit.AbilityKit';
6 import { FileUtil, CommonConstants } from '../utils/FileUtil'; 6 import { FileUtil, CommonConstants } from '../utils/FileUtil';
7 -// import { uploadFileByTask } from '../utils/uploadCloud'  
8 -import { commonRouterParams } from '../utils/UserAuth'  
9 7
10 /** 8 /**
11 * 视频录制 9 * 视频录制
12 */ 10 */
13 11
14 let context = getContext(this) as common.UIAbilityContext; 12 let context = getContext(this) as common.UIAbilityContext;
15 -let routerParamsData: commonRouterParams = router.getParams() as commonRouterParams;  
16 @Entry 13 @Entry
17 @Component 14 @Component
18 struct CreateCamera { 15 struct CreateCamera {
@@ -67,11 +64,8 @@ struct CreateCamera { @@ -67,11 +64,8 @@ struct CreateCamera {
67 this.timer = 0 64 this.timer = 0
68 promptAction.showToast({ message: '已完成录制,开始上传' }) 65 promptAction.showToast({ message: '已完成录制,开始上传' })
69 await this.stopRecord(); 66 await this.stopRecord();
70 - routerParamsData.videoPath = this.path;  
71 - router.back({  
72 - url:'',  
73 - params: routerParamsData  
74 - }) 67 + AppStorage.set('videoPath', this.path);
  68 + router.back()
75 } else { 69 } else {
76 promptAction.showToast({ message: '已开始录制,再次点击完成录制' }) 70 promptAction.showToast({ message: '已开始录制,再次点击完成录制' })
77 this.timer = setInterval(async () => { 71 this.timer = setInterval(async () => {
@@ -81,11 +75,8 @@ struct CreateCamera { @@ -81,11 +75,8 @@ struct CreateCamera {
81 this.timer = 0 75 this.timer = 0
82 promptAction.showToast({ message: '已完成录制,开始上传' }) 76 promptAction.showToast({ message: '已完成录制,开始上传' })
83 await this.stopRecord(); 77 await this.stopRecord();
84 - routerParamsData.videoPath = this.path;  
85 - router.back({  
86 - url:'',  
87 - params: routerParamsData  
88 - }) 78 + AppStorage.set('videoPath', this.path);
  79 + router.back()
89 } 80 }
90 }, 1000); 81 }, 1000);
91 await this.startRecord(); 82 await this.startRecord();
@@ -118,43 +109,44 @@ struct CreateCamera { @@ -118,43 +109,44 @@ struct CreateCamera {
118 } 109 }
119 110
120 this.cameraManager.on('cameraStatus', (err: BusinessError, cameraStatusInfo: camera.CameraStatusInfo) => { 111 this.cameraManager.on('cameraStatus', (err: BusinessError, cameraStatusInfo: camera.CameraStatusInfo) => {
121 - promptAction.showToast({ message: `camera : ${cameraStatusInfo.camera.cameraId},status: ${cameraStatusInfo.status}` }) 112 + console.log(`camera : ${cameraStatusInfo.camera.cameraId},status: ${cameraStatusInfo.status}`)
  113 + // promptAction.showToast({ message: `camera : ${cameraStatusInfo.camera.cameraId},status: ${cameraStatusInfo.status}` })
122 }); 114 });
123 115
124 let cameraArray: Array<camera.CameraDevice> = []; 116 let cameraArray: Array<camera.CameraDevice> = [];
125 try { 117 try {
126 cameraArray = this.cameraManager.getSupportedCameras(); 118 cameraArray = this.cameraManager.getSupportedCameras();
127 } catch (error) { 119 } catch (error) {
128 - let err = error as BusinessError;  
129 - promptAction.showToast({ message: `getSupportedCameras call failed. error code: ${err.code}` }) 120 + // let err = error as BusinessError;
  121 + // promptAction.showToast({ message: `getSupportedCameras call failed. error code: ${err.code}` })
130 } 122 }
131 123
132 if (cameraArray.length <= 0) { 124 if (cameraArray.length <= 0) {
133 - promptAction.showToast({ message: 'cameraManager.getSupportedCameras error' }) 125 + // promptAction.showToast({ message: 'cameraManager.getSupportedCameras error' })
134 return; 126 return;
135 } 127 }
136 128
137 let cameraOutputCap: camera.CameraOutputCapability = 129 let cameraOutputCap: camera.CameraOutputCapability =
138 this.cameraManager.getSupportedOutputCapability(cameraArray[0], camera.SceneMode.NORMAL_VIDEO); 130 this.cameraManager.getSupportedOutputCapability(cameraArray[0], camera.SceneMode.NORMAL_VIDEO);
139 if (!cameraOutputCap) { 131 if (!cameraOutputCap) {
140 - promptAction.showToast({ message: 'cameraManager.getSupportedOutputCapability error' }) 132 + // promptAction.showToast({ message: 'cameraManager.getSupportedOutputCapability error' })
141 return; 133 return;
142 } 134 }
143 - promptAction.showToast({ message: 'outputCapability: ' + JSON.stringify(cameraOutputCap) }) 135 + // promptAction.showToast({ message: 'outputCapability: ' + JSON.stringify(cameraOutputCap) })
144 136
145 let previewProfilesArray: Array<camera.Profile> = cameraOutputCap.previewProfiles; 137 let previewProfilesArray: Array<camera.Profile> = cameraOutputCap.previewProfiles;
146 if (!previewProfilesArray) { 138 if (!previewProfilesArray) {
147 - promptAction.showToast({ message: 'createOutput previewProfilesArray === null || undefined' }) 139 + // promptAction.showToast({ message: 'createOutput previewProfilesArray === null || undefined' })
148 } 140 }
149 141
150 let photoProfilesArray: Array<camera.Profile> = cameraOutputCap.photoProfiles; 142 let photoProfilesArray: Array<camera.Profile> = cameraOutputCap.photoProfiles;
151 if (!photoProfilesArray) { 143 if (!photoProfilesArray) {
152 - promptAction.showToast({ message: 'createOutput photoProfilesArray === null || undefined' }) 144 + // promptAction.showToast({ message: 'createOutput photoProfilesArray === null || undefined' })
153 } 145 }
154 146
155 let videoProfilesArray: Array<camera.VideoProfile> = cameraOutputCap.videoProfiles; 147 let videoProfilesArray: Array<camera.VideoProfile> = cameraOutputCap.videoProfiles;
156 if (!videoProfilesArray) { 148 if (!videoProfilesArray) {
157 - promptAction.showToast({ message: 'createOutput videoProfilesArray === null || undefined' }) 149 + // promptAction.showToast({ message: 'createOutput videoProfilesArray === null || undefined' })
158 } 150 }
159 151
160 let videoSize: camera.Size = { 152 let videoSize: camera.Size = {
@@ -166,7 +158,7 @@ struct CreateCamera { @@ -166,7 +158,7 @@ struct CreateCamera {
166 }); 158 });
167 159
168 if (!videoProfile) { 160 if (!videoProfile) {
169 - promptAction.showToast({ message: 'videoProfile is not found' }) 161 + promptAction.showToast({ message: '没有找到视频文件' })
170 return; 162 return;
171 } 163 }
172 164
@@ -198,8 +190,8 @@ struct CreateCamera { @@ -198,8 +190,8 @@ struct CreateCamera {
198 try { 190 try {
199 this.avRecorder = await media.createAVRecorder(); 191 this.avRecorder = await media.createAVRecorder();
200 } catch (error) { 192 } catch (error) {
201 - let err = error as BusinessError;  
202 - promptAction.showToast({ message: `createAVRecorder call failed. error code: ${err.code}` }) 193 + // let err = error as BusinessError;
  194 + // promptAction.showToast({ message: `createAVRecorder call failed. error code: ${err.code}` })
203 } 195 }
204 196
205 if (this.avRecorder === undefined) { 197 if (this.avRecorder === undefined) {
@@ -209,16 +201,16 @@ struct CreateCamera { @@ -209,16 +201,16 @@ struct CreateCamera {
209 try { 201 try {
210 await this.avRecorder.prepare(aVRecorderConfig); 202 await this.avRecorder.prepare(aVRecorderConfig);
211 } catch (error) { 203 } catch (error) {
212 - let err = error as BusinessError;  
213 - promptAction.showToast({ message: `prepare call failed. error code: ${err.code}` }) 204 + // let err = error as BusinessError;
  205 + // promptAction.showToast({ message: `prepare call failed. error code: ${err.code}` })
214 } 206 }
215 207
216 let videoSurfaceId: string | undefined = undefined; 208 let videoSurfaceId: string | undefined = undefined;
217 try { 209 try {
218 videoSurfaceId = await this.avRecorder.getInputSurface(); 210 videoSurfaceId = await this.avRecorder.getInputSurface();
219 } catch (error) { 211 } catch (error) {
220 - let err = error as BusinessError;  
221 - promptAction.showToast({ message: `getInputSurface call failed. error code: ${err.code}` }) 212 + // let err = error as BusinessError;
  213 + // promptAction.showToast({ message: `getInputSurface call failed. error code: ${err.code}` })
222 } 214 }
223 if (videoSurfaceId === undefined) { 215 if (videoSurfaceId === undefined) {
224 return; 216 return;
@@ -227,26 +219,26 @@ struct CreateCamera { @@ -227,26 +219,26 @@ struct CreateCamera {
227 try { 219 try {
228 this.videoOutput = this.cameraManager.createVideoOutput(videoProfile, videoSurfaceId); 220 this.videoOutput = this.cameraManager.createVideoOutput(videoProfile, videoSurfaceId);
229 } catch (error) { 221 } catch (error) {
230 - let err = error as BusinessError;  
231 - promptAction.showToast({ message: `Failed to create the videoOutput instance. error: ${JSON.stringify(err)}` }) 222 + // let err = error as BusinessError;
  223 + // promptAction.showToast({ message: `Failed to create the videoOutput instance. error: ${JSON.stringify(err)}` })
232 } 224 }
233 if (this.videoOutput === undefined) { 225 if (this.videoOutput === undefined) {
234 return; 226 return;
235 } 227 }
236 this.videoOutput.on('frameStart', () => { 228 this.videoOutput.on('frameStart', () => {
237 - promptAction.showToast({ message: 'Video frame started' }) 229 + // promptAction.showToast({ message: 'Video frame started' })
238 }); 230 });
239 231
240 - this.videoOutput.on('error', (error: BusinessError) => {  
241 - promptAction.showToast({ message: `Video frame error code: ${error.code}` }) 232 + this.videoOutput.on('error', () => {
  233 + // promptAction.showToast({ message: `Video frame error code: ${error.code}` })
242 }); 234 });
243 235
244 try { 236 try {
245 this.captureSession = this.cameraManager.createSession(camera.SceneMode.NORMAL_VIDEO) as camera.VideoSession; 237 this.captureSession = this.cameraManager.createSession(camera.SceneMode.NORMAL_VIDEO) as camera.VideoSession;
246 ; 238 ;
247 } catch (error) { 239 } catch (error) {
248 - let err = error as BusinessError;  
249 - promptAction.showToast({ message: `Failed to create the CaptureSession instance. errorCode = ${err.code}` }) 240 + // let err = error as BusinessError;
  241 + // promptAction.showToast({ message: `Failed to create the CaptureSession instance. errorCode = ${err.code}` })
250 } 242 }
251 if (this.captureSession === undefined) { 243 if (this.captureSession === undefined) {
252 return; 244 return;
@@ -255,46 +247,46 @@ struct CreateCamera { @@ -255,46 +247,46 @@ struct CreateCamera {
255 try { 247 try {
256 this.captureSession.beginConfig(); 248 this.captureSession.beginConfig();
257 } catch (error) { 249 } catch (error) {
258 - let err = error as BusinessError;  
259 - promptAction.showToast({ message: `Failed to beginConfig. errorCode = ${err.code}` }) 250 + // let err = error as BusinessError;
  251 + // promptAction.showToast({ message: `Failed to beginConfig. errorCode = ${err.code}` })
260 } 252 }
261 253
262 let cameraInput: camera.CameraInput | undefined = undefined; 254 let cameraInput: camera.CameraInput | undefined = undefined;
263 try { 255 try {
264 cameraInput = this.cameraManager.createCameraInput(cameraArray[0]); 256 cameraInput = this.cameraManager.createCameraInput(cameraArray[0]);
265 } catch (error) { 257 } catch (error) {
266 - let err = error as BusinessError;  
267 - promptAction.showToast({ message: `Failed to createCameraInput. errorCode = ${err.code}` }) 258 + // let err = error as BusinessError;
  259 + // promptAction.showToast({ message: `Failed to createCameraInput. errorCode = ${err.code}` })
268 } 260 }
269 if (cameraInput === undefined) { 261 if (cameraInput === undefined) {
270 return; 262 return;
271 } 263 }
272 264
273 let cameraDevice: camera.CameraDevice = cameraArray[0]; 265 let cameraDevice: camera.CameraDevice = cameraArray[0];
274 - cameraInput.on('error', cameraDevice, (error: BusinessError) => {  
275 - promptAction.showToast({ message: `Camera input error code: ${error.code}` }) 266 + cameraInput.on('error', cameraDevice, () => {
  267 + // promptAction.showToast({ message: `Camera input error code: ${error.code}` })
276 }); 268 });
277 269
278 try { 270 try {
279 await cameraInput.open(); 271 await cameraInput.open();
280 } catch (error) { 272 } catch (error) {
281 - let err = error as BusinessError;  
282 - promptAction.showToast({ message: `Failed to open cameraInput. errorCode = ${err.code}` }) 273 + // let err = error as BusinessError;
  274 + // promptAction.showToast({ message: `Failed to open cameraInput. errorCode = ${err.code}` })
283 } 275 }
284 276
285 try { 277 try {
286 this.captureSession.addInput(cameraInput); 278 this.captureSession.addInput(cameraInput);
287 } catch (error) { 279 } catch (error) {
288 - let err = error as BusinessError;  
289 - promptAction.showToast({ message: `Failed to add cameraInput. errorCode = ${err.code}` }) 280 + // let err = error as BusinessError;
  281 + // promptAction.showToast({ message: `Failed to add cameraInput. errorCode = ${err.code}` })
290 } 282 }
291 283
292 let previewOutput: camera.PreviewOutput | undefined = undefined; 284 let previewOutput: camera.PreviewOutput | undefined = undefined;
293 try { 285 try {
294 previewOutput = this.cameraManager.createPreviewOutput(videoProfile, surfaceId); 286 previewOutput = this.cameraManager.createPreviewOutput(videoProfile, surfaceId);
295 } catch (error) { 287 } catch (error) {
296 - let err = error as BusinessError;  
297 - promptAction.showToast({ message: `Failed to create the previewOutput instance. error: ${JSON.stringify(err)}` }) 288 + // let err = error as BusinessError;
  289 + // promptAction.showToast({ message: `Failed to create the previewOutput instance. error: ${JSON.stringify(err)}` })
298 } 290 }
299 291
300 if (previewOutput === undefined) { 292 if (previewOutput === undefined) {
@@ -304,37 +296,37 @@ struct CreateCamera { @@ -304,37 +296,37 @@ struct CreateCamera {
304 try { 296 try {
305 this.captureSession.addOutput(previewOutput); 297 this.captureSession.addOutput(previewOutput);
306 } catch (error) { 298 } catch (error) {
307 - let err = error as BusinessError;  
308 - promptAction.showToast({ message: `Failed to add previewOutput. errorCode = ${err.code}` }) 299 + // let err = error as BusinessError;
  300 + // promptAction.showToast({ message: `Failed to add previewOutput. errorCode = ${err.code}` })
309 } 301 }
310 302
311 try { 303 try {
312 this.captureSession.addOutput(this.videoOutput); 304 this.captureSession.addOutput(this.videoOutput);
313 } catch (error) { 305 } catch (error) {
314 - let err = error as BusinessError;  
315 - promptAction.showToast({ message: `Failed to add videoOutput. errorCode = ${err.code}` }) 306 + // let err = error as BusinessError;
  307 + // promptAction.showToast({ message: `Failed to add videoOutput. errorCode = ${err.code}` })
316 } 308 }
317 309
318 try { 310 try {
319 await this.captureSession.commitConfig(); 311 await this.captureSession.commitConfig();
320 } catch (error) { 312 } catch (error) {
321 - let err = error as BusinessError;  
322 - promptAction.showToast({ message: `Failed to commitConfig. errorCode = ${err.code}` }) 313 + // let err = error as BusinessError;
  314 + // promptAction.showToast({ message: `Failed to commitConfig. errorCode = ${err.code}` })
323 } 315 }
324 316
325 try { 317 try {
326 await this.captureSession.start(); 318 await this.captureSession.start();
327 } catch (error) { 319 } catch (error) {
328 - let err = error as BusinessError;  
329 - promptAction.showToast({ message: `Failed to start captureSession. errorCode = ${err.code}` }) 320 + // let err = error as BusinessError;
  321 + // promptAction.showToast({ message: `Failed to start captureSession. errorCode = ${err.code}` })
330 } 322 }
331 323
332 this.videoOutput.start((err: BusinessError) => { 324 this.videoOutput.start((err: BusinessError) => {
333 if (err) { 325 if (err) {
334 - promptAction.showToast({ message: `Failed to start the video output. error: ${JSON.stringify(err)}` }) 326 + // promptAction.showToast({ message: `Failed to start the video output. error: ${JSON.stringify(err)}` })
335 return; 327 return;
336 } 328 }
337 - promptAction.showToast({message: 'Callback invoked to indicate the video output start success.'}) 329 + // promptAction.showToast({message: 'Callback invoked to indicate the video output start success.'})
338 }); 330 });
339 } 331 }
340 332
@@ -344,8 +336,8 @@ struct CreateCamera { @@ -344,8 +336,8 @@ struct CreateCamera {
344 try { 336 try {
345 await this.avRecorder.start(); 337 await this.avRecorder.start();
346 } catch (error) { 338 } catch (error) {
347 - let err = error as BusinessError;  
348 - promptAction.showToast({ message: `avRecorder start error: ${JSON.stringify(err)}` }) 339 + // let err = error as BusinessError;
  340 + // promptAction.showToast({ message: `avRecorder start error: ${JSON.stringify(err)}` })
349 } 341 }
350 } 342 }
351 } 343 }
@@ -357,22 +349,22 @@ struct CreateCamera { @@ -357,22 +349,22 @@ struct CreateCamera {
357 if (this.videoOutput) { 349 if (this.videoOutput) {
358 this.videoOutput.stop((err: BusinessError) => { 350 this.videoOutput.stop((err: BusinessError) => {
359 if (err) { 351 if (err) {
360 - promptAction.showToast({ message: `Failed to stop the video output. error: ${JSON.stringify(err)}` }) 352 + // promptAction.showToast({ message: `Failed to stop the video output. error: ${JSON.stringify(err)}` })
361 return; 353 return;
362 } 354 }
363 - promptAction.showToast({message: 'Callback invoked to indicate the video output stop success.'}) 355 + // promptAction.showToast({message: 'Callback invoked to indicate the video output stop success.'})
364 }); 356 });
365 } 357 }
366 try { 358 try {
367 await this.avRecorder.stop(); 359 await this.avRecorder.stop();
368 await this.avRecorder.release(); 360 await this.avRecorder.release();
369 } catch (error) { 361 } catch (error) {
370 - let err = error as BusinessError;  
371 - promptAction.showToast({ message: `avRecorder stop error: ${JSON.stringify(err)}` }) 362 + // let err = error as BusinessError;
  363 + // promptAction.showToast({ message: `avRecorder stop error: ${JSON.stringify(err)}` })
372 } 364 }
373 } catch (error) { 365 } catch (error) {
374 - let err = error as BusinessError;  
375 - promptAction.showToast({ message: `avRecorder stop error: ${JSON.stringify(err)}` }) 366 + // let err = error as BusinessError;
  367 + // promptAction.showToast({ message: `avRecorder stop error: ${JSON.stringify(err)}` })
376 } 368 }
377 try { 369 try {
378 if (this.captureSession) { 370 if (this.captureSession) {
@@ -394,8 +386,8 @@ struct CreateCamera { @@ -394,8 +386,8 @@ struct CreateCamera {
394 this.captureSession = undefined; 386 this.captureSession = undefined;
395 } 387 }
396 } catch (error) { 388 } catch (error) {
397 - let err = error as BusinessError;  
398 - promptAction.showToast({ message: `avRecorder stop error: ${JSON.stringify(err)}` }) 389 + // let err = error as BusinessError;
  390 + // promptAction.showToast({ message: `avRecorder stop error: ${JSON.stringify(err)}` })
399 } 391 }
400 } 392 }
401 } 393 }
@@ -38,6 +38,7 @@ struct DetailRecords { @@ -38,6 +38,7 @@ struct DetailRecords {
38 @State maintenanceComment: string = '' 38 @State maintenanceComment: string = ''
39 @State isShowCloudDown: boolean = false 39 @State isShowCloudDown: boolean = false
40 aboutToAppear(): void { 40 aboutToAppear(): void {
  41 + AppStorage.setOrCreate('videoPath', '');
41 if(!AppStorage.get('isShowTip')) { 42 if(!AppStorage.get('isShowTip')) {
42 this.uploadController.open() 43 this.uploadController.open()
43 } 44 }
@@ -2,7 +2,7 @@ import AreaPickerDialog from '../dialog/AreaPickerDialog' @@ -2,7 +2,7 @@ import AreaPickerDialog from '../dialog/AreaPickerDialog'
2 import { companyTest, companyData } from '../api/userType' 2 import { companyTest, companyData } from '../api/userType'
3 import preferencesUtil from '../utils/preferences' 3 import preferencesUtil from '../utils/preferences'
4 import baseUrl from '../utils/baseUrl' 4 import baseUrl from '../utils/baseUrl'
5 -import { ValidateInputHandle } from '../utils/validateInputHandle' 5 +import { ValidateInputHandle, ValidateHandle } from '../utils/validateInputHandle'
6 import { updateCompanyInfo, getEmailCode, getCompanyInfo, emailType } from '../api/user' 6 import { updateCompanyInfo, getEmailCode, getCompanyInfo, emailType } from '../api/user'
7 import { promptAction } from '@kit.ArkUI'; 7 import { promptAction } from '@kit.ArkUI';
8 import { AxiosResponse } from '@ohos/axios' 8 import { AxiosResponse } from '@ohos/axios'
@@ -24,6 +24,7 @@ struct EditUser { @@ -24,6 +24,7 @@ struct EditUser {
24 @State initEmail: string = this.companyInfo.email 24 @State initEmail: string = this.companyInfo.email
25 @State codeStr: string = '' // 存储验证码对比 25 @State codeStr: string = '' // 存储验证码对比
26 @State timerCount: number = 300 26 @State timerCount: number = 300
  27 + formKey: string[] = ['companyName', 'email', 'postCode', 'linkMan', 'lmTel', 'businessLicenseNo', 'businessLicensePic', 'address']
27 // 区域选择 28 // 区域选择
28 areaController: CustomDialogController = new CustomDialogController({ 29 areaController: CustomDialogController = new CustomDialogController({
29 builder: AreaPickerDialog({ 30 builder: AreaPickerDialog({
@@ -55,6 +56,15 @@ struct EditUser { @@ -55,6 +56,15 @@ struct EditUser {
55 alignment: DialogAlignment.Top, 56 alignment: DialogAlignment.Top,
56 }) 57 })
57 58
  59 + // 校验函数
  60 + ValidateHandle = (arr: string[], obj: companyData): boolean => {
  61 + let keyArr: string[] = Object.keys(obj)
  62 + let valueArr: (string | number | null)[] = Object.values(obj)
  63 + for(let i = 0; i < keyArr.length; i++) {
  64 + if(arr.includes(keyArr[i]) && valueArr[i] == '') return false
  65 + }
  66 + return true
  67 + }
58 // 获取验证码 68 // 获取验证码
59 getCode = async () => { 69 getCode = async () => {
60 if(this.codeStr == '') { 70 if(this.codeStr == '') {
@@ -82,11 +92,10 @@ struct EditUser { @@ -82,11 +92,10 @@ struct EditUser {
82 92
83 // 提交修改 93 // 提交修改
84 submitForm = async () => { 94 submitForm = async () => {
85 - let valueArr = Object.values(this.companyInfo) as (string | null | number)[]  
86 - let isEmpty = valueArr.every(item => item !== '')  
87 - if(!isEmpty) return promptAction.showToast({message: '带星号的为必填项'}) 95 + if(!this.ValidateHandle(this.formKey, this.companyInfo)) return promptAction.showToast({message: '带星号的为必填项'})
88 if(!ValidateInputHandle(this.companyInfo.lmTel, 'phone')) return promptAction.showToast({message: '手机号输入有误'}) 96 if(!ValidateInputHandle(this.companyInfo.lmTel, 'phone')) return promptAction.showToast({message: '手机号输入有误'})
89 if(!ValidateInputHandle(this.companyInfo.email, 'email')) return promptAction.showToast({message: '邮箱输入有误'}) 97 if(!ValidateInputHandle(this.companyInfo.email, 'email')) return promptAction.showToast({message: '邮箱输入有误'})
  98 + if(!ValidateInputHandle(this.companyInfo.businessLicenseNo, 'businessLicenseNo')) return promptAction.showToast({message: '请正确填写社会信用代码'})
90 if(this.isShowCode && (this.companyInfo.code == '' || this.companyInfo.code == undefined)) return promptAction.showToast({message: '请输入验证码'}) 99 if(this.isShowCode && (this.companyInfo.code == '' || this.companyInfo.code == undefined)) return promptAction.showToast({message: '请输入验证码'})
91 if(this.isShowCode && this.companyInfo.code !== this.codeStr) return promptAction.showToast({message: '验证码输入有误'}) 100 if(this.isShowCode && this.companyInfo.code !== this.codeStr) return promptAction.showToast({message: '验证码输入有误'})
92 101
@@ -97,7 +106,10 @@ struct EditUser { @@ -97,7 +106,10 @@ struct EditUser {
97 promptAction.showToast({ message: '修改成功', duration: 2000 }) 106 promptAction.showToast({ message: '修改成功', duration: 2000 })
98 } 107 }
99 108
100 - aboutToAppear() { 109 + async aboutToAppear() {
  110 + const info: AxiosResponse<companyTest> = await getCompanyInfo()
  111 + preferencesUtil.set('XF_COMPANY_INFO', JSON.stringify(info.data.data))
  112 + this.companyInfo = JSON.parse(preferencesUtil.get('XF_COMPANY_INFO', '') as string)
101 this.companyInfo.address = this.pickerValue.join(' ') 113 this.companyInfo.address = this.pickerValue.join(' ')
102 } 114 }
103 build() { 115 build() {
@@ -119,6 +131,7 @@ struct EditUser { @@ -119,6 +131,7 @@ struct EditUser {
119 }.width(90) 131 }.width(90)
120 TextInput({placeholder: '请输入邮箱', text: $$this.companyInfo.email}) 132 TextInput({placeholder: '请输入邮箱', text: $$this.companyInfo.email})
121 .backgroundColor('#fff').layoutWeight(1).type(InputType.Email) 133 .backgroundColor('#fff').layoutWeight(1).type(InputType.Email)
  134 + .showError(ValidateInputHandle(this.companyInfo.email, 'email') ? '' : '请正确输入邮箱')
122 .onChange((value) => { this.isShowCode = this.initEmail !== value }) 135 .onChange((value) => { this.isShowCode = this.initEmail !== value })
123 }.border({width: {bottom: 1}, color: '#eee'}).padding({top: 10, bottom: 10}) 136 }.border({width: {bottom: 1}, color: '#eee'}).padding({top: 10, bottom: 10})
124 Row(){ 137 Row(){
@@ -150,6 +163,7 @@ struct EditUser { @@ -150,6 +163,7 @@ struct EditUser {
150 } 163 }
151 TextInput({placeholder: '请输入手机号', text: $$this.companyInfo.lmTel}) 164 TextInput({placeholder: '请输入手机号', text: $$this.companyInfo.lmTel})
152 .backgroundColor('#fff').layoutWeight(1).type(InputType.PhoneNumber) 165 .backgroundColor('#fff').layoutWeight(1).type(InputType.PhoneNumber)
  166 + .showError(ValidateInputHandle(this.companyInfo.lmTel, 'phone') ? '' : '请正确输入手机号')
153 }.border({width: {bottom: 1}, color: '#eee'}).padding({top: 10, bottom: 10}) 167 }.border({width: {bottom: 1}, color: '#eee'}).padding({top: 10, bottom: 10})
154 Row(){ 168 Row(){
155 Row(){ 169 Row(){
@@ -25,7 +25,11 @@ struct EditUser { @@ -25,7 +25,11 @@ struct EditUser {
25 @State initEmail: string = this.userInfo.email 25 @State initEmail: string = this.userInfo.email
26 @State codeStr: string = '' // 存储验证码对比 26 @State codeStr: string = '' // 存储验证码对比
27 @State timerCount: number = 300 27 @State timerCount: number = 300
28 - aboutToAppear() { 28 + formKey: string[] = ['personName', 'email', 'birthDate', 'idNo', 'phone', 'personalImg', 'idImgFront', 'idImgBack']
  29 + async aboutToAppear() {
  30 + const info: AxiosResponse<personTest> = await getPersonInfo()
  31 + preferencesUtil.set('XF_PERSON_INFO', JSON.stringify(info.data.data))
  32 + this.userInfo = JSON.parse(preferencesUtil.get('XF_PERSON_INFO', '') as string)
29 this.userInfo.address = this.pickerValue.join(' ') 33 this.userInfo.address = this.pickerValue.join(' ')
30 } 34 }
31 // 区域弹窗 35 // 区域弹窗
@@ -80,11 +84,20 @@ struct EditUser { @@ -80,11 +84,20 @@ struct EditUser {
80 }) 84 })
81 } 85 }
82 } 86 }
  87 +
  88 + // 校验函数
  89 + ValidateHandle = (arr: string[], obj: personData): boolean => {
  90 + let keyArr: string[] = Object.keys(obj)
  91 + let valueArr: (string | number | null)[] = Object.values(obj)
  92 + for(let i = 0; i < keyArr.length; i++) {
  93 + if(arr.includes(keyArr[i]) && valueArr[i] == '') return false
  94 + }
  95 + return true
  96 + }
  97 +
83 // 提交修改 98 // 提交修改
84 submitForm = async () => { 99 submitForm = async () => {
85 - let valueArr = Object.values(this.userInfo) as (string | null | number)[]  
86 - let isEmpty = valueArr.every(item => item !== '')  
87 - if(!isEmpty) return promptAction.showToast({message: '带星号的为必填项'}) 100 + if(!this.ValidateHandle(this.formKey, this.userInfo)) return promptAction.showToast({message: '带星号的为必填项'})
88 if(!ValidateInputHandle(this.userInfo.idNo, 'idCard')) return promptAction.showToast({message: '身份证输入有误'}) 101 if(!ValidateInputHandle(this.userInfo.idNo, 'idCard')) return promptAction.showToast({message: '身份证输入有误'})
89 if(!ValidateInputHandle(this.userInfo.phone, 'phone')) return promptAction.showToast({message: '手机号输入有误'}) 102 if(!ValidateInputHandle(this.userInfo.phone, 'phone')) return promptAction.showToast({message: '手机号输入有误'})
90 if(!ValidateInputHandle(this.userInfo.email, 'email')) return promptAction.showToast({message: '邮箱输入有误'}) 103 if(!ValidateInputHandle(this.userInfo.email, 'email')) return promptAction.showToast({message: '邮箱输入有误'})
@@ -32,10 +32,10 @@ struct FireProtectionDetail { @@ -32,10 +32,10 @@ struct FireProtectionDetail {
32 webviewController: webview.WebviewController = new webview.WebviewController() 32 webviewController: webview.WebviewController = new webview.WebviewController()
33 33
34 onPageShow() { 34 onPageShow() {
35 - let pathUrl = (router.getParams() as commonRouterParams)?.videoPath || ''  
36 - console.log('pathUrl', pathUrl)  
37 - if (pathUrl !== '' || pathUrl !== undefined || pathUrl !== null) { 35 + let pathUrl: string | null | undefined = AppStorage.get('videoPath')
  36 + if (pathUrl !== '' && pathUrl !== undefined && pathUrl !== null) {
38 this.uploadMethods(this.cosKeyStr, this.relateId, pathUrl, 'mp4') 37 this.uploadMethods(this.cosKeyStr, this.relateId, pathUrl, 'mp4')
  38 + AppStorage.set('videoPath', '')
39 } 39 }
40 } 40 }
41 aboutToAppear(): void { 41 aboutToAppear(): void {
@@ -140,7 +140,7 @@ struct FireProtectionDetail { @@ -140,7 +140,7 @@ struct FireProtectionDetail {
140 } else if(formatData[0] == '鸿蒙视频上传'){ 140 } else if(formatData[0] == '鸿蒙视频上传'){
141 // 使用相机录像 141 // 使用相机录像
142 if (checkAccessToken(this.permissions)) { 142 if (checkAccessToken(this.permissions)) {
143 - router.pushUrl({ url: 'pages/CreateCamera', params: this.projectInfo }) 143 + router.pushUrl({ url: 'pages/CreateCamera' })
144 } 144 }
145 } 145 }
146 return false 146 return false
@@ -68,12 +68,6 @@ struct MyWallet { @@ -68,12 +68,6 @@ struct MyWallet {
68 this.walletData = walletInfo.data.rows[0] 68 this.walletData = walletInfo.data.rows[0]
69 } 69 }
70 70
71 - // 获取是否显示充值  
72 - // getShowPay = async () => {  
73 - // const payInfo: AxiosResponse<beanType> = await getPay()  
74 - // this.isShowPay = payInfo.data.msg == "true"  
75 - // }  
76 -  
77 async aboutToAppear(){ 71 async aboutToAppear(){
78 Promise.all([ 72 Promise.all([
79 this.getList(), 73 this.getList(),
1 -import AreaPickerDialog from '../dialog/AreaPickerDialog'  
2 import { personData, personTest } from '../api/userType' 1 import { personData, personTest } from '../api/userType'
3 import baseUrl from '../utils/baseUrl' 2 import baseUrl from '../utils/baseUrl'
4 import { router } from '@kit.ArkUI'; 3 import { router } from '@kit.ArkUI';
5 import { AxiosResponse } from '@ohos/axios' 4 import { AxiosResponse } from '@ohos/axios'
6 import NavHeader from '../components/NavHeader' 5 import NavHeader from '../components/NavHeader'
7 import { getPersonDetail } from '../api/user' 6 import { getPersonDetail } from '../api/user'
  7 +import PhotoBrowser from '../dialog/PhotoBrowserDialog'
  8 +
  9 +
8 interface routerQuery { 10 interface routerQuery {
9 personId: number 11 personId: number
10 } 12 }
@@ -53,20 +55,20 @@ struct EditUser { @@ -53,20 +55,20 @@ struct EditUser {
53 companyId: 0, 55 companyId: 0,
54 } 56 }
55 @State pickerValue:string[] = ['广西壮族自治区','南宁市','青秀区']//省市区选中值 57 @State pickerValue:string[] = ['广西壮族自治区','南宁市','青秀区']//省市区选中值
56 - areaController: CustomDialogController = new CustomDialogController({  
57 - builder: AreaPickerDialog({  
58 - value:this.pickerValue,//首次默认选中值  
59 - onChange: (value:string[]) => {//选择改变回调  
60 - this.pickerValue = value  
61 - this.userInfo.address = this.pickerValue.join(' ')  
62 - }  
63 - }),  
64 - customStyle: true 58 + @State photoList: (string | ResourceStr)[] = [] // 预览图片列表
  59 +
  60 + // 图片预览
  61 + photoBrowserController: CustomDialogController = new CustomDialogController({
  62 + builder: PhotoBrowser({ imagesList: this.photoList}),
  63 + customStyle: true,
  64 + offset: { dx: 0, dy: 0 },
  65 + alignment: DialogAlignment.Top,
65 }) 66 })
66 67
67 async aboutToAppear(){ 68 async aboutToAppear(){
68 let res: AxiosResponse<personTest> = await getPersonDetail(personId) 69 let res: AxiosResponse<personTest> = await getPersonDetail(personId)
69 this.userInfo = res.data.data 70 this.userInfo = res.data.data
  71 + this.photoList = [baseUrl + this.userInfo.personalImg || $r('app.media.userAvatar'), baseUrl + this.userInfo.idImgFront || $r('app.media.idCard'), baseUrl + this.userInfo.idImgBack || $r('app.media.unIdCard')]
70 } 72 }
71 build() { 73 build() {
72 Column(){ 74 Column(){
@@ -134,7 +136,7 @@ struct EditUser { @@ -134,7 +136,7 @@ struct EditUser {
134 }.width(90) 136 }.width(90)
135 Row(){ 137 Row(){
136 Image(baseUrl + this.userInfo.personalImg || $r('app.media.userAvatar')).width(60) 138 Image(baseUrl + this.userInfo.personalImg || $r('app.media.userAvatar')).width(60)
137 - }.margin({left: 20}) 139 + }.margin({left: 20}).onClick(() => this.photoBrowserController.open())
138 }.border({width: {bottom: 1}, color: '#eee'}).padding({top: 10, bottom: 10}).width('100%') 140 }.border({width: {bottom: 1}, color: '#eee'}).padding({top: 10, bottom: 10}).width('100%')
139 .justifyContent(FlexAlign.SpaceBetween).height(80) 141 .justifyContent(FlexAlign.SpaceBetween).height(80)
140 Row(){ 142 Row(){
@@ -143,7 +145,7 @@ struct EditUser { @@ -143,7 +145,7 @@ struct EditUser {
143 }.width(90) 145 }.width(90)
144 Row(){ 146 Row(){
145 Image(baseUrl + this.userInfo.idImgFront || $r('app.media.idCard')).width(60) 147 Image(baseUrl + this.userInfo.idImgFront || $r('app.media.idCard')).width(60)
146 - }.margin({left: 20}) 148 + }.margin({left: 20}).onClick(() => this.photoBrowserController.open())
147 }.border({width: {bottom: 1}, color: '#eee'}).padding({top: 10, bottom: 10}).width('100%') 149 }.border({width: {bottom: 1}, color: '#eee'}).padding({top: 10, bottom: 10}).width('100%')
148 .justifyContent(FlexAlign.SpaceBetween).height(80) 150 .justifyContent(FlexAlign.SpaceBetween).height(80)
149 Row(){ 151 Row(){
@@ -152,7 +154,7 @@ struct EditUser { @@ -152,7 +154,7 @@ struct EditUser {
152 }.width(90) 154 }.width(90)
153 Row(){ 155 Row(){
154 Image(baseUrl + this.userInfo.idImgBack || $r('app.media.unIdCard')).width(60) 156 Image(baseUrl + this.userInfo.idImgBack || $r('app.media.unIdCard')).width(60)
155 - }.margin({left: 20}) 157 + }.margin({left: 20}).onClick(() => this.photoBrowserController.open())
156 }.border({width: {bottom: 1}, color: '#eee'}).padding({top: 10, bottom: 10}).width('100%') 158 }.border({width: {bottom: 1}, color: '#eee'}).padding({top: 10, bottom: 10}).width('100%')
157 .justifyContent(FlexAlign.SpaceBetween).height(80) 159 .justifyContent(FlexAlign.SpaceBetween).height(80)
158 Row(){ 160 Row(){
@@ -10,6 +10,7 @@ import { uploadFile, uploadResult } from '../utils/uploadFile' @@ -10,6 +10,7 @@ import { uploadFile, uploadResult } from '../utils/uploadFile'
10 import { uploadDocFile } from '../utils/uploadDocmentFile' 10 import { uploadDocFile } from '../utils/uploadDocmentFile'
11 import { request } from '@kit.BasicServicesKit' 11 import { request } from '@kit.BasicServicesKit'
12 import NavHeader from '../components/NavHeader' 12 import NavHeader from '../components/NavHeader'
  13 +import LoadingDialog from '../dialog/LoadingDialog'
13 14
14 15
15 @Entry 16 @Entry
@@ -53,6 +54,7 @@ struct Register { @@ -53,6 +54,7 @@ struct Register {
53 } 54 }
54 @State confirmPassword: string = '' 55 @State confirmPassword: string = ''
55 @State pickerValue:string[] = ['广西壮族自治区','南宁市','青秀区']//省市区选中值 56 @State pickerValue:string[] = ['广西壮族自治区','南宁市','青秀区']//省市区选中值
  57 + formKey: string[] = ['username', 'password', 'companyName', 'peopleNum', 'floorage', 'linkMan', 'email', 'lmTel', 'siteVoucher', 'businessLicenseNo', 'businessLicensePic']
56 dialogController: CustomDialogController = new CustomDialogController({ 58 dialogController: CustomDialogController = new CustomDialogController({
57 builder: CompanyCommit(), 59 builder: CompanyCommit(),
58 autoCancel: false, 60 autoCancel: false,
@@ -85,6 +87,23 @@ struct Register { @@ -85,6 +87,23 @@ struct Register {
85 this.idErrorMsg = res.data.total == 0 ? '' : '身份证号码已存在,请重新输入' 87 this.idErrorMsg = res.data.total == 0 ? '' : '身份证号码已存在,请重新输入'
86 } 88 }
87 89
  90 + // 校验函数
  91 + ValidateHandle = (arr: string[], obj: companyData): boolean => {
  92 + let keyArr: string[] = Object.keys(obj)
  93 + let valueArr: (string | number | null)[] = Object.values(obj)
  94 + for(let i = 0; i < keyArr.length; i++) {
  95 + if(arr.includes(keyArr[i]) && valueArr[i] == '') return false
  96 + }
  97 + return true
  98 + }
  99 + // 加载弹窗
  100 + loadingController: CustomDialogController = new CustomDialogController({
  101 + builder: LoadingDialog(),
  102 + customStyle: true,
  103 + offset: { dx: 0, dy: 0 },
  104 + alignment: DialogAlignment.Center,
  105 + autoCancel: false
  106 + })
88 async aboutToAppear() { 107 async aboutToAppear() {
89 this.dialogController.open() 108 this.dialogController.open()
90 this.companyInfo.address = this.pickerValue.join(' ') 109 this.companyInfo.address = this.pickerValue.join(' ')
@@ -196,6 +215,7 @@ struct Register { @@ -196,6 +215,7 @@ struct Register {
196 .backgroundColor('#1890ff').fontColor('#fff').borderRadius(4) 215 .backgroundColor('#1890ff').fontColor('#fff').borderRadius(4)
197 .onClick(async () => { 216 .onClick(async () => {
198 let that = this 217 let that = this
  218 + that.loadingController.open()
199 let uploader = await uploadDocFile() as request.UploadTask 219 let uploader = await uploadDocFile() as request.UploadTask
200 // 3. 监控上传错误 220 // 3. 监控上传错误
201 uploader.on('fail', (err) => { 221 uploader.on('fail', (err) => {
@@ -205,6 +225,8 @@ struct Register { @@ -205,6 +225,8 @@ struct Register {
205 uploader.on('headerReceive',(res)=>{ 225 uploader.on('headerReceive',(res)=>{
206 let uploadInfo = JSON.parse(res['body']) as uploadResult 226 let uploadInfo = JSON.parse(res['body']) as uploadResult
207 that.companyInfo.siteVoucher = uploadInfo.fileName as string 227 that.companyInfo.siteVoucher = uploadInfo.fileName as string
  228 + that.loadingController.close()
  229 + promptAction.showToast({message: '上传成功'})
208 }) 230 })
209 }) 231 })
210 Button('查看文件').controlSize(ControlSize.SMALL).type(ButtonType.Normal) 232 Button('查看文件').controlSize(ControlSize.SMALL).type(ButtonType.Normal)
@@ -283,11 +305,10 @@ struct Register { @@ -283,11 +305,10 @@ struct Register {
283 Text('提交').borderRadius(5).layoutWeight(1).height(30).fontColor('#fff') 305 Text('提交').borderRadius(5).layoutWeight(1).height(30).fontColor('#fff')
284 .backgroundColor('#1B65FD').fontSize(14).textAlign(TextAlign.Center) 306 .backgroundColor('#1B65FD').fontSize(14).textAlign(TextAlign.Center)
285 .onClick(async () => { 307 .onClick(async () => {
  308 + if(!this.ValidateHandle(this.formKey, this.companyInfo)) return promptAction.showToast({message: '带星号的为必填项'})
286 if(this.confirmPassword !== this.companyInfo.password) return promptAction.showToast({message: '两次密码输入不一致'}) 309 if(this.confirmPassword !== this.companyInfo.password) return promptAction.showToast({message: '两次密码输入不一致'})
287 if(!ValidateInputHandle(this.companyInfo.lmTel, 'phone')) return promptAction.showToast({message: '手机号输入有误'}) 310 if(!ValidateInputHandle(this.companyInfo.lmTel, 'phone')) return promptAction.showToast({message: '手机号输入有误'})
288 if(!ValidateInputHandle(this.companyInfo.email, 'email')) return promptAction.showToast({message: '邮箱输入有误'}) 311 if(!ValidateInputHandle(this.companyInfo.email, 'email')) return promptAction.showToast({message: '邮箱输入有误'})
289 - let ValuesArr = Object.values(this.companyInfo) as (string | number | null)[]  
290 - if(!ValuesArr.every(item => item !== '')) return promptAction.showToast({message: '带型号的为必填项'})  
291 await companyRegister(this.companyInfo) 312 await companyRegister(this.companyInfo)
292 promptAction.showToast({ message: '注册成功' }) 313 promptAction.showToast({ message: '注册成功' })
293 router.back() 314 router.back()
@@ -42,6 +42,7 @@ struct UserRegister { @@ -42,6 +42,7 @@ struct UserRegister {
42 @State initEmail: string = this.userInfo.email 42 @State initEmail: string = this.userInfo.email
43 @State confirmPassword: string = '' 43 @State confirmPassword: string = ''
44 private selectedDate: Date = new Date('2000-01-01') 44 private selectedDate: Date = new Date('2000-01-01')
  45 + formKey: string[] = ['username', 'password', 'personName', 'birthDate', 'idNo', 'phone', 'personalImg', 'idImgFront', 'idImgBack']
45 dialogController: CustomDialogController = new CustomDialogController({ 46 dialogController: CustomDialogController = new CustomDialogController({
46 builder: UserCommit(), 47 builder: UserCommit(),
47 autoCancel: false, 48 autoCancel: false,
@@ -66,8 +67,21 @@ struct UserRegister { @@ -66,8 +67,21 @@ struct UserRegister {
66 } 67 }
67 // 查身份证是否被占用 68 // 查身份证是否被占用
68 queryId = async (id: string) => { 69 queryId = async (id: string) => {
69 - const res: AxiosResponse<queryIdNoType> = await queryIdNo(id)  
70 - this.idErrorMsg = res.data.total == 0 ? '' : '身份证号码已存在,请重新输入' 70 + if(id === '') {
  71 + this.idErrorMsg = '请输入身份证号'
  72 + } else {
  73 + const res: AxiosResponse<queryIdNoType> = await queryIdNo(id)
  74 + this.idErrorMsg = res.data.total == 0 ? '' : '身份证号码已存在,请重新输入'
  75 + }
  76 + }
  77 + // 校验函数
  78 + ValidateHandle = (arr: string[], obj: personData): boolean => {
  79 + let keyArr: string[] = Object.keys(obj)
  80 + let valueArr: (string | number | null)[] = Object.values(obj)
  81 + for(let i = 0; i < keyArr.length; i++) {
  82 + if(arr.includes(keyArr[i]) && valueArr[i] == '') return false
  83 + }
  84 + return true
71 } 85 }
72 async aboutToAppear() { 86 async aboutToAppear() {
73 this.dialogController.open() 87 this.dialogController.open()
@@ -282,12 +296,11 @@ struct UserRegister { @@ -282,12 +296,11 @@ struct UserRegister {
282 Text('提交').borderRadius(5).layoutWeight(1).height(30).fontColor('#fff') 296 Text('提交').borderRadius(5).layoutWeight(1).height(30).fontColor('#fff')
283 .backgroundColor('#1B65FD').fontSize(14).textAlign(TextAlign.Center) 297 .backgroundColor('#1B65FD').fontSize(14).textAlign(TextAlign.Center)
284 .onClick(async () => { 298 .onClick(async () => {
  299 + if(!this.ValidateHandle(this.formKey, this.userInfo)) return promptAction.showToast({message: '带星号的为必填项'})
285 if(this.confirmPassword !== this.userInfo.password) return promptAction.showToast({message: '两次密码输入不一致'}) 300 if(this.confirmPassword !== this.userInfo.password) return promptAction.showToast({message: '两次密码输入不一致'})
286 if(!ValidateInputHandle(this.userInfo.idNo, 'idCard')) return promptAction.showToast({message: '身份证输入有误'}) 301 if(!ValidateInputHandle(this.userInfo.idNo, 'idCard')) return promptAction.showToast({message: '身份证输入有误'})
287 if(!ValidateInputHandle(this.userInfo.phone, 'phone')) return promptAction.showToast({message: '手机号输入有误'}) 302 if(!ValidateInputHandle(this.userInfo.phone, 'phone')) return promptAction.showToast({message: '手机号输入有误'})
288 if(!ValidateInputHandle(this.userInfo.email, 'email')) return promptAction.showToast({message: '邮箱输入有误'}) 303 if(!ValidateInputHandle(this.userInfo.email, 'email')) return promptAction.showToast({message: '邮箱输入有误'})
289 - let valuesArr = Object.values(this.userInfo) as (string | number)[]  
290 - if(!valuesArr.every(item => item !== '')) return promptAction.showToast({message: '带星号的为必填项'})  
291 await userRegister(this.userInfo) 304 await userRegister(this.userInfo)
292 promptAction.showToast({ message: '注册成功' }) 305 promptAction.showToast({ message: '注册成功' })
293 router.back() 306 router.back()
@@ -12,7 +12,7 @@ export async function reqPermissionsFromUser(permissions: Array<Permissions>, co @@ -12,7 +12,7 @@ export async function reqPermissionsFromUser(permissions: Array<Permissions>, co
12 if(grantStatus.every((numberItem: number) => numberItem === 0)){ 12 if(grantStatus.every((numberItem: number) => numberItem === 0)){
13 promptAction.showToast({message: '授权成功'}) 13 promptAction.showToast({message: '授权成功'})
14 } else { 14 } else {
15 - promptAction.showToast({message: '用户已取消授权'}) 15 + console.log('用户已取消授权')
16 } 16 }
17 } catch (err) { 17 } catch (err) {
18 promptAction.showToast({message: `Failed to request permissions from user. Code is ${err.code}, message is ${err.message}`}) 18 promptAction.showToast({message: `Failed to request permissions from user. Code is ${err.code}, message is ${err.message}`})
@@ -27,7 +27,7 @@ export function checkAccessToken(permissions: Array<Permissions>): boolean { @@ -27,7 +27,7 @@ export function checkAccessToken(permissions: Array<Permissions>): boolean {
27 try { 27 try {
28 return permissions.every((permissionItem: Permissions) => atManager.verifyAccessTokenSync(callerTokenId, permissionItem) !== -1) 28 return permissions.every((permissionItem: Permissions) => atManager.verifyAccessTokenSync(callerTokenId, permissionItem) !== -1)
29 } catch (err) { 29 } catch (err) {
30 - promptAction.showToast({message: `checkAccessToken catch err->${JSON.stringify(err)}`}) 30 + console.log(`checkAccessToken catch err->${JSON.stringify(err)}`)
31 return false 31 return false
32 } 32 }
33 } 33 }
@@ -111,7 +111,7 @@ export async function uploadFile() { @@ -111,7 +111,7 @@ export async function uploadFile() {
111 try { 111 try {
112 let systemPhotoImagePath = await selectImg() // 选择图片 112 let systemPhotoImagePath = await selectImg() // 选择图片
113 // let systemPhotoImagePath = await cameraPickerImg() // 使用相机拍照 113 // let systemPhotoImagePath = await cameraPickerImg() // 使用相机拍照
114 - if(systemPhotoImagePath == '') return promptAction.showToast({message: '未选择图片'}) 114 + if(systemPhotoImagePath === '' || systemPhotoImagePath === undefined || systemPhotoImagePath === null) return promptAction.showToast({message: '未选择图片'})
115 const fileData: string[] = await copyCachePath(systemPhotoImagePath) 115 const fileData: string[] = await copyCachePath(systemPhotoImagePath)
116 let uploader = await request.uploadFile(getContext(),{ // 上传图片 116 let uploader = await request.uploadFile(getContext(),{ // 上传图片
117 url:'http://xfwbzshd.crgx.net/common/upload', // 请求地址 117 url:'http://xfwbzshd.crgx.net/common/upload', // 请求地址
@@ -29,3 +29,34 @@ export function ValidateInputHandle(input: string, type: typeValue): boolean { @@ -29,3 +29,34 @@ export function ValidateInputHandle(input: string, type: typeValue): boolean {
29 throw new Error("传入的参数有误!") 29 throw new Error("传入的参数有误!")
30 } 30 }
31 } 31 }
  32 +
  33 +
  34 +// 校验函数
  35 +export function ValidateHandle(arr: string[], obj: Record<string, (string | number | null)>): boolean {
  36 + let keyArr: string[] = Object.keys(obj)
  37 + let valueArr = Object.values(obj) as (string | number | null )[]
  38 + for(let i = 0; i < keyArr.length; i++) {
  39 + console.log(keyArr[i], valueArr[i])
  40 + if(arr.includes(keyArr[i]) && valueArr[i] === '') return false
  41 + }
  42 + return true
  43 +}
  44 +
  45 +interface objType {
  46 + username: string;
  47 + password: string;
  48 + phone: string;
  49 + email: string;
  50 + businessLicenseNo: string;
  51 + idCard: number;
  52 +}
  53 +
  54 +let arrNew = ['username', 'password', 'phone', 'email', 'businessLicenseNo', 'idCard']
  55 +let objNew: objType = {
  56 + username: '',
  57 + password: '',
  58 + phone: '',
  59 + email: '',
  60 + businessLicenseNo: '',
  61 + idCard: 1234
  62 +}