PCB
This commit is contained in:
@@ -1,149 +1,126 @@
|
||||
import Vue from 'vue'
|
||||
import { Component, Watch } from 'vue-property-decorator'
|
||||
import { defineComponent, onMounted, ref } from 'vue'
|
||||
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 '@/boot/i18n'
|
||||
import { toolsext } from '@store/Modules/toolsext'
|
||||
import { useQuasar } from 'quasar'
|
||||
import { costanti } from '@costanti'
|
||||
import { shared_consts } from '@src/common/shared_vuejs'
|
||||
// import MixinBase from '@src/mixins/mixin-base'
|
||||
|
||||
import { SingleProject } from '../../../components/projects/SingleProject/index'
|
||||
import { CTodo } from '../../../components/todos/CTodo'
|
||||
|
||||
import { CProgress } from '../../../components/CProgress'
|
||||
import { CDate } from '../../../components/CDate'
|
||||
import { Action } from 'vuex'
|
||||
import Products from '@src/store/Modules/Products'
|
||||
import { CSingleCart } from '../../../components/CSingleCart'
|
||||
import { CTitleBanner } from '@components'
|
||||
import { tools } from '@src/store/Modules/tools'
|
||||
import { ICart, IOrderCart } from '@src/model'
|
||||
import MixinBase from '@src/mixins/mixin-base'
|
||||
import { shared_consts } from '@src/common/shared_vuejs'
|
||||
|
||||
const namespace: string = 'Products'
|
||||
export default defineComponent({
|
||||
name: 'OrderInfo',
|
||||
components: { CSingleCart, CTitleBanner },
|
||||
props: {},
|
||||
setup() {
|
||||
const userStore = useUserStore()
|
||||
const globalStore = useGlobalStore()
|
||||
const productStore = useProducts()
|
||||
const $router = useRouter()
|
||||
const $q = useQuasar()
|
||||
const { t } = useI18n();
|
||||
|
||||
@Component({
|
||||
name: 'checkOut',
|
||||
components: { SingleProject, CProgress, CTodo, CDate, CSingleCart, CTitleBanner },
|
||||
filters: {
|
||||
capitalize(value) {
|
||||
if (!value) {
|
||||
return ''
|
||||
const myorderscart = ref(<IOrderCart[] | undefined>[])
|
||||
const myarrrec = ref(<any>{})
|
||||
const myoldrec = ref(<any>{})
|
||||
|
||||
const conferma_carrello = ref(false)
|
||||
const conferma_ordine = ref(false)
|
||||
|
||||
const taborders = ref('incorso')
|
||||
const statusnow = ref(0)
|
||||
const arrnumstatus = ref(<any[]>[])
|
||||
const columns = ref(<any>[
|
||||
{
|
||||
name: 'numorder',
|
||||
required: true,
|
||||
align: 'left',
|
||||
label: 'Numero Ordine',
|
||||
field: 'numorder',
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
name: 'nameSurname',
|
||||
required: true,
|
||||
align: 'left',
|
||||
label: 'Nome',
|
||||
field: 'nameSurname',
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
name: 'created_at',
|
||||
required: true,
|
||||
align: 'center',
|
||||
label: 'Effettuato il',
|
||||
field: 'created_at',
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
name: 'items',
|
||||
required: true,
|
||||
label: 'Articoli',
|
||||
field: 'items',
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
name: 'totalPrice',
|
||||
required: true,
|
||||
label: 'Totale',
|
||||
field: 'totalPrice',
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
name: 'status',
|
||||
align: 'center',
|
||||
required: true,
|
||||
label: 'Stato',
|
||||
field: 'status',
|
||||
sortable: true
|
||||
}
|
||||
value = value.toString()
|
||||
return value.charAt(0).toUpperCase() + value.slice(1)
|
||||
])
|
||||
|
||||
// const { setValDb, getValDb } = MixinBase()
|
||||
|
||||
function getCols(props: any) {
|
||||
return props.cols.filter((col: any) => col.name !== 'desc')
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
export default class OrderInfo extends MixinBase {
|
||||
public $q: any
|
||||
public myorderscart: IOrderCart[] = []
|
||||
public myarrrec: any = {}
|
||||
|
||||
public conferma_carrello: boolean = false
|
||||
public conferma_ordine: boolean = false
|
||||
|
||||
public taborders: string = 'incorso'
|
||||
public filter: string = ''
|
||||
public statusnow: number = 0
|
||||
public arrnumstatus: any = []
|
||||
public columns = [
|
||||
{
|
||||
name: 'numorder',
|
||||
required: true,
|
||||
align: 'left',
|
||||
label: 'Numero Ordine',
|
||||
field: 'numorder',
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
name: 'nameSurname',
|
||||
required: true,
|
||||
align: 'left',
|
||||
label: 'Nome',
|
||||
field: 'nameSurname',
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
name: 'created_at',
|
||||
required: true,
|
||||
align: 'center',
|
||||
label: 'Effettuato il',
|
||||
field: 'created_at',
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
name: 'items',
|
||||
required: true,
|
||||
label: 'Articoli',
|
||||
field: 'items',
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
name: 'totalPrice',
|
||||
required: true,
|
||||
label: 'Totale',
|
||||
field: 'totalPrice',
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
name: 'status',
|
||||
align: 'center',
|
||||
required: true,
|
||||
label: 'Stato',
|
||||
field: 'status',
|
||||
sortable: true
|
||||
function getOrdersCart(): IOrderCart[] | undefined {
|
||||
return productStore.getOrdersCart(taborders.value)
|
||||
}
|
||||
]
|
||||
|
||||
/*public $refs: {
|
||||
singleproject: SingleProject[],
|
||||
ctodo: CTodo
|
||||
}*/
|
||||
function getAllOrdersCart() {
|
||||
return productStore.getOrdersAllCart()
|
||||
}
|
||||
|
||||
get getOrdersCart() {
|
||||
return Products.getters.getOrdersCart(this.taborders)
|
||||
}
|
||||
|
||||
get getAllOrdersCart() {
|
||||
return Products.getters.getOrdersAllCart()
|
||||
}
|
||||
|
||||
public change_field(myorderid, fieldname) {
|
||||
if (this.myarrrec[myorderid][fieldname] !== this[fieldname]) {
|
||||
this.myarrrec[myorderid][fieldname] = this[fieldname]
|
||||
|
||||
const mydata = {
|
||||
[fieldname]: this.myarrrec[myorderid][fieldname]
|
||||
function updateorders() {
|
||||
myorderscart.value = getOrdersCart()
|
||||
for (const ordercart of myorderscart.value!) {
|
||||
myarrrec.value[ordercart._id] = Object.keys(ordercart)
|
||||
}
|
||||
|
||||
const allorders = getAllOrdersCart()
|
||||
for (const status of [2, 3, 4, 6, 10]) {
|
||||
arrnumstatus.value[status] = allorders.filter((rec) => (rec.status === status)).reduce((sum, item) => sum + 1, 0)
|
||||
}
|
||||
|
||||
const aggiorna = fieldname !== 'status'
|
||||
tools.saveFieldToServer(this, 'orderscart', myorderid, mydata, aggiorna)
|
||||
}
|
||||
}
|
||||
public updateorders() {
|
||||
this.myorderscart = this.getOrdersCart
|
||||
for (const ordercart of this.myorderscart) {
|
||||
this.myarrrec[ordercart._id] = Object.keys(ordercart)
|
||||
}
|
||||
|
||||
const allorders = this.getAllOrdersCart
|
||||
for (const status of [
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
6,
|
||||
10
|
||||
]) {
|
||||
this.arrnumstatus[status] = allorders.filter((rec) => (rec.status === status)).reduce((sum, item) => sum + 1, 0)
|
||||
}
|
||||
function mounted() {
|
||||
|
||||
}
|
||||
updateorders()
|
||||
|
||||
public mounted() {
|
||||
console.log('arrnumstatus;')
|
||||
console.log(arrnumstatus.value)
|
||||
|
||||
this.updateorders()
|
||||
|
||||
console.log('arrnumstatus;')
|
||||
console.log(this.arrnumstatus)
|
||||
|
||||
this.columns = [...this.columns,
|
||||
columns.value = [...columns.value,
|
||||
{
|
||||
name: 'comandi',
|
||||
align: 'center',
|
||||
@@ -153,75 +130,93 @@ export default class OrderInfo extends MixinBase {
|
||||
sortable: false
|
||||
}]
|
||||
|
||||
}
|
||||
|
||||
public CanBeShipped() {
|
||||
return Products.state.cart.items.filter((rec) => rec.order.product.canBeShipped).length
|
||||
}
|
||||
|
||||
public CanBeBuyOnline() {
|
||||
return Products.state.cart.items.filter((rec) => rec.order.product.canBeBuyOnline).length
|
||||
}
|
||||
|
||||
get getnumsteps() {
|
||||
let numsteps = 1
|
||||
|
||||
if (this.CanBeShipped())
|
||||
numsteps++
|
||||
if (this.CanBeBuyOnline())
|
||||
numsteps++
|
||||
|
||||
return numsteps
|
||||
}
|
||||
|
||||
public docheckout() {
|
||||
|
||||
// Può essere spedito?
|
||||
|
||||
if (this.CanBeShipped()) {
|
||||
// mostra form di spedizione
|
||||
}
|
||||
|
||||
if (this.CanBeBuyOnline()) {
|
||||
// mostra form di acquisto Online
|
||||
}
|
||||
}
|
||||
|
||||
get nextstep() {
|
||||
return 0
|
||||
}
|
||||
|
||||
public clickFunz(order, status) {
|
||||
|
||||
if (status === shared_consts.OrderStatus.ORDER_CONFIRMED) {
|
||||
// Conferma Ordine
|
||||
function CanBeShipped() {
|
||||
return productStore.cart.items!.filter((rec) => rec.order.product!.canBeShipped).length
|
||||
}
|
||||
|
||||
const statusStr = shared_consts.getStatusStr(status)
|
||||
function CanBeBuyOnline() {
|
||||
return productStore.cart.items!.filter((rec) => rec.order.product!.canBeBuyOnline).length
|
||||
}
|
||||
|
||||
this.$q.dialog({
|
||||
message: 'Impostare l\'ordine n. ' + order.numorder + ' ' + statusStr + ' ?',
|
||||
ok: {
|
||||
label: this.$t('dialog.yes'),
|
||||
push: true
|
||||
},
|
||||
cancel: {
|
||||
label: this.$t('dialog.cancel')
|
||||
},
|
||||
title: 'Ordine'
|
||||
}).onOk(async () => {
|
||||
function getnumsteps() {
|
||||
let numsteps = 1
|
||||
|
||||
this.statusnow = await Products.actions.UpdateOrderStatus({ order_id: order._id, status })
|
||||
if (CanBeShipped())
|
||||
numsteps++
|
||||
if (CanBeBuyOnline())
|
||||
numsteps++
|
||||
|
||||
if (this.statusnow === status) {
|
||||
order.status = this.statusnow
|
||||
this.updateorders()
|
||||
tools.showPositiveNotif(this.$q, 'Ordine ' + statusStr)
|
||||
return numsteps
|
||||
}
|
||||
|
||||
function docheckout() {
|
||||
|
||||
// Può essere spedito?
|
||||
|
||||
if (CanBeShipped()) {
|
||||
// mostra form di spedizione
|
||||
}
|
||||
// this.change_field('status')
|
||||
// this.change_field('status')
|
||||
})
|
||||
|
||||
if (CanBeBuyOnline()) {
|
||||
// mostra form di acquisto Online
|
||||
}
|
||||
}
|
||||
|
||||
function nextstep() {
|
||||
return 0
|
||||
}
|
||||
|
||||
function clickFunz(order: IOrderCart, status: number) {
|
||||
|
||||
if (status === shared_consts.OrderStatus.ORDER_CONFIRMED) {
|
||||
// Conferma Ordine
|
||||
}
|
||||
|
||||
const statusStr = shared_consts.getStatusStr(status)
|
||||
|
||||
$q.dialog({
|
||||
message: 'Impostare l\'ordine n. ' + order.numorder + ' ' + statusStr + ' ?',
|
||||
ok: {
|
||||
label: t('dialog.yes'),
|
||||
push: true
|
||||
},
|
||||
cancel: {
|
||||
label: t('dialog.cancel')
|
||||
},
|
||||
title: 'Ordine'
|
||||
}).onOk(async () => {
|
||||
|
||||
statusnow.value = await productStore.UpdateOrderStatus({ order_id: order._id, status })
|
||||
|
||||
if (statusnow.value === status) {
|
||||
order.status = statusnow.value
|
||||
updateorders()
|
||||
tools.showPositiveNotif($q, 'Ordine ' + statusStr)
|
||||
}
|
||||
// change_field('status')
|
||||
// change_field('status')
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(mounted)
|
||||
|
||||
return {
|
||||
userStore,
|
||||
costanti,
|
||||
tools,
|
||||
toolsext,
|
||||
shared_consts,
|
||||
columns,
|
||||
taborders,
|
||||
arrnumstatus,
|
||||
clickFunz,
|
||||
getOrdersCart,
|
||||
getAllOrdersCart,
|
||||
updateorders,
|
||||
getCols,
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user