From 89d095d1c9a66726b38591e989583ffcbd1e33cc Mon Sep 17 00:00:00 2001 From: Surya Paolo Date: Tue, 2 Jan 2024 15:24:57 +0100 Subject: [PATCH] ++ Cassa - parte 1 --- src/common/shared_vuejs.ts | 21 + src/components/CProductCard/CProductCard.scss | 24 + src/components/CProductCard/CProductCard.ts | 11 +- src/components/CProductCard/CProductCard.vue | 557 +++++++----------- src/db/lang/ws_it.js | 1 + src/model/Products.ts | 3 + src/rootgen/admin/cash/cash.scss | 0 src/rootgen/admin/cash/cash.ts | 24 + src/rootgen/admin/cash/cash.vue | 32 + src/router/route-config.ts | 2 +- src/router/routesECommerce.ts | 23 + src/statics/lang/it.js | 22 +- src/store/Modules/fieldsTable.ts | 77 ++- src/store/Modules/toolsext.ts | 1 + src/store/Products.ts | 3 +- src/store/globalStore.ts | 3 + src/views/ecommerce/orderInfo/orderInfo.ts | 6 +- .../ecommerce/productsList/productsList.ts | 7 +- 18 files changed, 441 insertions(+), 376 deletions(-) create mode 100755 src/rootgen/admin/cash/cash.scss create mode 100755 src/rootgen/admin/cash/cash.ts create mode 100755 src/rootgen/admin/cash/cash.vue diff --git a/src/common/shared_vuejs.ts b/src/common/shared_vuejs.ts index e0b8256c..a93a6710 100755 --- a/src/common/shared_vuejs.ts +++ b/src/common/shared_vuejs.ts @@ -31,6 +31,27 @@ export const shared_consts = { PEZZI: 4, }, + TYPECASH: { + NESSUNO: 0, + IN: 1, + OUT: 2, + }, + + TypeCashStr: [ + { + label: '[Nessuno]', + value: 0, + }, + { + label: 'Ingresso', + value: 1, + }, + { + label: 'Uscita', + value: 2, + }, + ], + Units_Of_Measure_ListBox: [ { label: '[Nessuno]', diff --git a/src/components/CProductCard/CProductCard.scss b/src/components/CProductCard/CProductCard.scss index 20d01f56..1f2c348e 100755 --- a/src/components/CProductCard/CProductCard.scss +++ b/src/components/CProductCard/CProductCard.scss @@ -97,3 +97,27 @@ max-height: 100%; } +.titolo_prod{ + cursor: pointer; +} + +.image-section { + justify-content: center; +} + +.image-container { + width: 300px; + height: 300px; + position: relative; + overflow: hidden; + @media (max-width: 718px) { + width: 200px; + height: 200px; + } +} + +.img-pic { + width: 100%; + height: 100%; + object-fit: cover; +} \ No newline at end of file diff --git a/src/components/CProductCard/CProductCard.ts b/src/components/CProductCard/CProductCard.ts index 44914209..e3e4c2c7 100755 --- a/src/components/CProductCard/CProductCard.ts +++ b/src/components/CProductCard/CProductCard.ts @@ -15,6 +15,7 @@ import { tools } from '@store/Modules/tools' import { useProducts } from '@store/Products' import { shared_consts } from '@src/common/shared_vuejs' +import { useRouter } from 'vue-router' export default defineComponent({ name: 'CProductCard', @@ -53,6 +54,8 @@ export default defineComponent({ const site = ref(globalStore.site) + const $router = useRouter() + const fullscreenImage = ref(null) let myorder = reactive({ @@ -293,6 +296,7 @@ export default defineComponent({ function load() { initproduct() updateproduct() + // console.log('Load', myproduct.value.name) // console.log('created Cproductcard', code) @@ -406,6 +410,10 @@ export default defineComponent({ fullscreenImage.value.fullscreenImage.style.transform = 'scale(1)'; } + function naviga(path: string) { + $router.push(path) + } + onMounted(mounted) onBeforeUnmount(beforeDestroy) @@ -450,7 +458,8 @@ export default defineComponent({ onTouchStart, onTouchMove, onTouchEnd, - + $router, + naviga, } } }) diff --git a/src/components/CProductCard/CProductCard.vue b/src/components/CProductCard/CProductCard.vue index 1ee4b93b..a8c5232c 100755 --- a/src/components/CProductCard/CProductCard.vue +++ b/src/components/CProductCard/CProductCard.vue @@ -1,163 +1,120 @@ - + - + @@ -558,12 +442,7 @@ - + Data Persona @@ -573,11 +452,7 @@ - +
{{ func_tools.getDateTimeShortStr(ordcart.created_at) }} @@ -595,22 +470,14 @@
- - {{ singleord.order.quantity }} - - {{ singleord.order.quantitypreordered }} + + {{ singleord.order.quantity }} + + {{ singleord.order.quantitypreordered }}
@@ -632,38 +499,14 @@ - -
- + +
+
- +
diff --git a/src/db/lang/ws_it.js b/src/db/lang/ws_it.js index 737bda79..aeab2813 100755 --- a/src/db/lang/ws_it.js +++ b/src/db/lang/ws_it.js @@ -31,6 +31,7 @@ const msg_website_it = { producer: 'Produttore', orderinfo: 'Ordini Effettuati', products: 'Prodotti', + cash: 'Cassa', productInfos: 'Info Prodotti', listinoprodotti: 'Listino Prodotti', productslist: 'Lista Prodotti', diff --git a/src/model/Products.ts b/src/model/Products.ts index 26556089..7d721cf4 100755 --- a/src/model/Products.ts +++ b/src/model/Products.ts @@ -17,6 +17,8 @@ export interface IProductInfo { date?: Date, icon?: string, img?: string + ingredienti?: string, + valori_nutrizionali?: string, } export interface IProduct { @@ -133,6 +135,7 @@ export interface IStorehouse { _id?: any idapp?: string name?: string, + username?: string, description?: string, referent?: string, address?: string, diff --git a/src/rootgen/admin/cash/cash.scss b/src/rootgen/admin/cash/cash.scss new file mode 100755 index 00000000..e69de29b diff --git a/src/rootgen/admin/cash/cash.ts b/src/rootgen/admin/cash/cash.ts new file mode 100755 index 00000000..3cc52450 --- /dev/null +++ b/src/rootgen/admin/cash/cash.ts @@ -0,0 +1,24 @@ +import { defineComponent } from 'vue' + +import { CImgText } from '../../../components/CImgText/index' +import { CCard } from '@/components/CCard' +import { CMyPage } from '@/components/CMyPage' +import { CTitleBanner } from '@/components/CTitleBanner' +import { CGridTableRec } from '@/components/CGridTableRec' + +import { colTableCash } from '@src/store/Modules/fieldsTable' +import MixinMetaTags from '@/mixins/mixin-metatags' + +export default defineComponent({ + name: 'Cash', + components: { CImgText, CCard, CMyPage, CTitleBanner, CGridTableRec }, + setup() { + + const { setmeta } = MixinMetaTags() + + return { + colTableCash, + setmeta, + } + } +}) diff --git a/src/rootgen/admin/cash/cash.vue b/src/rootgen/admin/cash/cash.vue new file mode 100755 index 00000000..f1758201 --- /dev/null +++ b/src/rootgen/admin/cash/cash.vue @@ -0,0 +1,32 @@ + + + diff --git a/src/router/route-config.ts b/src/router/route-config.ts index a595249b..a7ce7bb5 100755 --- a/src/router/route-config.ts +++ b/src/router/route-config.ts @@ -38,7 +38,7 @@ export const cfgrouter = { tools.addRoute(arrroutes, route) } - console.log('getmenu', arrroutes) + // console.log('getmenu', arrroutes) return arrroutes }, diff --git a/src/router/routesECommerce.ts b/src/router/routesECommerce.ts index 954770ed..b42ad495 100644 --- a/src/router/routesECommerce.ts +++ b/src/router/routesECommerce.ts @@ -83,6 +83,20 @@ function getRoutesEcomm(site: ISites) { onlyManager: true, onlyEditor: true }, + { + active: true, + order: 30, + path: '/admin/ecommerce/cash', + materialIcon: 'fas fa-cash-register', + name: 'pages.cash', + component: () => import('@/rootgen/admin/cash/cash.vue'), + inmenu: true, + submenu: true, + level_parent: 0, + level_child: 0.5, + onlyManager: true, + onlyEditor: true + }, { active: true, order: 30, @@ -231,6 +245,15 @@ function getRoutesEcomm(site: ISites) { inmenu: false, infooter: false, }, + { + active: true, + order: 30, + path: '/admin/ecommerce/cash', + name: 'pages.cash', + component: () => import('@/rootgen/admin/cash/cash.vue'), + inmenu: false, + infooter: false, + }, { active: true, order: 31, diff --git a/src/statics/lang/it.js b/src/statics/lang/it.js index 07775c47..64a95101 100755 --- a/src/statics/lang/it.js +++ b/src/statics/lang/it.js @@ -79,7 +79,7 @@ const msg_it = { addcart: '+{qta}', subcart: '-{qta}', origine: 'Origine', - ingredienti: 'ingredienti', + ingredienti: 'Ingredienti', valori_nutrizionali: 'Valori Nutrizionali', note: 'Note', codice_EAN: 'EAN', @@ -1715,7 +1715,25 @@ const msg_it = { x_prodotti_gas: '{qta} prodotti', x_prodotti_bottega: '{qta} prodotti', tutti: 'Tutti', - } + }, + orderscart: { + numorder: 'Ordine', + totalQty: 'totalQty', + totalQtyPreordered: 'totalQty PreOrd', + }, + cash: { + creatorUserId: 'Creatore', + date_payment: 'Data Pagamento', + type: 'Entrata/Uscita', + descr: 'Descrizione', + internal: 'Interno', + note: 'Note', + fromUserId: 'Mittente', + toUserId: 'Destinatario', + orderscart: 'Ordine', + confirmed: 'Confermato', + causale: 'Causale', + }, }, }; diff --git a/src/store/Modules/fieldsTable.ts b/src/store/Modules/fieldsTable.ts index 4c239230..660c6172 100755 --- a/src/store/Modules/fieldsTable.ts +++ b/src/store/Modules/fieldsTable.ts @@ -1685,7 +1685,7 @@ export const colTableSites = [ AddCol({ name: 'telegram_support_chat', label_trans: 'sites.telegram_support_chat', fieldtype: costanti.FieldType.string }), AddCol({ name: 'telegram_key_test', label_trans: 'sites.telegram_key_test', fieldtype: costanti.FieldType.string }), AddCol({ name: 'load_process_telegram_test', label_trans: 'sites.load_process_telegram_test', fieldtype: costanti.FieldType.boolean }), - AddCol({ name: 'load_process_telegramt', label_trans: 'sites.load_process_telegram', fieldtype: costanti.FieldType.boolean}), + AddCol({ name: 'load_process_telegramt', label_trans: 'sites.load_process_telegram', fieldtype: costanti.FieldType.boolean }), AddCol({ name: 'telegram_bot_name_test', label_trans: 'sites.telegram_bot_name_test', @@ -1997,17 +1997,28 @@ export const colTableProductInfos = [ AddCol({ name: 'size', label_trans: 'products.size' }), AddCol({ name: 'weight', label_trans: 'products.weight', fieldtype: costanti.FieldType.number }), AddCol({ name: 'vegan', label_trans: 'products.vegan', fieldtype: costanti.FieldType.boolean }), - AddCol({ name: 'unit', label_trans: 'products.unit', - fieldtype: costanti.FieldType.select, jointable: 'units', }), + AddCol({ + name: 'unit', label_trans: 'products.unit', + fieldtype: costanti.FieldType.select, jointable: 'units', + }), AddCol({ name: 'stars', label_trans: 'products.stars', fieldtype: costanti.FieldType.number }), AddCol({ name: 'date', label_trans: 'products.date', fieldtype: costanti.FieldType.date }), - AddCol({ name: 'ingredienti', label_trans: 'products.ingredienti' }), - AddCol({ name: 'valori_nutrizionali', label_trans: 'products.valori_nutrizionali' }), - AddCol({ name: 'note', label_trans: 'products.note' }), + AddCol({ name: 'ingredienti', label_trans: 'products.ingredienti', fieldtype: costanti.FieldType.html }), + AddCol({ name: 'valori_nutrizionali', label_trans: 'products.valori_nutrizionali', fieldtype: costanti.FieldType.html }), + AddCol({ name: 'note', label_trans: 'products.note', fieldtype: costanti.FieldType.html }), AddCol(DeleteRec), AddCol(DuplicateRec), ] +export const colTableOrdersCart = [ + AddCol({ name: '_id', label_trans: 'others.value' }), + AddCol({ name: 'numorder', label_trans: 'orderscart.numorder', fieldtype: costanti.FieldType.boolean }), + AddCol({ name: 'totalQty', label_trans: 'orderscart.totalQty', fieldtype: costanti.FieldType.number }), + AddCol({ name: 'totalQtyPreordered', label_trans: 'orderscart.totalQtyPreordered', fieldtype: costanti.FieldType.number }), + AddCol({ name: 'totalPrice', label_trans: 'orderscart.totalPrice', fieldtype: costanti.FieldType.number }), + AddCol({ name: 'status', label_trans: 'orderscart.status', fieldtype: costanti.FieldType.number }), +] + export const colTableProducts = [ AddCol({ name: 'active', label_trans: 'products.active', fieldtype: costanti.FieldType.boolean }), AddCol({ @@ -2375,6 +2386,37 @@ const colTableEvents = [ AddCol(DuplicateRec), ] +export const colTableCash = [ + AddCol({ name: '_id', label_trans: 'event._id' }), + AddCol({ name: 'creatorUserId', label_trans: 'order.users', fieldtype: costanti.FieldType.select, jointable: 'users' }), + AddCol({ + name: 'idCashCategory', + label_trans: 'Category.idCashCategory', + fieldtype: costanti.FieldType.select, + jointable: 'cashcategory', + }), + AddCol({ name: 'fromUserId', label_trans: 'cash.fromUserId', fieldtype: costanti.FieldType.select, jointable: 'users' }), + AddCol({ name: 'toUserId', label_trans: 'cash.toUserId', fieldtype: costanti.FieldType.select, jointable: 'users' }), + AddCol({ name: 'idOrdersCart', label_trans: 'cash.orderscart', fieldtype: costanti.FieldType.select, jointable: 'orderscart' }), + AddCol({ name: 'type', label_trans: 'cash.type', fieldtype: costanti.FieldType.select, jointable: toolsext.TABTYPECASH }), + AddCol({ + name: 'date_payment', label_trans: 'cash.date_payment', fieldtype: costanti.FieldType.onlydate, + sortable: true, + }), + AddCol({ name: 'price', label_trans: 'products.price', fieldtype: costanti.FieldType.number }), + AddCol({ name: 'causale', label_trans: 'cash.causale' }), + AddCol({ name: 'note', label_trans: 'cash.note' }), + AddCol({ name: 'internal', label_trans: 'cash.internal', fieldtype: costanti.FieldType.boolean }), + AddCol({ name: 'extra', label_trans: 'cash.extra', fieldtype: costanti.FieldType.boolean }), + AddCol({ name: 'confirmed', label_trans: 'cash.confirmed', fieldtype: costanti.FieldType.boolean }), + AddCol({ + name: 'date_created', label_trans: 'reg.pub_created', fieldtype: costanti.FieldType.onlydate, + sortable: true, + }), + AddCol(DeleteRec), + AddCol(DuplicateRec), +] + export const fields = { colSettings: [ AddCol({ name: 'key', label_trans: 'col.label' }), @@ -3120,8 +3162,6 @@ export const colTableExtraList = [ AddCol(DuplicateRec), ] -export const colTableCash = [] - export const colTableCashCategory = [ AddCol({ name: 'descr', label_trans: 'pages.description' }), AddCol({ name: 'notes', label_trans: 'reg.note' }), @@ -3642,6 +3682,13 @@ export const fieldsTable = { colkey: '_id', collabel: '_id', }, + { + value: 'orderscart', + label: 'Ordini', + columns: colTableOrdersCart, + colkey: '_id', + collabel: 'numorder', + }, { value: 'productinfos', label: 'Info Prodotti', @@ -3656,6 +3703,13 @@ export const fieldsTable = { colkey: '_id', collabel: 'name', }, + { + value: 'cashs', + label: 'Cassa', + columns: colTableCash, + colkey: '_id', + collabel: 'causale', + }, { value: 'departments', label: 'Uffici', @@ -3874,6 +3928,13 @@ export const fieldsTable = { colicon: 'icon', noshow: true, }, + { + value: toolsext.TABTYPECASH, + label: 'Ingresso/Uscita', + columns: colTableGeneric, + colkey: 'value', + collabel: 'label', + }, { value: 'confsite_opt', label: 'Configura Opzioni Sito', diff --git a/src/store/Modules/toolsext.ts b/src/store/Modules/toolsext.ts index 2c079d1e..332ca508 100755 --- a/src/store/Modules/toolsext.ts +++ b/src/store/Modules/toolsext.ts @@ -98,6 +98,7 @@ export const toolsext = { TABCIRCUITS: 'circuits', TABUNITS: 'units', SERVKEY_VERS: 'vers', + TABTYPECASH: 'typecash', ERR_GENERICO: -1, ERR_SERVERFETCH: -2, diff --git a/src/store/Products.ts b/src/store/Products.ts index 17c445e7..b2ccf5fc 100755 --- a/src/store/Products.ts +++ b/src/store/Products.ts @@ -138,7 +138,6 @@ export const useProducts = defineStore('Products', { }, - getProductById: (state: IProductsState) => (id: string): IProduct => { const prod = state.products.find((prod: IProduct) => prod._id === id) return prod ? prod : getRecordProductEmpty() @@ -692,7 +691,7 @@ export const useProducts = defineStore('Products', { let ris = null - ris = await Api.SendReq('/cart/' + userStore.my._id + '/ordercartstatus', 'POST', { order_id, status }) + ris = await Api.SendReq('/cart/' + userStore.my._id + '/ordercartstatus', 'POST', { order_id, status, options }) .then((res) => { this.updateDataProduct(res) diff --git a/src/store/globalStore.ts b/src/store/globalStore.ts index 2ae77540..b410a1ff 100644 --- a/src/store/globalStore.ts +++ b/src/store/globalStore.ts @@ -315,6 +315,7 @@ export const useGlobalStore = defineStore('GlobalStore', { else if (table === 'storehouses') ris = state.storehouses else if (table === 'providers') ris = state.providers else if (table === 'productinfos') ris = Products.productInfos + else if (table === 'product') ris = Products.products else if (table === 'gasordines') ris = state.gasordines else if (table === 'scontisticas') ris = state.scontisticas else if (table === 'groups') ris = state.groups @@ -1542,6 +1543,7 @@ export const useGlobalStore = defineStore('GlobalStore', { this.paymenttypes = (res.data.paymenttypes) ? [...res.data.paymenttypes] : [] this.gallery = (res.data.gallery) ? [...res.data.gallery] : [] this.calzoom = (res.data.calzoom) ? [...res.data.calzoom] : [] + Products.products = (res.data.products) ? [...res.data.products] : [] Products.productInfos = (res.data.productInfos) ? [...res.data.productInfos] : [] this.producers = (res.data.producers) ? [...res.data.producers] : [] this.storehouses = (res.data.storehouses) ? [...res.data.storehouses] : [] @@ -1849,6 +1851,7 @@ export const useGlobalStore = defineStore('GlobalStore', { else if (table === toolsext.TABLOCACCOM) myarr = shared_consts.LocationAccom else if (table === toolsext.TABPREF) myarr = shared_consts.Preferences else if (table === toolsext.TABUNITS) myarr = shared_consts.Units_Of_Measure_ListBox + else if (table === toolsext.TABTYPECASH) myarr = shared_consts.TypeCashStr else if (table === 'usernotifs') myarr = shared_consts.UsersNotif_Adv_List else if (table === 'typenotifs') myarr = shared_consts.TypeNotifs_Arr else myarr = this.getListByTable(table, value2) diff --git a/src/views/ecommerce/orderInfo/orderInfo.ts b/src/views/ecommerce/orderInfo/orderInfo.ts index 75ef25db..5be53ec1 100755 --- a/src/views/ecommerce/orderInfo/orderInfo.ts +++ b/src/views/ecommerce/orderInfo/orderInfo.ts @@ -300,7 +300,11 @@ export default defineComponent({ title: 'Ordine' }).onOk(async () => { - statusnow.value = await productStore.UpdateOrderCartStatus({ order_id: order._id, status }) + let options = { + // userIdStore: order.items ? order.items[0].order.storehouse.username : '', + } + + statusnow.value = await productStore.UpdateOrderCartStatus({ order_id: order._id, status, options }) if (statusnow.value === status) { order.status = statusnow.value diff --git a/src/views/ecommerce/productsList/productsList.ts b/src/views/ecommerce/productsList/productsList.ts index 01810d85..e8928190 100755 --- a/src/views/ecommerce/productsList/productsList.ts +++ b/src/views/ecommerce/productsList/productsList.ts @@ -39,18 +39,17 @@ export default defineComponent({ const getArrProducts = computed(() => { let arrprod = productStore.getProducts(cosa.value) let catstr = cat.value; - if ((!search.value || (search.value && search.value.length < 2)) && !catstr) { + let lowerSearchText = search.value.toLowerCase().trim(); + if ((!lowerSearchText || (lowerSearchText && lowerSearchText.length < 2)) && !catstr) { return arrprod } - let lowerSearchText = search.value.toLowerCase(); - return arrprod.filter((product: IProduct) => { let lowerName = product.productInfo.name!.toLowerCase(); let hasCategoria = !catstr || (catstr && product.productInfo.idCatProds?.includes(catstr)); // Use a regular expression to match whole words - let codeMatch = new RegExp(`\\b${search.value}\\b`, 'i'); + let codeMatch = new RegExp(`\\b${lowerSearchText}\\b`, 'i'); let nameMatch = new RegExp(`\\b${lowerSearchText}`, 'i'); // Check if any word in lowerName starts with lowerSearchText