Commit 7c37b7ac authored by 前端-钟卫鹏's avatar 前端-钟卫鹏

fix:新建商品添加对视频大小格式和图片格式限制,新建商品对是否提供发票校验失效问题,订单详情添加对售后跳转过来的字段兼顾

parent e0456a33
......@@ -214,7 +214,6 @@ const AddProducts: React.FC<{}> = (props) => {
try {
if (_productAttributeAndImageParams.length > 0) {
_productAttributeAndImageParams.map(_item => {
// console.log(_item, '_item')
_item.goods = { id: _item.goodsId } // id为0表示无货品
delete _item.goodsId
......@@ -222,7 +221,7 @@ const AddProducts: React.FC<{}> = (props) => {
// 过滤掉上传失败时 返回null等无效数据
if (_item.commodityPic.length > 0) {
// 编辑情况下兼顾手动添加图片列表属性
_item.commodityPic = _item.commodityPic.map(__item => __item?.response?.data || __item?.url)
_item.commodityPic = _item.commodityPic.map(__item => __item?.response?.data || __item?.url || __item)
if(_item.commodityPic.filter(Boolean).length === 0){
throw new Error('每项请至少上传一张商品图片!')
}
......@@ -289,13 +288,13 @@ const AddProducts: React.FC<{}> = (props) => {
// 校验属性单位重量是否提供发票
try {
if(!_params.commodityAttributeList.length && !_params?.unitId && typeof(_params.isInvoice) !== 'boolean' && !_params?.logistics?.weight){
if(!_params.commodityAttributeList.length || !_params?.unitId || typeof(_params.isInvoice) !== 'boolean' || !_params?.logistics?.weight){
throw new Error('请完善商品其他信息!')
}
} catch (e) {
return e
}
console.log(!_params.commodityAttributeList.length && !_params?.unitId && typeof(_params.isInvoice) !== 'boolean' && !_params?.logistics?.weight,_params,'123456')
// 校验价格
try {
if(_params.unitPriceAndPicList){
......@@ -409,15 +408,6 @@ const AddProducts: React.FC<{}> = (props) => {
onRef={(refs) => setFormRefs([...formRefs, refs])}
/>
</TabPane>
{/* 带校验 Badge */}
{/* <TabPane tab={<Badge count={1} offset={[12, 0]}>基本信息</Badge>} key="1">
<BasicInfoForm
onRef={(refs) => setFormRefs([...formRefs, refs])}
onChangeAttributeList={(_lists: any) => setAttributeList(_lists)} />
</TabPane> */}
</Tabs>
</Card>
......
......@@ -2,10 +2,10 @@ import React, { useState, useEffect, useRef } from 'react'
import { history } from 'umi'
import { Form, Select, Radio, Checkbox, InputNumber } from 'antd'
import { PublicApi } from '@/services/api'
import {
GetLogisticsSelectListCompanyResponse,
GetLogisticsSelectListShipperAddressResponse,
GetLogisticsSelectListFreightTemplateResponse
import {
GetLogisticsSelectListCompanyResponse,
GetLogisticsSelectListShipperAddressResponse,
GetLogisticsSelectListFreightTemplateResponse
} from '@/services/LogisticsApi'
import { store } from '@/store'
const { ProductStore } = store
......@@ -25,7 +25,7 @@ export interface Iprops {
const { Option } = Select
const LogisticsForm: React.FC<Iprops> = (props) => {
const LogisticsForm: React.FC<Iprops> = (props) => {
const { onRef } = props
const logisticsFormRef = useRef()
const [logisticsForm] = Form.useForm()
......@@ -74,7 +74,7 @@ const LogisticsForm: React.FC<Iprops> = (props) => {
useEffect(() => {
// 品类 变动清空form
if(history.location.query?.id && !flagRef.current) {
flagRef.current = true
flagRef.current = true
} else {
logisticsForm.resetFields()
logisticsForm.setFieldsValue({deliveryType:1, carriageType:1})
......@@ -82,7 +82,6 @@ const LogisticsForm: React.FC<Iprops> = (props) => {
}, [selectCategoryId])
useEffect(() => {
console.log(productPriceType)
if(productPriceType === 3){
logisticsForm.setFieldsValue({carriageType: 1})
setCarriageType(1)
......@@ -147,7 +146,7 @@ const LogisticsForm: React.FC<Iprops> = (props) => {
<Radio value={3}>无需配送</Radio>
</Radio.Group>
</Form.Item>
{
{
deliveryType === 1 && <><Form.Item
name="carriageType"
label="运费方式"
......@@ -187,7 +186,7 @@ const LogisticsForm: React.FC<Iprops> = (props) => {
</Form.Item></>
}
{
carriageType === 2 && <Form.Item
carriageType === 2 && <Form.Item
name="useTemplate"
valuePropName="checked"
label=" "
......@@ -231,7 +230,7 @@ const LogisticsForm: React.FC<Iprops> = (props) => {
</Select>
</Form.Item>
}
{
{
deliveryType === 1 && <Form.Item
name="company"
label="物流公司"
......@@ -250,4 +249,4 @@ const LogisticsForm: React.FC<Iprops> = (props) => {
</>)
}
export default LogisticsForm
\ No newline at end of file
export default LogisticsForm
......@@ -15,12 +15,12 @@ const layout = {
}
export interface Iprops {
onRef: (refs: any) => void;
onRef: (refs: any) => void;
}
const { TextArea } = Input
const OtherForm: React.FC<Iprops> = (props) => {
const OtherForm: React.FC<Iprops> = (props) => {
const { onRef } = props
const otherFormRef = useRef()
const flagRef = useRef<boolean>(false)
......@@ -38,7 +38,7 @@ const OtherForm: React.FC<Iprops> = (props) => {
useEffect(() => {
// 品类 变动清空form
if(history.location.query?.id && !flagRef.current) {
flagRef.current = true
flagRef.current = true
} else {
otherForm.resetFields()
}
......@@ -57,12 +57,10 @@ const OtherForm: React.FC<Iprops> = (props) => {
<Form.Item
name="isInvoice"
label="提供发票"
rules={[
{
required: true,
message: '请选择是否提供发票'
}
]}
rules={[{
required: true,
message: "请选择是否提供发票"
}]}
>
<Radio.Group size="small">
<Radio.Button value={true} style={{ width: 100, textAlign: 'center' }}></Radio.Button>
......@@ -106,4 +104,4 @@ const OtherForm: React.FC<Iprops> = (props) => {
</>)
}
export default OtherForm
\ No newline at end of file
export default OtherForm
......@@ -57,6 +57,17 @@ const ProductDescFormDefualt: React.FC<{}> = (props) => {
action: '/api/file/file/upload',
showUploadList: false,
data: { fileType: UPLOAD_TYPE },
beforeUpload(file) {
const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/jpg' || file.type === 'image/png' || file.type === 'image/gif';
if (!isJpgOrPng) {
message.error('仅支持jpeg/jpg/png/gif格式的图片文件!');
}
// const isLt2M = file.size / 1024 / 1024 < 2;
// if (!isLt2M) {
// message.error('Image must smaller than 2MB!');
// }
return isJpgOrPng;
},
onChange(info) {
setIsLoading(true)
if (info.file.status === 'done') {
......@@ -70,6 +81,8 @@ const ProductDescFormDefualt: React.FC<{}> = (props) => {
} else if (info.file.status === 'error') {
setIsLoading(false)
message.error(`${info.file.name} 文件上传失败`);
} else if(!info.file.status) {
setIsLoading(false)
}
},
}
......@@ -79,14 +92,17 @@ const ProductDescFormDefualt: React.FC<{}> = (props) => {
action: '/api/file/file/upload',
showUploadList: false,
data: { fileType: UPLOAD_TYPE },
// beforeUpload(file) {
// console.log(file, 'video file')
// const isVideo = file.type === 'video/mp4' || file.type === 'image/png';
// if (!isVideo) {
// message.error('请上传视频文件!');
// }
// return isVideo
// },
beforeUpload(file) {
const isVideo = file.type === 'video/mp4';
if (!isVideo) {
message.error('请上传mp4格式的视频文件!');
}
const isLt10M = file.size / 1024 / 1024 < 10;
if (!isLt10M) {
message.error('请上传小于10M的视频文件!');
}
return isVideo && isLt10M;
},
onChange(info) {
setIsLoading(true)
if (info.file.status === 'done') {
......@@ -100,6 +116,8 @@ const ProductDescFormDefualt: React.FC<{}> = (props) => {
} else if (info.file.status === 'error') {
setIsLoading(false)
message.error(`${info.file.name} 文件上传失败`);
} else if(!info.file.status) {
setIsLoading(false)
}
},
}
......
......@@ -8,6 +8,7 @@ import { orderTypeLabel } from '../constant'
import { formatTimeString } from '@/utils'
import StatusColors from '../../../components/StatusColors'
import { message } from 'antd'
import { history } from 'umi'
interface OrderDetailHookProps {
// 采购、销售
......@@ -24,6 +25,7 @@ export const useOrderDetail = (options: OrderDetailHookProps) => {
// 支付信息列表
const [payList, setPaylist] = useState<any[]>([])
const { id } = usePageStatus()
const { orderNo } = history.location.query
const { type } = options
const dataRef = useRef<any>([
{ label: '对应报价单号', name: 'quotationNo', span: 8, render: text => <Link to={'/'}>{text}</Link> },
......@@ -42,9 +44,9 @@ export const useOrderDetail = (options: OrderDetailHookProps) => {
}, [])
const reloadFormData = useCallback(() => {
if (id) {
if (id || orderNo) {
const fn = type === 'purchaseOrder' ? PublicApi.getOrderProcurementOrderDetails : PublicApi.getOrderPurchaseOrderDetails
fn({ id }, { ctlType: "none" }).then(res => {
fn( id ? { id } : { orderNo }, { ctlType: "none" }).then(res => {
const { code, data, message: msg } = res
if (code === 1000) {
setFormData(data)
......
import React from 'react'
import { Tag } from 'antd'
import { PurchaseOrderInsideWorkStateTexts, PurchaseOrderOutWorkStateTexts, PurchaseOrderInsideWorkState, PurchaseOrderOutWorkState, SaleOrderInsideWorkState, SaleOrderInsideWorkStateTexts, PayOutWorkStateTexts, DeliverySideState, DeliverySideStateTexts, InquiryStateTexts, OrderTransformOutWorkStateTexts, PurchaseOrderTransformInsideWorkStateTexts, SaleOrderTransformInsideWorkStateTexts } from '@/constants'
export interface IStatusColor {
[key: string]: {
value: string | number,
color: string
}
}
// 用于标签状态控制
export interface StatusColorsProps {
status: number,
type: 'out' | 'inside' | 'saleInside' | 'payOut' | 'deliveInside' | 'inquiry' | 'transformOut' | 'transformInside' | 'transformSaleInside'
}
export enum ORDER_EXAMINE_ENUM {
/**
* 新增订单
*/
ADD_ORDER = 1,
/**
* 一级审核
*/
ONE_LEVEL_VALIDATE,
/**
* 二级审核
*/
TWO_LEVEL_VALIDATE,
/**
* 提交订单中
*/
SUBMIT_ORDER_PROCESS,
/**
* 提交订单成功
*/
SUBMIT_ORDER_SUCCESS,
/**
* 一级审核失败
*/
ONE_LEVEL_VALIDATE_ERROR,
/**
* 二级审核失败
*/
TWO_LEVEL_VALIDATE_ERROR
}
export const ORDER_EXAMINE_LIST = ['',
'新增订单',
'一级审核中',
'二级审核中',
'提交订单',
'提交成功',
'一级审核不通过',
'二级审核不通过'
]
// 状态颜色映射
export const StatusColorsMaps = {
ready: '#C0C4CC',
process: '#FFC400',
submit: '#6C9CEB',
success: '#41CC9E',
error: '#EF6260'
}
const matchStatusColor = (status: number): string => {
const maps = {
[ORDER_EXAMINE_ENUM.ADD_ORDER]: StatusColorsMaps.ready,
[ORDER_EXAMINE_ENUM.ONE_LEVEL_VALIDATE]: StatusColorsMaps.process,
[ORDER_EXAMINE_ENUM.TWO_LEVEL_VALIDATE]: StatusColorsMaps.process,
[ORDER_EXAMINE_ENUM.SUBMIT_ORDER_PROCESS]: StatusColorsMaps.submit,
[ORDER_EXAMINE_ENUM.SUBMIT_ORDER_SUCCESS]: StatusColorsMaps.success
}
const READY_LISTS = [
PurchaseOrderInsideWorkState.CANCEL_ORDER,
PurchaseOrderOutWorkState.CANCEL_ORDER
]
// 默认返回错误的状态颜色
return maps[status] || StatusColorsMaps.error
}
const typeMaps = {
'out': PurchaseOrderOutWorkStateTexts,
'inside': PurchaseOrderInsideWorkStateTexts,
'saleInside': SaleOrderInsideWorkStateTexts,
'payOut': PayOutWorkStateTexts,
'deliveInside': DeliverySideStateTexts,
'inquiry': InquiryStateTexts,
'transformOut': OrderTransformOutWorkStateTexts,
'transformInside': PurchaseOrderTransformInsideWorkStateTexts,
'transformSaleInside': SaleOrderTransformInsideWorkStateTexts
}
// 订单内部状态显示
const StatusColors:React.FC<StatusColorsProps> = (props) => {
const { status, type } = props
const statusText = typeMaps[type]
const statusShowColor = matchStatusColor(status)
// 单独处理支付比例 确认到账的状态颜色
if(type === 'payOut' && status === 3) {
return (<Tag color="#41CC9E">{statusText[status]}</Tag>)
}
return (<Tag color={statusShowColor}>{statusText[status]}</Tag>)
}
StatusColors.defaultProps = {}
export default StatusColors
\ No newline at end of file
import React from 'react'
import { Tag } from 'antd'
import { PurchaseOrderInsideWorkStateTexts, PurchaseOrderOutWorkStateTexts, PurchaseOrderInsideWorkState, PurchaseOrderOutWorkState, SaleOrderInsideWorkState, SaleOrderInsideWorkStateTexts, PayOutWorkStateTexts, DeliverySideState, DeliverySideStateTexts, InquiryStateTexts, OrderTransformOutWorkStateTexts, PurchaseOrderTransformInsideWorkStateTexts, SaleOrderTransformInsideWorkStateTexts } from '@/constants'
export interface IStatusColor {
[key: string]: {
value: string | number,
color: string
}
}
// 用于标签状态控制
export interface StatusColorsProps {
status: number,
type: 'out' | 'inside' | 'saleInside' | 'payOut' | 'deliveInside' | 'inquiry' | 'transformOut' | 'transformInside' | 'transformSaleInside'
}
export enum ORDER_EXAMINE_ENUM {
/**
* 新增订单
*/
ADD_ORDER = 1,
/**
* 一级审核
*/
ONE_LEVEL_VALIDATE,
/**
* 二级审核
*/
TWO_LEVEL_VALIDATE,
/**
* 提交订单中
*/
SUBMIT_ORDER_PROCESS,
/**
* 提交订单成功
*/
SUBMIT_ORDER_SUCCESS,
/**
* 一级审核失败
*/
ONE_LEVEL_VALIDATE_ERROR,
/**
* 二级审核失败
*/
TWO_LEVEL_VALIDATE_ERROR
}
export const ORDER_EXAMINE_LIST = ['',
'新增订单',
'一级审核中',
'二级审核中',
'提交订单',
'提交成功',
'一级审核不通过',
'二级审核不通过'
]
// 状态颜色映射
export const StatusColorsMaps = {
ready: '#C0C4CC',
process: '#FFC400',
submit: '#6C9CEB',
success: '#41CC9E',
error: '#EF6260'
}
const matchStatusColor = (status: number): string => {
const maps = {
[ORDER_EXAMINE_ENUM.ADD_ORDER]: StatusColorsMaps.ready,
[ORDER_EXAMINE_ENUM.ONE_LEVEL_VALIDATE]: StatusColorsMaps.process,
[ORDER_EXAMINE_ENUM.TWO_LEVEL_VALIDATE]: StatusColorsMaps.process,
[ORDER_EXAMINE_ENUM.SUBMIT_ORDER_PROCESS]: StatusColorsMaps.submit,
[ORDER_EXAMINE_ENUM.SUBMIT_ORDER_SUCCESS]: StatusColorsMaps.success
}
const READY_LISTS = [
PurchaseOrderInsideWorkState.CANCEL_ORDER,
PurchaseOrderOutWorkState.CANCEL_ORDER
]
// 默认返回错误的状态颜色
return maps[status] || StatusColorsMaps.error
}
const typeMaps = {
'out': PurchaseOrderOutWorkStateTexts,
'inside': PurchaseOrderInsideWorkStateTexts,
'saleInside': SaleOrderInsideWorkStateTexts,
'payOut': PayOutWorkStateTexts,
'deliveInside': DeliverySideStateTexts,
'inquiry': InquiryStateTexts,
'transformOut': OrderTransformOutWorkStateTexts,
'transformInside': PurchaseOrderTransformInsideWorkStateTexts,
'transformSaleInside': SaleOrderTransformInsideWorkStateTexts
}
// 订单内部状态显示
const StatusColors:React.FC<StatusColorsProps> = (props) => {
const { status, type } = props
const statusText = typeMaps[type]
const statusShowColor = matchStatusColor(status)
// 单独处理支付比例 确认到账的状态颜色
if(type === 'payOut' && status === 3) {
return (<Tag color="#41CC9E">{statusText[status]}</Tag>)
}
return (<Tag color={statusShowColor}>{statusText[status]}</Tag>)
}
StatusColors.defaultProps = {}
export default StatusColors
......@@ -286,7 +286,7 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
// 跳转至待新增列表
window.sessionStorage.removeItem(spam_id)
setTimeout(() => {
history.goBack()
history.push("/memberCenter/tranactionAbility/purchaseOrder/readyAddOrder")
}, 1000)
} else {
setBtnLoading(false)
......
import React from 'react';
import { OrderDetailContext } from '../../_public/order/context';
import OrderDetailHeader from '@/pages/transaction/components/OrderDetailHeader';
import OrderDetailWrapper from '@/pages/transaction/components/OrderDetailWrapper';
import PreLoading from '@/components/PreLoading';
import { useOrderDetail } from '../../_public/order/effects/useOrderDetail';
import OrderDetailSection from '../../components/orderDetailSection';
const OrderPreview: React.FC = () => {
const { formContext, detailList } = useOrderDetail({type: 'purchaseOrder'})
return (
<div>
<OrderDetailContext.Provider value={formContext}>
<OrderDetailHeader detailList={detailList} detailData={formContext.data}/>
<OrderDetailWrapper>
<PreLoading loading={!formContext.data} active paragraph={{rows: 6}}>
<OrderDetailSection formContext={formContext}/>
</PreLoading>
</OrderDetailWrapper>
</OrderDetailContext.Provider>
</div>
);
};
export default OrderPreview;
\ No newline at end of file
import React from 'react';
import { OrderDetailContext } from '../../_public/order/context';
import OrderDetailHeader from '@/pages/transaction/components/OrderDetailHeader';
import OrderDetailWrapper from '@/pages/transaction/components/OrderDetailWrapper';
import PreLoading from '@/components/PreLoading';
import { useOrderDetail } from '../../_public/order/effects/useOrderDetail';
import OrderDetailSection from '../../components/orderDetailSection';
const OrderPreview: React.FC = () => {
const { formContext, detailList } = useOrderDetail({type: 'purchaseOrder'})
return (
<div>
<OrderDetailContext.Provider value={formContext}>
<OrderDetailHeader detailList={detailList} detailData={formContext.data}/>
<OrderDetailWrapper>
<PreLoading loading={!formContext.data} active paragraph={{rows: 6}}>
<OrderDetailSection formContext={formContext}/>
</PreLoading>
</OrderDetailWrapper>
</OrderDetailContext.Provider>
</div>
);
};
export default OrderPreview;
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