|
|
@@ -315,10 +315,11 @@ export default {
|
|
|
});
|
|
|
},
|
|
|
/** 查询设备类型下拉树结构 */
|
|
|
- getTreeselect() {
|
|
|
+ getTreeselect(id) {
|
|
|
const data={
|
|
|
current: 1,
|
|
|
- size:-1
|
|
|
+ size:-1,
|
|
|
+ id:id
|
|
|
}
|
|
|
listHanrwareType(data).then((response) => {
|
|
|
debugger;
|
|
|
@@ -384,22 +385,42 @@ export default {
|
|
|
this.open = true;
|
|
|
this.title = this.$t('mes.hardwareType.addHardwareType');
|
|
|
},
|
|
|
- /** 修改按钮操作 */
|
|
|
+ /** 修改按钮操作 - 修复版本 */
|
|
|
handleUpdate(row) {
|
|
|
this.reset();
|
|
|
- this.getTreeselect();
|
|
|
- if(row.parentTypeId == "0") {
|
|
|
- this.form.parentTypeId = undefined;
|
|
|
- }
|
|
|
+ this.getTreeselect(row.id);
|
|
|
+
|
|
|
+ // 修复:当父类型选中了自己时,不传递parentTypeId参数
|
|
|
if (row != null) {
|
|
|
- this.form.parentTypeId = row.id;
|
|
|
+ // 如果父类型ID等于当前行ID(选中了自己),设置为undefined
|
|
|
+ if (row.parentTypeId == row.id) {
|
|
|
+ this.form.parentTypeId = row.id;
|
|
|
+ }
|
|
|
+ // 如果父类型ID为"0"或null,也设置为undefined
|
|
|
+ else if (row.parentTypeId == "0" || row.parentTypeId == null || row.parentTypeId == undefined) {
|
|
|
+ this.form.parentTypeId = undefined;
|
|
|
+ }
|
|
|
+ // 其他情况,正常设置父类型ID
|
|
|
+ else {
|
|
|
+ this.form.parentTypeId = row.parentTypeId;
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
getHardwareTypeInfo(row.id).then((response) => {
|
|
|
this.form = response.data;
|
|
|
+
|
|
|
+ // 修复:在获取数据后,再次检查并处理父类型ID
|
|
|
+ // 如果父类型选中了自己,确保设置为undefined
|
|
|
+ if (this.form.parentTypeId == this.form.id) {
|
|
|
+ this.form.parentTypeId = this.form.id;
|
|
|
+ }
|
|
|
+
|
|
|
this.open = true;
|
|
|
this.title = this.$t('mes.hardwareType.editHardwareType');
|
|
|
});
|
|
|
},
|
|
|
+
|
|
|
+
|
|
|
/** 提交按钮 */
|
|
|
submitForm() {
|
|
|
this.$refs["form"].validate((valid) => {
|