Merge branch 'dev-scheduling' of http://42.192.7.176:3000/suojin/jonhon-mes-web into dev-scheduling
commit
ac8c4dc37a
19 changed files with 1374 additions and 279 deletions
@ -0,0 +1,154 @@ |
|||||||
|
<template> |
||||||
|
<el-dialog title="新增" append-to-body v-model="openShow" width="70%" @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> |
||||||
|
<el-table :data="tableData" style="width: 100%" border :cell-style="{ padding: '5px' }"> |
||||||
|
<!-- 设施 --> |
||||||
|
<el-table-column prop="device" label="设施" align="center" width="150"> |
||||||
|
<template #header> |
||||||
|
<span><i style="color: red">*</i>设施</span> |
||||||
|
</template> |
||||||
|
<template #default="scope"> |
||||||
|
<el-input v-model="scope.row.device" placeholder="请输入" /> |
||||||
|
</template> |
||||||
|
</el-table-column> |
||||||
|
<el-table-column prop="drug" label="药品" align="center" width="150"> |
||||||
|
<template #header> |
||||||
|
<span><i style="color: red">*</i>药品</span> |
||||||
|
</template> |
||||||
|
<template #default="scope"> |
||||||
|
<el-input v-model="scope.row.drug" placeholder="请输入" /> |
||||||
|
</template> |
||||||
|
</el-table-column> |
||||||
|
<el-table-column prop="dose" label="剂量(kg)" align="center" width="150"> |
||||||
|
<template #header> |
||||||
|
<span><i style="color: red">*</i>剂量(kg)</span> |
||||||
|
</template> |
||||||
|
<template #default="scope"> |
||||||
|
<el-input v-model="scope.row.dose" placeholder="请输入" /> |
||||||
|
</template> |
||||||
|
</el-table-column> |
||||||
|
<el-table-column prop="dosingTime" label="加药时间" align="center" width="210"> |
||||||
|
<template #header> |
||||||
|
<span><i style="color: red" >*</i>加药时间</span> |
||||||
|
</template> |
||||||
|
<template #default="scope"> |
||||||
|
<el-date-picker v-model="scope.row.dosingTime" format="YYYY-MM-DD HH:mm:ss" value-format="YYYY-MM-DD HH:mm:ss" type="datetime" placeholder="选择日期" style="width: 100%" /> |
||||||
|
</template> |
||||||
|
</el-table-column> |
||||||
|
<el-table-column prop="dosingMan" label="加药人" align="center" width="150"> |
||||||
|
<template #header> |
||||||
|
<span><i style="color: red">*</i>加药人</span> |
||||||
|
</template> |
||||||
|
<template #default="scope"> |
||||||
|
<el-select v-model="scope.row.dosingMan" placeholder="请选择" style="width: 100%"> |
||||||
|
<el-option label="崔殿龙" value="541" /> |
||||||
|
</el-select> |
||||||
|
</template> |
||||||
|
</el-table-column> |
||||||
|
<el-table-column prop="memo" label="备注" align="center"> |
||||||
|
<template #default="scope"> |
||||||
|
<el-input v-model="scope.row.memo" /> |
||||||
|
</template> |
||||||
|
</el-table-column> |
||||||
|
</el-table> |
||||||
|
|
||||||
|
<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> |
||||||
|
export default { |
||||||
|
props: { |
||||||
|
showDialog: { |
||||||
|
type: Boolean, |
||||||
|
default: false, |
||||||
|
}, |
||||||
|
moldAddMore: { |
||||||
|
type: Boolean, |
||||||
|
default: false, |
||||||
|
}, |
||||||
|
}, |
||||||
|
data() { |
||||||
|
return { |
||||||
|
openShow: false, |
||||||
|
tableData: [ |
||||||
|
// 初始化一行空数据 |
||||||
|
{ |
||||||
|
device: null, |
||||||
|
dosingTime: null, |
||||||
|
dosingMan: null, |
||||||
|
drug: null, |
||||||
|
dose: null, |
||||||
|
memo: '', |
||||||
|
}, |
||||||
|
], |
||||||
|
}; |
||||||
|
}, |
||||||
|
watch: { |
||||||
|
// 监听父组件传入的显示状态,同步更新弹窗 |
||||||
|
showDialog: { |
||||||
|
handler(newVal) { |
||||||
|
this.openShow = newVal; |
||||||
|
}, |
||||||
|
immediate: true |
||||||
|
}, |
||||||
|
}, |
||||||
|
methods: { |
||||||
|
closeDialog() { |
||||||
|
this.openShow = false; |
||||||
|
this.$emit('closeDialog'); |
||||||
|
}, |
||||||
|
// 插入一行 |
||||||
|
addTable() { |
||||||
|
this.tableData.push({ |
||||||
|
device: null, |
||||||
|
dosingTime: null, |
||||||
|
dosingMan: null, |
||||||
|
drug: null, |
||||||
|
dose: null, |
||||||
|
memo: '', |
||||||
|
}); |
||||||
|
}, |
||||||
|
// 删除行 |
||||||
|
delTable() { |
||||||
|
if (this.tableData.length <= 1) { |
||||||
|
this.$message.warning('至少保留一行数据'); |
||||||
|
return; |
||||||
|
} |
||||||
|
this.tableData.pop(); // 删除最后一行 |
||||||
|
}, |
||||||
|
// 提交数据 |
||||||
|
submit() { |
||||||
|
const isValid = this.tableData.every(row => { |
||||||
|
// 检查所有必填项 |
||||||
|
if (!row.device || !row.dosingTime || !row.dosingMan || !row.drug || !row.dose) { |
||||||
|
// 指明具体缺少的字段 |
||||||
|
const missingFields = []; |
||||||
|
if (!row.device) missingFields.push("设施"); |
||||||
|
if (!row.dosingTime) missingFields.push("加药时间"); |
||||||
|
if (!row.dosingMan) missingFields.push("加药人"); |
||||||
|
if (!row.drug) missingFields.push("药品"); |
||||||
|
if (!row.dose) missingFields.push("剂量(kg)"); |
||||||
|
this.$message.error(`请完善必填项: ${missingFields.join(", ")}`); |
||||||
|
return false; |
||||||
|
} |
||||||
|
return true; |
||||||
|
}); |
||||||
|
if (isValid) { |
||||||
|
// 向父组件传递新增的数据 |
||||||
|
console.log(this.tableData, 'this.tableData'); |
||||||
|
this.$emit('submitData', this.tableData); |
||||||
|
this.closeDialog(); // 提交后关闭弹窗 |
||||||
|
} |
||||||
|
}, |
||||||
|
}, |
||||||
|
}; |
||||||
|
</script> |
||||||
|
<style lang="scss" scoped></style> |
||||||
@ -0,0 +1,148 @@ |
|||||||
|
<template> |
||||||
|
<el-dialog title="新增" append-to-body v-model="openShow" width="70%" @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> |
||||||
|
<el-table :data="tableData" style="width: 100%" border :cell-style="{padding: '5px'}"> |
||||||
|
<!-- 报废槽液类型(可选择) --> |
||||||
|
<el-table-column prop="wasteType" label="报废槽液类型" align="center" width="170"> |
||||||
|
<template #header> |
||||||
|
<span><i style="color: red">*</i>报废槽液类型</span> |
||||||
|
</template> |
||||||
|
<template #default="scope"> |
||||||
|
<el-select v-model="scope.row.wasteType" placeholder="请选择" style="width: 100%"> |
||||||
|
<el-option label="预镀镍废液" value="预镀镍废液" /> |
||||||
|
<el-option label="除油废液" value="除油废液" /> |
||||||
|
<el-option label="其它废液" value="其它废液" /> |
||||||
|
</el-select> |
||||||
|
</template> |
||||||
|
</el-table-column> |
||||||
|
|
||||||
|
<!-- 排放班组(可选择) --> |
||||||
|
<el-table-column prop="teamName" label="排放班组" align="center" width="170"> |
||||||
|
<template #header> |
||||||
|
<span><i style="color: red">*</i>排放班组</span> |
||||||
|
</template> |
||||||
|
<template #default="scope"> |
||||||
|
<el-select v-model="scope.row.teamName" placeholder="请选择" style="width: 100%"> |
||||||
|
<el-option label="化学镀镍二班" value="化学镀镍二班" /> |
||||||
|
<el-option label="零件管理班" value="零件管理班" /> |
||||||
|
</el-select> |
||||||
|
</template> |
||||||
|
</el-table-column> |
||||||
|
|
||||||
|
<!-- 排放量(输入框) --> |
||||||
|
<el-table-column prop="amount" label="排放量(单位:L)" align="center" width="170"> |
||||||
|
<template #header> |
||||||
|
<span><i style="color: red">*</i>排放量</span> |
||||||
|
</template> |
||||||
|
<template #default="scope"> |
||||||
|
<el-input v-model.number="scope.row.amount" placeholder="请输入" /> |
||||||
|
</template> |
||||||
|
</el-table-column> |
||||||
|
|
||||||
|
<!-- 日期(日期选择器) --> |
||||||
|
<el-table-column prop="dirDate" label="日期" align="center" width="170"> |
||||||
|
<template #header> |
||||||
|
<span><i style="color: red" >*</i>日期</span> |
||||||
|
</template> |
||||||
|
<template #default="scope"> |
||||||
|
<el-date-picker v-model="scope.row.dirDate" format="YYYY-MM-DD HH:mm:ss" value-format="YYYY-MM-DD HH:mm:ss" type="date" placeholder="选择日期" style="width: 100%" /> |
||||||
|
</template> |
||||||
|
</el-table-column> |
||||||
|
|
||||||
|
<!-- 备注(输入框) --> |
||||||
|
<el-table-column prop="memo" label="备注" align="center" > |
||||||
|
<template #default="scope"> |
||||||
|
<el-input v-model="scope.row.memo" placeholder="请输入备注" /> |
||||||
|
</template> |
||||||
|
</el-table-column> |
||||||
|
</el-table> |
||||||
|
|
||||||
|
<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> |
||||||
|
export default { |
||||||
|
props: { |
||||||
|
showDialog: { |
||||||
|
type: Boolean, |
||||||
|
default: false, |
||||||
|
}, |
||||||
|
moldAddMore: { |
||||||
|
type: Boolean, |
||||||
|
default: false, |
||||||
|
}, |
||||||
|
}, |
||||||
|
data() { |
||||||
|
return { |
||||||
|
openShow: false, |
||||||
|
tableData: [], |
||||||
|
}; |
||||||
|
}, |
||||||
|
watch: { |
||||||
|
// 监听父组件传入的显示状态,同步更新弹窗 |
||||||
|
showDialog: { |
||||||
|
handler(newVal) { |
||||||
|
this.openShow = newVal; |
||||||
|
}, |
||||||
|
immediate: true |
||||||
|
}, |
||||||
|
}, |
||||||
|
methods: { |
||||||
|
closeDialog() { |
||||||
|
this.openShow = false; |
||||||
|
this.$emit('closeDialog'); |
||||||
|
// 关闭时清空数据,避免下次打开残留 |
||||||
|
this.tableData = [{ wasteType: null, teamName: null, amount: null, dirDate: null, memo: '' }]; |
||||||
|
}, |
||||||
|
// 插入一行 |
||||||
|
addTable() { |
||||||
|
this.tableData.push({}); |
||||||
|
}, |
||||||
|
// 删除行 |
||||||
|
delTable() { |
||||||
|
this.tableData.pop() |
||||||
|
}, |
||||||
|
// 提交数据 |
||||||
|
submit() { |
||||||
|
// 简单验证:检查必填项 |
||||||
|
const isValid = this.tableData.every(row => { |
||||||
|
// 添加调试信息 |
||||||
|
console.log("验证数据:", { |
||||||
|
wasteType: row.wasteType, |
||||||
|
teamName: row.teamName, |
||||||
|
amount: row.amount, |
||||||
|
dirDate: row.dirDate |
||||||
|
}); |
||||||
|
|
||||||
|
// 检查所有必填项 |
||||||
|
if (!row.wasteType || !row.teamName || !row.amount || !row.dirDate) { |
||||||
|
// 指明具体缺少的字段 |
||||||
|
const missingFields = []; |
||||||
|
if (!row.wasteType) missingFields.push("报废槽液类型"); |
||||||
|
if (!row.teamName) missingFields.push("排放班组"); |
||||||
|
if (!row.amount) missingFields.push("排放量"); |
||||||
|
if (!row.dirDate) missingFields.push("日期"); |
||||||
|
|
||||||
|
this.$message.error(`请完善必填项: ${missingFields.join(", ")}`); |
||||||
|
return false; |
||||||
|
} |
||||||
|
return true; |
||||||
|
}); |
||||||
|
if (isValid) { |
||||||
|
// 向父组件传递新增的数据 |
||||||
|
this.$emit('submitData', this.tableData); |
||||||
|
this.closeDialog(); // 提交后关闭弹窗 |
||||||
|
} |
||||||
|
}, |
||||||
|
}, |
||||||
|
}; |
||||||
|
</script> |
||||||
|
<style lang="scss" scoped></style> |
||||||
@ -0,0 +1,148 @@ |
|||||||
|
<template> |
||||||
|
<el-dialog title="新增" append-to-body v-model="openShow" width="70%" @close="closeDialog" destroy-on-close> |
||||||
|
<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> |
||||||
|
<el-table :data="tableData" style="width: 100%" border :cell-style="{ padding: '5px' }"> |
||||||
|
<!-- 设施 --> |
||||||
|
<el-table-column prop="device" label="设施" align="center" width="170"> |
||||||
|
<template #header> |
||||||
|
<span><i style="color: red">*</i>设施</span> |
||||||
|
</template> |
||||||
|
<template #default="scope"> |
||||||
|
<el-input v-model="scope.row.device" placeholder="请输入" /> |
||||||
|
</template> |
||||||
|
</el-table-column> |
||||||
|
|
||||||
|
<!-- 药品 --> |
||||||
|
<el-table-column prop="drug" label="药品" align="center" width="170"> |
||||||
|
<template #header> |
||||||
|
<span><i style="color: red">*</i>药品</span> |
||||||
|
</template> |
||||||
|
<template #default="scope"> |
||||||
|
<el-input v-model="scope.row.drug" placeholder="请输入" /> |
||||||
|
</template> |
||||||
|
</el-table-column> |
||||||
|
|
||||||
|
<!-- 剂量 --> |
||||||
|
<el-table-column prop="dose" label="剂量(kg)" align="center" width="170"> |
||||||
|
<template #header> |
||||||
|
<span><i style="color: red">*</i>剂量(kg)</span> |
||||||
|
</template> |
||||||
|
<template #default="scope"> |
||||||
|
<el-input v-model.number="scope.row.dose" placeholder="请输入" /> |
||||||
|
</template> |
||||||
|
</el-table-column> |
||||||
|
<!-- 加药人 --> |
||||||
|
<el-table-column prop="dosingMan" label="加药人" align="center" width="170"> |
||||||
|
<template #header> |
||||||
|
<span><i style="color: red">*</i>加药人</span> |
||||||
|
</template> |
||||||
|
<template #default="scope"> |
||||||
|
<el-select v-model="scope.row.dosingMan" placeholder="请选择" style="width: 100%"> |
||||||
|
<el-option label="崔殿龙" value="541" /> |
||||||
|
</el-select> |
||||||
|
</template> |
||||||
|
</el-table-column> |
||||||
|
<!-- 加药时间 --> |
||||||
|
<el-table-column prop="dosingTime" label="加药时间" align="center" width="210"> |
||||||
|
<template #header> |
||||||
|
<span><i style="color: red">*</i>加药时间</span> |
||||||
|
</template> |
||||||
|
<template #default="scope"> |
||||||
|
<el-date-picker v-model="scope.row.dosingTime" format="YYYY-MM-DD HH:mm:ss" |
||||||
|
value-format="YYYY-MM-DD HH:mm:ss" type="datetime" placeholder="选择时间" style="width: 100%" /> |
||||||
|
</template> |
||||||
|
</el-table-column> |
||||||
|
|
||||||
|
<!-- 备注(输入框) --> |
||||||
|
<el-table-column prop="memo" label="备注" align="center"> |
||||||
|
<template #default="scope"> |
||||||
|
<el-input v-model="scope.row.memo" placeholder="请输入备注" /> |
||||||
|
</template> |
||||||
|
</el-table-column> |
||||||
|
</el-table> |
||||||
|
<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> |
||||||
|
export default { |
||||||
|
props: { |
||||||
|
showDialog: { |
||||||
|
type: Boolean, |
||||||
|
default: false, |
||||||
|
}, |
||||||
|
moldAddMore: { |
||||||
|
type: Boolean, |
||||||
|
default: false, |
||||||
|
}, |
||||||
|
}, |
||||||
|
data() { |
||||||
|
return { |
||||||
|
openShow: false, |
||||||
|
tableData:[], |
||||||
|
}; |
||||||
|
}, |
||||||
|
watch: { |
||||||
|
// 监听父组件传入的显示状态,同步更新弹窗 |
||||||
|
showDialog: { |
||||||
|
handler(newVal) { |
||||||
|
this.openShow = newVal; |
||||||
|
}, |
||||||
|
immediate: true |
||||||
|
}, |
||||||
|
}, |
||||||
|
methods: { |
||||||
|
show(){ |
||||||
|
this.openShow = true; |
||||||
|
this.tableData = []; |
||||||
|
}, |
||||||
|
closeDialog() { |
||||||
|
this.openShow = false; |
||||||
|
}, |
||||||
|
// 插入一行 |
||||||
|
addTable() { |
||||||
|
this.tableData.push({}); |
||||||
|
}, |
||||||
|
// 删除行 |
||||||
|
delTable() { |
||||||
|
this.tableData.pop() |
||||||
|
}, |
||||||
|
// 提交数据 |
||||||
|
submit() { |
||||||
|
const isValid = this.tableData.every(row => { |
||||||
|
// 检查所有必填项 |
||||||
|
if (!row.device || !row.drug || !row.dose || !row.dosingTime || !row.dosingMan) { |
||||||
|
// 指明具体缺少的字段 |
||||||
|
const missingFields = []; |
||||||
|
if (!row.device) missingFields.push("设施"); |
||||||
|
if (!row.drug) missingFields.push("药品"); |
||||||
|
if (!row.dose) missingFields.push("剂量(kg)"); |
||||||
|
if (!row.dosingTime) missingFields.push("加药时间"); |
||||||
|
if (!row.dosingMan) missingFields.push("加药人"); |
||||||
|
this.$message.error(`请完善必填项: ${missingFields.join(", ")}`); |
||||||
|
return false; |
||||||
|
} |
||||||
|
return true; |
||||||
|
}); |
||||||
|
if (isValid) { |
||||||
|
// 如果所有必填项都填写了,则进行提交操作 |
||||||
|
// if(res.code == 200){ |
||||||
|
// this.$message.success("提交成功"); |
||||||
|
// this.closeDialog(); // 提交后关闭弹窗 |
||||||
|
// this.$emit("submitData"); // 通知父组件刷新表格数据 |
||||||
|
// }else{ |
||||||
|
// this.$message.error("提交失败"); |
||||||
|
// } |
||||||
|
} |
||||||
|
}, |
||||||
|
}, |
||||||
|
}; |
||||||
|
</script> |
||||||
|
<style lang="scss" scoped></style> |
||||||
@ -0,0 +1,172 @@ |
|||||||
|
<template> |
||||||
|
<el-dialog title="新增" append-to-body v-model="openShow" width="70%" @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> |
||||||
|
<el-table :data="tableData" style="width: 100%" border :cell-style="{ padding: '5px' }"> |
||||||
|
<!-- 设施 --> |
||||||
|
<el-table-column prop="device" label="设施" align="center" width="150"> |
||||||
|
<template #header> |
||||||
|
<span><i style="color: red">*</i>设施</span> |
||||||
|
</template> |
||||||
|
<template #default="scope"> |
||||||
|
<el-input v-model="scope.row.device" placeholder="请输入" /> |
||||||
|
</template> |
||||||
|
</el-table-column> |
||||||
|
<el-table-column prop="dosingTime" label="化验时间" align="center" width="150"> |
||||||
|
<template #header> |
||||||
|
<span><i style="color: red">*</i>化验时间</span> |
||||||
|
</template> |
||||||
|
<template #default="scope"> |
||||||
|
<el-date-picker v-model="scope.row.dosingTime" |
||||||
|
format="YYYY-MM-DD HH:mm:ss" value-format="YYYY-MM-DD HH:mm:ss" |
||||||
|
type="datetime" placeholder="选择时间" |
||||||
|
style="width: 100%" /> |
||||||
|
</template> |
||||||
|
</el-table-column> |
||||||
|
<el-table-column prop="dosingMan" label="化验人" align="center" width="150"> |
||||||
|
<template #header> |
||||||
|
<span><i style="color: red">*</i>化验人</span> |
||||||
|
</template> |
||||||
|
<template #default="scope"> |
||||||
|
<el-select v-model="scope.row.dosingMan" placeholder="请选择" style="width: 100%"> |
||||||
|
<el-option label="崔殿龙" value="541" /> |
||||||
|
</el-select> |
||||||
|
</template> |
||||||
|
</el-table-column> |
||||||
|
<el-table-column prop="itNi" label="镍" align="center" width="100"> |
||||||
|
<template #header> |
||||||
|
<span>镍</span> |
||||||
|
</template> |
||||||
|
<template #default="scope"> |
||||||
|
<el-input v-model="scope.row.itNi" /> |
||||||
|
</template> |
||||||
|
</el-table-column> |
||||||
|
<el-table-column prop="itCu" label="铜" align="center" width="100"> |
||||||
|
<template #header> |
||||||
|
<span>铜</span> |
||||||
|
</template> |
||||||
|
<template #default="scope"> |
||||||
|
<el-input v-model="scope.row.itCu" /> |
||||||
|
</template> |
||||||
|
</el-table-column> |
||||||
|
<el-table-column prop="itCr" label="六价铬" align="center" width="100"> |
||||||
|
<template #header> |
||||||
|
<span>六价铬</span> |
||||||
|
</template> |
||||||
|
<template #default="scope"> |
||||||
|
<el-input v-model="scope.row.itCr" /> |
||||||
|
</template> |
||||||
|
</el-table-column> |
||||||
|
<el-table-column prop="itCn2" label="氰化物" align="center" width="100"> |
||||||
|
<template #header> |
||||||
|
<span>氰化物</span> |
||||||
|
</template> |
||||||
|
<template #default="scope"> |
||||||
|
<el-input v-model="scope.row.itCn2" /> |
||||||
|
</template> |
||||||
|
</el-table-column> |
||||||
|
<el-table-column prop="itPh" label="PH" align="center" width="80"> |
||||||
|
<template #header> |
||||||
|
<span>PH</span> |
||||||
|
</template> |
||||||
|
<template #default="scope"> |
||||||
|
<el-input v-model="scope.row.itPh" /> |
||||||
|
</template> |
||||||
|
</el-table-column> |
||||||
|
<!-- 备注(输入框) --> |
||||||
|
<el-table-column prop="memo" label="备注" align="center" > |
||||||
|
<template #default="scope"> |
||||||
|
<el-input v-model="scope.row.memo"/> |
||||||
|
</template> |
||||||
|
</el-table-column> |
||||||
|
</el-table> |
||||||
|
|
||||||
|
<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> |
||||||
|
export default { |
||||||
|
props: { |
||||||
|
showDialog: { |
||||||
|
type: Boolean, |
||||||
|
default: false, |
||||||
|
}, |
||||||
|
moldAddMore: { |
||||||
|
type: Boolean, |
||||||
|
default: false, |
||||||
|
}, |
||||||
|
}, |
||||||
|
data() { |
||||||
|
return { |
||||||
|
openShow: false, |
||||||
|
tableData: [], |
||||||
|
}; |
||||||
|
}, |
||||||
|
watch: { |
||||||
|
// 监听父组件传入的显示状态,同步更新弹窗 |
||||||
|
showDialog: { |
||||||
|
handler(newVal) { |
||||||
|
this.openShow = newVal; |
||||||
|
}, |
||||||
|
immediate: true |
||||||
|
}, |
||||||
|
}, |
||||||
|
methods: { |
||||||
|
closeDialog() { |
||||||
|
this.openShow = false; |
||||||
|
this.$emit('closeDialog'); |
||||||
|
// 关闭时清空数据 |
||||||
|
this.tableData = |
||||||
|
[{ |
||||||
|
device: null, |
||||||
|
dosingTime: null, |
||||||
|
dosingMan: null, |
||||||
|
itNi: null, |
||||||
|
itCu: null, |
||||||
|
itCr: null, |
||||||
|
itCn2: null, |
||||||
|
itPh: null, |
||||||
|
memo: '', |
||||||
|
}]; |
||||||
|
}, |
||||||
|
// 插入一行 |
||||||
|
addTable() { |
||||||
|
this.tableData.push({}); |
||||||
|
}, |
||||||
|
// 删除行 |
||||||
|
delTable() { |
||||||
|
this.tableData.pop() |
||||||
|
}, |
||||||
|
// 提交数据 |
||||||
|
submit() { |
||||||
|
const isValid = this.tableData.every(row => { |
||||||
|
// 检查所有必填项 |
||||||
|
if (!row.device || !row.dosingTime || !row.dosingMan) { |
||||||
|
// 指明具体缺少的字段 |
||||||
|
const missingFields = []; |
||||||
|
if (!row.device) missingFields.push("设施"); |
||||||
|
if (!row.dosingTime) missingFields.push("化验时间"); |
||||||
|
if (!row.dosingMan) missingFields.push("化验人"); |
||||||
|
this.$message.error(`请完善必填项: ${missingFields.join(", ")}`); |
||||||
|
return false; |
||||||
|
} |
||||||
|
return true; |
||||||
|
}); |
||||||
|
if (isValid) { |
||||||
|
// 向父组件传递新增的数据 |
||||||
|
console.log(this.tableData, 'this.tableData'); |
||||||
|
this.$emit('submitData', this.tableData); |
||||||
|
this.closeDialog(); // 提交后关闭弹窗 |
||||||
|
} |
||||||
|
}, |
||||||
|
}, |
||||||
|
}; |
||||||
|
</script> |
||||||
|
<style lang="scss" scoped></style> |
||||||
Loading…
Reference in new issue