This commit is contained in:
@@ -27,7 +27,9 @@
|
|||||||
"
|
"
|
||||||
@input="fieldValueChanged('purchaseOrderNextSerial')"
|
@input="fieldValueChanged('purchaseOrderNextSerial')"
|
||||||
append-outer-icon="$ayiSave"
|
append-outer-icon="$ayiSave"
|
||||||
@click:append-outer="set(ayaTypes.PurchaseOrder)"
|
@click:append-outer="
|
||||||
|
submit(ayaTypes().PurchaseOrder, obj.purchaseOrderNextSerial)
|
||||||
|
"
|
||||||
></v-text-field>
|
></v-text-field>
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
@@ -155,40 +157,20 @@ export default {
|
|||||||
window.$gz.errorHandler.handleFormError(error, vm);
|
window.$gz.errorHandler.handleFormError(error, vm);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async submit() {
|
async submit(aType, nextNumber) {
|
||||||
let vm = this;
|
let vm = this;
|
||||||
let url = API_BASE_URL;
|
let url = `${API_BASE_URL}${aType}/${nextNumber}`;
|
||||||
//clear any errors vm might be around from previous submit
|
//clear any errors vm might be around from previous submit
|
||||||
window.$gz.form.deleteAllErrorBoxErrors(vm);
|
window.$gz.form.deleteAllErrorBoxErrors(vm);
|
||||||
|
|
||||||
//Create template data object here....
|
|
||||||
//Note that server expects to see a string array of json template, not actual json
|
|
||||||
let newObj = {
|
|
||||||
id: vm.templateId,
|
|
||||||
template: "[]"
|
|
||||||
};
|
|
||||||
//temporary array to hold template for later stringification
|
|
||||||
let temp = [];
|
|
||||||
for (let i = 0; i < vm.workingArray.length; i++) {
|
|
||||||
let ti = vm.workingArray[i];
|
|
||||||
if (ti.include == true) {
|
|
||||||
temp.push({
|
|
||||||
fld: ti.key
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
//now set the template as a json string
|
let res = await window.$gz.api.put(url);
|
||||||
newObj.template = JSON.stringify(temp);
|
|
||||||
let res = await window.$gz.api.upsert(url, newObj);
|
|
||||||
|
|
||||||
vm.formState.loading = false;
|
vm.formState.loading = false;
|
||||||
if (res.error) {
|
if (res.error) {
|
||||||
vm.formState.serverError = res.error;
|
vm.formState.serverError = res.error;
|
||||||
window.$gz.form.setErrorBoxErrors(vm);
|
window.$gz.form.setErrorBoxErrors(vm);
|
||||||
} else {
|
} else {
|
||||||
//It's a 204 no data response so no error means it's ok
|
|
||||||
//form is now clean
|
|
||||||
window.$gz.form.setFormState({
|
window.$gz.form.setFormState({
|
||||||
vm: vm,
|
vm: vm,
|
||||||
dirty: false
|
dirty: false
|
||||||
|
|||||||
Reference in New Issue
Block a user