<template>
|
<j-modal
|
:title="title"
|
:width="width"
|
:visible="visible"
|
switchFullscreen
|
@ok="handleOk"
|
:okButtonProps="{ class:{'jee-hidden': disableSubmit} }"
|
@cancel="handleCancel"
|
cancelText="关闭">
|
|
<a-spin :spinning="spinning">
|
<a-form-model ref="form" :model="model" :rules="validatorRules" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
<a-row :gutter="24">
|
<a-col :span="8">
|
<a-form-model-item prop="standardCode" label="工单号">
|
<a-input placeholder="工单号自动生成" v-model="model.orderNum" readOnly/>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="8">
|
<a-form-model-item prop="equipmentId" label="设备编号">
|
<a-select placeholder="请选择设备" v-model="model.equipmentId" :options="inspectionEquipmentOptions" @change="handleEquipmentChange"></a-select>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="8">
|
<a-form-model-item prop="standardName" label="标准名称">
|
<a-input placeholder="选择设备后自动带出" readOnly v-model="model.standardName"/>
|
</a-form-model-item>
|
</a-col>
|
</a-row>
|
<a-row :gutter="24">
|
<a-col :span="8">
|
<a-form-model-item prop="standardCode" label="标准编码">
|
<a-input placeholder="选择设备后自动带出" readOnly v-model="model.standardCode"/>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="8">
|
<a-form-model-item label="保养周期">
|
<a-input placeholder="选择设备后自动带出" v-model="model.maintenancePeriod" readOnly/>
|
</a-form-model-item>
|
</a-col>
|
</a-row>
|
<a-row :gutter="24">
|
<vxe-table
|
ref="table"
|
border
|
show-overflow
|
show-header-overflow
|
:scroll-x="{enabled: true}"
|
:data="dataSource"
|
:edit-config="{trigger: 'click', mode: 'cell'}"
|
:edit-rules="editRules"
|
>
|
<vxe-table-column title="序号" field="itemCode" width="50" align="center"></vxe-table-column>
|
<vxe-table-column title="部位" field="itemPart" align="center"></vxe-table-column>
|
<vxe-table-column title="保养项目" field="itemName" align="center"></vxe-table-column>
|
<vxe-table-column title="检查标准或要求" field="itemDemand" align="center"></vxe-table-column>
|
<vxe-table-column title="保养要求" field="itemDemandAlias" align="center"></vxe-table-column>
|
<vxe-table-column title="检查方法" field="checkMethod" align="center"></vxe-table-column>
|
<vxe-table-column title="点检结果" field="inspectionResult" align="center"
|
:edit-render="{name: '$select', options: inspectionResultOptions}">
|
<template #default="{ row }">
|
<span v-if="row.inspectionResult">{{ getInspectionResultLabel(row.inspectionResult) }}</span>
|
<span v-else class="placeholder-text">请选择点检结果</span>
|
</template>
|
</vxe-table-column>
|
<vxe-table-column title="异常描述" field="exceptionDescription" align="center"
|
:edit-render="{name: '$input', placeholder: '请输入异常描述'}">
|
<template #default="{ row }">
|
<span v-if="row.inspectionResult === '2' && !row.exceptionDescription" class="placeholder-text">请输入异常描述</span>
|
<span v-else-if="row.exceptionDescription">{{ row.exceptionDescription }}</span>
|
</template>
|
<template #edit="{ row }">
|
<vxe-input v-if="row.inspectionResult === '2'" v-model="row.exceptionDescription" placeholder="请输入异常描述" />
|
</template>
|
</vxe-table-column>
|
</vxe-table>
|
</a-row>
|
</a-form-model>
|
</a-spin>
|
</j-modal>
|
</template>
|
|
<script>
|
import { postAction, getAction, putAction } from '@api/manage'
|
|
export default {
|
name: 'MesProductionWorkOrderReportModal',
|
data () {
|
return {
|
title: '设备点检',
|
width: 1200,
|
visible: false,
|
loading: false,
|
disableSubmit: false,
|
model: {},
|
spinning: false,
|
validatorRules: {
|
},
|
labelCol: {
|
xs: { span: 24 },
|
sm: { span: 6 },
|
},
|
wrapperCol: {
|
xs: { span: 24 },
|
sm: { span: 18 },
|
},
|
inspectionResultOptions: [
|
{
|
label: '正常',
|
value: '1'
|
},
|
{
|
label: '异常',
|
value: '2'
|
}
|
],
|
dataSource: [],
|
editRules: {
|
inspectionResult: [
|
{ required: true, message: '检查结果必须选择' }
|
],
|
exceptionDescription: [
|
{
|
required: true,
|
message: '异常描述不能为空',
|
validator: ({ cellValue, row }) => {
|
// 当点检结果为异常时,异常描述必填
|
if (row.inspectionResult === '2') {
|
return cellValue && cellValue.trim() !== '' ? true : new Error('异常描述必须填写');
|
}
|
return true;
|
}
|
}
|
]
|
},
|
url: {
|
report: '/mesworkreporting/mesWorkReporting/add',
|
listInspectionEquipment: '/eam/equipment/listProductionLineInspectionEquipment',
|
queryByEquipmentId: '/eam/maintenanceStandard/queryByEquipmentId',
|
addInspectionOrder: '/eam/eamInspectionOrder/add',
|
updateOrderInspectionStatus: '/mes/mesProductionWorkOrder/edit'
|
},
|
inspectionEquipmentOptions: [],
|
workOrderId: null
|
}
|
},
|
computed: {
|
formDisabled(){
|
return this.disabled
|
}
|
},
|
methods: {
|
getInspectionResultLabel(value) {
|
const option = this.inspectionResultOptions.find(item => item.value === value);
|
return option ? option.label : value;
|
},
|
inspect (record) {
|
this.resetFormData()
|
this.workOrderId = record.id
|
getAction(this.url.listInspectionEquipment, {orderId: record.id}).then(res => {
|
if (res.success) {
|
this.inspectionEquipmentOptions = res.result
|
}
|
})
|
this.visible = true
|
},
|
close () {
|
this.$emit('close');
|
this.visible = false;
|
},
|
handleEquipmentChange(id) {
|
getAction(this.url.queryByEquipmentId, {equipmentId: id}).then(res => {
|
if (res.success) {
|
console.log(res.result)
|
this.model = {
|
...this.model,
|
standardId: res.result.id,
|
standardName: res.result.standardName,
|
standardCode: res.result.standardCode,
|
maintenancePeriod: res.result.maintenancePeriod
|
}
|
this.dataSource = res.result.maintenanceStandardDetailList
|
}
|
})
|
},
|
handleOk () {
|
this.$refs.table.validate((valid) => {
|
if (valid) {
|
this.$message.error("请完成所有必填信息后再提交!")
|
} else {
|
let tableData = this.$refs.table.getTableData().fullData
|
const data = {
|
...this.model,
|
workOrderId: this.workOrderId,
|
tableDetailList: tableData
|
}
|
postAction(this.url.addInspectionOrder, data).then(res=> {
|
if (res.success) {
|
this.$message.success(res.message)
|
getAction(this.url.listInspectionEquipment, {orderId: this.workOrderId}).then(res => {
|
if (res.success) {
|
if (res.result && res.result.length > 0) {
|
// 还有设备需要点检,清空表单和表格数据
|
this.inspectionEquipmentOptions = res.result
|
this.resetFormData()
|
} else {
|
// 没有需要点检的设备,更新点检状态
|
putAction(this.url.updateOrderInspectionStatus, {id: this.workOrderId, equipmentInspectionFlag: '1'}).then(res => {
|
if (res.success) {
|
this.$message.success('设备点检完成')
|
this.submitCallback()
|
} else {
|
this.$message.warning(res.message)
|
}
|
})
|
this.submitCallback()
|
}
|
}
|
})
|
} else {
|
this.$message.warning(res.message)
|
}
|
})
|
}
|
})
|
},
|
resetFormData() {
|
this.$refs.form.resetFields()
|
this.model = {}
|
this.dataSource = []
|
},
|
submitCallback(){
|
this.$emit('ok');
|
this.visible = false;
|
},
|
handleCancel () {
|
this.close()
|
}
|
}
|
}
|
</script>
|
|
<style scoped>
|
|
.placeholder-text {
|
color: #999;
|
font-style: italic;
|
}
|
|
</style>
|