<template>
|
<a-card :bordered="false" :class="'cust-erp-sub-tab'">
|
<a-table
|
ref="table"
|
bordered
|
rowKey="id"
|
:columns="columns"
|
:dataSource="dataSource"
|
:pagination="ipagination"
|
@change="handleTableChange"
|
>
|
<template
|
v-for="col in columns"
|
:slot="col.dataIndex"
|
slot-scope='text, record, index'
|
>
|
<div :key="col.dataIndex">
|
<a-input
|
:value="text"
|
v-if="col.dataIndex == 'faultCause'"
|
:maxLength="5000"
|
auto-size
|
placeholder="请输入故障原因"
|
@change="(e)=>handleChange(e, record.key, col, index)"
|
:disabled="record.disabled"
|
/>
|
<a-input
|
:value="text"
|
v-if="col.dataIndex == 'faultType'"
|
:maxLength="5000"
|
auto-size
|
placeholder="请输入技术类型"
|
@change="(e)=>handleChange(e, record.key, col, index)"
|
:disabled="record.disabled"
|
/>
|
<a-textarea
|
:value="text"
|
v-if="col.dataIndex == 'suggestion'"
|
:maxLength="5000"
|
auto-size
|
placeholder="请输入维保改进意见"
|
@change="(e)=>handleChange(e, record.key, col, index)"
|
:disabled="record.disabled"
|
/>
|
</div>
|
</template>
|
<span slot='action' slot-scope='text, record,index'>
|
<a @click="handleDeleteFake(index)">删除</a>
|
</span>
|
</a-table>
|
<a-button
|
style="width: 100%; margin-top: 16px; margin-bottom: 8px"
|
type="dashed"
|
icon="plus"
|
@click="addMaterial"
|
:disabled="repairOrderStatus!='3'"
|
>添加故障分析
|
</a-button>
|
<div :style="{width: '100%',border: '1px solid #e9e9e9',padding: '10px 16px',background: '#fff',}">
|
<a-row :style="{textAlign:'right'}">
|
<a-button
|
:style="{marginRight: '8px'}"
|
@click="handleCancel"
|
:disabled="repairOrderStatus!='3'"
|
>
|
清空
|
</a-button>
|
<a-button
|
@click="handleOk(1)"
|
type="primary"
|
:style="{marginRight: '8px'}"
|
:disabled="repairOrderStatus!='3'"
|
>暂存</a-button>
|
<a-button
|
@click="handleOk(0)"
|
type="primary"
|
:disabled="repairOrderStatus!='3'"
|
>保存</a-button>
|
</a-row>
|
<!-- :disabled="false" -->
|
</div>
|
</a-card>
|
</template>
|
<script>
|
import { postAction, getAction } from '@/api/manage'
|
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
|
import pick from 'lodash.pick'
|
import JEllipsis from '@/components/jeecg/JEllipsis'
|
export default {
|
name: 'ActualMaterialEditTable',
|
mixins: [JeecgListMixin],
|
components: {
|
JEllipsis,
|
},
|
props:{
|
repairOrderId:{
|
type:String,
|
required:false,
|
default:''
|
},
|
repairOrderStatus:{
|
type:String,
|
required:false,
|
default:''
|
}
|
},
|
data() {
|
return {
|
title: "工艺确认",
|
flag: false,//主页面的标记位 用于区分是否确认过工单工艺 来区分table页展示 工单工序 还是产品工序
|
visible: false,
|
model: {},
|
obj: {},
|
maskClosable: true,
|
confirmLoading: false,
|
form: this.$form.createForm(this),
|
/* 分页参数 */
|
ipagination: {
|
current: 1,
|
pageSize: 99,
|
pageSizeOptions: ['99', '199'],
|
showTotal: (total, range) => {
|
return range[0] + "-" + range[1] + " 共" + total + "条"
|
},
|
showQuickJumper: true,
|
showSizeChanger: true,
|
total: 0
|
},
|
validatorRules: {
|
faultCause: {
|
rules: [
|
{ required: true, message: '请填写故障原因!' },
|
]
|
},
|
faultType: {
|
rules: [
|
{ required: false, message: '请填写故障类型!'},
|
]
|
},
|
},
|
labelCol: {
|
xs: { span: 24 },
|
sm: { span: 7 },
|
},
|
wrapperCol: {
|
xs: { span: 24 },
|
sm: { span: 16 },
|
},
|
drawerWidth: "100%",
|
visible: false,
|
disableSubmit: false,
|
disableSelect: false,
|
loading: false,
|
dataSource: [],
|
columns: [
|
{
|
title: '*故障原因',
|
dataIndex: 'faultCause',
|
align: "center",
|
scopedSlots: { customRender: 'faultCause' },
|
className: 'red',
|
width: 250,
|
},
|
{
|
title: '*故障类型',
|
dataIndex: 'faultType',
|
align: "center",
|
scopedSlots: { customRender: 'faultType' },
|
className: 'red',
|
width: 250,
|
},
|
{
|
title: '维保改进意见',
|
dataIndex: 'suggestion',
|
align: "center",
|
scopedSlots: { customRender: 'suggestion' },
|
width: 250,
|
},
|
{
|
title: '操作',
|
dataIndex: 'action',
|
align: 'center',
|
width: 250,
|
scopedSlots: { customRender: 'action' }
|
}
|
],
|
url: {
|
list: "/eam/repairOrder/listRepairOrderFaultAnalysisByMainId",
|
confirmMaterial:"/eam/repairOrder/addRepairOrderFaultAnalysis"
|
},
|
changeIndex: 0
|
}
|
},
|
created(){
|
this.queryParam['repairOrderId'] = this.repairOrderId;
|
this.loadData(1);
|
},
|
methods: {
|
addMaterial() {
|
this.dataSource.push({faultType: '',repairOrderId:this.repairOrderId,faultType:'',faultCause:'',id:''})
|
},
|
handleCancel() {
|
this.close()
|
},
|
close() {
|
this.$emit('close');
|
this.dataSource = [];
|
this.disableSubmit = false;
|
this.visible = false;
|
},
|
handleDeleteFake(index){
|
this.dataSource.pop(index);
|
},
|
handleOk(saveStatus) {
|
const that = this
|
if(saveStatus==0){
|
let faultAnalysisDataSource = that.dataSource;
|
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)+"行故障原因!");
|
return false;
|
}
|
if(faultAnalysisDataSource[i].faultType == undefined || faultAnalysisDataSource[i].faultType == null||faultAnalysisDataSource[i].faultType==''){
|
that.$message.warning("请填写第"+(i+1)+"行故障类型!");
|
return false;
|
}
|
}
|
}
|
this.form.validateFields((err, values) => {
|
if (!err) {
|
that.confirmLoading = true
|
let formData = {}
|
formData.repairOrderId = that.repairOrderId;
|
formData.faultAnalysisList = that.dataSource;
|
let obj = obj = postAction(this.url.confirmMaterial, formData)
|
obj.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.loadData(1);
|
})
|
}
|
})
|
},
|
handleChange(value, key, column, index) {
|
let that = this;
|
const temp = [...that.dataSource];
|
const target = temp[index];
|
if (target) {
|
target[column.dataIndex] = value;
|
if ('suggestion' == column.dataIndex) {
|
target['suggestion'] = value.target.value;
|
}
|
if ('faultCause' == column.dataIndex) {
|
target['faultCause'] = value.target.value;
|
}
|
if ('faultType' == column.dataIndex) {
|
target['faultType'] = value.target.value;
|
}
|
that.dataSource = temp;
|
}
|
},
|
clearList(){
|
this.dataSource=[];
|
this.ipagination.current = 1
|
}
|
},
|
watch:{
|
repairOrderId:{
|
immediate: true,
|
handler(val) {
|
this.clearList();
|
this.queryParam['repairOrderId'] = val
|
this.loadData(1);
|
}
|
}
|
}
|
}
|
</script>
|
|
<style scoped>
|
/deep/ .red {
|
color: red;
|
}
|
</style>
|