提交 490dc22a 作者: 龚洪江

功能:租赁联调完成

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