作者 xiaoqiu

优化了录制上传回显问题,增加了项目区域和综合评述

不能预览此文件类型
... ... @@ -157,6 +157,8 @@ export interface addParamsType {
technicalDirector?: string | null
technicalDirectorId?: string
undeGroundLayers?: string | null
city?: string
county?: string
}
export interface projectType{
... ... @@ -206,8 +208,8 @@ export interface reportDetailData {
allowPerson?: null;
state: string;
reportType: string;
city?: null;
county?: null;
city?: string;
county?: string;
projectNature?: null;
reportTime: string;
contractId?: null;
... ...
... ... @@ -2,7 +2,8 @@ import { useCascadeAreaData } from '../utils/getArea'
@Component
export default struct AreaPicker {
@State cascade: TextCascadePickerRangeContent[] = useCascadeAreaData() //省市区列表数据
@Prop provinceValue: string
@State cascade: TextCascadePickerRangeContent[] = useCascadeAreaData(this.provinceValue) //省市区列表数据
@Link value: string[] //选中值例如:['北京市','北京市','东城区']
private onChange: (value: string[], index: number[]) => void = () => {
} //选择改变回调函数
... ...
... ... @@ -4,6 +4,7 @@ import AreaPicker from '../components/AreaPicker'
export default struct AreaPickerDialog {
private dialogController: CustomDialogController //弹窗控制器
@State value: string[] = [] //选中值
@Prop provinceValue: string = '' // 单选某个省份是市、区/县
//确认关闭选择改变回调
onChange: (value: string[]) => void = () => {
}
... ... @@ -13,7 +14,7 @@ export default struct AreaPickerDialog {
//记录打开时候的默认值
this.defaultValue = this.value
if (Array.isArray(this.value) && this.value.length < 3) {
this.value = ['北京市', '北京市', '东城区']; //设置默认值
this.value = ['广西壮族自治区','南宁市','青秀区']; //设置默认值
}
}
... ... @@ -41,7 +42,7 @@ export default struct AreaPickerDialog {
.justifyContent(FlexAlign.SpaceBetween)
//地区选择器
AreaPicker({ value: this.value })
AreaPicker({ value: this.value, provinceValue: this.provinceValue })
}
.backgroundColor(Color.White)
.borderRadius(24)
... ...
... ... @@ -11,7 +11,7 @@ import {
} from '@csj/openadsdk'
import { UIUtil } from '../mediation_adtype/tools/UIUtil'
import { PrintBiddingTokenUtils } from '../mediation_adtype/test/PrintBiddintTokenUtils'
import { window, promptAction, router } from '@kit.ArkUI'
import { window, router } from '@kit.ArkUI'
import { DemoConstants } from '../entryability/DemoConstants'
import('./SplashAdShowPage')
... ... @@ -100,7 +100,11 @@ export struct SplashAdDemoPage {
}
aboutToAppear(){
let adSlot = new AdSlotBuilder()
<<<<<<< HEAD
.setCodeId("103438700")
=======
.setCodeId("103397742")
>>>>>>> 2191e70067b776ee401629441f16bd4644393902
.setAcceptSize(adWidth,
adHeight)
.build()
... ... @@ -149,14 +153,17 @@ export struct SplashAdDemoPage {
onDidClick: () => {
console.log("开屏回调 - onDidClick")
router.pushUrl({ url: "pages/Login"})
this.closeWin()
},
onVideoDidPlayFinish: () => {
console.log("开屏回调 - onVideoDidPlayFinish")
this.closeWin()
},
onVideoDidPlayFail: () => {
console.log("开屏回调 - onVideoDidPlayFail")
this.closeWin()
}
}
}
\ No newline at end of file
... ...
... ... @@ -12,14 +12,26 @@ import {
RecordsList
} from '../api/recordsType'
import NavHeader from '../components/NavHeader'
import AreaPickerDialog from '../dialog/AreaPickerDialog'
import LoadingDialog from '../dialog/LoadingDialog'
import { quarterType, quarterTest } from '../api/options/optionsType'
import { getMaintenanceType, getLatestProjectList, getEquipmentList, addRecords, getCompanyPersonList, getReportDetail, updateRecords, getRecordsList } from '../api/originalRecords'
import { AxiosResponse } from '@ohos/axios'
import preferencesUtil from '../utils/preferences'
import { router, promptAction } from '@kit.ArkUI'
import { Color } from '@ohasasugar/hp-richtext/src/main/ets/common/types/artUIEnum'
interface routerParams {
reportId: number
}
interface comprehensiveType {
range: string;
facility: string;
existingProblem: string;
cumulativeIssues: string;
correctedProblems: string;
other: string;
}
let params = router.getParams() as routerParams
let reportId: number | undefined = params?.reportId
// 查看原始记录编号是否存在
... ... @@ -45,9 +57,54 @@ function searchByIndexOf(keyWord: string, list: equipmentType[]){
return arr;
}
// 提取的富文本内容分别赋值
function multiply(range: string, facility: string, existingProblem: string,cumulativeIssues:string, correctedProblems: string, ...other: string[]){
let otherValue: string = other.length > 1 ? other?.slice(1).join('、') : other[0].slice(3)
let newObj:comprehensiveType = {
range: range.split(':')[1],
facility: facility.split(':')[1],
existingProblem: existingProblem.split(':')[1],
cumulativeIssues: cumulativeIssues.split(':')[1],
correctedProblems: correctedProblems.split(':')[1],
other: otherValue
}
return newObj
}
// 提取富文本中的内容解析后导出
function extractRichText(str: string): comprehensiveType{
let richText = str.replace(/<.*?>/g, '?')
let arrValue: string[] = richText.split('?').filter(item => item !== '')
let otherArr: string[] = []
if(arrValue.length > 5){
for (let index = 5; index < arrValue.length; index++) {
otherArr.push(arrValue[index])
}
}
return multiply(arrValue[0], arrValue[1], arrValue[2], arrValue[3], arrValue[4], ...otherArr)
}
// 提交修改时合并富文本内容
function mergeRichText(comprehensive: comprehensiveType): string{
let resStr = `<div>${'本月维保范围:' + comprehensive.range}</div><div style="margin-top: 6px;">${'维保设施包含:' + comprehensive.facility}</div><div style="margin-top: 6px;">${'存在问题:' + comprehensive.existingProblem}</div><div style="margin-top: 6px;">${'累计问题:' + comprehensive.cumulativeIssues}</div><div style="margin-top: 6px;">${'已整改问题:' + comprehensive.correctedProblems}</div>`
if (comprehensive.other) {
resStr += `<div style="margin-top: 6px;">${'其他:' + comprehensive.other}</div>`
}
return resStr
}
@Extend(Text) function TitleReview () {
.fontColor('#000').fontSize(14).fontWeight(500)
}
@Extend(TextInput) function TextInputReview () {
.width('100%').height(40).fontSize(14).fontColor('#999')
.border({width: 1, color: '#eee'}).backgroundColor(Color.Transparent)
.placeholderColor('#999').borderRadius(4).placeholderFont({size: 14})
}
@Entry
@Component
struct EditUser {
struct AddRecords {
@Builder indicatorBuilder(icon: ResourceStr) {
Image(icon)
}
... ... @@ -75,9 +132,19 @@ struct EditUser {
technicalDirectorId: ''
}
personId = preferencesUtil.get('XF_PERSON_ID', 0)
@State pickerValue:string[] = ['广西壮族自治区','南宁市','青秀区']//省市区选中值
@State comprehensiveReview: comprehensiveType = {
range: '',
facility: '',
existingProblem: '',
cumulativeIssues: '',
other: '',
correctedProblems: '',
}
// 回显数据使用
@State viewEquipmentList: string[] = []
@State fireFacilitiesList: string[] = []
// 维保人员列表
@State PeopleList: string[] = []
@State isEdit: boolean = false
// 公司在职人员列表
... ... @@ -119,6 +186,8 @@ struct EditUser {
this.fireFacilitiesList = this.addForm.fireFacilities.split('、')
this.viewEquipmentList = result.equipment.split(',')
this.PeopleList = result.technicalDirectorId?.split(',') || []
this.pickerValue = ['广西壮族自治区', result.city as string, result.county as string]
this.comprehensiveReview = extractRichText(result.result)
}
getMaintenanceType().then((res: AxiosResponse<quarterTest>) => {
this.recordsType = res.data.data
... ... @@ -145,6 +214,28 @@ struct EditUser {
@State space: number = 8
@State arrowPosition: ArrowPosition = ArrowPosition.END
// 选择区域弹窗
areaController: CustomDialogController = new CustomDialogController({
builder: AreaPickerDialog({
value:this.pickerValue,//首次默认选中值
provinceValue: '广西壮族自治区',
onChange: (value:string[]) => {//选择改变回调
this.pickerValue = value
this.addForm.city = value[1]
this.addForm.county = value[2]
}
}),
customStyle: true
})
// 加载弹窗
loadingController: CustomDialogController = new CustomDialogController({
builder: LoadingDialog(),
customStyle: true,
offset: { dx: 0, dy: 0 },
alignment: DialogAlignment.Center,
autoCancel: false
})
build() {
Column(){
NavHeader({title: '添加原始记录'})
... ... @@ -168,20 +259,25 @@ struct EditUser {
}.width(90)
Row({ space: 5 }){
TextInput({placeholder: '请输入项目编号', text: $$this.addForm.reportNo})
.backgroundColor('#fff').showError(this.errorMsg).onBlur(async () => {
this.errorMsg = await queryReportNo(this.addForm.reportNo as string) ? '此原始记录编号已被使用' : ''
})
.backgroundColor('#fff').showError(this.errorMsg)
.onBlur(async () => {
if(this.addForm.reportNo == '') {
this.errorMsg = '请输入项目编号'
} else {
this.errorMsg = await queryReportNo(this.addForm.reportNo as string) ? '此原始记录编号已被使用' : ''
}
})
}.layoutWeight(1)
}.border({width: {bottom: 1}, color: '#eee'}).padding({top: 10, bottom: 10})
.visibility(this.isEdit ? Visibility.None : Visibility.Visible)
// 编辑状态下项目编号不可修改
Row(){
Row(){
Image($r('app.media.require')).width(20)
Text('项目编号')
}.width(90)
Row({ space: 5 }){
Text(this.addForm.reportNo).fontColor('#c0c4cc')
.fontSize(16).padding({top: 8, bottom: 8, left: 16, right: 16})
Text(this.addForm.reportNo).padding({top: 8, bottom: 8, left: 16, right: 16})
}.layoutWeight(1)
}.border({width: {bottom: 1}, color: '#eee'}).padding({top: 10, bottom: 10})
.visibility(this.isEdit ? Visibility.Visible : Visibility.None)
... ... @@ -294,16 +390,17 @@ struct EditUser {
}.justifyContent(FlexAlign.Start).width('100%')
TextInput({placeholder: '请输入消防设施管理单位', text: $$this.addForm.applyCompanyName})
.backgroundColor('#fff')
}.border({width: {bottom: 1}, color: '#eee'}).padding({top: 10, bottom: 10})
}.border({width: {bottom: 1}, color: '#eee'}).padding({top: 10})
Row(){
Row(){
Text('备注')
}.width(100)
TextArea({
text: $$this.addForm.result,
placeholder: '请输入内容'
}).layoutWeight(1).height(80).borderRadius(5).backgroundColor('#fff')
.border({width: 1, color: "#eee"})
Image($r('app.media.require')).width(20)
Text('项目区域')
}.width(90)
Text(this.pickerValue.join(' ')).layoutWeight(1).padding({top: 8, bottom: 8, left: 16, right: 16})
.backgroundColor('#fff').textOverflow({overflow: TextOverflow.Ellipsis}).maxLines(2)
.onClick(() => {
this.areaController?.open()
})
}.border({width: {bottom: 1}, color: '#eee'}).padding({top: 10, bottom: 10})
Column(){
Row(){
... ... @@ -351,6 +448,7 @@ struct EditUser {
.selectedColor('#1890ff')
.onChange((itemName: CheckboxGroupResult) => {
this.addForm.fireFacilities = itemName.name.join('、')
this.comprehensiveReview.facility = itemName.name.join('、')
})
.mark({
strokeColor:Color.White,
... ... @@ -411,45 +509,82 @@ struct EditUser {
this.equipmentList = searchByIndexOf(value, this.initEquipmentList) as equipmentType[]
}
})
}.width('100%').justifyContent(FlexAlign.Start)
Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center, wrap: FlexWrap.Wrap }) {
Row(){
CheckboxGroup({ group: 'checkboxGroup2' })
.checkboxShape(CheckBoxShape.ROUNDED_SQUARE)
.selectedColor('#1890ff')
.onChange((itemName: CheckboxGroupResult) => {
this.addForm.equipmentList = itemName.name
this.addForm.equipment = itemName.name.join(',')
})
.mark({
strokeColor:Color.White,
size: 12,
strokeWidth: 2
}.width('100%').justifyContent(FlexAlign.Start).padding({left: 10})
List(){
ListItem(){
Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center, wrap: FlexWrap.Wrap }) {
Row(){
CheckboxGroup({ group: 'checkboxGroup2' })
.checkboxShape(CheckBoxShape.ROUNDED_SQUARE)
.selectedColor('#1890ff')
.onChange((itemName: CheckboxGroupResult) => {
this.addForm.equipmentList = itemName.name
this.addForm.equipment = itemName.name.join(',')
})
.mark({
strokeColor:Color.White,
size: 12,
strokeWidth: 2
})
.unselectedColor('#eee')
.width(15)
.height(15)
Text('选择全部').fontSize(14)
}.margin({right: 10})
ForEach(this.equipmentList, (children: equipmentType) => {
Row(){
Checkbox({ name: children.equipmentName, group: 'checkboxGroup2' })
.selectedColor('#1890ff')
.select(this.viewEquipmentList.includes(children.equipmentName))
.shape(CheckBoxShape.ROUNDED_SQUARE)
.mark({
strokeColor:Color.White,
size: 12,
strokeWidth: 2
})
.unselectedColor('#eee')
.width(15)
.height(15)
Text(children.equipmentName).fontSize(14)
}.margin({right: 10})
})
.unselectedColor('#eee')
.width(15)
.height(15)
Text('选择全部').fontSize(14)
}.margin({right: 10})
ForEach(this.equipmentList, (children: equipmentType) => {
Row(){
Checkbox({ name: children.equipmentName, group: 'checkboxGroup2' })
.selectedColor('#1890ff')
.select(this.viewEquipmentList.includes(children.equipmentName))
.shape(CheckBoxShape.ROUNDED_SQUARE)
.mark({
strokeColor:Color.White,
size: 12,
strokeWidth: 2
})
.unselectedColor('#eee')
.width(15)
.height(15)
Text(children.equipmentName).fontSize(14)
}.margin({right: 10})
})
}.margin({right:15})
}.border({width: {bottom: 1}, color: '#eee'}).padding({top: 10, bottom: 10})
}.margin({right:15})
}.border({width: {bottom: 1}, color: '#eee'})
}.height(300).width('100%')
}.padding({top: 10, bottom: 10})
Column({space: 10}){
Row(){
Text().width(4).height(16).backgroundColor('#1890ff').margin({right: 6})
Text('综合评述')
}.padding({left: 10})
Column({space: 10}){
Column({space: 10}){
Text('本月维保范围').TitleReview()
TextInput({placeholder: '请输入本月维保范围(填写楼层)', text: $$this.comprehensiveReview.range}).TextInputReview()
}.width('100%').alignItems(HorizontalAlign.Start)
Column({space: 10}){
Text('消防设施包含').TitleReview()
Text(this.comprehensiveReview.facility || '勾选主要消防设施').width('100%').height(40).fontSize(14).padding({top: 8, bottom: 8, left: 16, right: 16})
.border({width: 1, color: '#eee'}).borderRadius(4).fontColor('#999').textAlign(TextAlign.Start)
}.width('100%').alignItems(HorizontalAlign.Start)
Column({space: 10}){
Text('存在问题').TitleReview()
TextInput({placeholder: '请输入存在问题', text: this.comprehensiveReview.existingProblem}).TextInputReview()
}.width('100%').alignItems(HorizontalAlign.Start)
Column({space: 10}){
Text('累计问题').TitleReview()
TextInput({placeholder: '请输入累计问题', text: $$this.comprehensiveReview.cumulativeIssues}).TextInputReview()
}.width('100%').alignItems(HorizontalAlign.Start)
Column({space: 10}){
Text('已整改问题').TitleReview()
TextInput({placeholder: '请输入已整改问题', text: $$this.comprehensiveReview.correctedProblems}).TextInputReview()
}.width('100%').alignItems(HorizontalAlign.Start)
Column({space: 10}){
Text('其他').TitleReview()
TextInput({placeholder: '其他内容', text: $$this.comprehensiveReview.other}).TextInputReview()
}.width('100%').alignItems(HorizontalAlign.Start)
}
}.width('100%').alignItems(HorizontalAlign.Start).margin({top: 20}).padding({bottom: 30})
}.backgroundColor('#fff').width('100%').padding({left: 5, right: 5}).borderRadius(10)
}.padding(10).margin({bottom: 20, top: 10})
}.layoutWeight(1).scrollBar(BarState.Off)
... ... @@ -477,14 +612,18 @@ struct EditUser {
return promptAction.showToast({message: '本人必须在维护人员中'})
}
if(this.isEdit){
console.log(JSON.stringify(this.addForm))
this.loadingController.open()
this.addForm.result = mergeRichText(this.comprehensiveReview)
await updateRecords(this.addForm)
this.loadingController.close()
promptAction.showToast({
message: '更新成功'
})
} else {
this.loadingController.open()
this.addForm.maintenanceDate = [this.addForm.maintenanceTime as string, this.addForm.maintenanceEndTime as string]
await addRecords(this.addForm)
this.loadingController.close()
promptAction.showToast({
message: '添加成功'
})
... ...
... ... @@ -4,20 +4,15 @@ import { BusinessError } from '@ohos.base';
import { promptAction, router } from '@kit.ArkUI'
import { common } from '@kit.AbilityKit';
import { FileUtil, CommonConstants } from '../utils/FileUtil';
import { uploadFileByTask } from '../utils/uploadCloud'
// import { uploadFileByTask } from '../utils/uploadCloud'
import { commonRouterParams } from '../utils/UserAuth'
/**
* 视频录制
*/
interface routerParams {
cosKeyStr: string;
relateId: number;
}
const TAG: string = 'Record';
let context = getContext(this) as common.UIAbilityContext;
let routerParamsData: routerParams = router.getParams() as routerParams;
let routerParamsData: commonRouterParams = router.getParams() as commonRouterParams;
@Entry
@Component
struct CreateCamera {
... ... @@ -70,21 +65,30 @@ struct CreateCamera {
if (this.recording) {
clearInterval(this.timer);
this.timer = 0
promptAction.showToast({ message: '已完成录制,开始上传' })
await this.stopRecord();
await uploadFileByTask(routerParamsData.cosKeyStr, routerParamsData.relateId, this.path);
router.back()
routerParamsData.videoPath = this.path;
router.back({
url:'',
params: routerParamsData
})
} else {
promptAction.showToast({ message: '已开始录制,再次点击完成录制' })
this.timer = setInterval(async () => {
this.countTime++;
if(this.countTime >= 120){
clearInterval(this.timer);
this.timer = 0
promptAction.showToast({ message: '已完成录制,开始上传' })
await this.stopRecord();
await uploadFileByTask(routerParamsData.cosKeyStr, routerParamsData.relateId, this.path);
router.back()
routerParamsData.videoPath = this.path;
router.back({
url:'',
params: routerParamsData
})
}
}, 1000);
this.startRecord();
await this.startRecord();
}
this.recording = !this.recording;
})
... ...
... ... @@ -10,9 +10,11 @@ import UploadTipDialog from '../dialog/UploadTipDialog'
import { getReportDetail, getMalfunctionList, deleteRecords, successReport, returnSing } from '../api/originalRecords'
import { reportDetailTest, reportDetailData, ProjectList, ItemList, MalfunctionListTest, MalfunctionListRow, configTest } from '../api/recordsType'
import { pushOutsideWeb } from '../utils/pushOutsideWeb'
import { commonRouterParams } from '../utils/UserAuth'
import ThemeStaticTest from '../components/ThemeStaticText'
import NavHeader from '../components/NavHeader'
interface showVideoOrImg {
cosKey: string | null;
itemName: string;
... ... @@ -157,7 +159,11 @@ struct DetailRecords {
}.border({width: {bottom: 1}, color: '#eee'}).padding(10).justifyContent(FlexAlign.SpaceBetween).width('100%')
Row(){
Text('项目负责人').fontSize(12).fontColor('#999')
Text(this.reportDetail?.approvePerson || '').fontColor('#999').fontSize(12).margin({left: 3, right: 3})
Text(this.reportDetail?.approvePerson).fontColor('#999').fontSize(12).margin({left: 3, right: 3})
}.border({width: {bottom: 1}, color: '#eee'}).padding(10).justifyContent(FlexAlign.SpaceBetween).width('100%')
Row(){
Text('项目区域').fontSize(12).fontColor('#999')
Text(`${this.reportDetail?.city} ${this.reportDetail?.county}`).fontColor('#999').fontSize(12).margin({left: 3, right: 3})
}.border({width: {bottom: 1}, color: '#eee'}).padding(10).justifyContent(FlexAlign.SpaceBetween).width('100%')
Row(){
Text('维保人员').fontSize(12).fontColor('#999')
... ... @@ -197,14 +203,14 @@ struct DetailRecords {
Text('仪器设备').fontSize(12).fontColor('#999')
Text(this.reportDetail?.equipment || '').fontColor('#999').fontSize(12).margin({left: 3, right: 3})
}.border({width: {bottom: 1}, color: '#eee'}).padding(10).alignItems(HorizontalAlign.Start).width('100%')
Row(){
Text('备注').fontSize(12).fontColor('#999').margin({right: 10})
Column({space: 10}){
Text('综合评述').fontSize(12).fontColor('#999').margin({right: 10})
HmParseHTML({
htmlStr: this.reportDetail?.result || '<p>无</p>',
baseFontSize: 12,
baseFontColor: '#999'
})
}.padding(10).justifyContent(FlexAlign.SpaceBetween)
}.padding(10).alignItems(HorizontalAlign.Start).width('100%')
}.backgroundColor('#fff').borderRadius(10).padding(10).width('100%')
// 主要消防措施
Column({space: 10}){
... ... @@ -246,9 +252,14 @@ struct DetailRecords {
Text(item.projectName).fontSize(16).fontColor('#1890ff')
Image($r('app.media.edit_1')).width(16).margin({right: 4})
}.onClick(() => {
let routerData: commonRouterParams = {
projectId: item.projectId,
reportId: item.reportId,
videoPath: ''
}
router.pushUrl({
url: 'pages/FireProtectionDetail',
params: item
params: routerData
})
})
}
... ...
import { router, promptAction } from '@kit.ArkUI'
import { ProjectList } from '../api/recordsType'
import { webview } from '@kit.ArkWeb'
import { basePath } from '../utils/baseUrl'
import fs from '@ohos.file.fs';
import preferencesUtils from '../utils/preferences'
import { BusinessError, request } from '@kit.BasicServicesKit';
import { cameraPickerImg, cameraPickerVideo, videoCompressMethod } from '../utils/uploadFile'
import { common, Permissions } from '@kit.AbilityKit';
import { AxiosResponse } from '@ohos/axios'
import { getCosKey, cosKeyTest, cosKeyData, uploadVideoOrImg } from '../api/cosKey'
import loadingDialog from '../dialog/LoadingDialog'
import { rpc } from '@kit.IPCKit';
import { abilityAccessCtrl, common, Permissions } from '@kit.AbilityKit';
import { AxiosResponse } from '@ohos/axios'
import NavHeader from '../components/NavHeader'
import { basePath } from '../utils/baseUrl'
import preferencesUtils from '../utils/preferences'
import { BusinessError, request } from '@kit.BasicServicesKit';
import { cameraPickerImg } from '../utils/uploadFile'
import { reqPermissionsFromUser, checkAccessToken, commonRouterParams } from '../utils/UserAuth'
let routerInfo: ProjectList = router.getParams() as ProjectList
let routerInfo: commonRouterParams = router.getParams() as commonRouterParams
const context = getContext() as common.UIAbilityContext;
@Entry
... ... @@ -20,8 +21,9 @@ const context = getContext() as common.UIAbilityContext;
struct FireProtectionDetail {
controller: RichEditorController = new RichEditorController();
options: RichEditorOptions = { controller: this.controller };
@State projectInfo: ProjectList = routerInfo
private result: boolean = false;
@State projectInfo: commonRouterParams = routerInfo
cosKeyStr: string | null =''
relateId: number = 0
permissions: Array<Permissions> = [
'ohos.permission.CAMERA',
'ohos.permission.MICROPHONE',
... ... @@ -29,8 +31,15 @@ struct FireProtectionDetail {
];
webviewController: webview.WebviewController = new webview.WebviewController()
onPageShow() {
let pathUrl = (router.getParams() as commonRouterParams)?.videoPath || ''
console.log('pathUrl', pathUrl)
if (pathUrl !== '' || pathUrl !== undefined || pathUrl !== null) {
this.uploadMethods(this.cosKeyStr, this.relateId, pathUrl, 'mp4')
}
}
aboutToAppear(): void {
this.reqPermissionsFromUser(this.permissions, context)
reqPermissionsFromUser(this.permissions, context)
}
// 加载弹窗
loadingController: CustomDialogController = new CustomDialogController({
... ... @@ -40,49 +49,11 @@ struct FireProtectionDetail {
alignment: DialogAlignment.Center,
autoCancel: false
})
// 获取用户授权
reqPermissionsFromUser(permissions: Array<Permissions>, context: common.UIAbilityContext) {
let atManager: abilityAccessCtrl.AtManager = abilityAccessCtrl.createAtManager();
atManager.requestPermissionsFromUser(context, permissions).then((data) => {
let grantStatus: Array<number> = data.authResults;
let length: number = grantStatus.length;
for (let i = 0; i < length; i++) {
if (grantStatus[i] === 0) {
promptAction.showToast({message: 'User authorized.'})
} else {
promptAction.showToast({message: 'User denied authorization.'})
return;
}
}
}).catch((err: BusinessError) => {
promptAction.showToast({message: `Failed to request permissions from user. Code is ${err.code}, message is ${err.message}`})
})
}
// 检查用户是否授权
checkAccessToken(permissions: Array<Permissions>) {
// Determine the authorization status.
let callerTokenId: number = rpc.IPCSkeleton.getCallingTokenId();
let atManager: abilityAccessCtrl.AtManager = abilityAccessCtrl.createAtManager();
try {
for (let i = 0; i < permissions.length; i++) {
let data: abilityAccessCtrl.GrantStatus = atManager.verifyAccessTokenSync(callerTokenId, permissions[i]);
if (data === -1) {
this.result = false;
} else {
this.result = true;
}
if (!this.result) {
break;
}
}
} catch (err) {
promptAction.showToast({message: `checkAccessToken catch err->${JSON.stringify(err)}`})
}
}
// 上传方法
uploadMethods = async (cosKeyStr: string | null, relateId: number, systemPhotoImagePath: string, fileType: string) => {
if(systemPhotoImagePath =='' || systemPhotoImagePath == null || systemPhotoImagePath == undefined){
return promptAction.showToast({ message: '用户取消选择' });
}
let _this = this
_this.loadingController.open()
let cacheDir = getContext().cacheDir // 获取缓存目录
... ... @@ -112,7 +83,7 @@ struct FireProtectionDetail {
method: "PUT",
files:[{ // 上传文件
filename: filename, // 文件名
type: 'jpg', // 文件扩展名
type: fileType, // 文件扩展名
name:'file', // 接口参数名
uri:`internal://cache/${filename}` // 缓存目录中的要上传给服务器的图片路径
}],
... ... @@ -123,11 +94,10 @@ struct FireProtectionDetail {
_this.loadingController.close()
for (let i = 0; i < taskStates.length; i++) {
let cosKeyArr: string[] = []
if(cosKeyStr !== null) {
if(cosKeyStr !== null && cosKeyStr !== 'null') {
cosKeyArr = cosKeyStr.split(';')
}
cosKeyArr.push(cosKey)
console.log('最终的cosKeys数据: ' + cosKeyArr.join(';'))
await uploadVideoOrImg({ cosKey: cosKeyArr.join(';'), relateId: relateId })
await _this.webviewController.runJavaScript(`window.setKey(${JSON.stringify(cosKeyArr.join(';'))})`)
_this.loadingController.close()
... ... @@ -149,29 +119,28 @@ struct FireProtectionDetail {
}
build() {
Column(){
NavHeader({title: '编写记录信息'})
Web({
src: `${basePath}/report/handle?id=${this.projectInfo.reportId}&pid=${this.projectInfo.projectId}&source=harmony&token=${preferencesUtils.get('XF_TOKEN', '')}`,
// src: 'http://www.xiao-ming.love/',
controller: this.webviewController,
}).mixedMode(MixedMode.All).javaScriptAccess(true).domStorageAccess(true)
.onConsole((event) => {
let data = event.message.getMessage().replace(/^['"]|['"]$/g, '');
let formatData = data.split('&')
let cosKeyStr: string | null = formatData[1]
let relateId: number = parseInt(formatData[2])
this.cosKeyStr = formatData[1]
this.relateId = parseInt(formatData[2])
if (formatData[0] == '鸿蒙图片上传') {
// 使用相机拍照
cameraPickerImg().then(async systemPhotoImagePath => {
if (systemPhotoImagePath == '' || systemPhotoImagePath == null) {
return promptAction.showToast({ message: '用户取消选择' });
}
this.uploadMethods(cosKeyStr, relateId, systemPhotoImagePath, 'jpg')
this.uploadMethods(this.cosKeyStr, this.relateId, systemPhotoImagePath, 'jpg')
})
} else if(formatData[0] == '鸿蒙视频上传'){
// 使用相机录像
this.checkAccessToken(this.permissions);
if (this.result) {
router.pushUrl({ url: 'pages/CreateCamera', params: { cosKeyStr: cosKeyStr, relateId: relateId} })
if (checkAccessToken(this.permissions)) {
router.pushUrl({ url: 'pages/CreateCamera', params: this.projectInfo })
}
}
return false
... ...
... ... @@ -2,6 +2,7 @@ import { router } from '@kit.ArkUI'
import { webview } from '@kit.ArkWeb'
import preferencesUtils from '../utils/preferences'
import { basePath } from '../utils/baseUrl'
import NavHeader from '../components/NavHeader'
interface routerType {
reportId: number
}
... ... @@ -14,6 +15,7 @@ struct LookRecords {
webviewController: webview.WebviewController = new webview.WebviewController()
build() {
Column(){
NavHeader({title: '查看记录'})
Web({
src: `${basePath}/report/record?id=${reportId}&token=${preferencesUtils.get('XF_TOKEN', '')}&time=${new Date().getTime()}&type=${preferencesUtils.get('XF_ROLE_NAME', '')}&username=${preferencesUtils.get('XF_USERNAME', '')}`,
controller: this.webviewController,
... ...
... ... @@ -8,7 +8,7 @@ import {
// 创建SDKConfig对象
let adConfigBuilder = new SDKConfigBuilder()
let config: SDKConfig = adConfigBuilder
.appId("5669833")
.appId("5682334")
.appName("消防维保助手")
.allowShowNotify(true)
.debug(true)
... ...
import { abilityAccessCtrl, common, Permissions } from '@kit.AbilityKit';
import { promptAction } from '@kit.ArkUI'
import { rpc } from '@kit.IPCKit';
// 获取用户授权
export async function reqPermissionsFromUser(permissions: Array<Permissions>, context: common.UIAbilityContext) {
let atManager: abilityAccessCtrl.AtManager = abilityAccessCtrl.createAtManager();
try {
let data = await atManager.requestPermissionsFromUser(context, permissions)
let grantStatus: Array<number> = data.authResults;
if(grantStatus.every((numberItem: number) => numberItem === 0)){
promptAction.showToast({message: '授权成功'})
} else {
promptAction.showToast({message: '用户已取消授权'})
}
} catch (err) {
promptAction.showToast({message: `Failed to request permissions from user. Code is ${err.code}, message is ${err.message}`})
}
}
// 检查用户是否授权
export function checkAccessToken(permissions: Array<Permissions>): boolean {
// Determine the authorization status.
let callerTokenId: number = rpc.IPCSkeleton.getCallingTokenId();
let atManager: abilityAccessCtrl.AtManager = abilityAccessCtrl.createAtManager();
try {
return permissions.every((permissionItem: Permissions) => atManager.verifyAccessTokenSync(callerTokenId, permissionItem) !== -1)
} catch (err) {
promptAction.showToast({message: `checkAccessToken catch err->${JSON.stringify(err)}`})
return false
}
}
export interface commonRouterParams {
reportId: number;
projectId: number;
videoPath: string;
}
\ No newline at end of file
... ...
... ... @@ -3905,7 +3905,7 @@ const makeOption = (
children,
});
export function useCascadeAreaData() {
export function useCascadeAreaData(provinceValue: string = '') {
const city = areaList.city_list
const county = areaList.county_list
... ... @@ -3934,6 +3934,10 @@ export function useCascadeAreaData() {
}
});
return Array.from(provinceMap.values());
if(provinceValue === '') {
return Array.from(provinceMap.values());
} else {
return Array.from(provinceMap.values()).filter((item) => item.text === provinceValue)
}
}
... ...