storage url o'zgartirildi
This commit is contained in:
@@ -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;
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -111,7 +111,6 @@
|
||||
type="file"
|
||||
name="image"
|
||||
@change="ImageFile($event)"
|
||||
onchange="PreviewImage();"
|
||||
/>
|
||||
<label
|
||||
class="custom-file-label"
|
||||
@@ -126,6 +125,7 @@
|
||||
<div class="text-center">
|
||||
<img
|
||||
id="uploadPreview"
|
||||
:src="category.imagePreview"
|
||||
style="
|
||||
width: 300px;
|
||||
height: auto;
|
||||
@@ -707,6 +707,7 @@ export default {
|
||||
},
|
||||
|
||||
image: null,
|
||||
imagePreview: null,
|
||||
},
|
||||
|
||||
char: [],
|
||||
@@ -798,6 +799,12 @@ export default {
|
||||
|
||||
ImageFile(event) {
|
||||
this.category.image = event.target.files[0];
|
||||
|
||||
if (this.category.image) {
|
||||
this.category.imagePreview = URL.createObjectURL(
|
||||
this.category.image
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
addChar() {
|
||||
|
||||
@@ -111,7 +111,6 @@
|
||||
type="file"
|
||||
name="image"
|
||||
@change="ImageFile($event)"
|
||||
onchange="PreviewImage();"
|
||||
/>
|
||||
<label
|
||||
class="custom-file-label"
|
||||
@@ -811,6 +810,10 @@ export default {
|
||||
|
||||
ImageFile(event) {
|
||||
this.file = event.target.files[0];
|
||||
|
||||
if (this.file) {
|
||||
this.category.image_url = URL.createObjectURL(this.file);
|
||||
}
|
||||
},
|
||||
|
||||
addChar() {
|
||||
|
||||
Reference in New Issue
Block a user