调整MyDialog组件 支持传递按钮名
This commit is contained in:
parent
e20e06c303
commit
7f4ba633ec
@ -15,8 +15,8 @@
|
||||
<slot></slot>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="onCancel">取消</el-button>
|
||||
<el-button type="primary" @click="onConfirm"> 确认 </el-button>
|
||||
<el-button @click="onCancel"> {{ onCancelName }} </el-button>
|
||||
<el-button type="primary" @click="onConfirm"> {{ onConfirmName }} </el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
@ -58,6 +58,14 @@ const props = defineProps({
|
||||
type: Function,
|
||||
default: () => {},
|
||||
},
|
||||
onConfirmName: {
|
||||
type: String,
|
||||
default: "确认",
|
||||
},
|
||||
onCancelName: {
|
||||
type: String,
|
||||
default: "取消",
|
||||
}
|
||||
});
|
||||
|
||||
const normalizedComponent = computed(() =>
|
||||
|
||||
@ -79,6 +79,17 @@ const INIT_FORM = {
|
||||
}; // 表单初始值
|
||||
const form = reactive({ ...INIT_FORM }); // 表单
|
||||
|
||||
// 重置表单方法
|
||||
const resetForm = () => {
|
||||
// 深拷贝重置嵌套对象
|
||||
form.material = { ...INIT_FORM.material };
|
||||
form.photos = [...INIT_FORM.photos];
|
||||
|
||||
form.material.yhzid = yhzid.value;
|
||||
form.material.jd = yhzData.value?.jd;
|
||||
form.material.wd = yhzData.value?.wd;
|
||||
};
|
||||
|
||||
|
||||
|
||||
// 节点过滤函数
|
||||
@ -367,10 +378,7 @@ const getDetailData = async (row) => {
|
||||
const openAddModel = () => {
|
||||
model.title = `新增物资`;
|
||||
model.content = AddDialog;
|
||||
Object.assign(form, INIT_FORM);
|
||||
form.material.yhzid = yhzid.value;
|
||||
form.material.jd = yhzData.value?.jd;
|
||||
form.material.wd = yhzData.value?.wd;
|
||||
resetForm(); // 重置表单
|
||||
model.props = {
|
||||
yhzData: yhzData.value,
|
||||
form: form,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user