Commit f611fc4d authored by Bill's avatar Bill

Merge branch 'dev' of 10.0.0.22:lingxi/lingxi-business-paltform into dev

parents 4d45b3bb d66023ca
......@@ -7,10 +7,17 @@
*/
import React from 'react';
import { Upload } from 'antd';
import { FileData } from '@/utils';
import MellowCard from '@/components/MellowCard';
import styles from './index.less';
const FileList: React.FC = () => {
interface FileListProps {
fileList: FileData[];
};
const FileList: React.FC<FileListProps> = ({
fileList = [],
}) => {
return (
<MellowCard
title="相关不良原因举证附件"
......@@ -18,21 +25,7 @@ const FileList: React.FC = () => {
>
<Upload
className={styles.file}
fileList={[
{
uid: '1',
name: 'xxx.png',
status: 'done',
response: 'Server Error 500', // custom error message to show
url: 'http://www.baidu.com/xxx.png',
},
{
uid: '2',
name: 'yyy.png',
status: 'done',
url: 'http://www.baidu.com/yyy.png',
},
]}
fileList={fileList}
/>
</MellowCard>
);
......
......@@ -22,6 +22,8 @@ interface HistoryListHistoryListProps {
rowKey?: string;
// 目标路径
target?: string;
// loading
loading?: boolean;
};
const ProductList: React.FC<HistoryListHistoryListProps> = ({
......@@ -30,6 +32,7 @@ const ProductList: React.FC<HistoryListHistoryListProps> = ({
columns = [],
rowKey = 'id',
target,
loading = false,
}) => {
return (
......@@ -40,7 +43,7 @@ const ProductList: React.FC<HistoryListHistoryListProps> = ({
rowKey={rowKey}
dataSource={dataSource}
columns={columns}
loading={false}
loading={loading}
pagination={null}
/>
</MellowCard>
......
......@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2020-11-03 13:53:58
* @LastEditors: XieZhiXiong
* @LastEditTime: 2020-11-03 14:11:57
* @LastEditTime: 2020-11-16 17:59:26
* @Description: 维修地址
*/
import React from 'react';
......@@ -10,7 +10,21 @@ import { Descriptions } from 'antd';
import MellowCard from '@/components/MellowCard';
import styles from './index.less';
const RepairAddressInfo: React.FC = () => {
export interface RepairAddressInfoProps {
info: {
id: string;
// 收件人
receiverName: string;
// 电话
phone: string;
// 详细地址
fullAddress: string;
};
};
const RepairAddressInfo: React.FC<RepairAddressInfoProps> = ({
info = {},
}) => {
return (
<MellowCard
title="维修地址"
......@@ -18,8 +32,8 @@ const RepairAddressInfo: React.FC = () => {
>
<Descriptions column={1} className={styles.desc}>
<Descriptions.Item label="维修地址">
<p>张三 / 185 2929 6475</p>
<p>广东省广州市海珠区新港东路1068号中洲中心北塔6楼</p>
<p>{info.receiverName || ''} / {info.phone || ''}</p>
<p>{info.fullAddress || ''}</p>
</Descriptions.Item>
</Descriptions>
</MellowCard>
......
......@@ -2,26 +2,51 @@
* @Author: XieZhiXiong
* @Date: 2020-11-03 14:12:34
* @LastEditors: XieZhiXiong
* @LastEditTime: 2020-11-03 17:48:20
* @LastEditTime: 2020-11-16 18:02:24
* @Description: 评价
*/
import React from 'react';
import MellowCard from '@/components/MellowCard';
import { Gauge } from '@/components/Charts';
const Score: React.FC = () => {
// 满分 5分
const FULL_SCORE = 5;
const COLOR_MAP = {
0: '#EF6260',
1: '#EF6260',
2: '#FFC400',
3: '#6C9CEB',
4: '#41CC9E',
5: '#41CC9E',
};
const TITLE_MAP = {
0: '非常不满意',
1: '非常不满意',
2: '不满意',
3: '一般',
4: '满意',
5: '非常满意',
};
interface ScoreProps {
score: number;
};
const Score: React.FC<ScoreProps> = ({
score = 0,
}) => {
return (
<MellowCard
title="售后评价"
fullHeight
>
<Gauge
title="5分"
title={`${score}分`}
height={170}
percent={80}
percent={+(score/FULL_SCORE).toFixed(2)}
formatter={() => ''}
formatContent={(val) => `非常满意${val}`}
color="#41CC9E"
formatContent={(val) => `${TITLE_MAP[score]}${val}`}
color={COLOR_MAP[score]}
/>
</MellowCard>
);
......
......@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2020-10-28 17:29:14
* @LastEditors: XieZhiXiong
* @LastEditTime: 2020-10-28 17:38:06
* @LastEditTime: 2020-11-16 18:28:40
* @Description: 提交审核 Modal
*/
import React from 'react';
......@@ -48,8 +48,8 @@ const VerifyModal: React.FC<VerifyModalProps> = ({
>
<NiceForm
effects={($, { setFieldState }) => {
onFieldValueChange$('agree').subscribe(fieldState => {
setFieldState('reason', state => {
onFieldValueChange$('isPass').subscribe(fieldState => {
setFieldState('opinion', state => {
state.visible = !fieldState.value;
});
});
......
......@@ -14,9 +14,8 @@ import { FormOutlined } from '@ant-design/icons';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { history } from 'umi';
import { PublicApi } from '@/services/api';
import { GetAsRepairGoodsGetDetailByConsumerResponse } from '@/services/AfterServiceApi';
import { CREDIT_INNER_STATUS, CREDIT_OUTER_STATUS, CREDIT_STATUS } from '@/constants';
import { normalizeFiledata, FileData, findLastIndexFlowState } from '@/utils';
import { GetAsRepairGoodsGetDetailByConsumerResponse, GetAsRepairGoodsPageRepairGoodsResponse } from '@/services/AfterServiceApi';
import { normalizeFiledata, FileData, findLastIndexFlowState, isJSONStr } from '@/utils';
import AvatarWrap from '@/components/AvatarWrap';
import StatusTag from '@/components/StatusTag';
import EyePreview from '@/components/EyePreview';
......@@ -44,14 +43,20 @@ interface DetailInfoProps {
headExtra?: React.ReactNode;
};
interface DetailInfo extends GetAsRepairGoodsGetDetailByConsumerResponse {
fileList: FileData[];
};
const DetailInfo: React.FC<DetailInfoProps> = ({
id,
isEdit = false,
target,
headExtra = null,
}) => {
const [detailInfo, setDetailInfo] = useState<GetAsRepairGoodsGetDetailByConsumerResponse>(null);
const [detailInfo, setDetailInfo] = useState<DetailInfo>(null);
const [repairGoodsList, setRepairGoodsList] = useState<GetAsRepairGoodsPageRepairGoodsResponse>({ data: [], totalCount: 0 });
const [infoLoading, setInfoLoading] = useState(false);
const [repairGoodsLoading, setRepairGoodsLoading] = useState(false);
const productColumns: EditableColumns[] = [
{
......@@ -66,8 +71,8 @@ const DetailInfo: React.FC<DetailInfoProps> = ({
),
},
{
title: 'ID',
dataIndex: 'id',
title: '商品ID',
dataIndex: 'productId',
align: 'center',
},
{
......@@ -92,17 +97,17 @@ const DetailInfo: React.FC<DetailInfoProps> = ({
},
{
title: '采购数量',
dataIndex: 'quantity',
dataIndex: 'purchaseCount',
align: 'center',
},
{
title: '维修数量',
dataIndex: 'num',
dataIndex: 'repairCount',
align: 'center',
},
{
title: '维修原因',
dataIndex: 'reason',
dataIndex: 'repairReason',
align: 'center',
},
];
......@@ -117,15 +122,50 @@ const DetailInfo: React.FC<DetailInfoProps> = ({
repairId: id,
}).then(res => {
if (res.code === 1000) {
setDetailInfo(res.data);
const {
repairAddress,
faultFileList,
supplierName,
supplierMemberId,
supplierRoleId,
...rest
} = res.data;
setDetailInfo({
faultFileList,
supplierName,
...rest,
fileList: faultFileList.map(item => normalizeFiledata(item.filePath)),
repairAddress: isJSONStr(repairAddress) || null,
});
}
}).finally(() => {
setInfoLoading(false);
});
};
// 获取维修明细列表
const getRepairGoods = () => {
if (!id) {
return;
}
setRepairGoodsLoading(true);
PublicApi.getAsRepairGoodsPageRepairGoods({
repairId: id,
current: `${1}`,
pageSize: `${99999}`,
}).then(res => {
if (res.code === 1000) {
setRepairGoodsList(res.data);
}
}).finally(() => {
setRepairGoodsLoading(false);
});
};
useEffect(() => {
getDetailInfo();
getRepairGoods();
}, []);
return (
......@@ -195,8 +235,10 @@ const DetailInfo: React.FC<DetailInfoProps> = ({
<Suspense fallback={null}>
<ProductList
title="维修商品"
rowKey="orderRecordId"
columns={productColumns}
dataSource={[]}
dataSource={repairGoodsList.data}
loading={repairGoodsLoading}
/>
</Suspense>
</Col>
......@@ -208,19 +250,19 @@ const DetailInfo: React.FC<DetailInfoProps> = ({
>
<Col span={6}>
<Suspense fallback={null}>
<FileList />
<FileList fileList={detailInfo?.fileList} />
</Suspense>
</Col>
<Col span={12}>
<Suspense fallback={null}>
<RepairAddressInfo />
<RepairAddressInfo info={detailInfo && detailInfo.repairAddress ? detailInfo.repairAddress as any : {}} />
</Suspense>
</Col>
<Col span={6}>
<Suspense fallback={null}>
<Score />
<Score score={detailInfo?.evaluate?.level} />
</Suspense>
</Col>
</Row>
......
......@@ -45,7 +45,7 @@ const RepairPrFinished: React.FC = () => {
render: (text, record) => (
<>
<EyePreview
url={`/memberCenter/afterService/repairApplication/repairPrFinished/detail?id=${record.id}`}
url={`/memberCenter/afterService/repairApplication/repairPrFinished/detail?id=${record.applyId}`}
>
{text}
</EyePreview>
......@@ -93,7 +93,7 @@ const RepairPrFinished: React.FC = () => {
<>
<Button
type="link"
onClick={() => history.push(`/memberCenter/afterService/repairApplication/repairPrFinished/verify`)}
onClick={() => history.push(`/memberCenter/afterService/repairApplication/repairPrFinished/verify?id=${record.applyId}`)}
>
确认售后完成
</Button>
......@@ -122,17 +122,6 @@ const RepairPrFinished: React.FC = () => {
reject();
});
});
// return Promise.resolve({
// data: [
// {
// id: 1,
// applyNo: '123',
// parentMemberName: '申请单摘要',
// created: '2020-11-03 11:46:00',
// },
// ],
// total: 10,
// });
};
// 初始化高级筛选选项
......
......@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2020-11-04 15:09:09
* @LastEditors: XieZhiXiong
* @LastEditTime: 2020-11-13 15:54:18
* @LastEditTime: 2020-11-16 16:22:36
* @Description: 维修商品抽屉组件
*/
import React, { useState, useEffect } from 'react';
......@@ -68,12 +68,16 @@ export interface OrderListRes {
};
interface GoodsDrawerProps {
// 选中值(子表格的值)
checked: number[];
// 是否可见的
visible: boolean;
// 关闭事件
onClose: () => void;
// 确定事件
onConfirm: (values: goodItem[]) => void;
// 选项改变事件
onChange: (value: number[]) => void;
// 获取订单列表数据
fetchOrderList: (params: any) => Promise<OrderListRes>;
};
......@@ -94,7 +98,51 @@ interface GoodsDrawerState {
loading: boolean;
};
// 跟 选中的子节点 找到 父级选中的 keys
function transformParentKeys(data: any[], childCheckedKeys: string[]) {
const ret = [];
if (!Array.isArray(data)) {
return ret;
}
data.forEach(item => {
const atom = {
checkeds: [],
...item,
};
// 这里循环遍历 判断 选中的子表格的keys中 是否包含 当前子项,如果有先 push 到父节点的 checkeds
if (item.productDateilss && item.productDateilss.length) {
item.productDateilss.forEach(childItem => {
if (childCheckedKeys.find(key => key === childItem.id)) {
atom.checkeds.push(childItem.id);
}
});
}
// 判断两者长度 一样 就表示父节点时候选中的
if (atom.checkeds.length === atom.productDateilss.length) {
ret.push(atom.id);
}
});
return ret;
};
class GoodsDrawer extends React.Component<GoodsDrawerProps, GoodsDrawerState> {
static getDerivedStateFromProps(nextProps, nextState) {
const { checked } = nextProps;
const { dataSource } = nextState;
const parents = transformParentKeys(dataSource.data, checked);
if ('checked' in nextProps) {
return {
selectedRowKeys: parents,
childSelectedRowKeys: checked,
};
}
return null;
}
constructor(props) {
super(props);
this.state = {
......@@ -243,22 +291,9 @@ class GoodsDrawer extends React.Component<GoodsDrawerProps, GoodsDrawerState> {
}
};
handleSetChildSelectedRowKeys = keys => {
this.setState({
childSelectedRowKeys: keys,
});
};
handleSetSelectedRowKeys = keys => {
this.setState({
selectedRowKeys: keys,
});
};
// 子表格选中行
handleChildSelectChange = (record: any, selected: any, selectedRows: any) => {
const {
selectedRowKeys,
childSelectedRowKeys,
dataSource: {
data,
......@@ -271,24 +306,11 @@ class GoodsDrawer extends React.Component<GoodsDrawerProps, GoodsDrawerState> {
} else {
childArr.splice(childArr.findIndex((item: any) => item === record.id), 1);
}
  // 必须去除undefined,否则selectedRows会将其他子Table中选中的 id值 放到数组中,但是值为undefined,如:[ undefined,1,uundefined]
selectedRows = selectedRows.filter((a: any) => a !== undefined);
// 第二步,判断selectedRows的长度是否为data中child的长度,相等,就将父table选中,不等就不选中
for (let item of data) {
if (item.productDateilss.find((d: any) => d.id === record.id)) {
let parentArr: any = [...selectedRowKeys];
if (item.productDateilss.length === selectedRows.length) {
parentArr.push(item.id);
} else {
if (parentArr.length && parentArr.find((d: any) => d === item.id)) {
parentArr.splice(parentArr.findIndex((item1: any) => item1 === item.id), 1);
}
}
this.handleSetSelectedRowKeys(parentArr);
break;
}
if (!('checked' in this.props)) {
this.setState({ childSelectedRowKeys: childArr });
}
this.handleSetChildSelectedRowKeys(childArr);
this.triggerChange(childArr);
};
// 子表格选中所有行
......@@ -309,22 +331,10 @@ class GoodsDrawer extends React.Component<GoodsDrawerProps, GoodsDrawerState> {
// 取消全选
childArr = childArr.filter((item: any) => !changeRows.some((e: any) => e.id === item));
}
// 第二步:找到子Table对应的父Table的所在行,再判断selected,true:将父Table所在行选中,false:将父Table所在行取消选中
for (let item of data) {
if (item.productDateilss.find((d: any) => d.id === changeRows[0].id)) {
let parentArr: any = [...selectedRowKeys];
if (selected) {
// 全选
parentArr.push(item.id);
} else {
// 取消全选
parentArr.splice(parentArr.findIndex((item: any) => item === item.id), 1);
}
this.handleSetSelectedRowKeys(parentArr);
break;
if (!('checked' in this.props)) {
this.setState({ childSelectedRowKeys: childArr });
}
}
this.handleSetChildSelectedRowKeys(childArr);
this.triggerChange(childArr);
};
// 表格选中行
......@@ -336,23 +346,22 @@ class GoodsDrawer extends React.Component<GoodsDrawerProps, GoodsDrawerState> {
data,
},
} = this.state;
let parentArr: any = [...selectedRowKeys];
let childArr: any = [...childSelectedRowKeys];
// setChildArr:选择父Table下的所有子选项
let setChildArr = data.find((d: any) => d.id === record.id).productDateilss.map((item: any) => item.id);
// 第一步 判断selected true:选中,false,取消选中
if (selected) {
// 第二步,父Table选中,子Table全选中(全部整合到一起,然后去重)
parentArr.push(record.id);
childArr = Array.from(new Set([...setChildArr, ...childArr]));
} else {
// 第二步,父Table取消选中,子Table全取消选中(针对childArr,过滤掉取消选中的父Table下的所有子Table的 id)
parentArr.splice(parentArr.findIndex((item: any) => item === record.id), 1);
childArr = childArr.filter((item: any) => !setChildArr.some((e: any) => e === item));
}
// 第三步,设置父,子的SelectedRowKeys
this.handleSetSelectedRowKeys(parentArr);
this.handleSetChildSelectedRowKeys(childArr);
if (!('checked' in this.props)) {
this.setState({ childSelectedRowKeys: childArr });
}
this.triggerChange(childArr);
};
// 表格选中所有行
......@@ -364,24 +373,25 @@ class GoodsDrawer extends React.Component<GoodsDrawerProps, GoodsDrawerState> {
data,
},
} = this.state;
let parentArr: any = [...selectedRowKeys];
let setChildArr: any = [];
  // 将改变的父Table下的子Table下的 id 都添加到setChildArr中
changeRows.forEach((item: any) => {
data.forEach((item: any) => {
setChildArr = [...setChildArr, ...item.productDateilss.map((item: any) => item.id)];
});
// 第一步判断 selected true:全选,false:取消全选
if (selected) {
// 第二步:父Table选中,子Table全选中,设置子Table 的 SelectedRowKeys
parentArr = Array.from(new Set([...parentArr, ...changeRows.map((item: any) => item.id)]));
this.handleSetChildSelectedRowKeys(setChildArr);
if (!('checked' in this.props)) {
this.setState({ childSelectedRowKeys: setChildArr });
}
this.triggerChange(setChildArr);
} else {
// 第二步:父Table取消选中,子Table 全取消选中,设置子 Table 的 SelectedRowKeys
parentArr = parentArr.filter((item: any) => !changeRows.some((e: any) => e.id === item));
this.handleSetChildSelectedRowKeys([]);
if (!('checked' in this.props)) {
this.setState({ childSelectedRowKeys: [] });
}
this.triggerChange([]);
}
// 第三步:设置父Table的SelectedRowKeys
this.handleSetSelectedRowKeys(parentArr);
};
handleConfirm = () => {
......@@ -411,6 +421,20 @@ class GoodsDrawer extends React.Component<GoodsDrawerProps, GoodsDrawerState> {
this.handleClose();
};
handleAfterVisibleChange = visible => {
console.log('visible', visible)
if (!visible) {
this.handleClose();
}
};
triggerChange = changedValue => {
const { onChange } = this.props;
if (onChange) {
onChange(changedValue);
}
};
render() {
const {
page,
......@@ -428,7 +452,8 @@ class GoodsDrawer extends React.Component<GoodsDrawerProps, GoodsDrawerState> {
<Drawer
title="选择维修商品"
width={1200}
onClose={this.handleClose}
// onClose={this.handleClose}
afterVisibleChange={this.handleAfterVisibleChange}
visible={visible}
footer={
<div
......
......@@ -8,6 +8,7 @@ import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { SaveOutlined, PlusOutlined } from '@ant-design/icons';
import { createFormActions, FormEffectHooks } from '@formily/antd';
import { PublicApi } from '@/services/api';
import { GetAsRepairGoodsPageRepairGoodsResponse } from '@/services/AfterServiceApi';
import { normalizeFiledata, FileData, isJSONStr } from '@/utils';
import ReutrnEle from '@/components/ReturnEle';
import NiceForm from '@/components/NiceForm';
......@@ -31,6 +32,10 @@ interface DetailInfo {
faultFileList?: FileData[];
repairAddress?: { [key: string]: any }[];
supplierMember?: {},
outerStatus?: number,
outerStatusName?: string,
innerStatus?: number,
innerStatusName?: string,
}
interface BillsFormProps {
......@@ -46,14 +51,14 @@ const RepairForm: React.FC<BillsFormProps> = ({
const [detailInfo, setDetailInfo] = useState<DetailInfo>({
applyTime: moment().format('YYYY-MM-DD HH:mm:ss'),
});
const [visible, setVisible] = useState(false);
const [repairGoodsList, setRepairGoodsList] = useState<GetAsRepairGoodsPageRepairGoodsResponse>({ data: [], totalCount: 0 });
const [unsaved, setUnsaved] = useState(false);
const [infoLoading, setInfoLoading] = useState(false);
const [repairGoodsLoading, setRepairGoodsLoading] = useState(false);
const [goodsValue, setGoodsValue] = useState([]);
const [submitLoading, setSubmitLoading] = useState(false);
const [visibleDrawer, setVisibleDrawer] = useState(false);
const goodsDrawerRef = useRef(null);
// 获取维修申请详情
const getDetailInfo = () => {
if (!id) {
......@@ -68,6 +73,8 @@ const RepairForm: React.FC<BillsFormProps> = ({
repairAddress,
faultFileList,
supplierName,
supplierMemberId,
supplierRoleId,
...rest
} = res.data;
......@@ -79,6 +86,7 @@ const RepairForm: React.FC<BillsFormProps> = ({
);
setDetailInfo({
...detailInfo,
faultFileList: faultFileList.map(item => normalizeFiledata(item.filePath)),
repairAddress: isJSONStr(repairAddress) || null,
supplierMember:
......@@ -86,6 +94,8 @@ const RepairForm: React.FC<BillsFormProps> = ({
[
{
name: supplierName,
memberId: supplierMemberId,
roleId: supplierRoleId,
},
] :
[]
......@@ -98,6 +108,26 @@ const RepairForm: React.FC<BillsFormProps> = ({
});
};
// 获取维修明细列表
const getRepairGoods = () => {
if (!id) {
return;
}
setRepairGoodsLoading(true);
PublicApi.getAsRepairGoodsPageRepairGoods({
repairId: id,
current: `${1}`,
pageSize: `${99999}`,
}).then(res => {
if (res.code === 1000) {
setRepairGoodsList(res.data);
setGoodsValue(res.data && res.data.data ? res.data.data.map(item => item.orderRecordId) : []);
}
}).finally(() => {
setRepairGoodsLoading(false);
});
};
// 根据供应会员获取订单列表
const getOrderList = (params): Promise<OrderListRes> => {
const supplierMemberValue = addSchemaAction.getFieldValue('supplierMember');
......@@ -120,6 +150,7 @@ const RepairForm: React.FC<BillsFormProps> = ({
useEffect(() => {
getDetailInfo();
getRepairGoods();
}, []);
const handleAddGoods = () => {
......@@ -153,9 +184,6 @@ const RepairForm: React.FC<BillsFormProps> = ({
...rest
} = values;
console.log('values', values)
return;
setSubmitLoading(true);
const payload = {
repairId: id || 0, // 有 id 表示编辑,0表示新增
......@@ -174,6 +202,7 @@ const RepairForm: React.FC<BillsFormProps> = ({
unit,
...rest
}) => ({
orderRecordId: id,
repairCount: +repairCount,
brand: brand || '',
unit: unit || '',
......@@ -195,22 +224,15 @@ const RepairForm: React.FC<BillsFormProps> = ({
});
};
// 删除维修商品项
const handleRemoveItem = (index: number) => {
const { childSelectedRowKeys } = goodsDrawerRef.current.state;
goodsDrawerRef.current.handleSetChildSelectedRowKeys([]);
// do something
// const newSelectRow = [...productRowCtl.selectRow];
// const newSelectedRowKeys = [...productRowCtl.selectedRowKeys];
// const newValue = [...addSchemaAction.getFieldValue('invoicesDetailsRequests')];
const newGoodsValue = [...goodsValue];
const newValue = [...addSchemaAction.getFieldValue('repairGoodsList')];
// newSelectRow.splice(index, 1);
// newSelectedRowKeys.splice(index, 1);
// productRowCtl.setSelectRow(newSelectRow);
// productRowCtl.setSelectedRowKeys(newSelectedRowKeys);
// newValue.splice(index, 1);
// addSchemaAction.setFieldValue('invoicesDetailsRequests', newValue);
const deleted = newValue.splice(index, 1);
addSchemaAction.setFieldValue('repairGoodsList', newValue);
newGoodsValue.splice(newGoodsValue.findIndex(item => item === deleted[0].id), 1);
setGoodsValue(newGoodsValue);
};
// ArrayTable自定义渲染
......@@ -255,6 +277,10 @@ const RepairForm: React.FC<BillsFormProps> = ({
addSchemaAction.setFieldValue('repairGoodsList', value);
};
const handleGoodsChange = values => {
setGoodsValue(values);
};
const OuterStatus = (
<StatusTag type={REPAIR_OUTER_STATUS_TAG_MAP[detailInfo?.outerStatus]} title={detailInfo?.outerStatusName} />
);
......@@ -264,7 +290,7 @@ const RepairForm: React.FC<BillsFormProps> = ({
);
return (
<Spin spinning={infoLoading}>
<Spin spinning={infoLoading || repairGoodsLoading}>
<PageHeaderWrapper
style={{
padding: 24,
......@@ -296,7 +322,10 @@ const RepairForm: React.FC<BillsFormProps> = ({
>
<Card>
<NiceForm
initialValues={detailInfo}
initialValues={{
...detailInfo,
repairGoodsList: repairGoodsList.data,
}}
expressionScope={{
TableAddButton,
OuterStatus,
......@@ -328,7 +357,8 @@ const RepairForm: React.FC<BillsFormProps> = ({
fetchOrderList={getOrderList}
onClose={() => setVisibleDrawer(false)}
onConfirm={handleGoodsConfirm}
ref={goodsDrawerRef}
checked={goodsValue}
onChange={handleGoodsChange}
/>
<Prompt when={unsaved} message="您还有未保存的内容,是否确定要离开?" />
......
......@@ -6,6 +6,7 @@ import {
Button,
Popconfirm,
Space,
message,
} from 'antd';
import { history } from 'umi';
import {
......@@ -25,11 +26,15 @@ import { coverColFiltersItem } from '@/utils';
import EyePreview from '@/components/EyePreview';
import NiceForm from '@/components/NiceForm';
import StatusTag from '@/components/StatusTag';
import { listSearchSchema } from './schema';
import {
REPAIR_INNER_STATUS_UNCOMMITTED,
REPAIR_OUTER_STATUS_FAILED,
} from '@/constants';
import {
REPAIR_OUTER_STATUS_TAG_MAP,
REPAIR_INNER_STATUS_BADGE_MAP,
} from '../../constants';
import { listSearchSchema } from './schema';
import styles from './index.less';
const formActions = createFormActions();
......@@ -37,6 +42,38 @@ const formActions = createFormActions();
const RepairPrSubmit: React.FC = () => {
const ref = useRef<any>({});
const handleDelete = record => {
const msg = message.loading({
content: '正在删除',
duration: 0,
});
PublicApi.postAsRepairGoodsDelete({
dataId: record.applyId,
}).then(res => {
if (res.code === 1000) {
ref.current.reload();
}
}).finally(() => {
msg();
});
};
const handleSubmit = record => {
const msg = message.loading({
content: '正在提交',
duration: 0,
});
PublicApi.postAsRepairGoodsSubmit({
dataId: record.applyId,
}).then(res => {
if (res.code === 1000) {
ref.current.reload();
}
}).finally(() => {
msg();
});
};
const defaultColumns: ColumnType<any>[] = [
{
title: '申请单号',
......@@ -45,7 +82,7 @@ const RepairPrSubmit: React.FC = () => {
render: (text, record) => (
<>
<EyePreview
url={`/memberCenter/afterService/repairApplication/repairPrSubmit/detail?id=${record.id}`}
url={`/memberCenter/afterService/repairApplication/repairPrSubmit/detail?id=${record.applyId}`}
>
{text}
</EyePreview>
......@@ -91,17 +128,20 @@ const RepairPrSubmit: React.FC = () => {
align: 'center',
render: (text, record) => (
<>
{record.outerStatus === REPAIR_INNER_STATUS_UNCOMMITTED && (
<Button
type="link"
onClick={() => {}}
onClick={() => handleSubmit(record)}
>
提交
</Button>
)}
{record.outerStatus === REPAIR_INNER_STATUS_UNCOMMITTED && (
<Popconfirm
title="确定要删除吗?"
okText="是"
cancelText="否"
onConfirm={() => {}}
onConfirm={() => handleDelete(record)}
>
<Button
type="link"
......@@ -110,12 +150,19 @@ const RepairPrSubmit: React.FC = () => {
删除
</Button>
</Popconfirm>
)}
{/* 外部状态为不接受申请 或者 内部状态为 待提交申请 都可以进行编辑 */}
{(
record.outerStatus === REPAIR_OUTER_STATUS_FAILED ||
record.innerStatus === REPAIR_INNER_STATUS_UNCOMMITTED
) && (
<Button
type="link"
onClick={() => history.push(`/memberCenter/afterService/repairApplication/repairPrSubmit/edit?id=${record.applyId}`)}
>
编辑
</Button>
)}
</>
),
},
......@@ -141,17 +188,6 @@ const RepairPrSubmit: React.FC = () => {
reject();
});
});
// return Promise.resolve({
// data: [
// {
// id: 1,
// applyNo: '123',
// parentMemberName: '申请单摘要',
// created: '2020-11-03 11:46:00',
// },
// ],
// total: 10,
// });
};
// 初始化高级筛选选项
......
......@@ -14,9 +14,8 @@ import { FormOutlined } from '@ant-design/icons';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { history } from 'umi';
import { PublicApi } from '@/services/api';
import { GetAsRepairGoodsGetDetailBySupplierResponse } from '@/services/AfterServiceApi';
import { CREDIT_INNER_STATUS, CREDIT_OUTER_STATUS, CREDIT_STATUS } from '@/constants';
import { normalizeFiledata, FileData, findLastIndexFlowState } from '@/utils';
import { GetAsRepairGoodsGetDetailBySupplierResponse, GetAsRepairGoodsPageRepairGoodsResponse } from '@/services/AfterServiceApi';
import { normalizeFiledata, FileData, findLastIndexFlowState, isJSONStr } from '@/utils';
import AvatarWrap from '@/components/AvatarWrap';
import StatusTag from '@/components/StatusTag';
import AuditProcess from '@/components/AuditProcess';
......@@ -44,14 +43,20 @@ interface DetailInfoProps {
headExtra?: React.ReactNode;
};
interface DetailInfo extends GetAsRepairGoodsGetDetailBySupplierResponse {
fileList: FileData[];
};
const DetailInfo: React.FC<DetailInfoProps> = ({
id,
isEdit = false,
target,
headExtra = null,
}) => {
const [detailInfo, setDetailInfo] = useState<GetAsRepairGoodsGetDetailBySupplierResponse>(null);
const [infoLoading, setInfoloading] = useState(false);
const [detailInfo, setDetailInfo] = useState<DetailInfo>(null);
const [repairGoodsList, setRepairGoodsList] = useState<GetAsRepairGoodsPageRepairGoodsResponse>({ data: [], totalCount: 0 });
const [infoLoading, setInfoLoading] = useState(false);
const [repairGoodsLoading, setRepairGoodsLoading] = useState(false);
const productColumns: EditableColumns[] = [
{
......@@ -66,8 +71,8 @@ const DetailInfo: React.FC<DetailInfoProps> = ({
),
},
{
title: 'ID',
dataIndex: 'id',
title: '商品ID',
dataIndex: 'productId',
align: 'center',
},
{
......@@ -92,17 +97,17 @@ const DetailInfo: React.FC<DetailInfoProps> = ({
},
{
title: '采购数量',
dataIndex: 'quantity',
dataIndex: 'purchaseCount',
align: 'center',
},
{
title: '维修数量',
dataIndex: 'num',
dataIndex: 'repairCount',
align: 'center',
},
{
title: '维修原因',
dataIndex: 'reason',
dataIndex: 'repairReason',
align: 'center',
},
];
......@@ -112,20 +117,53 @@ const DetailInfo: React.FC<DetailInfoProps> = ({
if (!id) {
return;
}
setInfoloading(true);
setInfoLoading(true);
PublicApi.getAsRepairGoodsGetDetailBySupplier({
repairId: id,
}).then(res => {
if (res.code === 1000) {
setDetailInfo(res.data);
const {
repairAddress,
faultFileList,
supplierName,
...rest
} = res.data;
setDetailInfo({
faultFileList,
supplierName,
...rest,
fileList: faultFileList.map(item => normalizeFiledata(item.filePath)),
repairAddress: isJSONStr(repairAddress) || null,
});
}
}).finally(() => {
setInfoLoading(false);
});
};
// 获取维修明细列表
const getRepairGoods = () => {
if (!id) {
return;
}
setRepairGoodsLoading(true);
PublicApi.getAsRepairGoodsPageRepairGoods({
repairId: id,
current: `${1}`,
pageSize: `${99999}`,
}).then(res => {
if (res.code === 1000) {
setRepairGoodsList(res.data);
}
}).finally(() => {
setInfoloading(false);
setRepairGoodsLoading(false);
});
};
useEffect(() => {
getDetailInfo();
getRepairGoods();
}, []);
return (
......@@ -208,8 +246,10 @@ const DetailInfo: React.FC<DetailInfoProps> = ({
<Suspense fallback={null}>
<ProductList
title="维修商品"
rowKey="orderRecordId"
columns={productColumns}
dataSource={[]}
dataSource={repairGoodsList.data}
loading={repairGoodsLoading}
/>
</Suspense>
</Col>
......@@ -221,19 +261,19 @@ const DetailInfo: React.FC<DetailInfoProps> = ({
>
<Col span={6}>
<Suspense fallback={null}>
<FileList />
<FileList fileList={detailInfo?.fileList} />
</Suspense>
</Col>
<Col span={12}>
<Suspense fallback={null}>
<RepairAddressInfo />
<RepairAddressInfo info={detailInfo && detailInfo.repairAddress ? detailInfo.repairAddress as any : {}} />
</Suspense>
</Col>
<Col span={6}>
<Suspense fallback={null}>
<Score />
<Score score={detailInfo?.evaluate?.level} />
</Suspense>
</Col>
</Row>
......
......@@ -37,7 +37,7 @@ const RepairPr1: React.FC = () => {
render: (text, record) => (
<>
<EyePreview
url={`/memberCenter/afterService/repairManage/repairPr1/detail?id=${record.id}`}
url={`/memberCenter/afterService/repairManage/repairPr1/detail?id=${record.applyId}`}
>
{text}
</EyePreview>
......@@ -85,7 +85,7 @@ const RepairPr1: React.FC = () => {
<>
<Button
type="link"
onClick={() => history.push(`/memberCenter/afterService/repairManage/repairPr1/verify?id=${record.id}`)}
onClick={() => history.push(`/memberCenter/afterService/repairManage/repairPr1/verify?id=${record.applyId}`)}
>
提交审核
</Button>
......@@ -114,17 +114,6 @@ const RepairPr1: React.FC = () => {
reject();
});
});
// return Promise.resolve({
// data: [
// {
// id: 1,
// applyNo: '123',
// parentMemberName: '申请单摘要',
// created: '2020-11-03 11:46:00',
// },
// ],
// total: 10,
// });
};
// 初始化高级筛选选项
......
......@@ -37,7 +37,7 @@ const RepairPr2: React.FC = () => {
render: (text, record) => (
<>
<EyePreview
url={`/memberCenter/afterService/repairManage/repairPr2/detail?id=${record.id}`}
url={`/memberCenter/afterService/repairManage/repairPr2/detail?id=${record.applyId}`}
>
{text}
</EyePreview>
......@@ -85,7 +85,7 @@ const RepairPr2: React.FC = () => {
<>
<Button
type="link"
onClick={() => history.push(`/memberCenter/afterService/repairManage/repairPr2/verify?id=${record.id}`)}
onClick={() => history.push(`/memberCenter/afterService/repairManage/repairPr2/verify?id=${record.applyId}`)}
>
提交审核
</Button>
......
......@@ -37,7 +37,7 @@ const RepairPrConfirm: React.FC = () => {
render: (text, record) => (
<>
<EyePreview
url={`/memberCenter/afterService/repairManage/repairPrConfirm/detail?id=${record.id}`}
url={`/memberCenter/afterService/repairManage/repairPrConfirm/detail?id=${record.applyId}`}
>
{text}
</EyePreview>
......@@ -46,17 +46,17 @@ const RepairPrConfirm: React.FC = () => {
},
{
title: '申请单摘要',
dataIndex: 'parentMemberName',
dataIndex: 'applyAbstract',
align: 'center',
},
{
title: '采购会员',
dataIndex: 'purchaser',
dataIndex: 'consumerName',
align: 'center',
},
{
title: '单据时间',
dataIndex: 'created',
dataIndex: 'applyTime',
align: 'center',
},
{
......@@ -85,7 +85,7 @@ const RepairPrConfirm: React.FC = () => {
<>
<Button
type="link"
onClick={() => history.push(`/memberCenter/afterService/repairManage/repairPrConfirm/verify?id=${record.id}`)}
onClick={() => history.push(`/memberCenter/afterService/repairManage/repairPrConfirm/verify?id=${record.applyId}`)}
>
提交审核
</Button>
......
......@@ -37,7 +37,7 @@ const RepairPrSubmit: React.FC = () => {
render: (text, record) => (
<>
<EyePreview
url={`/memberCenter/afterService/repairManage/repairPrSubmit/detail?id=${record.id}`}
url={`/memberCenter/afterService/repairManage/repairPrSubmit/detail?id=${record.applyId}`}
>
{text}
</EyePreview>
......@@ -85,7 +85,7 @@ const RepairPrSubmit: React.FC = () => {
<>
<Button
type="link"
onClick={() => history.push(`/memberCenter/afterService/repairManage/repairPrSubmit/verify?id=${record.id}`)}
onClick={() => history.push(`/memberCenter/afterService/repairManage/repairPrSubmit/verify?id=${record.applyId}`)}
>
提交审核
</Button>
......@@ -114,17 +114,6 @@ const RepairPrSubmit: React.FC = () => {
reject();
});
});
// return Promise.resolve({
// data: [
// {
// id: 1,
// applyNo: '123',
// parentMemberName: '申请单摘要',
// created: '2020-11-03 11:46:00',
// },
// ],
// total: 10,
// });
};
// 初始化高级筛选选项
......
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