This commit is contained in:
2021-02-24 15:50:58 +00:00
parent c0a0157755
commit ea8ad27f31
2 changed files with 46 additions and 42 deletions

View File

@@ -28,6 +28,7 @@
<gz-pick-list
:aya-type="ayaTypes().Vendor"
:show-edit-icon="true"
:allow-no-selection="false"
v-model="obj.vendorId"
:readonly="formState.readOnly"
:label="$ay.t('Vendor')"
@@ -35,6 +36,7 @@
data-cy="vendorId"
:error-messages="form().serverErrors(this, 'vendorId')"
@input="fieldValueChanged('vendorId')"
:rules="[form().required(this, 'vendorId')]"
></gz-pick-list>
</v-col>
<v-col
@@ -758,7 +760,7 @@ export default {
{
id: 0,
concurrency: 0,
serial: null,
serial: 0,
notes: null,
wiki: null,
customFields: null,
@@ -769,7 +771,7 @@ export default {
vendorId: null,
orderedDate: window.$gz.locale.nowUTC8601String(),
expectedReceiveDate: null,
status: null,
status: 1,
projectId: null,
text1: null,
text2: null,
@@ -1138,25 +1140,29 @@ export default {
let url = API_BASE_URL; // + vm.$route.params.recordid;
//clear any errors vm might be around from previous submit
window.$gz.form.deleteAllErrorBoxErrors(vm);
console.log("UPSERT");
let res = await window.$gz.api.upsert(url, vm.obj);
if (res.error) {
vm.formState.serverError = res.error;
window.$gz.form.setErrorBoxErrors(vm);
} else {
//POST or PUT - whole new object returned
vm.obj = res.data;
//Change URL to new record
//NOTE: will not cause a page re-render, almost nothing does unless forced with a KEY property or using router.GO()
// this.$router.push({
// name: "inv-purchase-order",
// params: {
// recordid: res.data.id,
// obj: res.data // Pass data object to new form
// }
// });
//POST or PUT - whole new object returned which is a little different than other objects
//so if it's new then need to navigate to it to update url with id
if (vm.$route.params.recordid != 0) {
console.log("STAY IN PLACE");
//update of existing record
vm.obj = res.data;
} else {
console.log("NAV TO NEW");
this.$router.push({
name: "inv-purchase-order",
params: {
recordid: res.data.id,
obj: res.data // Pass data object to new form
}
});
}
//Update the form status
window.$gz.form.setFormState({