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

fix: 编辑商品里面添加属性值做校验

parent 0d124c21
......@@ -1193,4 +1193,6 @@ export default {
'commodity.products.zhuangtai': 'Status',
'commodity.products.xuanzeshangyougongyingshangpin': 'Select upstream supply products',
'commodity.products.xuanzexiayouxiaoshoushangpin': 'Select downstream products for sale',
'commodity.addProduct.productAttributeForm.addAttribute.error1': 'Enter a maximum of 12 characters and 6 Chinese characters',
}
......@@ -1194,4 +1194,6 @@ export default {
'commodity.products.zhuangtai': '상태',
'commodity.products.xuanzeshangyougongyingshangpin': '상류 공급 제품 선택',
'commodity.products.xuanzexiayouxiaoshoushangpin': '판매할 다운스트림 제품 선택',
'commodity.addProduct.productAttributeForm.addAttribute.error1': '최대 12자, 6자를 입력할 수 있습니다',
}
......@@ -1203,5 +1203,5 @@ export default {
'commodity.products.xuanzeshangyougongyingshangpin': '选择上游供应商品',
'commodity.products.xuanzexiayouxiaoshoushangpin': '选择下游销售商品',
'commodity.addProduct.productAttributeForm.addAttribute.error1': '最多输入12个字符,6个汉字',
}
import React, { useState, useEffect, useRef } from 'react'
import { history, useIntl } from 'umi'
import { Form, Select, Checkbox, Tabs, Input, DatePicker, Row, Col, Button, Modal, Divider, Space, Typography } from 'antd'
import { Form, Select, Checkbox, Tabs, Input, DatePicker, Row, Col, Button, Modal, Divider, Space, Typography, message } from 'antd'
import { inject, observer } from 'mobx-react'
import { store } from '@/store'
import { validatorByte } from '@/utils/regExp'
......@@ -203,6 +203,10 @@ const ProductAttributeForm: React.FC<Iprops> = (props) => {
const addItem = (e, record) => {
e.preventDefault();
let _str = newValue.replace(/[\u4e00-\u9fa5]/g, 'OO')
if(_str.length > 12) {
return message.error(intl.formatMessage({ id: 'commodity.addProduct.productAttributeForm.addAttribute.error1' }));
}
newValue && postProductCustomerSaveOrUpdateCustomerAttributeValue({
customerAttribute: { id: record.id, name: record.name, groupName: record.groupName },
isEnable: true,
......@@ -395,6 +399,15 @@ const ProductAttributeForm: React.FC<Iprops> = (props) => {
<Form.Item
name='value'
label={intl.formatMessage({ id: 'commodity.products.addProductsItem.productAttributeForm.modal.formItem.label3' })}
rules={[
{
required: true,
message: intl.formatMessage({ id: 'classAndProperty.addPropertyValue.form.value.message' }),
},
{
validator: (r, v, c) => validatorByte(r, v, c, 12)
}
]}
>
<Input placeholder={intl.formatMessage({ id: 'commodity.products.addProductsItem.productAttributeForm.modal.formItem.label3.placeholder' })} />
</Form.Item>
......
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