|
...
|
...
|
@@ -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: '添加成功'
|
|
|
|
})
|
...
|
...
|
|