<template>
|
<j-modal
|
:title='title'
|
:width='width'
|
:visible='visible'
|
:confirmLoading='confirmLoading'
|
switchFullscreen
|
@ok='handleOk'
|
@cancel='handleCancel'
|
cancelText='关闭'
|
>
|
<a-spin :spinning='confirmLoading'>
|
<a-form-model
|
ref='form'
|
:model='model'
|
:rules='isSelfCreate?validatorRules1:validatorRules2'
|
>
|
<a-row>
|
<a-col :span='12'>
|
<a-form-model-item
|
label='维修工单号'
|
:labelCol='labelCol'
|
:wrapperCol='wrapperCol'
|
prop='num'
|
>
|
<a-input
|
v-model='model.num'
|
placeholder='请输入维修订单号'
|
></a-input>
|
</a-form-model-item>
|
</a-col>
|
<a-col
|
:span='12'
|
v-if='!isSelfCreate'
|
>
|
<a-form-model-item
|
label='故障报修单'
|
:labelCol='labelCol'
|
:wrapperCol='wrapperCol'
|
prop='reportRepairId'
|
>
|
<j-popup
|
v-model='model.reportRepairId_dictText'
|
field='id'
|
org-fields='id,num'
|
dest-fields='reportRepairId,reportRepairId_dictText'
|
code='repair_report_msg'
|
:multi='false'
|
@input='popupCallback'
|
placeholder='请选择故障报修单'
|
/>
|
</a-form-model-item>
|
</a-col>
|
<a-col
|
:span='12'
|
v-if='isSelfCreate'
|
>
|
<a-form-model-item
|
label='设备编码/名称/型号'
|
:labelCol='labelCol'
|
:wrapperCol='wrapperCol'
|
prop='equipmentId'
|
>
|
<a-select
|
v-model='model.equipmentId'
|
required
|
placeholder='请选择设备'
|
>
|
<a-select-option
|
v-for='item of equipmentList'
|
:value='item.id'
|
:key='item.id'
|
>
|
{{ (item.num + '/' + item.name + '/' + item.model) }}
|
</a-select-option>
|
</a-select>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span='12'>
|
<a-form-model-item
|
label='维保方式'
|
:labelCol='labelCol'
|
:wrapperCol='wrapperCol'
|
prop='maintenanceMethod'
|
>
|
<j-dict-select-tag
|
placeholder='请选择维保方式'
|
dictCode='maintenance_method'
|
v-model='model.maintenanceMethod'
|
/>
|
</a-form-model-item>
|
</a-col>
|
<a-col
|
:span='12'
|
v-if='isSelfCreate'
|
>
|
<a-form-model-item
|
label='使用部门'
|
:labelCol='labelCol'
|
:wrapperCol='wrapperCol'
|
prop='departId'
|
>
|
<j-popup
|
v-model='model.departId_dictText'
|
field='departId'
|
org-fields='name,departid'
|
dest-fields='departId_dictText,departId'
|
code='depart_msg'
|
:multi='false'
|
@input='popupCallback'
|
placeholder='请选择使用部门'
|
/>
|
</a-form-model-item>
|
</a-col>
|
<a-col
|
:span='12'
|
v-if='isSelfCreate'
|
>
|
<a-form-model-item
|
label='故障时间'
|
:labelCol='labelCol'
|
:wrapperCol='wrapperCol'
|
prop='faultTime'
|
>
|
<j-date
|
placeholder='请选择故障时间'
|
v-model='model.faultTime'
|
:show-time='true'
|
date-format='YYYY-MM-DD HH:mm:ss'
|
style='width: 100%'
|
/>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span='12'>
|
<a-form-model-item
|
label='责任班组'
|
:labelCol='labelCol'
|
:wrapperCol='wrapperCol'
|
prop='teamId'
|
>
|
<j-dict-select-tag
|
allow-clear
|
placeholder='请选择责任班组'
|
:triggerChange='true'
|
dictCode="mom_base_team,name,id,del_flag!='1'"
|
v-model='model.teamId'
|
/>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span='12'>
|
<a-form-model-item
|
label='责任人'
|
:labelCol='labelCol'
|
:wrapperCol='wrapperCol'
|
prop='responsibilityId'
|
>
|
<j-dict-select-tag
|
allow-clear
|
placeholder='请选择责任人'
|
:triggerChange='true'
|
dictCode="sys_user,username,id,del_flag!='1'"
|
v-model='model.responsibilityId'
|
/>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span='12'>
|
<a-form-model-item
|
label='工时定额'
|
:labelCol='labelCol'
|
:wrapperCol='wrapperCol'
|
prop='workingHourQuota'
|
>
|
<a-input-number
|
style='width: 100%'
|
v-model='model.workingHourQuota'
|
placeholder='工时定额'
|
></a-input-number>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span='12'>
|
<a-form-model-item
|
label='委外单位'
|
:labelCol='labelCol'
|
:wrapperCol='wrapperCol'
|
prop='outsourcingUnit'
|
>
|
<j-dict-select-tag
|
allow-clear
|
placeholder='请选择委外单位'
|
:triggerChange='true'
|
dictCode="mom_base_supplier,name,id,del_flag!='1'"
|
v-model='model.outsourcingUnit'
|
/>
|
</a-form-model-item>
|
</a-col>
|
</a-row>
|
|
|
<a-row :gutter='24'>
|
<a-col
|
:span='12'
|
v-if='isSelfCreate'
|
>
|
<a-form-model-item
|
label='故障描述'
|
:labelCol='labelCol'
|
:wrapperCol='wrapperCol'
|
prop='faultDescription'
|
>
|
<a-input
|
v-model='model.faultDescription'
|
placeholder='请输入故障描述'
|
></a-input>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span='12'>
|
<a-form-model-item
|
label='备注'
|
:labelCol='labelCol'
|
:wrapperCol='wrapperCol'
|
prop='remark'
|
>
|
<a-textarea
|
v-model='model.remark'
|
placeholder='请输入备注'
|
></a-textarea>
|
</a-form-model-item>
|
</a-col>
|
<!-- <a-col
|
:span="12"
|
v-if="isSelfCreate"
|
>
|
<a-form-model-item
|
label="故障照片"
|
:labelCol="labelCol"
|
:wrapperCol="wrapperCol"
|
prop="photo"
|
>
|
<j-image-upload
|
:isMultiple="false"
|
v-model="model.photo"
|
></j-image-upload>
|
</a-form-model-item>
|
</a-col>-->
|
</a-row>
|
<a-row>
|
<a-col
|
:span="24"
|
v-if="isSelfCreate"
|
>
|
<a-form-model-item
|
label="故障照片"
|
:labelCol="labelCol"
|
:wrapperCol="wrapperCol"
|
prop="photo"
|
>
|
<j-image-upload
|
:isMultiple="true"
|
v-model="model.photo"
|
></j-image-upload>
|
</a-form-model-item>
|
</a-col>
|
</a-row>
|
</a-form-model>
|
<!-- <a-tabs
|
type='card'
|
defaultActiveKey='1'
|
>
|
<a-tab-pane
|
tab='维修内容'
|
key='1'
|
>
|
<repair-order-detail-report-model
|
@getDetailList='getDetailList'
|
ref='detailReport'
|
:repairOrderId='model.id'
|
></repair-order-detail-report-model>
|
</a-tab-pane>
|
<a-tab-pane
|
tab='实际用料'
|
key='2'
|
forceRender
|
>
|
<repair-order-actual-material-report-model
|
@getActualMaterialList='getActualMaterialList'
|
ref='actualMaterialReport'
|
:repairOrderId='model.id'
|
></repair-order-actual-material-report-model>
|
</a-tab-pane>
|
<a-tab-pane
|
tab='实际工时'
|
key='3'
|
forceRender
|
>
|
<repair-order-actual-hours-report-model
|
ref='actualHoursReport'
|
@getHoursList='getHoursList'
|
:repairOrderId='model.id'
|
></repair-order-actual-hours-report-model>
|
</a-tab-pane>
|
<a-tab-pane
|
tab='故障分析'
|
key='4'
|
forceRender
|
>
|
<repair-order-fault-analysis-report-model
|
@getFaultAnalysisList='getFaultAnalysisList'
|
ref='faultAnalysisReport'
|
:repairOrderId='model.id'
|
></repair-order-fault-analysis-report-model>
|
</a-tab-pane>
|
</a-tabs>-->
|
</a-spin>
|
</j-modal>
|
</template>
|
|
<script>
|
|
import { httpAction } from '@/api/manage'
|
import { validateDuplicateValue } from '@/utils/util'
|
import { getAction } from '../../../../api/manage'
|
import { duplicateCheck } from '@/api/api'
|
import RepairOrderActualHoursReportModel
|
from '../../repairOrderFinishedReport/modules/RepairOrderActualHoursReportModel.vue'
|
import RepairOrderActualMaterialReportModel
|
from '../../repairOrderFinishedReport/modules/RepairOrderActualMaterialReportModel.vue'
|
import RepairOrderDetailReportModel from '../../repairOrderFinishedReport/modules/RepairOrderDetailReportModel.vue'
|
import RepairOrderFaultAnalysisReportModel
|
from '../../repairOrderFinishedReport/modules/RepairOrderFaultAnalysisReportModel.vue'
|
|
export default {
|
name: 'RepairOrderModal',
|
components: {
|
RepairOrderActualMaterialReportModel,
|
RepairOrderActualHoursReportModel,
|
RepairOrderDetailReportModel,
|
RepairOrderFaultAnalysisReportModel
|
},
|
props: {
|
isSelfCreate: {
|
type: Boolean,
|
required: false,
|
default: true
|
}
|
},
|
data() {
|
return {
|
title: '操作',
|
width: 1400,
|
visible: false,
|
model: {},
|
labelCol: {
|
xs: { span: 24 },
|
sm: { span: 5 }
|
},
|
wrapperCol: {
|
xs: { span: 24 },
|
sm: { span: 16 }
|
},
|
confirmLoading: false,
|
validatorRules1: {
|
workingHourQuota: [
|
{ required: true, message: '请输入工时定额!' }
|
],
|
outsourcingUnit: [
|
{ required: true, message: '请选择委外单位!' }
|
],
|
num: [
|
{ required: true, message: '请输入单据号!' },
|
{ validator: this.validateNum },
|
{ max: 32, message: '超过做大输入限制,请缩减长度' }
|
],
|
equipmentId: [
|
{ required: true, message: '请选择设备!' }
|
],
|
faultTime: [
|
{ required: true, message: '请选择故障时间!' }
|
],
|
faultDescription: [
|
{ required: true, message: '请输入故障描述!' },
|
{ max: 32, message: '超过最大输入限制,请缩减长度' }
|
],
|
responsibilityId: [
|
{ required: true, message: '请输入责任人!' }
|
],
|
maintenanceMethod: [
|
{ required: true, message: '请选择维保方式!' }
|
],
|
teamId: [
|
{ required: true, message: '请选择责任班组!' }
|
],
|
remark: [{ min: 0, max: 100, message: '超过做大输入限制,请缩减长度' }],
|
departId: [
|
{ required: true, message: '请选择使用部门!' }
|
]
|
},
|
validatorRules2: {
|
num: [
|
{ required: true, message: '请输入类型编码!' },
|
{ validator: this.validateNum },
|
{ max: 32, message: '超过做大输入限制,请缩减长度' }
|
],
|
maintenanceMethod: [
|
{ required: true, message: '请选择维保方式!' }
|
],
|
reportRepairId: [
|
{ required: true, message: '请选择故障报修单!' },
|
{ validator: this.validateReportRepair }
|
],
|
teamId: [
|
{ required: true, message: '请选择责任班组!' }
|
],
|
remark: [{ min: 0, max: 100, message: '超过做大输入限制,请缩减长度' }],
|
departId: [
|
{ required: true, message: '请选择使用部门!' }
|
]
|
},
|
url: {
|
add: '/eam/reportAfterRepair/add',
|
edit: '/eam/reportAfterRepair/edit',
|
getEquipments: '/eam/repairOrder/getEquipments',
|
getRepairReport: '/eam/repairOrder/getRepairReport'
|
},
|
equipmentList: [],
|
hoursList: [],
|
actualMaterialList: [],
|
faultAnalysisList: [],
|
orderDetailList: [],
|
reportRepairStatus: false
|
|
}
|
},
|
created() {
|
//备份model原始值
|
this.getEquipments()
|
this.modelDefault = JSON.parse(JSON.stringify(this.model))
|
},
|
methods: {
|
add() {
|
this.edit(this.modelDefault)
|
this.model.id = this.getUuiD(16)
|
},
|
edit(record) {
|
this.model = Object.assign({}, record)
|
console.log(this.isSelfCreate)
|
this.visible = true
|
},
|
close() {
|
this.$emit('close')
|
this.visible = false
|
this.$refs.form.clearValidate()
|
},
|
handleOk() {
|
const that = this
|
// 触发表单验证
|
this.$refs.form.validate(valid => {
|
if (valid) {
|
that.confirmLoading = true
|
let httpurl = ''
|
let method = ''
|
if (this.title == '新增') {
|
httpurl += this.url.add
|
method = 'post'
|
} else {
|
httpurl += this.url.edit
|
method = 'put'
|
}
|
//子表验证(维修内容)
|
var details = this.orderDetailList
|
for (let i = 0; i < details.length; i++) {
|
if (details[i].location == undefined || details[i].location == null || details[i].location == '') {
|
that.$message.warning('请填写维修内容第' + (i + 1) + '行故障原因!')
|
that.confirmLoading = false
|
return false
|
}
|
if (details[i].sketchMap == undefined || details[i].sketchMap == null || details[i].sketchMap == '') {
|
that.$message.warning('请上传维修内容第' + (i + 1) + '行故障示意图!')
|
that.confirmLoading = false
|
return false
|
}
|
if (details[i].maintenanceItem == undefined || details[i].maintenanceItem == null || details[i].maintenanceItem == '') {
|
that.$message.warning('请填写维修内容第' + (i + 1) + '行维修项目!')
|
that.confirmLoading = false
|
return false
|
}
|
if (details[i].maintenanceRequire == undefined || details[i].maintenanceRequire == null || details[i].maintenanceRequire == '') {
|
that.$message.warning('请填写维修内容第' + (i + 1) + '行维修维修要求!')
|
that.confirmLoading = false
|
return false
|
}
|
if (details[i].maintenanceWay == undefined || details[i].maintenanceWay == null || details[i].maintenanceWay == '') {
|
that.$message.warning('请填写维修内容第' + (i + 1) + '行维修方法!')
|
that.confirmLoading = false
|
return false
|
}
|
if (details[i].maintenanceTooling == undefined || details[i].maintenanceTooling == null || details[i].maintenanceTooling == '') {
|
that.$message.warning('请填写维修内容第' + (i + 1) + '行维修工具!')
|
that.confirmLoading = false
|
return false
|
}
|
if (details[i].safetyRequirement == undefined || details[i].safetyRequirement == null || details[i].safetyRequirement == '') {
|
that.$message.warning('请填写维修内容第' + (i + 1) + '行安全要求!')
|
that.confirmLoading = false
|
return false
|
}
|
if (details[i].timeQuota == undefined || details[i].timeQuota == null || details[i].timeQuota == '') {
|
that.$message.warning('请填写维修内容第' + (i + 1) + '行工时定额!')
|
that.confirmLoading = false
|
return false
|
}
|
if (details[i].repairCycle == undefined || details[i].repairCycle == null || details[i].repairCycle == '') {
|
that.$message.warning('请填写维修内容第' + (i + 1) + '行维修周期!')
|
that.confirmLoading = false
|
return false
|
}
|
if (details[i].mamaintenanceSpecialtyId == undefined || details[i].mamaintenanceSpecialtyId == null || details[i].mamaintenanceSpecialtyId == '') {
|
that.$message.warning('请选择维修内容第' + (i + 1) + '行维保专业!')
|
that.confirmLoading = false
|
return false
|
}
|
}
|
//子表验证(实际用料)
|
var actualMaterials = this.actualMaterialList
|
for (let i = 0; i < actualMaterials.length; i++) {
|
if (actualMaterials[i].materialId == undefined || actualMaterials[i].materialId == null || actualMaterials[i].materialId == '') {
|
that.$message.warning('请选择实际用料第' + (i + 1) + '行物料!')
|
that.confirmLoading = false
|
return false
|
}
|
if (actualMaterials[i].actualQuantity == undefined || actualMaterials[i].actualQuantity == null || actualMaterials[i].actualQuantity == '') {
|
that.$message.warning('请填写实际用料第' + (i + 1) + '行用料数!')
|
that.confirmLoading = false
|
return false
|
}
|
}
|
//子表验证(实际工时)
|
var workHoursDataSource = this.hoursList
|
for (let i = 0; i < workHoursDataSource.length; i++) {
|
if (workHoursDataSource[i].userId == undefined || workHoursDataSource[i].userId == null || workHoursDataSource[i].userId == '') {
|
that.$message.warning('请选择实际工时第' + (i + 1) + '行维修人员!')
|
that.confirmLoading = false
|
return false
|
}
|
if (workHoursDataSource[i].actualHour == undefined || workHoursDataSource[i].actualHour == null || workHoursDataSource[i].actualHour == '') {
|
that.$message.warning('请填写实际工时第' + (i + 1) + '行实际工时!')
|
that.confirmLoading = false
|
return false
|
}
|
}
|
//子表验证(故障分析)
|
let faultAnalysisDataSource = this.faultAnalysisList
|
for (let i = 0; i < faultAnalysisDataSource.length; i++) {
|
if (faultAnalysisDataSource[i].faultCause == undefined || faultAnalysisDataSource[i].faultCause == null || faultAnalysisDataSource[i].faultCause == '') {
|
that.$message.warning('请填写故障分析第' + (i + 1) + '行故障原因!')
|
that.confirmLoading = false
|
return false
|
}
|
if (faultAnalysisDataSource[i].faultType == undefined || faultAnalysisDataSource[i].faultType == null || faultAnalysisDataSource[i].faultType == '') {
|
that.$message.warning('请填写故障分析第' + (i + 1) + '行故障类型!')
|
that.confirmLoading = false
|
return false
|
}
|
}
|
//表单提交
|
this.model.actualMaterials = actualMaterials
|
this.model.orderDetails = details
|
this.model.faultAnalysis = faultAnalysisDataSource
|
this.model.actualHours = workHoursDataSource
|
httpAction(httpurl, this.model, method).then((res) => {
|
if (res.success) {
|
that.$message.success(res.message)
|
that.$emit('ok')
|
} else {
|
that.$message.warning(res.message)
|
}
|
}).finally(() => {
|
that.confirmLoading = false
|
that.close()
|
that.$refs.detailReport.dataSource = []
|
that.$refs.actualMaterialReport.dataSource = []
|
that.$refs.actualHoursReport.dataSource = []
|
that.$refs.faultAnalysisReport.dataSource = []
|
})
|
} else {
|
return false
|
}
|
})
|
},
|
handleCancel() {
|
this.close()
|
},
|
//表单校验
|
validateNum(rule, value, callback) {
|
var params = {
|
tableName: 'mom_eam_report_after_repair',
|
fieldName: 'num',
|
fieldVal: value,
|
dataId: this.model.id,
|
//数据库中存在字段del_flag并使用该字段作为未删除策略,真删除:false 假删除:true
|
delFlag: '0'
|
}
|
duplicateCheck(params).then((res) => {
|
if (res.success) {
|
callback()
|
} else {
|
callback('编号已存在!')
|
}
|
})
|
},
|
validateReportRepair(rule, value, callback) {
|
var params = {
|
tableName: 'mom_eam_repair_order',
|
fieldName: 'report_repair_id',
|
fieldVal: this.model.reportRepairId,
|
dataId: this.model.id,
|
//数据库中存在字段del_flag并使用该字段作为未删除策略,真删除:false 假删除:true
|
delFlag: '0'
|
}
|
duplicateCheck(params).then((res) => {
|
if (res.success) {
|
callback()
|
} else {
|
callback('该故障报修单已生成工单,请重新选择!')
|
}
|
})
|
},
|
// 获取选择器的列表
|
getEquipments() {
|
getAction(this.url.getEquipments).then(res => {
|
this.equipmentList = res.result
|
})
|
},
|
getHoursList(val) {
|
this.hoursList = val
|
},
|
getActualMaterialList(val) {
|
this.actualMaterialList = val
|
},
|
getFaultAnalysisList(val) {
|
this.faultAnalysisList = val
|
},
|
getDetailList(val) {
|
this.orderDetailList = val
|
},
|
getUuiD(randomLength) {
|
return Number(
|
Math.random()
|
.toString()
|
.substr(2, randomLength) + Date.now()
|
).toString(36)
|
},
|
popupCallback(value, row) {
|
this.model = Object.assign(this.model, row)
|
console.log(this.model)
|
}
|
}
|
}
|
</script>
|