This commit is contained in:
@@ -1,21 +1,295 @@
|
||||
<template>
|
||||
<UnderConstruction data-cy="underconstruction" />
|
||||
<div>
|
||||
<v-row justify="center">
|
||||
<v-dialog
|
||||
@keydown.esc="openDialog = false"
|
||||
@keydown.enter="openQuote()"
|
||||
v-model="openDialog"
|
||||
persistent
|
||||
max-width="600px"
|
||||
>
|
||||
<v-card>
|
||||
<v-card-title>
|
||||
<span class="text-h5">{{ $ay.t("Open") }}</span>
|
||||
</v-card-title>
|
||||
<v-card-text>
|
||||
<v-text-field
|
||||
v-model="openQuoteNumber"
|
||||
:label="$ay.t('Quote')"
|
||||
autofocus
|
||||
required
|
||||
type="number"
|
||||
></v-text-field>
|
||||
</v-card-text>
|
||||
<v-card-actions>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn color="blue darken-1" text @click="openDialog = false">{{
|
||||
$ay.t("Cancel")
|
||||
}}</v-btn>
|
||||
<v-btn
|
||||
color="blue darken-1"
|
||||
text
|
||||
@click="openQuote()"
|
||||
:disabled="!openQuoteNumber"
|
||||
>{{ $ay.t("OK") }}</v-btn
|
||||
>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</v-row>
|
||||
<gz-report-selector ref="reportSelector"></gz-report-selector>
|
||||
<gz-extensions
|
||||
:aya-type="aType"
|
||||
:selected-items="selectedItems"
|
||||
ref="extensions"
|
||||
>
|
||||
</gz-extensions>
|
||||
|
||||
<gz-data-table
|
||||
ref="gzdatatable"
|
||||
form-key="quote-list"
|
||||
data-list-key="QuoteDataList"
|
||||
:show-select="rights.read"
|
||||
:reload="reload"
|
||||
@selection-change="handleSelected"
|
||||
data-cy="quotesTable"
|
||||
:client-criteria="clientCriteria"
|
||||
:pre-filter-mode="preFilterMode"
|
||||
@clear-pre-filter="clearPreFilter"
|
||||
>
|
||||
</gz-data-table>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import UnderConstruction from "../components/underconstruction.vue";
|
||||
|
||||
const FORM_KEY = "quote-list";
|
||||
export default {
|
||||
components: {
|
||||
UnderConstruction
|
||||
async created() {
|
||||
this.rights = window.$gz.role.getRights(window.$gz.type.Quote);
|
||||
window.$gz.eventBus.$on("menu-click", clickHandler);
|
||||
await fetchTranslatedText();
|
||||
|
||||
//------ Show all ----
|
||||
//OPTIONAL "Show All" FILTER
|
||||
this.objectId = window.$gz.util.stringToIntOrNull(
|
||||
this.$route.params.objectId
|
||||
);
|
||||
this.aForType = window.$gz.util.stringToIntOrNull(this.$route.params.aType);
|
||||
|
||||
if (this.objectId && this.objectId != 0 && this.aForType) {
|
||||
//OBJECTID,AYATYPE
|
||||
this.clientCriteria = `${this.objectId},${this.aForType}`;
|
||||
|
||||
this.preFilterMode = {
|
||||
icon: window.$gz.util.iconForType(this.aForType),
|
||||
id: this.objectId,
|
||||
ayatype: this.aForType,
|
||||
viz: this.$route.params.name,
|
||||
clearable: true
|
||||
};
|
||||
}
|
||||
//------ /show all ----
|
||||
|
||||
generateMenu(this);
|
||||
},
|
||||
beforeCreate() {
|
||||
window.$gz.eventBus.$emit("menu-change", {
|
||||
isMain: true,
|
||||
icon: "$ayiPencilAlt",
|
||||
title: "QuoteList",
|
||||
helpUrl: "svc-quotes"
|
||||
});
|
||||
beforeDestroy() {
|
||||
window.$gz.eventBus.$off("menu-click", clickHandler);
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
rights: window.$gz.role.defaultRightsObject(),
|
||||
aType: window.$gz.type.Quote,
|
||||
selectedItems: [],
|
||||
reload: false,
|
||||
openDialog: false,
|
||||
openQuoteNumber: null,
|
||||
clientCriteria: undefined,
|
||||
preFilterMode: null,
|
||||
objectId: null,
|
||||
aForType: null,
|
||||
name: null
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
handleSelected(selected) {
|
||||
this.selectedItems = selected;
|
||||
},
|
||||
clearPreFilter() {
|
||||
this.clientCriteria = null;
|
||||
this.preFilterMode = null;
|
||||
this.reload = !this.reload;
|
||||
},
|
||||
|
||||
async openQuote() {
|
||||
if (!this.openQuoteNumber) {
|
||||
return;
|
||||
}
|
||||
//get id from number then push open
|
||||
let res = await window.$gz.api.get(
|
||||
"quote/id-from-number/" + this.openQuoteNumber
|
||||
);
|
||||
if (res.error) {
|
||||
window.$gz.eventBus.$emit(
|
||||
"notify-warning",
|
||||
window.$gz.errorHandler.errorToString(res, this)
|
||||
);
|
||||
return;
|
||||
// throw new Error(window.$gz.errorHandler.errorToString(res, this));
|
||||
}
|
||||
|
||||
this.$router.push({
|
||||
name: "quote-edit",
|
||||
params: { recordid: res.data }
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/////////////////////////////
|
||||
//
|
||||
//
|
||||
async function clickHandler(menuItem) {
|
||||
if (!menuItem) {
|
||||
return;
|
||||
}
|
||||
let m = window.$gz.menu.parseMenuItem(menuItem);
|
||||
if (m.owner == FORM_KEY && !m.disabled) {
|
||||
switch (m.key) {
|
||||
case "new":
|
||||
m.vm.$router.push({
|
||||
name: "quote-edit",
|
||||
params: { recordid: 0 }
|
||||
});
|
||||
break;
|
||||
case "extensions":
|
||||
let res = await m.vm.$refs.extensions.open(
|
||||
m.vm.$refs.gzdatatable.getDataListSelection(window.$gz.type.Quote)
|
||||
);
|
||||
if (res && res.refresh == true) {
|
||||
m.vm.reload = !m.vm.reload;
|
||||
}
|
||||
break;
|
||||
case "report":
|
||||
if (m.id != null) {
|
||||
//last report selected is in m.id
|
||||
m.vm.$router.push({
|
||||
name: "ay-report",
|
||||
params: { recordid: m.id, ayatype: window.$gz.type.Quote }
|
||||
});
|
||||
} else {
|
||||
//general report selector chosen
|
||||
|
||||
let res = await m.vm.$refs.reportSelector.open(
|
||||
m.vm.$refs.gzdatatable.getDataListSelection(window.$gz.type.Quote)
|
||||
);
|
||||
|
||||
//if null for no selection
|
||||
//just bail out
|
||||
if (res == null) {
|
||||
return;
|
||||
}
|
||||
//persist last report selected
|
||||
window.$gz.form.setLastReport(FORM_KEY, res);
|
||||
|
||||
//Now open the report viewer...
|
||||
m.vm.$router.push({
|
||||
name: "ay-report",
|
||||
params: { recordid: res.id, ayatype: window.$gz.type.Quote }
|
||||
});
|
||||
}
|
||||
break;
|
||||
case "QuoteItemList":
|
||||
m.vm.$router.push({
|
||||
name: "svc-quote-items"
|
||||
});
|
||||
break;
|
||||
case "open":
|
||||
m.vm.openDialog = true;
|
||||
break;
|
||||
default:
|
||||
window.$gz.eventBus.$emit(
|
||||
"notify-warning",
|
||||
FORM_KEY + "::context click: [" + m.key + "]"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////
|
||||
//
|
||||
//
|
||||
function generateMenu(vm) {
|
||||
let menuOptions = {
|
||||
isMain: true,
|
||||
icon: "$ayiPencilAlt",
|
||||
title: "QuoteList",
|
||||
helpUrl: "svc-quotes",
|
||||
menuItems: [],
|
||||
formData: {
|
||||
ayaType: window.$gz.type.Quote
|
||||
}
|
||||
};
|
||||
|
||||
if (vm.rights.change) {
|
||||
menuOptions.menuItems.push({
|
||||
title: "New",
|
||||
icon: "$ayiPlus",
|
||||
surface: true,
|
||||
key: FORM_KEY + ":new",
|
||||
vm: vm
|
||||
});
|
||||
}
|
||||
|
||||
//REPORTS
|
||||
//Report not Print, print is a further option
|
||||
menuOptions.menuItems.push({
|
||||
title: "Report",
|
||||
icon: "$ayiFileAlt",
|
||||
key: FORM_KEY + ":report",
|
||||
vm: vm
|
||||
});
|
||||
|
||||
//get last report selected
|
||||
let lastReport = window.$gz.form.getLastReport(FORM_KEY);
|
||||
if (lastReport != null) {
|
||||
menuOptions.menuItems.push({
|
||||
title: lastReport.name,
|
||||
icon: "$ayiFileAlt",
|
||||
key: FORM_KEY + ":report:" + lastReport.id,
|
||||
vm: vm
|
||||
});
|
||||
}
|
||||
|
||||
menuOptions.menuItems.push({
|
||||
title: "Extensions",
|
||||
icon: "$ayiPuzzlePiece",
|
||||
key: FORM_KEY + ":extensions",
|
||||
vm: vm
|
||||
});
|
||||
menuOptions.menuItems.push({
|
||||
title: "Open",
|
||||
icon: "$ayiTools",
|
||||
key: FORM_KEY + ":open",
|
||||
vm: vm
|
||||
});
|
||||
menuOptions.menuItems.push({ divider: true, inset: false });
|
||||
|
||||
menuOptions.menuItems.push({
|
||||
title: "QuoteItemList",
|
||||
icon: "$ayiWrench",
|
||||
key: FORM_KEY + ":QuoteItemList",
|
||||
vm: vm
|
||||
});
|
||||
|
||||
menuOptions.menuItems.push({ divider: true, inset: false });
|
||||
|
||||
window.$gz.eventBus.$emit("menu-change", menuOptions);
|
||||
}
|
||||
//////////////////////////////////////////////////////////
|
||||
//
|
||||
// Ensures UI translated text is available
|
||||
//
|
||||
async function fetchTranslatedText() {
|
||||
await window.$gz.translation.cacheTranslations(["Quote"]);
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user