This commit is contained in:
@@ -451,6 +451,10 @@ export default {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
selectReturnColumns: {
|
||||
type: Array,
|
||||
default: null
|
||||
},
|
||||
reload: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
@@ -655,16 +659,66 @@ export default {
|
||||
};
|
||||
},
|
||||
handleSelectChange() {
|
||||
//due to making own template for items need to handle singleselect which only affects if select all checkbox at top is visible when making own item template
|
||||
if (this.singleSelect) {
|
||||
this.selected.splice(0, this.selected.length - 1);
|
||||
}
|
||||
//emit event to parent form of selected rows
|
||||
if (
|
||||
this.selectReturnColumns != null &&
|
||||
this.selectReturnColumns.length > 0
|
||||
) {
|
||||
//todo: here need to check if calling form has asked for a template of certain fields instead of row id's
|
||||
//and emit that as objects instead
|
||||
//i.e. restock list provides selectReturnTemplate array of field key names:
|
||||
// ['PartPartNumber','PartWarehouseName','PartWholesalerID','PartAlternativeWholesalerID','PartManufacturerID','PartByWarehouseInventoryReorderQuantity']
|
||||
//select then saves exactly those columns into the selection instead of id's
|
||||
//returns the id and name values or basically anything in that column ready for ease of use by extensions like partrestock extension which needs display and id values both
|
||||
//maybe need to rename selectedRowIds if it can fit within that system too.
|
||||
|
||||
this.$emit(
|
||||
"selection-change",
|
||||
this.selected.map(z => z.id)
|
||||
);
|
||||
console.log("handleselectchange templated", {
|
||||
selected: this.selected,
|
||||
headers: this.headers
|
||||
});
|
||||
|
||||
//build a map of column numbers that correspond with template fk names
|
||||
/*
|
||||
arrays of objects like this, fk corresponds to field template, value columns.cx equals actual column we need, text may be useful too save a translation to send it maybe?
|
||||
align: "start"
|
||||
fk: "PartPartNumber"
|
||||
flt: true
|
||||
text: "Part Number"
|
||||
value: "columns.c0"
|
||||
*/
|
||||
//iterate the selected items which are like below, i is id number of record, t is type maybe useful, v is display value, key is only useless thing, maybe just strip the key and send the rest?
|
||||
/*
|
||||
c0: {…}
|
||||
i: 3
|
||||
key: "0-0"
|
||||
t: 4
|
||||
v: "017368"
|
||||
*/
|
||||
|
||||
//return array like this:
|
||||
/*
|
||||
todo: work this out, array of arrays I guess??
|
||||
[
|
||||
{
|
||||
fk:"PartPartNumber",
|
||||
text:"Part number",
|
||||
i: 3,
|
||||
t: 4,
|
||||
v: "01768"
|
||||
}
|
||||
*/
|
||||
|
||||
} else {
|
||||
//due to making own template for items need to handle singleselect which only affects if select all checkbox at top is visible when making own item template
|
||||
if (this.singleSelect) {
|
||||
this.selected.splice(0, this.selected.length - 1);
|
||||
}
|
||||
//emit event to parent form of selected rows
|
||||
|
||||
this.$emit(
|
||||
"selection-change",
|
||||
this.selected.map(z => z.id)
|
||||
);
|
||||
}
|
||||
},
|
||||
editColumnView() {
|
||||
this.$router.push({
|
||||
|
||||
@@ -28,7 +28,10 @@ export default {
|
||||
let vm = this;
|
||||
await fetchTranslatedText(vm);
|
||||
//NOTE: if extension doesn't support a particular object add it here to the NoType default
|
||||
if (vm.dataListSelection.ObjectType != 0) {
|
||||
if (
|
||||
vm.dataListSelection.ObjectType != 0 &&
|
||||
vm.dataListSelection.ObjectType != window.$gz.type.PartInventoryRestock
|
||||
) {
|
||||
vm.rights = window.$gz.role.getRights(vm.dataListSelection.ObjectType);
|
||||
}
|
||||
vm.available = vm.rights.change;
|
||||
|
||||
@@ -26,7 +26,11 @@ export default {
|
||||
}),
|
||||
methods: {
|
||||
available() {
|
||||
return this.dataListSelection.ObjectType != 0;
|
||||
return (
|
||||
this.dataListSelection.ObjectType != 0 &&
|
||||
this.dataListSelection.ObjectType !=
|
||||
window.$gz.type.PartInventoryRestock
|
||||
);
|
||||
},
|
||||
goHelp() {
|
||||
window.open(this.$store.state.helpUrl + "ay-ex-export", "_blank");
|
||||
|
||||
145
ayanova/src/components/extension-restock-po-control.vue
Normal file
145
ayanova/src/components/extension-restock-po-control.vue
Normal file
@@ -0,0 +1,145 @@
|
||||
<template>
|
||||
<v-expansion-panel v-if="available() == true">
|
||||
<v-expansion-panel-header
|
||||
disable-icon-rotate
|
||||
expand-icon="$ayiTruckLoading"
|
||||
>{{ $ay.t("Order restock items") }}</v-expansion-panel-header
|
||||
>
|
||||
<v-expansion-panel-content>
|
||||
<v-row>
|
||||
<v-col cols="12">
|
||||
PurchaseOrderUICopyToPurchaseOrder po selector (variant open ones only
|
||||
or maybe they type the number???) or create new here
|
||||
{{ dataListSelection }}
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-btn icon @click="goHelp()"><v-icon>$ayiQuestionCircle</v-icon></v-btn>
|
||||
<v-btn
|
||||
:disabled="!canDoAction()"
|
||||
color="blue darken-1"
|
||||
text
|
||||
@click="doAction()"
|
||||
:loading="jobActive"
|
||||
>{{ $ay.t("StartJob") }}</v-btn
|
||||
>
|
||||
</v-expansion-panel-content>
|
||||
</v-expansion-panel>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
async created() {
|
||||
let vm = this;
|
||||
await fetchTranslatedText(vm);
|
||||
|
||||
if (vm.dataListSelection.ObjectType != 0) {
|
||||
vm.rights = window.$gz.role.getRights(vm.dataListSelection.ObjectType);
|
||||
}
|
||||
},
|
||||
data: () => ({
|
||||
jobActive: false,
|
||||
rights: window.$gz.role.defaultRightsObject()
|
||||
}),
|
||||
methods: {
|
||||
goHelp() {
|
||||
window.open(this.$store.state.helpUrl + "ay-ex-restock-po", "_blank");
|
||||
},
|
||||
available() {
|
||||
return (
|
||||
this.dataListSelection.ObjectType ==
|
||||
window.$gz.type.PartInventoryRestock
|
||||
);
|
||||
},
|
||||
canDoAction() {
|
||||
return true;
|
||||
},
|
||||
async doAction() {
|
||||
let vm = this;
|
||||
//probably dont' need a prompt, can always delete off po anyway to reverse this
|
||||
// let dialogResult = await window.$gz.dialog.confirmGeneric(
|
||||
// "EraseMultipleObjectsWarning",
|
||||
// "error"
|
||||
// );
|
||||
// if (dialogResult == false) {
|
||||
// return;
|
||||
// }
|
||||
//Clear any possible prior errors
|
||||
vm.$emit("ext-show-job-log", "clear");
|
||||
|
||||
//do the batch action
|
||||
let url = "purchase-order/batch-add-restock";
|
||||
let body = this.dataListSelection;
|
||||
|
||||
try {
|
||||
//call api route
|
||||
let jobId = await window.$gz.api.upsert(url, body);
|
||||
if (jobId.error) {
|
||||
//throw new Error(jobId.error);
|
||||
throw new Error(window.$gz.errorHandler.errorToString(jobId, vm));
|
||||
}
|
||||
jobId = jobId.jobId; //it's in a sub key
|
||||
//indicate loading by setting on button
|
||||
vm.jobActive = true;
|
||||
|
||||
/* /// <summary>
|
||||
/// Job status for opsjobs
|
||||
/// </summary>
|
||||
public enum JobStatus : int
|
||||
{
|
||||
Absent=0,
|
||||
Sleeping = 1,
|
||||
Running = 2,
|
||||
Completed = 3,
|
||||
Failed = 4
|
||||
} */
|
||||
let jobStatus = 1;
|
||||
//get status
|
||||
|
||||
while (vm.jobActive == true) {
|
||||
await window.$gz.util.sleepAsync(1000);
|
||||
//check if done
|
||||
jobStatus = await window.$gz.api.get(
|
||||
`job-operations/status/${jobId}`
|
||||
);
|
||||
if (jobStatus.error) {
|
||||
throw new Error(
|
||||
window.$gz.errorHandler.errorToString(jobStatus, vm)
|
||||
);
|
||||
}
|
||||
jobStatus = jobStatus.data;
|
||||
if (jobStatus == 4 || jobStatus == 0) {
|
||||
if (jobStatus == 4) {
|
||||
//emit job id and event to parent for log viewing
|
||||
vm.$emit("ext-show-job-log", jobId);
|
||||
}
|
||||
throw new Error("Job failed");
|
||||
}
|
||||
if (jobStatus == 3) {
|
||||
vm.jobActive = false;
|
||||
}
|
||||
}
|
||||
//Here if it's completed successfully
|
||||
window.$gz.eventBus.$emit("notify-success", vm.$ay.t("JobCompleted"));
|
||||
vm.$emit("ext-close-refresh");
|
||||
} catch (error) {
|
||||
vm.jobActive = false;
|
||||
|
||||
//window.$gz.errorHandler.handleFormError(error, vm);
|
||||
window.$gz.eventBus.$emit("notify-error", vm.$ay.t("JobFailed"));
|
||||
}
|
||||
}
|
||||
},
|
||||
props: {
|
||||
dataListSelection: { type: Object, default: null }
|
||||
}
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
//
|
||||
// Ensures UI translated text is available
|
||||
//
|
||||
async function fetchTranslatedText(vm) {
|
||||
await window.$gz.translation.cacheTranslations([
|
||||
"PurchaseOrderUICopyToPurchaseOrder"
|
||||
]);
|
||||
}
|
||||
</script>
|
||||
@@ -44,8 +44,11 @@
|
||||
export default {
|
||||
created() {
|
||||
let vm = this;
|
||||
//NOTE: if extension doesn't support a particular object add it here to the NoType default
|
||||
if (vm.dataListSelection.ObjectType != 0) {
|
||||
|
||||
if (
|
||||
vm.dataListSelection.ObjectType != 0 &&
|
||||
vm.dataListSelection.ObjectType != window.$gz.type.PartInventoryRestock
|
||||
) {
|
||||
vm.rights = window.$gz.role.getRights(vm.dataListSelection.ObjectType);
|
||||
}
|
||||
vm.available = vm.rights.change;
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
@ext-show-job-log="handleError($event)"
|
||||
:data-list-selection="dataListSelection"
|
||||
/>
|
||||
<ExtensionRestockPo :data-list-selection="dataListSelection" />
|
||||
</v-expansion-panels>
|
||||
</v-card-text>
|
||||
<v-card-actions>
|
||||
@@ -42,11 +43,13 @@
|
||||
import ExtensionTags from "./extension-tags-control.vue";
|
||||
import ExtensionExport from "./extension-export-control.vue";
|
||||
import ExtensionDelete from "./extension-delete-control.vue";
|
||||
import ExtensionRestockPo from "./extension-restock-po-control.vue";
|
||||
export default {
|
||||
components: {
|
||||
ExtensionTags,
|
||||
ExtensionExport,
|
||||
ExtensionDelete
|
||||
ExtensionDelete,
|
||||
ExtensionRestockPo
|
||||
},
|
||||
async created() {
|
||||
await initForm(this);
|
||||
|
||||
Reference in New Issue
Block a user