Commit 8849f054 authored by 前端-钟卫鹏's avatar 前端-钟卫鹏

fix: 商品批量上下架限制状态和类型,商品行操作由接口字段控制,处理采购下单删除地址后提交异常问题

parent e6bb5ed2
import React, { useEffect, useState } from 'react'
import { Popconfirm, Button, Dropdown, Menu } from 'antd'
import React from 'react'
import { Button, Dropdown, Menu } from 'antd'
import { CaretDownOutlined } from '@ant-design/icons'
/**
* 表格行操作
* 操作显示隐藏受控接口返回字段
* 操作按钮大于两项 显示更多
*/
type IButtonTextFieldMap = Record<string, boolean>;
type IOperationHandler = Record<string, any>;
export interface TableOperationProps {
record: any,
/** 自定义状态字段, 默认'status' */
customField?: string,
/** 所有状态和操作名称的映射 */
statusOperationMap: any,
/** 所有的操作句柄函数 */
operationHandler: any,
/** 优先靠前的操作名称 */
priorityOperationName?: string,
/** 按钮文本和字段值映射 */
buttonTextFieldMap: IButtonTextFieldMap,
/** 按钮文本和操作函数映射 */
operationHandler: IOperationHandler,
}
const TableOperation:React.FC<TableOperationProps> = (props) => {
const { buttonTextFieldMap, operationHandler } = props
const keyNames = Object.keys(buttonTextFieldMap)
const { record, statusOperationMap, operationHandler, priorityOperationName, customField = 'status' } = props
const [operationName, setOperationName] = useState<string[]>([])
useEffect(() => {
let maps = record[customField] ? statusOperationMap[record[customField]] : []
if(maps.length > 2 && priorityOperationName && maps.includes(priorityOperationName)){
let temp = maps.filter(_ => _ != priorityOperationName)
temp.unshift(priorityOperationName)
setOperationName(temp)
}else{
setOperationName(() => record[customField] ? statusOperationMap[record[customField]] : [])
}
}, [record])
return ( <>
return (<>
{
operationName.length > 2
Object.values(buttonTextFieldMap).filter(Boolean).length > 2
?
<>
<Button type='link' onClick={operationHandler[operationName[0]]}>{operationName[0]}</Button>
<Button type='link' onClick={operationHandler[keyNames[0]]}>{keyNames[0]}</Button>
<Dropdown overlay={
<Menu>
{
operationName.slice(1, operationName.length).map((e, i) => (
keyNames.slice(1, keyNames.length).map((item, i) => buttonTextFieldMap[item] ? (
<Menu.Item key={`menuItem${i}`}>
<Button type='link' onClick={operationHandler[e]}>{ e }</Button>
<Button type='link' onClick={operationHandler[item]}>{ item }</Button>
</Menu.Item>
))
) : null)
}
</Menu>
}>
......@@ -54,10 +44,9 @@ const TableOperation:React.FC<TableOperationProps> = (props) => {
</Dropdown>
</>
:
operationName.map((e, i) => (<Button key={`btnItem${i}`} type='link' onClick={operationHandler[e]}>{ e }</Button>))
keyNames.map((item, i) => (buttonTextFieldMap[item] ? <Button key={`btnItem${i}`} type='link' onClick={operationHandler[item]}>{ item }</Button> : null))
}
</>
)
</>)
}
TableOperation.defaultProps = {}
......
This diff is collapsed.
......@@ -520,7 +520,7 @@ const viewProducts: React.FC<{}> = () => {
{/* 没有价格属性默认一行直接显示图片 */}
<div className={styles.productImgBox}>
{
productDetail?.unitPriceAndPicList[0].commodityPic.length>0 && productDetail?.unitPriceAndPicList[0].commodityPic.map((_item, index) =>
productDetail?.unitPriceAndPicList?.length && productDetail?.unitPriceAndPicList[0].commodityPic.length>0 && productDetail?.unitPriceAndPicList[0].commodityPic.map((_item, index) =>
<div key={index} className={styles.imgItem}><img className={styles.pic} src={_item} alt=""/>
</div>)
}
......
import React, { useRef } from 'react'
import { history, Link } from 'umi'
import { Button, Row, Col, Modal } from 'antd'
import { Modal } from 'antd'
import { PublicApi } from '@/services/api'
import EyePreview from '@/components/EyePreview'
import { formatTimeString } from '@/utils'
import StatusColors from '@/pages/transaction/components/statusColors'
import { FieldTimeOutlined } from '@ant-design/icons'
import { ORDER_TYPE, PurchaseOrderInsideWorkState } from '@/constants/order'
import { DOC_TYPE_PURCHASE_RECEIPT } from '@/constants/commodity'
import TableOperation from '@/components/TableOperation'
// 业务hooks, 待支付订单
export const useSelfTable = () => {
const ref = useRef<any>({})
/** 参照后台数据生成 */
const renderOptionButton = (record: any) => {
const statusAndOperationList = {
'9': ['新增入库单'],
'10': ['审核'],
const buttonGroup = {
'审核': true,
'新增入库单': true,
}
const operationHandler = {
'审核': () => handleConfirm(record),
'新增入库单': () => handleAdd(record),
}
return (
<TableOperation
record={record}
customField='button'
statusOperationMap={statusAndOperationList}
buttonTextFieldMap={buttonGroup}
operationHandler={operationHandler}
priorityOperationName='审核'
/>
)
}
......
......@@ -17,6 +17,7 @@ import cx from 'classnames'
import ModalForm from '@/components/ModalForm'
import { useHttpRequest } from '@/hooks/useHttpRequest'
import { CaretDownOutlined } from '@ant-design/icons'
import TableOperation from '@/components/TableOperation'
const SelectStyles = styled((props) => <div className='select-list' {...props}></div>)`
.select_style_border {
......@@ -137,34 +138,12 @@ const PurchaseOrder: React.FC<PurchaseOrderProps> = (props) => {
'评价': () => handleEvaluate(record.orderId),
}
const keyNames = Object.keys(buttonGroup)
return (<>
{
Object.values(buttonGroup).filter(Boolean).length > 2
?
<>
<Button type='link' onClick={operationHandler[keyNames[0]]}>{keyNames[0]}</Button>
<Dropdown overlay={
<Menu>
{
keyNames.slice(1, keyNames.length).map((e, i) => (
<Menu.Item key={`menuItem${i}`}>
<Button type='link' onClick={operationHandler[e]}>{ e }</Button>
</Menu.Item>
))
}
</Menu>
}>
<a className="ant-dropdown-link" onClick={e => e.preventDefault()}>
更多 <CaretDownOutlined />
</a>
</Dropdown>
</>
:
keyNames.map((e, i) => (buttonGroup[e] ? <Button key={`btnItem${i}`} type='link' onClick={operationHandler[e]}>{ e }</Button> : null))
}
</>)
return (
<TableOperation
buttonTextFieldMap={buttonGroup}
operationHandler={operationHandler}
/>
)
}
const secondColumns = () => {
......
......@@ -79,8 +79,7 @@ const ContractModalTable:React.FC<ContractModalTableProps> = (props) => {
temp.brand = v.brand;
temp.unit = v.unit;
temp.relevanceProductId = v.associatedDataId;
temp.relevanceProductName = v.associatedMaterielName;
temp.relevanceProductNo = v.associatedMaterielNo;
temp.relevanceProductName = v.associatedGoods;
temp.relevanceProductType = v.associatedType;
temp.relevanceProductCategory = v.associatedCategory;
temp.relevanceProductBrand = v.associatedBrand;
......
......@@ -100,8 +100,7 @@ const MaterialModalTable:React.FC<MaterialModalTableProps> = (props) => {
temp.brand = v.brand;
temp.unit = v.unit;
temp.relevanceProductId = v.associatedDataId;
temp.relevanceProductName = v.associatedMaterielName;
temp.relevanceProductNo = v.associatedMaterielNo;
temp.relevanceProductName = v.associatedGoods;
temp.relevanceProductType = v.associatedType;
temp.relevanceProductCategory = v.associatedCategory;
temp.relevanceProductBrand = v.associatedBrand;
......
......@@ -66,7 +66,8 @@ const SelectAddress = (props: ISchemaFieldComponentProps) => {
value = dataSource.find(v => v.id === value) || {}
}
// 当前选中的id
const checkedId = value.id || dataSource[0]?.id
// const checkedId = value.id || dataSource[0]?.id
const checkedId = value.id
const handleAdd = () => {
setMode('add')
......@@ -98,6 +99,10 @@ const SelectAddress = (props: ISchemaFieldComponentProps) => {
e.stopPropagation()
try {
const result = await PublicApi.postLogisticsReceiverAddressDelete({ id })
if(result.code === 1000) {
// 删除后置空表单值
mutators.change([])
}
reloadAddress()
} catch (error) {
......
......@@ -199,7 +199,7 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
// 交付地址数据字段转换拼接 查询省市区冗余
const { data: addressDetail, code} = await PublicApi.getLogisticsReceiverAddressGet({
id: params.deliveryAddresId?.id || params.deliveryAddresId
})
}, { ctlType: 'none' })
if(code === 1000) {
params.consignee = {
deliverDate: params.deliverDate,
......
......@@ -5,6 +5,7 @@ import { PublicApi } from '@/services/api'
import { useRowSelectionTable } from '@/hooks/useRowSelectionTable'
import { history } from 'umi'
import { CaretDownOutlined } from '@ant-design/icons'
import TableOperation from '@/components/TableOperation'
// 业务hooks, 待新增订单
export const useSelfTable = () => {
......@@ -36,34 +37,12 @@ export const useSelfTable = () => {
'删除': () => handleDelete(record.orderId),
}
const keyNames = Object.keys(buttonGroup)
return (<>
{
Object.values(buttonGroup).filter(Boolean).length > 2
?
<>
<Button type='link' onClick={operationHandler[keyNames[0]]}>{keyNames[0]}</Button>
<Dropdown overlay={
<Menu>
{
keyNames.slice(1, keyNames.length).map((e, i) => (
<Menu.Item key={`menuItem${i}`}>
<Button type='link' onClick={operationHandler[e]}>{ e }</Button>
</Menu.Item>
))
}
</Menu>
}>
<a className="ant-dropdown-link" onClick={e => e.preventDefault()}>
更多 <CaretDownOutlined />
</a>
</Dropdown>
</>
:
keyNames.map((e, i) => (buttonGroup[e] ? <Button key={`btnItem${i}`} type='link' onClick={operationHandler[e]}>{ e }</Button> : null))
}
</>)
return (
<TableOperation
buttonTextFieldMap={buttonGroup}
operationHandler={operationHandler}
/>
)
}
const secondColumns = () => {
......
......@@ -19,21 +19,16 @@ export const useSelfTable = () => {
/** 参照后台数据生成 */
const renderOptionButton = (record: any) => {
const statusAndOperationList = {
'11': ['新增发货单'],
'12': ['审核'],
}
const buttonGroup = { '新增发货单': true, '审核': true }
const operationHandler = {
'审核': () => handleConfirm(record),
'新增发货单': () => handleAdd(record),
}
return (
<TableOperation
record={record}
customField='button'
statusOperationMap={statusAndOperationList}
buttonTextFieldMap={buttonGroup}
operationHandler={operationHandler}
priorityOperationName='审核'
/>
)
}
......
......@@ -13,10 +13,10 @@ import DateRangePickerUnix from '@/components/NiceForm/components/DateRangePicke
import Submit from '@/components/NiceForm/components/Submit'
import NiceForm from '@/components/NiceForm'
import { createFormActions } from '@formily/antd'
import TableOperation from '@/components/TableOperation'
import ModalForm from '@/components/ModalForm'
import { useHttpRequest } from '@/hooks/useHttpRequest'
import { CaretDownOutlined } from '@ant-design/icons'
import TableOperation from '@/components/TableOperation'
// 销售订单查询
......@@ -90,34 +90,12 @@ const SaleOrder: React.FC<SaleOrderProps> = (props) => {
'评价': () => handleEvaluate(record.orderId),
}
const keyNames = Object.keys(buttonGroup)
return (<>
{
Object.values(buttonGroup).filter(Boolean).length > 2
?
<>
<Button type='link' onClick={operationHandler[keyNames[0]]}>{keyNames[0]}</Button>
<Dropdown overlay={
<Menu>
{
keyNames.slice(1, keyNames.length).map((e, i) => (
<Menu.Item key={`menuItem${i}`}>
<Button type='link' onClick={operationHandler[e]}>{ e }</Button>
</Menu.Item>
))
}
</Menu>
}>
<a className="ant-dropdown-link" onClick={e => e.preventDefault()}>
更多 <CaretDownOutlined />
</a>
</Dropdown>
</>
:
keyNames.map((e, i) => (buttonGroup[e] ? <Button key={`btnItem${i}`} type='link' onClick={operationHandler[e]}>{ e }</Button> : null))
}
</>)
return (
<TableOperation
buttonTextFieldMap={buttonGroup}
operationHandler={operationHandler}
/>
)
}
const secondColumns = () => {
......
......@@ -18,10 +18,10 @@ export const useSelfTable = () => {
/** 参照后台数据生成 */
const renderOptionButton = (record: any) => {
const statusAndOperationList = {
'13': ['新增物流单'],
'14': ['查看物流单'],
'15': ['修改物流单'],
const buttonGroup = {
'新增物流单': true,
'查看物流单': true,
'修改物流单': true,
}
const operationHandler = {
'新增物流单': () => handleConfirm(record),
......@@ -30,11 +30,8 @@ export const useSelfTable = () => {
}
return (
<TableOperation
record={record}
customField='button'
statusOperationMap={statusAndOperationList}
buttonTextFieldMap={buttonGroup}
operationHandler={operationHandler}
priorityOperationName='审核'
/>
)
}
......
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