Commit 54b15728 authored by XieZhiXiong's avatar XieZhiXiong

chore: 完善 售后维修相关

parent add727ad
......@@ -22,6 +22,11 @@ import EyePreview from '@/components/EyePreview';
import { EditableColumns } from '@/components/PolymericTable/interface';
import { REPAIR_OUTER_STATUS_FINISHED } from '@/constants';
import {
ORDER_TYPE_INQUIRY_CONTRACT,
ORDER_TYPE_BIDDING_CONTRACT,
ORDER_TYPE_TENDER_CONTRACT,
} from '@/constants/order';
import {
REPAIR_OUTER_STATUS_TAG_MAP,
REPAIR_INNER_STATUS_BADGE_MAP,
} from '../../../constants';
......@@ -68,6 +73,12 @@ const DetailInfo: React.FC<DetailInfoProps> = ({
const [infoLoading, setInfoLoading] = useState(false);
const [repairGoodsLoading, setRepairGoodsLoading] = useState(false);
const isMateriel = (
detailInfo?.orderType === ORDER_TYPE_INQUIRY_CONTRACT
|| detailInfo?.orderType === ORDER_TYPE_BIDDING_CONTRACT
|| detailInfo?.orderType === ORDER_TYPE_TENDER_CONTRACT
);
const productColumns: EditableColumns[] = [
{
title: '订单号',
......@@ -80,31 +91,70 @@ const DetailInfo: React.FC<DetailInfoProps> = ({
</EyePreview>
),
},
{
title: '商品ID',
dataIndex: 'productId',
align: 'center',
},
{
title: '商品名称',
dataIndex: 'productName',
align: 'center',
},
{
title: '品类',
dataIndex: 'category',
align: 'center',
},
{
title: '品牌',
dataIndex: 'brand',
align: 'center',
},
{
title: '单位',
dataIndex: 'unit',
align: 'center',
},
...(
!isMateriel
? [
{
title: '商品ID',
dataIndex: 'productId',
align: 'center',
},
{
title: '商品名称',
dataIndex: 'productName',
align: 'center',
},
{
title: '品类',
dataIndex: 'category',
align: 'center',
},
{
title: '品牌',
dataIndex: 'brand',
align: 'center',
},
{
title: '单位',
dataIndex: 'unit',
align: 'center',
}
]
: [
{
title: '物料编号',
dataIndex: 'materielNo',
align: 'center',
},
{
title: '物料名称、规格',
dataIndex: 'materielName',
align: 'center',
render: (text, record) => `${text}/${record.materielType}`,
},
{
title: '品类',
dataIndex: 'materielCategory',
align: 'center',
},
{
title: '品牌',
dataIndex: 'materielBrand',
align: 'center',
},
{
title: '单位',
dataIndex: 'materielUnit',
align: 'center',
},
{
title: detailInfo?.orderType !== ORDER_TYPE_TENDER_CONTRACT ? '关联报价商品ID、名称、规格、品类、品牌' : '关联投标商品ID、名称、规格、品类、品牌',
dataIndex: 'productId',
align: 'center',
render: (text, record) => `${text}/${record.productName}/${record.category}/${record.brand}`,
},
]
),
{
title: '采购数量',
dataIndex: 'purchaseCount',
......@@ -120,7 +170,7 @@ const DetailInfo: React.FC<DetailInfoProps> = ({
dataIndex: 'repairReason',
align: 'center',
},
];
] as EditableColumns[];
// 获取维修申请详情
const getDetailInfo = () => {
......
......@@ -10,7 +10,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 { GetAsRepairGoodsPageRepairGoodsResponseDetail } from '@/services/AfterServiceApi';
import { normalizeFiledata, FileData, isJSONStr } from '@/utils';
import {
PurchaseOrderOutWorkStateTexts,
......@@ -88,7 +88,7 @@ const RepairForm: React.FC<BillsFormProps> = ({
const [detailInfo, setDetailInfo] = useState<DetailInfo>({
applyTime: moment().format('YYYY-MM-DD HH:mm:ss'),
});
const [repairGoodsList, setRepairGoodsList] = useState<GetAsRepairGoodsPageRepairGoodsResponse>({ data: [], totalCount: 0 });
const [repairGoodsList, setRepairGoodsList] = useState<GetAsRepairGoodsPageRepairGoodsResponseDetail[]>([]);
const [unsaved, setUnsaved] = useState(false);
const [infoLoading, setInfoLoading] = useState(false);
const [repairGoodsLoading, setRepairGoodsLoading] = useState(false);
......@@ -139,9 +139,8 @@ const RepairForm: React.FC<BillsFormProps> = ({
},
isMateriel ? {
title: '合同编号',
dataIndex: 'type2',
dataIndex: 'contractNo',
align: 'center',
render: () => 'H-13-00002',
} : null,
].filter(Boolean) as ColumnType<any>[];
......@@ -192,6 +191,35 @@ 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.data.map(item => ({
...item,
extraData: {
id: item.orderRecordId,
orderId: item.orderId,
remaining: item.purchaseCount || 0, // 已维修数量,这里取 采购数量判断即可
},
associated: !item.materielId ? '' : `${item.productId}/${item.productName}/${item.category}/${item.brand}`,
materielNameAndType: `${item.materielName || ''}${item.materielType ? '/' + item.materielType : ''}`,
})));
setGoodsValue(res.data && res.data.data ? res.data.data.map(item => item.orderRecordId) : []);
}
}).finally(() => {
setRepairGoodsLoading(false);
});
};
// 获取维修申请详情
const getDetailInfo = () => {
if (!id) {
......@@ -208,6 +236,14 @@ const RepairForm: React.FC<BillsFormProps> = ({
supplierName,
parentMemberId,
parentMemberRoleId,
applyId,
consumerName,
evaluate,
innerRecordList,
innerTaskList,
outerRecordList,
outerStatus,
outerTaskList,
...rest
} = res.data;
......@@ -235,6 +271,7 @@ const RepairForm: React.FC<BillsFormProps> = ({
,
...rest,
});
getRepairGoods();
}
}).finally(() => {
setInfoLoading(false);
......@@ -289,37 +326,6 @@ 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);
setRepairGoodsList({
data: res.data.data.map(item => ({
...item,
extraData: {
id: item.orderRecordId,
orderId: item.orderId,
remaining: item.purchaseCount || 0, // 已维修数量,这里取 采购数量判断即可
},
})),
totalCount: res.data.totalCount,
});
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');
......@@ -345,7 +351,6 @@ const RepairForm: React.FC<BillsFormProps> = ({
useEffect(() => {
getDetailInfo();
getOrderDetailInfo();
getRepairGoods();
}, []);
const handleAddGoods = () => {
......@@ -363,16 +368,17 @@ const RepairForm: React.FC<BillsFormProps> = ({
setVisibleDrawer(true);
};
const TableAddButton = isEdit || !id ? (
const TableAddButton = (
<Button
icon={<PlusOutlined />}
onClick={handleAddGoods}
disabled={!isEdit || !!id}
type="dashed"
block
>
{!isMateriel ? '选择维修商品' : '选择维修物料'}
</Button>
) : null;
);
const handleSubmit = values => {
const {
......@@ -381,6 +387,10 @@ const RepairForm: React.FC<BillsFormProps> = ({
repairGoodsList,
repairAddress,
orderNo,
applyNo,
applyTime,
innerStatusName,
outerStatusName,
...rest
} = values;
......@@ -401,6 +411,7 @@ const RepairForm: React.FC<BillsFormProps> = ({
unit,
extraData,
associated,
materielNameAndType,
...rest
}) => ({
orderId: extraData.orderId,
......@@ -408,13 +419,6 @@ const RepairForm: React.FC<BillsFormProps> = ({
repairCount: +repairCount,
brand: brand || '',
unit: unit || '',
materielId: extraData.materiel ? extraData.materiel.materielId : 0,
materielNo: extraData.materiel ? extraData.materiel.materielNo : '',
materielName: extraData.materiel ? extraData.materiel.materielName : '',
materielType: extraData.materiel ? extraData.materiel.materielType : '',
materielCategory: extraData.materiel ? extraData.materiel.materielCategory : '',
materielBrand: extraData.materiel ? extraData.materiel.materielBrand : '',
materielUnit: extraData.materiel ? extraData.materiel.materielUnit : '',
...rest,
})),
...rest,
......@@ -476,26 +480,20 @@ const RepairForm: React.FC<BillsFormProps> = ({
brand: item.brand,
unit: item.unit,
purchaseCount: item.purchaseCount,
repairReason: '',
isHasTax: item.taxInclusive,
taxRate: item.taxRate,
contractId: item.contractId,
contractNo: item.contractNo,
repairReason: '',
associated: !isMateriel ? '' : `${item.productId}/${item.productName}/${item.category}/${item.brand}`,
extraData: {
id: item.id,
orderId: item.orderId,
remaining: item.purchaseCount - (item.repairCount || 0), // 可维修数量
materiel: !isMateriel ? null : {
materielId: item.materialId,
materielNo: item.materialCode,
materielName: item.materialName,
materielType: item.materialType,
materielCategory: item.materialCategory,
materielBrand: item.materialBrand,
materielUnit: '',
},
},
materielId: item.materialId,
materielNo: item.materialCode,
materielNameAndType: `${item.materialName || ''}${item.materialType ? '/' + item.materialType : ''}`,
materielName: item.materialName,
materielType: item.materialType,
materielCategory: item.materialCategory,
materielBrand: item.materialBrand,
materielUnit: item.materialUnit,
};
value.push(atom);
});
......@@ -556,8 +554,8 @@ const RepairForm: React.FC<BillsFormProps> = ({
<Card>
<NiceForm
value={{
...detailInfo,
repairGoodsList: repairGoodsList.data,
...detailInfo,
repairGoodsList: repairGoodsList,
}}
previewPlaceholder=" "
expressionScope={{
......
......@@ -301,27 +301,32 @@ export const addSchema = (orderType: number): ISchema => {
title: '物料编号',
'x-component': 'Text',
},
productName: {
materielNameAndType: {
type: 'string',
title: '物料名称、规格',
'x-component': 'Text',
},
materielName: {
type: 'string',
title: '物料名称',
'x-component': 'Text',
},
type: {
materielType: {
type: 'string',
title: '规格',
'x-component': 'Text',
},
category: {
materielCategory: {
type: 'string',
title: '品类',
'x-component': 'Text',
},
brand: {
materielBrand: {
type: 'string',
title: '品牌',
'x-component': 'Text',
},
unit: {
materielUnit: {
type: 'string',
title: '单位',
'x-component': 'Text',
......
......@@ -23,6 +23,11 @@ import EyePreview from '@/components/EyePreview';
import { EditableColumns } from '@/components/PolymericTable/interface';
import { REPAIR_OUTER_STATUS_FINISHED } from '@/constants';
import {
ORDER_TYPE_INQUIRY_CONTRACT,
ORDER_TYPE_BIDDING_CONTRACT,
ORDER_TYPE_TENDER_CONTRACT,
} from '@/constants/order';
import {
REPAIR_OUTER_STATUS_TAG_MAP,
REPAIR_INNER_STATUS_BADGE_MAP,
} from '../../../constants';
......@@ -68,6 +73,12 @@ const DetailInfo: React.FC<DetailInfoProps> = ({
const [infoLoading, setInfoLoading] = useState(false);
const [repairGoodsLoading, setRepairGoodsLoading] = useState(false);
const isMateriel = (
detailInfo?.orderType === ORDER_TYPE_INQUIRY_CONTRACT
|| detailInfo?.orderType === ORDER_TYPE_BIDDING_CONTRACT
|| detailInfo?.orderType === ORDER_TYPE_TENDER_CONTRACT
);
const productColumns: EditableColumns[] = [
{
title: '订单号',
......@@ -80,31 +91,70 @@ const DetailInfo: React.FC<DetailInfoProps> = ({
</EyePreview>
),
},
{
title: '商品ID',
dataIndex: 'productId',
align: 'center',
},
{
title: '商品名称',
dataIndex: 'productName',
align: 'center',
},
{
title: '品类',
dataIndex: 'category',
align: 'center',
},
{
title: '品牌',
dataIndex: 'brand',
align: 'center',
},
{
title: '单位',
dataIndex: 'unit',
align: 'center',
},
...(
!isMateriel
? [
{
title: '商品ID',
dataIndex: 'productId',
align: 'center',
},
{
title: '商品名称',
dataIndex: 'productName',
align: 'center',
},
{
title: '品类',
dataIndex: 'category',
align: 'center',
},
{
title: '品牌',
dataIndex: 'brand',
align: 'center',
},
{
title: '单位',
dataIndex: 'unit',
align: 'center',
}
]
: [
{
title: '物料编号',
dataIndex: 'materielNo',
align: 'center',
},
{
title: '物料名称、规格',
dataIndex: 'materielName',
align: 'center',
render: (text, record) => `${text}/${record.materielType}`,
},
{
title: '品类',
dataIndex: 'materielCategory',
align: 'center',
},
{
title: '品牌',
dataIndex: 'materielBrand',
align: 'center',
},
{
title: '单位',
dataIndex: 'materielUnit',
align: 'center',
},
{
title: '关联报价商品ID、名称、规格、品类、品牌',
dataIndex: 'productId',
align: 'center',
render: (text, record) => `${text}/${record.productName}/${record.category}/${record.brand}`,
},
]
),
{
title: '采购数量',
dataIndex: 'purchaseCount',
......@@ -120,7 +170,7 @@ const DetailInfo: React.FC<DetailInfoProps> = ({
dataIndex: 'repairReason',
align: 'center',
},
];
] as EditableColumns[];
// 获取查询维修申请详情
const getDetailInfo = () => {
......
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