Let user "add past product" when making new custorder
This commit is contained in:
parent
ddb05afe6b
commit
5d875bc731
|
@ -483,7 +483,13 @@
|
|||
@click="showAddItemDialog()">
|
||||
Add Item
|
||||
</b-button>
|
||||
<b-button icon-pack="fas"
|
||||
icon-left="fas fa-plus"
|
||||
@click="showAddPastItem()">
|
||||
Add Past Item
|
||||
</b-button>
|
||||
</div>
|
||||
|
||||
<b-modal :active.sync="showingItemDialog">
|
||||
<div class="card">
|
||||
<div class="card-content">
|
||||
|
@ -586,28 +592,18 @@
|
|||
</b-tab-item>
|
||||
<b-tab-item label="Quantity">
|
||||
|
||||
<div class="is-pulled-right has-text-centered">
|
||||
<img :src="productImageURL"
|
||||
style="height: 150px; width: 150px; "/>
|
||||
## <p>{{ productKey }}</p>
|
||||
</div>
|
||||
|
||||
<b-field grouped>
|
||||
<b-field label="Product" horizontal>
|
||||
<span>{{ productDisplay }}</span>
|
||||
</b-field>
|
||||
</b-field>
|
||||
|
||||
<b-field grouped>
|
||||
|
||||
<b-field label="Quantity" horizontal>
|
||||
<b-input v-model="productQuantity"></b-input>
|
||||
</b-field>
|
||||
|
||||
<b-select v-model="productUOM">
|
||||
<option v-for="choice in productUnitChoices"
|
||||
:key="choice.key"
|
||||
:value="choice.key"
|
||||
v-html="choice.value">
|
||||
</option>
|
||||
</b-select>
|
||||
|
||||
</b-field>
|
||||
|
||||
<b-field grouped>
|
||||
|
||||
<b-field label="Unit Size">
|
||||
|
@ -640,6 +636,22 @@
|
|||
|
||||
</b-field>
|
||||
|
||||
<b-field grouped>
|
||||
|
||||
<b-field label="Quantity" horizontal>
|
||||
<b-input v-model="productQuantity"></b-input>
|
||||
</b-field>
|
||||
|
||||
<b-select v-model="productUOM">
|
||||
<option v-for="choice in productUnitChoices"
|
||||
:key="choice.key"
|
||||
:value="choice.key"
|
||||
v-html="choice.value">
|
||||
</option>
|
||||
</b-select>
|
||||
|
||||
</b-field>
|
||||
|
||||
</b-tab-item>
|
||||
</b-tabs>
|
||||
|
||||
|
@ -659,6 +671,93 @@
|
|||
</div>
|
||||
</b-modal>
|
||||
|
||||
<b-modal :active.sync="pastItemsShowDialog">
|
||||
<div class="card">
|
||||
<div class="card-content">
|
||||
|
||||
<b-table :data="pastItems"
|
||||
icon-pack="fas"
|
||||
:loading="pastItemsLoading"
|
||||
:selected.sync="pastItemsSelected"
|
||||
sortable
|
||||
paginated
|
||||
per-page="6">
|
||||
<template slot-scope="props">
|
||||
|
||||
<b-table-column :label="productKeyLabel"
|
||||
field="key"
|
||||
sortable>
|
||||
{{ props.row.key }}
|
||||
</b-table-column>
|
||||
|
||||
<b-table-column label="Brand"
|
||||
field="brand_name"
|
||||
sortable>
|
||||
{{ props.row.brand_name }}
|
||||
</b-table-column>
|
||||
|
||||
<b-table-column label="Description"
|
||||
field="description"
|
||||
sortable>
|
||||
{{ props.row.description }}
|
||||
</b-table-column>
|
||||
|
||||
<b-table-column label="Size"
|
||||
field="size"
|
||||
sortable>
|
||||
{{ props.row.size }}
|
||||
</b-table-column>
|
||||
|
||||
<b-table-column label="Unit Price"
|
||||
field="unit_price"
|
||||
sortable>
|
||||
{{ props.row.unit_price_display }}
|
||||
</b-table-column>
|
||||
|
||||
<b-table-column label="Department"
|
||||
field="department_name"
|
||||
sortable>
|
||||
{{ props.row.department_name }}
|
||||
</b-table-column>
|
||||
|
||||
<b-table-column label="Vendor"
|
||||
field="vendor_name"
|
||||
sortable>
|
||||
{{ props.row.vendor_name }}
|
||||
</b-table-column>
|
||||
|
||||
</template>
|
||||
<template slot="empty">
|
||||
<div class="content has-text-grey has-text-centered">
|
||||
<p>
|
||||
<b-icon
|
||||
pack="fas"
|
||||
icon="fas fa-sad-tear"
|
||||
size="is-large">
|
||||
</b-icon>
|
||||
</p>
|
||||
<p>Nothing here.</p>
|
||||
</div>
|
||||
</template>
|
||||
</b-table>
|
||||
|
||||
<div class="buttons">
|
||||
<b-button @click="pastItemsShowDialog = false">
|
||||
Cancel
|
||||
</b-button>
|
||||
<b-button type="is-primary"
|
||||
icon-pack="fas"
|
||||
icon-left="plus"
|
||||
@click="pastItemsAddSelected()"
|
||||
:disabled="!pastItemsSelected">
|
||||
Add Selected Item
|
||||
</b-button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</b-modal>
|
||||
|
||||
<b-table v-if="items.length"
|
||||
:data="items">
|
||||
<template slot-scope="props">
|
||||
|
@ -818,6 +917,10 @@
|
|||
editingItem: null,
|
||||
showingItemDialog: false,
|
||||
itemDialogTabIndex: 0,
|
||||
pastItemsShowDialog: false,
|
||||
pastItemsLoading: false,
|
||||
pastItems: [],
|
||||
pastItemsSelected: null,
|
||||
productIsKnown: true,
|
||||
productUUID: null,
|
||||
productDisplay: null,
|
||||
|
@ -1164,6 +1267,11 @@
|
|||
},
|
||||
|
||||
contactChanged(uuid, callback) {
|
||||
|
||||
// clear out the past items cache
|
||||
this.pastItemsSelected = null
|
||||
this.pastItems = []
|
||||
|
||||
let params
|
||||
if (!uuid) {
|
||||
params = {
|
||||
|
@ -1380,6 +1488,7 @@
|
|||
this.productCaseQuantity = null
|
||||
this.productUnitPriceDisplay = null
|
||||
this.productCasePriceDisplay = null
|
||||
this.productImageURL = '${request.static_url('tailbone:static/img/product.png')}'
|
||||
this.productQuantity = 1
|
||||
this.productUnitChoices = this.defaultUnitChoices
|
||||
this.productUOM = this.defaultUOM
|
||||
|
@ -1395,6 +1504,53 @@
|
|||
})
|
||||
},
|
||||
|
||||
showAddPastItem() {
|
||||
this.pastItemsSelected = null
|
||||
|
||||
if (!this.pastItems.length) {
|
||||
this.pastItemsLoading = true
|
||||
let params = {
|
||||
action: 'get_past_items',
|
||||
}
|
||||
this.submitBatchData(params, response => {
|
||||
this.pastItems = response.data.past_items
|
||||
this.pastItemsLoading = false
|
||||
})
|
||||
}
|
||||
|
||||
this.pastItemsShowDialog = true
|
||||
},
|
||||
|
||||
pastItemsAddSelected() {
|
||||
this.pastItemsShowDialog = false
|
||||
|
||||
let selected = this.pastItemsSelected
|
||||
this.editingItem = null
|
||||
this.productIsKnown = true
|
||||
this.productUUID = selected.uuid
|
||||
this.productDisplay = selected.full_description
|
||||
this.productUPC = selected.upc_pretty || selected.upc
|
||||
this.productKey = selected.key
|
||||
this.productSize = selected.size
|
||||
this.productCaseQuantity = selected.case_quantity
|
||||
this.productUnitPriceDisplay = selected.unit_price_display
|
||||
this.productCasePriceDisplay = selected.case_price_display
|
||||
this.productImageURL = selected.image_url
|
||||
// TODO: this needs to come from handler i guess..
|
||||
// this.productURL = row.product_url
|
||||
this.productQuantity = 1
|
||||
this.productUnitChoices = selected.uom_choices
|
||||
// TODO: seems like the default should not be so generic?
|
||||
this.productUOM = this.defaultUOM
|
||||
|
||||
% if product_price_may_be_questionable:
|
||||
this.productPriceNeedsConfirmation = false
|
||||
% endif
|
||||
|
||||
this.itemDialogTabIndex = 1
|
||||
this.showingItemDialog = true
|
||||
},
|
||||
|
||||
showEditItemDialog(index) {
|
||||
row = this.items[index]
|
||||
this.editingItem = row
|
||||
|
|
|
@ -263,6 +263,7 @@ class CustomerOrderView(MasterView):
|
|||
'get_customer_info',
|
||||
# 'set_customer_data',
|
||||
'get_product_info',
|
||||
'get_past_items',
|
||||
'add_item',
|
||||
'update_item',
|
||||
'delete_item',
|
||||
|
@ -568,6 +569,21 @@ class CustomerOrderView(MasterView):
|
|||
info['url'] = self.request.route_url('products.view', uuid=info['uuid'])
|
||||
return info
|
||||
|
||||
def get_past_items(self, batch, data):
|
||||
past_products = self.handler.get_past_products(batch)
|
||||
past_items = []
|
||||
|
||||
for product in past_products:
|
||||
try:
|
||||
item = self.handler.get_product_info(batch, product)
|
||||
except:
|
||||
# nb. handler may raise error if product is "unsupported"
|
||||
pass
|
||||
else:
|
||||
past_items.append(item)
|
||||
|
||||
return {'past_items': past_items}
|
||||
|
||||
def normalize_batch(self, batch):
|
||||
return {
|
||||
'uuid': batch.uuid,
|
||||
|
|
Loading…
Reference in a new issue