提交 490dc22a 作者: 龚洪江

功能:租赁联调完成

上级 3efeb16b
...@@ -41,7 +41,13 @@ const EditableCell: React.FC< ...@@ -41,7 +41,13 @@ const EditableCell: React.FC<
const inputNode = () => { const inputNode = () => {
switch (inputType) { switch (inputType) {
case 'number': case 'number':
return <InputNumber placeholder={`请输入${placeholder || title}`} maxLength={maxLength} />; return (
<InputNumber
placeholder={`请输入${placeholder || title}`}
style={{ width: '100%' }}
maxLength={maxLength}
/>
);
case 'select': case 'select':
return ( return (
<Select placeholder={`请选择${placeholder || title}`} style={{ textAlign: 'start' }}> <Select placeholder={`请选择${placeholder || title}`} style={{ textAlign: 'start' }}>
...@@ -85,7 +91,13 @@ const EditableCell: React.FC< ...@@ -85,7 +91,13 @@ const EditableCell: React.FC<
case 'switch': case 'switch':
return <Switch />; return <Switch />;
default: default:
return <Input placeholder={`请输入${placeholder || title}`} maxLength={maxLength} />; return (
<Input
placeholder={`请输入${placeholder || title}`}
maxLength={maxLength}
style={{ width: '100%' }}
/>
);
} }
}; };
return ( return (
......
...@@ -282,6 +282,7 @@ const CommonSkuInfo = forwardRef<any, selfProps>( ...@@ -282,6 +282,7 @@ const CommonSkuInfo = forwardRef<any, selfProps>(
uploadSuccess: col.inputType === 'uploader' ? uploadSuccess : undefined, uploadSuccess: col.inputType === 'uploader' ? uploadSuccess : undefined,
rules: col.rules, rules: col.rules,
placeholder: col.placeholder, placeholder: col.placeholder,
maxLength: col.maxLength,
}), }),
}; };
}); });
......
import './index.scss'; import './index.scss';
import { Button, Col, Form, Row, Table } from 'antd'; import { Button, Col, Form, Row, Table, Tooltip } from 'antd';
import { forwardRef, useEffect, useImperativeHandle, useState } from 'react'; import { forwardRef, useEffect, useImperativeHandle, useState } from 'react';
import { InterDataType, InterReqType } from '~/api/interface'; import { InterDataType, InterReqType } from '~/api/interface';
import { addRentGoodsType, leaseGoodsDetailsType } from '~/api/interface/rentManageType'; import { addRentGoodsType, leaseGoodsDetailsType } from '~/api/interface/rentManageType';
import EditableCell from '~/components/EditableCell'; import EditableCell from '~/components/EditableCell';
import { MinusOutlined, PlusOutlined } from '@ant-design/icons'; import { MinusOutlined, PlusOutlined } from '@ant-design/icons';
import { isEmptyBol, regPriceNumber } from '~/utils/validateUtils';
//租赁商品详情返回类型 //租赁商品详情返回类型
type rentGoodsDetailType = InterDataType<leaseGoodsDetailsType>; type rentGoodsDetailType = InterDataType<leaseGoodsDetailsType>;
...@@ -25,6 +26,36 @@ interface selfProps { ...@@ -25,6 +26,36 @@ interface selfProps {
const AccessoryList = forwardRef<any, selfProps>(({ rentGoodsDetails }, ref) => { const AccessoryList = forwardRef<any, selfProps>(({ rentGoodsDetails }, ref) => {
const [accessoryTableForm] = Form.useForm<{ [x: string]: string | number }>(); const [accessoryTableForm] = Form.useForm<{ [x: string]: string | number }>();
//库存正则校验
const stockValidator = (_rules: any, value: number) => {
if (!isEmptyBol(value)) {
if (/^[+]{0,1}(\d+)$/.test(value.toString())) {
if (value > 99999999 || value < 0) {
return Promise.reject(new Error('库存最大为99999999且大于0'));
}
return Promise.resolve();
} else {
return Promise.reject(new Error('请输入正整数'));
}
} else {
return Promise.resolve();
}
};
//价格正则校验
const priceValidator = (_rules: any, value: number) => {
if (!isEmptyBol(value)) {
if (regPriceNumber(value.toString())) {
if (value > 99999999 || value < 0) {
return Promise.reject(new Error('价格最大为99999999且大于0'));
}
return Promise.resolve();
} else {
return Promise.reject(new Error('为整数且最多保留两位小数'));
}
} else {
return Promise.resolve();
}
};
const accessoryTableDefaultColumns: (ColumnTypes[number] & { const accessoryTableDefaultColumns: (ColumnTypes[number] & {
editable?: boolean; editable?: boolean;
dataIndex?: string; dataIndex?: string;
...@@ -42,6 +73,8 @@ const AccessoryList = forwardRef<any, selfProps>(({ rentGoodsDetails }, ref) => ...@@ -42,6 +73,8 @@ const AccessoryList = forwardRef<any, selfProps>(({ rentGoodsDetails }, ref) =>
editable: true, editable: true,
dataIndex: 'name', dataIndex: 'name',
align: 'center', align: 'center',
width: '30%',
maxLength: 30,
}, },
{ {
title: '数量', title: '数量',
...@@ -49,6 +82,8 @@ const AccessoryList = forwardRef<any, selfProps>(({ rentGoodsDetails }, ref) => ...@@ -49,6 +82,8 @@ const AccessoryList = forwardRef<any, selfProps>(({ rentGoodsDetails }, ref) =>
dataIndex: 'number', dataIndex: 'number',
align: 'center', align: 'center',
inputType: 'number', inputType: 'number',
width: '15%',
rules: [{ required: false, validator: stockValidator }],
}, },
{ {
title: '参考价格', title: '参考价格',
...@@ -56,6 +91,7 @@ const AccessoryList = forwardRef<any, selfProps>(({ rentGoodsDetails }, ref) => ...@@ -56,6 +91,7 @@ const AccessoryList = forwardRef<any, selfProps>(({ rentGoodsDetails }, ref) =>
dataIndex: 'price', dataIndex: 'price',
align: 'center', align: 'center',
inputType: 'number', inputType: 'number',
rules: [{ required: false, validator: priceValidator }],
}, },
{ {
title: '操作', title: '操作',
...@@ -63,21 +99,25 @@ const AccessoryList = forwardRef<any, selfProps>(({ rentGoodsDetails }, ref) => ...@@ -63,21 +99,25 @@ const AccessoryList = forwardRef<any, selfProps>(({ rentGoodsDetails }, ref) =>
render: (_: any, _record: any, index: number) => ( render: (_: any, _record: any, index: number) => (
<> <>
{index === accessoryTableData.length - 1 ? ( {index === accessoryTableData.length - 1 ? (
<Tooltip placement='top' title='添加一行'>
<Button <Button
type='primary' type='primary'
icon={<PlusOutlined />} icon={<PlusOutlined />}
style={{ marginRight: '5px' }} style={{ marginRight: '5px' }}
onClick={addAccessoryTableClick} onClick={addAccessoryTableClick}
></Button> ></Button>
</Tooltip>
) : ( ) : (
'' ''
)} )}
{index ? ( {index ? (
<Tooltip placement='top' title='删除一行'>
<Button <Button
type='primary' type='primary'
icon={<MinusOutlined />} icon={<MinusOutlined />}
onClick={() => deleteAccessoryTableClick(index)} onClick={() => deleteAccessoryTableClick(index)}
></Button> ></Button>
</Tooltip>
) : ( ) : (
'' ''
)} )}
...@@ -98,6 +138,7 @@ const AccessoryList = forwardRef<any, selfProps>(({ rentGoodsDetails }, ref) => ...@@ -98,6 +138,7 @@ const AccessoryList = forwardRef<any, selfProps>(({ rentGoodsDetails }, ref) =>
editing: col.editable, editing: col.editable,
inputType: col.inputType, inputType: col.inputType,
rules: col.rules, rules: col.rules,
maxLength: col.maxLength,
}), }),
}; };
}); });
......
import './index.scss'; import './index.scss';
import { Button, Form, Select, Table } from 'antd'; import { Button, Form, Select, Table, Tooltip } from 'antd';
import EditableCell from '~/components/EditableCell'; import EditableCell from '~/components/EditableCell';
import React, { forwardRef, useEffect, useImperativeHandle, useState } from 'react'; import React, { forwardRef, useEffect, useImperativeHandle, useState } from 'react';
import { MinusOutlined, PlusOutlined, UploadOutlined } from '@ant-design/icons'; import { MinusOutlined, PlusOutlined, UploadOutlined } from '@ant-design/icons';
...@@ -49,16 +49,23 @@ const RentAttr = forwardRef<any, selfProps>(({ rentGoodsDetails }, ref) => { ...@@ -49,16 +49,23 @@ const RentAttr = forwardRef<any, selfProps>(({ rentGoodsDetails }, ref) => {
maxLength?: number; maxLength?: number;
})[] = [ })[] = [
{ {
title: '序号',
align: 'center',
render: (_: any, _record, index: number) => index + 1,
},
{
title: '参数名称', title: '参数名称',
dataIndex: 'productParamName', dataIndex: 'productParamName',
editable: true, editable: true,
align: 'center', align: 'center',
maxLength: 30,
}, },
{ {
title: '参数值', title: '参数值',
dataIndex: 'productParamValue', dataIndex: 'productParamValue',
editable: true, editable: true,
align: 'center', align: 'center',
maxLength: 30,
}, },
{ {
title: '操作', title: '操作',
...@@ -66,21 +73,25 @@ const RentAttr = forwardRef<any, selfProps>(({ rentGoodsDetails }, ref) => { ...@@ -66,21 +73,25 @@ const RentAttr = forwardRef<any, selfProps>(({ rentGoodsDetails }, ref) => {
render: (_text: string, _record: any, index: number) => ( render: (_text: string, _record: any, index: number) => (
<> <>
{index === parameterTableData.length - 1 ? ( {index === parameterTableData.length - 1 ? (
<Tooltip placement='top' title='添加一行'>
<Button <Button
icon={<PlusOutlined />} icon={<PlusOutlined />}
type='primary' type='primary'
onClick={addParameterDataEvent} onClick={addParameterDataEvent}
style={{ marginRight: '10px' }} style={{ marginRight: '10px' }}
></Button> ></Button>
</Tooltip>
) : ( ) : (
'' ''
)} )}
{index ? ( {index ? (
<Tooltip placement='top' title='删除该行'>
<Button <Button
type='primary' type='primary'
icon={<MinusOutlined />} icon={<MinusOutlined />}
onClick={() => deleteParameterDataEvent(index)} onClick={() => deleteParameterDataEvent(index)}
></Button> ></Button>
</Tooltip>
) : ( ) : (
'' ''
)} )}
...@@ -101,6 +112,7 @@ const RentAttr = forwardRef<any, selfProps>(({ rentGoodsDetails }, ref) => { ...@@ -101,6 +112,7 @@ const RentAttr = forwardRef<any, selfProps>(({ rentGoodsDetails }, ref) => {
editing: col.editable, editing: col.editable,
inputType: col.inputType, inputType: col.inputType,
rules: col.rules, rules: col.rules,
maxLength: col.maxLength,
}), }),
}; };
}); });
......
...@@ -80,6 +80,7 @@ const SkuInfo = forwardRef<any, selfProps>(({ rentGoodsDetails }, ref) => { ...@@ -80,6 +80,7 @@ const SkuInfo = forwardRef<any, selfProps>(({ rentGoodsDetails }, ref) => {
title: '商品规格', title: '商品规格',
align: 'center', align: 'center',
children: [], children: [],
maxLength: 30,
}, },
{ {
title: '缺货', title: '缺货',
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论