Authored by lea guo

订单列表

... ... @@ -48,11 +48,11 @@ export default {
}
},
methods: {
...mapMutations(["setOrderStatus", "resetOrderData"]),
...mapMutations(["setOrderStatus", "resetPartialData"]),
...mapActions(["fetchOrderList"]),
onHandleClick(status) {
this.setOrderStatus(status);
this.resetOrderData();
this.resetPartialData();
const { owner } = this.$route.params;
this.fetchOrderList({ owner, status });
}
... ...
... ... @@ -65,8 +65,6 @@ const { mapActions: orderListMapActions } = createNamespacedHelpers(
"order/orderList"
);
const { mapMutations: orderMapMutations } = createNamespacedHelpers("order");
export default {
components: {
Scroll,
... ... @@ -96,14 +94,13 @@ export default {
// store.dispatch("order/orderList/fetchOrderList", { owner, status });
},
activated() {
this.reset("inSaleOrderList");
this.resetData();
this.fetchData();
},
methods: {
...mapActions(["fetchEntryOrderList", "fetchNotEntryOrderList"]),
...orderListMapActions(["cancelTradeConfirmInfo", "cancelTrade"]),
...mapMutations(["filterOrderList"]),
...orderMapMutations(["reset"]),
...mapMutations(["filterOrderList", "resetData"]),
fetchData() {
if (this.isFetchEntryOrder) {
this.fetchEntryOrderList();
... ...
... ... @@ -61,8 +61,6 @@ const { mapActions, mapState, mapMutations } = createNamespacedHelpers(
"order/orderList"
);
const { mapMutations: orderMapMutations } = createNamespacedHelpers("order");
export default {
components: {
Scroll,
... ... @@ -89,7 +87,7 @@ export default {
// store.dispatch("order/orderList/fetchOrderList", { owner, status });
},
activated() {
this.reset("orderList");
this.resetData();
this.fetchData();
},
methods: {
... ... @@ -99,8 +97,7 @@ export default {
"cancelTrade",
"deleteOrder"
]),
...mapMutations(["setOrderStatus", "filterOrderList"]),
...orderMapMutations(["reset"]),
...mapMutations(["setOrderStatus", "filterOrderList", "resetData"]),
fetchMore() {
this.fetchOrderList(this.$route.params);
},
... ... @@ -160,7 +157,7 @@ export default {
owner
});
if (isOk) {
this.reset("orderList");
this.resetData();
this.fetchData(this.$route.params);
}
const txt = isOk ? "取消成功" : "取消失败";
... ...
const initailData = () => ({
entryOrder: {
page: 1,
pageSize: 10,
pagetotal: 0,
list: [], // 订单列表
pullUpload: true,
},
notEntryOrder: {
page: 1,
pageSize: 10,
pagetotal: 0,
list: [], // 订单列表
pullUpload: true,
},
isShowEmpty: false,
});
export default function() {
return {
namespaced: true,
state: {
entryOrder: {
page: 1,
pageSize: 10,
pagetotal: 0,
list: [], // 订单列表
pullUpload: true,
},
notEntryOrder: {
page: 1,
pageSize: 10,
pagetotal: 0,
list: [], // 订单列表
pullUpload: true,
},
isShowEmpty: false,
},
state: initailData,
mutations: {
setEntryOrder(state, res) {
let { page, pagetotal, data = [] } = res;
... ... @@ -58,6 +60,13 @@ export default function() {
state.entryOrder.list.length === 0 &&
state.notEntryOrder.list.length === 0;
},
resetData(state) {
const s = initailData();
Object.keys(s).forEach(key => {
state[key] = s[key];
});
},
},
getters: {
// scroll 组件参数,是否触发上拉事件
... ...
... ... @@ -6,16 +6,6 @@ import orderLogistics from './order-logistics';
import orderDeliver from './order-deliver';
import inSaleOrderList from './in-sale-order-list';
const initialState = {
priceChange: priceChange().state,
orderList: orderList().state,
orderConfirm: orderConfirm().state,
orderDetail: orderDetail().state,
logisticsInfo: orderLogistics().state,
orderDeliver: orderDeliver().state,
inSaleOrderList: inSaleOrderList().state,
};
export default function() {
return {
namespaced: true,
... ... @@ -28,27 +18,5 @@ export default function() {
orderDeliver: orderDeliver(),
inSaleOrderList: inSaleOrderList(),
},
state: {
resetFlag: false,
},
mutations: {
/**
* reset module state
* @param {*} state
* @param { Array | String} moduleNames 模块名
*/
reset(state, moduleNames = []) {
if (typeof moduleNames === 'string') {
moduleNames = [moduleNames];
}
console.log('------reset module name------------', moduleNames);
// 修改flag,监听后reload
state.resetFlag = !state.resetFlag;
for (const name of moduleNames) {
Object.assign(state[name], initialState[name]);
}
},
},
};
}
... ...
const initailData = () => ({
page: 1,
pageSize: 10,
pagetotal: 0,
orderList: [], // 订单列表
// scroll 组件参数,是否触发上拉事件
pullUpLoad: true,
// 当前查询订单状态
currentStatus: 1,
isShowEmpty: false,
});
export default function() {
return {
namespaced: true,
modules: {},
state: {
page: 1,
pageSize: 10,
pagetotal: 0,
orderList: [], // 订单列表
// scroll 组件参数,是否触发上拉事件
pullUpLoad: true,
// 当前查询订单状态
currentStatus: 1,
routerParam: {},
isShowEmpty: false,
},
state: initailData,
mutations: {
setOrderList(state, res) {
let { page, pagetotal, data = [] } = res;
... ... @@ -39,12 +39,19 @@ export default function() {
setOrderStatus(state, currentStatus) {
state.currentStatus = +currentStatus;
},
resetOrderData(state) {
resetPartialData(state) {
state.page = 1;
state.orderList = [];
state.pagetotal = 0;
state.pullUpLoad = true;
},
resetData(state) {
const s = initailData();
Object.keys(s).forEach(key => {
state[key] = s[key];
});
},
},
actions: {
/**
... ...