Commit 5ef44bef authored by XieZhiXiong's avatar XieZhiXiong

思考判断工作流不同的逻辑中

parent faea484b
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
* @Author: XieZhiXiong * @Author: XieZhiXiong
* @Date: 2020-11-04 15:09:09 * @Date: 2020-11-04 15:09:09
* @LastEditors: XieZhiXiong * @LastEditors: XieZhiXiong
* @LastEditTime: 2020-12-11 16:25:51 * @LastEditTime: 2020-12-11 18:39:09
* @Description: 维修商品抽屉组件 * @Description: 维修商品抽屉组件
*/ */
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import { Drawer, Button, Pagination } from 'antd'; import { Drawer, Button, Pagination, message } from 'antd';
import { createFormActions } from '@formily/antd'; import { createFormActions } from '@formily/antd';
import moment from 'moment'; import moment from 'moment';
import { ColumnType } from 'antd/lib/table/interface'; import { ColumnType } from 'antd/lib/table/interface';
...@@ -18,6 +18,7 @@ import NestTable from '@/components/NestTable'; ...@@ -18,6 +18,7 @@ import NestTable from '@/components/NestTable';
import { goodItem, OrderListParams, OrderListRes } from './interface'; import { goodItem, OrderListParams, OrderListRes } from './interface';
import { listSearchSchema } from './schema'; import { listSearchSchema } from './schema';
import styles from './index.less'; import styles from './index.less';
import { PublicApi } from '@/services/api';
const formActions = createFormActions(); const formActions = createFormActions();
...@@ -42,6 +43,11 @@ interface GoodsDrawerProps { ...@@ -42,6 +43,11 @@ interface GoodsDrawerProps {
nestProps?: { nestProps?: {
[key: string]: any, [key: string]: any,
}; };
/**
* 流程类型:1.订单交易流程 2.售后换货流程 3.售后退货流程 4.售后维修流程
*/
type: 1 | 2 | 3 | 4,
}; };
interface GoodsDrawerState { interface GoodsDrawerState {
...@@ -58,6 +64,7 @@ interface GoodsDrawerState { ...@@ -58,6 +64,7 @@ interface GoodsDrawerState {
selectedRowKeys: number[]; selectedRowKeys: number[];
childSelectedRowKeys: number[]; childSelectedRowKeys: number[];
loading: boolean; loading: boolean;
currentProcessEnum: number;
}; };
// 跟 选中的子节点 找到 父级选中的 keys // 跟 选中的子节点 找到 父级选中的 keys
...@@ -124,6 +131,7 @@ class GoodsDrawer extends React.Component<GoodsDrawerProps, GoodsDrawerState> { ...@@ -124,6 +131,7 @@ class GoodsDrawer extends React.Component<GoodsDrawerProps, GoodsDrawerState> {
selectedRowKeys: [], selectedRowKeys: [],
childSelectedRowKeys: [], childSelectedRowKeys: [],
loading: false, loading: false,
currentProcessEnum: 0,
}; };
}; };
...@@ -201,26 +209,58 @@ class GoodsDrawer extends React.Component<GoodsDrawerProps, GoodsDrawerState> { ...@@ -201,26 +209,58 @@ class GoodsDrawer extends React.Component<GoodsDrawerProps, GoodsDrawerState> {
]; ];
// 获取订单列表 // 获取订单列表
getOrderList = () => { getOrderList = async () => {
const { page, size, searchVal } = this.state; const { page, size, searchVal } = this.state;
const { fetchOrderList } = this.props; const { fetchOrderList, type } = this.props;
if (!fetchOrderList) { if (!fetchOrderList) {
return; return;
} }
this.setState({ loading: true }); this.setState({ loading: true });
fetchOrderList({ const orderListRes = await fetchOrderList({
current: `${page}`, current: `${page}`,
pageSize: `${size}`, pageSize: `${size}`,
...searchVal, ...searchVal,
}) })
.then(res => { if (orderListRes) {
this.setState({ dataSource: res }); // 获取对应订单列表的工作流类型
}) const payload = [];
.finally(() => {
this.setState({ loading: false }); orderListRes.data.forEach(item => {
item.productDateilss.forEach(product => {
const atom = {
productId: product.productId,
memberId: product.memberId,
memberRoleId: product.memberRoleId,
shopId: item.shopId,
type, // 流程类型
};
payload.push(atom);
});
}); });
const processEnumRes: any = await PublicApi.postOrderGetProcessEnum({
list: payload,
}, {
ctlType: 'none',
});
console.log('processEnumRes', processEnumRes)
if (processEnumRes.code !== 1000) {
message.error('获取工作流枚举失败,请稍候再试');
return;
}
this.setState({
dataSource: {
data: orderListRes.data.map((item, index) => ({
...item,
processEnum: processEnumRes.data[index].processEnum,
})),
totalCount: orderListRes.totalCount,
},
});
}
this.setState({ loading: false });
}; };
componentDidUpdate(prevProps) { componentDidUpdate(prevProps) {
...@@ -259,6 +299,7 @@ class GoodsDrawer extends React.Component<GoodsDrawerProps, GoodsDrawerState> { ...@@ -259,6 +299,7 @@ class GoodsDrawer extends React.Component<GoodsDrawerProps, GoodsDrawerState> {
// 子表格选中行 // 子表格选中行
handleChildSelectChange = (record: any, selected: any, selectedRows: any) => { handleChildSelectChange = (record: any, selected: any, selectedRows: any) => {
console.log('selectedRows', selectedRows)
const { const {
childSelectedRowKeys, childSelectedRowKeys,
dataSource: { dataSource: {
...@@ -273,6 +314,7 @@ class GoodsDrawer extends React.Component<GoodsDrawerProps, GoodsDrawerState> { ...@@ -273,6 +314,7 @@ class GoodsDrawer extends React.Component<GoodsDrawerProps, GoodsDrawerState> {
childArr.splice(childArr.findIndex((item: any) => item === record.id), 1); childArr.splice(childArr.findIndex((item: any) => item === record.id), 1);
} }
// const filtered = this.filterProductByProcessEnum(childArr, data);
if (!('checked' in this.props)) { if (!('checked' in this.props)) {
this.setState({ childSelectedRowKeys: childArr }); this.setState({ childSelectedRowKeys: childArr });
} }
...@@ -297,6 +339,8 @@ class GoodsDrawer extends React.Component<GoodsDrawerProps, GoodsDrawerState> { ...@@ -297,6 +339,8 @@ class GoodsDrawer extends React.Component<GoodsDrawerProps, GoodsDrawerState> {
// 取消全选 // 取消全选
childArr = childArr.filter((item: any) => !changeRows.some((e: any) => e.id === item)); childArr = childArr.filter((item: any) => !changeRows.some((e: any) => e.id === item));
} }
// const filtered = this.filterProductByProcessEnum(childArr, data);
if (!('checked' in this.props)) { if (!('checked' in this.props)) {
this.setState({ childSelectedRowKeys: childArr }); this.setState({ childSelectedRowKeys: childArr });
} }
...@@ -324,6 +368,7 @@ class GoodsDrawer extends React.Component<GoodsDrawerProps, GoodsDrawerState> { ...@@ -324,6 +368,7 @@ class GoodsDrawer extends React.Component<GoodsDrawerProps, GoodsDrawerState> {
childArr = childArr.filter((item: any) => !setChildArr.some((e: any) => e === item)); childArr = childArr.filter((item: any) => !setChildArr.some((e: any) => e === item));
} }
// const filtered = this.filterProductByProcessEnum(childArr, data);
if (!('checked' in this.props)) { if (!('checked' in this.props)) {
this.setState({ childSelectedRowKeys: childArr }); this.setState({ childSelectedRowKeys: childArr });
} }
...@@ -344,6 +389,8 @@ class GoodsDrawer extends React.Component<GoodsDrawerProps, GoodsDrawerState> { ...@@ -344,6 +389,8 @@ class GoodsDrawer extends React.Component<GoodsDrawerProps, GoodsDrawerState> {
data.forEach((item: any) => { data.forEach((item: any) => {
setChildArr = [...setChildArr, ...item.productDateilss.map((item: any) => item.id)]; setChildArr = [...setChildArr, ...item.productDateilss.map((item: any) => item.id)];
}); });
// const filtered = this.filterProductByProcessEnum(setChildArr, data);
// 第一步判断 selected true:全选,false:取消全选 // 第一步判断 selected true:全选,false:取消全选
if (selected) { if (selected) {
// 第二步:父Table选中,子Table全选中,设置子Table 的 SelectedRowKeys // 第二步:父Table选中,子Table全选中,设置子Table 的 SelectedRowKeys
...@@ -423,6 +470,20 @@ class GoodsDrawer extends React.Component<GoodsDrawerProps, GoodsDrawerState> { ...@@ -423,6 +470,20 @@ class GoodsDrawer extends React.Component<GoodsDrawerProps, GoodsDrawerState> {
} }
}; };
// 过滤工作流不同的 商品
filterProductByProcessEnum = (selectKeys, data) => {
const first = data.length ? data[0] : null;
if (!first) {
return;
}
const filtered = data.filter(item => item.processEnum === first.processEnum);
if (filtered.length !== data.length) {
message.warning('已过滤掉售后工作流不同的商品');
}
return filtered;
};
render() { render() {
const { const {
page, page,
......
...@@ -612,6 +612,7 @@ const ReturnForm: React.FC<BillsFormProps> = ({ ...@@ -612,6 +612,7 @@ const ReturnForm: React.FC<BillsFormProps> = ({
<GoodsDrawer <GoodsDrawer
title="选择退货商品" title="选择退货商品"
type={3}
visible={visibleGoodsDrawer} visible={visibleGoodsDrawer}
fetchOrderList={getOrderList} fetchOrderList={getOrderList}
onClose={() => setVisibleGoodsDrawer(false)} onClose={() => setVisibleGoodsDrawer(false)}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment