|
|
|
|
@ -1,10 +1,10 @@ |
|
|
|
|
<template> |
|
|
|
|
<el-dialog title="新增" append-to-body v-model="openShow" width="70%" @close="closeDialog"> |
|
|
|
|
<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 :data="tableData" style="width: 100%" border :cell-style="{ padding: '5px' }"> |
|
|
|
|
<!-- 设施 --> |
|
|
|
|
<el-table-column prop="device" label="设施" align="center" width="170"> |
|
|
|
|
<template #header> |
|
|
|
|
@ -51,18 +51,18 @@ |
|
|
|
|
<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%" /> |
|
|
|
|
<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" > |
|
|
|
|
<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> |
|
|
|
|
@ -86,17 +86,7 @@ export default { |
|
|
|
|
data() { |
|
|
|
|
return { |
|
|
|
|
openShow: false, |
|
|
|
|
tableData: [ |
|
|
|
|
// 初始化一行空数据 |
|
|
|
|
{ |
|
|
|
|
device: null, |
|
|
|
|
drug: null, |
|
|
|
|
dose: null, |
|
|
|
|
dosingTime: null, |
|
|
|
|
dosingMan: null, |
|
|
|
|
memo: '', // 备注 |
|
|
|
|
}, |
|
|
|
|
], |
|
|
|
|
tableData:[], |
|
|
|
|
}; |
|
|
|
|
}, |
|
|
|
|
watch: { |
|
|
|
|
@ -109,45 +99,24 @@ export default { |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
methods: { |
|
|
|
|
show(){ |
|
|
|
|
this.openShow = true; |
|
|
|
|
this.tableData = []; |
|
|
|
|
}, |
|
|
|
|
closeDialog() { |
|
|
|
|
this.openShow = false; |
|
|
|
|
this.$emit('closeDialog'); |
|
|
|
|
// 关闭时清空数据 |
|
|
|
|
this.tableData = |
|
|
|
|
[{ device: null, drug: null, dose: null, dosingTime: null, dosingMan: null, memo: '' }]; |
|
|
|
|
}, |
|
|
|
|
// 插入一行 |
|
|
|
|
addTable() { |
|
|
|
|
this.tableData.push({ |
|
|
|
|
device: null, |
|
|
|
|
drug: null, |
|
|
|
|
dose: null, |
|
|
|
|
dosingTime: null, |
|
|
|
|
dosingMan: null, |
|
|
|
|
memo: '', // 备注 |
|
|
|
|
}); |
|
|
|
|
this.tableData.push({}); |
|
|
|
|
}, |
|
|
|
|
// 删除行 |
|
|
|
|
delTable() { |
|
|
|
|
if (this.tableData.length <= 1) { |
|
|
|
|
this.$message.warning('至少保留一行数据'); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
this.tableData.pop(); // 删除最后一行 |
|
|
|
|
this.tableData.pop() |
|
|
|
|
}, |
|
|
|
|
// 提交数据 |
|
|
|
|
submit() { |
|
|
|
|
// 简单验证:检查必填项 |
|
|
|
|
const isValid = this.tableData.every(row => { |
|
|
|
|
// 添加调试信息 |
|
|
|
|
console.log("验证数据:", { |
|
|
|
|
device: row.device, |
|
|
|
|
drug: row.drug, |
|
|
|
|
dose: row.dose, |
|
|
|
|
dosingTime: row.dosingTime, |
|
|
|
|
dosingMan: row.dosingMan |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
// 检查所有必填项 |
|
|
|
|
if (!row.device || !row.drug || !row.dose || !row.dosingTime || !row.dosingMan) { |
|
|
|
|
// 指明具体缺少的字段 |
|
|
|
|
@ -163,9 +132,14 @@ export default { |
|
|
|
|
return true; |
|
|
|
|
}); |
|
|
|
|
if (isValid) { |
|
|
|
|
// 向父组件传递新增的数据 |
|
|
|
|
this.$emit('submitData', this.tableData); |
|
|
|
|
this.closeDialog(); // 提交后关闭弹窗 |
|
|
|
|
// 如果所有必填项都填写了,则进行提交操作 |
|
|
|
|
// if(res.code == 200){ |
|
|
|
|
// this.$message.success("提交成功"); |
|
|
|
|
// this.closeDialog(); // 提交后关闭弹窗 |
|
|
|
|
// this.$emit("submitData"); // 通知父组件刷新表格数据 |
|
|
|
|
// }else{ |
|
|
|
|
// this.$message.error("提交失败"); |
|
|
|
|
// } |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
|