<template>
|
<a-spin :spinning="confirmLoading">
|
<j-form-container :disabled="formDisabled">
|
<a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
|
<a-row>
|
<a-col :span="8">
|
<a-form-model-item label="维修编码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="repairCode">
|
<a-input v-model="model.repairCode" placeholder="系统自动生成" disabled ></a-input>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="8">
|
<a-form-model-item label="项目名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="repairName">
|
<a-input v-model="model.repairName" placeholder="请输入项目名称" ></a-input>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="8" v-if="disabled">
|
<a-form-model-item label="维修状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="repairStatus">
|
<j-dict-select-tag placeholder="请选择维修状态" v-model="model.repairStatus" dictCode="major_partial_repair_status" disabled/>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="8">
|
<a-form-model-item label="维修类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="repairType">
|
<a-select v-model="model.repairType" placeholder="请选择维修类型">
|
<a-select-option value="大修">大修</a-select-option>
|
<a-select-option value="项修">项修</a-select-option>
|
</a-select>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="8">
|
<a-form-model-item label="申请人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="applicant">
|
<j-search-select-tag placeholder="请选择申请人" v-model="model.applicant" dict="sys_user,realname, username, del_flag=0 and status=1"/>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="8">
|
<a-form-model-item label="申请车间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="applicantProduction">
|
<a-tree-select v-model="model.applicantProduction"
|
style="width: 100%"
|
:tree-data="treeData"
|
:dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
|
placeholder="请选择申请车间"
|
allow-clear
|
tree-default-expand-all
|
>
|
</a-tree-select>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="8">
|
<a-form-model-item label="计划开始日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="planStartDate">
|
<j-date placeholder="请选择计划开始日期" v-model="model.planStartDate" style="width: 100%" />
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="8">
|
<a-form-model-item label="计划结束日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="planEndDate">
|
<j-date placeholder="请选择计划结束日期" v-model="model.planEndDate" style="width: 100%" />
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="8" v-if="disabled">
|
<a-form-model-item label="实际开始时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="actualStartTime">
|
<j-date :show-time="true" dateFormat="YYYY-MM-DD HH" placeholder="请选择实际开始时间" v-model="model.actualStartTime" style="width: 100%" />
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="8" v-if="disabled">
|
<a-form-model-item label="实际结束时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="actualEndTime">
|
<j-date :show-time="true" dateFormat="YYYY-MM-DD HH" placeholder="请选择实际结束时间" v-model="model.actualEndTime" style="width: 100%" />
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="8" v-if="disabled">
|
<a-form-model-item label="总金额" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="totalAmount">
|
<a-input-number :min=0 :precision="2" v-model="model.totalAmount" placeholder="请输入总金额" style="width: 100%" />
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="8">
|
<a-form-model-item label="申请原因" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="applicantReason">
|
<a-input v-model="model.applicantReason" placeholder="请输入申请原因" ></a-input>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="8">
|
<a-form-model-item label="责任人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="responsiblePerson">
|
<j-search-select-tag placeholder="请选择责任人" v-model="model.responsiblePerson" dict="sys_user,realname, username, del_flag=0 and status=1"/>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="8">
|
<a-form-model-item label="故障描述" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="faultDescription">
|
<a-textarea v-model="model.faultDescription" placeholder="请输入故障描述" ></a-textarea>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="8">
|
<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-row>
|
<a-row :gutter="24">
|
<a-tabs defaultActiveKey="1">
|
<a-tab-pane key="1" tab="维修明细">
|
<j-vxe-table
|
ref="editableDetailTable"
|
:rowNumber="true"
|
:rowSelection="true"
|
:bordered="true"
|
:alwaysEdit="true"
|
:toolbar="true"
|
:toolbar-config="detailToolbarConfig"
|
keep-source
|
:height="300"
|
:loading="detail.loading"
|
:dataSource="detail.dataSource"
|
:columns="equipmentColumns"
|
style="margin-top: 8px;"/>
|
</a-tab-pane>
|
</a-tabs>
|
</a-row>
|
</a-form-model>
|
</j-form-container>
|
</a-spin>
|
</template>
|
|
<script>
|
|
import { getAction, httpAction } from '@/api/manage'
|
import { JVxeTableModelMixin } from '@/mixins/JVxeTableModelMixin.js'
|
import { JVXETypes } from '@/components/jeecg/JVxeTable'
|
|
export default {
|
name: 'EamMajorPartialRepairForm',
|
mixins: [JVxeTableModelMixin],
|
components: {
|
},
|
props: {
|
//表单禁用
|
disabled: {
|
type: Boolean,
|
default: false,
|
required: false
|
}
|
},
|
data () {
|
return {
|
model: {},
|
labelCol: {
|
xs: { span: 24 },
|
sm: { span: 7 },
|
},
|
wrapperCol: {
|
xs: { span: 24 },
|
sm: { span: 16 },
|
},
|
confirmLoading: false,
|
validatorRules: {
|
repairName: { required: true, message: '请输入项目名称!' },
|
repairType: { required: true, message: '请选择维修类型!' },
|
applicant: { required: true, message: '请选择申请人!' },
|
applicantProduction: { required: true, message: '请输入申请车间!' },
|
planStartDate: { required: true, message: '请选择计划开始日期!' },
|
planEndDate: { required: true, message: '请选择计划结束日期!' },
|
applicantReason: { required: true, message: '请输入申请原因!' },
|
responsiblePerson: { required: true, message: '请输入责任人!' },
|
faultDescription: { required: true, message: '请输入故障描述!' }
|
},
|
treeData: [],
|
equipmentOptions: [],
|
detail: {
|
loading: false,
|
dataSource: [],
|
},
|
url: {
|
add: "/eam/eamMajorPartialRepair/add",
|
edit: "/eam/eamMajorPartialRepair/edit",
|
queryById: "/eam/eamMajorPartialRepair/queryById",
|
queryDetailList: "/eam/eamMajorPartialRepairDetail/list",
|
queryEquipmentList: "/eam/equipment/asyncLoadEquipment",
|
loadWorkShopOptions:'/mdc/mdcProduction/loadProductionTreeOptions'
|
}
|
}
|
},
|
computed: {
|
detailToolbarConfig() {
|
return {
|
// 如果是详情页,则不显示 add 按钮
|
btns: this.disabled ? ['remove', 'clearSelection'] : ['add', 'remove', 'clearSelection'],
|
slots: ['prefix', 'suffix']
|
};
|
},
|
formDisabled(){
|
return this.disabled
|
},
|
equipmentColumns() {
|
return [
|
{
|
title: '设备',
|
key: 'equipmentId',
|
type: JVXETypes.select,
|
options: this.equipmentOptions,
|
width: '20%',
|
align: 'center',
|
validateRules: [{ required: true, message: '设备不能为空!' }]
|
},
|
{
|
title: '单价',
|
key: 'unitPrice',
|
type: JVXETypes.inputNumber,
|
width: '10%',
|
align: 'center',
|
validateRules: [{ required: true, message: '单价不能为空!' }]
|
},
|
{
|
title: '维修结果',
|
key: 'repairResult',
|
type: JVXETypes.textarea,
|
width: '20%',
|
align: 'center',
|
visible: this.disabled
|
},
|
{
|
title: '维修描述',
|
key: 'repairDescription',
|
type: JVXETypes.textarea,
|
width: '30%',
|
align: 'center',
|
visible: this.disabled
|
}
|
];
|
}
|
},
|
created () {
|
//备份model原始值
|
this.modelDefault = JSON.parse(JSON.stringify(this.model));
|
this.loadWorkShopTree()
|
},
|
methods: {
|
loadWorkShopTree() {
|
//加载车间选择树
|
getAction(this.url.loadWorkShopOptions).then(res => {
|
if (res.success) {
|
this.treeData = [...res.result]
|
}else {
|
that.$message.warning(res.message)
|
}
|
})
|
},
|
add () {
|
this.edit(this.modelDefault)
|
},
|
edit (record) {
|
this.model = Object.assign({}, record);
|
this.visible = true
|
if (this.model.id) {
|
getAction(this.url.queryDetailList, { repairId: this.model.id }).then((res) => {
|
if (res.success) {
|
console.log(res.result)
|
if (res.result.total) {
|
this.detail.dataSource = res.result.records
|
}
|
}
|
})
|
}
|
getAction(this.url.queryEquipmentList, {}).then((res) => {
|
if (res.success) {
|
this.equipmentOptions = res.result.map(item => {
|
return {
|
label: item.text,
|
value: item.value
|
}
|
})
|
}
|
})
|
},
|
submitForm () {
|
const that = this;
|
// 触发表单验证
|
this.$refs.form.validate(valid => {
|
if (valid) {
|
that.confirmLoading = true;
|
let httpurl = '';
|
let method = '';
|
if(!this.model.id){
|
httpurl+=this.url.add;
|
method = 'post';
|
}else{
|
httpurl+=this.url.edit;
|
method = 'put';
|
}
|
const detailList = this.$refs.editableDetailTable.getTableData()
|
if (detailList.length === 0 || !detailList[0].equipmentId) {
|
this.$message.warning('请添加维修明细!')
|
that.confirmLoading = false;
|
return
|
}
|
this.model.eamMajorPartialRepairDetailList = this.$refs.editableDetailTable.getTableData()
|
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;
|
})
|
}
|
|
})
|
},
|
}
|
}
|
</script>
|