<template>
|
<j-modal :title="title" :width="1200" :visible="visible" :confirmLoading="confirmLoading"
|
:okButtonProps="{ class:{'jee-hidden': disableSubmit} }" fullscreen @ok="handleOk"
|
@cancel="handleCancel" centered cancelText="关闭">
|
<a-spin :spinning="spinning">
|
<a-form-model ref="form" :model="model" :rules="validatorRules" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
<a-row :gutter="24" id="outer-row">
|
<a-col :span="8" class="scroll-col">
|
<a-tabs>
|
<a-tab-pane tab="基础信息">
|
<a-row>
|
<a-col :span="12">
|
<a-form-model-item label="工单号">
|
<a-input v-model="model.orderNum" readOnly/>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="12">
|
<a-form-model-item label="统一编码">
|
<maintenance-equipment-select v-model="model.equipmentId" maintenanceCategory="SECOND_MAINTENANCE"
|
@autocompleteForm="autocompleteForm" disabled/>
|
</a-form-model-item>
|
</a-col>
|
</a-row>
|
|
<a-row>
|
<a-col :span="12">
|
<a-form-model-item label="规范名称">
|
<a-input v-model="model.standardName" readOnly/>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="12">
|
<a-form-model-item label="保养日期">
|
<a-input v-model="model.maintenanceDate" readOnly/>
|
</a-form-model-item>
|
</a-col>
|
</a-row>
|
|
<a-row>
|
<a-col :span="12">
|
<a-form-model-item label="操作工">
|
<a-input v-model="model.operator_dictText" readOnly/>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="12">
|
<a-form-model-item label="维修工">
|
<a-input v-model="model.repairman_dictText" readOnly/>
|
</a-form-model-item>
|
</a-col>
|
</a-row>
|
|
<a-row>
|
<a-col :span="12">
|
<a-form-model-item label="保养周期">
|
<a-input v-model="model.maintenancePeriod" readOnly/>
|
</a-form-model-item>
|
</a-col>
|
</a-row>
|
|
<a-row>
|
<a-form-model-item :labelCol="labelColLong" :wrapperCol="wrapperColLong" label="备注">
|
<a-textarea v-model="model.remark" readOnly/>
|
</a-form-model-item>
|
</a-row>
|
</a-tab-pane>
|
</a-tabs>
|
</a-col>
|
|
<a-col class="scroll-col"
|
:span="model.maintenanceStatus&&model.maintenanceStatus!='WAIT_MAINTENANCE'&&model.maintenanceStatus!='UNDER_MAINTENANCE'?10:16">
|
<a-tabs :active-key="activeTabKey" @change="handleTabChange">
|
<a-tab-pane :key="1" tab="操作工"
|
v-if="selectShenpiData.taskDefKey&&selectShenpiData.taskDefKey=='operator_task'||
|
(model.maintenanceStatus&&model.maintenanceStatus!='UNDER_MAINTENANCE')">
|
<j-vxe-table ref="editableDetailTable1" :rowNumber="false" rowSelection bordered
|
alwaysEdit keep-source
|
:dataSource="detail.operatorMaintenanceList" :columns="detail.columns"
|
@selectRowChange="handleTableSelectRowChange($event,'Operator')">
|
<template v-slot:maintenanceResult="props">
|
<j-dict-select-tag v-model="props.row.maintenanceResult" dictCode="maintenance_result"
|
placeholder="请选择保养结果"
|
:disabled="disableSubmit||(model.maintenanceStatus&&model.maintenanceStatus!='UNDER_MAINTENANCE')"
|
@change="handleInspectionResultSelectChange($event,props.row)"
|
style="width: 100%"/>
|
</template>
|
|
<template v-slot:exceptionDescription="props">
|
<a-textarea :rows="1" :autoSize="false" v-model="props.row.exceptionDescription"
|
:placeholder="props.row.maintenanceResult&&props.row.maintenanceResult!='1'?'请输入异常描述':''"
|
:disabled="disableSubmit||
|
(model.maintenanceStatus&&model.maintenanceStatus!='UNDER_MAINTENANCE') ||
|
!props.row.maintenanceResult ||
|
props.row.maintenanceResult === '1'"/>
|
</template>
|
|
<template v-slot:reportFlag="props">
|
<j-dict-select-tag v-model="props.row.reportFlag" dictCode="yn" style="width: 100%"
|
:placeholder="props.row.maintenanceResult&&props.row.maintenanceResult!='1'?'请选择异常是否报修':''"
|
:disabled="disableSubmit ||
|
(model.maintenanceStatus&&model.maintenanceStatus!='UNDER_MAINTENANCE') ||
|
!props.row.maintenanceResult ||
|
props.row.maintenanceResult === '1'"/>
|
</template>
|
</j-vxe-table>
|
</a-tab-pane>
|
|
<a-tab-pane :key="2" tab="维修工"
|
v-if="selectShenpiData.taskDefKey&&selectShenpiData.taskDefKey=='maintenance_task'||
|
(model.maintenanceStatus&&model.maintenanceStatus!='UNDER_MAINTENANCE')">
|
<j-vxe-table ref="editableDetailTable2" :rowNumber="false" rowSelection bordered
|
alwaysEdit kee-source
|
:dataSource="detail.repairerMaintenanceList" :columns="detail.columns"
|
@selectRowChange="handleTableSelectRowChange($event,'Repairer')">
|
<template v-slot:maintenanceResult="props">
|
<j-dict-select-tag v-model="props.row.maintenanceResult" dictCode="maintenance_result"
|
placeholder="请选择保养结果"
|
:disabled="disableSubmit||(model.maintenanceStatus&&model.maintenanceStatus!='UNDER_MAINTENANCE')"
|
@change="handleInspectionResultSelectChange($event,props.row)"
|
style="width: 100%"/>
|
</template>
|
|
<template v-slot:exceptionDescription="props">
|
<a-textarea :rows="1" :autoSize="false" v-model="props.row.exceptionDescription"
|
:placeholder="props.row.maintenanceResult&&props.row.maintenanceResult!='1'?'请输入异常描述':''"
|
:disabled="disableSubmit ||
|
(model.maintenanceStatus&&model.maintenanceStatus!='UNDER_MAINTENANCE') ||
|
!props.row.maintenanceResult ||
|
props.row.maintenanceResult === '1'"/>
|
</template>
|
|
<template v-slot:reportFlag="props">
|
<j-dict-select-tag v-model="props.row.reportFlag"
|
:placeholder="props.row.maintenanceResult&&props.row.maintenanceResult!='1'?'请选择异常是否报修':''"
|
dictCode="yn" style="width: 100%"
|
:disabled="disableSubmit||
|
(model.maintenanceStatus&&model.maintenanceStatus!='UNDER_MAINTENANCE') ||
|
!props.row.maintenanceResult ||
|
props.row.maintenanceResult === '1'"/>
|
</template>
|
</j-vxe-table>
|
</a-tab-pane>
|
|
<template v-if="selectShenpiData.procInstId">
|
<a-tab-pane key='3' tab='流程图'>
|
<img :src="imageSrc" alt="Fetched Image"/>
|
</a-tab-pane>
|
</template>
|
|
<a-button
|
v-if="activeTabKey!=='3'"
|
:disabled="disableSubmit ||
|
(model.maintenanceStatus&&model.maintenanceStatus!='UNDER_MAINTENANCE') ||
|
(activeTabKey=='1'&&selectedOperatorMaintenanceRowKeys.length == 0)||
|
(activeTabKey=='2'&&selectedRepairerMaintenanceRowKeys.length == 0)"
|
slot="tabBarExtraContent"
|
type="primary" @click="handleSelectAllInspectionResult">批量保养正常
|
</a-button>
|
</a-tabs>
|
</a-col>
|
|
<!--右侧审批列-->
|
<a-col :span="6" class="scroll-col"
|
v-if="model.maintenanceStatus&&model.maintenanceStatus!='WAIT_MAINTENANCE'&&model.maintenanceStatus!='UNDER_MAINTENANCE'">
|
<a-tabs v-if="displayAdminConfirmFlag">
|
<a-tab-pane tab="管理员确认">
|
<a-row>
|
<a-col :span="24">
|
<a-form-model-item prop="manageUserResult" label="确认类型">
|
<j-dict-select-tag type='radio' v-model='model.manageUserResult' dictCode='approve_reject'
|
placeholder="请选择确认类型"
|
:disabled="disableSubmit || model.maintenanceStatus!='WAIT_ADMIN_CONFIRM'"/>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="24">
|
<a-form-model-item label="问题描述">
|
<a-textarea placeholder="请描述问题" v-model='model.problemDescription'
|
:disabled="disableSubmit || model.maintenanceStatus!='WAIT_ADMIN_CONFIRM'"/>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="24">
|
<a-form-model-item label="处理措施描述">
|
<a-textarea placeholder="请描述处理措施" v-model="model.dealDescription"
|
:disabled="disableSubmit || model.maintenanceStatus!='WAIT_ADMIN_CONFIRM'"/>
|
</a-form-model-item>
|
</a-col>
|
</a-row>
|
</a-tab-pane>
|
</a-tabs>
|
|
<a-tabs v-if="displayInspectorConfirmFlag">
|
<a-tab-pane tab="检查人确认">
|
<a-row>
|
<a-col :span="24">
|
<a-form-model-item prop="inspectorResult" label="确认类型">
|
<j-dict-select-tag type='radio' v-model='model.inspectorResult' dictCode='approve_reject'
|
placeholder="请选择确认类型"
|
:disabled="disableSubmit || model.maintenanceStatus!='WAIT_INSPECTOR_CONFIRM'"/>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="24">
|
<a-form-model-item label="确认意见">
|
<a-textarea placeholder="请输入意见" v-model="model.inspectConfirmComment"
|
:disabled="disableSubmit || model.maintenanceStatus!='WAIT_INSPECTOR_CONFIRM'"/>
|
</a-form-model-item>
|
</a-col>
|
</a-row>
|
</a-tab-pane>
|
</a-tabs>
|
</a-col>
|
</a-row>
|
</a-form-model>
|
</a-spin>
|
</j-modal>
|
</template>
|
|
<script>
|
import { downFile, getAction, httpAction } from '@/api/manage'
|
import { JVxeTableModelMixin } from '@/mixins/JVxeTableModelMixin.js'
|
import { JVXETypes } from '@comp/jeecg/JVxeTable'
|
import MaintenanceEquipmentSelect from '@views/eam/equipment/modules/MaintenanceEquipmentSelect'
|
|
export default {
|
name: 'SecondMaintenanceApprovalModal',
|
mixins: [JVxeTableModelMixin],
|
components: {
|
MaintenanceEquipmentSelect
|
},
|
props: {
|
selectShenpiData: {
|
type: Object
|
}
|
},
|
data() {
|
return {
|
title: '操作',
|
visible: false,
|
model: {},
|
labelCol: {
|
xs: { span: 24 },
|
sm: { span: 6 }
|
},
|
wrapperCol: {
|
xs: { span: 24 },
|
sm: { span: 16 }
|
},
|
labelColLong: {
|
xs: { span: 24 },
|
sm: { span: 3 }
|
},
|
wrapperColLong: {
|
xs: { span: 24 },
|
sm: { span: 20 }
|
},
|
confirmLoading: false,
|
spinning: false,
|
imageSrc: null,
|
activeTabKey: 1,
|
validatorRules: {
|
manageUserResult: [{ required: true, message: '请选择确认类型' }],
|
inspectorResult: [{ required: true, message: '请选择确认类型' }]
|
},
|
url: {
|
queryById: '/eam/secondMaintenanceOrder/list',
|
detail: '/eam/secondMaintenanceOrderDetail/queryList',
|
approval: '/eam/secondMaintenanceOrder/approval',
|
diagramView: '/assign/flow/diagramView'
|
},
|
disableSubmit: false,
|
selectedOperatorMaintenanceRowKeys: [],
|
selectedRepairerMaintenanceRowKeys: [],
|
detail: {
|
operatorMaintenanceList: [],
|
repairerMaintenanceList: [],
|
columns: [
|
{
|
title: 'ID',
|
key: 'id',
|
type: JVXETypes.hidden
|
},
|
{
|
title: 'orderId',
|
key: 'orderId',
|
type: JVXETypes.hidden
|
},
|
{
|
title: '序号',
|
key: 'itemCode',
|
type: JVXETypes.normal,
|
width: 60,
|
align: 'center'
|
},
|
{
|
title: '保养项',
|
key: 'itemName',
|
type: JVXETypes.normal,
|
align: 'center'
|
},
|
{
|
title: '保养结果',
|
key: 'maintenanceResult',
|
type: JVXETypes.slot,
|
align: 'center',
|
slotName: 'maintenanceResult',
|
validateRules: [
|
{ required: true, message: '请选择${title}' }
|
]
|
},
|
{
|
title: '异常描述',
|
key: 'exceptionDescription',
|
type: JVXETypes.slot,
|
align: 'center',
|
slotName: 'exceptionDescription',
|
validateRules: [
|
{ handler: this.customValidator }
|
]
|
},
|
{
|
title: '是否报修',
|
key: 'reportFlag',
|
type: JVXETypes.slot,
|
align: 'center',
|
slotName: 'reportFlag',
|
validateRules: [
|
{ handler: this.customValidator }
|
]
|
}
|
]
|
}
|
}
|
},
|
computed: {
|
displayAdminConfirmFlag() {
|
return ['WAIT_ADMIN_CONFIRM', 'WAIT_INSPECTOR_CONFIRM', 'COMPLETE'].includes(this.model.maintenanceStatus)
|
},
|
displayInspectorConfirmFlag() {
|
return ['WAIT_INSPECTOR_CONFIRM', 'COMPLETE'].includes(this.model.maintenanceStatus)
|
}
|
},
|
methods: {
|
/**
|
* 主页面点击执行审批时触发
|
* @param record 主页面列表行记录
|
*/
|
async handleDetail(record) {
|
this.spinning = true
|
this.model = {}
|
this.detail.operatorMaintenanceList = this.detail.repairerMaintenanceList = []
|
this.handleTabToFirstTable()
|
this.getBasicInformationByApi(record)
|
this.getFlowChartImageByApi(record)
|
this.loadDetail(record.dataId)
|
},
|
|
/**
|
* 主页面点击详情时触发
|
* @param record 主页面列表行记录
|
*/
|
recordDetail(record) {
|
this.spinning = true
|
this.activeTabKey = 1
|
this.detail.operatorMaintenanceList = this.detail.repairerMaintenanceList = []
|
this.model = Object.assign({}, record)
|
this.loadDetail(record.id)
|
},
|
|
/**
|
* 获取基础信息
|
* @param record 主页面列表行记录
|
*/
|
getBasicInformationByApi(record) {
|
const that = this
|
getAction(this.url.queryById, { id: record.dataId })
|
.then(res => {
|
if (res.success) {
|
that.model = Object.assign({}, res.result.records[0])
|
that.model.dataId = record.dataId
|
that.model.taskId = record.id
|
that.model.userId = record.assignee
|
that.model.instanceId = record.procInstId
|
}
|
else {
|
that.$notification.warning({
|
message: '消息',
|
description: res.message
|
})
|
}
|
})
|
},
|
|
/**
|
* 获取流程图
|
* @param record 主页面列表行记录
|
*/
|
getFlowChartImageByApi(record) {
|
const { processDefinitionId, processInstanceId, processDefinitionKey } = record
|
|
downFile(this.url.diagramView, {
|
processDefinitionId,
|
processInstanceId,
|
TaskDefinitionKey: processDefinitionKey
|
}, 'get')
|
.then((res => {
|
this.imageSrc = window.URL.createObjectURL(new Blob([res]))
|
}))
|
.catch(err => {
|
this.$notification.error({
|
message: '消息',
|
description: err.message
|
})
|
})
|
},
|
|
async handleOk() {
|
const that = this
|
|
let errMap
|
if (that.$refs['editableDetailTable' + that.activeTabKey]) {
|
// 校验当前tab表格
|
errMap = await that.$refs['editableDetailTable' + that.activeTabKey].validateTable()
|
} else {
|
// 当前tab不是表格时则校验有表格的
|
for (let index = 1; index <= 2; index++) {
|
if (that.$refs['editableDetailTable' + index]) {
|
errMap = await that.$refs['editableDetailTable' + index].validateTable()
|
if (errMap) {
|
that.activeTabKey = index
|
console.log('that.activeTabKey-----------', that.activeTabKey)
|
that.$refs['editableDetailTable' + that.activeTabKey].clearValidate()
|
that.$notification.warning({
|
message: '消息',
|
description: '保养不能为空'
|
})
|
break
|
}
|
}
|
}
|
}
|
if (errMap) return
|
|
// 触发表单验证
|
this.$refs.form.validate(valid => {
|
if (valid) {
|
that.confirmLoading = that.spinning = true
|
|
// 仅在保养中状态传递表格列表
|
if (this.model.maintenanceStatus == 'UNDER_MAINTENANCE') {
|
for (let index = 1; index <= 2; index++) {
|
if (that.$refs['editableDetailTable' + index]) {
|
this.model.tableDetailList = that.$refs['editableDetailTable' + index].getTableData()
|
break
|
}
|
}
|
}
|
console.log('model', this.model.tableDetailList)
|
|
httpAction(this.url.approval, this.model, 'put')
|
.then((res) => {
|
if (res.success) {
|
that.$notification.success({
|
message: '消息',
|
description: res.message
|
})
|
that.$emit('modalFormOk')
|
that.close()
|
} else {
|
that.$notification.warning({
|
message: '消息',
|
description: res.message
|
})
|
}
|
})
|
.finally(() => {
|
that.confirmLoading = that.spinning = false
|
})
|
} else {
|
return false
|
}
|
})
|
},
|
|
autocompleteForm(selectObj) {
|
this.$set(this.model, 'standardName', selectObj.standardName)
|
this.$set(this.model, 'standardId', selectObj.id)
|
this.$set(this.model, 'maintenancePeriod', selectObj.maintenancePeriod)
|
this.$set(this.model, 'equipmentId', selectObj.equipmentId)
|
this.spinning = false
|
},
|
|
/**
|
* 检查明细标签切换时触发
|
* @param tabKey 切换后的tabKey
|
*/
|
handleTabChange(tabKey) {
|
if (this.$refs['editableDetailTable' + this.activeTabKey]) this.$refs['editableDetailTable' + this.activeTabKey].clearValidate()
|
this.activeTabKey = tabKey
|
},
|
|
// 切换tab至第一个表格
|
handleTabToFirstTable() {
|
this.$nextTick(() => {
|
console.log('taskDefKey', this.selectShenpiData.taskDefKey)
|
if ((this.selectShenpiData.taskDefKey && this.selectShenpiData.taskDefKey == 'operator_task') || !this.selectShenpiData.taskDefKey) this.activeTabKey = 1
|
else if (this.selectShenpiData.taskDefKey && this.selectShenpiData.taskDefKey == 'maintenance_task') this.activeTabKey = 2
|
})
|
},
|
|
//规范选择变化
|
loadDetail(orderId) {
|
getAction(this.url.detail, { orderId })
|
.then(res => {
|
if (res.success) {
|
this.detail.operatorMaintenanceList = res.result.filter(item => item.itemCategory == 'OPERATOR_MAINTENANCE')
|
this.detail.repairerMaintenanceList = res.result.filter(item => item.itemCategory == 'REPAIRER_MAINTENANCE')
|
}
|
})
|
},
|
|
handleInspectionResultSelectChange(value, record) {
|
if (record.exceptionDescription) delete record.exceptionDescription
|
if (record.reportFlag) delete record.reportFlag
|
},
|
|
// 批量选择所有点检结果
|
handleSelectAllInspectionResult() {
|
let selectedRowKeys, prefix
|
if (this.activeTabKey == 1) {
|
selectedRowKeys = this.selectedOperatorMaintenanceRowKeys
|
prefix = 'operator'
|
}
|
else if (this.activeTabKey == 2) {
|
selectedRowKeys = this.selectedRepairerMaintenanceRowKeys
|
prefix = 'repairer'
|
}
|
else selectedRowKeys = []
|
if (selectedRowKeys.length == 0) return
|
|
selectedRowKeys.forEach(key => {
|
const dataItem = this.detail[prefix + 'MaintenanceList'].find(item => item.id === key)
|
if (dataItem && dataItem.maintenanceResult !== '1') {
|
delete dataItem.exceptionDescription
|
delete dataItem.reportFlag
|
dataItem.maintenanceResult = '1'
|
}
|
})
|
this.$refs['editableDetailTable' + this.activeTabKey].clearCheckboxRow()
|
this['selected' + prefix.charAt(0).toUpperCase() + prefix.slice(1) + 'MaintenanceRowKeys'] = []
|
},
|
|
/**
|
* 表格多选框发生改变时触发
|
* @param {selectedRowIds} 表格中已选择的ID列表
|
* @param key 二保区分key
|
*/
|
handleTableSelectRowChange({ selectedRowIds }, key) {
|
this[`selected${key}MaintenanceRowKeys`] = selectedRowIds
|
},
|
|
/**
|
* 自定义校验
|
* @param cellValue 输入值
|
* @param row 表格行记录
|
* @param callback 结果回调函数
|
*/
|
customValidator({ cellValue, row }, callback) {
|
if (row.maintenanceResult === '2') {
|
if (!cellValue) {
|
callback(false, '${title}不能为空') // false = 未通过,可以跟自定义提示
|
} else {
|
callback(true) // true = 通过验证
|
}
|
} else {
|
callback(true)
|
}
|
},
|
|
handleCancel() {
|
this.close()
|
},
|
|
close() {
|
this.$emit('close')
|
this.visible = false
|
this.$refs.form.clearValidate()
|
}
|
}
|
}
|
</script>
|
|
<style scoped lang="less">
|
/deep/ .ant-select-dropdown-menu {
|
text-align: left;
|
}
|
|
/deep/ .ant-spin-nested-loading {
|
height: 100%;
|
|
.ant-spin-container {
|
height: 100%;
|
|
.ant-form {
|
height: 100%;
|
|
#outer-row {
|
height: 100%;
|
|
.scroll-col {
|
height: 100%;
|
overflow: auto;
|
}
|
}
|
}
|
}
|
}
|
</style>
|