-
+
@@ -362,6 +364,7 @@ export default {
height: 0,
width: 0,
},
+ isAppendPageModel: false, // 追加页面的临时模型
saveForm: {
automationId: null, // 场景id
name: null, // 名称
@@ -421,9 +424,25 @@ export default {
}
},
mounted() {
+ // 确保在组件挂载时saveForm中有正确的初始值
+ if (!this.detail || Object.keys(this.detail).length === 0) {
+ this.$set(this.saveForm, 'isAppendPage', 0);
+ }
+ this.initData()
this.getListGroupData()
},
methods: {
+ // 初始化数据
+ initData() {
+ // 如果是编辑模式,会通过watch detail来设置saveForm
+ if (!this.detail || Object.keys(this.detail).length === 0) {
+ // 创建模式下,确保有初始值
+ this.saveForm = {
+ ...this.saveForm,
+ isAppendPage: 0
+ }
+ }
+ },
// 步骤类型变换
selectStepType() {
// 置空操作
@@ -441,8 +460,24 @@ export default {
}
})
},
+ // 处理操作对象类型切换
+ handleOperateObjectChange() {
+ if (this.saveForm.operateObject === '2') {
+ // 切换到元素定位时,清空元素对象相关的值
+ this.saveForm.operateGroupId = null;
+ this.saveForm.operateElementId = null;
+ this.elementList = [];
+ } else if (this.saveForm.operateObject === '1') {
+ // 切换到元素对象时,如果之前有选择过分组,则重新获取元素列表
+ if (this.saveForm.operateGroupId) {
+ this.getElementListData(this.saveForm.operateGroupId);
+ }
+ }
+ },
// 获取元素列表
getElementListData(groupId) {
+ if (!groupId) return;
+
getElementList({ groupId: groupId }).then(res => {
if (res.code === 200) {
this.elementList = res.rows;
@@ -469,6 +504,31 @@ export default {
},
},
watch: {
+ // 监听操作对象类型的变化
+ 'saveForm.operateObject': {
+ handler(newVal, oldVal) {
+ if (newVal === '1' && this.saveForm.operateGroupId) {
+ // 当切换到元素对象且已有分组ID时,重新获取元素列表
+ this.getElementListData(this.saveForm.operateGroupId);
+ }
+ }
+ },
+ // 监听复选框模型的变化
+ isAppendPageModel: {
+ immediate: true,
+ handler(val) {
+ this.saveForm.isAppendPage = val ? 1 : 0;
+ console.log('isAppendPageModel changed:', val, this.saveForm.isAppendPage);
+ }
+ },
+ // 监听saveForm中isAppendPage的变化来更新复选框状态
+ 'saveForm.isAppendPage': {
+ immediate: true,
+ handler(val) {
+ this.isAppendPageModel = val === 1;
+ console.log('isAppendPage changed:', val, this.isAppendPageModel);
+ }
+ },
detail(newVal, oldVal) {
this.saveForm = newVal
// 如果是元素对象且有元素组ID,获取元素列表
@@ -577,7 +637,7 @@ export default {
const beforeList = this.saveForm.beforeList || [];
const afterList = this.saveForm.afterList || [];
var newList = [...beforeList, ...afterList];
-
+
// 错误处理
var param3 = {
settingType: '3',
@@ -602,12 +662,14 @@ export default {
computed: {
appendPageValue: {
get() {
- // 将数字转换为布尔值用于显示
- return this.saveForm.isAppendPage === 1;
+ return this.saveForm && typeof this.saveForm.isAppendPage !== 'undefined' ? this.saveForm.isAppendPage === 1 : false;
},
set(value) {
- // 将布尔值转换为数字存储
+ if (!this.saveForm) {
+ this.saveForm = {};
+ }
this.saveForm.isAppendPage = value ? 1 : 0;
+ console.log('appendPageValue changed:', value, this.saveForm.isAppendPage);
}
}
},