Commit 3f0792cc authored by XieZhiXiong's avatar XieZhiXiong

完善中

parent da8d79ad
...@@ -44,11 +44,12 @@ const Relevance = props => { ...@@ -44,11 +44,12 @@ const Relevance = props => {
const tableRowLableKey = tableProps.lableKey || ''; // Input展示用的 key val const tableRowLableKey = tableProps.lableKey || ''; // Input展示用的 key val
const [visible, setVisible] = useState(false); const [visible, setVisible] = useState(false);
const [rowSelection, rowCtl] = useRowSelectionTable({ type: selectionType }); const [rowSelection, rowCtl] = useRowSelectionTable({ type: selectionType, customKey: tableRowKey });
useEffect(() => { useEffect(() => {
// Table 只能缓存 keys // Table 只能缓存 keys
const rowKeys = value.map(item => item[tableRowKey]); const rowKeys = value.map(item => item[tableRowKey]);
console.log('rowKeys', rowKeys)
rowCtl.setSelectedRowKeys(rowKeys); rowCtl.setSelectedRowKeys(rowKeys);
}, [props.value]); }, [props.value]);
......
...@@ -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-22 09:53:36 * @LastEditTime: 2020-09-24 14:58:10
* @Description: 联动逻辑相关 * @Description: 联动逻辑相关
*/ */
import { FormEffectHooks, FormPath } from '@formily/antd'; import { FormEffectHooks, FormPath } from '@formily/antd';
...@@ -25,6 +25,7 @@ import { ...@@ -25,6 +25,7 @@ import {
DOC_TYPE_EXCHANGE_INVOICE, DOC_TYPE_EXCHANGE_INVOICE,
DOC_TYPE_EXCHANGE_RECEIPT, DOC_TYPE_EXCHANGE_RECEIPT,
PurchaseOrderInsideWorkStateTexts, PurchaseOrderInsideWorkStateTexts,
DELIVERY_TYPE,
} from '@/constants'; } from '@/constants';
import Search from '@/components/NiceForm/components/Search'; import Search from '@/components/NiceForm/components/Search';
import Submit from '@/components/NiceForm/components/Submit'; import Submit from '@/components/NiceForm/components/Submit';
...@@ -142,8 +143,8 @@ const afterSaleColumns = [ ...@@ -142,8 +143,8 @@ const afterSaleColumns = [
}, },
]; ];
// 获取单相关数据 // 获取采购入库单相关数据
const fetchOrderList = async (params: any) => { const fetchOrderPurchaseReceiptAddList = async (params: any) => {
const res = await PublicApi.getOrderPurchaseReceiptAddList({ const res = await PublicApi.getOrderPurchaseReceiptAddList({
...params, ...params,
}) })
...@@ -153,6 +154,17 @@ const fetchOrderList = async (params: any) => { ...@@ -153,6 +154,17 @@ const fetchOrderList = async (params: any) => {
return []; return [];
}; };
// 获取销售发货单相关数据
const getOrderSalesInvoiceOrderList = async (params: any) => {
const res = await PublicApi.getOrderSalesInvoiceOrderList({
...params,
})
if (res.code === 1000) {
return res.data;
}
return [];
};
// 获取关联组件对应的 params // 获取关联组件对应的 params
const getParams = type => { const getParams = type => {
const params = { const params = {
...@@ -181,43 +193,29 @@ const getParams = type => { ...@@ -181,43 +193,29 @@ const getParams = type => {
} }
}, },
tableProps: { tableProps: {
rowKey: 'id', rowKey: 'orderNo',
lableKey: '', lableKey: '',
}, },
}; };
switch (type) { switch (type) {
// 对应单据 - 订 // 采购入库
case DEPENDENT_DOC_ORDER: { case DOC_TYPE_PURCHASE_RECEIPT: {
params.modalProps.title = '选择订单'; params.modalProps.title = '选择订单';
params.columns = orderColumns; params.columns = orderColumns;
params.fetchTableData = fetchOrderList; params.fetchTableData = fetchOrderPurchaseReceiptAddList;
params.formilyProps.ctx.schema = orderBillSchema; params.formilyProps.ctx.schema = orderBillSchema;
params.tableProps.lableKey = 'orderNo'; params.tableProps.lableKey = 'orderNo';
break; break;
} }
// 对应单据 - 换货 // 销售发货单
case DEPENDENT_DOC_EXCHANGE: { case DOC_TYPE_SALES_INVOICE: {
params.modalProps.title = '选择订单';
break; params.columns = orderColumns;
} params.fetchTableData = getOrderSalesInvoiceOrderList;
params.formilyProps.ctx.schema = orderBillSchema;
// 对应单据 - 退货 params.tableProps.lableKey = 'orderNo';
case DEPENDENT_DOC_RETURN: {
break;
}
// 对应单据 - 生产
case DEPENDENT_DOC_PRODUCTION: {
break;
}
// 对应单据 - 内部
case DEPENDENT_DOC_INTERNAL: {
break; break;
} }
...@@ -251,7 +249,7 @@ export const useBusinessEffects = (context, actions) => { ...@@ -251,7 +249,7 @@ export const useBusinessEffects = (context, actions) => {
const linkage = useLinkageUtils(); const linkage = useLinkageUtils();
// 根据 单据类型 联动 对应单据所选项 // 根据 单据类型 联动 对应单据所选项
onFieldValueChange$('invoicesTypeId').subscribe(fieldState => { onFieldInputChange$('invoicesTypeId').subscribe(fieldState => {
const newEnum = [...getFieldState('relevanceInvoices', state => state.props.enum)]; const newEnum = [...getFieldState('relevanceInvoices', state => state.props.enum)];
switch (fieldState.value) { switch (fieldState.value) {
...@@ -288,8 +286,20 @@ export const useBusinessEffects = (context, actions) => { ...@@ -288,8 +286,20 @@ export const useBusinessEffects = (context, actions) => {
break; break;
} }
} }
linkage.value('relevanceInvoices', undefined); linkage.value('relevanceInvoices', undefined);
linkage.enum('relevanceInvoices', newEnum); linkage.enum('relevanceInvoices', newEnum);
const orderNoVal = getFieldValue('orderNo');
if (orderNoVal && orderNoVal.length) {
linkage.value('orderNo', []);
}
});
// 根据 单据类型 联动 对应单据所选项
onFieldValueChange$('invoicesTypeId').subscribe(fieldState => {
const params = getParams(fieldState.value);
linkage.componentProps('orderNo', params);
}); });
onFieldInputChange$('inventoryId').subscribe(fieldState => { onFieldInputChange$('inventoryId').subscribe(fieldState => {
...@@ -298,28 +308,24 @@ export const useBusinessEffects = (context, actions) => { ...@@ -298,28 +308,24 @@ export const useBusinessEffects = (context, actions) => {
linkage.value('inventoryRole', current.principal); linkage.value('inventoryRole', current.principal);
} }
}); });
// 对应单据改变
onFieldValueChange$('relevanceInvoices').subscribe(fieldState => {
const params = getParams(fieldState.value);
linkage.componentProps('orderNo', params);
});
// 关联单据改变 // 关联单据改变
onFieldValueChange$('orderNo').subscribe(fieldState => { onFieldValueChange$('orderNo').subscribe(fieldState => {
const relevanceInvoicesVal = getFieldValue('relevanceInvoices'); const relevanceInvoicesVal = getFieldValue('relevanceInvoices');
const first = fieldState.value && fieldState.value[0]; const first = fieldState.value && fieldState.value[0];
setFieldValue('memberName', first ? first.memberName : '');
setFieldValue('relevanceInvoicesId', first ? first.id : null);
setFieldValue('deliveryAddresId', first ? first.deliveryAddresId : null);
setFieldValue('address', first ? `${first.fullAddress} ${first.receiverName}/${first.phone}` : '');
setFieldValue('transport', first && first.deliveryType ? DELIVERY_TYPE[first.deliveryType] : '');
if (!first) { if (!first) {
return; return;
} }
switch (relevanceInvoicesVal) { switch (relevanceInvoicesVal) {
// 对应单据 - 订单 // 对应单据 - 订单
case DEPENDENT_DOC_ORDER: { case DEPENDENT_DOC_ORDER: {
setFieldValue('memberName', first.supplyMembersName);
setFieldValue('address', '暂无收货地址');
setFieldValue('transport', '暂无物流方式');
// 根据选择的订单查询 订单对应的商品,并给 Table 的商品下拉框赋值 // 根据选择的订单查询 订单对应的商品,并给 Table 的商品下拉框赋值
PublicApi.getOrderProcurementOrderProductList({ PublicApi.getOrderProcurementOrderProductList({
id: first.id, id: first.id,
...@@ -391,7 +397,7 @@ export const useBusinessEffects = (context, actions) => { ...@@ -391,7 +397,7 @@ export const useBusinessEffects = (context, actions) => {
return `invoicesDetailsRequests.${$1}.price` return `invoicesDetailsRequests.${$1}.price`
}), }),
state => { state => {
state.value = `¥${current.price}`; state.value = current.price;
} }
); );
setFieldState( setFieldState(
...@@ -399,7 +405,7 @@ export const useBusinessEffects = (context, actions) => { ...@@ -399,7 +405,7 @@ export const useBusinessEffects = (context, actions) => {
return `invoicesDetailsRequests.${$1}.productCount` return `invoicesDetailsRequests.${$1}.productCount`
}), }),
state => { state => {
state.value = ''; state.value = 1;
} }
); );
setFieldState( setFieldState(
......
...@@ -2,6 +2,7 @@ import React, { useState, useEffect, useRef } from 'react'; ...@@ -2,6 +2,7 @@ import React, { useState, useEffect, useRef } from 'react';
import { Button, Card, Spin, message } from 'antd'; import { Button, Card, Spin, message } from 'antd';
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 { usePageStatus } from '@/hooks/usePageStatus'; import { usePageStatus } 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';
...@@ -112,7 +113,22 @@ const AddBills: React.FC<{}> = (props: any) => { ...@@ -112,7 +113,22 @@ const AddBills: React.FC<{}> = (props: any) => {
if (res.code !== 1000) { if (res.code !== 1000) {
return; return;
} }
setBillInfo(res.data); const {
transactionTime,
orderNo,
...rest
} = res.data;
setBillInfo({
transactionTime: transactionTime ? moment(transactionTime) : moment(),
orderNo: orderNo ? [{ orderNo }] : [],
...rest,
invoicesTypeId: 'S001',
});
console.log({
transactionTime: transactionTime ? moment(transactionTime) : moment(),
orderNo: orderNo ? [{ orderNo }] : [],
...rest,
})
}).finally(() => { }).finally(() => {
setInfoLoading(false); setInfoLoading(false);
}); });
...@@ -145,10 +161,25 @@ const AddBills: React.FC<{}> = (props: any) => { ...@@ -145,10 +161,25 @@ const AddBills: React.FC<{}> = (props: any) => {
}, []); }, []);
const handleSubmit = value => { const handleSubmit = value => {
const { invoicesTypeId, orderNo, transactionTime, ...rest } = value; const {
invoicesTypeId,
orderNo,
transactionTime,
receiverName,
address,
transport,
invoicesDetailsRequests = [],
...rest
} = value;
const newInvoicesDetailsRequests = invoicesDetailsRequests.map(item => ({
...item,
productCount: +item.productCount,
}));
const payload = { const payload = {
orderNo: orderNo[0].id, orderNo: orderNo[0].orderNo,
transactionTime: transactionTime ? transactionTime.format('YYYY-MM-DD HH:mm:ss') : '', relevanceInvoicesId: orderNo[0].id,
transactionTime: transactionTime ? transactionTime.valueOf() : null,
invoicesDetailsRequests: newInvoicesDetailsRequests,
...rest, ...rest,
}; };
...@@ -177,7 +208,22 @@ const AddBills: React.FC<{}> = (props: any) => { ...@@ -177,7 +208,22 @@ const AddBills: React.FC<{}> = (props: any) => {
// 销售发货单 // 销售发货单
case DOC_TYPE_SALES_INVOICE: { case DOC_TYPE_SALES_INVOICE: {
if (!id) {
PublicApi.postOrderSalesInvoiceOrder(payload)
.then(res => {
if (res.code !== 1000) {
return;
}
setUnsaved(false);
setTimeout(() => {
history.goBack();
}, 800);
}).finally(() => {
setSubmitLoading(false);
});
} else {
// update action
}
break; break;
} }
...@@ -228,16 +274,17 @@ const AddBills: React.FC<{}> = (props: any) => { ...@@ -228,16 +274,17 @@ const AddBills: React.FC<{}> = (props: any) => {
const handleOkAddProduct = async () => { const handleOkAddProduct = async () => {
const values = productRowCtl.selectRow.map(item => ({ const values = productRowCtl.selectRow.map(item => ({
itemNo: item.code, itemNo: item.code,
itemNmae: item.name, goodsId: item.id,
itemName: item.name,
specifications: item.type, specifications: item.type,
category: item.customerCategory.name, category: item.customerCategory.name,
brand: item.brand.name, brand: item.brand.name,
unit: item.unitName, unit: item.unitName,
costPrice: `¥${item.costPrice}`, costPrice: item.costPrice,
productName: undefined, productName: undefined,
productId: '', productId: '',
price: '', price: 0,
productCount: '', productCount: 0,
amount: '', amount: '',
})); }));
addSchemaAction.setFieldValue('invoicesDetailsRequests', values); addSchemaAction.setFieldValue('invoicesDetailsRequests', values);
...@@ -285,6 +332,7 @@ const AddBills: React.FC<{}> = (props: any) => { ...@@ -285,6 +332,7 @@ const AddBills: React.FC<{}> = (props: any) => {
> >
<Card> <Card>
<NiceForm <NiceForm
initialValues={billInfo}
expressionScope={{ expressionScope={{
tableAddButton, tableAddButton,
}} }}
......
...@@ -331,6 +331,11 @@ export const addBillSchema: ISchema = { ...@@ -331,6 +331,11 @@ export const addBillSchema: ISchema = {
title: '会员名称', title: '会员名称',
default: '', default: '',
}, },
// 不用于展示,只用于收集值
deliveryAddresId: {
type: 'string',
display: false,
},
address: { address: {
type: 'string', type: 'string',
'x-component': 'Text', 'x-component': 'Text',
......
...@@ -4,6 +4,7 @@ import { PageHeaderWrapper } from '@ant-design/pro-layout'; ...@@ -4,6 +4,7 @@ import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { Button, Card, Dropdown, Menu, Space, Badge, Popconfirm } from 'antd'; import { Button, Card, Dropdown, Menu, Space, Badge, Popconfirm } from 'antd';
import { PlusOutlined, DownOutlined, DeleteOutlined, RollbackOutlined, SnippetsOutlined, ZoomOutOutlined } from '@ant-design/icons'; import { PlusOutlined, DownOutlined, DeleteOutlined, RollbackOutlined, SnippetsOutlined, ZoomOutOutlined } from '@ant-design/icons';
import { StandardTable } from 'god'; import { StandardTable } from 'god';
import moment from 'moment';
import { ColumnType } from 'antd/lib/table/interface'; import { ColumnType } from 'antd/lib/table/interface';
import EyePreview from '@/components/EyePreview'; import EyePreview from '@/components/EyePreview';
import NiceForm from '@/components/NiceForm'; import NiceForm from '@/components/NiceForm';
...@@ -175,7 +176,6 @@ const Bills: React.FC<{}> = () => { ...@@ -175,7 +176,6 @@ const Bills: React.FC<{}> = () => {
title: '单据号', title: '单据号',
dataIndex: 'invoicesNo', dataIndex: 'invoicesNo',
align: 'center', align: 'center',
key: 'invoicesNo',
render: (text: any, record: any) => ( render: (text: any, record: any) => (
<EyePreview <EyePreview
url={`/memberCenter/tranactionAbility/stockSellStorage/addBills?id=${record.id}&preview=1`} url={`/memberCenter/tranactionAbility/stockSellStorage/addBills?id=${record.id}&preview=1`}
...@@ -206,25 +206,22 @@ const Bills: React.FC<{}> = () => { ...@@ -206,25 +206,22 @@ const Bills: React.FC<{}> = () => {
title: '对应仓库', title: '对应仓库',
align: 'center', align: 'center',
dataIndex: 'inventory', dataIndex: 'inventory',
key: 'inventory',
}, },
{ {
title: '交易时间', title: '交易时间',
align: 'center', align: 'center',
dataIndex: 'transactionTime', dataIndex: 'transactionTime',
key: 'transactionTime', render: text => text ? moment(text).format('YYYY-MM-DD HH:mm:ss') : '',
}, },
{ {
title: '订单号', title: '订单号',
align: 'center', align: 'center',
dataIndex: 'orderNo', dataIndex: 'orderNo',
key: 'orderNo',
}, },
{ {
title: '单据状态', title: '单据状态',
align: 'center', align: 'center',
dataIndex: 'state', dataIndex: 'state',
key: 'state',
filters: [ filters: [
{ text: DOC_STATUS[DOC_STATUS_UNREVIEWED], value: DOC_STATUS_UNREVIEWED }, { text: DOC_STATUS[DOC_STATUS_UNREVIEWED], value: DOC_STATUS_UNREVIEWED },
{ text: DOC_STATUS[DOC_STATUS_REVIEWED], value: DOC_STATUS_REVIEWED }, { text: DOC_STATUS[DOC_STATUS_REVIEWED], value: DOC_STATUS_REVIEWED },
......
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