|
|
|
|
@ -46,12 +46,40 @@
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item label="执行人" prop="executorId">
|
|
|
|
|
<el-input v-model="dataForm.executorId" placeholder="执行人"></el-input>
|
|
|
|
|
<el-select v-model="dataForm.executorId" placeholder="请选择执行人" style="width: 100%">
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="person in personList"
|
|
|
|
|
:key="person.uid"
|
|
|
|
|
:label="person.realName"
|
|
|
|
|
:value="person.uid">
|
|
|
|
|
</el-option>
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item label="执行部门" prop="executorDept">
|
|
|
|
|
<el-input v-model="dataForm.executorDept" placeholder="执行部门"></el-input>
|
|
|
|
|
<el-popover
|
|
|
|
|
placement="bottom-start"
|
|
|
|
|
width="300"
|
|
|
|
|
trigger="click"
|
|
|
|
|
v-model="deptPopoverVisible">
|
|
|
|
|
<el-tree
|
|
|
|
|
:data="deptTreeData"
|
|
|
|
|
:props="{ label: 'deptName', value: 'deptId', children: 'children' }"
|
|
|
|
|
node-key="deptId"
|
|
|
|
|
highlight-current
|
|
|
|
|
default-expand-all
|
|
|
|
|
@node-click="handleDeptNodeClick">
|
|
|
|
|
</el-tree>
|
|
|
|
|
<el-input
|
|
|
|
|
slot="reference"
|
|
|
|
|
v-model="deptName"
|
|
|
|
|
placeholder="请选择执行部门"
|
|
|
|
|
readonly
|
|
|
|
|
suffix-icon="el-icon-arrow-down"
|
|
|
|
|
style="width: 100%">
|
|
|
|
|
</el-input>
|
|
|
|
|
</el-popover>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
@ -87,7 +115,14 @@
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item label="维保状态" prop="status">
|
|
|
|
|
<el-input v-model="dataForm.status" placeholder="维保状态"></el-input>
|
|
|
|
|
<el-select v-model="dataForm.status" placeholder="请选择维保状态" style="width: 100%">
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="item in dict.maintenance_status"
|
|
|
|
|
:key="item.value"
|
|
|
|
|
:label="item.label"
|
|
|
|
|
:value="item.value">
|
|
|
|
|
</el-option>
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
@ -104,11 +139,14 @@
|
|
|
|
|
<el-form-item label="备注" prop="remark">
|
|
|
|
|
<el-input v-model="dataForm.remark" placeholder="备注" type="textarea"></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item label="文件id" prop="fileId">
|
|
|
|
|
<el-input v-model="dataForm.fileId" placeholder="文件id"></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="24">
|
|
|
|
|
<el-form-item label="附件上传" prop="files">
|
|
|
|
|
<FileUploadVO
|
|
|
|
|
:value="fileList"
|
|
|
|
|
@input="updateFileList"
|
|
|
|
|
></FileUploadVO>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
</el-row>
|
|
|
|
|
</el-form>
|
|
|
|
|
@ -120,14 +158,23 @@
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import request from '@/utils/request'
|
|
|
|
|
import * as api from '@/api/pmfacilitymaintenacerecord.js'
|
|
|
|
|
import * as apiByProject from '@/api/pmproject.js'
|
|
|
|
|
import * as apiByBuilding from '@/api/pmbuilding.js'
|
|
|
|
|
import * as apiByFacility from '@/api/pmfacility.js'
|
|
|
|
|
import * as apiByPlan from '@/api/pmfacilitymaintenanceplan.js'
|
|
|
|
|
import * as apiByUser from '@/api/ebuser.js'
|
|
|
|
|
import * as apiByDept from '@/api/dept.js'
|
|
|
|
|
import FileUploadVO from '@/components/FileUploadVO/index.vue'
|
|
|
|
|
export default {
|
|
|
|
|
components: {
|
|
|
|
|
FileUploadVO
|
|
|
|
|
},
|
|
|
|
|
dicts: ['maintenance_status'],
|
|
|
|
|
props: {
|
|
|
|
|
planId: {
|
|
|
|
|
type: Number,
|
|
|
|
|
type: [String, Number],
|
|
|
|
|
default: 0
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
@ -137,6 +184,12 @@
|
|
|
|
|
projectList: [],
|
|
|
|
|
buildingList: [],
|
|
|
|
|
facilityList: [],
|
|
|
|
|
personList: [],
|
|
|
|
|
deptList: [],
|
|
|
|
|
deptTreeData: [],
|
|
|
|
|
deptName: '',
|
|
|
|
|
deptPopoverVisible: false,
|
|
|
|
|
fileList: [], // 文件列表
|
|
|
|
|
dataForm: {
|
|
|
|
|
id: '' ,
|
|
|
|
|
planId: this.planId || '' ,
|
|
|
|
|
@ -153,24 +206,54 @@
|
|
|
|
|
result: '' ,
|
|
|
|
|
fileId: '' ,
|
|
|
|
|
remark: '' ,
|
|
|
|
|
files: [] ,
|
|
|
|
|
},
|
|
|
|
|
dataRule: {
|
|
|
|
|
executorId: [
|
|
|
|
|
{ required: true, message: '执行人 为必填项', trigger: 'blur' }
|
|
|
|
|
{ required: true, message: '执行人 为必填项', trigger: 'change' }
|
|
|
|
|
],
|
|
|
|
|
executorDept: [
|
|
|
|
|
{ required: true, message: '执行部门 为必填项', trigger: 'blur' }
|
|
|
|
|
{ required: true, message: '执行部门 为必填项', trigger: 'change' }
|
|
|
|
|
],
|
|
|
|
|
execTime: [
|
|
|
|
|
{ required: true, message: '执行时间 为必填项', trigger: 'blur' }
|
|
|
|
|
],
|
|
|
|
|
content: [
|
|
|
|
|
{ required: true, message: '实际维保内容 为必填项', trigger: 'blur' }
|
|
|
|
|
],
|
|
|
|
|
// content: [
|
|
|
|
|
// { required: true, message: '实际维保内容 为必填项', trigger: 'blur' }
|
|
|
|
|
// ],
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
// 更新文件列表
|
|
|
|
|
updateFileList(files) {
|
|
|
|
|
this.fileList = 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 || '', // 附件类型
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
this.dataForm.files = []
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
// 获取项目列表
|
|
|
|
|
getProjectList() {
|
|
|
|
|
apiByProject.pmprojectListByAllApi().then(res => {
|
|
|
|
|
@ -211,6 +294,76 @@
|
|
|
|
|
this.facilityList = []
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
// 获取执行人列表
|
|
|
|
|
getPersonList() {
|
|
|
|
|
// 调用API获取执行人列表
|
|
|
|
|
apiByUser.ebuserListApiByAll({ hasOwnerTenantId: true }).then(res => {
|
|
|
|
|
try {
|
|
|
|
|
this.personList = Array.isArray(res) ? res : (res.list || [])
|
|
|
|
|
} catch (processingErr) {
|
|
|
|
|
this.personList = []
|
|
|
|
|
}
|
|
|
|
|
}).catch(err => {
|
|
|
|
|
this.personList = []
|
|
|
|
|
console.error('获取执行人列表失败:', err)
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
// 获取执行部门列表
|
|
|
|
|
getDeptList() {
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
// 调用API获取部门树
|
|
|
|
|
apiByDept.deptTreeSelect().then(res => {
|
|
|
|
|
try {
|
|
|
|
|
const treeData = Array.isArray(res) ? res : (res.data || [])
|
|
|
|
|
// 保存树形数据用于下拉框显示
|
|
|
|
|
this.deptTreeData = treeData
|
|
|
|
|
// 处理树形数据,提取所有部门用于查找名称
|
|
|
|
|
this.deptList = this.flattenDeptTree(treeData)
|
|
|
|
|
resolve()
|
|
|
|
|
} catch (processingErr) {
|
|
|
|
|
this.deptTreeData = []
|
|
|
|
|
this.deptList = []
|
|
|
|
|
reject(processingErr)
|
|
|
|
|
}
|
|
|
|
|
}).catch(err => {
|
|
|
|
|
this.deptTreeData = []
|
|
|
|
|
this.deptList = []
|
|
|
|
|
console.error('获取执行部门列表失败:', err)
|
|
|
|
|
reject(err)
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
// 将部门树扁平化为列表
|
|
|
|
|
flattenDeptTree(treeData) {
|
|
|
|
|
const result = []
|
|
|
|
|
const flatten = (nodes) => {
|
|
|
|
|
nodes.forEach(node => {
|
|
|
|
|
result.push({
|
|
|
|
|
id: node.deptId,
|
|
|
|
|
name: node.deptName
|
|
|
|
|
})
|
|
|
|
|
if (node.children && node.children.length > 0) {
|
|
|
|
|
flatten(node.children)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
flatten(treeData)
|
|
|
|
|
return result
|
|
|
|
|
},
|
|
|
|
|
// 根据部门ID获取部门名称
|
|
|
|
|
getDeptNameById(deptId) {
|
|
|
|
|
if (!deptId) return ''
|
|
|
|
|
const dept = this.deptList.find(item => item.id == deptId)
|
|
|
|
|
return dept ? dept.name : ''
|
|
|
|
|
},
|
|
|
|
|
// 处理部门树节点点击
|
|
|
|
|
handleDeptNodeClick(data) {
|
|
|
|
|
this.dataForm.executorDept = data.deptId
|
|
|
|
|
this.deptName = data.deptName
|
|
|
|
|
this.deptPopoverVisible = false
|
|
|
|
|
// 手动触发执行部门的验证
|
|
|
|
|
this.$refs.dataForm.validateField('executorDept')
|
|
|
|
|
},
|
|
|
|
|
// 项目选择变化处理
|
|
|
|
|
handleProjectChange(projectId) {
|
|
|
|
|
this.dataForm.buildingId = '' // 重置楼栋选择
|
|
|
|
|
@ -235,8 +388,36 @@
|
|
|
|
|
this.dataForm.facilityId = facilityId || this.dataForm.facilityId
|
|
|
|
|
this.dataForm.buildingId = buildingId || this.dataForm.buildingId
|
|
|
|
|
this.dataForm.projectId = projectId || this.dataForm.projectId
|
|
|
|
|
|
|
|
|
|
// 获取项目列表
|
|
|
|
|
this.getProjectList()
|
|
|
|
|
// 获取执行人列表
|
|
|
|
|
this.getPersonList()
|
|
|
|
|
// 获取执行部门列表
|
|
|
|
|
this.getDeptList()
|
|
|
|
|
|
|
|
|
|
// 如果有计划ID,获取计划详情
|
|
|
|
|
if (finalPlanId) {
|
|
|
|
|
apiByPlan.pmfacilitymaintenanceplanDetailApi(finalPlanId).then(res => {
|
|
|
|
|
if (res) {
|
|
|
|
|
// 自动填写项目名称、楼栋名称和设施名称
|
|
|
|
|
this.dataForm.projectId = res.projectId || this.dataForm.projectId
|
|
|
|
|
this.dataForm.buildingId = res.buildingId || this.dataForm.buildingId
|
|
|
|
|
this.dataForm.facilityId = res.facilityId || this.dataForm.facilityId
|
|
|
|
|
|
|
|
|
|
// 如果有项目ID,获取楼栋列表
|
|
|
|
|
if (this.dataForm.projectId) {
|
|
|
|
|
this.getBuildingList(this.dataForm.projectId)
|
|
|
|
|
// 如果有楼栋ID,获取设施列表
|
|
|
|
|
if (this.dataForm.buildingId) {
|
|
|
|
|
this.getFacilityList(this.dataForm.projectId, this.dataForm.buildingId)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}).catch(err => {
|
|
|
|
|
console.error('获取计划详情失败:', err)
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
// 如果有项目ID,获取楼栋列表
|
|
|
|
|
if (this.dataForm.projectId) {
|
|
|
|
|
this.getBuildingList(this.dataForm.projectId)
|
|
|
|
|
@ -245,11 +426,33 @@
|
|
|
|
|
this.getFacilityList(this.dataForm.projectId, this.dataForm.buildingId)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (this.dataForm.id) {
|
|
|
|
|
api.pmfacilitymaintenacerecordDetailApi(id).then(res => {
|
|
|
|
|
this.dataForm = res;
|
|
|
|
|
// 处理文件列表
|
|
|
|
|
if (res.files && res.files.length > 0) {
|
|
|
|
|
this.fileList = res.files.map(file => ({
|
|
|
|
|
id: file.attId || file.id || '',
|
|
|
|
|
name: file.name || file.oldName || '',
|
|
|
|
|
attDir: file.attDir || file.attachFileUrl || '',
|
|
|
|
|
attSize: file.attSize || '',
|
|
|
|
|
attType: file.attType || '',
|
|
|
|
|
oldName: file.name || file.oldName || ''
|
|
|
|
|
}))
|
|
|
|
|
} else {
|
|
|
|
|
this.fileList = []
|
|
|
|
|
}
|
|
|
|
|
// 获取项目列表
|
|
|
|
|
this.getProjectList()
|
|
|
|
|
// 获取执行人列表
|
|
|
|
|
this.getPersonList()
|
|
|
|
|
// 获取执行部门列表
|
|
|
|
|
this.getDeptList().then(() => {
|
|
|
|
|
// 设置部门名称
|
|
|
|
|
this.deptName = this.getDeptNameById(this.dataForm.executorDept)
|
|
|
|
|
})
|
|
|
|
|
// 如果有项目ID,获取楼栋列表
|
|
|
|
|
if (this.dataForm.projectId) {
|
|
|
|
|
this.getBuildingList(this.dataForm.projectId)
|
|
|
|
|
@ -259,6 +462,9 @@
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
// 新增时清空文件列表
|
|
|
|
|
this.fileList = []
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
@ -266,10 +472,27 @@
|
|
|
|
|
dataSubmit () {
|
|
|
|
|
this.$refs['dataForm'].validate((valid) => {
|
|
|
|
|
if (valid) {
|
|
|
|
|
// 发送事件给父组件,将维保记录数据传递过去
|
|
|
|
|
this.$emit('saveMaintenanceRecord', this.dataForm)
|
|
|
|
|
if (this.dataForm.id) {
|
|
|
|
|
// 修改
|
|
|
|
|
api.pmfacilitymaintenacerecordUpdateApi(this.dataForm).then(res => {
|
|
|
|
|
this.$message.success('修改成功')
|
|
|
|
|
this.$emit('refreshDataList')
|
|
|
|
|
this.visible = false
|
|
|
|
|
}).catch(err => {
|
|
|
|
|
this.$message.error('修改失败')
|
|
|
|
|
console.error(err)
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
// 新增
|
|
|
|
|
api.pmfacilitymaintenacerecordCreateApi(this.dataForm).then(res => {
|
|
|
|
|
this.$message.success('保存成功')
|
|
|
|
|
this.$emit('refreshDataList')
|
|
|
|
|
this.visible = false
|
|
|
|
|
}).catch(err => {
|
|
|
|
|
this.$message.error('保存失败')
|
|
|
|
|
console.error(err)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|