Commit 37c48cb5 by 无尘

fix: 修改配置

parent 5a272b81
......@@ -74,7 +74,10 @@ export default {
},
data() {
return {
trData: {}
trData: {},
tempArr: [],
newItemData: {},
allDataList: []
};
},
methods: {
......@@ -88,12 +91,47 @@ export default {
that.$delete(that.itemData.properties, oldKey);
} */
},
async handleDisable(obj, flag, parentKey) {
const that = this;
for (let k in obj) {
if (obj[k].currentKey == parentKey) {
obj[k].isRootKeyFlag = flag ? true : false;
}
if (obj[k].type == 'object' && Object.keys(obj[k].properties).length) {
await that.handleDisable(obj[k].properties, flag, parentKey);
}
if (obj[k].type == 'array' && Object.keys(obj[k].items.properties).length) {
await that.handleDisable(obj[k].items.properties, flag, parentKey);
}
}
},
/**
* 改变checkbox
*/
/* eslint-disable */
async changeCheck(obj, key) {
const that = this;
// console.log('改变checkbox:', obj, key);
console.log('改变checkbox:', obj, key,that.itemData);
// 查找父级禁用和不禁用
if(obj.backendOriginType == 'body' && obj.level > 2 ) {
if(obj.parentKey == 'bodyRoot') {
that.itemData.isRootKeyFlag = obj.isRootKey ? true : false;
}else {
for( let pk in that.newItemData.properties) {
if(that.newItemData.properties[pk].currentKey == obj.parentKey) {
that.newItemData.properties[pk].isRootKeyFlag = obj.isRootKey ? true : false;
}else {
if(that.newItemData.properties[pk].type == 'object' && Object.keys(that.newItemData.properties[pk].properties).length){
await that.handleDisable(that.newItemData.properties[pk].properties, obj.isRootKey, obj.parentKey)
}
if(that.newItemData.properties[pk].type == 'array' && Object.keys(that.newItemData.properties[pk].items.properties).length){
await that.handleDisable(that.newItemData.properties[pk].items.properties, obj.isRootKey, obj.parentKey)
}
}
}
}
}
// 设置子级禁用和不禁用
if (obj.type == 'object' && Object.keys(obj.properties).length) {
obj.isRootKeyFlag = false;
......@@ -110,17 +148,19 @@ export default {
if (obj.type == 'array' && Object.keys(obj.items.properties).length) {
obj.isRootKeyFlag = false;
for (let key in obj.items.properties) {
obj.items.properties[key].isRootKeyFlag = true;
if (obj.properties[key].type == 'array' && Object.keys(obj.items.properties[key].properties).length) {
obj.items.properties[key].isRootKeyFlag = obj.isRootKey ? true : false;
if (obj.items.properties[key].type == 'object' && Object.keys(obj.items.properties[key].properties).length) {
obj.isRootKey ? await that.checkArrObjData(obj.items.properties[key].properties) : await that.checkArrObjFalse(obj.items.properties[key].properties);
}
if (obj.items.properties[key].type == 'array' && Object.keys(obj.items.properties[key].properties).length) {
obj.isRootKey ? await that.checkArrObjData(obj.items.properties[key].items.properties) : await that.checkArrObjFalse(obj.items.properties[key].items.properties);
}
}
}
that.$forceUpdate();
},
async checkArrObjData(item) {
const that = this;
// console.log(item);
for (let k in item) {
item[k].isRootKeyFlag = true;
if (item[k].type == 'object' && Object.keys(item[k].properties).length) {
......@@ -146,18 +186,76 @@ export default {
await that.checkArrObjData(item[k].items.properties);
}
}
},
/**
* 处理
*/
async handleToArr() {
const that = this;
if(that.itemData.level == 1 && that.itemData.properties.hasOwnProperty('bodyRoot')) {
let arrObj = [];
let newItemData = JSON.parse(JSON.stringify(that.itemData));
that.newItemData = JSON.parse(JSON.stringify(that.itemData));
if(Object.keys(newItemData.properties.bodyRoot.properties).length) {
for(let key in newItemData.properties.bodyRoot.properties) {
let innerArr = [];
innerArr.push(newItemData.properties.bodyRoot);
let returnArr = await that.handleLoop(newItemData.properties.bodyRoot.properties[key], innerArr);
returnArr.forEach(ele => {
if (Array.isArray(ele)) {
arrObj.push(ele);
}
})
if(Array.isArray(returnArr[0])) {
continue;
}
arrObj.push(returnArr);
}
that.allDataList = arrObj;
}
}
},
async handleLoop(item, innerArr) {
const that = this;
innerArr.push(item);
if(item.type != 'object' && item.type != 'array'){
return innerArr;
}
let arrRet = [];
if(item.type == 'object' && Object.keys(item.properties).length) {
for(let key in item.properties) {
let mid = JSON.parse(JSON.stringify(innerArr));
let arrMid = await that.handleLoop(item.properties[key], mid);
arrRet.push(arrMid);
}
}
if(item.type == 'array' && Object.keys(item.items.properties).length) {
for(let key in item.items.properties) {
let mid = JSON.parse(JSON.stringify(innerArr));
let arrMid = await that.handleLoop(item.items.properties[key], mid);
arrRet.push(arrMid);
}
}
return arrRet;
}
},
watch: {
itemData: function(newData, oldData) {
const that = this;
that.trData = JSON.parse(JSON.stringify(newData));
that.handleToArr();
}
},
mounted() {
const that = this;
that.trData = JSON.parse(JSON.stringify(that.itemData));
}
that.handleToArr();
},
beforeDestroy() {
this.tempArr = [];
},
};
</script>
<style lang="less" scoped>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment