storage url o'zgartirildi

This commit is contained in:
2026-04-28 15:02:06 +05:00
parent 3aa4601229
commit bb733d14c1
37 changed files with 282 additions and 407 deletions

View File

@@ -137,168 +137,67 @@ export default {
subCategories: [],
category: null,
subCategory: null,
currentParentId: null,
};
},
methods: {
async SendForm() {
const formData = new FormData();
for (var i = 0; i < this.categories.length; i++) {
formData.append(
"categories[" + i + "][id]",
this.categories[i].id
);
formData.append(
"categories[" + i + "][position]",
this.categories[i].position
);
formData.append(
"categories[" + i + "][parent_id]",
this.categories[i].parent_id
);
if (this.categories[i].children.length > 0) {
for (
var c = 0;
c < this.categories[i].children.length;
c++
) {
formData.append(
"categories[" + i + "][children][" + c + "][id]",
this.categories[i].children[c].id
);
formData.append(
"categories[" +
i +
"][children][" +
c +
"][position]",
this.categories[i].children[c].position
);
formData.append(
"categories[" +
i +
"][children][" +
c +
"][parent_id]",
this.categories[i].children[c].parent_id
);
if (
this.categories[i].children[c].children.length > 0
) {
for (
var w = 0;
w <
this.categories[i].children[c].children.length;
w++
) {
formData.append(
"categories[" +
i +
"][children][" +
c +
"][children][" +
w +
"][id]",
this.categories[i].children[c].children[w]
.id
);
formData.append(
"categories[" +
i +
"][children][" +
c +
"][children][" +
w +
"][position]",
this.categories[i].children[c].children[w]
.position
);
formData.append(
"categories[" +
i +
"][children][" +
c +
"][children][" +
w +
"][parent_id]",
this.categories[i].children[c].children[w]
.parent_id
);
}
}
}
}
}
const { data } = await axios.post(
"/dashboard/categories/position",
formData
{
categories: this.normalizeTree(this.categoriesData, null, 0),
}
);
if (data.status) {
// window.location.href = "/dashboard/categories";
window.location.reload();
}
},
Change() {
for (var i = 0; i < this.categories.length; i++) {
var num = i + 1;
this.normalizeTree(this.categoriesData, null, 0);
},
this.categories[i].position = num;
this.categories[i].droppable = true;
normalizeTree(categories, parentId, level) {
return categories.map((category, index) => {
category.position = index + 1;
category.parent_id = parentId;
category.droppable = level < 2;
if (this.categories[i].children.length > 0) {
for (
var c = 0;
c < this.categories[i].children.length;
c++
) {
var numm = c + 1;
this.categories[i].children[c].position = numm;
this.categories[i].children[c].parent_id =
this.categories[i].id;
this.categories[i].children[c].droppable = true;
const children = Array.isArray(category.children)
? this.normalizeTree(category.children, category.id, level + 1)
: [];
if (
this.categories[i].children[c].children.length > 0
) {
for (
var w = 0;
w <
this.categories[i].children[c].children.length;
w++
) {
var nummm = w + 1;
this.categories[i].children[c].children[
w
].position = nummm;
this.categories[i].children[c].children[
w
].parent_id = this.categories[i].children[c].id;
this.categories[i].children[c].children[
w
].droppable = false;
}
}
}
}
}
return {
id: category.id,
position: category.position,
parent_id: category.parent_id,
children,
};
});
},
handleMainCategory() {
if (this.category) {
this.categories = this.category.children;
this.subCategories = this.category.children;
this.currentParentId = this.category.id;
} else {
this.categories = this.categoriesData;
this.subCategories = null;
this.currentParentId = null;
}
},
handleSubCategory() {
if (this.subCategory) this.categories = this.subCategory.children;
else this.categories = this.category.children;
if (this.subCategory) {
this.categories = this.subCategory.children;
this.currentParentId = this.subCategory.id;
} else {
this.categories = this.category.children;
this.currentParentId = this.category ? this.category.id : null;
}
},
},
};