新增属性bug修复

This commit is contained in:
hongchao 2024-12-16 12:23:53 +08:00
parent 6e5d37ec91
commit ae6f19e332
1 changed files with 43 additions and 31 deletions

View File

@ -623,6 +623,7 @@
" "
> >
<el-button <el-button
v-if="visiableAttr"
class="primary-lease" class="primary-lease"
type="primary" type="primary"
@click="addPartItem" @click="addPartItem"
@ -667,8 +668,8 @@
<el-col :span="8"> <el-col :span="8">
<el-form-item label="是否必填" prop="mustHave"> <el-form-item label="是否必填" prop="mustHave">
<el-radio-group v-model="item.mustHave"> <el-radio-group v-model="item.mustHave">
<el-radio label=1></el-radio> <el-radio label="1"></el-radio>
<el-radio label=0></el-radio> <el-radio label="0"></el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
</el-col> </el-col>
@ -973,7 +974,9 @@ export default {
editTypeIds: [], editTypeIds: [],
batchEdit: true, batchEdit: true,
maTypeProperties: [{'propertyName':'','mustHave': null}], maTypeProperties: [{'propertyName':'','mustHave': "0"}],
visiableAttr:false,
allPass:true,
}; };
}, },
watch: { watch: {
@ -1001,7 +1004,7 @@ export default {
// }) // })
// }, // },
/** 查询新增页面-上级类型下拉树结构 */ /** 查询新增页面-上级类型下拉树结构 */
getTreeData() { async getTreeData() {
getMaTypeList().then((response) => { getMaTypeList().then((response) => {
this.treeOptions = [ this.treeOptions = [
{ {
@ -1276,6 +1279,7 @@ export default {
/* 树节点增加 */ /* 树节点增加 */
appendTreeNode(data) { appendTreeNode(data) {
this.visiableAttr = false;
this.maTypeProperties = []; this.maTypeProperties = [];
if (data.level === 3) { if (data.level === 3) {
this.reset(); this.reset();
@ -1306,18 +1310,23 @@ export default {
.catch(() => {}); .catch(() => {});
}, },
/* 树节点修改 */ /* 树节点修改 */
editTreeNode(data) { async editTreeNode(data) {
console.log(data, "修改"); await this.getTreeData()
if(data.level!=2){ if(data.level!=2){
this.visiableAttr = false;
this.maTypeProperties= [] this.maTypeProperties= []
Object.assign(this.addFormParams, data); Object.assign(this.addFormParams, data);
this.addTitle = "修改"; this.addTitle = "修改";
this.addFormParams.typeName = data.label; this.addFormParams.typeName = data.label;
this.addTitleVisible = true; this.addTitleVisible = true;
}else{ }else{
this.maTypeProperties= [{'propertyName':'','mustHave':null}] this.maTypeProperties= []
if(data.maTypeProperties!=null){ this.visiableAttr = true;
if(data.maTypeProperties!=null && data.maTypeProperties.length>0){
console.log('1111111',data.maTypeProperties)
this.maTypeProperties = data.maTypeProperties this.maTypeProperties = data.maTypeProperties
}else{
this.maTypeProperties= [{'propertyName':'','mustHave':"0"}]
} }
Object.assign(this.addFormParams, data); Object.assign(this.addFormParams, data);
this.addTitle = "修改"; this.addTitle = "修改";
@ -1339,37 +1348,40 @@ export default {
maTypeProperties:this.maTypeProperties, maTypeProperties:this.maTypeProperties,
}; };
this.$refs["addFormParamsRef"].validate( (valid) => { this.$refs["addFormParamsRef"].validate( async(valid) => {
if (valid) { if (valid) {
this.$refs["maTypeRef"].forEach((formRef)=>{ await this.$refs["maTypeRef"].forEach((formRef)=>{
formRef.validate(async(validTemp)=>{ formRef.validate((validTemp)=>{
if(validTemp){ if(!validTemp){
if (this.addTitle === "新增") { this.allPass = false;
const res = await addMaType(addParams);
if (res.code === 200) {
this.$message.success("新增成功!");
this.addTitleVisible = false;
this.getTreeData();
}
} else {
const res = await updateMaType(editParams);
if (res.code === 200) {
this.$message.success("修改成功!");
this.addTitleVisible = false;
this.getTreeData();
}
this.maTypeProperties = [];
}
} }
}) })
}) })
if(this.allPass==true){
if (this.addTitle === "新增") {
const res = await addMaType(addParams);
if (res.code === 200) {
this.$message.success("新增成功!");
this.addTitleVisible = false;
this.getTreeData();
}
} else {
const res = await updateMaType(editParams);
if (res.code === 200) {
this.$message.success("修改成功!");
this.addTitleVisible = false;
this.getTreeData();
}
this.maTypeProperties = [];
}
}
} }
}); });
}, },
/* 取消 */ /* 取消 */
onCancel() { onCancel() {
this.addTitleVisible = false; this.addTitleVisible = false;
this.maTypeProperties = [''] this.maTypeProperties = []
}, },
getParentName(list, id) { getParentName(list, id) {
try { try {
@ -1442,7 +1454,7 @@ export default {
// //
addPartItem() { addPartItem() {
this.maTypeProperties.push({'propertyName':'','mustHave': null}); this.maTypeProperties.push({'propertyName':'','mustHave': "0"});
}, },
removePartItem(index) { removePartItem(index) {
if (this.maTypeProperties.length > 1) { if (this.maTypeProperties.length > 1) {