<template>
|
<el-dialog v-dialogDrag
|
:title="title"
|
:visible.sync="visible"
|
:width="width"
|
:fullscreen="fullscreen"
|
:append-to-body="true"
|
top="0"
|
class="avue-dialog"
|
:destroy-on-close="true"
|
:close-on-click-modal="false"
|
@close="dialogClose">
|
<!--窗口显示内容-->
|
<!--展示UI上下文-->
|
<ui-view ref="uiViewRef" v-if="paramVOS.context"
|
:key="'AddDialog-'+paramVOS.context"
|
:style="fullscreen?'':'height:'+height"
|
:btmType="paramVOS.type"
|
:context="paramVOS.context"
|
:inDialog="true"
|
:canEdit="true"
|
:actionType="type"
|
:sourceData="sourceData"
|
:dataStore="dataStore"
|
:paramVOS="paramVOS"
|
@getFormData="getFormData"
|
></ui-view>
|
<!--非UI上下文-->
|
<div v-else>这里是窗口显示内容</div>
|
|
<!--底部按钮,非必有-->
|
<div class="dialog-footer avue-dialog__footer">
|
<el-button type="primary" plain size="small" @click="save" >保 存</el-button>
|
<el-button size="small" @click="dialogClose">取 消</el-button>
|
</div>
|
</el-dialog>
|
</template>
|
|
<script>
|
import uiView from "@/views/base/UIContentViewerInDialog"
|
import {validatenull} from "@/util/validate"
|
import {parseEventByUrl} from "@/components/actions/BaseAction";
|
|
export default {
|
name: "AddResourceFolderDialog",
|
components:{uiView},
|
props: {
|
sourceData: {
|
//所属区域的上一区域选中数据
|
type: Object,
|
default: {}
|
},
|
dataStore: {
|
//弹窗时按钮所属区域选中数据
|
type: Array,
|
default: []
|
},
|
paramVOS: {
|
type: Object,
|
default: {}
|
}
|
},
|
data(){
|
return {
|
type: "add",
|
visible: false,
|
form:{}//表单对象
|
}
|
},
|
computed:{
|
title(){
|
return this.paramVOS.title || (this.type=='add'?'添加':'修改')
|
},
|
width() {
|
if (!validatenull(this.paramVOS.width)) {
|
if (this.paramVOS.width.includes("px") || this.paramVOS.width.includes("%")) {
|
return this.paramVOS.width;
|
} else {
|
return this.paramVOS.width + "px";
|
}
|
} else {
|
return "60%";
|
}
|
},
|
height(){
|
if (!validatenull(this.paramVOS.height)) {
|
if (this.paramVOS.height.includes("px") || this.paramVOS.height.includes("%")) {
|
return this.paramVOS.height;
|
} else {
|
return this.paramVOS.height + "px";
|
}
|
} else {
|
return "auto"
|
}
|
},
|
fullscreen(){
|
if(this.paramVOS.width || this.paramVOS.height){
|
return false;
|
}else if(this.paramVOS.form){
|
return false;
|
}
|
return true;
|
}
|
},
|
created() {
|
},
|
watch: {},
|
methods: {
|
//关闭弹窗
|
dialogClose() {
|
this.visible = false;
|
},
|
//保存
|
save() {
|
//有保存前置事件
|
if (this.paramVOS.savebeforeevent) {
|
var urlobj = parseEventByUrl(this.paramVOS.savebeforeevent, null, null, 'doAction');
|
if(urlobj.params){
|
Object.assign(this.paramVOS,urlobj.params);
|
}
|
if(validatenull(urlobj.jsPath)){
|
this.saveBforeHandle(this.paramVOS);
|
}else{
|
try {
|
import(`./${urlobj.jsPath}.js`).then(module => {
|
module[urlobj.methodName]({
|
paramVOS: this.paramVOS,
|
dataStore: this.dataStore,
|
sourceData: this.sourceData
|
}, this.saveHandle);
|
})
|
} catch (error) {
|
this.$message.error('未找到保存前置事件执行js');
|
}
|
}
|
|
}else{
|
//直接保存
|
this.saveHandle();
|
}
|
},
|
saveHandle(){
|
let that=this;
|
|
//执行保存逻辑
|
|
//保存成功后
|
that.$message({
|
type: "success",
|
message: that.paramVOS.successmsg||"保存成功!"
|
});
|
if(that.saveCallback){
|
that.saveCallback(that.type);
|
}
|
if (this.paramVOS.saveafterevent) {
|
let urlobj = parseEventByUrl(this.paramVOS.saveafterevent,null,null,'doAction');
|
if(urlobj.params){
|
Object.assign(this.paramVOS,urlobj.params);
|
}
|
if(validatenull(urlobj.jsPath)){
|
this.saveAfterHandle(this.paramVOS);
|
}else{
|
try {
|
import(`./${urlobj.jsPath}.js`).then(module => {
|
module[urlobj.methodName]({
|
paramVOS: this.paramVOS,
|
dataStore: this.dataStore,
|
sourceData:this.sourceData
|
});
|
})
|
} catch (error) {
|
this.$message.error('未找到保存后置事件执行js');
|
}
|
}
|
|
}
|
that.dialogClose();
|
},
|
//保存前置事件
|
saveBforeHandle(params){
|
this.$message.info('执行保存前置事件');
|
},
|
//保存后置事件
|
saveAfterHandle(params){
|
this.$message.info('保存后置事件执行');
|
},
|
getFormData(form) {
|
this.form = form;
|
}
|
}
|
}
|
</script>
|
|
<style scoped>
|
|
</style>
|