组件的动态挂载
弹窗aaa.vue
<template>
<el-dialog
width="700px "
v-dialog-out
destroy-on-close
v-if="dialogVisible"
:title="title"
:visible="dialogVisible"
:before-close="hideDialog"
:close-on-click-modal="false"
>
<div class="dialog-body">
</div>
<div class="dialog-footer">
<el-button @click="hideDialog">取 消</el-button>
<el-button type="primary" @click="validateForm">确 定</el-button>
</div>
</el-dialog>
</template>
<script>
export default {
name: "aaa",
components: {},
props: {},
data() {
return {
dialogVisible: false,
title: "",
};
},
methods: {
showDialog(data) {
console.log(data);
this.dialogVisible = true;
this.title = data.type;
if (data.data) {
this.getDetail(data.data.id);
}
},
hideDialog() {
this.dialogVisible = false;
this.$refs.form.resetFields();
this.formData = {};
this.$parent.getTableData();
this.fileUploadUtils.fileList = [];
},
getDetail(id) {
},
async validateForm() {
try {
if (await this.$refs.form.validate()) this.submitForm();
} catch (e) {}
},
submitForm() {
},
},
created() {},
mounted() {},
};
</script>
<style lang="scss" scoped>
::v-deep .el-dialog__body {
padding: 20px 0 0 !important;
}
.dialog-body {
padding: 0 20px;
max-height: 65vh;
overflow-y: auto;
}
.dialog-footer {
text-align: center;
padding: 10px 0 18px;
}
</style>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
弹窗bbb.vue
<template>
<el-dialog
width="700px "
v-dialog-out
destroy-on-close
v-if="dialogVisible"
:title="title"
:visible="dialogVisible"
:before-close="hideDialog"
:close-on-click-modal="false"
>
<div class="dialog-body">
</div>
<div class="dialog-footer">
<el-button @click="hideDialog">取 消</el-button>
<el-button type="primary" @click="validateForm">确 定</el-button>
</div>
</el-dialog>
</template>
<script>
export default {
name: "bbb",
components: {},
props: {},
data() {
return {
dialogVisible: false,
title: "",
};
},
methods: {
showDialog(data) {
console.log(data);
this.dialogVisible = true;
this.title = data.type;
if (data.data) {
this.getDetail(data.data.id);
}
},
hideDialog() {
this.dialogVisible = false;
this.$refs.form.resetFields();
this.formData = {};
this.$parent.getTableData();
this.fileUploadUtils.fileList = [];
},
getDetail(id) {
},
async validateForm() {
try {
if (await this.$refs.form.validate()) this.submitForm();
} catch (e) {}
},
submitForm() {
},
},
created() {},
mounted() {},
};
</script>
<style lang="scss" scoped>
::v-deep .el-dialog__body {
padding: 20px 0 0 !important;
}
.dialog-body {
padding: 0 20px;
max-height: 65vh;
overflow-y: auto;
}
.dialog-footer {
text-align: center;
padding: 10px 0 18px;
}
</style>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
父组件中使用
<template>
<div>
<el-button
type="text"
size="small"
icon="iconfont if-biaodancaozuo-xiugai"
@click="doSomething(scope.row, '审批', 'aaa')"
>审批
</el-button>
<el-button
type="text"
size="small"
icon="iconfont if-biaodancaozuo-xiugai"
@click="doSomething(scope.row, '修改', 'bbb')"
>修改
</el-button>
<component :is="dialogName" ref="dialog"></component>
</divd>
</template>
export default {
data() {
return {
dialogName: undefined,
}
},
methods: {
doSomething(data, type, dialogName) {
this.dialogName = this.getDialog(dialogName);
this.$nextTick(() => {
this.$refs.dialog.showDialog({ data, type });
});
},
getDialog(name) {
return require(`@/views/maintenanceProject/engineeringManage/dialog/${name}.vue`).default;
},
}
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45