- aggiornamento con proj RISO. postcss, pwa.
This commit is contained in:
@@ -1,27 +1,28 @@
|
||||
import { defineComponent, onMounted, ref, watch } from 'vue'
|
||||
import { tools } from '@tools'
|
||||
import { tools } from '@store/Modules/tools'
|
||||
import { useUserStore } from '@store/UserStore'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useGlobalStore } from '@store/globalStore'
|
||||
import { useProducts } from '@store/Products'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { toolsext } from '@store/Modules/toolsext'
|
||||
import { useQuasar } from 'quasar'
|
||||
import { useQuasar, exportFile } from 'quasar'
|
||||
import { costanti } from '@costanti'
|
||||
import { shared_consts } from '@src/common/shared_vuejs'
|
||||
// import MixinBase from '@src/mixins/mixin-base'
|
||||
import { serv_constants } from '@store/Modules/serv_constants'
|
||||
import { fieldsTable } from '@store/Modules/fieldsTable'
|
||||
|
||||
import { CSingleCart } from '@src/components/CSingleCart'
|
||||
import { CTitleBanner } from '@src/components/CTitleBanner'
|
||||
import { CMyFieldDb } from '@src/components/CMyFieldDb'
|
||||
import type { IOrderCart } from '@src/model';
|
||||
import { ICart, IOrder } from '@src/model'
|
||||
import { CSingleCart } from '../../../components/CSingleCart'
|
||||
import { CMyDialog } from '../../../components/CMyDialog'
|
||||
import { COrdersCart } from '../../../components/COrdersCart'
|
||||
import { CTitleBanner } from '../../../components/CTitleBanner'
|
||||
import { CMyFieldDb } from '../../../components/CMyFieldDb'
|
||||
import type { ISingleProductOrdered } from '@src/model'
|
||||
import { ICart, IOrder, IOrderCart } from '@src/model'
|
||||
|
||||
export default defineComponent({
|
||||
name: 'OrderInfo',
|
||||
components: { CSingleCart, CTitleBanner, CMyFieldDb },
|
||||
components: { CSingleCart, CTitleBanner, CMyFieldDb, COrdersCart, CMyDialog },
|
||||
props: {},
|
||||
setup() {
|
||||
const userStore = useUserStore()
|
||||
@@ -37,15 +38,45 @@ export default defineComponent({
|
||||
const templemail = ref('')
|
||||
|
||||
const cosa = ref(0)
|
||||
const showOrdersCart = ref(false)
|
||||
const idOrdersCartToShow = ref('')
|
||||
|
||||
const arrout = ref(<any[]>[])
|
||||
const listatotali = ref(<any[]>[])
|
||||
|
||||
const showWhichCode = ref(shared_consts.ShowCode.ALL)
|
||||
|
||||
const showWhichCodeOptions = ref([
|
||||
{
|
||||
label: 'Tutti i codici',
|
||||
value: shared_consts.ShowCode.ALL
|
||||
},
|
||||
{
|
||||
label: 'Codice Interno',
|
||||
value: shared_consts.ShowCode.CODE
|
||||
},
|
||||
{
|
||||
label: 'Codice Produttore',
|
||||
value: shared_consts.ShowCode.INTERNAL_CODE
|
||||
}
|
||||
])
|
||||
|
||||
const check_send_email = ref(false)
|
||||
const mostra_codice = ref(false)
|
||||
const mostra_cat = ref(false)
|
||||
const mostra_solo_ordini_produttore = ref(false)
|
||||
|
||||
const initialPagination = ref({
|
||||
sortBy: 'desc',
|
||||
sortBy: 'ind',
|
||||
descending: false,
|
||||
rowsPerPage: 10,
|
||||
rowsPerPage: 0,
|
||||
// rowsNumber: xx if getting data from a server
|
||||
})
|
||||
|
||||
const totalPagination = ref({
|
||||
sortBy: 'codice_interno',
|
||||
descending: false,
|
||||
rowsPerPage: 1000,
|
||||
// rowsNumber: xx if getting data from a server
|
||||
})
|
||||
|
||||
@@ -56,8 +87,81 @@ export default defineComponent({
|
||||
const storeGasordine = ref(<any>'')
|
||||
|
||||
const taborders = ref(shared_consts.OrderStat.IN_CORSO.value)
|
||||
const tabpages = ref(shared_consts.OrderPages.LISTA_TOTALI.value)
|
||||
const statusnow = ref(0)
|
||||
const arrnumstatus = ref(<any[]>[])
|
||||
|
||||
const columns_listafiltrati = ref(<any>[])
|
||||
|
||||
//index, code, productName, qty, singlePrice, subtotalPrice
|
||||
const columns_listaTotali = ref(<any>[
|
||||
{
|
||||
name: 'index',
|
||||
required: true,
|
||||
align: 'left',
|
||||
label: 'Indice',
|
||||
field: 'index',
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
name: 'code',
|
||||
required: true,
|
||||
align: 'left',
|
||||
label: 'Codice',
|
||||
field: 'code',
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
name: 'codice_interno',
|
||||
required: false,
|
||||
align: 'left',
|
||||
label: 'Codice Produttore',
|
||||
field: 'codice_interno',
|
||||
sortable: true,
|
||||
},
|
||||
{
|
||||
name: 'productName',
|
||||
required: true,
|
||||
align: 'left',
|
||||
label: 'Prodotto',
|
||||
field: 'productName',
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
name: 'strSubCatProds',
|
||||
required: true,
|
||||
align: 'left',
|
||||
label: 'Categoria',
|
||||
field: 'strSubCatProds',
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
name: 'qty',
|
||||
required: true,
|
||||
align: 'center',
|
||||
label: 'Qta',
|
||||
field: 'qty',
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
name: 'singlePrice',
|
||||
required: true,
|
||||
align: 'center',
|
||||
label: 'Prezzo',
|
||||
field: 'singlePrice',
|
||||
sortable: true,
|
||||
},
|
||||
{
|
||||
name: 'subtotalPrice',
|
||||
required: true,
|
||||
align: 'center',
|
||||
label: 'Totale',
|
||||
field: 'subtotalPrice',
|
||||
sortable: true
|
||||
}
|
||||
|
||||
])
|
||||
|
||||
const columns = ref(<any>[
|
||||
{
|
||||
name: 'ind',
|
||||
@@ -193,14 +297,40 @@ export default defineComponent({
|
||||
})
|
||||
|
||||
watch(() => taborders.value, (newval, oldval) => {
|
||||
tools.setCookie(tools.COOK_TABORD, taborders.value.toString())
|
||||
updateorders(false)
|
||||
})
|
||||
watch(() => tabpages.value, (newval, oldval) => {
|
||||
tools.setCookie(tools.COOK_TABPAGES, tabpages.value.toString())
|
||||
if (tabpages.value === shared_consts.OrderPages.LISTA_TOTALI.value) {
|
||||
taborders.value = -1
|
||||
}
|
||||
updateorders(true)
|
||||
})
|
||||
|
||||
watch(() => storeGasordine.value, (newval, oldval) => {
|
||||
tools.setCookie(tools.COOK_SELGAS, storeGasordine.value)
|
||||
updateorders(true)
|
||||
})
|
||||
|
||||
watch(() => mostra_codice.value, (newval, oldval) => {
|
||||
tools.setCookie(tools.COOK_SHOWCODICE, mostra_codice.value ? '1' : '0')
|
||||
updateorders(true)
|
||||
})
|
||||
watch(() => mostra_cat.value, (newval, oldval) => {
|
||||
tools.setCookie(tools.COOK_SHOWCAT, mostra_cat.value ? '1' : '0')
|
||||
updateorders(true)
|
||||
})
|
||||
watch(() => showWhichCode.value, (newval, oldval) => {
|
||||
tools.setCookie(tools.COOK_SHOWCODE, showWhichCode.value.toString())
|
||||
updateorders(true)
|
||||
})
|
||||
|
||||
watch(() => mostra_solo_ordini_produttore.value, (newval, oldval) => {
|
||||
tools.setCookie(tools.COOK_SHOWORDPROD, mostra_solo_ordini_produttore.value ? '1' : '0')
|
||||
updateorders(true)
|
||||
})
|
||||
|
||||
// const { setValDb, getValDb } = MixinBase()
|
||||
|
||||
function getCols(props: any) {
|
||||
@@ -214,6 +344,47 @@ export default defineComponent({
|
||||
return ris
|
||||
}
|
||||
|
||||
// Creami una lista di tutti i prodotti, con i totali delle quantità e il prezzo totale
|
||||
function getListProductBySumQuantity(): ISingleProductOrdered[] {
|
||||
const listproductstotal = productStore.getListProductBySumQuantity(storeGasordine.value)
|
||||
|
||||
if (listproductstotal) {
|
||||
// Calculate totals
|
||||
const totals: ISingleProductOrdered = {
|
||||
index: -1,
|
||||
code: '',
|
||||
codice_interno: '',
|
||||
idProduct: '',
|
||||
subCat: '',
|
||||
strSubCatProds: '',
|
||||
productName: 'TOTALI',
|
||||
qty: listproductstotal.reduce((total: number, rec: any) => total + rec.qty, 0),
|
||||
singlePrice: 0,
|
||||
subtotalPrice: listproductstotal.reduce((total: number, rec: any) => total + rec.subtotalPrice, 0),
|
||||
};
|
||||
|
||||
let rowsWithTotals: any = [...listproductstotal];
|
||||
|
||||
if (tools.isManager()) {
|
||||
// Combine orders and totals
|
||||
rowsWithTotals.push(totals);
|
||||
}
|
||||
|
||||
// Supponendo che rowsWithTotals sia il tuo array di record
|
||||
rowsWithTotals.forEach((record: any, index: number) => {
|
||||
record.ind = index;
|
||||
});
|
||||
|
||||
return rowsWithTotals;
|
||||
}
|
||||
|
||||
return listproductstotal
|
||||
}
|
||||
|
||||
function getTotaleOrdineByOrdId(id: string, idGasordine: string): string {
|
||||
return productStore.getTotaleOrdineByOrdId(id, idGasordine, mostra_solo_ordini_produttore.value).toFixed(2)
|
||||
}
|
||||
|
||||
function getOrdersCartWithTotals(): any[] {
|
||||
const orderscart = getOrdersCart();
|
||||
|
||||
@@ -233,7 +404,7 @@ export default defineComponent({
|
||||
totalPriceCalc: orderscart.reduce((total: number, rec: any) => total + rec.totalPriceCalc, 0),
|
||||
};
|
||||
|
||||
const rowsWithTotals: any = [...orderscart];
|
||||
let rowsWithTotals: any = [...orderscart];
|
||||
|
||||
if (tools.isManager()) {
|
||||
// Combine orders and totals
|
||||
@@ -258,26 +429,44 @@ export default defineComponent({
|
||||
}
|
||||
|
||||
function updateorders(updatetab: boolean) {
|
||||
arrout.value = []
|
||||
|
||||
myorderscart.value = getOrdersCart()
|
||||
if (myorderscart.value) {
|
||||
for (const orderscart of myorderscart.value) {
|
||||
myarrrec.value[orderscart._id] = Object.keys(orderscart)
|
||||
// Rimuovi dalla lista columns_listaTotali il record "codice_interno" se mostra_codice.value = false
|
||||
columns_listafiltrati.value = columns_listaTotali.value.filter((column: any) => {
|
||||
let show = false
|
||||
if (showWhichCode.value === shared_consts.ShowCode.ALL) {
|
||||
show = true
|
||||
} else if (showWhichCode.value === shared_consts.ShowCode.CODE) {
|
||||
show = (column.name !== 'codice_interno')
|
||||
} else if (showWhichCode.value === shared_consts.ShowCode.INTERNAL_CODE) {
|
||||
show = (column.name !== 'code')
|
||||
}
|
||||
}
|
||||
return show
|
||||
})
|
||||
|
||||
if (updatetab) {
|
||||
const allorders = getAllOrdersCart()
|
||||
for (const status of [15, 2, 3, 4, 5, 6, 7, 8, 10]) {
|
||||
arrnumstatus.value[status] = allorders.filter((rec) => (rec.status === status)).reduce((sum, item) => sum + 1, 0)
|
||||
|
||||
if (tabpages.value === shared_consts.OrderPages.ORDINI.value) {
|
||||
arrout.value = []
|
||||
|
||||
myorderscart.value = getOrdersCart()
|
||||
if (myorderscart.value) {
|
||||
for (const orderscart of myorderscart.value) {
|
||||
myarrrec.value[orderscart._id] = Object.keys(orderscart)
|
||||
}
|
||||
}
|
||||
|
||||
selectfirstavailable()
|
||||
if (updatetab) {
|
||||
const allorders = getAllOrdersCart()
|
||||
for (const status of [15, 2, 3, 4, 5, 6, 7, 8, 10]) {
|
||||
arrnumstatus.value[status] = allorders.filter((rec) => (rec.status === status)).reduce((sum, item) => sum + 1, 0)
|
||||
}
|
||||
|
||||
selectfirstavailable()
|
||||
}
|
||||
|
||||
arrout.value = getOrdersCartWithTotals()
|
||||
} else if (tabpages.value === shared_consts.OrderPages.LISTA_TOTALI.value) {
|
||||
listatotali.value = getListProductBySumQuantity()
|
||||
}
|
||||
|
||||
arrout.value = getOrdersCartWithTotals()
|
||||
|
||||
}
|
||||
|
||||
function selectfirstavailable() {
|
||||
@@ -293,18 +482,30 @@ export default defineComponent({
|
||||
|
||||
async function mounted() {
|
||||
|
||||
taborders.value = -1
|
||||
taborders.value = tools.getCookie(tools.COOK_TABORD, shared_consts.OrderStat.IN_CORSO.value, true)
|
||||
if (tools.isManager())
|
||||
tabpages.value = tools.getCookie(tools.COOK_TABPAGES, shared_consts.OrderPages.LISTA_TOTALI.value, true)
|
||||
else
|
||||
tabpages.value = shared_consts.OrderPages.ORDINI.value
|
||||
|
||||
storeGasordine.value = tools.getCookie(tools.COOK_SELGAS, '')
|
||||
|
||||
mostra_codice.value = tools.getCookie(tools.COOK_SHOWCODICE, '1') === '1'
|
||||
mostra_cat.value = tools.getCookie(tools.COOK_SHOWCAT, '1') === '1'
|
||||
mostra_solo_ordini_produttore.value = tools.getCookie(tools.COOK_SHOWORDPROD, '1') === '1'
|
||||
showWhichCode.value = tools.getCookie(tools.COOK_SHOWCODE, shared_consts.ShowCode.ALL, true)
|
||||
|
||||
await userStore.newsletterload(false)
|
||||
await productStore.loadProducts()
|
||||
|
||||
|
||||
updateorders(true)
|
||||
|
||||
if (taborders.value === -1)
|
||||
taborders.value = shared_consts.OrderStat.IN_CORSO.value
|
||||
|
||||
if (tabpages.value === -1)
|
||||
tabpages.value = shared_consts.OrderPages.LISTA_TOTALI.value
|
||||
|
||||
|
||||
if (tools.isManager()) {
|
||||
columns.value = [...columns_Admin.value]
|
||||
@@ -358,7 +559,7 @@ export default defineComponent({
|
||||
const statusStr = shared_consts.getStatusStr(status)
|
||||
|
||||
$q.dialog({
|
||||
message: 'Impostare l\'ordine di ' + tools.getNomeUtenteByRecUser(order.user) + ' n. ' + order.numorder + ' ' + statusStr + ' ?',
|
||||
message: 'Impostare l\'ordine di ' + tools.getNomeUtenteByRecUser(order.user!) + ' n. ' + order.numorder + ' ' + statusStr + ' ?',
|
||||
ok: {
|
||||
label: t('dialog.yes'),
|
||||
push: true
|
||||
@@ -468,6 +669,31 @@ export default defineComponent({
|
||||
})
|
||||
}
|
||||
|
||||
function exportListaTotali() {
|
||||
// console.log('row', serverData.value)
|
||||
// console.log('mycolumns.value', mycolumns.value)
|
||||
// naive encoding to csv format
|
||||
const content = [columns_listafiltrati.value.map((col: any) => (col.label))].concat(
|
||||
listatotali.value.map((row: any) => columns_listafiltrati.value.map((col: any) => (
|
||||
row[col.field]
|
||||
)).join(','))
|
||||
).join('\r\n')
|
||||
|
||||
const status = exportFile(
|
||||
'lista-totali-' + productStore.getGasordineNameById(storeGasordine.value) + '_' + tools.getstrYYMMDDDate(tools.getDateNow()) + '.csv',
|
||||
content,
|
||||
'text/csv'
|
||||
)
|
||||
|
||||
if (status !== true) {
|
||||
$q.notify({
|
||||
message: 'Il Browser ha negato il download del file.',
|
||||
color: 'negative',
|
||||
icon: 'warning'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(mounted)
|
||||
|
||||
return {
|
||||
@@ -479,6 +705,7 @@ export default defineComponent({
|
||||
globalStore,
|
||||
columns,
|
||||
taborders,
|
||||
tabpages,
|
||||
arrnumstatus,
|
||||
clickFunz,
|
||||
getOrdersCart,
|
||||
@@ -499,6 +726,18 @@ export default defineComponent({
|
||||
arrout,
|
||||
check_send_email,
|
||||
ConfermaOrdini,
|
||||
mostra_codice,
|
||||
mostra_cat,
|
||||
mostra_solo_ordini_produttore,
|
||||
listatotali,
|
||||
columns_listafiltrati,
|
||||
showWhichCode,
|
||||
showWhichCodeOptions,
|
||||
getTotaleOrdineByOrdId,
|
||||
showOrdersCart,
|
||||
idOrdersCartToShow,
|
||||
exportListaTotali,
|
||||
totalPagination,
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user