This commit is contained in:
2021-01-08 18:35:30 +00:00
parent fede08f639
commit 3ff422e20c
3 changed files with 114 additions and 11 deletions

View File

@@ -3,7 +3,7 @@
<v-row> <v-row>
<template v-if="!readonly"> <template v-if="!readonly">
<v-col cols="12"> <v-col cols="12">
<v-dialog v-model="dlgdate" width="290px"> <v-dialog v-model="dlgdate" width="300px">
<template v-slot:activator="{ on }"> <template v-slot:activator="{ on }">
<v-text-field <v-text-field
v-on="on" v-on="on"

View File

@@ -4,7 +4,7 @@
<v-row> <v-row>
<template v-if="!readonly"> <template v-if="!readonly">
<v-col xs6> <v-col xs6>
<v-dialog v-model="dlgdate" width="290px"> <v-dialog v-model="dlgdate" width="300px">
<template v-slot:activator="{ on }"> <template v-slot:activator="{ on }">
<v-text-field <v-text-field
v-on="on" v-on="on"

View File

@@ -5,6 +5,45 @@
<gz-error :errorBoxMessage="formState.errorBoxMessage"></gz-error> <gz-error :errorBoxMessage="formState.errorBoxMessage"></gz-error>
<v-form ref="form"> <v-form ref="form">
<v-row> <v-row>
<v-col cols="12" sm="6" lg="4" xl="3">
<gz-pick-list
:ayaType="ayaTypes().Customer"
:showEditIcon="true"
:includeInactive="true"
v-model="obj.customerId"
:readonly="true"
:label="$ay.t('Customer')"
ref="customerId"
data-cy="customerId"
></gz-pick-list>
</v-col>
<v-col cols="12" sm="6" lg="4" xl="3">
<!-- {{ priorityColor() }} -->
<v-select
color="purple"
v-model="obj.priority"
:items="selectLists.priorities"
item-text="name"
item-value="id"
:readonly="true"
:label="$ay.t('CustomerServiceRequestPriority')"
ref="priority"
data-cy="priority"
></v-select>
</v-col>
<v-col cols="12" sm="6" lg="4" xl="3">
<v-select
v-model="obj.status"
:items="selectLists.status"
item-text="name"
item-value="id"
:readonly="true"
:label="$ay.t('CustomerServiceRequestStatus')"
ref="status"
data-cy="status"
></v-select>
</v-col>
<!-- ---------------------------------- -->
<v-col cols="12" sm="6" lg="4" xl="3"> <v-col cols="12" sm="6" lg="4" xl="3">
<v-text-field <v-text-field
v-model="obj.name" v-model="obj.name"
@@ -146,6 +185,39 @@
></v-col> ></v-col>
</v-row> </v-row>
</v-form> </v-form>
<v-row justify="center">
<v-dialog v-model="woSelectorDialog" persistent max-width="300px">
<v-card>
<v-card-title>
<span class="headline">{{
$ay.t("CustomerServiceRequestAcceptToExisting")
}}</span>
</v-card-title>
<v-card-text>
<!-- //MIGRATE_OUTSTANDING awaiting workorder pick list, also this should be json variant data -->
<gz-pick-list
:ayaType="ayaTypes().WorkOrder"
:variant="'customerid:' + obj.customerId"
:showEditIcon="false"
v-model="selectedWOId"
:label="$ay.t('WorkOrder')"
></gz-pick-list>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn
color="blue darken-1"
text
@click="woSelectorDialog = false"
>{{ $ay.t("Cancel") }}</v-btn
>
<v-btn color="blue darken-1" text @click="accept(selectedWOId)">{{
$ay.t("OK")
}}</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</v-row>
</div> </div>
<template v-if="!formState.ready"> <template v-if="!formState.ready">
<v-progress-circular <v-progress-circular
@@ -177,7 +249,7 @@ export default {
vm.rights = window.$gz.role.getRights( vm.rights = window.$gz.role.getRights(
window.$gz.type.CustomerServiceRequest window.$gz.type.CustomerServiceRequest
); );
vm.formState.readOnly = !vm.rights.change; vm.formState.readOnly = !vm.rights.change || vm.obj.status != 0;
window.$gz.eventBus.$on("menu-click", clickHandler); window.$gz.eventBus.$on("menu-click", clickHandler);
//id 0 means create a new record don't load one //id 0 means create a new record don't load one
@@ -229,6 +301,12 @@ export default {
data() { data() {
return { return {
formCustomTemplateKey: FORM_CUSTOM_TEMPLATE_KEY, formCustomTemplateKey: FORM_CUSTOM_TEMPLATE_KEY,
selectedWOId: 0,
woSelectorDialog: false,
selectLists: {
status: [],
priorities: []
},
obj: obj:
//IMPORTANT NOTE: Fields that are NON NULLABLE in the schema for the table but *are* hideable **MUST** have a default value set here or else there will be no way to save the record //IMPORTANT NOTE: Fields that are NON NULLABLE in the schema for the table but *are* hideable **MUST** have a default value set here or else there will be no way to save the record
//I.E. Serial, usertype fields, ACTIVE //I.E. Serial, usertype fields, ACTIVE
@@ -322,6 +400,16 @@ export default {
} }
}, },
methods: { methods: {
priorityColor: function() {
switch (this.obj.priority) {
case 1: //asap
return "warning";
case 2: //emergency
return "error";
default:
return "info";
}
},
canSave: function() { canSave: function() {
return this.formState.valid && this.formState.dirty; return this.formState.valid && this.formState.dirty;
}, },
@@ -558,7 +646,8 @@ export default {
}); });
} }
}, },
async accept(toExisting) { async accept(toExistingId) {
console.log("ACCEPT TO WOID: ", toExistingId);
let vm = this; let vm = this;
if (vm.obj.status != 0 || vm.$route.params.recordid == 0) { if (vm.obj.status != 0 || vm.$route.params.recordid == 0) {
return; return;
@@ -568,10 +657,7 @@ export default {
loading: true loading: true
}); });
//get workorder if to existing //get workorder if to existing
let url = API_BASE_URL + "accept/" + vm.$route.params.recordid; let url = API_BASE_URL + "accept/" + vm.$route.params.recordid;
@@ -633,10 +719,10 @@ async function clickHandler(menuItem) {
m.vm.reject(); m.vm.reject();
break; break;
case "acceptexisting": case "acceptexisting":
m.vm.accept(true); m.vm.woSelectorDialog = true;
break; break;
case "acceptnew": case "acceptnew":
m.vm.accept(false); m.vm.accept();
break; break;
case "report": case "report":
if (m.id != null) { if (m.id != null) {
@@ -690,7 +776,7 @@ async function clickHandler(menuItem) {
function generateMenu(vm) { function generateMenu(vm) {
let menuOptions = { let menuOptions = {
isMain: false, isMain: false,
readOnly: vm.formState.readOnly, readOnly: vm.formState.readOnly || vm.obj.status != 0,
icon: "$ayiConciergeBell", icon: "$ayiConciergeBell",
title: "CustomerServiceRequest", title: "CustomerServiceRequest",
helpUrl: "form-svc-csr", helpUrl: "form-svc-csr",
@@ -799,6 +885,7 @@ let JUST_DELETED = false;
async function initForm(vm) { async function initForm(vm) {
await fetchTranslatedText(vm); await fetchTranslatedText(vm);
await window.$gz.formCustomTemplate.get(FORM_CUSTOM_TEMPLATE_KEY); await window.$gz.formCustomTemplate.get(FORM_CUSTOM_TEMPLATE_KEY);
await populateSelectionLists(vm);
} }
////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////
@@ -839,4 +926,20 @@ async function fetchTranslatedText(vm) {
"CustomerServiceRequestCustom16" "CustomerServiceRequestCustom16"
]); ]);
} }
//////////////////////
//
//
async function populateSelectionLists(vm) {
//ensure the pick lists required are pre-fetched
await window.$gz.enums.fetchEnumList("CustomerServiceRequestStatus");
vm.selectLists.status = window.$gz.enums.getSelectionList(
"CustomerServiceRequestStatus"
);
await window.$gz.enums.fetchEnumList("CustomerServiceRequestPriority");
vm.selectLists.priorities = window.$gz.enums.getSelectionList(
"CustomerServiceRequestPriority"
);
}
</script> </script>