Commit 17bc3456 authored by beisir's avatar beisir

feat: 商品库服务类商品

parent 2ce7c881
...@@ -3,13 +3,14 @@ const isPre = process.env.PRE_ENV === 'pre'; ...@@ -3,13 +3,14 @@ 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://sc-merchant-api-xyqb.liangkebang.net',
kdspApi: 'https://sc-op-api-xyqb.liangkebang.net', kdspApi: 'https://sc-merchant-api-xyqb.liangkebang.net',
goodsApi: 'https://sc-op-api-xyqb.liangkebang.net', goodsApi: 'https://sc-merchant-api-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',
querysApi: 'https://sc-settlement-api-xyqb.liangkebang.net', querysApi: 'https://sc-settlement-api-xyqb.liangkebang.net',
// goodsApi: '//192.168.188.111:7000',
prologueDomain: 'https://mall-xyqb.liangkebang.net', prologueDomain: 'https://mall-xyqb.liangkebang.net',
// qiniuHost: 'https://appsync.lkbang.net',
qiniuHost: 'https://kdspstatic.q-gp.com/', qiniuHost: 'https://kdspstatic.q-gp.com/',
opapiHost: 'https://opapi-xyqb.liangkebang.net', opapiHost: 'https://opapi-xyqb.liangkebang.net',
}; };
......
...@@ -157,7 +157,7 @@ class goodsManage extends Component { ...@@ -157,7 +157,7 @@ class goodsManage extends Component {
</FormItem> </FormItem>
</FormItem> </FormItem>
<FormItem label="商品类型" name="productType"> <FormItem label="商品类型" name="productType">
<Select style={iptNumWidth}> <Select style={selectW} placeholder="请选择商品类型">
<Option value={1}>实体商品</Option> <Option value={1}>实体商品</Option>
<Option value={2}>虚拟商品</Option> <Option value={2}>虚拟商品</Option>
<Option value={4}>服务类商品</Option> <Option value={4}>服务类商品</Option>
......
...@@ -38,7 +38,7 @@ export function column() { ...@@ -38,7 +38,7 @@ export function column() {
width: 125, width: 125,
align: 'center', align: 'center',
render: (_, row) => { render: (_, row) => {
if (row.type !== 1) { if (row.type === 2) {
return ( return (
<Badge <Badge
count={ count={
...@@ -153,26 +153,21 @@ export function column() { ...@@ -153,26 +153,21 @@ 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 <Button
key="edit" key="edit"
type="primary" type="primary"
size="small" size="small"
className={styles.button} className={styles.button}
onClick={() => this.onUpdateInfo(row)} onClick={() => {
> if (row.type === 4) {
修改 this.serviceVisbleChange(row);
</Button> } else {
<Button this.onUpdateInfo(row);
key="222" }
type="primary" }}
size="small"
className={styles.button}
onClick={() => this.serviceVisbleChange(row)}
> >
修改 修改
</Button> </Button>
</>
)} )}
<Button <Button
key="viewP" key="viewP"
...@@ -302,6 +297,7 @@ export const ProcessEditData = (data, row) => { ...@@ -302,6 +297,7 @@ export const ProcessEditData = (data, row) => {
}, {}); }, {});
const SourceData = { const SourceData = {
state: row.state,
id: data.id, id: data.id,
productType: data.productType, productType: data.productType,
pageProductType: row.productType, pageProductType: row.productType,
...@@ -313,6 +309,7 @@ export const ProcessEditData = (data, row) => { ...@@ -313,6 +309,7 @@ export const ProcessEditData = (data, row) => {
name: data.name, name: data.name,
categoryId: [data.firstCategoryId, data.secondCategoryId, data.thirdCategoryId], categoryId: [data.firstCategoryId, data.secondCategoryId, data.thirdCategoryId],
description: serviceItem.description || null, description: serviceItem.description || null,
afterAddressId: data.afterAddressId || null,
}, },
infoSpecData: { infoSpecData: {
firstSpec: oneItem.firstSpec, firstSpec: oneItem.firstSpec,
......
...@@ -73,8 +73,11 @@ ...@@ -73,8 +73,11 @@
} }
} }
.pictureWrapper {
position: relative;
}
.pullImage { .pullImage {
position: absolute; position: absolute;
top: 30px; top: 30px;
right: -80px; right: 40px;
} }
...@@ -80,8 +80,6 @@ export const CreateFormInput = props => { ...@@ -80,8 +80,6 @@ export const CreateFormInput = props => {
...options ...options
} = props; } = props;
console.log(dataIndex, roleProps);
if (type === 'input') { if (type === 'input') {
return ( return (
<Input <Input
...@@ -135,7 +133,6 @@ export const CreateFormInput = props => { ...@@ -135,7 +133,6 @@ export const CreateFormInput = props => {
style={{ width: '100%' }} style={{ width: '100%' }}
placeholder={`请输入${title}`} placeholder={`请输入${title}`}
onBlur={e => { onBlur={e => {
console.log(e);
onBlurEvent(e.target.value, dataIndex, rowIndex); onBlurEvent(e.target.value, dataIndex, rowIndex);
}} }}
/> />
......
...@@ -59,7 +59,6 @@ const EditFormTable = forwardRef((props, ref) => { ...@@ -59,7 +59,6 @@ const EditFormTable = forwardRef((props, ref) => {
form.setFieldsValue({ form.setFieldsValue({
tableList: initData, tableList: initData,
}); });
console.log('==============>生成的表格数据', initData);
setDataSource([...initData]); setDataSource([...initData]);
}, [initData]); }, [initData]);
...@@ -83,11 +82,8 @@ const EditFormTable = forwardRef((props, ref) => { ...@@ -83,11 +82,8 @@ const EditFormTable = forwardRef((props, ref) => {
const onCheck = async () => { const onCheck = async () => {
try { try {
const { tableList } = await form.validateFields(); await form.validateFields();
console.log('===============>编辑表格', tableList); const newTableList = [...dataSource].map(item => {
const newTableList = customer.isEdit
? [...dataSource]
: [...tableList].map(item => {
const { rowSpanCount, option, ...childItem } = item; const { rowSpanCount, option, ...childItem } = item;
return childItem; return childItem;
}); });
...@@ -125,14 +121,6 @@ const EditFormTable = forwardRef((props, ref) => { ...@@ -125,14 +121,6 @@ const EditFormTable = forwardRef((props, ref) => {
onCheck, onCheck,
form, form,
})); }));
const save = async () => {
try {
const tableList = form.getFieldValue('tableList');
handleSave(tableList);
} catch (errInfo) {
console.log('Save failed:', errInfo);
}
};
// 根据这里做判断渲染表格 // 根据这里做判断渲染表格
const columns = defaultColumns const columns = defaultColumns
.filter(item => !item.role || item.role.includes(customer.productType)) .filter(item => !item.role || item.role.includes(customer.productType))
...@@ -184,9 +172,10 @@ const EditFormTable = forwardRef((props, ref) => { ...@@ -184,9 +172,10 @@ const EditFormTable = forwardRef((props, ref) => {
return ( return (
<> <>
<Form form={form} scrollToFirstError component={false}> <Form form={form} scrollToFirstError component={false}>
<Button onClick={onCheck}>测试</Button> {/* <Button onClick={onCheck}>测试</Button> */}
<EditableContext.Provider value={form}> <EditableContext.Provider value={form}>
<Table <Table
scroll={{ y: 300, x: 1000 }}
height={300} height={300}
pagination={false} pagination={false}
size="small" size="small"
......
...@@ -46,7 +46,6 @@ const FormInformationBasic = forwardRef((props, ref) => { ...@@ -46,7 +46,6 @@ const FormInformationBasic = forwardRef((props, ref) => {
} }
values.specs = specs; values.specs = specs;
values.temp = 'infoMation'; values.temp = 'infoMation';
console.log(values);
return values; return values;
} catch (errorInfo) { } catch (errorInfo) {
return null; return null;
...@@ -70,16 +69,11 @@ const FormInformationBasic = forwardRef((props, ref) => { ...@@ -70,16 +69,11 @@ const FormInformationBasic = forwardRef((props, ref) => {
} }
}, [customer.isEdit, editData]); }, [customer.isEdit, editData]);
const onFinish = values => {
console.log('Received values of form: ', values);
};
return ( return (
<Form <Form
{...formItemLayout} {...formItemLayout}
form={form} form={form}
name="register" name="register"
onFinish={onFinish}
initialValues={{ initialValues={{
brandId: null, brandId: null,
name: '', name: '',
...@@ -88,9 +82,9 @@ const FormInformationBasic = forwardRef((props, ref) => { ...@@ -88,9 +82,9 @@ const FormInformationBasic = forwardRef((props, ref) => {
}} }}
scrollToFirstError scrollToFirstError
> >
<Button type="primary" onClick={onCheck}> {/* <Button type="primary" onClick={onCheck}>
测试 测试
</Button> </Button> */}
<Form.Item <Form.Item
name="categoryId" name="categoryId"
label="商品类目" label="商品类目"
...@@ -160,7 +154,7 @@ const FormInformationBasic = forwardRef((props, ref) => { ...@@ -160,7 +154,7 @@ const FormInformationBasic = forwardRef((props, ref) => {
rules={[{ required: true, message: '请选择售后地址!' }]} rules={[{ required: true, message: '请选择售后地址!' }]}
> >
<Select showSearch placeholder="请选择售后地址" filterOption={fileterBrandOptions}> <Select showSearch placeholder="请选择售后地址" filterOption={fileterBrandOptions}>
{([{ id: 9527, addressName: '测试地址' }] || afterAddressList).map(item => ( {(afterAddressList || []).map(item => (
<Select.Option key={item.id} value={item.id}> <Select.Option key={item.id} value={item.id}>
{item.addressName} {item.addressName}
</Select.Option> </Select.Option>
......
...@@ -226,7 +226,6 @@ const FormPriceOrStock = forwardRef((props, ref) => { ...@@ -226,7 +226,6 @@ const FormPriceOrStock = forwardRef((props, ref) => {
try { try {
const values = await form.validateFields(); const values = await form.validateFields();
const items = await editRef.current.onCheck(); const items = await editRef.current.onCheck();
console.log('================>items', items);
if (items) { if (items) {
return { ...values, items, temp: 'infoSpecData' }; return { ...values, items, temp: 'infoSpecData' };
} }
...@@ -358,7 +357,6 @@ const FormPriceOrStock = forwardRef((props, ref) => { ...@@ -358,7 +357,6 @@ const FormPriceOrStock = forwardRef((props, ref) => {
useEffect(() => { useEffect(() => {
if (customer.isEdit) { if (customer.isEdit) {
if (!editData) return; if (!editData) return;
console.log('===============>设置参数', editData);
form.setFieldsValue(editData); // 设置规格数据 form.setFieldsValue(editData); // 设置规格数据
firstOnChangeEvent(); // 触发成底部动态表格数据 firstOnChangeEvent(); // 触发成底部动态表格数据
setSpecInitValue(editData); // 缓存规格数据 setSpecInitValue(editData); // 缓存规格数据
......
...@@ -85,7 +85,7 @@ const FormRuleSetting = forwardRef((props, ref) => { ...@@ -85,7 +85,7 @@ const FormRuleSetting = forwardRef((props, ref) => {
> >
<Select mode="multiple" placeholder="请选择适用门店"> <Select mode="multiple" placeholder="请选择适用门店">
{(supplierIdList || []).map(item => ( {(supplierIdList || []).map(item => (
<Option value={item.id} key={item.id}> <Option value={+item.id} key={item.id}>
{item.name} {item.name}
</Option> </Option>
))} ))}
......
...@@ -112,6 +112,8 @@ const FormRuleVPictures = forwardRef((props, ref) => { ...@@ -112,6 +112,8 @@ const FormRuleVPictures = forwardRef((props, ref) => {
initialValues={{ initialValues={{
commonImageList: [], commonImageList: [],
cardImageList: [], cardImageList: [],
imageList: {},
detailImageList: [],
}} }}
> >
<Form.Item <Form.Item
...@@ -122,16 +124,18 @@ const FormRuleVPictures = forwardRef((props, ref) => { ...@@ -122,16 +124,18 @@ const FormRuleVPictures = forwardRef((props, ref) => {
{ {
required: imgConfig.commonImageList.rule, required: imgConfig.commonImageList.rule,
type: 'array', type: 'array',
message: `请上传${imgConfig.commonImageList.title}!`, message: '请上传图片!',
}, },
{ {
validateTrigger: 'submit',
validator(rule, value, callback) { validator(rule, value, callback) {
if (customer.productType !== 1) { if (customer.productType !== 1) {
return callback(); return callback();
} }
// 规格图不为必传,如未上传规格图时,公共图为必传图
const checkImageList = form.getFieldValue('imageList'); const checkImageList = form.getFieldValue('imageList');
const check = Object.keys(checkImageList).length; const check = Object.keys(checkImageList || {}).length;
return check > 0 ? callback() : callback('请上传封面图片'); return check || value.length ? callback() : callback('请上传封面图片');
}, },
}, },
]} ]}
...@@ -168,11 +172,14 @@ const FormRuleVPictures = forwardRef((props, ref) => { ...@@ -168,11 +172,14 @@ const FormRuleVPictures = forwardRef((props, ref) => {
)} )}
{!customer.isCard && {!customer.isCard &&
Object.keys(imageList).map(key => ( Object.keys(imageList).map(key => (
<div key={key} className={commonStyle.pictureWrapper}>
<Form.Item <Form.Item
name={['imageList', key]} name={['imageList', key]}
key={key} key={key}
label={`商品图片(${key})`} label={`商品图片(${key})`}
rules={[{ required: imgConfig.imageList.rule, type: 'array', message: '请上传图片!' }]} rules={[
{ required: imgConfig.imageList.rule, type: 'array', message: '请上传图片!' },
]}
extra={imgConfig.imageList.renderExtra()} extra={imgConfig.imageList.renderExtra()}
> >
<UploadImage <UploadImage
...@@ -182,10 +189,11 @@ const FormRuleVPictures = forwardRef((props, ref) => { ...@@ -182,10 +189,11 @@ const FormRuleVPictures = forwardRef((props, ref) => {
pictures={imageList[key]} pictures={imageList[key]}
setPictureList={list => onPictureSuccessEvent(list, key)} setPictureList={list => onPictureSuccessEvent(list, key)}
/> />
</Form.Item>
<Button className={commonStyle.pullImage} type="primary"> <Button className={commonStyle.pullImage} type="primary">
拉取公共图 拉取公共图
</Button> </Button>
</Form.Item> </div>
))} ))}
<Form.Item <Form.Item
name="detailImageList" name="detailImageList"
......
...@@ -138,6 +138,7 @@ const UploadImage = forwardRef((props, ref) => { ...@@ -138,6 +138,7 @@ const UploadImage = forwardRef((props, ref) => {
setUploadLoading(false); setUploadLoading(false);
} }
} catch (error) { } catch (error) {
console.log(error);
setUploadLoading(false); setUploadLoading(false);
Modal.warning({ Modal.warning({
maskClosable: true, maskClosable: true,
......
...@@ -12,7 +12,7 @@ export const TaskList = [ ...@@ -12,7 +12,7 @@ export const TaskList = [
name: '实体商品', name: '实体商品',
type: 1, type: 1,
desc: '物流发货', desc: '物流发货',
// hide: true, hide: true,
imgConfig: { imgConfig: {
commonImageList: { commonImageList: {
title: '公共滑动图', title: '公共滑动图',
...@@ -37,7 +37,7 @@ export const TaskList = [ ...@@ -37,7 +37,7 @@ export const TaskList = [
name: '虚拟商品', name: '虚拟商品',
type: 2, type: 2,
desc: '无需物流', desc: '无需物流',
// hide: true, hide: true,
imgConfig: { imgConfig: {
commonImageList: { commonImageList: {
title: '公共滑动图', title: '公共滑动图',
...@@ -58,36 +58,36 @@ export const TaskList = [ ...@@ -58,36 +58,36 @@ export const TaskList = [
}, },
}, },
}, },
// {
// name: '电子卡卷',
// type: 3,
// desc: '无需物流',
// hide: true,
// imgConfig: {
// commonImageList: {
// title: '封面图片',
// rule: true,
// limit: 11,
// renderExtra(leng) {
// return `建议尺寸: ##宽##高 (${leng} / 1) `;
// },
// },
// imageList: {
// rule: true,
// limit: 1,
// },
// detailImageList: {
// title: '商品图片',
// rule: true,
// limit: null,
// renderExtra() {
// return '请上传商品图!';
// },
// },
// },
// },
{ {
name: '电子卡卷', name: '电子卡卷',
type: 3,
desc: '无需物流',
hide: true,
imgConfig: {
commonImageList: {
title: '封面图片',
rule: true,
limit: 11,
renderExtra(leng) {
return `建议尺寸: ##宽##高 (${leng} / 1) `;
},
},
imageList: {
rule: true,
limit: 1,
},
detailImageList: {
title: '商品图片',
rule: true,
limit: null,
renderExtra() {
return '请上传商品图!';
},
},
},
},
{
name: '服务类商品',
type: 4, type: 4,
desc: '无需物流', desc: '无需物流',
imgConfig: { imgConfig: {
...@@ -165,7 +165,7 @@ export const StaticColumns = customer => [ ...@@ -165,7 +165,7 @@ export const StaticColumns = customer => [
min: 0, min: 0,
}, },
roleRules: { required: true }, roleRules: { required: true },
disabeldRender: () => customer.isJDGoods, disabeldRender: () => customer.isJDGoods || customer.isService,
}, },
{ {
title: '佣金费率', title: '佣金费率',
...@@ -175,7 +175,7 @@ export const StaticColumns = customer => [ ...@@ -175,7 +175,7 @@ export const StaticColumns = customer => [
roleRules: { required: true }, roleRules: { required: true },
roleProps: { roleProps: {
min: 0, min: 0,
max: 100, // max: 100,
}, },
}, },
{ {
...@@ -188,6 +188,7 @@ export const StaticColumns = customer => [ ...@@ -188,6 +188,7 @@ export const StaticColumns = customer => [
min: 0, min: 0,
}, },
roleRules: { required: true }, roleRules: { required: true },
disabeldRender: () => customer.isService,
}, },
{ {
title: '销售价', title: '销售价',
...@@ -207,15 +208,18 @@ export const StaticColumns = customer => [ ...@@ -207,15 +208,18 @@ export const StaticColumns = customer => [
editable: true, editable: true,
batchRole: [1], batchRole: [1],
batchProps: { batchProps: {
min: 0,
precision: 3, precision: 3,
max: 999999.999, max: 999999.999,
}, },
role: [1], role: [1],
roleRules: { required: true }, roleRules: { required: true },
roleProps: { roleProps: {
min: 0,
precision: 3, precision: 3,
max: 999999.999, max: 999999.999,
}, },
disabeldRender: () => customer.isService,
}, },
{ {
title: '库存', title: '库存',
...@@ -226,17 +230,16 @@ export const StaticColumns = customer => [ ...@@ -226,17 +230,16 @@ export const StaticColumns = customer => [
batchProps: { batchProps: {
precision: 0, precision: 0,
step: 1, step: 1,
// eslint-disable-next-line radix min: 0,
formatter: val => parseInt(val, '10') || '',
}, },
roleProps: { roleProps: {
min: 0, min: 0,
}, },
roleRules: { required: true }, roleRules: { required: true },
disabeldRender: record => customer.isEdit && record.id, disabeldRender: () => customer.isService,
}, },
{ {
title: '库存预警阈值', title: '库存预警',
dataIndex: 'productStockWarning', dataIndex: 'productStockWarning',
editable: true, editable: true,
batchRole: [1], batchRole: [1],
...@@ -244,7 +247,10 @@ export const StaticColumns = customer => [ ...@@ -244,7 +247,10 @@ export const StaticColumns = customer => [
roleRules: { required: true }, roleRules: { required: true },
roleProps: { roleProps: {
min: 0, min: 0,
precision: 0,
maxLength: 5,
}, },
disabeldRender: () => customer.isService,
}, },
{ {
title: '商品自编码', title: '商品自编码',
...@@ -253,6 +259,7 @@ export const StaticColumns = customer => [ ...@@ -253,6 +259,7 @@ export const StaticColumns = customer => [
role: [1, 2], role: [1, 2],
inputType: 'input', inputType: 'input',
roleRules: { required: true }, roleRules: { required: true },
disabeldRender: () => customer.isService,
}, },
{ {
title: '京东链接', title: '京东链接',
...@@ -261,6 +268,7 @@ export const StaticColumns = customer => [ ...@@ -261,6 +268,7 @@ export const StaticColumns = customer => [
role: [1, 2], role: [1, 2],
inputType: 'input', inputType: 'input',
roleRules: { required: false }, roleRules: { required: false },
disabeldRender: () => customer.isService,
}, },
{ {
title: 'sku名称', title: 'sku名称',
......
...@@ -9,18 +9,16 @@ import FormRuleSetting from './components/FormRuleSetting'; ...@@ -9,18 +9,16 @@ import FormRuleSetting from './components/FormRuleSetting';
import FormRuleVPictures from './components/FormRuleVPictures'; import FormRuleVPictures from './components/FormRuleVPictures';
import FormSettlementOthers from './components/FormSettlementOthers'; import FormSettlementOthers from './components/FormSettlementOthers';
import { import {
getProductDetail,
merchantCategoryGetAll,
merchantBrandList, merchantBrandList,
merchantSpecList, merchantSpecList,
afterSalesAddrsPage, afterSalesAddrsPage,
merchantgetJdPicList, merchantgetJdPicList,
merchantProductAdd,
// getSupplierList,
supplierListQuery, supplierListQuery,
shopGetBySupplierId, shopGetBySupplierId,
merchantProductAdd,
merchantProductEdit,
} from './service'; } from './service';
import { isUrl, filterSendData } from './utils'; import { isUrl, filterSendData, clearCurrent } from './utils';
import { ServiceContext } from './context'; import { ServiceContext } from './context';
/** /**
...@@ -41,70 +39,37 @@ const ServiceGoods = options => { ...@@ -41,70 +39,37 @@ const ServiceGoods = options => {
const [isEdit, setIsEdit] = useState(false); // 是否是编辑状态 const [isEdit, setIsEdit] = useState(false); // 是否是编辑状态
const [productType, setProductType] = useState(4); // 商品状态 const [productType, setProductType] = useState(4); // 商品状态
const [pageLoading, setPageLoading] = useState(false); // 页面加载状态 const [pageLoading, setPageLoading] = useState(false); // 页面加载状态
// const [categoryList, setCategoryList] = useState([]); // 获取三级类目 const [afterAddressList, setAfterAddressList] = useState([]); // 售后地址
const [afterAddressList, setAfterAddressList] = useState([]); const [supplierIdList, setSupplierIdList] = useState([]); // 适用们店列表
const [supplierIdList, setSupplierIdList] = useState([]);
// const [shopList, setShopList] = 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({}); // 编辑保存数据
const baseCheckList = [basicRef, stockRef, settingRef, settleOtrRef, picturesRef]; // 卡卷默认5个,到时改版为实体对应3个 // const [shopList, setShopList] = useState([]); // 供应商列表
const [checkFormList, setCheckFormList] = useState(baseCheckList); const [checkFormList] = useState([basicRef, stockRef, settingRef, settleOtrRef, picturesRef]);
const [specKeyList, setSpecKeyList] = useState([]); // 记录一级规格key字段 const [specKeyList, setSpecKeyList] = useState([]); // 记录一级规格key字段
const changeCheckList = proType => { const resetForm = () => clearCurrent(checkFormList).forEach(({ current }) => current.reset());
const newBaseCheckList =
proType === 4 ? [...baseCheckList, settingRef, settleOtrRef] : baseCheckList;
setCheckFormList(newBaseCheckList);
};
const resetForm = () => {
checkFormList.forEach(({ current }) => {
if (current) {
current.reset();
}
});
};
const productChange = task => { const productChange = task => {
setProductType(task.type); setProductType(task.type);
changeCheckList(task.type);
const timer = setTimeout(() => { const timer = setTimeout(() => {
resetForm(); resetForm();
clearTimeout(timer); clearTimeout(timer);
}, 1000); }, 1000);
}; };
const handleCancel = () => { const handleCancel = refresh => {
setPageId(null); setPageId(null);
setIsEdit(false); setIsEdit(false);
setProductType(4); // 默认写死服务类商品 setProductType(4); // 默认写死服务类商品
setEditData({}); setEditData({});
setSpecKeyList([]); setSpecKeyList([]);
resetForm(); resetForm();
options.onChange(false); options.onChange(false, refresh);
};
// 编辑回显详情数据
const getProductDetailResponse = async id => {
try {
const res = await getProductDetail(id);
if (res && res.data) {
setProductType(res.data.type);
setEditData(res.data);
}
} catch (err) {
console.log('接口调用失败!');
}
}; };
// 获取三级类目分类数据
// const getMerchantCategory = async () => {
// const result = await merchantCategoryGetAll();
// // setCategoryList(result.data || []);
// };
// 获取商品牌数据 // 获取商品牌数据
const getMerchantBrandList = async () => { const getMerchantBrandList = async () => {
if (!brandList.length) { if (!brandList.length) {
...@@ -134,15 +99,20 @@ const ServiceGoods = options => { ...@@ -134,15 +99,20 @@ const ServiceGoods = options => {
// setShopList(result.data); // setShopList(result.data);
// } // }
// }; // };
const sendMerchantProductHttpRequest = async sendData => {
const sendMerchantProductAdd = async sendData => { try {
setPageLoading(true); setPageLoading(true);
const addResponse = await merchantProductAdd(sendData); const sendAsyncHttpRequest = isEdit ? merchantProductEdit : merchantProductAdd;
const addResponse = await sendAsyncHttpRequest(sendData);
if (addResponse.data) { if (addResponse.data) {
message.success('添加成功!'); message.success(`${isEdit ? '修改' : '添加'}成功!`);
handleCancel(); handleCancel(true);
} }
setPageLoading(false); setPageLoading(false);
} catch (error) {
console.log(error);
setPageLoading(false);
}
}; };
const shopGetBySupplierIdResponse = async () => { const shopGetBySupplierIdResponse = async () => {
...@@ -153,7 +123,7 @@ const ServiceGoods = options => { ...@@ -153,7 +123,7 @@ const ServiceGoods = options => {
}; };
const submitEvent = async () => { const submitEvent = async () => {
const checkPromiseList = checkFormList.map(({ current }) => current.onCheck()); const checkPromiseList = clearCurrent(checkFormList).map(({ current }) => current.onCheck());
const resuslt = await Promise.all(checkPromiseList); const resuslt = await Promise.all(checkPromiseList);
if (!resuslt.includes(null)) { if (!resuslt.includes(null)) {
const params = resuslt.reduce((origin, item) => { const params = resuslt.reduce((origin, item) => {
...@@ -161,9 +131,11 @@ const ServiceGoods = options => { ...@@ -161,9 +131,11 @@ const ServiceGoods = options => {
origin[temp] = other; origin[temp] = other;
return origin; return origin;
}, {}); }, {});
const sendData = filterSendData(productType, params); const sendData = filterSendData(productType, params);
sendMerchantProductAdd(sendData); if (isEdit) {
sendData.id = pageId;
}
sendMerchantProductHttpRequest(sendData);
} }
}; };
...@@ -197,11 +169,10 @@ const ServiceGoods = options => { ...@@ -197,11 +169,10 @@ const ServiceGoods = options => {
await getAfterSalesAddrsPage(); await getAfterSalesAddrsPage();
await getMerchantSpecList(); await getMerchantSpecList();
if (Object.keys(SourceData).length) { if (Object.keys(SourceData).length) {
// const isService = initData.state && initData.state !== 4;
setEditData(SourceData); setEditData(SourceData);
setPageId(options.id); setPageId(SourceData.id);
setProductType(SourceData.productType); setProductType(SourceData.productType);
changeCheckList(SourceData.productType); // changeCheckList(SourceData.productType);
setIsEdit(true); setIsEdit(true);
} }
setPageLoading(false); setPageLoading(false);
...@@ -233,8 +204,6 @@ const ServiceGoods = options => { ...@@ -233,8 +204,6 @@ const ServiceGoods = options => {
jdSkuInfoUrl: params.skuLink, jdSkuInfoUrl: params.skuLink,
}); });
} }
console.log(event, params);
}; };
const providerValue = { const providerValue = {
...@@ -253,11 +222,13 @@ const ServiceGoods = options => { ...@@ -253,11 +222,13 @@ const ServiceGoods = options => {
visible={options.visible} visible={options.visible}
onCancel={() => handleCancel()} onCancel={() => handleCancel()}
width={1000} width={1000}
maskClosable={false}
keyboard={false}
footer={[ footer={[
<Button key="submit" type="primary" loading={pageLoading} onClick={submitEvent}> <Button key="submit" type="primary" loading={pageLoading} onClick={submitEvent}>
提交 提交
</Button>, </Button>,
<Button key="back" onClick={handleCancel}> <Button key="back" onClick={() => handleCancel()}>
返回 返回
</Button>, </Button>,
]} ]}
......
...@@ -73,6 +73,12 @@ export const merchantProductAdd = data => ...@@ -73,6 +73,12 @@ export const merchantProductAdd = data =>
data, data,
}); });
export const merchantProductEdit = data =>
request.post('/product/api/merchant/edit', {
prefix: goodsApi,
data,
});
export const supplierListQuery = () => export const supplierListQuery = () =>
request.get('/api/kdsp/supplier/supplier-list-query', { request.get('/api/kdsp/supplier/supplier-list-query', {
prefix: config.kdspApi, prefix: config.kdspApi,
......
import { Button, Form, Input, Popconfirm, Table } from 'antd';
export interface Task {
name: string;
type: number;
desc: string;
}
interface EditableRowProps {
index: number;
}
export type EditableTableProps = Parameters<typeof Table>[0];
export type ColumnTypes = Exclude<EditableTableProps['columns'], undefined>;
...@@ -77,9 +77,6 @@ export const batchTableSourceData = ({ batchItem, tableData, bacthSecon, bacthFi ...@@ -77,9 +77,6 @@ export const batchTableSourceData = ({ batchItem, tableData, bacthSecon, bacthFi
const filterItems = (type, props) => { const filterItems = (type, props) => {
const { infoSpecData, serviceItem, infoImageData, infoMation, settlementItem } = props; const { infoSpecData, serviceItem, infoImageData, infoMation, settlementItem } = props;
console.log('===========>infoSpecData', infoSpecData);
const { imageList = {}, commonImageList, cardImageList } = infoImageData; const { imageList = {}, commonImageList, cardImageList } = infoImageData;
return infoSpecData.items.map(item => { return infoSpecData.items.map(item => {
if (type === 4) { if (type === 4) {
......
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