parent
410bf86913
commit
9b4d8b1c16
src/pages/Ecomerce
|
@ -8,6 +8,7 @@ import VnSelect from 'src/components/common/VnSelect.vue';
|
|||
import { formatDateTitle, formatDate } from 'src/lib/filters.js';
|
||||
import useNotify from 'src/composables/useNotify.js';
|
||||
import { onUserId } from 'src/utils/onUserId';
|
||||
import { useUserStore } from 'stores/user';
|
||||
import { useAppStore } from 'stores/app';
|
||||
import { storeToRefs } from 'pinia';
|
||||
|
||||
|
@ -18,6 +19,7 @@ const route = useRoute();
|
|||
const router = useRouter();
|
||||
const { notify } = useNotify();
|
||||
const appStore = useAppStore();
|
||||
const userStore = useUserStore();
|
||||
const { localeDates, isMobile } = storeToRefs(appStore);
|
||||
|
||||
const stepperRef = ref(null);
|
||||
|
@ -299,6 +301,13 @@ const onPreviousStep = async stepIndex => {
|
|||
|
||||
const submit = async () => {
|
||||
loading.value = true;
|
||||
|
||||
const userId = userStore?.user?.id;
|
||||
|
||||
if (!userId) {
|
||||
throw 'no user id';
|
||||
}
|
||||
|
||||
let query =
|
||||
'CALL myOrder_create(@orderId, #date, #method, #agency, #address); SELECT @orderId;';
|
||||
if (id) {
|
||||
|
@ -311,6 +320,25 @@ const submit = async () => {
|
|||
try {
|
||||
const { date, ...restOfForm } = orderForm.value;
|
||||
const _date = new Date(date);
|
||||
|
||||
if (!id) {
|
||||
|
||||
console.log('orderForm.value', orderForm.value);
|
||||
|
||||
const response = await api.post(
|
||||
'Orders',
|
||||
{
|
||||
sourceApp: 'WEB',
|
||||
landed: new Date(date),
|
||||
clientFk: userId,
|
||||
companyFk: 442, // SELECT defaultCompanyFk FROM orderConfig; (wtf)
|
||||
addressFk: orderForm.value.address,
|
||||
agencyModeFk: 1,
|
||||
},
|
||||
);
|
||||
console.log('response', response);
|
||||
}
|
||||
|
||||
resultSet = await jApi.execQuery(query, { ...restOfForm, date: _date });
|
||||
if (id) {
|
||||
notify(t('orderUpdated'), 'positive');
|
||||
|
|
Loading…
Reference in New Issue