Commit 6cbd2b7c authored by XieZhiXiong's avatar XieZhiXiong
parents b475d4ef e6554d4b
......@@ -7,6 +7,7 @@ import { StandardTable } from 'god'
import {ColumnType} from 'antd/lib/table/interface';
import ReutrnEle from '@/components/ReturnEle';
import { PublicApi } from '@/services/api';
import { validatorByte } from '@/utils/regExp';
const { Option } = Select;
......@@ -180,9 +181,12 @@ const AddAtttribute: React.FC<{}> = () => {
required: true,
message: '输入属性组名!',
},
{
validator: (r, v, c) => validatorByte(r, v, c, 20)
}
]}
>
<Input maxLength={10} placeholder="输入属性组名" disabled={isSee} />
<Input placeholder="输入属性组名" disabled={isSee} />
</Form.Item>
</Col>
<Col span={18}>
......@@ -202,9 +206,12 @@ const AddAtttribute: React.FC<{}> = () => {
required: true,
message: '输入属性名称!',
},
{
validator: (r, v, c) => validatorByte(r, v, c, 20)
}
]}
>
<Input maxLength={10} placeholder="输入属性名称" disabled={isSee} />
<Input placeholder="输入属性名称" disabled={isSee} />
</Form.Item>
</Col>
<Col span={18}>
......
......@@ -9,6 +9,7 @@ import { PublicApi } from '@/services/api';
import TabTree, { useTreeActions, createTreeActions } from '@/components/TabTree';
import { useTreeTabs } from '@/hooks/useTreeTabs';
import { GetManageAreaAllResponse } from '@/services';
import { validatorByte } from '@/utils/regExp';
const layout = {
labelCol: {
......@@ -202,9 +203,12 @@ const AddPropertyValue: React.FC<{}> = () => {
required: true,
message: '输入属性值名称!',
},
{
validator: (r, v, c) => validatorByte(r, v, c, 12)
}
]}
>
<Input maxLength={12} placeholder="输入属性值名称" disabled={isSee} />
<Input placeholder="输入属性值名称" disabled={isSee} />
</Form.Item>
}
{
......
......@@ -9,6 +9,7 @@ import ReutrnEle from '@/components/ReturnEle';
import styles from './index.less'
import { PublicApi } from '@/services/api';
import { GetProductCustomerGetCustomerCategoryTreeResponse } from '@/services';
import { validatorByte } from '@/utils/regExp';
const { Option } = Select;
const layout = {
......@@ -158,9 +159,12 @@ const AddGoods = () => {
required: true,
message: '请填入货品名称'
},
{
validator: (r, v, c) => validatorByte(r, v, c, 40)
}
]}
>
<Input placeholder="最长20个字符" maxLength={20} disabled={isSee} />
<Input placeholder="最长40个字符20个汉字" disabled={isSee} />
</Form.Item>
<Form.Item
name="type"
......@@ -170,9 +174,12 @@ const AddGoods = () => {
required: true,
message: '请填入规格型号'
},
{
validator: (r, v, c) => validatorByte(r, v, c, 40)
}
]}
>
<Input placeholder="最长20个字符" maxLength={20} disabled={isSee} />
<Input placeholder="最长40个字符20个汉字" disabled={isSee} />
</Form.Item>
{/* <Form.Item
name={['customerCategory', 'id']}
......
......@@ -162,29 +162,18 @@ const AddProducts: React.FC<{}> = (props) => {
if(_productAttributeAndImageParams.length>0){
_productAttributeAndImageParams.map(_item => {
console.log(_item, '_item')
_item.goods = { id: _item.goodsId } // id为0表示无货品
delete _item.goodsId
// if(_item.attributeAndValueList.length>0){
// _item.attributeAndValueList.map(__item => {
// delete __item.customerAttributeName
// // **** 新字段结构变更
// __item.customerAttribute = { id: __item.customerAttributeId }
// __item.customerAttributeValue = { id: __item.id, value: __item.value }
// delete __item.id
// delete __item.value
// delete __item.customerAttributeId
// })
// }
if(_item.commodityPic.length>0){
// 编辑情况下兼顾手动添加图片列表属性
console.log('不一定')
_item.commodityPic = _item.commodityPic.map(__item => __item?.response?.data || __item?.url)
// 多种属性组合 所有属性共用的情况下 每一行都是用第一项
if(isAllAttributePic)
_item.commodityPic = _productAttributeAndImageParams[0].commodityPic
}else{
if(isAllAttributePic && _productAttributeAndImageParams[0].commodityPic.length>0){ //处理所有属性共用
console.log('所有属性共用')
_item.commodityPic = _productAttributeAndImageParams[0].commodityPic
}
else
......@@ -201,7 +190,6 @@ const AddProducts: React.FC<{}> = (props) => {
}else{ // 编辑 没有点击商品图片
_params.unitPriceAndPicList = productInfoByEdit.unitPriceAndPicList
if(clickTabIndex.indexOf("4") !== -1){ // 没有点击图片单单修改了商品价格 取原有的图片和新的价格合成
console.log('仅修改商品价格')
_params.unitPriceAndPicList = priceAttributeParams.map((item, index) => {
return {
goods: { id: item.goodsId },
......
......@@ -17,6 +17,7 @@ import { inject, observer } from 'mobx-react'
// import { IProductModule } from '@/module/productModule'
// import { IStore } from '@/store';
import { store } from '@/store'
import { validatorByte } from '@/utils/regExp';
const { Option } = Select
const layout = {
......@@ -268,9 +269,12 @@ const BasicInfoForm: React.FC<Iprops> = (props) => {
required: true,
message: '商品名称'
},
{
validator: (r, v, c) => validatorByte(r, v, c, 90)
}
]}
>
<Input placeholder="商品名称" maxLength={45} onBlur={e =>onChangeName(e.target.value)}/>
<Input placeholder="商品名称" onBlur={e =>onChangeName(e.target.value)}/>
</Form.Item>
<Form.Item
name="slogan"
......@@ -282,14 +286,17 @@ const BasicInfoForm: React.FC<Iprops> = (props) => {
</Tooltip>
</span>
}
// rules={[
rules={[
// {
// required: true,
// message: '请填入商品标语'
// },
// ]}
{
validator: (r, v, c) => validatorByte(r, v, c, 90)
}
]}
>
<Input placeholder="请输入商品标语" maxLength={45} />
<Input placeholder="请输入商品标语" />
</Form.Item>
<Form.Item
name="sellingPoint"
......@@ -312,6 +319,7 @@ const BasicInfoForm: React.FC<Iprops> = (props) => {
mode="tags"
placeholder="请输入或选择商品卖点"
maxTagCount={3}
maxTagTextLength={8}
tagRender={tagRender}
/>
</Form.Item>
......
......@@ -2,6 +2,7 @@ import React, { useState, useEffect, useRef } from 'react'
import { history } from 'umi'
import { Form, Select, Radio, Input } from 'antd'
import { store } from '@/store'
import { validatorByte } from '@/utils/regExp'
const { ProductStore } = store
const layout = {
......@@ -60,20 +61,35 @@ const OtherForm: React.FC<Iprops> = (props) => {
<Form.Item
name="marks"
label="唛头"
rules={[
{
validator: (r, v, c) => validatorByte(r, v, c, 50)
}
]}
>
<Input maxLength={25} placeholder="请输入唛头(最长25个字符)" />
<Input placeholder="最长50个字符25个汉字" />
</Form.Item>
<Form.Item
name="packing"
label="包装清单"
rules={[
{
validator: (r, v, c) => validatorByte(r, v, c, 120)
}
]}
>
<TextArea maxLength={120} rows={4} placeholder="最长120个字符" />
<TextArea rows={4} placeholder="最长120个字符60个汉字" />
</Form.Item>
<Form.Item
name="afterService"
label="售后服务"
rules={[
{
validator: (r, v, c) => validatorByte(r, v, c, 300)
}
]}
>
<TextArea maxLength={300} rows={4} placeholder="最长300个字符" />
<TextArea rows={4} placeholder="最长300个字符150个汉字" />
</Form.Item>
</Form>
</>)
......
......@@ -5,6 +5,7 @@ import styles from './index.less'
import { inject, observer } from 'mobx-react'
import { store } from '@/store'
import { validatorByte } from '@/utils/regExp'
const layout = {
labelCol: {
......@@ -166,20 +167,6 @@ const ProductAttributeForm: React.FC<Iprops> = (props) => {
_isDisabled = _isPrice && !_isUpdateAttribute
}
// 校验字节
const validatorByte = (rule, value, callback) => {
try {
let str = value
str = str.replace(/[\u4e00-\u9fa5]/g, 'OO')
if(str.length > 60)
throw new Error('最多输入60个字符,30个汉字');
else
callback()
} catch (err) {
callback(err)
}
}
return (
<>
{
......@@ -253,13 +240,12 @@ const ProductAttributeForm: React.FC<Iprops> = (props) => {
required: true,
message: '此项为必填项'
},{
validator: validatorByte
validator: (r, v, c) => validatorByte(r, v, c, 60)
}]}
>
<TextArea
disabled={_isDisabled}
onChange={(v)=>onChange(v, attrItem)}
maxLength={60}
placeholder="最多输入60个字符,30个汉字"
rows={4}
/>
......
......@@ -150,15 +150,17 @@ const ProductImageForm: React.FC<Iprops> = (props) => {
const handleChange = ({ file, fileList }, index) => {
let _priceAttributeParams = [...priceAttributeParamsByRender]
console.log(_priceAttributeParams, index, '图片更改初始数据')
// console.log(_priceAttributeParams, index, '图片更改初始数据')
setCommonImageList(fileList)
if(file?.response?.data){ // 服务端是否响应正常url字符
_priceAttributeParams[index].commodityPic = fileList
}
if(!file?.status && file?.status !== 'done'){
let ttt = _priceAttributeParams[index].commodityPic.filter(_ => _.status === 'done')
_priceAttributeParams[index].commodityPic = ttt
setCommonImageList(ttt)
}
console.log(_priceAttributeParams, '图片更改之后数据')
// console.log(_priceAttributeParams, '图片更改之后数据')
setPriceAttributeParamsByRender(_priceAttributeParams)
setProductAttributeAndImageParams(_priceAttributeParams)
}
......
......@@ -17,6 +17,7 @@ import ReutrnEle from '@/components/ReturnEle'
import { PublicApi } from '@/services/api'
import { UPLOAD_TYPE } from '@/constants'
import styles from './index.less'
import { validatorByte } from '@/utils/regExp'
const { Step } = Steps;
......@@ -120,7 +121,7 @@ const AddBrand: React.FC<{}> = () => {
setLogoLoading(false)
}
};
// @ts-ignore
const handleChange = ({ fileList }) =>setFileList(fileList)
const handleSave = () => {
......@@ -141,14 +142,12 @@ const AddBrand: React.FC<{}> = () => {
PublicApi.postProductBrandSaveOrUpdateBrand(values).then(res => {
setIsDisabledSave(true)
setIsEnableCheck(false)
//@ts-ignore
setReponseId(res.data)
})
})
}
const handleApplyCheck = () => {
//@ts-ignore
PublicApi.postProductBrandApplyCheckBrand({id: responseId}).then(res=>{
setCurrentStep(1)
setTimeout(() => {
......@@ -213,6 +212,9 @@ const AddBrand: React.FC<{}> = () => {
required: true,
message: '输入品牌名称!',
},
{
validator: (r, v, c) => validatorByte(r, v, c, 20)
}
]}
>
<Input disabled={banSomeField} placeholder="输入品牌名称" />
......
......@@ -17,6 +17,8 @@ import RuleSetting from './components/RuleSetting'
const addSchemaAction = createFormActions()
const AddRule:React.FC<{}> = (props) => {
const [isDisabled, setIsDisabled] = useState<boolean>(false)
const {
id,
preview,
......@@ -25,7 +27,7 @@ const AddRule:React.FC<{}> = (props) => {
// 整体表单提交
const formSubmit = async (values) => {
console.log(values)
setIsDisabled(true)
values.products = values.products.map(item => ({
productId: item.id,
commodityId: item.commodityId,
......@@ -36,14 +38,22 @@ const AddRule:React.FC<{}> = (props) => {
}))
values.isElectronicContract = values.isElectronicContract ? 1 : 0
const params = omit(values, ['state']) // 移除不需要的字段
addSchemaAction.getFieldState('transactionProcesssId', state => {
let dataSource = state.dataSource.filter(item => params.transactionProcesssId === item.id)
params.transactionProcess = dataSource[0].name
})
let res: any = {}
if(pageStatus === PageStatus.EDIT){
await PublicApi.postOrderTradingRulesUpdata(params)
res = await PublicApi.postOrderTradingRulesUpdata(params)
}else if(pageStatus === PageStatus.ADD){
await PublicApi.postOrderTradingRulesAdd(params)
res = await PublicApi.postOrderTradingRulesAdd(params)
}
setTimeout(() => {
if(res.code === 1000){
setIsDisabled(false)
history.goBack(-1)
}, 1000)
}
}
return (
......@@ -57,7 +67,7 @@ const AddRule:React.FC<{}> = (props) => {
onClick={() => addSchemaAction.submit()}
type="primary"
icon={<SaveOutlined />}
disabled={pageStatus === PageStatus.PREVIEW}
disabled={pageStatus === PageStatus.PREVIEW || isDisabled}
>
保存
</Button>,
......
......@@ -245,7 +245,6 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
}
addSchemaAction.setFieldValue('isElectronicContract', data.isElectronicContract ? true : false)
addSchemaAction.setFieldValue('transactionProcesssId', data.transactionProcesssId)
console.log(data)
addSchemaAction.setFieldValue('isTacitlyApprove', data.isTacitlyApprove)
setInitialValue(data)
}
......
......@@ -29,13 +29,6 @@ const TransactionRules: React.FC<{}> = () => {
})
}
// id
// name
// state
// 状态:1.有效 0.无效
// transactionProcess
// operationTime
const columns: ColumnType<any>[] = [
{
title: '交易规则ID',
......
......@@ -52,7 +52,6 @@ export const ruleDetailSchema: ISchema = padRequiredMessage({
"transactionProcesssId": {
type: 'string',
title: '流程选择',
"x-component": 'SelectProcesss',
"x-mega-props": {
style: {
......@@ -65,10 +64,9 @@ export const ruleDetailSchema: ISchema = padRequiredMessage({
"x-rules": [
{
required: true,
message: '请选择收货方式'
message: '请选择流程配置'
}
],
// required: true,
// "x-component": 'SearchSelect',
// "x-component-props": {
......
import { values } from 'mobx';
/**
* @param str:string 需要校验的字符串
* @param type:string 需要校验的类型
......@@ -42,3 +43,28 @@ export const checkRegExp = (str:string, type:string) => {
return true;
}
}
/**
* 区别校验 汉字 和 字符 长度
* @param rule
* @param value 表单输入的值
* @param callback
* @param maxByte:number 最大字符数
*/
export const validatorByte = (rule, value, callback, maxByte: number) => {
try {
if(value){
let str = value
str = str.replace(/[\u4e00-\u9fa5]/g, 'OO')
if(str.length > maxByte)
throw new Error(`最多输入${maxByte}个字符,${Math.floor(maxByte / 2)}个汉字`);
else
callback()
} else {
callback()
}
} catch (err) {
callback(err)
}
}
\ No newline at end of file
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