ed-frame-vue
Version:
easydata 基础组件
64 lines (61 loc) • 2.89 kB
JavaScript
export default {
methods: {
/**
* 点击动态模版操作右侧属性
* @param {*} command
*/
async updateRightProp(command) {
this.propActiveName = command;
await this.recordRightProp()
//获取参数属性
let module
if ('oneProp' === command) {
module = this.oneModules[this.oneModuleActive]
} else if ('twoProp' === command) {
let twoModules = this.oneModules[this.oneModuleActive]?.twoModules;
module = twoModules[this.twoModuleActive]
}
if (module) {
this.$set(this[command], 'formData', Object.assign({ id: module.id }, { key: module.prop? module.prop : {}}))
}
},
//记录右侧模块属性
async recordRightProp() {
let {GlobalPropEasyDataList, OnePropEasyDataList, TwoPropEasyDataList } = this.$refs;
//记录全局模块属性
if(GlobalPropEasyDataList) {
let oldGlobalModuleProp = await GlobalPropEasyDataList.getFormData();
if (oldGlobalModuleProp.key && this.templateModel) {
this.$set(this.templateModel, 'prop', oldGlobalModuleProp.key)
}
}
//记录历史一级模块属性
if (OnePropEasyDataList) {
let oldOneModuleProp = await OnePropEasyDataList.getFormData();
if (oldOneModuleProp.id) {
let oldOneModuleIndex = this.oneModules.findIndex(t => t.id === oldOneModuleProp.id);
let oldOneModule = this.oneModules.find(t => t.id === oldOneModuleProp.id);
if (oldOneModule) {
let temp = Object.assign({}, oldOneModule)
temp.prop = Object.assign({},oldOneModuleProp.key)
this.oneModules.splice(oldOneModuleIndex, 1, temp)
}
}
}
//记录历史二级模块属性
if (TwoPropEasyDataList) {
let oldTwoModuleProp = await TwoPropEasyDataList.getFormData();
let twoModules = this.oneModules[this.oneModuleActive]?.twoModules;
if (oldTwoModuleProp.id && twoModules) {
let oldTwoModuleIndex = twoModules.findIndex(t => t.id === oldTwoModuleProp.id);
let oldTwoModule = twoModules.find(t => t.id === oldTwoModuleProp.id);
if (oldTwoModule) {
oldTwoModule.prop = oldTwoModuleProp.key
twoModules.splice(oldTwoModuleIndex, 1, oldTwoModule)
this.$set(this.oneModules[this.oneModuleActive], 'twoModules', twoModules)
}
}
}
},
}
}