stash
This commit is contained in:
parent
0bf28321da
commit
39ce06d180
2 changed files with 70 additions and 17 deletions
|
@ -460,6 +460,12 @@ const store = createStore({
|
||||||
if (data && success) {
|
if (data && success) {
|
||||||
commit('setShippingCodes', data);
|
commit('setShippingCodes', data);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
async createShippingCode({commit, state}, code) {
|
||||||
|
const {data, success} = await http.post('/2/shipping_codes/', {code}, state.user.token);
|
||||||
|
if (data && success) {
|
||||||
|
commit('setShippingCodes', data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
|
|
|
@ -1,22 +1,48 @@
|
||||||
<template>
|
<template>
|
||||||
<Table
|
<div>
|
||||||
:columns="['type', 'code']"
|
<h3>Shipping Codes</h3>
|
||||||
:items="shippingCodes"
|
<Table
|
||||||
:keyName="'code'"
|
:columns="['type', 'code']"
|
||||||
>
|
:items="shippingCodes"
|
||||||
<template #actions="{ item }">
|
:keyName="'code'"
|
||||||
<div class="btn-group">
|
>
|
||||||
<button class="btn btn-secondary" @click.stop="alert(item)">
|
<template #actions="{ item }">
|
||||||
<font-awesome-icon icon="archive"/>
|
<div class="btn-group">
|
||||||
use
|
<button class="btn btn-secondary" @click.stop="alert(item)">
|
||||||
</button>
|
<font-awesome-icon icon="archive"/>
|
||||||
<button class="btn btn-danger" @click.stop="">
|
use
|
||||||
<font-awesome-icon icon="trash"/>
|
</button>
|
||||||
delete
|
<button class="btn btn-danger" @click.stop="">
|
||||||
|
<font-awesome-icon icon="trash"/>
|
||||||
|
delete
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</Table>
|
||||||
|
<div class="mt-3">
|
||||||
|
<textarea class="form-control mb-3" rows="5" placeholder="Shipping Code List" v-model="bulk_codes" v-if="bulk"></textarea>
|
||||||
|
<div class="input-group">
|
||||||
|
<input type="text" class="form-control" placeholder="Shipping Code" v-model="code" v-if="!bulk">
|
||||||
|
<select class="form-control" v-model="type">
|
||||||
|
<option value="2kg-eu">2kg DE</option>
|
||||||
|
<option value="2kg-uk">2kg EU</option>
|
||||||
|
<option value="2kg-us">5kg DE</option>
|
||||||
|
<option value="2kg-us">5kg EU</option>
|
||||||
|
<option value="2kg-us">10kg DE</option>
|
||||||
|
</select>
|
||||||
|
<div class="input-group-prepend">
|
||||||
|
<div class="input-group-text">
|
||||||
|
<input type="checkbox" v-model="bulk" class="mr-2" id="bulk" style="margin: 0;">
|
||||||
|
<label for="bulk" style="margin: 0;">Bulk</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<button class="btn btn-primary form-control" @click="createSingleOrBulkShippingCode">
|
||||||
|
<font-awesome-icon icon="plus"/>
|
||||||
|
{{ (bulk ? "Add Shipping Codes" : "Add Shipping Code") }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</div>
|
||||||
</Table>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
@ -26,8 +52,29 @@ import Table from '@/components/Table';
|
||||||
export default {
|
export default {
|
||||||
name: 'Shipping',
|
name: 'Shipping',
|
||||||
components: {Table},
|
components: {Table},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
code: '',
|
||||||
|
bulk_codes: '',
|
||||||
|
type: '2kg-eu',
|
||||||
|
bulk: false,
|
||||||
|
};
|
||||||
|
},
|
||||||
computed: mapState(['shippingCodes']),
|
computed: mapState(['shippingCodes']),
|
||||||
methods: mapActions(['fetchShippingCodes']),
|
methods: {
|
||||||
|
...mapActions(['fetchShippingCodes', 'createShippingCode']),
|
||||||
|
createSingleOrBulkShippingCode() {
|
||||||
|
if (this.bulk) {
|
||||||
|
this.bulk_codes.split('\n').forEach(code => {
|
||||||
|
this.createShippingCode({code: code.trim(), type: this.type});
|
||||||
|
});
|
||||||
|
this.bulk_codes = '';
|
||||||
|
} else {
|
||||||
|
this.createShippingCode({code: this.code, type: this.type});
|
||||||
|
this.code = '';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.fetchShippingCodes();
|
this.fetchShippingCodes();
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue