Commit dd1bd48b authored by beisir's avatar beisir

fix: 提交

parent 57d51709
...@@ -4,8 +4,11 @@ const isPre = process.env.PRE_ENV === 'pre'; ...@@ -4,8 +4,11 @@ const isPre = process.env.PRE_ENV === 'pre';
const envAPi = { const envAPi = {
api: 'https://backstms-xyqb.liangkebang.net', api: 'https://backstms-xyqb.liangkebang.net',
kdspOpApi: 'https://kdsp-operation-xyqb.liangkebang.net', kdspOpApi: 'https://kdsp-operation-xyqb.liangkebang.net',
kdspApi: 'https://sc-op-api-xyqb.liangkebang.net',
goodsApi: 'https://sc-op-api-xyqb.liangkebang.net', kdspApi: 'https://sc-merchant-api-xyqb.liangkebang.net',
// kdspApi: 'https://sc-op-api-xyqb.liangkebang.net',
goodsApi: 'https://sc-merchant-api-xyqb.liangkebang.net',
// goodsApi: 'https://sc-op-api-xyqb.liangkebang.net',
querysApi: 'https://sc-settlement-api-xyqb.liangkebang.net', querysApi: 'https://sc-settlement-api-xyqb.liangkebang.net',
// goodsApi: '//192.168.188.111:7000', // goodsApi: '//192.168.188.111:7000',
prologueDomain: 'https://mall-xyqb.liangkebang.net', prologueDomain: 'https://mall-xyqb.liangkebang.net',
......
...@@ -21,7 +21,7 @@ import { ...@@ -21,7 +21,7 @@ import {
} from './service'; } from './service';
import LogModal from './LogModal'; import LogModal from './LogModal';
import CreateModal from './createModal'; import CreateModal from './createModal';
import { column, JDSHOPID } from './staticdata'; import { column, JDSHOPID, ProcessEditData } from './staticdata';
import SearchForm from './SearchForm'; import SearchForm from './SearchForm';
import TempleatModal from './TempleatModal'; import TempleatModal from './TempleatModal';
import ServiceGoods from '../ServiceGoods'; import ServiceGoods from '../ServiceGoods';
...@@ -49,7 +49,9 @@ class goodsManage extends Component { ...@@ -49,7 +49,9 @@ class goodsManage extends Component {
isAll: 0, isAll: 0,
templateList: [], templateList: [],
isType: '', isType: '',
serviceVisble: true,
serviceVisble: false,
serviceData: {},
}; };
currentLog = null; currentLog = null;
...@@ -117,7 +119,7 @@ class goodsManage extends Component { ...@@ -117,7 +119,7 @@ class goodsManage extends Component {
this.setState({ this.setState({
createloading: true, createloading: true,
}); });
const { data, msg } = await spuDetail({ id: 894048258062 }); // spuId const { data, msg } = await spuDetail({ id: spuId }); // spuId
if (data) { if (data) {
data.state = state; data.state = state;
data.pageProductType = productType; data.pageProductType = productType;
...@@ -292,9 +294,38 @@ class goodsManage extends Component { ...@@ -292,9 +294,38 @@ class goodsManage extends Component {
}); });
}; };
serviceVisbleChange = visble => { // serviceVisbleChange = row => {
// this.setState({
// serviceVisble: true,
// });
// };
serviceVisbleChange = async row => {
const { state, spuId, productType } = row;
this.setState({ createloading: true });
const { data, msg } = await spuDetail({ id: spuId }); // spuId
if (data) {
const SourceData = ProcessEditData(data, row);
console.log('index.js=============>', SourceData);
this.setState({
serviceData: SourceData,
serviceVisble: true,
createloading: false,
});
} else {
this.setState({
createloading: false,
});
notification.warning({
message: msg,
});
}
};
serviceVisbleClose = flag => {
this.setState({ this.setState({
serviceVisble: visble, serviceVisble: flag,
serviceData: {},
}); });
}; };
...@@ -311,9 +342,7 @@ class goodsManage extends Component { ...@@ -311,9 +342,7 @@ class goodsManage extends Component {
<PageHeaderWrapper> <PageHeaderWrapper>
<Spin spinning={this.state.createloading}> <Spin spinning={this.state.createloading}>
<Card> <Card>
<Button type="primary" onClick={() => this.serviceVisbleChange(true)}> <Button onClick={() => this.serviceVisbleClose(true)}>新建</Button>
new 新增商品
</Button>
<SearchForm <SearchForm
handleSearch={this.handleSearch} handleSearch={this.handleSearch}
onReset={this.onReset} onReset={this.onReset}
...@@ -412,8 +441,15 @@ class goodsManage extends Component { ...@@ -412,8 +441,15 @@ class goodsManage extends Component {
{/* '894048258062' */} {/* '894048258062' */}
<ServiceGoods <ServiceGoods
visible={this.state.serviceVisble} visible={this.state.serviceVisble}
onChange={this.serviceVisbleChange}
id={894048258062} id={894048258062}
onChange={this.serviceVisbleClose}
SourceData={this.state.serviceData}
categoryList={
this.state.serviceData.productType === 2
? this.state.virtualTreeData
: this.state.treeData
}
specListData={this.state.specListData}
/> />
</Spin> </Spin>
</PageHeaderWrapper> </PageHeaderWrapper>
......
...@@ -152,15 +152,26 @@ export function column() { ...@@ -152,15 +152,26 @@ export function column() {
render: (_, row) => ( render: (_, row) => (
<div className={styles.actionBtn}> <div className={styles.actionBtn}>
{(row.state === 4 || (row.state >= 5 && row.updateState !== 1)) && ( {(row.state === 4 || (row.state >= 5 && row.updateState !== 1)) && (
<Button <>
key="edit" <Button
type="primary" key="edit"
size="small" type="primary"
className={styles.button} size="small"
onClick={() => this.onUpdateInfo(row)} className={styles.button}
> onClick={() => this.onUpdateInfo(row)}
修改 >
</Button> 修改
</Button>
<Button
key="222"
type="primary"
size="small"
className={styles.button}
onClick={() => this.serviceVisbleChange(row)}
>
修改
</Button>
</>
)} )}
<Button <Button
key="viewP" key="viewP"
...@@ -200,3 +211,122 @@ export const productTypeList = [ ...@@ -200,3 +211,122 @@ export const productTypeList = [
]; ];
export const JDSHOPID = [3, 5, 6]; export const JDSHOPID = [3, 5, 6];
// 编辑回显示时只获取用到的数据
const filterItem = skuItem => {
const { serviceItem, ...argsItem } = skuItem;
argsItem.disabled = true;
return argsItem;
};
const filterSpecData = skuList =>
skuList.reduce(
(orgin, skuItem) => {
const item = filterItem(skuItem);
const { firstSpecValue, secondSpecValue } = item;
if (firstSpecValue && !orgin.firstDuplicate.includes(firstSpecValue)) {
orgin.firstSpecValue.push(item);
orgin.firstDuplicate.push(firstSpecValue);
}
if (secondSpecValue && !orgin.secondDuplicate.includes(secondSpecValue)) {
orgin.secondSpecValue.push(item);
orgin.secondDuplicate.push(secondSpecValue);
}
return orgin;
},
{
firstSpecValue: [],
secondSpecValue: [],
dataSource: [],
firstDuplicate: [],
secondDuplicate: [],
},
);
const filterCarouseList = (carouseList = []) =>
carouseList.reduce((origin, itemImg) => {
if (itemImg.skuSpecImageList.length) {
origin[itemImg.specValue || 'NOT'] = itemImg.skuSpecImageList || [];
}
return origin;
}, {});
export const ProcessEditData = (data, row) => {
const [oneItem = {}] = data.skuList;
const serviceItem = oneItem.serviceItem || {};
const orginSpecItem = filterSpecData(data.skuList);
const imageList = filterCarouseList(data.carouseList);
const SourceData = {
productType: data.productType,
pageProductType: row.productType,
state: row.state,
infoMation: {
brandId: data.brandId,
supplierId: data.supplierId,
character: data.character,
name: data.name,
categoryId: [data.firstCategoryId, data.secondCategoryId, data.thirdCategoryId],
description: serviceItem.description || null,
},
infoSpecData: {
firstSpec: oneItem.firstSpec,
firstSpecId: oneItem.firstSpecId,
firstSpecValue: orginSpecItem.firstSpecValue,
secondSpec: oneItem.secondSpec,
secondSpecId: oneItem.secondSpecId,
secondSpecValue: orginSpecItem.secondSpecValue,
},
infoImageData: {
imageList,
commonImageList: data.commonImageList,
detailImageList: data.detailImageList,
},
skuList: data.skuList,
};
return SourceData;
// data.state = state;
// data.pageProductType = productType;
// data.categoryId = data.thirdCategoryId;
// data.firstSpecId = data.skuList[0].firstSpecId;
// data.secondSpecId = data.skuList[0].secondSpecId;
// data.firstSpecName = data.skuList[0].firstSpec;
// data.secondSpecName = data.skuList[0].secondSpec;
// data.firstSpecList = [];
// data.secondSpecList = [];
// data.colorKeys = [];
// data.carouseList.forEach(i => {
// if (i.specValue) {
// data.colorKeys.push(i.specValue);
// }
// });
// data.skuList.forEach(i => {
// if (data.firstSpecList.indexOf(i.firstSpecValue) === -1) {
// data.firstSpecList.push(`${i.firstSpecValue}`);
// }
// if (i.secondSpecValue && data.secondSpecList.indexOf(i.secondSpecValue) === -1) {
// data.secondSpecList.push(i.secondSpecValue);
// }
// });
// data.specs.forEach(item => {
// const arr = [];
// if (item.specValues.length) {
// item.specValues.forEach(childItem => {
// arr.push(childItem.value);
// });
// }
// data[item.specId] = arr;
// });
// data.imageList = [];
// data.carouseList.forEach(i => {
// data.imageList[`${i.specValue}`] = i.skuSpecImageList || [];
// });
// data.editData = sortBy(data.skuList, item => item.firstSpecValue);
// this.setState({
// initData: data,
// createVisible: true,
// createloading: false,
// });
};
import React from 'react'; import React from 'react';
import { Select, Form, InputNumber, Input, Button } from 'antd';
import commonStyle from '../common.less'; import commonStyle from '../common.less';
export const WrapperContainer = props => ( export const WrapperContainer = props => (
...@@ -20,14 +21,70 @@ export const Title = props => ( ...@@ -20,14 +21,70 @@ export const Title = props => (
</div> </div>
); );
// export const IdSelect = (props: IdSelectProps) => { export const SelectTemplate = props => {
// const {value, onChange, defaultOptionName, options, ...resetProps} = props; const {
value,
onChange,
formName,
noSty,
defaultOptionName,
dataList,
fieldNames,
...resetProps
} = props;
if (!dataList.length) {
return null;
}
const selectTemp = (
<Select allowClear {...resetProps}>
{defaultOptionName ? <Select.Option value={0}>{defaultOptionName}</Select.Option> : null}
{dataList.map((item, index) => {
const val = fieldNames ? item[fieldNames.value] : item;
const lab = fieldNames ? item[fieldNames.label] : item;
return (
<Select.Option key={val} value={val}>
{lab}
</Select.Option>
);
})}
</Select>
);
// return <Select {...resetProps} value={options?.length ? toNumber(value): 0} onChange={value => onChange?.(toNumber(value) || undefined)}> return formName ? (
// { <Form.Item noStyle={noSty} name={formName} key={formName}>
// defaultOptionName ? <Select.Option value={0}>{defaultOptionName}</Select.Option> : null {selectTemp}
// } </Form.Item>
// {options?.map(option => <Select.Option key={option.id} value={option.id}>{option.name}</Select.Option>)} ) : (
// </Select> selectTemp
// } );
// const toNumber = (value: unknown) => isNaN(Number(value)) ? 0: Number(value); };
export const CreateFormInput = props => {
const { title, record, dataIndex, rowIndex, onClick, type, ...options } = props;
if (type === 'input') {
return <Input placeholder={title} {...options} />;
}
if (type === 'option') {
return (
<>
{record.skuLink && (
<Button type="primary" size="small" onClick={() => onClick('cloneImg', record)}>
拉图片
</Button>
)}
{props.isJDGoods && (
<Button
type="primary"
size="small"
onClick={() => onClick('updateName', { ...record, dataIndex, rowIndex })}
disabled={props.disabled}
>
修改sku名称
</Button>
)}
</>
);
}
return <InputNumber placeholder={title} {...options} />;
};
...@@ -8,6 +8,7 @@ import React, { ...@@ -8,6 +8,7 @@ import React, {
useImperativeHandle, useImperativeHandle,
} from 'react'; } from 'react';
import { ServiceContext } from '../context'; import { ServiceContext } from '../context';
import { CreateFormInput } from './CommonTemplate';
const EditableContext = createContext(null); const EditableContext = createContext(null);
...@@ -20,10 +21,12 @@ const EditableCell = props => { ...@@ -20,10 +21,12 @@ const EditableCell = props => {
children, children,
dataIndex, dataIndex,
record, record,
roleProps,
handleSave, handleSave,
...restProps ...restProps
} = props; } = props;
// console.log('==============>', props);
const form = useContext(EditableContext); const form = useContext(EditableContext);
const save = async () => { const save = async () => {
try { try {
...@@ -33,6 +36,7 @@ const EditableCell = props => { ...@@ -33,6 +36,7 @@ const EditableCell = props => {
console.log('Save failed:', errInfo); console.log('Save failed:', errInfo);
} }
}; };
const onClickEvent = () => {};
const childNode = ( const childNode = (
<Form.Item <Form.Item
...@@ -40,7 +44,21 @@ const EditableCell = props => { ...@@ -40,7 +44,21 @@ const EditableCell = props => {
name={['tableList', rowIndex, dataIndex]} name={['tableList', rowIndex, dataIndex]}
rules={[{ required: true, message: `${title} is required.` }]} rules={[{ required: true, message: `${title} is required.` }]}
> >
{editable ? <InputNumber onBlur={save} /> : children[1]} {editable ? (
<CreateFormInput
{...roleProps}
title={title}
rowIndex={rowIndex}
dataIndex={dataIndex}
record={record}
type={props.type}
onBlur={save}
onClick={onClickEvent}
disabled={props.disabled}
/>
) : (
<Button type="text">{children[1]}</Button>
)}
</Form.Item> </Form.Item>
); );
return <td {...restProps}>{childNode}</td>; return <td {...restProps}>{childNode}</td>;
...@@ -103,6 +121,9 @@ const EditFormTable = forwardRef((props, ref) => { ...@@ -103,6 +121,9 @@ const EditFormTable = forwardRef((props, ref) => {
rowIndex, rowIndex,
editable: col.editable, editable: col.editable,
dataIndex: col.dataIndex, dataIndex: col.dataIndex,
disabled: col.disabled,
type: col.inputType,
roleProps: col.roleProps || {},
title: col.title, title: col.title,
handleSave, handleSave,
}; };
...@@ -124,7 +145,7 @@ const EditFormTable = forwardRef((props, ref) => { ...@@ -124,7 +145,7 @@ const EditFormTable = forwardRef((props, ref) => {
}} }}
bordered bordered
dataSource={dataSource} dataSource={dataSource}
rowKey={(row, rowInd) => rowInd} rowKey={(row, rowInd) => (customer.isEdit ? row.id : rowInd)}
columns={columns} columns={columns}
/> />
</EditableContext.Provider> </EditableContext.Provider>
......
import React, { useContext, useEffect, forwardRef, useImperativeHandle } from 'react'; import React, { useState, useContext, useEffect, forwardRef, useImperativeHandle } from 'react';
import { Cascader, Form, Input, Select } from 'antd'; import { Cascader, Form, Input, Select, Popover, Button, Checkbox } from 'antd';
import { formItemLayout } from '../config'; import { formItemLayout } from '../config';
import { ServiceContext } from '../context'; import { ServiceContext } from '../context';
...@@ -16,8 +16,9 @@ const filterCategoryOptions = (inputValue, path) => ...@@ -16,8 +16,9 @@ const filterCategoryOptions = (inputValue, path) =>
path.some(option => option.name.toLowerCase().indexOf(inputValue.toLowerCase()) > -1); path.some(option => option.name.toLowerCase().indexOf(inputValue.toLowerCase()) > -1);
const FormInformationBasic = forwardRef((props, ref) => { const FormInformationBasic = forwardRef((props, ref) => {
const { editData, categoryList, brandList } = props; const { editData, categoryList, brandList, afterAddressList, specListData } = props;
const [form] = Form.useForm(); const [form] = Form.useForm();
const [noreBrandList, setNoreBrandList] = useState([]);
const onCheck = async () => { const onCheck = async () => {
try { try {
...@@ -33,21 +34,28 @@ const FormInformationBasic = forwardRef((props, ref) => { ...@@ -33,21 +34,28 @@ const FormInformationBasic = forwardRef((props, ref) => {
reset: form.resetFields, reset: form.resetFields,
})); }));
const customer = useContext(ServiceContext); const customer = useContext(ServiceContext);
useEffect(() => {
const noreList = (brandList || []).filter(item => item.name === '虚拟商品');
setNoreBrandList(noreList);
}, [brandList]);
useEffect(() => { useEffect(() => {
if (customer.isEdit) { if (customer.isEdit) {
if (!Object.keys(editData).length) return; if (!editData) return;
const initValues = { // const initValues = {
brandId: editData.brandId, // brandId: editData.brandId,
supplierId: editData.supplierId, // supplierId: editData.supplierId,
name: editData.name, // character: editData.character,
categoryId: [editData.firstCategoryId, editData.secondCategoryId, editData.thirdCategoryId], // name: editData.name,
description: null, // categoryId: [editData.firstCategoryId, editData.secondCategoryId, editData.thirdCategoryId],
}; // description: null,
if (customer.isCard) { // };
const { serviceItem } = editData.skuList[0]; // if (customer.isCard) {
initValues.description = (serviceItem || {}).description || null; // const { serviceItem } = editData.skuList[0];
} // initValues.description = (serviceItem || {}).description || null;
form.setFieldsValue(initValues); // }
form.setFieldsValue(editData);
} }
}, [customer.isEdit, editData]); }, [customer.isEdit, editData]);
...@@ -70,37 +78,99 @@ const FormInformationBasic = forwardRef((props, ref) => { ...@@ -70,37 +78,99 @@ const FormInformationBasic = forwardRef((props, ref) => {
}} }}
scrollToFirstError scrollToFirstError
> >
<Form.Item
name="brandId"
label="供应商名称"
rules={[{ required: true, message: '请选择供应商名称!' }]}
>
<Select showSearch placeholder="请选择供应商名称" filterOption={fileterBrandOptions}>
{CreateSelectOption(brandList)}
</Select>
</Form.Item>
<Form.Item
name="name"
label="商品名称"
rules={[{ required: true, message: '请输入商品名称!', whitespace: true }]}
>
<Input placeholder="请输入商品名称" />
</Form.Item>
<Form.Item <Form.Item
name="categoryId" name="categoryId"
label="商品类目" label="商品类目"
rules={[{ type: 'array', required: true, message: '请输入商品类目!' }]} rules={[{ type: 'array', required: true, message: '请输入商品类目!' }]}
> >
<Cascader <Cascader
disabled={customer.isService}
placeholder="请选择商品类目!" placeholder="请选择商品类目!"
showSearch={{ filter: filterCategoryOptions }} showSearch={{ filter: filterCategoryOptions }}
fieldNames={{ label: 'name', value: 'id', children: 'children' }} fieldNames={{ label: 'name', value: 'id', children: 'children' }}
options={categoryList} options={categoryList}
/> />
</Form.Item> </Form.Item>
<Form.Item
name="brandId"
label="商品品牌"
rules={[{ required: true, message: '请选择商品品牌!' }]}
extra="若需新增品牌请联系业务员"
>
<Select
disabled={customer.isService}
showSearch
placeholder="请选择商品品牌"
filterOption={fileterBrandOptions}
>
{CreateSelectOption(customer.productType === 2 ? noreBrandList : brandList)}
</Select>
</Form.Item>
<Popover content={form.getFieldValue('name')} trigger="hover">
<Form.Item
key="name"
name="name"
label="商品名称"
rules={[
{ required: true, min: 2, message: '请输入最少两个字符的商品名称!', whitespace: true },
]}
>
<Input disabled={customer.isService} placeholder="请输入商品名称" />
</Form.Item>
</Popover>
{customer.isJDGoods && (
<Button key="jdMsg" danger type="text">
*本列表的商品名称仅供搜索使用,不在前端作展示。若要修改APP端展示的商品名称,请在商品信息中修改。
</Button>
)}
<Form.Item
name="character"
label="商品卖点"
maxLength={50}
placeholder="卖点最优可填写3个词,12个字。前后用空格加竖杠分隔,例: 莹莹剔透 | 粒粒优选 | 易煮易熟"
rules={[{ required: true, message: '请输入商品卖点!', whitespace: true }]}
>
<Input placeholder="请输入商品名称" />
</Form.Item>
<Form.Item
name="afterAddressId"
label="售后地址"
rules={[{ required: true, message: '请选择售后地址!' }]}
>
<Select showSearch placeholder="请选择商品品牌" filterOption={fileterBrandOptions}>
{afterAddressList.map(item => (
<Select.Option key={item.id} value={item.id}>
{item.addressName}
</Select.Option>
))}
</Select>
</Form.Item>
{specListData.map((item, index) => (
<Form.Item
key={item.specId}
label={item.specName}
name={item.specId}
labelCol={{ span: 2 }}
>
<Checkbox.Group options={item.specValues} />
</Form.Item>
))}
{/* <Form.Item
name="brandId"
label="供应商名称"
rules={[{ required: true, message: '请选择供应商名称!' }]}
>
<Select showSearch placeholder="请选择供应商名称" filterOption={fileterBrandOptions}>
{CreateSelectOption(brandList)}
</Select>
</Form.Item> */}
{customer.isCard ? ( {customer.isCard ? (
<Form.Item <Form.Item
key="description"
name="description" name="description"
label="描述" label="描述"
rules={[{ required: true, message: '请输入描述!' }]} rules={[{ required: true, message: '请输入描述!' }]}
......
...@@ -12,6 +12,16 @@ import { formItemLayout, StaticColumns } from '../config'; ...@@ -12,6 +12,16 @@ import { formItemLayout, StaticColumns } from '../config';
import EditFormTable from './EditFormTable'; import EditFormTable from './EditFormTable';
import { createProductData, cleanArray } from '../utils'; import { createProductData, cleanArray } from '../utils';
import { ServiceContext } from '../context'; import { ServiceContext } from '../context';
import { SelectTemplate } from './CommonTemplate';
const initSpecReced = () => ({
firstSpec: '',
firstSpecId: null,
firstSpecValue: [],
secondSpec: '',
secondSpecId: null,
secondSpecValue: [],
});
const validatorSpecValue = (value, list, index, specName) => { const validatorSpecValue = (value, list, index, specName) => {
const checkList = list.filter((item, ind) => { const checkList = list.filter((item, ind) => {
...@@ -26,7 +36,7 @@ const validatorSpecValue = (value, list, index, specName) => { ...@@ -26,7 +36,7 @@ const validatorSpecValue = (value, list, index, specName) => {
const SpecificationTemplate = (props, _) => { const SpecificationTemplate = (props, _) => {
const { const {
form, form,
name, formName,
label, label,
specName, specName,
specList, specList,
...@@ -50,8 +60,8 @@ const SpecificationTemplate = (props, _) => { ...@@ -50,8 +60,8 @@ const SpecificationTemplate = (props, _) => {
}; };
const bundlePlusAddSpecEvent = addCallback => { const bundlePlusAddSpecEvent = addCallback => {
console.log(name); console.log(formName);
const specId = form.getFieldValue(name); const specId = form.getFieldValue(formName);
if (!specId) { if (!specId) {
Modal.warning({ Modal.warning({
maskClosable: true, maskClosable: true,
...@@ -70,7 +80,7 @@ const SpecificationTemplate = (props, _) => { ...@@ -70,7 +80,7 @@ const SpecificationTemplate = (props, _) => {
return ( return (
<> <>
<Form.Item name={name} label={label}> <Form.Item name={formName} label={label}>
<Select <Select
disabled={customer.isEdit} disabled={customer.isEdit}
allowClear allowClear
...@@ -85,7 +95,9 @@ const SpecificationTemplate = (props, _) => { ...@@ -85,7 +95,9 @@ const SpecificationTemplate = (props, _) => {
onChange={handleChange} onChange={handleChange}
/> />
</Form.Item> </Form.Item>
<Form.Item name={selectName} hidden></Form.Item> <Form.Item name={selectName} hidden>
<Input hidden />
</Form.Item>
<Form.List name={specName}> <Form.List name={specName}>
{(fields, { add, remove }) => ( {(fields, { add, remove }) => (
<> <>
...@@ -170,26 +182,46 @@ const filterSpecData = skuList => ...@@ -170,26 +182,46 @@ const filterSpecData = skuList =>
return orgin; return orgin;
}, originItems); }, originItems);
const CreateBatchFormItems = ({ batchChange, editRef, defaultColumns }) => { const CreateBatchFormItems = ({ specInitValue, batchChange, editRef, defaultColumns }) => {
const customer = useContext(ServiceContext); const customer = useContext(ServiceContext);
const formItems = defaultColumns const formItems = defaultColumns
.filter(item => !item.role || item?.role.includes(customer.productType)) .filter(item => item.batchRole && item?.batchRole.includes(customer.productType))
.map((item, index) => ( .map((item, index) => (
<Form.Item <Form.Item
noStyle noStyle
key={item.dataIndex} key={`${item.dataIndex}`}
name={['batchItem', item.dataIndex]} name={['batchItem', item.dataIndex]}
initialValue={null} initialValue={null}
> >
<InputNumber placeholder={item.title} /> <InputNumber {...(item.batchProps || {})} placeholder={item.title} />
</Form.Item> </Form.Item>
)); ));
return ( return (
<> <>
{formItems.length ? ( {formItems.length ? (
<Space style={{ marginBottom: 20 }}> <Space style={{ marginBottom: 20 }}>
{
<SelectTemplate
width={150}
noSty
formName="bacthFirst"
placeholder={specInitValue.firstSpec}
dataList={specInitValue.firstSpecValue}
fieldNames={{ label: 'firstSpecValue', value: 'firstSpecValue' }}
/>
}
{
<SelectTemplate
noSty
width={150}
formName="bacthSecon"
placeholder={specInitValue.secondSpec}
dataList={specInitValue.secondSpecValue}
fieldNames={{ label: 'secondSpecValue', value: 'secondSpecValue' }}
/>
}
{formItems.concat( {formItems.concat(
<Button key="batch" type="primary" onClick={batchChange}> <Button key="batch" type="primary" disabled={customer.isService} onClick={batchChange}>
批量设置 批量设置
</Button>, </Button>,
)} )}
...@@ -200,18 +232,11 @@ const CreateBatchFormItems = ({ batchChange, editRef, defaultColumns }) => { ...@@ -200,18 +232,11 @@ const CreateBatchFormItems = ({ batchChange, editRef, defaultColumns }) => {
}; };
const FormPriceOrStock = forwardRef((props, ref) => { const FormPriceOrStock = forwardRef((props, ref) => {
const { specList, editData, onSpecChange } = props; const { specList, editData, skuList, onSpecChange } = props;
const editRef = useRef(null); const editRef = useRef(null);
const customer = useContext(ServiceContext); const customer = useContext(ServiceContext);
const [form] = Form.useForm(); const [form] = Form.useForm();
const [specInitValue, setSpecInitValue] = useState({ const [specInitValue, setSpecInitValue] = useState(initSpecReced());
firstSpec: '',
firstSpecId: null,
firstSpecValue: [],
secondSpec: '',
secondSpecId: null,
secondSpecValue: [],
});
const [defaultColumns, setDefaultColumns] = useState([]); const [defaultColumns, setDefaultColumns] = useState([]);
const [tableData, setTableData] = useState([]); const [tableData, setTableData] = useState([]);
...@@ -242,7 +267,7 @@ const FormPriceOrStock = forwardRef((props, ref) => { ...@@ -242,7 +267,7 @@ const FormPriceOrStock = forwardRef((props, ref) => {
}); });
} }
const dynamicColumns = [...columsData, ...StaticColumns]; const dynamicColumns = [...columsData, ...StaticColumns(customer)];
setDefaultColumns(dynamicColumns); setDefaultColumns(dynamicColumns);
}; };
...@@ -289,43 +314,52 @@ const FormPriceOrStock = forwardRef((props, ref) => { ...@@ -289,43 +314,52 @@ const FormPriceOrStock = forwardRef((props, ref) => {
useImperativeHandle(ref, () => ({ useImperativeHandle(ref, () => ({
onCheck, onCheck,
reset: form.resetFields, reset: () => {
console.log('============>cleaarn', initSpecReced());
form.resetFields();
setDefaultColumns([]);
setTableData([]);
setMergeTable(false);
setSpecInitValue(initSpecReced());
},
})); }));
useEffect(() => { useEffect(() => {
if (customer.isEdit) { if (customer.isEdit) {
if (!Object.keys(editData).length) return; if (!editData) return;
const { skuList } = editData; // const { skuList } = editData;
const [oneItem] = skuList; // const [oneItem] = skuList;
// 根据接口过滤数据 // // 根据接口过滤数据
const { firstSpecValue, secondSpecValue, dataSource } = filterSpecData(skuList); // const { firstSpecValue, secondSpecValue, dataSource } = filterSpecData(skuList);
const specData = { // const specData = {
firstSpec: oneItem.firstSpec, // firstSpec: oneItem.firstSpec,
firstSpecId: oneItem.firstSpecId, // firstSpecId: oneItem.firstSpecId,
firstSpecValue, // firstSpecValue,
secondSpec: oneItem.secondSpec, // secondSpec: oneItem.secondSpec,
secondSpecId: oneItem.secondSpecId, // secondSpecId: oneItem.secondSpecId,
secondSpecValue, // secondSpecValue,
}; // };
form.setFieldsValue(specData); // 设置规格数据 console.log('=============>editDataeditDataeditData', editData);
setSpecInitValue(specData); // 缓存规格数据
form.setFieldsValue(editData); // 设置规格数据
setSpecInitValue(editData); // 缓存规格数据
firstOnChangeEvent(); // 触发成底部动态表格数据 firstOnChangeEvent(); // 触发成底部动态表格数据
onFinish(); // 触发生成表格 if (editData.firstSpecId) {
onFinish(); // 触发生成表格
} else {
CreateColumnsEvent(editData);
setMergeTable(Boolean(editData.secondSpecValue.length));
setTableData(skuList);
}
} }
}, [customer.isEdit, editData]); }, [customer.isEdit, editData]);
return ( return (
<Form <Form form={form} autoComplete="off" initialValues={initSpecReced()}>
form={form}
name="dynamic_form_nest_item"
// onFinish={onFinish}
autoComplete="off"
initialValues={specInitValue}
>
<SpecificationTemplate <SpecificationTemplate
form={form} form={form}
label="一级规格" label="一级规格"
name="firstSpecId" formName="firstSpecId"
onChange={firstOnChangeEvent} onChange={firstOnChangeEvent}
selectName="firstSpec" selectName="firstSpec"
specName="firstSpecValue" specName="firstSpecValue"
...@@ -335,20 +369,21 @@ const FormPriceOrStock = forwardRef((props, ref) => { ...@@ -335,20 +369,21 @@ const FormPriceOrStock = forwardRef((props, ref) => {
<SpecificationTemplate <SpecificationTemplate
form={form} form={form}
label="二级规格" label="二级规格"
name="secondSpecId" formName="secondSpecId"
selectName="secondSpec" selectName="secondSpec"
specName="secondSpecValue" specName="secondSpecValue"
specList={specList} specList={specList}
specDataList={specInitValue.secondSpecValue} specDataList={specInitValue.secondSpecValue}
/> />
<div style={{ display: 'flex', justifyContent: 'center', marginBottom: 20 }}> <div style={{ display: 'flex', justifyContent: 'center', marginBottom: 20 }}>
<Button type="primary" onClick={onFinish}> <Button type="primary" disabled={customer.isService} onClick={onFinish}>
生成商品信息 生成商品信息
</Button> </Button>
</div> </div>
<CreateBatchFormItems <CreateBatchFormItems
batchChange={batchChange} batchChange={batchChange}
editRef={editRef} editRef={editRef}
specInitValue={specInitValue}
defaultColumns={defaultColumns} defaultColumns={defaultColumns}
/> />
<EditFormTable <EditFormTable
......
...@@ -13,34 +13,46 @@ const FormRuleVPictures = forwardRef((props, ref) => { ...@@ -13,34 +13,46 @@ const FormRuleVPictures = forwardRef((props, ref) => {
const customer = useContext(ServiceContext); const customer = useContext(ServiceContext);
useEffect(() => { useEffect(() => {
if (customer.isEdit) { if (customer.isEdit) {
console.log('==============>图片', editData); // if (!Object.keys(editData).length) return;
if (!Object.keys(editData).length) return; // setCommonImageList(editData.commonImageList); // 编辑状态下设置公共图
setCommonImageList(editData.commonImageList); // 编辑状态下设置公共图 // setDetailImageList(editData.detailImageList); // 编辑状态下设置详情图
setDetailImageList(editData.detailImageList); // 编辑状态下设置详情图 // const commImg = editData.skuList.reduce((orgin, item) => {
const commImg = editData.skuList.reduce((orgin, item) => { // const keyString = `${item.firstSpecValue}`; // _${item.firstSpecId}
const keyString = `${item.firstSpecValue}`; // _${item.firstSpecId} // if (!Object.keys(orgin).includes(keyString)) {
if (!Object.keys(orgin).includes(keyString)) { // orgin[keyString] = item.imageList;
orgin[keyString] = item.imageList; // }
} // return orgin;
return orgin; // }, {});
}, {});
// setImageList(commImg);
// form.setFieldsValue({
// imageList: commImg,
// commonImageList: editData.commonImageList,
// detailImageList: editData.detailImageList,
// });
setImageList(commImg); if (editData) {
form.setFieldsValue({ setImageList(editData.imageList);
imageList: commImg, setCommonImageList(editData.commonImageList); // 编辑状态下设置公共图
commonImageList: editData.commonImageList, setDetailImageList(editData.detailImageList); // 编辑状态下设置详情图
detailImageList: editData.detailImageList, form.setFieldsValue({
}); imageList: editData.imageList,
commonImageList: editData.commonImageList,
detailImageList: editData.detailImageList,
});
}
} }
}, [customer.isEdit, editData]); }, [customer.isEdit, editData]);
useEffect(() => { useEffect(() => {
const newImageList = specKeyItem.reduce((origin, item) => { if (specKeyItem.length) {
const showItem = imageList[item] || []; const newImageList = specKeyItem.reduce((origin, item) => {
origin[item] = showItem; const showItem = imageList[item] || [];
return origin; origin[item] = showItem;
}, {}); return origin;
setImageList(newImageList); }, {});
setImageList(newImageList);
}
}, [specKeyItem]); }, [specKeyItem]);
const onCheck = async () => { const onCheck = async () => {
...@@ -55,7 +67,12 @@ const FormRuleVPictures = forwardRef((props, ref) => { ...@@ -55,7 +67,12 @@ const FormRuleVPictures = forwardRef((props, ref) => {
useImperativeHandle(ref, () => ({ useImperativeHandle(ref, () => ({
onCheck, onCheck,
reset: form.resetFields, reset: () => {
form.resetFields();
setImageList({});
setCommonImageList([]);
setDetailImageList([]);
},
})); }));
const onFinish = values => { const onFinish = values => {
...@@ -75,9 +92,9 @@ const FormRuleVPictures = forwardRef((props, ref) => { ...@@ -75,9 +92,9 @@ const FormRuleVPictures = forwardRef((props, ref) => {
name="register" name="register"
onFinish={onFinish} onFinish={onFinish}
initialValues={{ initialValues={{
imageList, imageList: {},
commonImageList, commonImageList: [],
detailImageList, detailImageList: [],
}} }}
scrollToFirstError scrollToFirstError
> >
......
...@@ -65,11 +65,17 @@ export const WeeksList = [ ...@@ -65,11 +65,17 @@ export const WeeksList = [
}, },
]; ];
export const StaticColumns = [ export const StaticColumns = customer => [
{ {
title: '供货价', title: '供货价',
dataIndex: 'supplyPrice', dataIndex: 'supplyPrice',
editable: true, editable: true,
batchRole: [1, 2, 3],
roleProps: {
precision: 2,
min: 0,
},
disabled: customer.isJDGoods || customer.isService,
}, },
{ {
title: '佣金费率', title: '佣金费率',
...@@ -81,42 +87,90 @@ export const StaticColumns = [ ...@@ -81,42 +87,90 @@ export const StaticColumns = [
title: '市场价', title: '市场价',
dataIndex: 'marketPrice', dataIndex: 'marketPrice',
editable: true, editable: true,
batchRole: [1, 2, 3],
roleProps: {
precision: 2,
min: 0,
},
disabled: customer.isService,
},
{
title: '重量(kg)',
dataIndex: 'weight',
editable: true,
batchRole: [1],
batchProps: {
precision: 3,
max: 999999.999,
},
disabled: customer.isService,
}, },
{ {
title: '销售价', title: '销售价',
dataIndex: 'salePrice', dataIndex: 'salePrice',
editable: true, editable: true,
role: [],
}, },
{ {
title: '库存', title: '库存',
dataIndex: 'stock', dataIndex: 'stock',
editable: true, editable: true,
role: [3], role: [3],
// disabled: customer.isService,
}, },
{ {
title: '库存', title: '库存',
dataIndex: 'productStock', dataIndex: 'productStock',
editable: true, editable: true,
role: [1, 2], role: [1, 2],
batchRole: [1, 2],
batchProps: {
precision: 0,
step: 1,
// eslint-disable-next-line radix
formatter: val => parseInt(val, '10') || '',
},
roleProps: {
precision: 2,
min: 0,
},
disabled: customer.isService,
}, },
{ {
title: '库存预警阈值', title: '库存预警阈值',
dataIndex: 'productStockWarning', dataIndex: 'productStockWarning',
editable: true, editable: true,
role: [], batchRole: [1],
role: [1],
disabled: customer.isService,
}, },
{ {
title: '商品自编码', title: '商品自编码',
dataIndex: 'thirdSkuNo', dataIndex: 'thirdSkuNo',
editable: true, editable: true,
role: [1, 2], role: [1, 2],
inputType: 'text', inputType: 'input',
disabled: customer.isService,
}, },
{ {
title: '京东链接', title: '京东链接',
dataIndex: 'skuLink', dataIndex: 'skuLink',
editable: true, editable: true,
role: [1, 2], role: [1, 2],
inputType: 'text', inputType: 'input',
disabled: customer.isService,
},
{
title: '操作',
editable: true,
dataIndex: 'option',
role: [1, 2],
inputType: 'option',
roleProps: {
isJDGoods: customer.isJDGoods,
min: 0,
},
disabled: customer.isService,
}, },
]; ];
...@@ -12,8 +12,10 @@ import { ...@@ -12,8 +12,10 @@ import {
merchantCategoryGetAll, merchantCategoryGetAll,
merchantBrandList, merchantBrandList,
merchantSpecList, merchantSpecList,
afterSalesAddrsPage,
} from './service'; } from './service';
import { ServiceContext } from './context'; import { ServiceContext } from './context';
import { ConsoleSqlOutlined } from '@ant-design/icons';
/** /**
* 服务商品改造-商品模块 * 服务商品改造-商品模块
...@@ -21,6 +23,8 @@ import { ServiceContext } from './context'; ...@@ -21,6 +23,8 @@ import { ServiceContext } from './context';
* @returns ReactDOM * @returns ReactDOM
*/ */
const ServiceGoods = options => { const ServiceGoods = options => {
const { SourceData, categoryList, specListData } = options;
const basicRef = useRef(null); const basicRef = useRef(null);
const stockRef = useRef(null); const stockRef = useRef(null);
const settingRef = useRef(null); const settingRef = useRef(null);
...@@ -31,7 +35,9 @@ const ServiceGoods = options => { ...@@ -31,7 +35,9 @@ const ServiceGoods = options => {
const [isEdit, setIsEdit] = useState(false); // 是否是编辑状态 const [isEdit, setIsEdit] = useState(false); // 是否是编辑状态
const [productType, setProductType] = useState(1); // 商品状态 const [productType, setProductType] = useState(1); // 商品状态
const [pageLoading, setPageLoading] = useState(false); // 页面加载状态 const [pageLoading, setPageLoading] = useState(false); // 页面加载状态
const [categoryList, setCategoryList] = useState([]); // 获取三级类目 // const [categoryList, setCategoryList] = useState([]); // 获取三级类目
const [afterAddressList, setAfterAddressList] = useState([]);
const [brandList, setBrandList] = useState([]); // 获取商品牌 const [brandList, setBrandList] = useState([]); // 获取商品牌
const [specList, setSpecList] = useState([]); // 规格列表 const [specList, setSpecList] = useState([]); // 规格列表
const [editData, setEditData] = useState({}); // 编辑保存数据 const [editData, setEditData] = useState({}); // 编辑保存数据
...@@ -45,14 +51,22 @@ const ServiceGoods = options => { ...@@ -45,14 +51,22 @@ const ServiceGoods = options => {
proType === 3 ? [...baseCheckList, settingRef, settleOtrRef] : baseCheckList; proType === 3 ? [...baseCheckList, settingRef, settleOtrRef] : baseCheckList;
setCheckFormList(newBaseCheckList); setCheckFormList(newBaseCheckList);
}; };
useEffect(() => {
const timer = setTimeout(() => { const resetForm = () => {
checkFormList.forEach(({ current }) => { checkFormList.forEach(({ current }) => {
if (current) {
current.reset(); current.reset();
}); }
clearTimeout(timer);
}); });
}, [checkFormList]); };
// useEffect(() => {
// const timer = setTimeout(() => {
// console.log(checkFormList);
// clearTimeout(timer);
// }, 1000);
// }, [checkFormList, options.visible]);
const productChange = task => { const productChange = task => {
setProductType(task.type); setProductType(task.type);
...@@ -81,17 +95,28 @@ const ServiceGoods = options => { ...@@ -81,17 +95,28 @@ const ServiceGoods = options => {
// 获取三级类目分类数据 // 获取三级类目分类数据
const getMerchantCategory = async () => { const getMerchantCategory = async () => {
const result = await merchantCategoryGetAll(); const result = await merchantCategoryGetAll();
setCategoryList(result.data || []); // setCategoryList(result.data || []);
}; };
// 获取商品牌数据 // 获取商品牌数据
const getMerchantBrandList = async () => { const getMerchantBrandList = async () => {
const result = await merchantBrandList(); if (!brandList.length) {
setBrandList(result.data || []); const result = await merchantBrandList();
setBrandList(result.data || []);
}
}; };
// 获取规格列表 // 获取规格列表
const getMerchantSpecList = async () => { const getMerchantSpecList = async () => {
const result = await merchantSpecList(); if (!specList.length) {
setSpecList(result.data || []); const result = await merchantSpecList();
setSpecList(result.data || []);
}
};
const getAfterSalesAddrsPage = async () => {
if (!afterAddressList.length) {
const result = await afterSalesAddrsPage();
setAfterAddressList(result.data.records);
}
}; };
useEffect(() => { useEffect(() => {
...@@ -99,23 +124,42 @@ const ServiceGoods = options => { ...@@ -99,23 +124,42 @@ const ServiceGoods = options => {
if (!options.visible) { if (!options.visible) {
return; return;
} }
setPageId(options.id);
setPageLoading(true); setPageLoading(true);
await getMerchantCategory();
await getMerchantBrandList(); await getMerchantBrandList();
await getAfterSalesAddrsPage();
await getMerchantSpecList(); await getMerchantSpecList();
if (options.id) { if (Object.keys(SourceData).length) {
// const isService = initData.state && initData.state !== 4;
setEditData(SourceData);
setPageId(options.id);
setProductType(SourceData.productType);
changeCheckList(SourceData.productType);
setIsEdit(true); setIsEdit(true);
await getProductDetailResponse(options.id);
changeCheckList(productType);
} }
setPageLoading(false); setPageLoading(false);
// setPageLoading(true);
// await getMerchantCategory();
// await getMerchantBrandList();
// await getMerchantSpecList();
// if (options.id) {
// setIsEdit(true);
// await getProductDetailResponse(options.id);
// changeCheckList(productType);
// }
// setPageLoading(false);
})(); })();
}, [options.visible, options.id]); }, [SourceData]);
const handleOk = () => {}; const handleOk = () => {};
const handleCancel = () => { const handleCancel = () => {
setPageId(null);
setIsEdit(false);
setProductType(1);
setEditData({});
setSpecKeyList([]);
resetForm();
options.onChange(false); options.onChange(false);
}; };
...@@ -126,22 +170,31 @@ const ServiceGoods = options => { ...@@ -126,22 +170,31 @@ const ServiceGoods = options => {
[specKeyList], [specKeyList],
); );
const providerValue = {
pageId,
isEdit,
productType,
isCard: productType === 3,
isService: SourceData.state && SourceData.state !== 4,
isJDGoods: isEdit && SourceData.pageProductType && +SourceData.pageProductType !== 1,
};
return ( return (
<Modal visible={options.visible} onOk={handleOk} onCancel={handleCancel} width={1366}> <Modal visible={options.visible} onOk={handleOk} onCancel={handleCancel} width={1366}>
<Spin tip="正在加载..." spinning={pageLoading} delay={100}> <Spin tip="正在加载..." spinning={pageLoading} delay={100}>
<WrapperContainer> <WrapperContainer>
<ServiceContext.Provider <ServiceContext.Provider value={providerValue}>
value={{ pageId, isEdit, productType, isCard: productType === 3 }}
>
<Title title="商品类型" /> <Title title="商品类型" />
<TaskTypeSelect productType={productType} onChange={productChange} /> <TaskTypeSelect productType={productType} onChange={productChange} />
<Title title="商品基本信息编辑" /> <Title title="商品基本信息编辑" />
<FormInformationBasic <FormInformationBasic
ref={basicRef} ref={basicRef}
editData={editData} editData={editData.infoMation}
categoryList={categoryList} categoryList={categoryList}
brandList={brandList} brandList={brandList}
afterAddressList={afterAddressList}
specListData={specListData}
/> />
<Title title="价格与库存" /> <Title title="价格与库存" />
...@@ -149,14 +202,19 @@ const ServiceGoods = options => { ...@@ -149,14 +202,19 @@ const ServiceGoods = options => {
ref={stockRef} ref={stockRef}
specList={specList} specList={specList}
onSpecChange={onSpecCommonImgEvent} onSpecChange={onSpecCommonImgEvent}
editData={editData} editData={editData.infoSpecData}
skuList={editData.skuList}
/> />
<Title title="规则设置" /> {/* <Title title="规则设置" />
{productType === 3 && <FormRuleSetting ref={settingRef} editData={editData} />} {productType === 3 && <FormRuleSetting ref={settingRef} editData={editData} />} */}
<FormRuleVPictures ref={picturesRef} specKeyItem={specKeyList} editData={editData} /> <FormRuleVPictures
{productType === 3 && <FormSettlementOthers ref={settleOtrRef} editData={editData} />} ref={picturesRef}
specKeyItem={specKeyList}
editData={editData.infoImageData}
/>
{/* {productType === 3 && <FormSettlementOthers ref={settleOtrRef} editData={editData} />} */}
<Button type="primary" onClick={submitEvent}> <Button type="primary" onClick={submitEvent}>
Register Register
</Button> </Button>
......
...@@ -41,3 +41,19 @@ export const merchantSpecList = () => ...@@ -41,3 +41,19 @@ export const merchantSpecList = () =>
request.post('/product/spec/api/merchant/list', { request.post('/product/spec/api/merchant/list', {
prefix: goodsApi, prefix: goodsApi,
}); });
// 查询供应商售后地址
export const afterSalesAddrsPage = () => {
const params = {
pageSize: 100,
pageNo: 1,
};
const data = request.post('/api/kdsp/supplier/after-sales-addrs-page', {
prefix: kdspApi,
data: stringify(_.omitBy(params, v => !v)),
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
});
return data;
};
...@@ -65,7 +65,7 @@ export const createProductData = ({ firstValues, secondValues, firstSpecId, seco ...@@ -65,7 +65,7 @@ export const createProductData = ({ firstValues, secondValues, firstSpecId, seco
const specFirst = createInitProduct(fisrtItem, true); const specFirst = createInitProduct(fisrtItem, true);
specFirst.firstSpecId = firstSpecId; specFirst.firstSpecId = firstSpecId;
specFirst.firstSpecValue = fisrtItem.firstSpecValue; specFirst.firstSpecValue = fisrtItem.firstSpecValue;
if (secondValues.length) { if (secondSpecId && secondValues.length) {
createSecondProduct(secondValues, specFirst, secondSpecId, dataSource, specSecond => { createSecondProduct(secondValues, specFirst, secondSpecId, dataSource, specSecond => {
if (!countRowSpan[specFirst.firstSpecValue]) { if (!countRowSpan[specFirst.firstSpecValue]) {
countRowSpan[specFirst.firstSpecValue] = true; countRowSpan[specFirst.firstSpecValue] = true;
......
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