Commit 78d2d448 authored by 武广's avatar 武广

fix: 添加字符串去空功能

parent f7ab93b3
...@@ -164,7 +164,7 @@ class goodsManage extends Component { ...@@ -164,7 +164,7 @@ class goodsManage extends Component {
className={styles.searchForm} className={styles.searchForm}
> >
<FormItem label="SKU编码" name="skuId"> <FormItem label="SKU编码" name="skuId">
<InputNumber placeholder="请输入SKU编码" style={selectW} /> <InputNumber placeholder="请输入SKU编码" max={99999999999999999} style={selectW} />
</FormItem> </FormItem>
<FormItem label="商品名称" name="skuName"> <FormItem label="商品名称" name="skuName">
<Input placeholder="请输入商品名称" allowClear style={selectW} /> <Input placeholder="请输入商品名称" allowClear style={selectW} />
...@@ -193,6 +193,7 @@ class goodsManage extends Component { ...@@ -193,6 +193,7 @@ class goodsManage extends Component {
/> />
</FormItem> </FormItem>
{this.state.productType !== 5 && ( {this.state.productType !== 5 && (
<>
<FormItem label="审核状态" name="state"> <FormItem label="审核状态" name="state">
<Select <Select
style={selectW} style={selectW}
...@@ -207,7 +208,6 @@ class goodsManage extends Component { ...@@ -207,7 +208,6 @@ class goodsManage extends Component {
))} ))}
</Select> </Select>
</FormItem> </FormItem>
)}
<FormItem label="供货价区间"> <FormItem label="供货价区间">
<FormItem name="supplyPriceMin" className={styles.iptNumRight} noStyle> <FormItem name="supplyPriceMin" className={styles.iptNumRight} noStyle>
<InputNumber placeholder="请输入" min={0} max={999999999} style={iptNumWidth} /> <InputNumber placeholder="请输入" min={0} max={999999999} style={iptNumWidth} />
...@@ -225,16 +225,16 @@ class goodsManage extends Component { ...@@ -225,16 +225,16 @@ class goodsManage extends Component {
/> />
</FormItem> </FormItem>
</FormItem> </FormItem>
{this.state.productType !== 5 && (
<FormItem name="thirdSkuNo" label="第三方SKU编码"> <FormItem name="thirdSkuNo" label="第三方SKU编码">
<Input placeholder="请输入第三方SKU编码" allowClear style={selectW} /> <Input placeholder="请输入第三方SKU编码" allowClear style={selectW} />
</FormItem> </FormItem>
</>
)} )}
<FormItem className={styles.queryBtn}> <FormItem className={styles.queryBtn}>
<Button onClick={() => this.handleSearch()} type="primary" className={styles.button}> <Button onClick={() => this.handleSearch()} type="primary" className={styles.button}>
查询 查询
</Button> </Button>
<Button onClick={() => this.onReset()} type="primary" className={styles.button}> <Button onClick={() => this.onReset()} className={styles.button}>
重置 重置
</Button> </Button>
{this.state.productType !== 5 && ( {this.state.productType !== 5 && (
...@@ -242,6 +242,8 @@ class goodsManage extends Component { ...@@ -242,6 +242,8 @@ class goodsManage extends Component {
<Button <Button
loading={this.state.loading} loading={this.state.loading}
onClick={() => this.onExportGoodsInfo()} onClick={() => this.onExportGoodsInfo()}
type="primary"
ghost
className={styles.button} className={styles.button}
> >
导出 导出
......
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { Form, Modal, Input, Switch, Alert, message } from 'antd'; import { Form, Modal, Input, Switch, Alert, message } from 'antd';
import { apiCreateStorage, apiEditStorage, apiStorageInfo } from '../../service'; import { apiCreateStorage, apiEditStorage, apiStorageInfo } from '../../service';
import { stringOrObjectTrim } from '@/utils/utils';
const GroupInfo = options => { const GroupInfo = options => {
const [form] = Form.useForm(); const [form] = Form.useForm();
...@@ -15,15 +16,17 @@ const GroupInfo = options => { ...@@ -15,15 +16,17 @@ const GroupInfo = options => {
const handleConfirm = async () => { const handleConfirm = async () => {
const { name, necessary } = await form.validateFields(); const { name, necessary } = await form.validateFields();
const api = options.id ? apiEditStorage : apiCreateStorage; const api = options.id ? apiEditStorage : apiCreateStorage;
await api({ const res = await api({
name, name: stringOrObjectTrim(name),
necessary: necessary ? 1 : 0, necessary: necessary ? 1 : 0,
shopId: options.shopId, shopId: options.shopId,
id: options.id, id: options.id,
}); });
message.success('添加成功!'); if (res.code === '0000' && res.businessCode === '0000') {
message.success('保存成功!');
handleCancel(); handleCancel();
options.search(); options.search();
}
}; };
const getInfo = async id => { const getInfo = async id => {
......
...@@ -126,4 +126,25 @@ export const getClientInfo = () => { ...@@ -126,4 +126,25 @@ export const getClientInfo = () => {
}; };
}; };
// 字符串或json去空格
export const stringOrObjectTrim = params => {
if (isClass(params) === 'String') {
return params.trim();
}
if (isClass(params) === 'Object') {
Object.keys(params).forEach(key => {
if (isClass(params[key]) === 'String') {
params[key] = params[key].trim();
} else if (isClass(params[key]) === 'Object') {
stringOrObjectTrim(params[key]);
} else if (isClass(params[key]) === 'Array') {
params[key].forEach((item, i) => {
params[key][i] = stringOrObjectTrim(item);
});
}
});
}
return params;
};
export const getObjectType = v => Object.prototype.toString.call(v).replace(/\[object |]/g, ''); export const getObjectType = v => Object.prototype.toString.call(v).replace(/\[object |]/g, '');
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