This commit is contained in:
2021-03-22 20:33:34 +00:00
parent cd41eeb39c
commit c3114de056

View File

@@ -27,7 +27,9 @@
"
@input="fieldValueChanged('purchaseOrderNextSerial')"
append-outer-icon="$ayiSave"
@click:append-outer="set(ayaTypes.PurchaseOrder)"
@click:append-outer="
submit(ayaTypes().PurchaseOrder, obj.purchaseOrderNextSerial)
"
></v-text-field>
</v-col>
</v-row>
@@ -155,40 +157,20 @@ export default {
window.$gz.errorHandler.handleFormError(error, vm);
}
},
async submit() {
async submit(aType, nextNumber) {
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
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 {
//now set the template as a json string
newObj.template = JSON.stringify(temp);
let res = await window.$gz.api.upsert(url, newObj);
let res = await window.$gz.api.put(url);
vm.formState.loading = false;
if (res.error) {
vm.formState.serverError = res.error;
window.$gz.form.setErrorBoxErrors(vm);
} else {
//It's a 204 no data response so no error means it's ok
//form is now clean
window.$gz.form.setFormState({
vm: vm,
dirty: false