Commit 02694c90 authored by XieZhiXiong's avatar XieZhiXiong

对接进销存详情、修改相关、完善

parent 3b608df1
...@@ -9,10 +9,9 @@ const RowStyleLayout = styled(props => <div {...props} />)` ...@@ -9,10 +9,9 @@ const RowStyleLayout = styled(props => <div {...props} />)`
width: 100%; width: 100%;
.relevance { .relevance {
height: 100%;
background: #6b778c; background: #6b778c;
border: none;
border-radius: 0; border-radius: 0;
height: 100%;
&[disabled] { &[disabled] {
background: #f5f5f5; background: #f5f5f5;
...@@ -21,6 +20,7 @@ const RowStyleLayout = styled(props => <div {...props} />)` ...@@ -21,6 +20,7 @@ const RowStyleLayout = styled(props => <div {...props} />)`
.ant-input-group-addon { .ant-input-group-addon {
padding: 0; padding: 0;
border: none;
} }
`; `;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: XieZhiXiong * @Author: XieZhiXiong
* @Date: 2020-09-16 15:16:47 * @Date: 2020-09-16 15:16:47
* @LastEditors: XieZhiXiong * @LastEditors: XieZhiXiong
* @LastEditTime: 2020-09-25 11:31:15 * @LastEditTime: 2020-09-25 16:37:38
* @Description: 联动逻辑相关 * @Description: 联动逻辑相关
*/ */
import { FormEffectHooks, FormPath } from '@formily/antd'; import { FormEffectHooks, FormPath } from '@formily/antd';
...@@ -303,6 +303,7 @@ export const useBusinessEffects = (context, actions) => { ...@@ -303,6 +303,7 @@ export const useBusinessEffects = (context, actions) => {
linkage.componentProps('orderNo', params); linkage.componentProps('orderNo', params);
}); });
// 对应仓库改变
onFieldInputChange$('inventoryId').subscribe(fieldState => { onFieldInputChange$('inventoryId').subscribe(fieldState => {
const current = fieldState.originAsyncData.find(item => item.id === fieldState.value); const current = fieldState.originAsyncData.find(item => item.id === fieldState.value);
if (current) { if (current) {
...@@ -315,14 +316,19 @@ export const useBusinessEffects = (context, actions) => { ...@@ -315,14 +316,19 @@ export const useBusinessEffects = (context, actions) => {
const relevanceInvoicesVal = getFieldValue('relevanceInvoices'); const relevanceInvoicesVal = getFieldValue('relevanceInvoices');
const first = fieldState.value && fieldState.value[0]; const first = fieldState.value && fieldState.value[0];
console.log('first', first) setFieldValue('supplyMembersName', first ? first.supplyMembersName : '');
setFieldValue('memberName', first ? first.supplyMembersName : '');
setFieldValue('relevanceInvoicesId', first ? first.id : null); setFieldValue('relevanceInvoicesId', first ? first.id : null);
setFieldValue('deliveryAddresId', first ? first.deliveryAddresId : null);
setFieldValue('address', first ? `${first.fullAddress} ${first.receiverName}/${first.phone}` : ''); setFieldValue('address', first ? `${first.fullAddress} ${first.receiverName}/${first.phone}` : '');
setFieldValue('transport', first && first.deliveryType ? DELIVERY_TYPE[first.deliveryType] : ''); setFieldValue('transport', first && first.deliveryType ? DELIVERY_TYPE[first.deliveryType] : '');
// 以下数据只用于收集,不用于展示
setFieldValue('deliveryAddresId', first ? first.deliveryAddresId : null);
setFieldValue('receiverName', first ? first.receiverName : '');
setFieldValue('fullAddress', first ? first.fullAddress : '');
setFieldValue('phone', first ? first.phone : '');
setFieldValue('deliveryType', first ? first.deliveryType : null);
setFieldValue('isDefault', first ? first.isDefault : false);
if (!first) { if (!first) {
return; return;
} }
...@@ -335,10 +341,10 @@ export const useBusinessEffects = (context, actions) => { ...@@ -335,10 +341,10 @@ export const useBusinessEffects = (context, actions) => {
}).then(res => { }).then(res => {
if (res.code === 1000) { if (res.code === 1000) {
const goodOptions = res.data.map(item => ({ const goodOptions = res.data.map(item => ({
label: `${item.productId}/${item.productName}/¥${item.price}`, label: item.productName,
value: item.id, value: item.productId,
})); }));
setFieldState('invoicesDetailsRequests.*.productName', state => { setFieldState('invoicesDetailsRequests.*.product', state => {
FormPath.setIn(state, 'originAsyncData', res.data); FormPath.setIn(state, 'originAsyncData', res.data);
FormPath.setIn(state, 'props.enum', goodOptions); FormPath.setIn(state, 'props.enum', goodOptions);
}); });
...@@ -374,14 +380,17 @@ export const useBusinessEffects = (context, actions) => { ...@@ -374,14 +380,17 @@ export const useBusinessEffects = (context, actions) => {
default: default:
break; break;
} }
});
// 关联单据改变
onFieldInputChange$('orderNo').subscribe(fieldState => {
setFieldValue('invoicesDetailsRequests', []); setFieldValue('invoicesDetailsRequests', []);
}); });
// 关联明细 商品下拉框 联动商品ID、单价 // 关联明细 商品下拉框 联动商品ID、单价
onFieldInputChange$('invoicesDetailsRequests.*.productName').subscribe(fieldState => { onFieldInputChange$('invoicesDetailsRequests.*.product').subscribe(fieldState => {
const { name, originAsyncData, value } = fieldState; const { name, originAsyncData, value } = fieldState;
const current = originAsyncData.find(item => item.id === value); const current = originAsyncData.find(item => item.productId === value);
if (!current) { if (!current) {
return; return;
...@@ -397,6 +406,14 @@ export const useBusinessEffects = (context, actions) => { ...@@ -397,6 +406,14 @@ export const useBusinessEffects = (context, actions) => {
); );
setFieldState( setFieldState(
FormPath.transform(name, /\d/, $1 => { FormPath.transform(name, /\d/, $1 => {
return `invoicesDetailsRequests.${$1}.productName`
}),
state => {
state.value = current.productName;
}
);
setFieldState(
FormPath.transform(name, /\d/, $1 => {
return `invoicesDetailsRequests.${$1}.price` return `invoicesDetailsRequests.${$1}.price`
}), }),
state => { state => {
...@@ -426,17 +443,17 @@ export const useBusinessEffects = (context, actions) => { ...@@ -426,17 +443,17 @@ export const useBusinessEffects = (context, actions) => {
const { name, value } = fieldState; const { name, value } = fieldState;
const originAsyncData = getFieldState( const originAsyncData = getFieldState(
FormPath.transform(name, /\d/, $1 => { FormPath.transform(name, /\d/, $1 => {
return `invoicesDetailsRequests.${$1}.productName` return `invoicesDetailsRequests.${$1}.product`
}), }),
state => state.originAsyncData, state => state.originAsyncData,
); );
const goodId = getFieldState( const goodId = getFieldState(
FormPath.transform(name, /\d/, $1 => { FormPath.transform(name, /\d/, $1 => {
return `invoicesDetailsRequests.${$1}.productName` return `invoicesDetailsRequests.${$1}.product`
}), }),
state => state.value, state => state.value,
);; );;
const current = originAsyncData.find(item => item.id === goodId); const current = originAsyncData.find(item => item.productId === goodId);
if (!current || isNaN(+value)) { if (!current || isNaN(+value)) {
return; return;
......
import React, { useState, useEffect, useRef } from 'react'; import React, { useState, useEffect, useRef } from 'react';
import { Button, Card, Spin, message } from 'antd'; import { Button, Card, Spin, message } from 'antd';
import { DeleteOutlined } from '@ant-design/icons';
import { Radio, ArrayTable } from '@formily/antd-components'; import { Radio, ArrayTable } from '@formily/antd-components';
import { history, Prompt } from 'umi'; import { history, Prompt } from 'umi';
import moment from 'moment'; import moment from 'moment';
import { usePageStatus } from '@/hooks/usePageStatus'; import { usePageStatus, PageStatus } from '@/hooks/usePageStatus';
import { PageHeaderWrapper } from '@ant-design/pro-layout'; import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { SaveOutlined, PlusOutlined } from '@ant-design/icons'; import { SaveOutlined, PlusOutlined } from '@ant-design/icons';
import { createFormActions, FormEffectHooks } from '@formily/antd'; import { createFormActions, FormEffectHooks } from '@formily/antd';
...@@ -123,14 +124,57 @@ const AddBills: React.FC<{}> = (props: any) => { ...@@ -123,14 +124,57 @@ const AddBills: React.FC<{}> = (props: any) => {
const { const {
transactionTime, transactionTime,
orderNo, orderNo,
relevanceInvoicesId,
deliveryAddresId,
supplyMembersName,
fullAddress,
receiverName,
phone,
deliveryType,
isDefault,
invoicesDetailsList,
...rest ...rest
} = res.data; } = res.data;
const details = invoicesDetailsList ? invoicesDetailsList.map(item => ({
...item,
product: item.productId,
amount: `¥${(+item.productCount * item.price).toFixed(2)}`,
})) : [];
addSchemaAction.setFieldState(
'*(invoicesTypeId,orderNo)',
state => {
state.props['x-component-props'].disabled = true;
}
);
setBillInfo({ setBillInfo({
transactionTime: transactionTime ? moment(transactionTime) : moment(), transactionTime: transactionTime ? moment(transactionTime).format('YYYY-MM-DD HH:mm:ss') : moment().format('YYYY-MM-DD HH:mm:ss'),
orderNo: orderNo ? [{ orderNo }] : [], orderNo:
orderNo ?
[
{
orderNo,
id: +relevanceInvoicesId,
deliveryAddresId: +deliveryAddresId,
supplyMembersName,
fullAddress,
receiverName,
phone,
deliveryType,
isDefault,
}
] :
[]
,
invoicesDetailsRequests: details,
...rest, ...rest,
invoicesTypeId: 'S001', invoicesTypeId: 'S002',
}); });
productRowCtl.setSelectRow(details);
productRowCtl.setSelectedRowKeys(details.map(item => item.id));
}).finally(() => { }).finally(() => {
setInfoLoading(false); setInfoLoading(false);
}); });
...@@ -146,7 +190,56 @@ const AddBills: React.FC<{}> = (props: any) => { ...@@ -146,7 +190,56 @@ const AddBills: React.FC<{}> = (props: any) => {
switch (invoicesTypeId) { switch (invoicesTypeId) {
// 采购入库单 // 采购入库单
case DOC_TYPE_PURCHASE_RECEIPT: { case DOC_TYPE_PURCHASE_RECEIPT: {
setInfoLoading(true);
PublicApi.getOrderProcurementOrderDetails({
id: relevanceInvoicesId,
}).then(res => {
if (res.code !== 1000) {
return;
}
const {
supplyMembersName,
deliveryType,
deliveryAddresId,
orderNo,
province,
city,
area,
addres,
addresName,
tel,
isDefault,
} = res.data;
addSchemaAction.setFieldState(
'*(invoicesTypeId,orderNo)',
state => {
state.props['x-component-props'].disabled = true;
}
);
setBillInfo({
invoicesTypeId,
relevanceInvoices: +relevanceInvoices,
orderNo:
orderNo ?
[
{
orderNo,
id: +relevanceInvoicesId,
deliveryAddresId: +deliveryAddresId,
supplyMembersName,
fullAddress: `${province || ''}${city || ''}${area || ''}${addres || ''}`,
receiverName: addresName || '',
phone: tel || '',
deliveryType,
isDefault,
}
] :
[]
,
});
}).finally(() => {
setInfoLoading(false);
});
break; break;
} }
...@@ -170,6 +263,7 @@ const AddBills: React.FC<{}> = (props: any) => { ...@@ -170,6 +263,7 @@ const AddBills: React.FC<{}> = (props: any) => {
addres, addres,
addresName, addresName,
tel, tel,
isDefault,
} = res.data; } = res.data;
addSchemaAction.setFieldState( addSchemaAction.setFieldState(
'*(invoicesTypeId,orderNo)', '*(invoicesTypeId,orderNo)',
...@@ -192,6 +286,7 @@ const AddBills: React.FC<{}> = (props: any) => { ...@@ -192,6 +286,7 @@ const AddBills: React.FC<{}> = (props: any) => {
receiverName: addresName || '', receiverName: addresName || '',
phone: tel || '', phone: tel || '',
deliveryType, deliveryType,
isDefault,
} }
] : ] :
[] []
...@@ -261,7 +356,7 @@ const AddBills: React.FC<{}> = (props: any) => { ...@@ -261,7 +356,7 @@ const AddBills: React.FC<{}> = (props: any) => {
setVisible(true); setVisible(true);
}; };
const tableAddButton = ( const TableAddButton = pageStatus !== PageStatus.PREVIEW ? (
<Button <Button
style={{ marginBottom: 16 }} style={{ marginBottom: 16 }}
block block
...@@ -271,7 +366,7 @@ const AddBills: React.FC<{}> = (props: any) => { ...@@ -271,7 +366,7 @@ const AddBills: React.FC<{}> = (props: any) => {
> >
添加单据明细 添加单据明细
</Button> </Button>
); ) : null;
const handleSubmit = value => { const handleSubmit = value => {
const { const {
...@@ -284,14 +379,20 @@ const AddBills: React.FC<{}> = (props: any) => { ...@@ -284,14 +379,20 @@ const AddBills: React.FC<{}> = (props: any) => {
invoicesDetailsRequests = [], invoicesDetailsRequests = [],
...rest ...rest
} = value; } = value;
const newInvoicesDetailsRequests = invoicesDetailsRequests.map(item => ({ const newInvoicesDetailsRequests = invoicesDetailsRequests.map(({
...item, product,
productCount: +item.productCount, productCount,
...rest
}) => ({
productCount: +productCount,
...rest,
})); }));
const newTransactionTime = transactionTime ? moment(transactionTime).valueOf() : null;
const payload = { const payload = {
orderNo: orderNo[0].orderNo, orderNo: orderNo[0].orderNo,
relevanceInvoicesId: orderNo[0].id, relevanceInvoicesId: orderNo[0].id,
transactionTime: transactionTime ? transactionTime.valueOf() : null, transactionTime: newTransactionTime,
invoicesDetailsRequests: newInvoicesDetailsRequests, invoicesDetailsRequests: newInvoicesDetailsRequests,
...rest, ...rest,
}; };
...@@ -315,6 +416,25 @@ const AddBills: React.FC<{}> = (props: any) => { ...@@ -315,6 +416,25 @@ const AddBills: React.FC<{}> = (props: any) => {
}); });
} else { } else {
// update action // update action
PublicApi.postWarehouseInvoicesUpdata({
id: +id,
invoicesAbstract: payload.invoicesAbstract,
inventoryId: payload.inventoryId,
inventoryRole: payload.inventoryRole,
transactionTime: payload.transactionTime,
invoicesDetailsRequests: payload.invoicesDetailsRequests,
})
.then(res => {
if (res.code !== 1000) {
return;
}
setUnsaved(false);
setTimeout(() => {
history.goBack();
}, 800);
}).finally(() => {
setSubmitLoading(false);
});
} }
break; break;
} }
...@@ -336,6 +456,25 @@ const AddBills: React.FC<{}> = (props: any) => { ...@@ -336,6 +456,25 @@ const AddBills: React.FC<{}> = (props: any) => {
}); });
} else { } else {
// update action // update action
PublicApi.postWarehouseInvoicesUpdata({
id: +id,
invoicesAbstract: payload.invoicesAbstract,
inventoryId: payload.inventoryId,
inventoryRole: payload.inventoryRole,
transactionTime: payload.transactionTime,
invoicesDetailsRequests: payload.invoicesDetailsRequests,
})
.then(res => {
if (res.code !== 1000) {
return;
}
setUnsaved(false);
setTimeout(() => {
history.goBack();
}, 800);
}).finally(() => {
setSubmitLoading(false);
});
} }
break; break;
} }
...@@ -394,7 +533,8 @@ const AddBills: React.FC<{}> = (props: any) => { ...@@ -394,7 +533,8 @@ const AddBills: React.FC<{}> = (props: any) => {
brand: item.brand.name, brand: item.brand.name,
unit: item.unitName, unit: item.unitName,
costPrice: item.costPrice, costPrice: item.costPrice,
productName: undefined, product: undefined,
productName: item.productName,
productId: '', productId: '',
price: 0, price: 0,
productCount: 0, productCount: 0,
...@@ -415,6 +555,29 @@ const AddBills: React.FC<{}> = (props: any) => { ...@@ -415,6 +555,29 @@ const AddBills: React.FC<{}> = (props: any) => {
return []; return [];
} }
const handleRemoveItem = (index: number) => {
const newSelectRow = [...productRowCtl.selectRow];
const newSelectedRowKeys = [...productRowCtl.selectedRowKeys];
const newValue = [...addSchemaAction.getFieldValue('invoicesDetailsRequests')];
newSelectRow.splice(index, 1);
newSelectedRowKeys.splice(index, 1);
productRowCtl.setSelectRow(newSelectRow);
productRowCtl.setSelectedRowKeys(newSelectedRowKeys);
newValue.splice(index, 1);
addSchemaAction.setFieldValue('invoicesDetailsRequests', newValue);
};
// ArrayTable自定义渲染
const renderListTableRemove = (index: number) => (
<Button
shape="circle"
icon={<DeleteOutlined />}
onClick={() => handleRemoveItem(index)}
/>
);
return ( return (
<Spin spinning={infoLoading}> <Spin spinning={infoLoading}>
<PageHeaderWrapper <PageHeaderWrapper
...@@ -445,14 +608,19 @@ const AddBills: React.FC<{}> = (props: any) => { ...@@ -445,14 +608,19 @@ const AddBills: React.FC<{}> = (props: any) => {
> >
<Card> <Card>
<NiceForm <NiceForm
defaultValue={{
transactionTime: moment().format('YYYY-MM-DD HH:mm:ss'),
}}
initialValues={billInfo} initialValues={billInfo}
expressionScope={{ expressionScope={{
tableAddButton, TableAddButton,
renderListTableRemove,
}} }}
components={{ components={{
RadioGroup: Radio.Group, RadioGroup: Radio.Group,
ArrayTable, ArrayTable,
}} }}
editable={pageStatus !== PageStatus.PREVIEW}
effects={($, actions) => { effects={($, actions) => {
createEffects($, actions) createEffects($, actions)
onFormInputChange$().subscribe(() => { onFormInputChange$().subscribe(() => {
......
...@@ -253,7 +253,6 @@ export const addBillSchema: ISchema = { ...@@ -253,7 +253,6 @@ export const addBillSchema: ISchema = {
transactionTime: { transactionTime: {
type: 'date', type: 'date',
title: '单据时间', title: '单据时间',
default: moment(),
'x-component-props': { 'x-component-props': {
format: 'YYYY-MM-DD HH:mm:ss', format: 'YYYY-MM-DD HH:mm:ss',
showTime: true, showTime: true,
...@@ -325,17 +324,12 @@ export const addBillSchema: ISchema = { ...@@ -325,17 +324,12 @@ export const addBillSchema: ISchema = {
}, },
}, },
}, },
memberName: { supplyMembersName: {
type: 'string', type: 'string',
'x-component': 'Text', 'x-component': 'Text',
title: '会员名称', title: '会员名称',
default: '', default: '',
}, },
// 不用于展示,只用于收集值
deliveryAddresId: {
type: 'string',
display: false,
},
address: { address: {
type: 'string', type: 'string',
'x-component': 'Text', 'x-component': 'Text',
...@@ -348,6 +342,36 @@ export const addBillSchema: ISchema = { ...@@ -348,6 +342,36 @@ export const addBillSchema: ISchema = {
title: '物流方式', title: '物流方式',
default: '', default: '',
}, },
// 不用于展示,只用于收集值
deliveryAddresId: {
type: 'string',
display: false,
},
// 不用于展示,只用于收集值
receiverName: {
type: 'string',
display: false,
},
// 不用于展示,只用于收集值
fullAddress: {
type: 'string',
display: false,
},
// 不用于展示,只用于收集值
phone: {
type: 'string',
display: false,
},
// 不用于展示,只用于收集值
deliveryType: {
type: 'number',
display: false,
},
// 不用于展示,只用于收集值
isDefault: {
type: 'boolean',
display: false,
},
}, },
}, },
}, },
...@@ -371,7 +395,7 @@ export const addBillSchema: ISchema = { ...@@ -371,7 +395,7 @@ export const addBillSchema: ISchema = {
type: 'object', type: 'object',
'x-component': 'Children', 'x-component': 'Children',
'x-component-props': { 'x-component-props': {
children: '{{tableAddButton}}' children: '{{TableAddButton}}'
}, },
}, },
invoicesDetailsRequests: { invoicesDetailsRequests: {
...@@ -379,6 +403,7 @@ export const addBillSchema: ISchema = { ...@@ -379,6 +403,7 @@ export const addBillSchema: ISchema = {
'x-component': 'ArrayTable', 'x-component': 'ArrayTable',
'x-component-props': { 'x-component-props': {
renderAddition: () => null, renderAddition: () => null,
renderRemove: '{{renderListTableRemove}}',
}, },
items: { items: {
type: 'object', type: 'object',
...@@ -418,7 +443,7 @@ export const addBillSchema: ISchema = { ...@@ -418,7 +443,7 @@ export const addBillSchema: ISchema = {
title: '成本价', title: '成本价',
'x-component': 'Text', 'x-component': 'Text',
}, },
productName: { product: {
type: 'string', type: 'string',
title: '商品名称', title: '商品名称',
enum: [], enum: [],
...@@ -432,6 +457,11 @@ export const addBillSchema: ISchema = { ...@@ -432,6 +457,11 @@ export const addBillSchema: ISchema = {
}, },
], ],
}, },
// 不用于展示,只收集值
productName: {
type: 'string',
display: false,
},
productId: { productId: {
type: 'string', type: 'string',
title: '商品ID', title: '商品ID',
......
...@@ -242,6 +242,7 @@ const Bills: React.FC<{}> = () => { ...@@ -242,6 +242,7 @@ const Bills: React.FC<{}> = () => {
render: (_, record: any) => { render: (_, record: any) => {
return ( return (
<> <>
<Button type="link" onClick={() => history.push(`/memberCenter/tranactionAbility/stockSellStorage/addBills?id=${record.id}`)}>修改</Button>
{record.state === DOC_STATUS_UNREVIEWED && ( {record.state === DOC_STATUS_UNREVIEWED && (
<> <>
<Button type="link" onClick={() => history.push(`/memberCenter/tranactionAbility/stockSellStorage/addBills?id=${record.id}`)}>修改</Button> <Button type="link" onClick={() => history.push(`/memberCenter/tranactionAbility/stockSellStorage/addBills?id=${record.id}`)}>修改</Button>
......
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