Commit 4d334927 authored by 武广's avatar 武广

fix: 修改价格校验

parent d1372010
...@@ -2,19 +2,19 @@ const isProduction = process.env.NODE_ENV === 'production'; ...@@ -2,19 +2,19 @@ const isProduction = process.env.NODE_ENV === 'production';
const isPre = process.env.PRE_ENV === 'pre'; const isPre = process.env.PRE_ENV === 'pre';
const envAPi = { const envAPi = {
api: 'https://security-sc.liangkebang.net', //'https://security-sc.liangkebang.net', api: 'https://security-xyqb.liangkebang.net', //'https://security-xyqb.liangkebang.net',
kdspOpApi: 'https://sc-merchant-api-sc.liangkebang.net', kdspOpApi: 'https://sc-merchant-api-xyqb.liangkebang.net',
kdspApi: 'https://sc-merchant-api-sc.liangkebang.net', kdspApi: 'https://sc-merchant-api-xyqb.liangkebang.net',
goodsApi: 'https://sc-merchant-api-sc.liangkebang.net', goodsApi: 'https://sc-merchant-api-xyqb.liangkebang.net',
// kdspOpApi: 'https://kdsp-operation-sc.liangkebang.net', // kdspOpApi: 'https://kdsp-operation-xyqb.liangkebang.net',
// kdspApi: 'https://sc-op-api-sc.liangkebang.net', // kdspApi: 'https://sc-op-api-xyqb.liangkebang.net',
// goodsApi: 'https://sc-op-api-sc.liangkebang.net', // goodsApi: 'https://sc-op-api-xyqb.liangkebang.net',
querysApi: 'https://sc-settlement-api-sc.liangkebang.net', querysApi: 'https://sc-settlement-api-xyqb.liangkebang.net',
// goodsApi: '//192.168.188.111:7000', // goodsApi: '//192.168.188.111:7000',
prologueDomain: 'https://mall-sc.liangkebang.net', prologueDomain: 'https://mall-xyqb.liangkebang.net',
// qiniuHost: 'https://appsync.lkbang.net', // qiniuHost: 'https://appsync.lkbang.net',
qiniuHost: 'https://kdspstatic.q-gp.com/', qiniuHost: 'https://kdspstatic.q-gp.com/',
opapiHost: 'https://opapi-sc.liangkebang.net', opapiHost: 'https://opapi-xyqb.liangkebang.net',
}; };
const prodApi = { const prodApi = {
......
...@@ -92,7 +92,6 @@ const FormInformationBasic = forwardRef((props, ref) => { ...@@ -92,7 +92,6 @@ const FormInformationBasic = forwardRef((props, ref) => {
rules={[{ type: 'array', required: true, message: '请输入商品类目!' }]} rules={[{ type: 'array', required: true, message: '请输入商品类目!' }]}
> >
<Cascader <Cascader
disabled={customer.isService}
placeholder="请选择商品类目!" placeholder="请选择商品类目!"
showSearch={{ filter: filterCategoryOptions }} showSearch={{ filter: filterCategoryOptions }}
fieldNames={{ label: 'name', value: 'id', children: 'children' }} fieldNames={{ label: 'name', value: 'id', children: 'children' }}
...@@ -127,7 +126,7 @@ const FormInformationBasic = forwardRef((props, ref) => { ...@@ -127,7 +126,7 @@ const FormInformationBasic = forwardRef((props, ref) => {
{ required: true, min: 2, message: '请输入最少两个字符的商品名称!', whitespace: true }, { required: true, min: 2, message: '请输入最少两个字符的商品名称!', whitespace: true },
]} ]}
> >
<Input disabled={customer.isService} placeholder="请输入商品名称" /> <Input placeholder="请输入商品名称" />
</Form.Item> </Form.Item>
</Popover> </Popover>
{customer.isJDGoods && ( {customer.isJDGoods && (
......
...@@ -2,7 +2,7 @@ import React, { useState, forwardRef, useEffect, useImperativeHandle } from 'rea ...@@ -2,7 +2,7 @@ import React, { useState, forwardRef, useEffect, useImperativeHandle } from 'rea
import { Form, Button, Row, Col, Input, Select, Modal, notification } from 'antd'; import { Form, Button, Row, Col, Input, Select, Modal, notification } from 'antd';
import { PlusOutlined } from '@ant-design/icons'; import { PlusOutlined } from '@ant-design/icons';
import styles from '../common.less'; import styles from '../common.less';
import { isIntegerNotZero, isCheckNumberPrice } from '@/utils/validator'; import { isIntegerNotZero, isCheckPriceOneDecimal } from '@/utils/validator';
import UUID from '@/utils/uuid'; import UUID from '@/utils/uuid';
const { Option } = Select; const { Option } = Select;
...@@ -59,7 +59,7 @@ const FormCai = forwardRef((props, ref) => { ...@@ -59,7 +59,7 @@ const FormCai = forwardRef((props, ref) => {
name={[name, 'dishName']} name={[name, 'dishName']}
rules={[{ required: true, message: '请输入菜名.' }]} rules={[{ required: true, message: '请输入菜名.' }]}
> >
<Input maxLength={30} /> <Input maxLength={10} placeholder="最多10个字符" />
</Form.Item> </Form.Item>
</Col> </Col>
<Col span={2}> <Col span={2}>
...@@ -82,7 +82,7 @@ const FormCai = forwardRef((props, ref) => { ...@@ -82,7 +82,7 @@ const FormCai = forwardRef((props, ref) => {
name={[name, 'price']} name={[name, 'price']}
rules={[ rules={[
{ required: true, message: '请输入价格.' }, { required: true, message: '请输入价格.' },
{ validator: isCheckNumberPrice, message: '请输入正确的价格' }, { validator: isCheckPriceOneDecimal, message: '请输入正确的价格' },
]} ]}
> >
<Input maxLength={10} /> <Input maxLength={10} />
......
...@@ -202,7 +202,7 @@ const CreateBatchFormItems = ({ specInitValue, batchChange, editRef, defaultColu ...@@ -202,7 +202,7 @@ const CreateBatchFormItems = ({ specInitValue, batchChange, editRef, defaultColu
fieldNames={{ label: 'secondSpecValue', value: 'secondSpecValue' }} fieldNames={{ label: 'secondSpecValue', value: 'secondSpecValue' }}
/> />
{formItems.concat( {formItems.concat(
<Button key="batch" type="primary" disabled={customer.isService} onClick={batchChange}> <Button key="batch" type="primary" onClick={batchChange}>
批量设置 批量设置
</Button>, </Button>,
)} )}
...@@ -230,7 +230,14 @@ const FormPriceOrStock = forwardRef((props, ref) => { ...@@ -230,7 +230,14 @@ const FormPriceOrStock = forwardRef((props, ref) => {
const setMealContent = await packageRef.current.onCheck(); const setMealContent = await packageRef.current.onCheck();
const values = await form.validateFields(); const values = await form.validateFields();
const items = await editRef.current.onCheck(); const items = await editRef.current.onCheck();
if (items) { if (!setMealContent) {
notification.open({
message: '提示',
description: '请添加正确的套餐信息!',
});
return null;
}
if (items && setMealContent) {
return { ...values, items, setMealContent, temp: 'infoSpecData' }; return { ...values, items, setMealContent, temp: 'infoSpecData' };
} }
notification.open({ notification.open({
...@@ -394,7 +401,7 @@ const FormPriceOrStock = forwardRef((props, ref) => { ...@@ -394,7 +401,7 @@ const FormPriceOrStock = forwardRef((props, ref) => {
specDataList={specInitValue.secondSpecValue} specDataList={specInitValue.secondSpecValue}
/> />
<div style={{ display: 'flex', justifyContent: 'center', marginBottom: 20 }}> <div style={{ display: 'flex', justifyContent: 'center', marginBottom: 20 }}>
<Button type="primary" disabled={customer.isService} onClick={onFinish}> <Button type="primary" onClick={onFinish}>
生成商品信息 生成商品信息
</Button> </Button>
</div> </div>
......
...@@ -134,7 +134,7 @@ const FormSettlementOthers = forwardRef((props, ref) => { ...@@ -134,7 +134,7 @@ const FormSettlementOthers = forwardRef((props, ref) => {
<Form.Item <Form.Item
name="receptionVolume" name="receptionVolume"
label="每日最低接待量" label="每日最低接待量"
rules={[{ required: true, message: '每日最低接待量' }]} // rules={[{ required: true, message: '每日最低接待量' }]}
> >
<InputNumber min={0} style={{ width: 200 }} placeholder="请输入每日最低接待量" /> <InputNumber min={0} style={{ width: 200 }} placeholder="请输入每日最低接待量" />
</Form.Item> </Form.Item>
......
...@@ -27,7 +27,7 @@ export const TaskList = [ ...@@ -27,7 +27,7 @@ export const TaskList = [
}, },
detailImageList: { detailImageList: {
title: '详情图', title: '详情图',
// rule: true, rule: true,
limit: null, limit: null,
renderExtra: () => '(图片最大上传2M)', renderExtra: () => '(图片最大上传2M)',
}, },
...@@ -165,7 +165,7 @@ export const StaticColumns = customer => [ ...@@ -165,7 +165,7 @@ export const StaticColumns = customer => [
min: 0, min: 0,
}, },
roleRules: { required: true }, roleRules: { required: true },
disabeldRender: () => customer.isJDGoods || customer.isService, disabeldRender: () => customer.isJDGoods,
}, },
{ {
title: '佣金费率', title: '佣金费率',
...@@ -188,7 +188,7 @@ export const StaticColumns = customer => [ ...@@ -188,7 +188,7 @@ export const StaticColumns = customer => [
min: 0, min: 0,
}, },
roleRules: { required: true }, roleRules: { required: true },
disabeldRender: () => customer.isService, // disabeldRender: () => customer.isService,
}, },
{ {
title: '销售价', title: '销售价',
...@@ -219,7 +219,7 @@ export const StaticColumns = customer => [ ...@@ -219,7 +219,7 @@ export const StaticColumns = customer => [
precision: 3, precision: 3,
max: 999999.999, max: 999999.999,
}, },
disabeldRender: () => customer.isService, // disabeldRender: () => customer.isService,
}, },
{ {
title: '库存', title: '库存',
...@@ -250,7 +250,7 @@ export const StaticColumns = customer => [ ...@@ -250,7 +250,7 @@ export const StaticColumns = customer => [
precision: 0, precision: 0,
maxLength: 5, maxLength: 5,
}, },
disabeldRender: () => customer.isService, // disabeldRender: () => customer.isService,
}, },
{ {
title: '商品自编码', title: '商品自编码',
......
...@@ -241,6 +241,7 @@ const ServiceGoods = options => { ...@@ -241,6 +241,7 @@ const ServiceGoods = options => {
title={isEdit ? '修改商品' : '新增商品'} title={isEdit ? '修改商品' : '新增商品'}
visible={options.visible} visible={options.visible}
onCancel={() => handleCancel()} onCancel={() => handleCancel()}
destroyOnClose
width={1050} width={1050}
maskClosable={false} maskClosable={false}
keyboard={false} keyboard={false}
......
...@@ -402,3 +402,20 @@ export function isCheckNumberPrice(rule, value, callback) { ...@@ -402,3 +402,20 @@ export function isCheckNumberPrice(rule, value, callback) {
callback(); callback();
} }
} }
// 验证价格保留小数点1位
export function isCheckPriceOneDecimal(rule, value, callback) {
const num = +value;
const arr = `${value}`.split('.');
if (!value) {
callback();
} else if (Number.isNaN(num)) {
callback(new Error('请输入数字'));
} else if (num < 0) {
callback(new Error('请输入大于0的数字'));
} else if (arr.length === 2 && arr[1].length > 1) {
callback(new Error('小数点保留1位'));
} else {
callback();
}
}
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