|
|
|
|
@ -6,74 +6,222 @@
|
|
|
|
|
:visible.sync="visible">
|
|
|
|
|
<!-- 新增和修改表单 -->
|
|
|
|
|
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataSubmit()" label-width="80px">
|
|
|
|
|
<el-form-item label="业主类型" prop="ownerType">
|
|
|
|
|
<el-input v-model="dataForm.ownerType" placeholder="业主类型"></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="业主id" prop="ownerId">
|
|
|
|
|
<el-input v-model="dataForm.ownerId" placeholder="业主id"></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="房屋id" prop="houseId">
|
|
|
|
|
<el-input v-model="dataForm.houseId" placeholder="房屋id"></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="房屋业主id" prop="houseOwnerId">
|
|
|
|
|
<el-input v-model="dataForm.houseOwnerId" placeholder="房屋业主id"></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="报修单号" prop="orderNo">
|
|
|
|
|
<el-input v-model="dataForm.orderNo" placeholder="报修单号"></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="故障类型" prop="faultType">
|
|
|
|
|
<el-input v-model="dataForm.faultType" placeholder="故障类型"></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="故障描述" prop="faultDesc">
|
|
|
|
|
<el-input v-model="dataForm.faultDesc" placeholder="故障描述"></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="故障照片" prop="faultPhoto">
|
|
|
|
|
<el-input v-model="dataForm.faultPhoto" placeholder="故障照片"></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="报修渠道" prop="reportChannel">
|
|
|
|
|
<el-input v-model="dataForm.reportChannel" placeholder="报修渠道"></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="报修时间" prop="reportTime">
|
|
|
|
|
<el-input v-model="dataForm.reportTime" placeholder="报修时间"></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="紧急程度" prop="urgencyLevel">
|
|
|
|
|
<el-input v-model="dataForm.urgencyLevel" placeholder="紧急程度"></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="状态" prop="status">
|
|
|
|
|
<el-input v-model="dataForm.status" placeholder="状态"></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="备注" prop="remark">
|
|
|
|
|
<el-input v-model="dataForm.remark" placeholder="备注"></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-row :gutter="20">
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item label="业主名称" prop="ownerId">
|
|
|
|
|
<el-select v-model="dataForm.ownerId" placeholder="请选择业主" clearable style="width: 100%" @change="handleOwnerChange">
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="item in ownerList"
|
|
|
|
|
:key="item.id"
|
|
|
|
|
:label="item.ownerName"
|
|
|
|
|
:value="item.id"
|
|
|
|
|
/>
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item label="业主类型" prop="ownerType">
|
|
|
|
|
<el-select v-model="dataForm.ownerType" placeholder="请选择业主类型" clearable disabled style="width: 100%">
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="dict in dict.type.owner_Type"
|
|
|
|
|
:key="dict.value"
|
|
|
|
|
:label="dict.label"
|
|
|
|
|
:value="dict.value"
|
|
|
|
|
/>
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
</el-row>
|
|
|
|
|
<el-row :gutter="20">
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item label="房屋名称" prop="houseId">
|
|
|
|
|
<el-select v-model="dataForm.houseId" placeholder="选择房屋" clearable style="width: 100%" @change="handleHouseChange" disabled>
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="item in ownerHouseList"
|
|
|
|
|
:key="item.id"
|
|
|
|
|
:label="`${item.unitNo}单元 ${item.floorNo}层 ${item.houseNo}室`"
|
|
|
|
|
:value="item.id"
|
|
|
|
|
/>
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item label="报修单号" prop="orderNo">
|
|
|
|
|
<el-input v-model="dataForm.orderNo" placeholder="报修单号"></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
</el-row>
|
|
|
|
|
<el-row :gutter="20">
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item label="故障类型" prop="faultType">
|
|
|
|
|
<el-select v-model="dataForm.faultType" placeholder="请选择故障类型" clearable style="width: 100%">
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="dict in dict.type.fault_type"
|
|
|
|
|
:key="dict.value"
|
|
|
|
|
:label="dict.label"
|
|
|
|
|
:value="dict.value"
|
|
|
|
|
/>
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item label="报修渠道" prop="reportChannel">
|
|
|
|
|
<el-input v-model="dataForm.reportChannel" placeholder="报修渠道"></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
</el-row>
|
|
|
|
|
<el-row :gutter="20">
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item label="报修时间" prop="reportTime">
|
|
|
|
|
<el-date-picker
|
|
|
|
|
v-model="dataForm.reportTime"
|
|
|
|
|
type="datetime"
|
|
|
|
|
placeholder="选择报修时间"
|
|
|
|
|
style="width: 100%"
|
|
|
|
|
></el-date-picker>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item label="紧急程度" prop="urgencyLevel">
|
|
|
|
|
<el-input v-model="dataForm.urgencyLevel" placeholder="紧急程度"></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
</el-row>
|
|
|
|
|
<el-row :gutter="20">
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item label="状态" prop="status">
|
|
|
|
|
<el-select v-model="dataForm.status" placeholder="选择状态" clearable style="width: 100%">
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="dict in dict.type.fault_status"
|
|
|
|
|
:key="dict.value"
|
|
|
|
|
:label="dict.label"
|
|
|
|
|
:value="dict.value"
|
|
|
|
|
/>
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
</el-row>
|
|
|
|
|
<!-- 隐藏的房屋业主id字段 -->
|
|
|
|
|
<el-form-item label="房屋业主id" prop="houseOwnerId" v-show="false">
|
|
|
|
|
<el-input v-model="dataForm.houseOwnerId" placeholder="房屋业主id" readonly></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<!-- 故障照片单独一行 -->
|
|
|
|
|
<el-row :gutter="20">
|
|
|
|
|
<el-col :span="24">
|
|
|
|
|
<el-form-item label="故障照片" prop="faultPhoto">
|
|
|
|
|
<FileUploadVO
|
|
|
|
|
:value="faultPhotoFiles"
|
|
|
|
|
@input="updateFaultPhotoFiles"
|
|
|
|
|
></FileUploadVO>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
</el-row>
|
|
|
|
|
<!-- 故障描述 -->
|
|
|
|
|
<el-row :gutter="20">
|
|
|
|
|
<el-col :span="24">
|
|
|
|
|
<el-form-item label="故障描述" prop="faultDesc">
|
|
|
|
|
<el-input v-model="dataForm.faultDesc" placeholder="故障描述" type="textarea"></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
</el-row>
|
|
|
|
|
<el-row :gutter="20">
|
|
|
|
|
<el-col :span="24">
|
|
|
|
|
<el-form-item label="备注" prop="remark">
|
|
|
|
|
<el-input v-model="dataForm.remark" placeholder="备注" type="textarea"></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
</el-row>
|
|
|
|
|
</el-form>
|
|
|
|
|
<!-- 显示添加报修派单记录按钮 -->
|
|
|
|
|
<!-- <div style="margin-bottom: 20px;">-->
|
|
|
|
|
<!-- <el-button type="success" @click="addDispatchRecord">添加报修派单记录</el-button>-->
|
|
|
|
|
<!-- </div>-->
|
|
|
|
|
|
|
|
|
|
<!-- <!– 报修派单记录列表 –>-->
|
|
|
|
|
<!-- <div class="dispatch-records-container">-->
|
|
|
|
|
<!-- <el-table :data="dispatchRecords" style="width: 100%">-->
|
|
|
|
|
<!-- <el-table-column prop="assignerId" label="派单人" width="120"></el-table-column>-->
|
|
|
|
|
<!-- <el-table-column prop="executorId" label="执行人" width="120"></el-table-column>-->
|
|
|
|
|
<!-- <el-table-column prop="executorDept" label="执行部门" width="150"></el-table-column>-->
|
|
|
|
|
<!-- <el-table-column prop="phone" label="联系方式" width="120"></el-table-column>-->
|
|
|
|
|
<!-- <el-table-column label="派单时间" width="180">-->
|
|
|
|
|
<!-- <template slot-scope="scope">-->
|
|
|
|
|
<!-- {{ formatDisplayDate(scope.row.assignTime) }}-->
|
|
|
|
|
<!-- </template>-->
|
|
|
|
|
<!-- </el-table-column>-->
|
|
|
|
|
<!-- <el-table-column prop="assigneContext" label="派单工作内容" width="200"></el-table-column>-->
|
|
|
|
|
<!-- <el-table-column label="预计完成时间" width="180">-->
|
|
|
|
|
<!-- <template slot-scope="scope">-->
|
|
|
|
|
<!-- {{ formatDisplayDate(scope.row.expectedCompleteTime) }}-->
|
|
|
|
|
<!-- </template>-->
|
|
|
|
|
<!-- </el-table-column>-->
|
|
|
|
|
<!-- <el-table-column label="实际完成时间" width="180">-->
|
|
|
|
|
<!-- <template slot-scope="scope">-->
|
|
|
|
|
<!-- {{ formatDisplayDate(scope.row.completeTime) }}-->
|
|
|
|
|
<!-- </template>-->
|
|
|
|
|
<!-- </el-table-column>-->
|
|
|
|
|
<!-- <el-table-column prop="status" label="状态" width="100">-->
|
|
|
|
|
<!-- <template slot-scope="scope">-->
|
|
|
|
|
<!-- <dict-tag :options="dict.type.dispatch_status" :value="scope.row.status"></dict-tag>-->
|
|
|
|
|
<!-- </template>-->
|
|
|
|
|
<!-- </el-table-column>-->
|
|
|
|
|
<!-- <el-table-column prop="remark" label="备注" width="150"></el-table-column>-->
|
|
|
|
|
<!-- <el-table-column label="操作" width="180" fixed="right">-->
|
|
|
|
|
<!-- <template slot-scope="scope">-->
|
|
|
|
|
<!-- <el-button type="text" size="small" @click="editDispatchRecord(scope.row.id)">{{ '修改' }}</el-button>-->
|
|
|
|
|
<!-- <el-button type="text" size="small" @click="deleteDispatchRecord(scope.row.id, scope.$index)">{{ '删除' }}</el-button>-->
|
|
|
|
|
<!-- </template>-->
|
|
|
|
|
<!-- </el-table-column>-->
|
|
|
|
|
<!-- </el-table>-->
|
|
|
|
|
<!-- </div>-->
|
|
|
|
|
|
|
|
|
|
<span slot="footer" class="dialog-footer">
|
|
|
|
|
<el-button @click="visible = false">取消</el-button>
|
|
|
|
|
<el-button type="primary" @click="dataSubmit()">确定</el-button>
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
<!-- 报修派单记录弹窗 -->
|
|
|
|
|
<add-or-update-dispatch ref="addOrUpdateDispatch" :orderId="dataForm.id" @refreshDataList="getDispatchRecords" @saveDispatchRecord="saveDispatchRecord"></add-or-update-dispatch>
|
|
|
|
|
</el-dialog>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import * as api from '@/api/pmmaintenanceorder.js'
|
|
|
|
|
import * as ownerApi from '@/api/pmowner.js'
|
|
|
|
|
import * as houseApi from '@/api/pmhouse.js'
|
|
|
|
|
import * as ownerHouseRelApi from '@/api/pmownerhouserel.js'
|
|
|
|
|
import * as dispatchApi from '@/api/pmmaintenancedispatch.js'
|
|
|
|
|
import FileUploadVO from '@/components/FileUploadVO/index.vue'
|
|
|
|
|
import AddOrUpdateDispatch from '../dispatch/pmmaintenancedispatch-add-and-update.vue'
|
|
|
|
|
export default {
|
|
|
|
|
components: {
|
|
|
|
|
FileUploadVO,
|
|
|
|
|
AddOrUpdateDispatch
|
|
|
|
|
},
|
|
|
|
|
dicts: ['owner_Type','fault_type','fault_status','dispatch_status'],
|
|
|
|
|
data () {
|
|
|
|
|
return {
|
|
|
|
|
visible: false,
|
|
|
|
|
ownerList: [],
|
|
|
|
|
houseList: [],
|
|
|
|
|
ownerHouseList: [], // 所选业主的房屋列表
|
|
|
|
|
faultPhotoFiles: [], // 故障照片文件列表
|
|
|
|
|
dispatchRecords: [], // 报修派单记录列表
|
|
|
|
|
dataForm: {
|
|
|
|
|
id: 0,
|
|
|
|
|
ownerType: '' ,
|
|
|
|
|
ownerId: '' ,
|
|
|
|
|
houseId: '' ,
|
|
|
|
|
houseOwnerId: '' ,
|
|
|
|
|
orderNo: '' ,
|
|
|
|
|
faultType: '' ,
|
|
|
|
|
faultDesc: '' ,
|
|
|
|
|
faultPhoto: '' ,
|
|
|
|
|
reportChannel: '' ,
|
|
|
|
|
reportTime: '' ,
|
|
|
|
|
urgencyLevel: '' ,
|
|
|
|
|
status: '' ,
|
|
|
|
|
remark: '' ,
|
|
|
|
|
ownerType: '',
|
|
|
|
|
ownerId: '',
|
|
|
|
|
houseId: '',
|
|
|
|
|
houseOwnerId: '',
|
|
|
|
|
orderNo: '',
|
|
|
|
|
faultType: '',
|
|
|
|
|
faultDesc: '',
|
|
|
|
|
faultPhoto: null,
|
|
|
|
|
reportChannel: '',
|
|
|
|
|
reportTime: '',
|
|
|
|
|
urgencyLevel: '',
|
|
|
|
|
status: '',
|
|
|
|
|
remark: '',
|
|
|
|
|
files: []
|
|
|
|
|
},
|
|
|
|
|
dataRule: {
|
|
|
|
|
ownerType: [
|
|
|
|
|
@ -85,40 +233,124 @@
|
|
|
|
|
houseId: [
|
|
|
|
|
{ required: true, message: '房屋id 为必填项', trigger: 'blur' }
|
|
|
|
|
],
|
|
|
|
|
houseOwnerId: [
|
|
|
|
|
{ required: true, message: '房屋业主id 为必填项', trigger: 'blur' }
|
|
|
|
|
],
|
|
|
|
|
orderNo: [
|
|
|
|
|
{ required: true, message: '报修单号 为必填项', trigger: 'blur' }
|
|
|
|
|
],
|
|
|
|
|
faultType: [
|
|
|
|
|
{ required: true, message: '故障类型 为必填项', trigger: 'blur' }
|
|
|
|
|
],
|
|
|
|
|
faultDesc: [
|
|
|
|
|
{ required: true, message: '故障描述 为必填项', trigger: 'blur' }
|
|
|
|
|
],
|
|
|
|
|
faultPhoto: [
|
|
|
|
|
{ required: true, message: '故障照片 为必填项', trigger: 'blur' }
|
|
|
|
|
],
|
|
|
|
|
reportChannel: [
|
|
|
|
|
{ required: true, message: '报修渠道 为必填项', trigger: 'blur' }
|
|
|
|
|
],
|
|
|
|
|
reportTime: [
|
|
|
|
|
{ required: true, message: '报修时间 为必填项', trigger: 'blur' }
|
|
|
|
|
],
|
|
|
|
|
urgencyLevel: [
|
|
|
|
|
{ required: true, message: '紧急程度 为必填项', trigger: 'blur' }
|
|
|
|
|
],
|
|
|
|
|
status: [
|
|
|
|
|
{ required: true, message: '状态 为必填项', trigger: 'blur' }
|
|
|
|
|
],
|
|
|
|
|
remark: [
|
|
|
|
|
{ required: true, message: '备注 为必填项', trigger: 'blur' }
|
|
|
|
|
],
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
mounted() {
|
|
|
|
|
this.handleGetOwnerList()
|
|
|
|
|
this.handleGetHouseList()
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
// 获取业主列表
|
|
|
|
|
handleGetOwnerList() {
|
|
|
|
|
ownerApi.pmownerListApi({ page: 1, limit: 9999 }).then(res => {
|
|
|
|
|
this.ownerList = res.list || []
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
// 获取房屋列表
|
|
|
|
|
handleGetHouseList() {
|
|
|
|
|
houseApi.pmhouseListApi({ page: 1, limit: 9999 }).then(res => {
|
|
|
|
|
this.houseList = res.list || []
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 处理业主选择变化
|
|
|
|
|
handleOwnerChange(ownerId) {
|
|
|
|
|
// 设置业主类型
|
|
|
|
|
if (ownerId) {
|
|
|
|
|
const selectedOwner = this.ownerList.find(owner => owner.id === ownerId)
|
|
|
|
|
if (selectedOwner && selectedOwner.ownerType) {
|
|
|
|
|
this.dataForm.ownerType = selectedOwner.ownerType
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// 清空业主类型
|
|
|
|
|
this.dataForm.ownerType = ''
|
|
|
|
|
}
|
|
|
|
|
// 获取关联房屋并自动选择第一个
|
|
|
|
|
if (ownerId) {
|
|
|
|
|
ownerHouseRelApi.pmownerhouserelListApi({ ownerId: ownerId, page: 1, limit: 9999 }).then(res => {
|
|
|
|
|
const relList = res.list || []
|
|
|
|
|
// 获取房屋ID列表
|
|
|
|
|
const houseIds = relList.map(item => item.houseId)
|
|
|
|
|
// 从房屋列表中筛选出关联的房屋
|
|
|
|
|
this.ownerHouseList = this.houseList.filter(house => houseIds.includes(house.id))
|
|
|
|
|
// 自动选择第一个房屋
|
|
|
|
|
if (this.ownerHouseList.length > 0) {
|
|
|
|
|
this.dataForm.houseId = this.ownerHouseList[0].id
|
|
|
|
|
this.dataForm.houseOwnerId = ownerId
|
|
|
|
|
} else {
|
|
|
|
|
this.dataForm.houseId = ''
|
|
|
|
|
this.dataForm.houseOwnerId = ''
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
this.ownerHouseList = []
|
|
|
|
|
this.dataForm.houseId = ''
|
|
|
|
|
this.dataForm.houseOwnerId = ''
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
// 处理房屋选择变化
|
|
|
|
|
handleHouseChange(houseId) {
|
|
|
|
|
if (houseId) {
|
|
|
|
|
// 设置房屋业主ID为当前选择的业主ID
|
|
|
|
|
this.dataForm.houseOwnerId = this.dataForm.ownerId
|
|
|
|
|
} else {
|
|
|
|
|
// 清空房屋业主ID
|
|
|
|
|
this.dataForm.houseOwnerId = ''
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
// 更新故障照片文件列表
|
|
|
|
|
updateFaultPhotoFiles(files) {
|
|
|
|
|
this.faultPhotoFiles = files
|
|
|
|
|
// 将文件保存到dataForm.files中
|
|
|
|
|
if (files && files.length > 0) {
|
|
|
|
|
// 将FileUploadVO返回的文件格式转换为后端SystemAttachment需要的格式
|
|
|
|
|
this.dataForm.files = files.map(file => {
|
|
|
|
|
// 处理文件路径,确保符合后端要求的格式
|
|
|
|
|
let attDir = file.attDir || file.attachFileUrl || ''
|
|
|
|
|
// 如果路径以/file/public/开头,去掉这个前缀,因为后端存储格式不需要
|
|
|
|
|
if (attDir.startsWith('/file/public/')) {
|
|
|
|
|
attDir = attDir.replace('/file/public/', '')
|
|
|
|
|
} else if (attDir.startsWith('/file/')) {
|
|
|
|
|
attDir = attDir.replace('/file/', '')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
// 严格按照SystemAttachment的字段要求设置
|
|
|
|
|
attId: file.id || file.attId || '', // 确保转换为字符串
|
|
|
|
|
name: file.name || file.oldName || '', // 附件名称
|
|
|
|
|
attDir: attDir, // 附件路径
|
|
|
|
|
attSize: file.attSize || '', // 附件大小
|
|
|
|
|
attType: file.attType || '', // 附件类型
|
|
|
|
|
// 保留原有字段以保持兼容性
|
|
|
|
|
fileName: file.name || file.oldName || '',
|
|
|
|
|
filePath: attDir,
|
|
|
|
|
url: attDir,
|
|
|
|
|
createTime: null,
|
|
|
|
|
createdBy: null,
|
|
|
|
|
createTimeStr: null,
|
|
|
|
|
delFlag: '0',
|
|
|
|
|
updateBy: null,
|
|
|
|
|
updateTime: null,
|
|
|
|
|
i18nCode: '',
|
|
|
|
|
i18nLanguage: '',
|
|
|
|
|
originalFileName: file.name || file.oldName || '',
|
|
|
|
|
position: 0,
|
|
|
|
|
remark: file.remark || '',
|
|
|
|
|
sort: 0,
|
|
|
|
|
status: ''
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
this.dataForm.files = []
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
init (id) { // 初始化表单验证规则
|
|
|
|
|
this.dataForm.id = id || 0
|
|
|
|
|
this.visible = true
|
|
|
|
|
@ -126,23 +358,275 @@
|
|
|
|
|
this.$refs['dataForm'].resetFields()
|
|
|
|
|
if (this.dataForm.id) {
|
|
|
|
|
api.pmmaintenanceorderDetailApi(id).then(function(res) {
|
|
|
|
|
this.dataForm = res;
|
|
|
|
|
// 处理日期格式
|
|
|
|
|
if (res.reportTime) {
|
|
|
|
|
res.reportTime = new Date(res.reportTime)
|
|
|
|
|
}
|
|
|
|
|
// 先保存订单详情
|
|
|
|
|
const orderDetail = res;
|
|
|
|
|
|
|
|
|
|
// 确保房屋列表已经加载完成
|
|
|
|
|
if (this.houseList.length === 0) {
|
|
|
|
|
// 如果房屋列表为空,重新加载
|
|
|
|
|
this.handleGetHouseList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 确保业主列表已经加载完成
|
|
|
|
|
if (this.ownerList.length === 0) {
|
|
|
|
|
// 如果业主列表为空,重新加载
|
|
|
|
|
this.handleGetOwnerList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 延迟一下,确保房屋列表和业主列表已经加载完成
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
// 根据业主ID获取关联的房屋列表
|
|
|
|
|
if (orderDetail.ownerId) {
|
|
|
|
|
ownerHouseRelApi.pmownerhouserelListApi({ ownerId: orderDetail.ownerId, page: 1, limit: 9999 }).then(relRes => {
|
|
|
|
|
const relList = relRes.list || []
|
|
|
|
|
// 获取房屋ID列表
|
|
|
|
|
const houseIds = relList.map(item => item.houseId)
|
|
|
|
|
// 从房屋列表中筛选出关联的房屋
|
|
|
|
|
this.ownerHouseList = this.houseList.filter(house => houseIds.includes(house.id))
|
|
|
|
|
// 然后更新表单数据
|
|
|
|
|
this.dataForm = orderDetail;
|
|
|
|
|
// 处理故障照片文件列表
|
|
|
|
|
if (orderDetail.files && orderDetail.files.length > 0) {
|
|
|
|
|
// 转换files为FileUploadVO需要的格式
|
|
|
|
|
this.faultPhotoFiles = orderDetail.files.map((file, index) => ({
|
|
|
|
|
attachFileUrl: file.attDir || file.filePath || file.url || '',
|
|
|
|
|
attDir: file.attDir || file.filePath || file.url || '',
|
|
|
|
|
name: file.name || file.fileName || '',
|
|
|
|
|
oldName: file.name || file.fileName || '',
|
|
|
|
|
attId: file.attId || '',
|
|
|
|
|
uid: file.id || file.fileId || index + new Date().getTime()
|
|
|
|
|
}))
|
|
|
|
|
} else {
|
|
|
|
|
this.faultPhotoFiles = []
|
|
|
|
|
}
|
|
|
|
|
// 获取该订单的报修派单记录
|
|
|
|
|
this.getDispatchRecords()
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
// 如果没有业主ID,直接更新表单数据
|
|
|
|
|
this.dataForm = orderDetail;
|
|
|
|
|
// 处理故障照片文件列表
|
|
|
|
|
if (orderDetail.files && orderDetail.files.length > 0) {
|
|
|
|
|
// 转换files为FileUploadVO需要的格式
|
|
|
|
|
this.faultPhotoFiles = orderDetail.files.map((file, index) => ({
|
|
|
|
|
attachFileUrl: file.attDir || file.filePath || file.url || '',
|
|
|
|
|
attDir: file.attDir || file.filePath || file.url || '',
|
|
|
|
|
name: file.name || file.fileName || '',
|
|
|
|
|
oldName: file.name || file.fileName || '',
|
|
|
|
|
attId: file.attId || '',
|
|
|
|
|
uid: file.id || file.fileId || index + new Date().getTime()
|
|
|
|
|
}))
|
|
|
|
|
} else {
|
|
|
|
|
this.faultPhotoFiles = []
|
|
|
|
|
}
|
|
|
|
|
// 获取该订单的报修派单记录
|
|
|
|
|
this.getDispatchRecords()
|
|
|
|
|
}
|
|
|
|
|
}, 500); // 延迟500毫秒,确保数据已经加载完成
|
|
|
|
|
}.bind(this))
|
|
|
|
|
} else {
|
|
|
|
|
// 新增时清空故障照片文件列表
|
|
|
|
|
this.faultPhotoFiles = []
|
|
|
|
|
this.dataForm.files = []
|
|
|
|
|
// 新增时清空报修派单记录
|
|
|
|
|
this.dispatchRecords = []
|
|
|
|
|
// 新增时设置默认报修时间为当前时间
|
|
|
|
|
this.dataForm.reportTime = new Date()
|
|
|
|
|
}
|
|
|
|
|
}.bind(this))
|
|
|
|
|
},
|
|
|
|
|
// 格式化日期为后端期望的格式
|
|
|
|
|
formatDate(date) {
|
|
|
|
|
if (!date) return null
|
|
|
|
|
// 如果date是字符串,先转换为Date对象
|
|
|
|
|
if (typeof date === 'string') {
|
|
|
|
|
date = new Date(date)
|
|
|
|
|
}
|
|
|
|
|
// 检查date是否是有效的Date对象
|
|
|
|
|
if (isNaN(date.getTime())) {
|
|
|
|
|
return null
|
|
|
|
|
}
|
|
|
|
|
const year = date.getFullYear()
|
|
|
|
|
const month = String(date.getMonth() + 1).padStart(2, '0')
|
|
|
|
|
const day = String(date.getDate()).padStart(2, '0')
|
|
|
|
|
const hours = String(date.getHours()).padStart(2, '0')
|
|
|
|
|
const minutes = String(date.getMinutes()).padStart(2, '0')
|
|
|
|
|
const seconds = String(date.getSeconds()).padStart(2, '0')
|
|
|
|
|
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
|
|
|
|
|
},
|
|
|
|
|
// 格式化日期用于列表显示
|
|
|
|
|
formatDisplayDate(date) {
|
|
|
|
|
if (!date) return ''
|
|
|
|
|
// 如果date是字符串,先转换为Date对象
|
|
|
|
|
if (typeof date === 'string') {
|
|
|
|
|
date = new Date(date)
|
|
|
|
|
}
|
|
|
|
|
// 检查date是否是有效的Date对象
|
|
|
|
|
if (isNaN(date.getTime())) {
|
|
|
|
|
return ''
|
|
|
|
|
}
|
|
|
|
|
const year = date.getFullYear()
|
|
|
|
|
const month = String(date.getMonth() + 1).padStart(2, '0')
|
|
|
|
|
const day = String(date.getDate()).padStart(2, '0')
|
|
|
|
|
const hours = String(date.getHours()).padStart(2, '0')
|
|
|
|
|
const minutes = String(date.getMinutes()).padStart(2, '0')
|
|
|
|
|
return `${year}-${month}-${day} ${hours}:${minutes}`
|
|
|
|
|
},
|
|
|
|
|
// 获取报修派单记录列表
|
|
|
|
|
getDispatchRecords() {
|
|
|
|
|
if (!this.dataForm.id) return
|
|
|
|
|
console.log('getDispatchRecords - start')
|
|
|
|
|
dispatchApi.pmmaintenancedispatchListApi({
|
|
|
|
|
orderId: this.dataForm.id
|
|
|
|
|
}).then(function(res) {
|
|
|
|
|
try {
|
|
|
|
|
console.log('getDispatchRecords - res:', res)
|
|
|
|
|
// 保存从API获取的记录,但是保留之前的files字段和新记录
|
|
|
|
|
const apiRecords = Array.isArray(res) ? res : (res.list || [])
|
|
|
|
|
const newRecords = apiRecords.map(apiRecord => {
|
|
|
|
|
// 查找本地记录,保留之前的files字段
|
|
|
|
|
const localRecord = this.dispatchRecords.find(item => item.id === apiRecord.id)
|
|
|
|
|
if (localRecord && localRecord.files) {
|
|
|
|
|
apiRecord.files = localRecord.files
|
|
|
|
|
}
|
|
|
|
|
return apiRecord
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// 保留之前的新记录(即没有ID的记录)
|
|
|
|
|
const localNewRecords = this.dispatchRecords.filter(item => item.id === 0 || item.id === '0')
|
|
|
|
|
if (localNewRecords && localNewRecords.length > 0) {
|
|
|
|
|
newRecords.push(...localNewRecords)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.dispatchRecords = newRecords
|
|
|
|
|
console.log('getDispatchRecords - updated dispatchRecords:', this.dispatchRecords)
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.log('getDispatchRecords - error:', error)
|
|
|
|
|
this.dispatchRecords = []
|
|
|
|
|
}
|
|
|
|
|
}.bind(this)).catch(function(err) {
|
|
|
|
|
console.log('getDispatchRecords - err:', err)
|
|
|
|
|
this.dispatchRecords = []
|
|
|
|
|
}.bind(this))
|
|
|
|
|
},
|
|
|
|
|
// 新增报修派单记录
|
|
|
|
|
addDispatchRecord() {
|
|
|
|
|
if (this.$refs.addOrUpdateDispatch) {
|
|
|
|
|
// 直接传递订单ID参数
|
|
|
|
|
this.$refs.addOrUpdateDispatch.init(0, this.dataForm.id)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
// 编辑报修派单记录
|
|
|
|
|
editDispatchRecord(id) {
|
|
|
|
|
console.log((this.$refs.addOrUpdateDispatch));
|
|
|
|
|
if (this.$refs.addOrUpdateDispatch) {
|
|
|
|
|
console.log((this.$refs.addOrUpdateDispatch));
|
|
|
|
|
this.$refs.addOrUpdateDispatch.init(id, this.dataForm.id)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
// 删除报修派单记录
|
|
|
|
|
deleteDispatchRecord(id, index) {
|
|
|
|
|
this.$confirm('确定要删除这条报修派单记录吗?', '提示', {
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
cancelButtonText: '取消',
|
|
|
|
|
type: 'warning'
|
|
|
|
|
}).then(() => {
|
|
|
|
|
if (id) {
|
|
|
|
|
// 已有ID的记录,调用API删除
|
|
|
|
|
dispatchApi.pmmaintenancedispatchDeleteApi([id]).then(() => {
|
|
|
|
|
this.$message.success('删除成功')
|
|
|
|
|
// 从列表中移除这条记录
|
|
|
|
|
this.dispatchRecords.splice(index, 1)
|
|
|
|
|
}).catch(() => {
|
|
|
|
|
this.$message.error('删除失败')
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
// 还没有ID的新增记录,直接从列表中删除
|
|
|
|
|
this.dispatchRecords.splice(index, 1)
|
|
|
|
|
this.$message.success('删除成功')
|
|
|
|
|
}
|
|
|
|
|
}).catch(() => {
|
|
|
|
|
this.$message.info('已取消删除')
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 保存报修派单记录(从报修派单记录弹窗接收)
|
|
|
|
|
saveDispatchRecord(recordData) {
|
|
|
|
|
if (!recordData) return
|
|
|
|
|
|
|
|
|
|
// 检查是新增还是更新
|
|
|
|
|
const existingIndex = this.dispatchRecords.findIndex(record => record.id === recordData.id)
|
|
|
|
|
|
|
|
|
|
// 处理日期字段,确保它们是有效的Date对象或字符串
|
|
|
|
|
const formattedRecord = { ...recordData }
|
|
|
|
|
// 处理派单时间
|
|
|
|
|
if (formattedRecord.assignTime && typeof formattedRecord.assignTime === 'string' && formattedRecord.assignTime !== '') {
|
|
|
|
|
formattedRecord.assignTime = new Date(formattedRecord.assignTime)
|
|
|
|
|
}
|
|
|
|
|
// 处理预计完成时间
|
|
|
|
|
if (formattedRecord.expectedCompleteTime && typeof formattedRecord.expectedCompleteTime === 'string' && formattedRecord.expectedCompleteTime !== '') {
|
|
|
|
|
formattedRecord.expectedCompleteTime = new Date(formattedRecord.expectedCompleteTime)
|
|
|
|
|
}
|
|
|
|
|
// 处理实际完成时间
|
|
|
|
|
if (formattedRecord.completeTime && typeof formattedRecord.completeTime === 'string' && formattedRecord.completeTime !== '') {
|
|
|
|
|
formattedRecord.completeTime = new Date(formattedRecord.completeTime)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (existingIndex !== -1) {
|
|
|
|
|
// 更新现有记录
|
|
|
|
|
this.dispatchRecords.splice(existingIndex, 1, formattedRecord)
|
|
|
|
|
} else {
|
|
|
|
|
// 添加新记录
|
|
|
|
|
this.dispatchRecords.push(formattedRecord)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
// 表单数据提交
|
|
|
|
|
dataSubmit () {
|
|
|
|
|
this.$refs['dataForm'].validate((valid) => {
|
|
|
|
|
if (valid) {
|
|
|
|
|
// 复制表单数据,避免修改原始数据
|
|
|
|
|
const submitData = { ...this.dataForm }
|
|
|
|
|
// 格式化报修时间
|
|
|
|
|
if (submitData.reportTime) {
|
|
|
|
|
submitData.reportTime = this.formatDate(submitData.reportTime)
|
|
|
|
|
}
|
|
|
|
|
// 添加报修派单记录列表,并格式化其中的日期字段
|
|
|
|
|
if (this.dispatchRecords && this.dispatchRecords.length > 0) {
|
|
|
|
|
submitData.pmMaintenanceDispatchList = this.dispatchRecords.map(record => {
|
|
|
|
|
const formattedRecord = { ...record }
|
|
|
|
|
// 格式化派单时间
|
|
|
|
|
if (formattedRecord.assignTime) {
|
|
|
|
|
formattedRecord.assignTime = this.formatDate(formattedRecord.assignTime)
|
|
|
|
|
}
|
|
|
|
|
// 格式化预计完成时间
|
|
|
|
|
if (formattedRecord.expectedCompleteTime) {
|
|
|
|
|
formattedRecord.expectedCompleteTime = this.formatDate(formattedRecord.expectedCompleteTime)
|
|
|
|
|
}
|
|
|
|
|
// 格式化实际完成时间
|
|
|
|
|
if (formattedRecord.completeTime) {
|
|
|
|
|
formattedRecord.completeTime = this.formatDate(formattedRecord.completeTime)
|
|
|
|
|
}
|
|
|
|
|
// 处理id字段,新增记录的id应该为null
|
|
|
|
|
if (formattedRecord.id === 0) {
|
|
|
|
|
formattedRecord.id = null
|
|
|
|
|
}
|
|
|
|
|
return formattedRecord
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
submitData.pmMaintenanceDispatchList = []
|
|
|
|
|
}
|
|
|
|
|
if (this.dataForm.id) {
|
|
|
|
|
api.pmmaintenanceorderUpdateApi(this.dataForm).then(function(res) {
|
|
|
|
|
api.pmmaintenanceorderUpdateApi(submitData).then(function(res) {
|
|
|
|
|
this.$message.success('保存成功')
|
|
|
|
|
this.visible = false
|
|
|
|
|
this.$emit('refreshDataList')
|
|
|
|
|
}.bind(this));
|
|
|
|
|
} else {
|
|
|
|
|
api.pmmaintenanceorderCreateApi(this.dataForm).then(function(res) {
|
|
|
|
|
api.pmmaintenanceorderCreateApi(submitData).then(function(res) {
|
|
|
|
|
this.$message.success('新增成功')
|
|
|
|
|
this.visible = false
|
|
|
|
|
this.$emit('refreshDataList')
|
|
|
|
|
@ -154,3 +638,15 @@
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
.dispatch-records-container {
|
|
|
|
|
margin-top: 20px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.no-data-tip {
|
|
|
|
|
text-align: center;
|
|
|
|
|
padding: 20px;
|
|
|
|
|
color: #909399;
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
|