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.

310 lines
7.4 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';
import vm from '@/main';
@Module({
namespaced: true,
dynamic: true,
store,
name: 'raw.handover.aggregating',
})
export class AggregatingModule extends VuexModule {
/**
*
*/
proOrderList = [];
param: any;
orderOutIdListParams: any;
/**
*
*/
proOrderResultList = [];
4 years ago
isFormChange: any;
/**
*
*/
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;
if (item.checked) {
item.hvAmount = item.totalMoAmount - item.totalHvAmount;
} else {
item.hvAmount = 0;
}
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[index].hvAmount = hvAmount;
// this.aggregateList.splice(index, 1, newItem);
// if (this.aggregateList[index].checked) {
// this.aggregateList[index].hvAmount = this.aggregateList[index].totalMoAmount - this.aggregateList[index].totalHvAmount;
// } else {
// this.aggregateList[index].hvAmount = 0;
// }
}
/**
*
* @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);
this.orderList[index].hvAmount = hvAmount;
}
// setOrderListItemHvAmount() {
// this.orderList
// .filter((_: any) => _.checked)
// .forEach((item: any) => {
// item.hvAmount = item.totalMoAmount - item.totalHvAmount;
// // 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;
}
4 years ago
/**
* /
* @param checked
*/
@Mutation
checkAllProOrderList(checked: boolean) {
this.proOrderList = this.proOrderList.map((item: any) => ({
...item,
checked,
}));
}
/**
* /
* @param checked
*/
@Mutation
checkAllOrderList(checked: boolean) {
this.orderList = this.orderList.map((item: any) => {
item.checked = checked;
if (item.checked) {
item.hvAmount = item.totalMoAmount - item.totalHvAmount;
} else {
item.hvAmount = 0;
}
return item;
});
}
/**
*
* @param params
*/
@MutationAction
async queryProOrder(params: any) {
4 years ago
const { list: proOrderList }: any = await http.post(url.sumscan.query.orderno, params);
//const proOrderList = values.map((v: string) => ({ prdOrder, amount: v, materialCode: v, materialDesc: v }));
//const proOrderList = values;
//console.log(">>>>>?????proOrderList",proOrderList);
4 years ago
proOrderList.forEach((_: any) => (_.checked = true));
if (!proOrderList.length) {
// uni.showToast({
// icon: 'none',
// title: 'No Data Found',
// });
vm.customToast(vm.$t('message.Pi_NoDataFound') as any);
}
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',
// });
vm.customToast(vm.$t('message.Pi_NoDataFound') as any);
4 years ago
return { aggregateList };
}
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);
console.log('orderList', orderList);
if (orderList.length == 0) {
return { orderList };
}
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',
// });
vm.customToast(vm.$t('message.Pi_NoDataFound') as any);
}
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);
}
@Action({ commit: 'updateCheckedOrderInInfoListKw' })
async queryByFactoryCodeAndWorkAreaCode(content: any) {
let res = await http.post('/wmspda/fg/queryByFactoryCodeAndWorkAreaCode', content);
return res;
}
}
export default getModule(AggregatingModule);