You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

271 lines
5.7 KiB
TypeScript

import {
getModule,
Module,
Mutation,
Action,
MutationAction,
VuexModule,
} from 'vuex-module-decorators';
import store from '@/store';
import http from '@/utils/request';
import { url } from '@/utils/url';
import { cloneDeep } from 'lodash/fp';
@Module({
namespaced: true,
dynamic: true,
store,
name: 'raw.handover.aggregating',
})
export class AggregatingModule extends VuexModule {
/**
*
*/
proOrderList = [];
/**
*
*/
proOrderResultList = [];
/**
*
*/
aggregateList: any[] = [];
/**
*
*/
orderList: any[] = [];
/**
*
*/
accessoryList: any[] = [];
/**
*
*/
locationList = [];
/**
*
*/
get isCheckedAll() {
return !this.proOrderList.filter((_: any) => !_.checked).length;
}
/**
*
*/
get hasChecked() {
return this.checkedProOrderList.length > 0;
}
/**
*
*/
get checkedProOrderList() {
return this.proOrderList.filter((_: any) => _.checked);
}
/**
*
*/
@Mutation
clearProOrderResultList() {
this.proOrderResultList = [];
}
/**
*
*/
@Mutation
clearProOrderList() {
this.proOrderList = [];
}
/**
*
*/
get isAggregateCheckedAll() {
return !this.aggregateList.filter((_: any) => !_.checked).length;
}
/**
* /
* @param checked
*/
@Mutation
checkAllAggregateList(checked: boolean) {
this.aggregateList = this.aggregateList.map((item: any) => {
item.checked = checked;
return item;
});
}
/**
* -
* @param params
*/
@Action
async uploadAggregateList(params: any) {
return http.post(url.sumscan.u.hzlist, params);
}
/**
*
* @param params
*/
@Mutation
setAggregateListItemHvAmount({ index, hvAmount }: { index: number; hvAmount: number }) {
const original = this.aggregateList[index];
const newItem = { ...original, hvAmount };
this.aggregateList.splice(index, 1, newItem);
}
/**
*
* @param params
*/
@Mutation
setOrderListItemHvAmount({ index, hvAmount }: { index: number; hvAmount: number }) {
const original = this.orderList[index];
const newItem = { ...original, hvAmount };
this.orderList.splice(index, 1, newItem);
}
// setOrderListItemHvAmount(params: { hvAmount: number }) {
// this.orderList
// .filter((_: any) => _.checked)
// .forEach((item: any) => {
// if (params.hvAmount) {
// item.currentAmount = params.hvAmount;
// }
// });
// }
/**
*
* @param params
*/
@Mutation
setAccessoryListItemHvAmount({ index, hvAmount }: { index: number; hvAmount: number }) {
const original = this.accessoryList[index];
const newItem = { ...original, hvAmount };
this.accessoryList.splice(index, 1, newItem);
}
/**
*
*/
get isOrderCheckedAll() {
return !this.orderList.filter((_: any) => !_.checked).length;
}
/**
* /
* @param checked
*/
@Mutation
checkAllOrderList(checked: boolean) {
this.orderList = this.orderList.map((item: any) => {
item.checked = checked;
return item;
});
}
/**
*
* @param params
*/
@MutationAction
async queryProOrder(params: any) {
const { values }: any = await http.post(url.sumscan.query.orderno, params);
const proOrderList = values.map((v: string) => ({ prdOrder: v }));
proOrderList.forEach((_: any) => (_.checked = true));
if (!proOrderList.length) {
uni.showToast({
icon: 'none',
title: 'No Data Found',
});
}
return { proOrderList };
}
/**
*
* @param params
*/
@MutationAction
async queryProOrderResult(params: any) {
const { list: proOrderResultList }: any = await http.post(url.sumscan.query.ordoutlist, params);
return { proOrderResultList };
}
/**
* -
* @param params
*/
@MutationAction
async queryAggregateList(params: any) {
const { list: aggregateList }: any = await http.post(url.sumscan.query.hzlist, params);
if (!aggregateList.length) {
uni.showToast({
icon: 'none',
title: 'No Data Found',
});
}
return { aggregateList };
}
/**
* -
* @param params
*/
@MutationAction
async queryOrderList(params: any) {
const { queryParams, proOrderResultList } = params;
await http.post(url.sumscan.lock.list, queryParams);
const orderList = cloneDeep<any>(proOrderResultList);
return { orderList };
}
/**
* -
* @param params
*/
@MutationAction
async queryAccessoryList(params: any) {
const { list: accessoryList }: any = await http.post(url.sumscan.query.fllist, params);
if (!accessoryList.length) {
uni.showToast({
icon: 'none',
title: 'No Data Found',
});
}
return { accessoryList };
}
/**
* -
* @param params
*/
@Action
async uploadOrderList(params: any) {
await http.post(url.sumscan.u.order, params);
uni.showToast({
icon: 'success',
title: 'success',
});
}
/**
* -
* @param params
*/
@Action
async uploadAccessoryList(params: any) {
return http.post(url.sumscan.u.fllist, params);
}
}
export default getModule(AggregatingModule);