re-factor / cleanup
This commit is contained in:
@@ -16,12 +16,12 @@
|
||||
xl="3"
|
||||
>
|
||||
<gz-pick-list
|
||||
ref="customerId"
|
||||
v-model="obj.customerId"
|
||||
:aya-type="ayaTypes().Customer"
|
||||
show-edit-icon
|
||||
:include-inactive="true"
|
||||
v-model="obj.customerId"
|
||||
:label="$ay.t('Customer')"
|
||||
ref="customerId"
|
||||
data-cy="customerId"
|
||||
variant="ho"
|
||||
template="[{'fld':'customername'}]"
|
||||
@@ -30,14 +30,14 @@
|
||||
</v-col>
|
||||
<v-col cols="12" sm="6" lg="4" xl="3">
|
||||
<v-select
|
||||
ref="priority"
|
||||
v-model="obj.priority"
|
||||
:color="priorityColor()"
|
||||
:item-color="priorityColor()"
|
||||
v-model="obj.priority"
|
||||
:items="selectLists.priorities"
|
||||
item-text="name"
|
||||
item-value="id"
|
||||
:label="$ay.t('CustomerServiceRequestPriority')"
|
||||
ref="priority"
|
||||
data-cy="priority"
|
||||
append-icon=""
|
||||
@input="fieldValueChanged('priority')"
|
||||
@@ -61,10 +61,10 @@
|
||||
xl="3"
|
||||
>
|
||||
<v-text-field
|
||||
ref="customerReferenceNumber"
|
||||
v-model="obj.customerReferenceNumber"
|
||||
:readonly="formState.readOnly"
|
||||
:label="$ay.t('CustomerServiceRequestCustomerReferenceNumber')"
|
||||
ref="customerReferenceNumber"
|
||||
data-cy="customerReferenceNumber"
|
||||
:error-messages="
|
||||
form().serverErrors(this, 'customerReferenceNumber')
|
||||
@@ -81,6 +81,8 @@
|
||||
xl="3"
|
||||
>
|
||||
<gz-pick-list
|
||||
ref="unitId"
|
||||
v-model="obj.unitId"
|
||||
:aya-type="ayaTypes().Unit"
|
||||
:variant="unitListVariant()"
|
||||
template="[
|
||||
@@ -88,10 +90,8 @@
|
||||
{ fld: 'UnitModelName' },
|
||||
{ fld: 'UnitModelVendorID' }
|
||||
]"
|
||||
v-model="obj.unitId"
|
||||
:readonly="formState.readOnly"
|
||||
:label="$ay.t('CustomerServiceRequestItemUnitID')"
|
||||
ref="unitId"
|
||||
data-cy="unitId"
|
||||
:error-messages="form().serverErrors(this, 'unitId')"
|
||||
@input="fieldValueChanged('unitId')"
|
||||
@@ -111,12 +111,12 @@
|
||||
|
||||
<v-col cols="12">
|
||||
<v-text-field
|
||||
ref="name"
|
||||
v-model="obj.name"
|
||||
:readonly="formState.readOnly"
|
||||
:label="$ay.t('CustomerServiceRequestTitle')"
|
||||
:rules="[form().required(this, 'name')]"
|
||||
:error-messages="form().serverErrors(this, 'name')"
|
||||
ref="name"
|
||||
data-cy="name"
|
||||
@input="fieldValueChanged('name')"
|
||||
></v-text-field>
|
||||
@@ -127,35 +127,35 @@
|
||||
cols="12"
|
||||
>
|
||||
<v-textarea
|
||||
ref="notes"
|
||||
v-model="obj.notes"
|
||||
:readonly="formState.readOnly"
|
||||
:label="$ay.t('CustomerServiceRequestDetails')"
|
||||
:error-messages="form().serverErrors(this, 'notes')"
|
||||
ref="notes"
|
||||
data-cy="notes"
|
||||
@input="fieldValueChanged('notes')"
|
||||
auto-grow
|
||||
@input="fieldValueChanged('notes')"
|
||||
></v-textarea>
|
||||
</v-col>
|
||||
|
||||
<v-col cols="12" sm="6" lg="4" xl="3">
|
||||
<gz-date-picker
|
||||
:label="$ay.t('Created')"
|
||||
v-model="obj.dateRequested"
|
||||
readonly
|
||||
ref="dateRequested"
|
||||
v-model="obj.dateRequested"
|
||||
:label="$ay.t('Created')"
|
||||
readonly
|
||||
data-cy="dateRequested"
|
||||
></gz-date-picker>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="6" lg="4" xl="3">
|
||||
<v-select
|
||||
ref="status"
|
||||
v-model="obj.status"
|
||||
:items="selectLists.status"
|
||||
item-text="name"
|
||||
item-value="id"
|
||||
readonly
|
||||
:label="$ay.t('CustomerServiceRequestStatus')"
|
||||
ref="status"
|
||||
data-cy="status"
|
||||
append-icon=""
|
||||
></v-select>
|
||||
@@ -167,7 +167,7 @@
|
||||
<!-- ################################################################################-->
|
||||
<template>
|
||||
<v-row justify="center">
|
||||
<v-dialog max-width="1600px" v-model="addUnitDialog">
|
||||
<v-dialog v-model="addUnitDialog" max-width="1600px">
|
||||
<v-card>
|
||||
<v-card-title> </v-card-title>
|
||||
<v-card-text>
|
||||
@@ -193,22 +193,22 @@
|
||||
</v-col> -->
|
||||
<v-col cols="12" sm="6" lg="4" xl="3">
|
||||
<v-text-field
|
||||
ref="serial"
|
||||
v-model="unitObj.serial"
|
||||
:readonly="formState.readOnly"
|
||||
:label="$ay.t('UnitSerial')"
|
||||
:rules="[form().required(this, 'serial')]"
|
||||
:error-messages="form().serverErrors(this, 'serial')"
|
||||
ref="serial"
|
||||
data-cy="serial"
|
||||
@input="fieldValueChanged('serial')"
|
||||
></v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="6" lg="4" xl="3">
|
||||
<v-text-field
|
||||
ref="description"
|
||||
v-model="unitObj.description"
|
||||
:readonly="formState.readOnly"
|
||||
:label="$ay.t('UnitDescription')"
|
||||
ref="description"
|
||||
data-cy="description"
|
||||
:error-messages="form().serverErrors(this, 'description')"
|
||||
></v-text-field>
|
||||
@@ -216,13 +216,13 @@
|
||||
|
||||
<v-col cols="12" sm="6" lg="4" xl="3">
|
||||
<gz-pick-list
|
||||
ref="unitModelId"
|
||||
v-model="unitObj.unitModelId"
|
||||
:aya-type="ayaTypes().UnitModel"
|
||||
template="[{ fld: 'UnitModelName' },{ fld: 'UnitModelVendorID' }]"
|
||||
show-edit-icon
|
||||
v-model="unitObj.unitModelId"
|
||||
:readonly="formState.readOnly"
|
||||
:label="$ay.t('UnitModel')"
|
||||
ref="unitModelId"
|
||||
data-cy="unitModelId"
|
||||
:error-messages="form().serverErrors(this, 'unitModelId')"
|
||||
></gz-pick-list>
|
||||
@@ -230,7 +230,7 @@
|
||||
</v-row>
|
||||
</v-card-text>
|
||||
<v-card-actions>
|
||||
<v-btn text @click="addUnitDialog = false" color="primary">{{
|
||||
<v-btn text color="primary" @click="addUnitDialog = false">{{
|
||||
$ay.t("Cancel")
|
||||
}}</v-btn>
|
||||
<v-spacer></v-spacer>
|
||||
@@ -238,9 +238,9 @@
|
||||
:disabled="unitObj.serial == null"
|
||||
color="primary"
|
||||
text
|
||||
@click="addUnit()"
|
||||
class="ml-4"
|
||||
data-cy="csrUnitAdd"
|
||||
@click="addUnit()"
|
||||
>{{ $ay.t("Add") }}</v-btn
|
||||
>
|
||||
</v-card-actions>
|
||||
@@ -259,70 +259,6 @@ const FORM_KEY = "customer-csr-edit";
|
||||
const API_BASE_URL = "csr/";
|
||||
const FORM_CUSTOM_TEMPLATE_KEY = "CustomerServiceRequest";
|
||||
export default {
|
||||
async created() {
|
||||
const vm = this;
|
||||
try {
|
||||
await initForm(vm);
|
||||
|
||||
vm.rights = window.$gz.role.getRights(
|
||||
window.$gz.type.CustomerServiceRequest
|
||||
);
|
||||
vm.formState.readOnly = !vm.rights.change || vm.obj.status != 0;
|
||||
window.$gz.eventBus.$on("menu-click", clickHandler);
|
||||
|
||||
//id 0 means create or duplicate to new
|
||||
if (vm.$route.params.recordid != 0) {
|
||||
//is there already an obj from a prior operation?
|
||||
if (this.$route.params.obj) {
|
||||
//yes, no need to fetch it
|
||||
this.obj = this.$route.params.obj;
|
||||
window.$gz.form.setFormState({
|
||||
vm: vm,
|
||||
loading: false
|
||||
});
|
||||
} else {
|
||||
await vm.getDataFromApi(vm.$route.params.recordid);
|
||||
}
|
||||
} else {
|
||||
//NEW
|
||||
//
|
||||
if (this.$store.state.userType == 3) {
|
||||
//Customer specific user
|
||||
this.obj.customerId = this.$store.state.customerRights.entityId;
|
||||
this.unitObj.customerId = this.$store.state.customerRights.entityId;
|
||||
}
|
||||
window.$gz.form.setFormState({
|
||||
vm: vm,
|
||||
loading: false
|
||||
});
|
||||
}
|
||||
window.$gz.form.setFormState({
|
||||
vm: vm,
|
||||
dirty: false,
|
||||
valid: true
|
||||
});
|
||||
|
||||
generateMenu(vm);
|
||||
} catch (error) {
|
||||
window.$gz.errorHandler.handleFormError(error, vm);
|
||||
} finally {
|
||||
vm.formState.ready = true;
|
||||
}
|
||||
},
|
||||
async beforeRouteLeave(to, from, next) {
|
||||
if (!this.formState.dirty || JUST_DELETED) {
|
||||
next();
|
||||
return;
|
||||
}
|
||||
if ((await window.$gz.dialog.confirmLeaveUnsaved()) === true) {
|
||||
next();
|
||||
} else {
|
||||
next(false);
|
||||
}
|
||||
},
|
||||
beforeDestroy() {
|
||||
window.$gz.eventBus.$off("menu-click", clickHandler);
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
formCustomTemplateKey: FORM_CUSTOM_TEMPLATE_KEY,
|
||||
@@ -399,6 +335,70 @@ export default {
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
async created() {
|
||||
const vm = this;
|
||||
try {
|
||||
await initForm(vm);
|
||||
|
||||
vm.rights = window.$gz.role.getRights(
|
||||
window.$gz.type.CustomerServiceRequest
|
||||
);
|
||||
vm.formState.readOnly = !vm.rights.change || vm.obj.status != 0;
|
||||
window.$gz.eventBus.$on("menu-click", clickHandler);
|
||||
|
||||
//id 0 means create or duplicate to new
|
||||
if (vm.$route.params.recordid != 0) {
|
||||
//is there already an obj from a prior operation?
|
||||
if (this.$route.params.obj) {
|
||||
//yes, no need to fetch it
|
||||
this.obj = this.$route.params.obj;
|
||||
window.$gz.form.setFormState({
|
||||
vm: vm,
|
||||
loading: false
|
||||
});
|
||||
} else {
|
||||
await vm.getDataFromApi(vm.$route.params.recordid);
|
||||
}
|
||||
} else {
|
||||
//NEW
|
||||
//
|
||||
if (this.$store.state.userType == 3) {
|
||||
//Customer specific user
|
||||
this.obj.customerId = this.$store.state.customerRights.entityId;
|
||||
this.unitObj.customerId = this.$store.state.customerRights.entityId;
|
||||
}
|
||||
window.$gz.form.setFormState({
|
||||
vm: vm,
|
||||
loading: false
|
||||
});
|
||||
}
|
||||
window.$gz.form.setFormState({
|
||||
vm: vm,
|
||||
dirty: false,
|
||||
valid: true
|
||||
});
|
||||
|
||||
generateMenu(vm);
|
||||
} catch (error) {
|
||||
window.$gz.errorHandler.handleFormError(error, vm);
|
||||
} finally {
|
||||
vm.formState.ready = true;
|
||||
}
|
||||
},
|
||||
async beforeRouteLeave(to, from, next) {
|
||||
if (!this.formState.dirty || JUST_DELETED) {
|
||||
next();
|
||||
return;
|
||||
}
|
||||
if ((await window.$gz.dialog.confirmLeaveUnsaved()) === true) {
|
||||
next();
|
||||
} else {
|
||||
next(false);
|
||||
}
|
||||
},
|
||||
beforeDestroy() {
|
||||
window.$gz.eventBus.$off("menu-click", clickHandler);
|
||||
},
|
||||
methods: {
|
||||
showAddUnitDialog: function() {
|
||||
this.unitObj.customerId = this.obj.customerId;
|
||||
|
||||
Reference in New Issue
Block a user