Commit 3bf3795e authored by beisir's avatar beisir

fix(校验必填内容): 添加表格详细校验说明

parent 99da4b14
...@@ -3,20 +3,12 @@ import React from 'react'; ...@@ -3,20 +3,12 @@ import React from 'react';
import { Input, Button, notification, Popover, InputNumber } from 'antd'; import { Input, Button, notification, Popover, InputNumber } from 'antd';
import { sortBy } from 'lodash'; import { sortBy } from 'lodash';
const KEYLIST = [ const CHECK_OBJECT = {
'id', supplyPrice: '供货价',
'name', marketPrice: '市场价',
'skuLink', productStock: '库存',
'imageList', thirdSkuNo: '商品自编码',
'firstSpecId', };
'secondSpecId',
'supplyPrice',
'productStockWarning',
'firstSpec',
'firstSpecValue',
'secondSpec',
'secondSpecValue',
];
export function normFile(fileList) { export function normFile(fileList) {
return fileList; return fileList;
...@@ -135,27 +127,31 @@ export function createEditData(values, initData) { ...@@ -135,27 +127,31 @@ export function createEditData(values, initData) {
} }
export function validateSpuInfo(values, initData, editData, productType) { export function validateSpuInfo(values, initData, editData, productType) {
const checkKeyList = productType === 1 ? KEYLIST : [...KEYLIST, 'weight']; const newCheckObject =
let flag = false; productType === 1 ? { ...CHECK_OBJECT, weight: '重量(kg)' } : { ...CHECK_OBJECT };
editData.forEach(item => { const checkKey = Object.keys(newCheckObject);
const keys = Object.keys(item); const checkString = [];
keys.forEach(key => { editData.forEach((item, index) => {
if (checkKeyList.includes(key)) { const rowCheckString = checkKey.reduce((checkMessage, val, ind) => {
return; const checkItem = item[val];
if (checkItem === null || checkItem === undefined || checkItem === '') {
checkMessage += `${newCheckObject[val]}; `;
} }
// console.log(key, item, item[key], (item[key] === undefined) || (item[key] === null)); return checkMessage;
// if (!`${item[key]}`) { }, '');
if (item[key] === undefined || item[key] === null || item[key] === '') { if (rowCheckString) {
flag = true; checkString.push(<div key={index.toString()}>{`第${index + 1}行: ${rowCheckString}`}</div>);
} }
}); });
if (checkString.length) {
notification.warning({
message: '请完善表格:',
description: checkString,
duration: null,
}); });
if (flag) { return true;
notification.error({
message: '请完善商品表格!',
});
} }
return flag; return false;
} }
export function dataInit(list) { export function dataInit(list) {
...@@ -208,13 +204,6 @@ export function editColumns(methods, firstData, firstSpec, secondSpec, isJDGoods ...@@ -208,13 +204,6 @@ export function editColumns(methods, firstData, firstSpec, secondSpec, isJDGoods
onChange={value => inputChange(value, 'supplyPrice', index)} onChange={value => inputChange(value, 'supplyPrice', index)}
disabled={isJDGoods} disabled={isJDGoods}
/> />
// <Input
// value={val}
// className={`supplyPrice ${index}`}
// defaultValue={val}
// onChange={evt => inputChange(evt.target.value, 'supplyPrice', index)}
// disabled={isJDGoods}
// />
), ),
}, },
{ {
...@@ -231,13 +220,6 @@ export function editColumns(methods, firstData, firstSpec, secondSpec, isJDGoods ...@@ -231,13 +220,6 @@ export function editColumns(methods, firstData, firstSpec, secondSpec, isJDGoods
min={0} min={0}
onChange={value => inputChange(value, 'marketPrice', index)} onChange={value => inputChange(value, 'marketPrice', index)}
/> />
// <Input
// value={val}
// className={`marketPrice ${index}`}
// defaultValue={val}
// onChange={evt => inputChange(evt.target.value, 'marketPrice', index)}
// />
), ),
}, },
{ {
...@@ -252,7 +234,6 @@ export function editColumns(methods, firstData, firstSpec, secondSpec, isJDGoods ...@@ -252,7 +234,6 @@ export function editColumns(methods, firstData, firstSpec, secondSpec, isJDGoods
precision={0} precision={0}
min={0} min={0}
onChange={value => inputChange(value, 'productStock', index)} onChange={value => inputChange(value, 'productStock', index)}
// disabled={isEdit && row.id}
/> />
), ),
}, },
...@@ -271,18 +252,6 @@ export function editColumns(methods, firstData, firstSpec, secondSpec, isJDGoods ...@@ -271,18 +252,6 @@ export function editColumns(methods, firstData, firstSpec, secondSpec, isJDGoods
/> />
), ),
}, },
// {
// title: 'sku名称',
// align: 'center',
// key: 'name',
// dataIndex: 'name',
// width: 100,
// render: val => (
// <Popover content={val} trigger="hover">
// <a>查看名称</a>
// </Popover>
// ),
// },
{ {
title: '京东链接', title: '京东链接',
align: 'center', align: 'center',
......
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