This commit is contained in:
rakesh 2022-02-14 17:03:50 +05:30
parent 8c3f940308
commit e987740c1e
4 changed files with 48 additions and 84 deletions

View File

@ -1 +1 @@
{"branch_name":"dev","last_commit_date":"2022-02-12T12:20:27.000Z","last_commit_author":"anjujangid","last_commit_hash":"a57b07eaa8b1f0f62e4854ee8176a6f7f88836e9"} {"branch_name":"dev","last_commit_date":"2022-02-14T10:30:18.000Z","last_commit_author":"anjujangid","last_commit_hash":"8c3f940308bc510defde9f95c815bd081f6b15b0"}

View File

@ -17,6 +17,7 @@
outlined outlined
hide-details hide-details
v-model="orderNumber" v-model="orderNumber"
dense
></v-text-field> ></v-text-field>
</v-col> </v-col>
<v-col cols="12" sm="12" md="6" lg="5"> <v-col cols="12" sm="12" md="6" lg="5">
@ -36,6 +37,7 @@
v-on="on" v-on="on"
outlined outlined
hide-details hide-details
dense
></v-text-field> ></v-text-field>
</template> </template>
<v-date-picker <v-date-picker
@ -65,6 +67,7 @@
v-on="on" v-on="on"
outlined outlined
hide-details hide-details
dense
></v-text-field> ></v-text-field>
</template> </template>
<v-date-picker <v-date-picker
@ -102,12 +105,12 @@
:class="hover ? 'white--text warning' : 'warning--text'" :class="hover ? 'white--text warning' : 'warning--text'"
class="width-250px" class="width-250px"
outlined outlined
@click.prevent="searchOrder" @click.prevent="orderlistApi"
> >
Search Search
</v-btn> </v-btn>
</v-hover> </v-hover>
</v-col>- </v-col>
<v-col cols="12" sm="12" md="6" lg="3"> <v-col cols="12" sm="12" md="6" lg="3">
<v-hover v-slot:default="{ hover }"> <v-hover v-slot:default="{ hover }">
<router-link <router-link
@ -144,10 +147,10 @@
<span>{{ item.incrementId }}</span> <span>{{ item.incrementId }}</span>
</template> </template>
<template v-slot:item.retailername="{ item }"> <template v-slot:item.retailername="{ item }">
<span>{{ `-` }}</span> <span>{{ userInfo.firstname + '' + userInfo.lastname }}</span>
</template> </template>
<template v-slot:item.salesrepname="{ item }"> <template v-slot:item.salesrepname="{ item }">
<span>{{ `-` }}</span> <span>{{ userInfo.firstname + '' + userInfo.lastname }}</span>
</template> </template>
<template v-slot:item.status="{ item }"> <template v-slot:item.status="{ item }">
<span>{{ item.status }}</span> <span>{{ item.status }}</span>
@ -178,6 +181,12 @@
</template> </template>
<script> <script>
/* eslint-disable no-alert, no-console , no-debugger */ /* eslint-disable no-alert, no-console , no-debugger */
import { createHelpers } from "vuex-map-fields";
const { mapFields } = createHelpers({
getterType: "orderlist/getField",
mutationType: "orderlist/updateField",
});
export default { export default {
name: "BoxedOrderHistoryPage", name: "BoxedOrderHistoryPage",
@ -197,7 +206,6 @@ export default {
{ text: "Action", value: "action" }, { text: "Action", value: "action" },
], ],
orderNumber : ""
}), }),
computed: { computed: {
createdDate() { createdDate() {
@ -209,13 +217,15 @@ export default {
OrderHistory() { OrderHistory() {
return this.$store.state.orderlist.OrderHistory.items; return this.$store.state.orderlist.OrderHistory.items;
}, },
customerId() { userInfo() {
return this.$store.state.accountOne.one; return this.$store.state.accountOne.one;
}, },
inProgress() { inProgress() {
return this.$store.state.orderlist.inProgress; return this.$store.state.orderlist.inProgress;
}, },
...mapFields(["orderNumber"]),
}, },
methods: { methods: {
@ -244,20 +254,20 @@ export default {
this.$store.dispatch("orderlist/fetchSearchOrder"); this.$store.dispatch("orderlist/fetchSearchOrder");
}, },
reset(){ reset(){
this.$store.dispatch("orderlist/fetchReset"); this.$store.dispatch("orderlist/fetchReset",this.userInfo.id);
}, },
orderlistApi() { orderlistApi() {
if(this.customerId && this.customerId.id) if(this.userInfo && this.userInfo.id)
{ {
this.$store.dispatch("orderlist/fetchOrderList",this.customerId.id); this.$store.dispatch("orderlist/fetchOrderList",this.userInfo.id);
} }
}, },
}, },
watch: watch:
{ {
customerId() userInfo()
{ {
this.orderlistApi(); this.orderlistApi();
} }

View File

@ -676,7 +676,12 @@ export const doFetchProductTags = wrapRequest((sku) => {
}) })
export const doFetchOrderHistory = wrapRequest((customerId) => { export const doFetchOrderHistory = wrapRequest((obj) => {
let query = "";
query = `searchCriteria[pageSize]=5000&searchCriteria[currentPage]=1&searchCriteria[sortOrders][0][field]=created_at&searchCriteria[sortOrders][0][direction]=DESC&searchCriteria[filter_groups][0][filters][0][field]=customer_id&searchCriteria[filter_groups][0][filters][0][value]=${obj.customerId}&searchCriteria[filter_groups][0][filters][0][condition_type]=eq`;
if(obj.incrementId){
query = `&searchCriteria[filter_groups][1][filters][0][field]=increment_id&searchCriteria[filter_groups][1][filters][0][value]=${obj.incrementId}&searchCriteria[filter_groups][1][filters][0][condition_type]=eq`
}
const requestOptions = { const requestOptions = {
method: 'GET', method: 'GET',
headers: { headers: {
@ -684,49 +689,5 @@ export const doFetchOrderHistory = wrapRequest((customerId) => {
'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Origin': '*',
} }
}; };
return fetch(`${vueAppMagenotApiUrl}/rest/crn_retailer/V1/crorders?searchCriteria[filter_groups][0][filters][0][field]=customer_id&searchCriteria[filter_groups][0][filters][0][value]=${customerId}&searchCriteria[filter_groups][0][filters][0][condition_type]=eq&searchCriteria[pageSize]=100&searchCriteria[currentPage]=1&searchCriteria[sortOrders][0][field]=created_at&searchCriteria[sortOrders][0][direction]=DESC`, requestOptions) return fetch(`${vueAppMagenotApiUrl}/rest/crn_retailer/V1/crorders?${query}`, requestOptions)
});
export const doFetchIncrementId = wrapRequest((customerId,incrementId) => {
debugger
const requestOptions = {
method: 'GET',
headers: {
'Content-type': 'application/json'
},
};
if(customerId){
let query = "";
query = `?
searchCriteria[pageSize]=1000&searchCriteria[currentPage]=1
&searchCriteria[filter_groups][1][filters][0][field]=customer_id
&searchCriteria[filter_groups][1][filters][0][value]=${customerId}
&searchCriteria[filter_groups][1][filters][0][condition_type]=eq`
console.log('CustomerId', `${vueAppMagenotApiUrl}/rest/crn_retailer/V1/crproducts/${query}`);
return fetch(`${vueAppMagenotApiUrl}/rest/crn_retailer/V1/crproducts/${query}`, requestOptions)
}
if(incrementId){
let query = "";
query = `?
searchCriteria[pageSize]=1000&searchCriteria[currentPage]=1
&searchCriteria[filter_groups][1][filters][0][field]=increment_id
&searchCriteria[filter_groups][1][filters][0][value]=${incrementId}
&searchCriteria[filter_groups][1][filters][0][condition_type]=eq`
console.log('incrementId', `${vueAppMagenotApiUrl}/rest/crn_retailer/V1/crproducts/${query}`);
return fetch(`${vueAppMagenotApiUrl}/rest/crn_retailer/V1/crproducts/${query}`, requestOptions)
}
if(incrementId && customerId){
let query = "";
query = `?searchCriteria[pageSize]=1000&searchCriteria[currentPage]=1&searchCriteria[filter_groups][1][filters][0][field]=increment_id&searchCriteria[filter_groups][0][filters][0][field]=customer_id&searchCriteria[filter_groups][0][filters][0][value]=${customerId}&searchCriteria[filter_groups][1][filters][0][value]=${incrementId}&searchCriteria[filter_groups][1][filters][0][condition_type]=eq`
console.log('incrementId & CustomerId', `${vueAppMagenotApiUrl}/rest/crn_retailer/V1/crproducts/${query}`);
return fetch(`${vueAppMagenotApiUrl}/rest/crn_retailer/V1/crproducts/${query}`, requestOptions)
}
}); });

View File

@ -1,6 +1,6 @@
/* eslint-disable no-alert, no-console , no-debugger */ /* eslint-disable no-alert, no-console , no-debugger */
import { doFetchOrderHistory ,doFetchIncrementId} from '@/services/product.service'; import { doFetchOrderHistory } from '@/services/product.service';
import { getField, updateField } from 'vuex-map-fields'; import { getField, updateField } from 'vuex-map-fields';
import humps from 'lodash-humps'; import humps from 'lodash-humps';
@ -11,7 +11,7 @@ export const orderlist = {
OrderHistory: {}, OrderHistory: {},
customerId: "", customerId: "",
incrementId: "" orderNumber: ""
// createdDate: "", // createdDate: "",
// toDate: "", // toDate: "",
// purchaseOrderNumber: "", // purchaseOrderNumber: "",
@ -29,34 +29,13 @@ export const orderlist = {
setOrderHistory(state, orderhistorydata) { setOrderHistory(state, orderhistorydata) {
state.OrderHistory = orderhistorydata state.OrderHistory = orderhistorydata
}, },
setSearchOrder(state, orderItem,customerId) {
state.customerId=orderItem
state.customerId=customerId
} ,
// setReset(state,incrementId){
// state.incrementId=incrementId
// }
}, },
actions: { actions: {
fetchSearchOrder:async ({ commit, state} ) => { fetchOrderList: async ({state, commit },customerId) => {
debugger
const filterOrderlist = await doFetchIncrementId( state.OrderHistory,state.incrementId)
if(filterOrderlist){
commit('setSearchOrder', humps(filterOrderlist));
}
},
// fetchReset({commit}){
// commit('setReset');
// },
fetchOrderList: async ({ commit },customerId) => {
try { try {
commit('inProgress', true); commit('inProgress', true);
let OrderHistory = await doFetchOrderHistory(customerId); let OrderHistory = await doFetchOrderHistory({customerId:customerId,incrementId:state.orderNumber});
if (OrderHistory) { if (OrderHistory) {
commit('inProgress', false); commit('inProgress', false);
commit('setOrderHistory', humps(OrderHistory)); commit('setOrderHistory', humps(OrderHistory));
@ -67,8 +46,22 @@ export const orderlist = {
throw error throw error
} }
}, },
fetchReset: async ({state,commit },customerId) => {
try {
state.orderNumber="";
commit('inProgress', true);
let orderHistory = await doFetchOrderHistory({customerId:customerId,incrementId:state.orderNumber});
if (orderHistory) {
commit('inProgress', false);
commit('setOrderHistory', humps(orderHistory));
}
}
catch (error) {
commit('inProgress', false);
throw error
}
},
} }
} }