fix: edit values

This commit is contained in:
zeinab.ashrafi
2025-04-19 09:51:58 +03:30
parent 2e98810cf0
commit b599301477
3 changed files with 25 additions and 28 deletions
+2 -1
View File
@@ -99,6 +99,7 @@ const ApiService = {
export default ApiService
export { ApiService }
/*
axios.interceptors.request.use(request => {
// console.log("🔵 API Request:", request.method.toUpperCase(), request.url);
// console.log("🔹 Headers:", request.headers);
@@ -117,4 +118,4 @@ axios.interceptors.response.use(response => {
}, error => {
console.error("🔴 API Error:", error.response ? error.response.data : error);
return Promise.reject(error);
});
});*/
+15 -21
View File
@@ -120,33 +120,36 @@ export default {
formData: {
note: "",
labels: [
{
name: ''
}
{name: ''}
]
},
labels: [],
rules: {
required: value => !!value || "Required.",
counter: value =>
!value ||
value.length == 0 ||
value.length >= 5 ||
"Min 5 characters"
counter: value => !value || value.length == 0 || value.length >= 5 || "Min 5 characters"
}
};
},
created() {
this.loadLabels();
if (this.$route.params.cycle) {
this.load(this.$route.params.cycle);
}
this.loadLabels();
},
methods: {
async load(id) {
const result = await ApiService.get(urls.editCycle(id));
if (result && result.status == 200) {
this.formData = result.data.data;
const usedLabels = this.formData.labels.filter(i => i.id );
const existingIds = this.labels.map(i => i.id);
usedLabels.forEach(ui => {
if (!existingIds.includes(ui.id)) {
this.labels.push(ui);
}
});
console.log()
}
},
async loadLabels() {
@@ -158,15 +161,9 @@ export default {
async submitForm() {
let result;
if (this.$route.params.cycle) {
result = await ApiService.put(
urls.updateCycle(this.$route.params.cycle),
this.formData
);
result = await ApiService.put(urls.updateCycle(this.$route.params.cycle), this.formData);
} else {
result = await ApiService.post(
urls.storeCycle,
this.formData
);
result = await ApiService.post(urls.storeCycle, this.formData);
}
if (result && result.status == 200) {
@@ -174,10 +171,7 @@ export default {
}
},
duplicateForm(infoIndex) {
this.formData.labels.push({
name: "",
});
this.formData.labels.push({name: "",});
},
removeForm(infoIndex) {
this.formData.labels.splice(infoIndex, 1);
+8 -6
View File
@@ -104,19 +104,15 @@ export default {
items: [],
rules: {
required: value => !!value || "Required.",
counter: value =>
!value ||
value.length == 0 ||
value.length >= 5 ||
"Min 5 characters"
counter: value => !value || value.length == 0 || value.length >= 5 || "Min 5 characters"
}
};
},
created() {
this.loadItems();
if (this.$route.params.label) {
this.load(this.$route.params.label);
}
this.loadItems();
},
computed: {
lotNumber() {
@@ -138,6 +134,12 @@ export default {
const result = await ApiService.get(urls.editLabel(id));
if (result && result.status == 200) {
this.formData = result.data.data;
const existingIds = this.items.map(i => i.id);
if (!existingIds.includes(this.formData.package_id)) {
this.items.push(this.formData.package);
}
console.log()
}
},
async loadItems() {