parent
7cbb7f38ef
commit
c4624518e6
2 changed files with 425 additions and 351 deletions
@ -1,370 +1,437 @@ |
||||
<template> |
||||
<el-dialog title="新增" append-to-body :modelValue="openShow" fullscreen @close="closeDialog"> |
||||
<div style="margin-bottom: 12px" v-if="moldAddMore"> |
||||
<el-button type="primary" @click="addTable">插入一行</el-button> |
||||
<el-button type="danger" @click="delTable">删除选中行</el-button> |
||||
</div> |
||||
<!-- 单个 Form 包裹整个表格 --> |
||||
<el-form |
||||
ref="tableForm" |
||||
:model="form" |
||||
:rules="formRules" |
||||
label-width="0px" |
||||
> |
||||
<!-- 全局错误提示 --> |
||||
<div v-if="formError" class="error-message" style="color: #f56c6c; margin-bottom: 10px;"> |
||||
{{ formError }} |
||||
</div> |
||||
<el-table :data="form.tableData" @select="selectChange" border> |
||||
<el-table-column type="selection" width="55"></el-table-column> |
||||
<el-table-column align="center" label="工艺能力" prop="craftAbilityId"> |
||||
<template #header> |
||||
<span><i style="color: red">*</i>工艺能力</span> |
||||
</template> |
||||
<template #default="scope"> |
||||
<el-form-item :prop="`tableData[${scope.$index}].craftAbilityId`" :rules="formRules.craftAbilityId"> |
||||
<el-select |
||||
v-model="scope.row.craftAbilityId" |
||||
placeholder="请选择" |
||||
style="width: 100%" |
||||
filterable |
||||
|
||||
> |
||||
<el-option |
||||
v-for="item in capabilityData" |
||||
:key="item.id" |
||||
:value="item.id" |
||||
:label="item.caName" |
||||
></el-option> |
||||
</el-select> |
||||
</el-form-item> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column align="center" label="零件号" prop="partCode"> |
||||
<template #default="scope"> |
||||
<el-form-item :prop="`tableData[${scope.$index}].partCode`" :rules="formRules.partCode"> |
||||
<el-input v-model="scope.row.partCode" placeholder="请输入零件号"></el-input> |
||||
</el-form-item> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column align="center" label="生产标识" prop="prodMarkId"> |
||||
<template #default="scope"> |
||||
<el-form-item :prop="`tableData[${scope.$index}].prodMarkId`" :rules="formRules.prodMarkId"> |
||||
<el-select |
||||
multiple |
||||
v-model="scope.row.prodMarkId" |
||||
placeholder="请选择生产标识" |
||||
style="width: 100%" |
||||
filterable |
||||
> |
||||
<el-option |
||||
v-for="item in identificationData" |
||||
:key="item.id" |
||||
:value="item.id" |
||||
:label="item.qualityGrade" |
||||
></el-option> |
||||
</el-select> |
||||
</el-form-item> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column align="center" label="单件面积下限(dm²)" prop="lowArea"> |
||||
<template #default="scope"> |
||||
<el-form-item :prop="`tableData[${scope.$index}].lowArea`" :rules="formRules.lowArea"> |
||||
<el-input v-model="scope.row.lowArea" placeholder="请输入单件面积下限"></el-input> |
||||
</el-form-item> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column align="center" label="单件面积上限(dm²)" prop="upArea"> |
||||
<template #default="scope"> |
||||
<el-form-item :prop="`tableData[${scope.$index}].upArea`" :rules="formRules.upArea"> |
||||
<el-input v-model="scope.row.upArea" placeholder="请输入单件面积上限"></el-input> |
||||
</el-form-item> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column align="center" label="单批面积下限(dm²)" prop="singleDownArea"> |
||||
<template #default="scope"> |
||||
<el-form-item :prop="`tableData[${scope.$index}].singleDownArea`" :rules="formRules.singleDownArea"> |
||||
<el-input v-model="scope.row.singleDownArea" placeholder="请输入单批面积下限"></el-input> |
||||
</el-form-item> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column align="center" label="单批面积上限(dm²)" prop="singleUpArea"> |
||||
<template #default="scope"> |
||||
<el-form-item :prop="`tableData[${scope.$index}].singleUpArea`" :rules="formRules.singleUpArea"> |
||||
<el-input v-model="scope.row.singleUpArea" placeholder="请输入单批面积上限"></el-input> |
||||
</el-form-item> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column align="center" label="限制类型" prop="limitType"> |
||||
<template #header> |
||||
<span><i style="color: red">*</i>限制类型</span> |
||||
</template> |
||||
<template #default="scope"> |
||||
<el-form-item :prop="`tableData[${scope.$index}].limitType`" :rules="formRules.limitType"> |
||||
<el-select |
||||
v-model="scope.row.limitType" |
||||
placeholder="请选择限制类型" |
||||
style="width: 100%" |
||||
> |
||||
<el-option v-for="item in limitRule" :key="item.id" :value="item.dictKey" :label="item.dictValue"></el-option> |
||||
<!-- <el-option label="必须" :value="1"></el-option> --> |
||||
</el-select> |
||||
</el-form-item> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column align="center" label="指定类型" prop="pointType"> |
||||
<template #header> |
||||
<span><i style="color: red">*</i>指定类型</span> |
||||
</template> |
||||
<template #default="scope"> |
||||
<el-form-item :prop="`tableData[${scope.$index}].pointType`" :rules="formRules.pointType"> |
||||
<el-select |
||||
v-model="scope.row.pointType" |
||||
placeholder="请选择指定类型" |
||||
style="width: 100%" |
||||
> |
||||
<el-option v-for="item in pointRule" :key="item.id" :value="item.dictKey" :label="item.dictValue"></el-option> |
||||
<!-- <el-option label="厂内" value="1"></el-option> |
||||
<el-dialog |
||||
:title="row.id ? '编辑' : '新增'" |
||||
append-to-body |
||||
:modelValue="openShow" |
||||
fullscreen |
||||
@close="closeDialog" |
||||
> |
||||
<div style="margin-bottom: 12px" v-if="moldAddMore"> |
||||
<el-button type="primary" @click="addTable">插入一行</el-button> |
||||
<el-button type="danger" @click="delTable">删除选中行</el-button> |
||||
</div> |
||||
<!-- 单个 Form 包裹整个表格 --> |
||||
<el-form ref="tableForm" :model="form" :rules="formRules" label-width="0px"> |
||||
<!-- 全局错误提示 --> |
||||
<div v-if="formError" class="error-message" style="color: #f56c6c; margin-bottom: 10px"> |
||||
{{ formError }} |
||||
</div> |
||||
<el-table :data="form.tableData" @select="selectChange" border> |
||||
<el-table-column type="selection" width="55"></el-table-column> |
||||
<el-table-column align="center" label="工艺能力" prop="craftAbilityId"> |
||||
<template #header> |
||||
<span><i style="color: red">*</i>工艺能力</span> |
||||
</template> |
||||
<template #default="scope"> |
||||
<el-form-item |
||||
:prop="`tableData[${scope.$index}].craftAbilityId`" |
||||
:rules="formRules.craftAbilityId" |
||||
> |
||||
<el-select |
||||
v-model="scope.row.craftAbilityId" |
||||
placeholder="请选择" |
||||
style="width: 100%" |
||||
filterable |
||||
> |
||||
<el-option |
||||
v-for="item in capabilityData" |
||||
:key="item.id" |
||||
:value="item.id" |
||||
:label="item.caName" |
||||
></el-option> |
||||
</el-select> |
||||
</el-form-item> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column align="center" label="零件号" prop="partCode"> |
||||
<template #default="scope"> |
||||
<el-form-item :prop="`tableData[${scope.$index}].partCode`" :rules="formRules.partCode"> |
||||
<el-input v-model="scope.row.partCode" placeholder="请输入零件号"></el-input> |
||||
</el-form-item> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column align="center" label="生产标识" prop="prodMarkIds"> |
||||
<template #default="scope"> |
||||
<el-form-item |
||||
:prop="`tableData[${scope.$index}].prodMarkIds`" |
||||
:rules="formRules.prodMarkIds" |
||||
> |
||||
<el-select |
||||
multiple |
||||
v-model="scope.row.prodMarkIds" |
||||
placeholder="请选择生产标识" |
||||
style="width: 100%" |
||||
filterable |
||||
> |
||||
<el-option |
||||
v-for="item in identificationData" |
||||
:key="item.id" |
||||
:value="item.id" |
||||
:label="item.qualityGrade" |
||||
></el-option> |
||||
</el-select> |
||||
</el-form-item> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column align="center" label="单件面积下限(dm²)" prop="lowArea"> |
||||
<template #default="scope"> |
||||
<el-form-item :prop="`tableData[${scope.$index}].lowArea`" :rules="formRules.lowArea"> |
||||
<el-input v-model="scope.row.lowArea" placeholder="请输入单件面积下限"></el-input> |
||||
</el-form-item> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column align="center" label="单件面积上限(dm²)" prop="upArea"> |
||||
<template #default="scope"> |
||||
<el-form-item :prop="`tableData[${scope.$index}].upArea`" :rules="formRules.upArea"> |
||||
<el-input v-model="scope.row.upArea" placeholder="请输入单件面积上限"></el-input> |
||||
</el-form-item> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column align="center" label="单批面积下限(dm²)" prop="singleDownArea"> |
||||
<template #default="scope"> |
||||
<el-form-item |
||||
:prop="`tableData[${scope.$index}].singleDownArea`" |
||||
:rules="formRules.singleDownArea" |
||||
> |
||||
<el-input |
||||
v-model="scope.row.singleDownArea" |
||||
placeholder="请输入单批面积下限" |
||||
></el-input> |
||||
</el-form-item> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column align="center" label="单批面积上限(dm²)" prop="singleUpArea"> |
||||
<template #default="scope"> |
||||
<el-form-item |
||||
:prop="`tableData[${scope.$index}].singleUpArea`" |
||||
:rules="formRules.singleUpArea" |
||||
> |
||||
<el-input |
||||
v-model="scope.row.singleUpArea" |
||||
placeholder="请输入单批面积上限" |
||||
></el-input> |
||||
</el-form-item> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column align="center" label="限制类型" prop="limitType"> |
||||
<template #header> |
||||
<span><i style="color: red">*</i>限制类型</span> |
||||
</template> |
||||
<template #default="scope"> |
||||
<el-form-item |
||||
:prop="`tableData[${scope.$index}].limitType`" |
||||
:rules="formRules.limitType" |
||||
> |
||||
<el-select |
||||
v-model="scope.row.limitType" |
||||
placeholder="请选择限制类型" |
||||
style="width: 100%" |
||||
> |
||||
<el-option |
||||
v-for="item in limitRule" |
||||
:key="item.id" |
||||
:value="item.dictKey" |
||||
:label="item.dictValue" |
||||
></el-option> |
||||
<!-- <el-option label="必须" :value="1"></el-option> --> |
||||
</el-select> |
||||
</el-form-item> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column align="center" label="指定类型" prop="pointType"> |
||||
<template #header> |
||||
<span><i style="color: red">*</i>指定类型</span> |
||||
</template> |
||||
<template #default="scope"> |
||||
<el-form-item |
||||
:prop="`tableData[${scope.$index}].pointType`" |
||||
:rules="formRules.pointType" |
||||
> |
||||
<el-select |
||||
v-model="scope.row.pointType" |
||||
placeholder="请选择指定类型" |
||||
style="width: 100%" |
||||
> |
||||
<el-option |
||||
v-for="item in pointRule" |
||||
:key="item.id" |
||||
:value="item.dictKey" |
||||
:label="item.dictValue" |
||||
></el-option> |
||||
<!-- <el-option label="厂内" value="1"></el-option> |
||||
<el-option label="外协" value="2"></el-option> --> |
||||
</el-select> |
||||
</el-form-item> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column align="center" label="外协厂商" prop="oemId"> |
||||
<!-- <template #header v-if="showOem"> |
||||
</el-select> |
||||
</el-form-item> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column align="center" label="外协厂商" prop="oemId"> |
||||
<!-- <template #header v-if="showOem"> |
||||
<span><i style="color: red">*</i>外协厂商</span> |
||||
</template> --> |
||||
<template #default="scope"> |
||||
<el-form-item :prop="`tableData[${scope.$index}].oemId`" :rules="formRules.oemId"> |
||||
<el-select |
||||
v-model="scope.row.oemId" |
||||
placeholder="请选择外协厂商" |
||||
style="width: 100%" |
||||
filterable |
||||
clearable |
||||
> |
||||
<el-option v-for="item in companyData" :label="item.ocName" :key="item.id" :value="item.id"></el-option> |
||||
</el-select> |
||||
</el-form-item> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column align="center" label="作业中心" prop="centerId"> |
||||
<!-- <template #header v-if="showCenter"> |
||||
<template #default="scope"> |
||||
<el-form-item :prop="`tableData[${scope.$index}].oemId`" :rules="formRules.oemId"> |
||||
<el-select |
||||
v-model="scope.row.oemId" |
||||
placeholder="请选择外协厂商" |
||||
style="width: 100%" |
||||
filterable |
||||
clearable |
||||
> |
||||
<el-option |
||||
v-for="item in companyData" |
||||
:label="item.ocName" |
||||
:key="item.id" |
||||
:value="item.id" |
||||
></el-option> |
||||
</el-select> |
||||
</el-form-item> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column align="center" label="作业中心" prop="centerId"> |
||||
<!-- <template #header v-if="showCenter"> |
||||
<span><i style="color: red">*</i>作业中心</span> |
||||
</template> --> |
||||
<template #default="scope"> |
||||
<el-form-item :prop="`tableData[${scope.$index}].centerId`" :rules="formRules.centerId"> |
||||
<el-select |
||||
v-model="scope.row.centerId" |
||||
placeholder="请选择作业中心" |
||||
style="width: 100%" |
||||
filterable |
||||
clearable |
||||
> |
||||
<el-option v-for="item in workCenterData" :label="item.wcName" :key="item.id" :value="item.id"></el-option> |
||||
</el-select> |
||||
</el-form-item> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column align="center" label="备注" prop="remark"> |
||||
<template #default="scope"> |
||||
<el-form-item :prop="`tableData[${scope.$index}].remark`" :rules="formRules.remark"> |
||||
<el-input v-model="scope.row.remark" placeholder="请输入备注"></el-input> |
||||
</el-form-item> |
||||
</template> |
||||
</el-table-column> |
||||
</el-table> |
||||
</el-form> |
||||
<template #footer> |
||||
<span class="dialog-footer"> |
||||
<el-button @click="closeDialog">取 消</el-button> |
||||
<el-button type="primary" @click="submit">保 存</el-button> |
||||
</span> |
||||
</template> |
||||
</el-dialog> |
||||
<template #default="scope"> |
||||
<el-form-item :prop="`tableData[${scope.$index}].centerId`" :rules="formRules.centerId"> |
||||
<el-select |
||||
v-model="scope.row.centerId" |
||||
placeholder="请选择作业中心" |
||||
style="width: 100%" |
||||
filterable |
||||
clearable |
||||
> |
||||
<el-option |
||||
v-for="item in workCenterData" |
||||
:label="item.wcName" |
||||
:key="item.id" |
||||
:value="item.id" |
||||
></el-option> |
||||
</el-select> |
||||
</el-form-item> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column align="center" label="备注" prop="remark"> |
||||
<template #default="scope"> |
||||
<el-form-item :prop="`tableData[${scope.$index}].remark`" :rules="formRules.remark"> |
||||
<el-input v-model="scope.row.remark" placeholder="请输入备注"></el-input> |
||||
</el-form-item> |
||||
</template> |
||||
</el-table-column> |
||||
</el-table> |
||||
</el-form> |
||||
<template #footer> |
||||
<span class="dialog-footer"> |
||||
<el-button @click="closeDialog">取 消</el-button> |
||||
<el-button type="primary" @click="submit">保 存</el-button> |
||||
</span> |
||||
</template> |
||||
</el-dialog> |
||||
</template> |
||||
|
||||
<script> |
||||
import {getCapability,getProduction,getOutsourcing,getWorkCenter,getLimitRule, |
||||
getPointRule,saveRules} from "@/api/basicData/ruleMaintenance" |
||||
import { |
||||
getCapability, |
||||
getProduction, |
||||
getOutsourcing, |
||||
getWorkCenter, |
||||
getLimitRule, |
||||
getPointRule, |
||||
saveRules, |
||||
updateRules, |
||||
} from '@/api/basicData/ruleMaintenance'; |
||||
export default { |
||||
props:{ |
||||
isOpen:{ |
||||
type:Boolean, |
||||
default:false |
||||
}, |
||||
moldAddMore:{ |
||||
type:Boolean, |
||||
default:false |
||||
}, |
||||
row:{ |
||||
type:Object, |
||||
default:{} |
||||
} |
||||
props: { |
||||
isOpen: { |
||||
type: Boolean, |
||||
default: false, |
||||
}, |
||||
data(){ |
||||
return{ |
||||
openShow:false, |
||||
formError:'', |
||||
showOem:false, |
||||
showCenter:false, |
||||
form:{ |
||||
tableData:[] |
||||
}, |
||||
craftloading:false, |
||||
formRules:{ |
||||
craftAbilityId:[ |
||||
{ required: true, message: '请选择工艺能力', trigger: ['change', 'submit'] } |
||||
], |
||||
limitType:[ |
||||
{ required: true, message: '请选择限制类型', trigger: ['change', 'submit'] } |
||||
], |
||||
pointType:[ |
||||
{ required: true, message: '请选择指定类型', trigger: ['change', 'submit'] } |
||||
], |
||||
}, |
||||
capabilityData:[], |
||||
identificationData:[], |
||||
companyData:[], |
||||
workCenterData:[], |
||||
pointRule:[], |
||||
limitRule:[] |
||||
} |
||||
moldAddMore: { |
||||
type: Boolean, |
||||
default: false, |
||||
}, |
||||
async mounted(){ |
||||
// this.getCapability(); |
||||
// this.getProduction(); |
||||
// this.getOutsourcing(); |
||||
// this.getWorkCenter(); |
||||
// this.getPointRule() |
||||
// this.getLimitRule() |
||||
const pointData = await getPointRule() |
||||
this.pointRule = pointData.data.data |
||||
const limitData = await getLimitRule() |
||||
this.limitRule = limitData.data.data |
||||
const capaRes = await getCapability() |
||||
this.capabilityData = capaRes.data.data |
||||
const companyRes = await getOutsourcing() |
||||
this.companyData = companyRes.data.data |
||||
const idenRes = await getProduction() |
||||
this.identificationData = idenRes.data.data |
||||
const worlRes = await getWorkCenter() |
||||
this.workCenterData = worlRes.data.data |
||||
if(JSON.stringify(this.row) != '{}'){ |
||||
this.row.craftAbilityId = this.row.craftAbilityId + '' |
||||
this.row.centerId = this.row.centerId == -1 ? '' : this.row.centerId + '' |
||||
this.row.oemId = this.row.oemId == -1 ? '' : this.row.oemId + '' |
||||
this.form.tableData[0] = this.row |
||||
} |
||||
console.log('this.row', this.row) |
||||
this.openShow = this.isOpen; |
||||
|
||||
row: { |
||||
type: Object, |
||||
default: {}, |
||||
}, |
||||
methods:{ |
||||
// remoteMethodCraft(query){ |
||||
// console.log('query', query) |
||||
// if(query){ |
||||
}, |
||||
data() { |
||||
return { |
||||
openShow: false, |
||||
formError: '', |
||||
showOem: false, |
||||
showCenter: false, |
||||
form: { |
||||
tableData: [], |
||||
}, |
||||
craftloading: false, |
||||
formRules: { |
||||
craftAbilityId: [ |
||||
{ required: true, message: '请选择工艺能力', trigger: ['change', 'submit'] }, |
||||
], |
||||
limitType: [{ required: true, message: '请选择限制类型', trigger: ['change', 'submit'] }], |
||||
pointType: [{ required: true, message: '请选择指定类型', trigger: ['change', 'submit'] }], |
||||
}, |
||||
capabilityData: [], |
||||
identificationData: [], |
||||
companyData: [], |
||||
workCenterData: [], |
||||
pointRule: [], |
||||
limitRule: [], |
||||
}; |
||||
}, |
||||
async mounted() { |
||||
// this.getCapability(); |
||||
// this.getProduction(); |
||||
// this.getOutsourcing(); |
||||
// this.getWorkCenter(); |
||||
// this.getPointRule() |
||||
// this.getLimitRule() |
||||
const pointData = await getPointRule(); |
||||
this.pointRule = pointData.data.data; |
||||
const limitData = await getLimitRule(); |
||||
this.limitRule = limitData.data.data; |
||||
const capaRes = await getCapability(); |
||||
this.capabilityData = capaRes.data.data; |
||||
const companyRes = await getOutsourcing(); |
||||
this.companyData = companyRes.data.data; |
||||
const idenRes = await getProduction(); |
||||
this.identificationData = idenRes.data.data; |
||||
const worlRes = await getWorkCenter(); |
||||
this.workCenterData = worlRes.data.data; |
||||
if (JSON.stringify(this.row) != '{}') { |
||||
this.row.craftAbilityId = this.row.craftAbilityId + ''; |
||||
this.row.centerId = this.row.centerId == -1 ? '' : this.row.centerId + ''; |
||||
this.row.oemId = this.row.oemId == -1 ? '' : this.row.oemId + ''; |
||||
// 容错处理:确保prodMarkId在各种情况下都能正确处理 |
||||
if (this.row.prodMarkId && this.row.prodMarkId !== '') { |
||||
this.row.prodMarkIds = this.row.prodMarkId.split(','); |
||||
} else { |
||||
this.row.prodMarkIds = []; |
||||
} |
||||
this.form.tableData[0] = this.row; |
||||
} |
||||
console.log('this.row', this.row); |
||||
this.openShow = this.isOpen; |
||||
}, |
||||
methods: { |
||||
// remoteMethodCraft(query){ |
||||
// console.log('query', query) |
||||
// if(query){ |
||||
|
||||
// }else{ |
||||
// getCapability().then(res =>{ |
||||
// this.capabilityData = res.data.data |
||||
// }) |
||||
// }else{ |
||||
// getCapability().then(res =>{ |
||||
// this.capabilityData = res.data.data |
||||
// }) |
||||
// } |
||||
// }, |
||||
getPointRule() { |
||||
getPointRule().then(res => { |
||||
this.pointRule = res.data.data; |
||||
}); |
||||
}, |
||||
getLimitRule() { |
||||
getLimitRule().then(res => { |
||||
this.limitRule = res.data.data; |
||||
}); |
||||
}, |
||||
getCapability() { |
||||
getCapability().then(res => { |
||||
this.capabilityData = res.data.data; |
||||
}); |
||||
}, |
||||
getProduction() { |
||||
getProduction().then(res => { |
||||
this.identificationData = res.data.data; |
||||
}); |
||||
}, |
||||
getOutsourcing() { |
||||
getOutsourcing().then(res => { |
||||
this.companyData = res.data.data; |
||||
}); |
||||
}, |
||||
getWorkCenter() { |
||||
getWorkCenter().then(res => { |
||||
this.workCenterData = res.data.data; |
||||
}); |
||||
}, |
||||
selectChange(list, row) { |
||||
row._select = !row._select; |
||||
}, |
||||
// 删除选中行 |
||||
delTable() { |
||||
this.form.tableData = this.form.tableData.filter(row => !row._select); |
||||
}, |
||||
addTable() { |
||||
this.form.tableData.push({ |
||||
_select: false, |
||||
}); |
||||
}, |
||||
submit() { |
||||
this.formError = ''; |
||||
// 调用单个 Form 的校验方法 |
||||
this.$refs.tableForm.validate((isValid, invalidFields) => { |
||||
if (!isValid) { |
||||
// 校验失败:显示提示并滚动到第一个错误字段 |
||||
this.formError = '存在未完善的字段,请检查表格中的红色提示'; |
||||
this.$nextTick(() => { |
||||
// 找到第一个错误字段并滚动到视图 |
||||
const firstError = document.querySelector('.el-form-item.is-error'); |
||||
if (firstError) { |
||||
firstError.scrollIntoView({ behavior: 'smooth', block: 'center' }); |
||||
} |
||||
}); |
||||
return; |
||||
} |
||||
// this.form.tableData.map(item =>{ |
||||
// if(item.pointType == 1 && (!item.oemId || item.oemId == '')){ |
||||
// this.formError = '指定类型为外协时,请选择外协厂商'; |
||||
// return |
||||
// } |
||||
// }, |
||||
getPointRule(){ |
||||
getPointRule().then(res =>{ |
||||
this.pointRule = res.data.data |
||||
}) |
||||
}, |
||||
getLimitRule(){ |
||||
getLimitRule().then(res =>{ |
||||
this.limitRule = res.data.data |
||||
}) |
||||
}, |
||||
getCapability(){ |
||||
getCapability().then(res =>{ |
||||
this.capabilityData = res.data.data; |
||||
}) |
||||
}, |
||||
getProduction(){ |
||||
getProduction().then(res =>{ |
||||
this.identificationData = res.data.data; |
||||
}) |
||||
}, |
||||
getOutsourcing(){ |
||||
getOutsourcing().then(res =>{ |
||||
this.companyData = res.data.data; |
||||
}) |
||||
}, |
||||
getWorkCenter(){ |
||||
getWorkCenter().then(res =>{ |
||||
this.workCenterData = res.data.data; |
||||
}) |
||||
}, |
||||
selectChange(list, row) { |
||||
row._select = !row._select; |
||||
}, |
||||
// 删除选中行 |
||||
delTable() { |
||||
this.form.tableData = this.form.tableData.filter(row => !row._select); |
||||
}, |
||||
addTable(){ |
||||
this.form.tableData.push({ |
||||
_select:false |
||||
}) |
||||
}, |
||||
submit(){ |
||||
this.formError = ''; |
||||
// 调用单个 Form 的校验方法 |
||||
this.$refs.tableForm.validate((isValid, invalidFields) => { |
||||
if (!isValid) { |
||||
// 校验失败:显示提示并滚动到第一个错误字段 |
||||
this.formError = '存在未完善的字段,请检查表格中的红色提示'; |
||||
this.$nextTick(() => { |
||||
// 找到第一个错误字段并滚动到视图 |
||||
const firstError = document.querySelector('.el-form-item.is-error'); |
||||
if (firstError) { |
||||
firstError.scrollIntoView({ behavior: 'smooth', block: 'center' }); |
||||
} |
||||
}); |
||||
return; |
||||
} |
||||
// this.form.tableData.map(item =>{ |
||||
// if(item.pointType == 1 && (!item.oemId || item.oemId == '')){ |
||||
// this.formError = '指定类型为外协时,请选择外协厂商'; |
||||
// return |
||||
// } |
||||
// if(item.pointType == 0 && (!item.centerId || item.centerId == '')){ |
||||
// this.formError = '指定类型为厂内时,请选择作业中心'; |
||||
// return |
||||
// } |
||||
// }) |
||||
|
||||
console.log('form----------',this.form.tableData) |
||||
// 校验通过:准备提交数据(过滤无用字段) |
||||
const submitData = this.form.tableData.map(row => { |
||||
row.prodMarkId = row.prodMarkId && row.prodMarkId.length != 0 && row.prodMarkId.join(',') |
||||
const { _select, ...validData } = row; // 剔除选择状态字段 |
||||
return validData; |
||||
}); |
||||
saveRules(submitData).then(res =>{ |
||||
if(res.data.code == 200){ |
||||
this.$message.success('保存成功'); |
||||
this.closeDialog(true); |
||||
} |
||||
}) |
||||
}) |
||||
}, |
||||
closeDialog(val){ |
||||
this.openShow = false; |
||||
this.$emit('closeDialog',val); |
||||
// if(item.pointType == 0 && (!item.centerId || item.centerId == '')){ |
||||
// this.formError = '指定类型为厂内时,请选择作业中心'; |
||||
// return |
||||
// } |
||||
// }) |
||||
// 校验通过:准备提交数据(过滤无用字段) |
||||
const submitData = this.form.tableData.map(row => { |
||||
if (Array.isArray(row.prodMarkIds) && row.prodMarkIds.length > 0) { |
||||
row.prodMarkId = row.prodMarkIds.join(','); |
||||
} else { |
||||
row.prodMarkId = ''; |
||||
} |
||||
const { _select, ...validData } = row; // 剔除选择状态字段 |
||||
return validData; |
||||
}); |
||||
console.log('submitData', submitData, this.row); |
||||
if (this.row.id) { |
||||
// 修改 |
||||
updateRules(submitData[0]).then(res => { |
||||
if (res.data.code == 200) { |
||||
this.$message.success('修改成功'); |
||||
this.closeDialog(true); |
||||
} |
||||
}); |
||||
} else { |
||||
// 新增 |
||||
saveRules(submitData).then(res => { |
||||
if (res.data.code == 200) { |
||||
this.$message.success('保存成功'); |
||||
this.closeDialog(true); |
||||
} |
||||
}); |
||||
} |
||||
} |
||||
} |
||||
}); |
||||
}, |
||||
closeDialog(val) { |
||||
this.openShow = false; |
||||
this.$emit('closeDialog', val); |
||||
}, |
||||
}, |
||||
}; |
||||
</script> |
||||
|
||||
<style lang="scss" scoped> |
||||
::v-deep .el-form-item{ |
||||
margin-top: 15px !important; |
||||
::v-deep .el-form-item { |
||||
margin-top: 15px !important; |
||||
} |
||||
</style> |
||||
Loading…
Reference in new issue