Commit 448be474 authored by Bill's avatar Bill

fix: 修改加工

parent 6766cbf2
......@@ -377,7 +377,7 @@ const Add: React.FC<{}> = () => {
...rest,
deliveryDate: deliveryDateFormat,
otherAsk: {
annex: enclosure.map((item) => ({name: item.name, value: item.url})),
annex: enclosure?.map((item) => ({name: item.name, value: item.url})),
explain: [
{name: '交付说明', value: deliveryDesc},
{name: '付款说明', value: payDesc},
......
......@@ -32,7 +32,7 @@ import { filterExternalStateLabelList } from '@/pages/transaction/common/statusL
import { GetOrderProcessingOrderListResponseDetail } from '@/services/OrderV2Api';
const formActions = createFormActions();
const { onFieldInit$ } = FormEffectHooks
const { onFieldInit$, onFieldValueChange$ } = FormEffectHooks
registerVirtualBox('MellowCardBox', (_props) => {
const { children, props: outerProps } = _props;
......@@ -52,7 +52,20 @@ type EnterpriceType = {
roleId: number | string
}
type FileType = {
name: string,
url: string,
}
type submitDataType = {
/** 物流地址id, 显示用,不提交 */
receivefullAddress: number,
receiveAddress: string
receiveUserName: string
receiveUserTel: string
receiverAddressId: number
deliveryDate: string,
/**配送方式 */
deliveryType: 1 | 2 | number & {},
......@@ -71,7 +84,7 @@ type submitDataType = {
/** skuid */
commodityId: number,
/** 附件 */
enclosure: [],
enclosure: FileType[],
/** 订单商品,即下单的商品 唯一id */
id: string,
/** 是否是 */
......@@ -102,8 +115,36 @@ type submitDataType = {
/** 税率 */
taxRate: string,
/** 单位 */
unitName: string
},
unitName: string,
/** 商品属性 */
productProps: {
name: string,
value: string,
}[]
}[],
/** 加工商品 */
productList: {
brand: string,
category: string,
/** 商品id */
commodityId: number,
enclosure: FileType[],
isHasTax: 0 | 1 | number & {}
isHasTaxAndTaxRate: string,
mainPic: string,
name: string,
processNum: string,
processTotalPrice: string,
processUnitPrice: string,
productProps: {
name: string,
value: string,
}[],
/** skuid */
skuid: number,
taxRate: string,
unitName: string,
}[],
/** 其他说明 */
otherDesc: string,
/** 包装说明 */
......@@ -116,6 +157,7 @@ type submitDataType = {
deliveryDesc: string,
/** 物资说明 */
materialDesc: string,
enclosure: FileType[]
}
/** @tofix 临时的,因为后端不返回只能值么临时搞着 */
......@@ -475,7 +517,8 @@ const Create = () => {
enclosure: enclosure?.map((_row) => ({
name: _row.name,
url: _row.url
})) || []
})) || [],
productProps: productProps,
// ...values,
}
}
......@@ -538,7 +581,6 @@ const Create = () => {
setOrderProductSelectRowKeys((prev) => prev.filter((_row) => !keys.includes(_row)));
setOrderProductSelectRowRecord((prev) => prev.filter((_row) => !keys.includes(`${_row.orderId}_${_row.id}`)))
setProcessOrder((prev) => prev.filter((_item) => _item.id !== id))
}
return true;
......@@ -584,8 +626,128 @@ const Create = () => {
/** ------- 加工订单相关end------- */
const onSubmit = (value: any) => {
const fetchReceiveAddress = useCallback(async () => {
const { data, code } = await PublicApi.getLogisticsReceiverAddressPage({ current: '1', pageSize: '30' });
if (code === 1000) {
return data.data.map((_item) => ({
label: `${_item.fullAddress} / ${_item.receiverName} / ${_item.phone}`,
value: _item.id,
name: _item.receiverName,
address: _item.fullAddress,
phone: _item.phone
}))
}
return []
}, [])
const onSubmit = (value: submitDataType) => {
console.log(value)
const {
receivefullAddress,
deliveryDate,
deliveryType,
enclosure,
deliveryDesc,
payDesc,
taxDesc,
materialDesc,
packingDesc,
otherDesc,
orderList,
productList,
receiveAddress,
receiveUserName,
receiveUserTel,
receiverAddressId,
...rest
} = value;
const orderListFormated = orderList?.map((_item) => {
return {
orderId: _item.orderId,
orderNo: _item.orderNo,
orderDetailId: _item.id,
productId: _item.commodityId,
purchaseCount: _item.purchaseCount,
surplusProcessNum: _item.surplusAndProcessNum,
productName: _item.name,
category: _item.category,
brand: _item.brand,
unit: _item.unitName,
processNum: +_item.processNum,
processPrice: +_item.processUnitPrice,
processTotalPrice: +_item.processTotalPrice,
deliveryDate: deliveryDate,
isHasTax: _item.isHasTax,
taxRate: _item.taxRate,
property: {
specs: _item.productProps || [],
annex: _item.enclosure?.map((_row) => ({name: _row.name, value: _row.url})) || []
}
}
})
const productListFormated = productList.map((_item) => {
return {
/** 采购数量, 加工商品不需要,默认给0 */
purchaseCount: 0,
/** 剩余加工数量, 加工商品不需要 */
surplusProcessNum: 0,
prodcutId: _item.skuid,
productName: _item.name,
brand: _item.brand,
category: _item.category,
unit: _item.unitName,
processNum: +_item.processNum,
processPrice: +_item.processUnitPrice,
processTotalPrice: +_item.processTotalPrice,
deliveryDate: deliveryDate,
isHasTax: _item.isHasTax,
taxRate: _item.taxRate,
property:{
specs: _item.productProps || [],
annex: _item.enclosure && _item.enclosure.map((item) => ({name: item.name, value: item.url})) || []
}
}
})
let restData: {
processMemberId: number;
processName: string;
processRoleId: number;
source: 1 | 2 | number & {};
summary: string;
receiveAddress?: string,
receiveUserName?: string,
receiveUserTel?: string,
receiverAddressId?: number,
} = {} as any
if (deliveryType === 1) {
restData = {
...rest,
receiveAddress,
receiveUserName,
receiveUserTel,
receiverAddressId,
}
}
const postData = {
deliveryDate: deliveryDate,
otherAsk: {
annex: enclosure?.map((item) => ({name: item.name, value: item.url})) || [],
explain: [
{name: '交付说明', value: deliveryDesc},
{name: '付款说明', value: payDesc},
{name: '税费说明', value: taxDesc},
{name: '物资说明', value: materialDesc},
{name: '包装说明', value: packingDesc},
{name: '其他说明', value: otherDesc}
]
},
details: orderListFormated,
deliveryType,
...restData
}
console.info(postData ,orderListFormated);
}
......@@ -606,12 +768,28 @@ const Create = () => {
>
<NiceForm
onSubmit={onSubmit}
// fields={useFields() as any}
initialValues={
{
source: 1
}
}
effects={($, actions) => {
useAsyncSelect('receivefullAddress', fetchReceiveAddress)
onFieldValueChange$('receivefullAddress').subscribe((state) => {
if(state.visible) {
console.log(state);
const options = state.originAsyncData;
const target = options.filter((item) => item.value == state.value)[0];
if(target) {
formActions.setFieldValue("receiveAddress", target.address);
formActions.setFieldValue("receiveUserName", target.name.trim());
formActions.setFieldValue("receiveUserTel", target.phone.trim());
formActions.setFieldValue("receiverAddressId", target.value)
}
}
})
}}
actions={formActions}
schema={creataSchema}
expressionScope={{
......@@ -628,7 +806,6 @@ const Create = () => {
</div>
),
renderProductListTableRemove: renderProductListTableRemove
// renderAddProduct: renderAddition
}}
components={{
ArrayTable,
......
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