Commit 3bf3795e authored by beisir's avatar beisir

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

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