Commit 6723e411 authored by 前端-黄佳鑫's avatar 前端-黄佳鑫

feat: 完善请购单

parent 416a1531
......@@ -64,6 +64,12 @@ const EditSalesman: React.FC<MemberModalTableProps> = (props) => {
form.setFieldsValue({ requisitionSalesManReqs })
}
useEffect(() => {
if (record?.requisitionSalesManReqs) {
form.setFieldsValue({ requisitionSalesManReqs: record?.requisitionSalesManReqs })
}
}, [record])
console.log(record, 1002333)
return (
<Modal
destroyOnClose
......@@ -125,7 +131,7 @@ const EditSalesman: React.FC<MemberModalTableProps> = (props) => {
let totalPrice = 0
const requisitionSalesManReqs = form.getFieldValue(`requisitionSalesManReqs`);
requisitionSalesManReqs.forEach(_item => {
totalPrice += Number(_item.purchaseQuantity)
totalPrice += Number(_item?.purchaseQuantity) || 0
})
if (!value) {
return Promise.reject(new Error('请输入采购数量'))
......
......@@ -137,27 +137,35 @@ const MaterialModalTable: React.FC<MaterialModalTableProps> = (props) => {
if (Array.isArray(_value)) {
let processData = _value.map(v => {
let temp: any = {};
temp.id = v.id;
temp.code = v.code;
temp.name = v.name;
temp.type = v.type;
// 处理两套不同字段
temp.category = v?.customerCategory?.name || v?.category || null;
temp.brand = v?.brand?.name || v?.brand || null;
temp.unit = v?.unitName || v?.unit || null;
temp.manuFacturer = v?.manufacturer
temp.placeOrigin = v?.origin
temp.goodsGroup = v?.materialGroup?.name;
temp.materialsTrademark = v?.materialsTrademark;
temp.palmSpec = v?.palmSpec;
temp.cabinetSpec = v?.cabinetSpec;
temp.miniUnit = v?.miniUnit;
temp.trayTypeName = v?.trayTypeName;
temp.packageTypeName = v?.packageTypeName;
temp.traySpecName = v?.traySpecName;
temp.id = v.id; // 物料Id
temp.code = v.code; // 物料编号
temp.name = v.name; // 物料名称
temp.category = v?.customerCategory?.name || v?.category || null; // 物料品类
temp.brand = v?.brand?.name || v?.brand || null; // 物料品牌
temp.spec = v.type; // 物料规格
temp.unit = v?.unitName || v?.unit || null; //计价单位
// temp.price = v?.price; // 物料价格
// temp.stock = v?.stock; // 供方库存
// temp.quantity = v?.quantity; // 采购数量
temp.goodsGroup = v?.materialGroup?.name; // 物料组
temp.manuFacturer = v?.manufacturer // 生产厂家
temp.placeOrigin = v?.origin // 产地
// temp.remark = v?.remark; // 备注
temp.goodsPic = v?.goodsPic; // 物料图片
temp.materialNo = v?.materialsTrademark; // 物料牌号
temp.miniUnit = v?.miniUnit; // 最小单位
temp.packageType = v?.packageType; // 包装类型(枚举),枚举值packageTypeEnum
temp.packageTypeName = v?.packageTypeName; // 包装类型
temp.palmSpec = v?.palmSpec; // 托规格
temp.trayType = v?.trayType; // 托盘类型,枚举值trayTypeEnum
temp.trayTypeName = v?.trayTypeName; // 托盘类型
temp.traySpec = v?.traySpec; // 托盘规格,枚举值traySpecEnum
temp.traySpecName = v?.traySpecName; // 托盘规格
temp.cabinetSpec = v?.cabinetSpec; // 柜车规格
temp.requisitionSalesManReqs = v?.requisitionSalesManReqs; // 业务员列表
temp.factory = v?.factory; // 工厂
temp.globalMQID = v?.globalMQID;
temp.memberGlobalMQID = v?.memberGlobalMQID;
temp.factory = v?.factory
return temp
})
let originIds = tempOriginData.map(item => item.id)
......
import { Button } from "antd"
import { Button, Space } from "antd"
import { getIntl } from "umi"
/** 修改请购单 初始值转换 */
......@@ -112,6 +112,7 @@ export const departmentColumns: any[] = [
]
// 合同下单 物料列表
export const materialInfoColumns: any[] = [
{
title: 'ID',
......@@ -122,9 +123,9 @@ export const materialInfoColumns: any[] = [
},
{
title: '物料牌号',
dataIndex: 'materialsTrademark',
dataIndex: 'materialNo',
align: 'center',
key: 'materialsTrademark',
key: 'materialNo',
},
{
title: getIntl().formatMessage({ id: 'purchaseRequisition.wuliaobianhao', defaultMessage: '物料编号' }),
......
......@@ -2,7 +2,7 @@ import React, { useRef, useState, useEffect } from 'react'
import { history, useIntl } from 'umi'
import { usePageStatus } from '@/hooks/usePageStatus'
import { Button, Card, Col, Drawer, message, Radio, Row, Select, Upload } from 'antd'
import { createFormActions, registerVirtualBox, useFormSpy } from '@formily/antd'
import { createFormActions, FormEffectHooks, registerVirtualBox, useFormSpy } from '@formily/antd'
import { SaveOutlined, LinkOutlined, UploadOutlined } from '@ant-design/icons'
import NiceForm from '@/components/NiceForm'
import { increaseSchema } from './schema'
......@@ -30,8 +30,12 @@ import RadioNode from './components/RadioNode'
import NewMemberModalTable from './components/newMemberModalTable'
import ViewInventory from './components/viewInventory'
import EditSalesman from './components/editSalesman'
import { useLinkageUtils } from '@/utils/formEffectUtils'
import { getPurchaseRequisitionSrmGetEnumsData } from '@/services/PurchaseV2Api'
const {
onFormMount$,
} = FormEffectHooks;
const addSchemaAction = createFormActions()
const { Option } = Select;
const RowStyle = styled(props => <Row style={{ marginTop: 12, justifyContent: "flex-end" }} justify='end' {...props}>
......@@ -106,7 +110,6 @@ const IncreaseRequisition: React.FC<{}> = () => {
});
if (data.deliveryMethod === 1) {
deliveryTypeListRef.current.deliveryTypeList = deliveryTypeListRef.current.deliveryTypeList.map(item => { return { ...item, disabled: item.disabled = item.deliveryTypeName == '直送客户' ? false : true } })
console.log(deliveryTypeListRef.current.deliveryTypeList)
}
......@@ -198,6 +201,7 @@ const IncreaseRequisition: React.FC<{}> = () => {
if (_params.deliveryAddressId) {
_params.deliveryAddressId = _params.deliveryAddressId.id;
}
console.log(_params, '_params')
if (id) {
fnResult = await postPurchaseRequisitionUpdate({ ..._params, id })
} else {
......@@ -441,6 +445,33 @@ const IncreaseRequisition: React.FC<{}> = () => {
return;
}
}
const fnMap = (obj) => {
const arr = []
for (let key in obj) {
arr.push({
label: obj[key],
value: key
})
}
return arr
}
const useBusinessEffects = async () => {
const linkage = useLinkageUtils();
await onFormMount$().subscribe(() => {
getPurchaseRequisitionSrmGetEnumsData().then((res: any) => {
console.log(res.data, 'data')
const businessTypeMap = fnMap(res.data?.businessTypeMap)
const currencyMap = fnMap(res.data?.currencyMap)
const arrivalAreaMap = fnMap(res.data?.arrivalAreaMap)
linkage.enum('business', businessTypeMap)
linkage.enum('currency', currencyMap)
linkage.enum('arrivalArea', arrivalAreaMap);
})
})
}
return (<div className={styles['mian']}>
<FormDetailContext.Provider value={providerValue}>
<FormDetailHeader
......@@ -468,6 +499,7 @@ const IncreaseRequisition: React.FC<{}> = () => {
effects={($, ctx) => {
$('onFormMount').subscribe(() => { })
useEditHideField()
useBusinessEffects()
useAsyncSelect(
"deliveryMethod",
fetchOptions(
......
import { useRef, useState } from 'react'
import { useEffect, useMemo, useRef, useState } from 'react'
import { ISchemaFormActions, ISchemaFormAsyncActions } from '@formily/antd';
import { Button, Row, Col, Spin, Space } from 'antd';
import { getIntl, useIntl } from 'umi';
......@@ -27,15 +27,17 @@ export const useMaterialTable = (ctx: ISchemaFormActions | ISchemaFormAsyncActio
const { visible, setVisible, rowSelection, rowSelectionCtl } = useModalTable({ type: 'checkbox' })
const [_record, setRecord] = useState<any>()
console.log(rowSelectionCtl, 'rowSelectionCtl')
const handleDelete = (record) => {
const newData = [...ctx.getFieldValue('products')]
// 删除formvalue
const colIndex = newData.findIndex(v => v.id === record.id)
const colIndex = newData.findIndex(v => v.productId === record.productId)
newData.splice(colIndex, 1)
// 删除选中的项
rowSelectionCtl.setSelectRow(newData)
rowSelectionCtl.setSelectedRowKeys(newData.map(v => v.id))
rowSelectionCtl.setSelectedRowKeys(newData.map(v => v.productId))
ctx.setFieldValue('products', newData)
}
......@@ -58,7 +60,7 @@ export const useMaterialTable = (ctx: ISchemaFormActions | ISchemaFormAsyncActio
materialInfoColumns[materialInfoColumns.length - 2].render = (t, r) => r.amount && <span style={{ color: 'red' }}>{intl.formatMessage({ id: 'commodity.products.directChannel.columns.currency' })} {Number(r.amount).toFixed(2)}</span>
materialInfoColumns[materialInfoColumns.length - 1].render = (text, record) => <Space>
<Button type='link' onClick={() => handleDelete(record)}>{intl.formatMessage({ id: 'purchaseRequisition.shanchu', defaultMessage: '删除' })}</Button>
<Button type='link' onClick={() => handleSaleman(record)} disabled={!record?.quantity}>编辑业务员</Button>
<Button type='link' onClick={() => handleSaleman(record)}>编辑业务员</Button>
</Space>
return materialInfoColumns
})
......
......@@ -126,16 +126,7 @@ const basicInfo: ISchema = {
business: {
type: 'string',
enum: [
{
label: "大料",
value: 1
},
{
label: "小料",
value: 2
}
],
enum: [],
title: '业务类型',
"x-rules": [
{
......@@ -155,37 +146,13 @@ const basicInfo: ISchema = {
currency: {
type: 'string',
title: '币别',
enum: [
{
label: '人民币',
value: 1
},
{
label: '美元',
value: 2
},
{
label: '日元',
value: 3
},
{
label: '欧元',
value: 4
}
]
enum: []
},
//400华中区,401华东区,402华南区,403华西区,404华北区,404EC区
arrivalArea: {
type: 'string',
enum: [
{ label: '华中区', value: '400' },
{ label: '华东区', value: '401' },
{ label: '华南区', value: '402' },
{ label: '华西区', value: '403' },
{ label: '华北区', value: '404' },
{ label: 'EC区', value: '405' },
],
enum: [],
title: getIntl().formatMessage({ id: 'purchaseRequisition.currency', defaultMessage: '到货区域' }),
"x-mega-props": {
span: 1
......
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