This commit is contained in:
@@ -16,7 +16,7 @@ export default {
|
|||||||
Global: { Change: 2, ReadFullRecord: 1, Select: 0 },
|
Global: { Change: 2, ReadFullRecord: 1, Select: 0 },
|
||||||
GlobalOps: { Change: 16384, ReadFullRecord: 8192, Select: 0 },
|
GlobalOps: { Change: 16384, ReadFullRecord: 8192, Select: 0 },
|
||||||
User: { Change: 2, ReadFullRecord: 1, Select: 131071 },
|
User: { Change: 2, ReadFullRecord: 1, Select: 131071 },
|
||||||
UserOptions: { Change: 2, ReadFullRecord: 1, Select: 0 },
|
UserOptions: { Change: 2, ReadFullRecord: 1, Select: 0 },
|
||||||
Vendor: { Change: 106, ReadFullRecord: 98565, Select: 131071 },
|
Vendor: { Change: 106, ReadFullRecord: 98565, Select: 131071 },
|
||||||
ServerState: { Change: 16384, ReadFullRecord: 131071, Select: 0 },
|
ServerState: { Change: 16384, ReadFullRecord: 131071, Select: 0 },
|
||||||
LogFile: { Change: 0, ReadFullRecord: 24576, Select: 0 },
|
LogFile: { Change: 0, ReadFullRecord: 24576, Select: 0 },
|
||||||
|
|||||||
@@ -221,12 +221,12 @@ export default {
|
|||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case socktype.Vendor:
|
case socktype.Vendor:
|
||||||
vm.$router.push({
|
vm.$router.push({
|
||||||
name: "vendor-edit",
|
name: "vendor-edit",
|
||||||
params: { recordid: tid.id }
|
params: { recordid: tid.id }
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
window.$gz.eventBus.$emit(
|
window.$gz.eventBus.$emit(
|
||||||
|
|||||||
@@ -345,6 +345,12 @@ export default new Router({
|
|||||||
component: () =>
|
component: () =>
|
||||||
import(/* webpackChunkName: "biz" */ "./views/biz-purchase-list.vue")
|
import(/* webpackChunkName: "biz" */ "./views/biz-purchase-list.vue")
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: "/biz-purchase-list/:recordid",
|
||||||
|
name: "purchase-edit",
|
||||||
|
component: () =>
|
||||||
|
import(/* webpackChunkName: "biz" */ "./views/biz-purchase.vue")
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: "/biz-product-list",
|
path: "/biz-product-list",
|
||||||
name: "biz-product-list",
|
name: "biz-product-list",
|
||||||
|
|||||||
@@ -9,11 +9,11 @@
|
|||||||
</gz-extensions>
|
</gz-extensions>
|
||||||
<gz-data-table
|
<gz-data-table
|
||||||
ref="gzdatatable"
|
ref="gzdatatable"
|
||||||
form-key="customer-list"
|
form-key="purchase-list"
|
||||||
data-list-key="CustomerDataList"
|
data-list-key="PurchaseDataList"
|
||||||
:show-select="rights.read"
|
:show-select="rights.read"
|
||||||
:reload="reload"
|
:reload="reload"
|
||||||
data-cy="customersTable"
|
data-cy="purchasesTable"
|
||||||
:client-criteria="clientCriteria"
|
:client-criteria="clientCriteria"
|
||||||
:pre-filter-mode="preFilterMode"
|
:pre-filter-mode="preFilterMode"
|
||||||
@selection-change="handleSelected"
|
@selection-change="handleSelected"
|
||||||
@@ -24,12 +24,12 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const FORM_KEY = "customer-list";
|
const FORM_KEY = "purchase-list";
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
rights: window.$gz.role.defaultRightsObject(),
|
rights: window.$gz.role.defaultRightsObject(),
|
||||||
aType: window.$gz.type.Customer,
|
aType: window.$gz.type.Purchase,
|
||||||
selectedItems: [],
|
selectedItems: [],
|
||||||
reload: false,
|
reload: false,
|
||||||
clientCriteria: undefined,
|
clientCriteria: undefined,
|
||||||
@@ -37,11 +37,11 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.rights = window.$gz.role.getRights(window.$gz.type.Customer);
|
this.rights = window.$gz.role.getRights(window.$gz.type.Purchase);
|
||||||
window.$gz.eventBus.$on("menu-click", clickHandler);
|
window.$gz.eventBus.$on("menu-click", clickHandler);
|
||||||
|
|
||||||
//------ pre-filter ----
|
//------ pre-filter ----
|
||||||
//OPTIONAL "Show All customers of head office" FILTER
|
//OPTIONAL "Show All purchases of head office" FILTER
|
||||||
this.objectId = window.$gz.util.stringToIntOrNull(
|
this.objectId = window.$gz.util.stringToIntOrNull(
|
||||||
this.$route.params.objectId
|
this.$route.params.objectId
|
||||||
);
|
);
|
||||||
@@ -89,7 +89,7 @@ async function clickHandler(menuItem) {
|
|||||||
switch (m.key) {
|
switch (m.key) {
|
||||||
case "new":
|
case "new":
|
||||||
m.vm.$router.push({
|
m.vm.$router.push({
|
||||||
name: "customer-edit",
|
name: "purchase-edit",
|
||||||
params: { recordid: 0 }
|
params: { recordid: 0 }
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
@@ -97,7 +97,7 @@ async function clickHandler(menuItem) {
|
|||||||
{
|
{
|
||||||
const res = await m.vm.$refs.extensions.open(
|
const res = await m.vm.$refs.extensions.open(
|
||||||
m.vm.$refs.gzdatatable.getDataListSelection(
|
m.vm.$refs.gzdatatable.getDataListSelection(
|
||||||
window.$gz.type.Customer
|
window.$gz.type.Purchase
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
if (res && res.refresh == true) {
|
if (res && res.refresh == true) {
|
||||||
@@ -109,7 +109,7 @@ async function clickHandler(menuItem) {
|
|||||||
{
|
{
|
||||||
const res = await m.vm.$refs.reportSelector.open(
|
const res = await m.vm.$refs.reportSelector.open(
|
||||||
m.vm.$refs.gzdatatable.getDataListSelection(
|
m.vm.$refs.gzdatatable.getDataListSelection(
|
||||||
window.$gz.type.Customer
|
window.$gz.type.Purchase
|
||||||
),
|
),
|
||||||
m.id
|
m.id
|
||||||
);
|
);
|
||||||
@@ -135,11 +135,11 @@ function generateMenu(vm) {
|
|||||||
const menuOptions = {
|
const menuOptions = {
|
||||||
isMain: true,
|
isMain: true,
|
||||||
icon: "$sockiAddressCard",
|
icon: "$sockiAddressCard",
|
||||||
title: "CustomerList",
|
title: "PurchaseList",
|
||||||
helpUrl: "customers",
|
helpUrl: "purchases",
|
||||||
menuItems: [],
|
menuItems: [],
|
||||||
formData: {
|
formData: {
|
||||||
sockType: window.$gz.type.Customer
|
sockType: window.$gz.type.Purchase
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
704
client/src/views/biz-purchase.vue
Normal file
704
client/src/views/biz-purchase.vue
Normal file
@@ -0,0 +1,704 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<gz-report-selector ref="reportSelector"></gz-report-selector>
|
||||||
|
<div v-if="formState.ready">
|
||||||
|
<gz-error :error-box-message="formState.errorBoxMessage"></gz-error>
|
||||||
|
<v-form ref="form">
|
||||||
|
<v-row dense>
|
||||||
|
<v-col cols="12" sm="6" lg="4" xl="3">
|
||||||
|
<v-text-field
|
||||||
|
ref="name"
|
||||||
|
v-model="obj.name"
|
||||||
|
dense
|
||||||
|
:readonly="formState.readOnly"
|
||||||
|
:label="$sock.t('PurchaseName')"
|
||||||
|
:rules="[form().required(this, 'name')]"
|
||||||
|
:error-messages="form().serverErrors(this, 'name')"
|
||||||
|
data-cy="name"
|
||||||
|
@input="fieldValueChanged('name')"
|
||||||
|
></v-text-field>
|
||||||
|
</v-col>
|
||||||
|
|
||||||
|
<v-col
|
||||||
|
v-if="form().showMe(this, 'Vendor')"
|
||||||
|
cols="12"
|
||||||
|
sm="6"
|
||||||
|
lg="4"
|
||||||
|
xl="3"
|
||||||
|
>
|
||||||
|
<gz-pick-list
|
||||||
|
ref="vendorId"
|
||||||
|
v-model="obj.vendorId"
|
||||||
|
:aya-type="sockTypes().Vendor"
|
||||||
|
show-edit-icon
|
||||||
|
:readonly="formState.readOnly"
|
||||||
|
:label="$sock.t('Vendor')"
|
||||||
|
:error-messages="form().serverErrors(this, 'vendorId')"
|
||||||
|
:rules="[form().required(this, 'vendorId')]"
|
||||||
|
@input="fieldValueChanged('vendorId')"
|
||||||
|
></gz-pick-list>
|
||||||
|
</v-col>
|
||||||
|
|
||||||
|
<v-col
|
||||||
|
v-if="form().showMe(this, 'PurchaseVendorCode')"
|
||||||
|
cols="12"
|
||||||
|
sm="6"
|
||||||
|
lg="4"
|
||||||
|
xl="3"
|
||||||
|
>
|
||||||
|
<v-text-field
|
||||||
|
ref="vendorCode"
|
||||||
|
v-model="obj.vendorCode"
|
||||||
|
dense
|
||||||
|
:readonly="formState.readOnly"
|
||||||
|
:label="$sock.t('PurchaseVendorCode')"
|
||||||
|
data-cy="vendorCode"
|
||||||
|
:error-messages="form().serverErrors(this, 'vendorCode')"
|
||||||
|
@input="fieldValueChanged('vendorCode')"
|
||||||
|
></v-text-field>
|
||||||
|
</v-col>
|
||||||
|
|
||||||
|
<v-col
|
||||||
|
v-if="form().showMe(this, 'PurchaseOurCode')"
|
||||||
|
cols="12"
|
||||||
|
sm="6"
|
||||||
|
lg="4"
|
||||||
|
xl="3"
|
||||||
|
>
|
||||||
|
<v-text-field
|
||||||
|
ref="ourCode"
|
||||||
|
v-model="obj.ourCode"
|
||||||
|
dense
|
||||||
|
:readonly="formState.readOnly"
|
||||||
|
:label="$sock.t('PurchaseOurCode')"
|
||||||
|
data-cy="ourCode"
|
||||||
|
:error-messages="form().serverErrors(this, 'ourCode')"
|
||||||
|
@input="fieldValueChanged('ourCode')"
|
||||||
|
></v-text-field>
|
||||||
|
</v-col>
|
||||||
|
|
||||||
|
<v-col
|
||||||
|
v-if="form().showMe(this, 'PurchaseLicenseInterval')"
|
||||||
|
cols="12"
|
||||||
|
sm="6"
|
||||||
|
lg="4"
|
||||||
|
xl="3"
|
||||||
|
>
|
||||||
|
<gz-duration-picker
|
||||||
|
ref="licenseInterval"
|
||||||
|
v-model="obj.licenseInterval"
|
||||||
|
:readonly="formState.readOnly"
|
||||||
|
:label="$sock.t('PurchaseLicenseInterval')"
|
||||||
|
:show-seconds="false"
|
||||||
|
data-cy="licenseInterval"
|
||||||
|
:error-messages="form().serverErrors(this, 'licenseInterval')"
|
||||||
|
@input="fieldValueChanged('licenseInterval')"
|
||||||
|
></gz-duration-picker>
|
||||||
|
</v-col>
|
||||||
|
|
||||||
|
<v-col
|
||||||
|
v-if="form().showMe(this, 'PurchaseMaintInterval')"
|
||||||
|
cols="12"
|
||||||
|
sm="6"
|
||||||
|
lg="4"
|
||||||
|
xl="3"
|
||||||
|
>
|
||||||
|
<gz-duration-picker
|
||||||
|
ref="maintInterval"
|
||||||
|
v-model="obj.maintInterval"
|
||||||
|
:readonly="formState.readOnly"
|
||||||
|
:label="$sock.t('PurchaseMaintInterval')"
|
||||||
|
:show-seconds="false"
|
||||||
|
data-cy="maintInterval"
|
||||||
|
:error-messages="form().serverErrors(this, 'maintInterval')"
|
||||||
|
@input="fieldValueChanged('maintInterval')"
|
||||||
|
></gz-duration-picker>
|
||||||
|
</v-col>
|
||||||
|
|
||||||
|
<v-col cols="12" sm="6" lg="4" xl="3">
|
||||||
|
<v-checkbox
|
||||||
|
ref="active"
|
||||||
|
v-model="obj.active"
|
||||||
|
dense
|
||||||
|
:readonly="formState.readOnly"
|
||||||
|
:label="$sock.t('Active')"
|
||||||
|
data-cy="active"
|
||||||
|
:error-messages="form().serverErrors(this, 'active')"
|
||||||
|
@change="fieldValueChanged('active')"
|
||||||
|
></v-checkbox>
|
||||||
|
</v-col>
|
||||||
|
<!-- --------------------------------- -->
|
||||||
|
|
||||||
|
<v-col v-if="form().showMe(this, 'Tags')" cols="12">
|
||||||
|
<gz-tag-picker
|
||||||
|
ref="tags"
|
||||||
|
v-model="obj.tags"
|
||||||
|
:readonly="formState.readOnly"
|
||||||
|
data-cy="tags"
|
||||||
|
:error-messages="form().serverErrors(this, 'tags')"
|
||||||
|
@input="fieldValueChanged('tags')"
|
||||||
|
></gz-tag-picker>
|
||||||
|
</v-col>
|
||||||
|
|
||||||
|
<v-col v-if="form().showMe(this, 'Wiki')" cols="12">
|
||||||
|
<gz-wiki
|
||||||
|
ref="wiki"
|
||||||
|
v-model="obj.wiki"
|
||||||
|
:aya-type="sockType"
|
||||||
|
:aya-id="obj.id"
|
||||||
|
:readonly="formState.readOnly"
|
||||||
|
@input="fieldValueChanged('wiki')"
|
||||||
|
></gz-wiki
|
||||||
|
></v-col>
|
||||||
|
|
||||||
|
<v-col v-if="form().showMe(this, 'Attachments') && obj.id" cols="12">
|
||||||
|
<gz-attachments
|
||||||
|
:readonly="formState.readOnly"
|
||||||
|
:aya-type="sockType"
|
||||||
|
:aya-id="obj.id"
|
||||||
|
></gz-attachments
|
||||||
|
></v-col>
|
||||||
|
</v-row>
|
||||||
|
</v-form>
|
||||||
|
</div>
|
||||||
|
<v-overlay :value="!formState.ready || formState.loading">
|
||||||
|
<v-progress-circular indeterminate :size="64" />
|
||||||
|
</v-overlay>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
const FORM_KEY = "purchase-edit";
|
||||||
|
const API_BASE_URL = "purchase/";
|
||||||
|
const FORM_CUSTOM_TEMPLATE_KEY = "Purchase";
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
formCustomTemplateKey: FORM_CUSTOM_TEMPLATE_KEY,
|
||||||
|
obj: {
|
||||||
|
id: 0,
|
||||||
|
concurrency: 0,
|
||||||
|
name: null,
|
||||||
|
active: true,
|
||||||
|
vendorId: 1,
|
||||||
|
licenseInterval: "365.0:00:00",
|
||||||
|
maintInterval: "365.0:00:00",
|
||||||
|
vendorCode: null,
|
||||||
|
ourCode: null,
|
||||||
|
wiki: null,
|
||||||
|
tags: [],
|
||||||
|
sType: 0
|
||||||
|
},
|
||||||
|
formState: {
|
||||||
|
ready: false,
|
||||||
|
dirty: false,
|
||||||
|
valid: true,
|
||||||
|
readOnly: false,
|
||||||
|
loading: true,
|
||||||
|
errorBoxMessage: null,
|
||||||
|
appError: null,
|
||||||
|
serverError: {}
|
||||||
|
},
|
||||||
|
rights: window.$gz.role.defaultRightsObject(),
|
||||||
|
sockType: window.$gz.type.Purchase
|
||||||
|
};
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
formState: {
|
||||||
|
handler: function(val) {
|
||||||
|
if (this.formState.loading) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (val.dirty && val.valid && !val.readOnly) {
|
||||||
|
window.$gz.eventBus.$emit("menu-enable-item", FORM_KEY + ":save");
|
||||||
|
} else {
|
||||||
|
window.$gz.eventBus.$emit("menu-disable-item", FORM_KEY + ":save");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!val.dirty && val.valid && !val.readOnly) {
|
||||||
|
window.$gz.eventBus.$emit(
|
||||||
|
"menu-enable-item",
|
||||||
|
FORM_KEY + ":duplicate"
|
||||||
|
);
|
||||||
|
window.$gz.eventBus.$emit("menu-enable-item", FORM_KEY + ":new");
|
||||||
|
} else {
|
||||||
|
window.$gz.eventBus.$emit(
|
||||||
|
"menu-disable-item",
|
||||||
|
FORM_KEY + ":duplicate"
|
||||||
|
);
|
||||||
|
window.$gz.eventBus.$emit("menu-disable-item", FORM_KEY + ":new");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
deep: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async created() {
|
||||||
|
const vm = this;
|
||||||
|
try {
|
||||||
|
await initForm(vm);
|
||||||
|
vm.rights = window.$gz.role.getRights(window.$gz.type.Purchase);
|
||||||
|
vm.formState.readOnly = !vm.rights.change;
|
||||||
|
window.$gz.eventBus.$on("menu-click", clickHandler);
|
||||||
|
//---------------------------------
|
||||||
|
let setDirty = false;
|
||||||
|
//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;
|
||||||
|
} else {
|
||||||
|
await vm.getDataFromApi(vm.$route.params.recordid);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//Might be a duplicate and contain another record
|
||||||
|
if (this.$route.params.obj) {
|
||||||
|
this.obj = this.$route.params.obj;
|
||||||
|
this.obj.concurrency = undefined;
|
||||||
|
this.obj.id = 0;
|
||||||
|
this.obj.name = `${this.obj.name} - ${window.$gz.translation.get(
|
||||||
|
"Copy"
|
||||||
|
)}`;
|
||||||
|
setDirty = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
window.$gz.form.setFormState({
|
||||||
|
vm: vm,
|
||||||
|
loading: false,
|
||||||
|
dirty: setDirty,
|
||||||
|
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: {
|
||||||
|
canSave: function() {
|
||||||
|
return this.formState.valid && this.formState.dirty;
|
||||||
|
},
|
||||||
|
canDuplicate: function() {
|
||||||
|
return this.formState.valid && !this.formState.dirty;
|
||||||
|
},
|
||||||
|
sockTypes: function() {
|
||||||
|
return window.$gz.type;
|
||||||
|
},
|
||||||
|
form() {
|
||||||
|
return window.$gz.form;
|
||||||
|
},
|
||||||
|
fieldValueChanged(ref) {
|
||||||
|
if (
|
||||||
|
this.formState.ready &&
|
||||||
|
!this.formState.loading &&
|
||||||
|
!this.formState.readOnly
|
||||||
|
) {
|
||||||
|
window.$gz.form.fieldValueChanged(this, ref);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async getDataFromApi(recordId) {
|
||||||
|
const vm = this;
|
||||||
|
window.$gz.form.setFormState({
|
||||||
|
vm: vm,
|
||||||
|
loading: true
|
||||||
|
});
|
||||||
|
if (!recordId) {
|
||||||
|
throw new Error(FORM_KEY + "::getDataFromApi -> Missing recordID!");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
window.$gz.form.deleteAllErrorBoxErrors(vm);
|
||||||
|
const res = await window.$gz.api.get(API_BASE_URL + recordId);
|
||||||
|
if (res.error) {
|
||||||
|
if (res.error.code == "2010") {
|
||||||
|
window.$gz.form.handleObjectNotFound(vm);
|
||||||
|
}
|
||||||
|
vm.formState.serverError = res.error;
|
||||||
|
window.$gz.form.setErrorBoxErrors(vm);
|
||||||
|
} else {
|
||||||
|
vm.obj = res.data;
|
||||||
|
generateMenu(vm);
|
||||||
|
window.$gz.form.setFormState({
|
||||||
|
vm: vm,
|
||||||
|
dirty: false,
|
||||||
|
valid: true,
|
||||||
|
loading: false
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
window.$gz.errorHandler.handleFormError(error, vm);
|
||||||
|
} finally {
|
||||||
|
window.$gz.form.setFormState({
|
||||||
|
vm: vm,
|
||||||
|
loading: false
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async submit() {
|
||||||
|
const vm = this;
|
||||||
|
if (vm.canSave == false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
window.$gz.form.setFormState({
|
||||||
|
vm: vm,
|
||||||
|
loading: true
|
||||||
|
});
|
||||||
|
window.$gz.form.deleteAllErrorBoxErrors(vm);
|
||||||
|
const res = await window.$gz.api.upsert(API_BASE_URL, vm.obj);
|
||||||
|
if (res.error) {
|
||||||
|
vm.formState.serverError = res.error;
|
||||||
|
window.$gz.form.setErrorBoxErrors(vm);
|
||||||
|
} else {
|
||||||
|
if (res.data.id) {
|
||||||
|
//POST
|
||||||
|
vm.obj = res.data;
|
||||||
|
this.$router.replace({
|
||||||
|
name: "purchase-edit",
|
||||||
|
params: {
|
||||||
|
recordid: res.data.id,
|
||||||
|
obj: res.data
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
//PUT
|
||||||
|
vm.obj.concurrency = res.data.concurrency;
|
||||||
|
}
|
||||||
|
window.$gz.form.setFormState({
|
||||||
|
vm: vm,
|
||||||
|
dirty: false,
|
||||||
|
valid: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (ex) {
|
||||||
|
window.$gz.errorHandler.handleFormError(ex, vm);
|
||||||
|
} finally {
|
||||||
|
window.$gz.form.setFormState({
|
||||||
|
vm: vm,
|
||||||
|
loading: false
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async remove() {
|
||||||
|
try {
|
||||||
|
const dialogResult = await window.$gz.dialog.confirmDelete();
|
||||||
|
if (dialogResult != true) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
window.$gz.form.setFormState({
|
||||||
|
vm: this,
|
||||||
|
loading: true
|
||||||
|
});
|
||||||
|
|
||||||
|
if (this.$route.params.recordid == 0) {
|
||||||
|
JUST_DELETED = true;
|
||||||
|
|
||||||
|
this.$router.go(-1);
|
||||||
|
} else {
|
||||||
|
window.$gz.form.deleteAllErrorBoxErrors(this);
|
||||||
|
const res = await window.$gz.api.remove(
|
||||||
|
API_BASE_URL + this.$route.params.recordid
|
||||||
|
);
|
||||||
|
if (res.error) {
|
||||||
|
this.formState.serverError = res.error;
|
||||||
|
window.$gz.form.setErrorBoxErrors(this);
|
||||||
|
} else {
|
||||||
|
JUST_DELETED = true;
|
||||||
|
this.$router.go(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
window.$gz.errorHandler.handleFormError(error, this);
|
||||||
|
} finally {
|
||||||
|
window.$gz.form.setFormState({
|
||||||
|
vm: this,
|
||||||
|
loading: false
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
duplicate() {
|
||||||
|
this.$router.push({
|
||||||
|
name: "purchase-edit",
|
||||||
|
params: {
|
||||||
|
recordid: 0,
|
||||||
|
obj: this.obj
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/////////////////////////////
|
||||||
|
//
|
||||||
|
//
|
||||||
|
async function clickHandler(menuItem) {
|
||||||
|
if (!menuItem) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const m = window.$gz.menu.parseMenuItem(menuItem);
|
||||||
|
if (m.owner == FORM_KEY && !m.disabled) {
|
||||||
|
switch (m.key) {
|
||||||
|
case "save":
|
||||||
|
m.vm.submit();
|
||||||
|
break;
|
||||||
|
case "delete":
|
||||||
|
m.vm.remove();
|
||||||
|
break;
|
||||||
|
case "new":
|
||||||
|
m.vm.$router.push({
|
||||||
|
name: "purchase-edit",
|
||||||
|
params: { recordid: 0 }
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "duplicate":
|
||||||
|
m.vm.duplicate();
|
||||||
|
break;
|
||||||
|
case "report":
|
||||||
|
{
|
||||||
|
const res = await m.vm.$refs.reportSelector.open(
|
||||||
|
{
|
||||||
|
AType: window.$gz.type.Purchase,
|
||||||
|
selectedRowIds: [m.vm.obj.id]
|
||||||
|
},
|
||||||
|
m.id
|
||||||
|
);
|
||||||
|
if (res == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
window.$gz.form.setLastReportMenuItem(FORM_KEY, res, m.vm);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "WorkOrderList":
|
||||||
|
m.vm.$router.push({
|
||||||
|
name: "svc-workorders",
|
||||||
|
params: {
|
||||||
|
aType: m.vm.sockType,
|
||||||
|
objectId: m.vm.obj.id,
|
||||||
|
name: m.vm.obj.name
|
||||||
|
}
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "QuoteList":
|
||||||
|
m.vm.$router.push({
|
||||||
|
name: "svc-quotes",
|
||||||
|
params: {
|
||||||
|
aType: m.vm.sockType,
|
||||||
|
objectId: m.vm.obj.id,
|
||||||
|
name: m.vm.obj.name
|
||||||
|
}
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "PMList":
|
||||||
|
m.vm.$router.push({
|
||||||
|
name: "svc-pms",
|
||||||
|
params: {
|
||||||
|
aType: m.vm.sockType,
|
||||||
|
objectId: m.vm.obj.id,
|
||||||
|
name: m.vm.obj.name
|
||||||
|
}
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
window.$gz.eventBus.$emit(
|
||||||
|
"notify-warning",
|
||||||
|
FORM_KEY + "::context click: [" + m.key + "]"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////
|
||||||
|
//
|
||||||
|
//
|
||||||
|
function generateMenu(vm) {
|
||||||
|
const menuOptions = {
|
||||||
|
isMain: false,
|
||||||
|
readOnly: vm.formState.readOnly,
|
||||||
|
icon: "$sockiBarCode",
|
||||||
|
title: "Purchase",
|
||||||
|
helpUrl: "svc-purchases",
|
||||||
|
formData: {
|
||||||
|
sockType: window.$gz.type.Purchase,
|
||||||
|
recordId: vm.$route.params.recordid,
|
||||||
|
formCustomTemplateKey: FORM_CUSTOM_TEMPLATE_KEY,
|
||||||
|
recordName: vm.obj.name
|
||||||
|
},
|
||||||
|
menuItems: []
|
||||||
|
};
|
||||||
|
|
||||||
|
if (vm.rights.change) {
|
||||||
|
menuOptions.menuItems.push({
|
||||||
|
title: "Save",
|
||||||
|
icon: "$sockiSave",
|
||||||
|
surface: true,
|
||||||
|
key: FORM_KEY + ":save",
|
||||||
|
vm: vm
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
menuOptions.menuItems.push({
|
||||||
|
title: "Report",
|
||||||
|
icon: "$sockiFileAlt",
|
||||||
|
key: FORM_KEY + ":report",
|
||||||
|
vm: vm
|
||||||
|
});
|
||||||
|
|
||||||
|
const lastReport = window.$gz.form.getLastReport(FORM_KEY);
|
||||||
|
if (lastReport != null) {
|
||||||
|
menuOptions.menuItems.push({
|
||||||
|
title: lastReport.name,
|
||||||
|
notrans: true,
|
||||||
|
icon: "$sockiFileAlt",
|
||||||
|
key: FORM_KEY + ":report:" + lastReport.id,
|
||||||
|
vm: vm
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vm.rights.change) {
|
||||||
|
menuOptions.menuItems.push({
|
||||||
|
title: "New",
|
||||||
|
icon: "$sockiPlus",
|
||||||
|
key: FORM_KEY + ":new",
|
||||||
|
vm: vm
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vm.rights.change && vm.$route.params.recordid != 0) {
|
||||||
|
menuOptions.menuItems.push({
|
||||||
|
title: "Duplicate",
|
||||||
|
icon: "$sockiClone",
|
||||||
|
key: FORM_KEY + ":duplicate",
|
||||||
|
vm: vm
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (vm.rights.delete && vm.$route.params.recordid != 0) {
|
||||||
|
menuOptions.menuItems.push({
|
||||||
|
title: "Delete",
|
||||||
|
icon: "$sockiTrashAlt",
|
||||||
|
surface: false,
|
||||||
|
key: FORM_KEY + ":delete",
|
||||||
|
vm: vm
|
||||||
|
});
|
||||||
|
}
|
||||||
|
menuOptions.menuItems.push({ divider: true, inset: false });
|
||||||
|
|
||||||
|
menuOptions.menuItems.push({
|
||||||
|
title: "WorkOrderList",
|
||||||
|
icon: "$sockiTools",
|
||||||
|
key: FORM_KEY + ":WorkOrderList",
|
||||||
|
vm: vm
|
||||||
|
});
|
||||||
|
|
||||||
|
menuOptions.menuItems.push({
|
||||||
|
title: "QuoteList",
|
||||||
|
icon: "$sockiPencilAlt",
|
||||||
|
key: FORM_KEY + ":QuoteList",
|
||||||
|
vm: vm
|
||||||
|
});
|
||||||
|
|
||||||
|
menuOptions.menuItems.push({
|
||||||
|
title: "PMList",
|
||||||
|
icon: "$sockiBusinessTime",
|
||||||
|
key: FORM_KEY + ":PMList",
|
||||||
|
vm: vm
|
||||||
|
});
|
||||||
|
|
||||||
|
menuOptions.menuItems.push({ divider: true, inset: false });
|
||||||
|
window.$gz.eventBus.$emit("menu-change", menuOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
let JUST_DELETED = false;
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
//
|
||||||
|
//
|
||||||
|
async function initForm(vm) {
|
||||||
|
await fetchTranslatedText();
|
||||||
|
await window.$gz.formCustomTemplate.get(FORM_CUSTOM_TEMPLATE_KEY, vm);
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Ensures UI translated text is available
|
||||||
|
//
|
||||||
|
async function fetchTranslatedText() {
|
||||||
|
await window.$gz.translation.cacheTranslations([
|
||||||
|
"Purchase",
|
||||||
|
"PurchaseSalesOrderNumber",
|
||||||
|
"Vendor",
|
||||||
|
"Customer",
|
||||||
|
"Product",
|
||||||
|
"PurchaseSalesOrderNumber",
|
||||||
|
"PurchaseDate",
|
||||||
|
"PurchasePurchaseOverseerID",
|
||||||
|
"PurchaseExpireDate",
|
||||||
|
"PurchaseCancelDate",
|
||||||
|
"PurchaseCouponCode",
|
||||||
|
"PurchaseNotes",
|
||||||
|
"PurchaseRenewNoticeSent",
|
||||||
|
"PurchaseQuantity",
|
||||||
|
"PurchaseProcessedDate",
|
||||||
|
"PurchaseVendorData"
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
[Required]
|
||||||
|
public long CustomerId { get; set; }
|
||||||
|
[NotMapped]
|
||||||
|
public string CustomerViz { get; set; }
|
||||||
|
[Required]
|
||||||
|
public long VendorId { get; set; }
|
||||||
|
[NotMapped]
|
||||||
|
public string VendorViz { get; set; }
|
||||||
|
[Required]
|
||||||
|
public long ProductId { get; set; }
|
||||||
|
[NotMapped]
|
||||||
|
public string ProductViz { get; set; }
|
||||||
|
public string SalesOrderNumber { get; set; }
|
||||||
|
[Required]
|
||||||
|
public DateTime PurchaseDate { get; set; }
|
||||||
|
public DateTime? ExpireDate { get; set; }
|
||||||
|
public DateTime? CancelDate { get; set; }
|
||||||
|
public string CouponCode { get; set; }
|
||||||
|
public string Notes { get; set; }
|
||||||
|
public bool RenewNoticeSent { get; set; } = false;
|
||||||
|
public int Quantity { get; set; } = 1;
|
||||||
|
public string VendorData { get; set; }
|
||||||
|
public DateTime? ProcessedDate { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
expiredate TIMESTAMPTZ, canceldate TIMESTAMPTZ, couponcode text, notes text, "
|
||||||
|
|
||||||
|
+ "vendordata TEXT, processeddate TIMESTAMPTZ, "
|
||||||
|
+ "wiki TEXT, tags VARCHAR(255) ARRAY )");
|
||||||
|
await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'Purchase', 'Purchase' FROM atranslation t where t.baselanguage = 'en'");
|
||||||
|
await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'PurchaseList', 'Purchases' FROM atranslation t where t.baselanguage = 'en'");
|
||||||
|
await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'PurchaseSalesOrderNumber', 'Sales order #' FROM atranslation t where t.baselanguage = 'en'");
|
||||||
|
await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'PurchaseDate', 'Date' FROM atranslation t where t.baselanguage = 'en'");
|
||||||
|
await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'PurchaseExpireDate', 'Expires' FROM atranslation t where t.baselanguage = 'en'");
|
||||||
|
await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'PurchaseCancelDate', 'Cancelled' FROM atranslation t where t.baselanguage = 'en'");
|
||||||
|
await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'PurchaseCouponCode', 'Coupon' FROM atranslation t where t.baselanguage = 'en'");
|
||||||
|
await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'PurchaseNotes', 'Notes' FROM atranslation t where t.baselanguage = 'en'");
|
||||||
|
await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'PurchaseRenewNoticeSent', 'Renew notice sent' FROM atranslation t where t.baselanguage = 'en'");
|
||||||
|
await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'PurchaseQuantity', 'Quantity' FROM atranslation t where t.baselanguage = 'en'");
|
||||||
|
await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'PurchaseVendorData', 'Vendor data' FROM atranslation t where t.baselanguage = 'en'");
|
||||||
|
await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'PurchaseProcessedDate', 'Processed' FROM atranslation t where t.baselanguage = 'en'");
|
||||||
|
|
||||||
|
*/
|
||||||
|
</script>
|
||||||
@@ -45,7 +45,9 @@ export default {
|
|||||||
this.objectId = window.$gz.util.stringToIntOrNull(
|
this.objectId = window.$gz.util.stringToIntOrNull(
|
||||||
this.$route.params.objectId
|
this.$route.params.objectId
|
||||||
);
|
);
|
||||||
this.aForType = window.$gz.util.stringToIntOrNull(this.$route.params.sockType);
|
this.aForType = window.$gz.util.stringToIntOrNull(
|
||||||
|
this.$route.params.sockType
|
||||||
|
);
|
||||||
|
|
||||||
if (this.objectId && this.objectId != 0 && this.aForType) {
|
if (this.objectId && this.objectId != 0 && this.aForType) {
|
||||||
//OBJECTID,AYsockType
|
//OBJECTID,AYsockType
|
||||||
|
|||||||
@@ -372,6 +372,25 @@ namespace Sockeye.Biz
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Purchase
|
||||||
|
{
|
||||||
|
List<FormField> l = new List<FormField>();
|
||||||
|
l.Add(new FormField { TKey = "PurchaseExpireDate", FieldKey = "PurchaseExpireDate" });
|
||||||
|
l.Add(new FormField { TKey = "PurchaseCancelDate", FieldKey = "PurchaseCancelDate" });
|
||||||
|
l.Add(new FormField { TKey = "PurchaseCouponCode", FieldKey = "PurchaseCouponCode" });
|
||||||
|
l.Add(new FormField { TKey = "PurchaseNotes", FieldKey = "PurchaseNotes" });
|
||||||
|
l.Add(new FormField { TKey = "PurchaseVendorData", FieldKey = "PurchaseVendorData" });
|
||||||
|
l.Add(new FormField { TKey = "PurchaseProcessedDate", FieldKey = "PurchaseProcessedDate" });
|
||||||
|
|
||||||
|
l.Add(new FormField { TKey = "Tags", FieldKey = "Tags" });
|
||||||
|
l.Add(new FormField { TKey = "Wiki", FieldKey = "Wiki" });
|
||||||
|
l.Add(new FormField { TKey = "Attachments", FieldKey = "Attachments", Requireable = false });
|
||||||
|
|
||||||
|
|
||||||
|
_formFields.Add(SockType.Purchase.ToString(), l);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
//******************************************************
|
//******************************************************
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -898,7 +898,7 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
|
|||||||
|
|
||||||
|
|
||||||
await ExecQueryAsync("CREATE TABLE apurchase (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, customerid BIGINT NOT NULL REFERENCES acustomer(id) ON DELETE CASCADE, "
|
await ExecQueryAsync("CREATE TABLE apurchase (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, customerid BIGINT NOT NULL REFERENCES acustomer(id) ON DELETE CASCADE, "
|
||||||
+ "vendorid BIGINT NOT NULL REFERENCES avendor(id), productid BIGINT NOT NULL REFERENCES aproduct(id), salesordernumber TEXT, "
|
+ "vendorid BIGINT NOT NULL REFERENCES avendor(id), productid BIGINT NOT NULL REFERENCES aproduct(id), salesordernumber TEXT NOT NULL, "
|
||||||
+ "purchasedate TIMESTAMPTZ NOT NULL, expiredate TIMESTAMPTZ, canceldate TIMESTAMPTZ, couponcode text, notes text, "
|
+ "purchasedate TIMESTAMPTZ NOT NULL, expiredate TIMESTAMPTZ, canceldate TIMESTAMPTZ, couponcode text, notes text, "
|
||||||
+ "renewnoticesent BOOL NOT NULL DEFAULT false, quantity INTEGER NOT NULL DEFAULT 1, "
|
+ "renewnoticesent BOOL NOT NULL DEFAULT false, quantity INTEGER NOT NULL DEFAULT 1, "
|
||||||
+ "vendordata TEXT, processeddate TIMESTAMPTZ, "
|
+ "vendordata TEXT, processeddate TIMESTAMPTZ, "
|
||||||
|
|||||||
Reference in New Issue
Block a user