提交 135f159c 作者: 龚洪江

功能:产品配置价格,商品,租赁新增编辑产品调整

上级 ae793c0d
...@@ -5,7 +5,6 @@ import type { RadioChangeEvent } from 'antd'; ...@@ -5,7 +5,6 @@ import type { RadioChangeEvent } from 'antd';
import EditableCell from '~/components/EditableCell'; import EditableCell from '~/components/EditableCell';
import { InterDataType } from '~/api/interface'; import { InterDataType } from '~/api/interface';
import { categoryListType } from '~/api/interface/categoryManage';
import { ProduceManageAPI } from '~/api'; import { ProduceManageAPI } from '~/api';
import { import {
cooperationTagType, cooperationTagType,
...@@ -16,8 +15,6 @@ import { customizeEntity, skuUnitType, specEntity } from '~/api/interface/goodsT ...@@ -16,8 +15,6 @@ import { customizeEntity, skuUnitType, specEntity } from '~/api/interface/goodsT
import { Uploader } from '~/components/uploader'; import { Uploader } from '~/components/uploader';
import ConfigurePriceModal from '../configurePriceModal'; import ConfigurePriceModal from '../configurePriceModal';
//分类返回类型
type categoryType = InterDataType<categoryListType>['list'];
//产品返回类型 //产品返回类型
type productType = InterDataType<productListType>['list']; type productType = InterDataType<productListType>['list'];
//产品-规格返回类型 //产品-规格返回类型
...@@ -31,7 +28,6 @@ interface selfProps { ...@@ -31,7 +28,6 @@ interface selfProps {
handleCancel: () => void; handleCancel: () => void;
handleOk: (data: specEntity) => void; handleOk: (data: specEntity) => void;
currentDesc: number; currentDesc: number;
categoryList: categoryType;
curtRowData: Partial<specEntity>; curtRowData: Partial<specEntity>;
skuUnitList: unitType; skuUnitList: unitType;
goodsType: number; goodsType: number;
...@@ -49,7 +45,6 @@ const AddOrEditSkuModal: React.FC<ModalProps & selfProps> = ({ ...@@ -49,7 +45,6 @@ const AddOrEditSkuModal: React.FC<ModalProps & selfProps> = ({
handleCancel, handleCancel,
handleOk, handleOk,
currentDesc, currentDesc,
categoryList,
curtRowData, curtRowData,
skuUnitList, skuUnitList,
goodsType, goodsType,
...@@ -151,15 +146,6 @@ const AddOrEditSkuModal: React.FC<ModalProps & selfProps> = ({ ...@@ -151,15 +146,6 @@ const AddOrEditSkuModal: React.FC<ModalProps & selfProps> = ({
}), }),
}; };
}); });
// // 根据产品类型获取产品列表
const handleProdTypeSelect = (id: number) => {
getProductList(id);
skuForm.setFieldsValue({
skuId: undefined,
specIds: undefined,
});
// getProduct(id);
};
// //
// // 根据所属行业获取方案列表 // // 根据所属行业获取方案列表
// const handleIndeTypeSelect = async (id: number) => { // const handleIndeTypeSelect = async (id: number) => {
...@@ -212,8 +198,8 @@ const AddOrEditSkuModal: React.FC<ModalProps & selfProps> = ({ ...@@ -212,8 +198,8 @@ const AddOrEditSkuModal: React.FC<ModalProps & selfProps> = ({
handleCancel(); handleCancel();
}; };
//获取产品列表 //获取产品列表
const getProductList = (categoryId: number) => { const getProductList = () => {
ProduceManageAPI.listPageProductSku({ pageNo: 1, pageSize: 9999, categoryId }).then( ProduceManageAPI.listPageProductSku({ pageNo: 1, pageSize: 9999, type: goodsType }).then(
({ result }) => { ({ result }) => {
setProductList(result.list || []); setProductList(result.list || []);
}, },
...@@ -393,7 +379,6 @@ const AddOrEditSkuModal: React.FC<ModalProps & selfProps> = ({ ...@@ -393,7 +379,6 @@ const AddOrEditSkuModal: React.FC<ModalProps & selfProps> = ({
useEffect(() => { useEffect(() => {
if (Object.keys(curtRowData).length !== 0) { if (Object.keys(curtRowData).length !== 0) {
setDialogTitle('编辑'); setDialogTitle('编辑');
getProductList(curtRowData.categoryId as number);
if (!curtRowData.flag) { if (!curtRowData.flag) {
getProductSpecList(curtRowData.skuId as number); getProductSpecList(curtRowData.skuId as number);
} }
...@@ -424,6 +409,9 @@ const AddOrEditSkuModal: React.FC<ModalProps & selfProps> = ({ ...@@ -424,6 +409,9 @@ const AddOrEditSkuModal: React.FC<ModalProps & selfProps> = ({
setDialogTitle('添加'); setDialogTitle('添加');
} }
}, [curtRowData]); }, [curtRowData]);
useEffect(() => {
getProductList();
}, []);
return ( return (
<div> <div>
<Modal <Modal
......
...@@ -290,7 +290,6 @@ const GoodsAddOrEditOrDetail = () => { ...@@ -290,7 +290,6 @@ const GoodsAddOrEditOrDetail = () => {
open={addOrEditSkuModalShow} open={addOrEditSkuModalShow}
handleCancel={addOrEditSkuModalCancel} handleCancel={addOrEditSkuModalCancel}
handleOk={addOrEditSkuModalOk} handleOk={addOrEditSkuModalOk}
categoryList={categoryList}
skuUnitList={skuUnitList} skuUnitList={skuUnitList}
curtRowData={curtRowData} curtRowData={curtRowData}
goodsType={0} goodsType={0}
......
import React, { FC, useEffect, useState } from 'react'; import React, { FC, useEffect, useState } from 'react';
import { Form, Input, message, Modal, Select, Row, Col, Button, ModalProps, Card } from 'antd'; import { Form, Input, message, Modal, Select, Row, Col, Button, ModalProps } from 'antd';
import { ProduceManageAPI } from '~/api'; import { ProduceManageAPI } from '~/api';
import { InterDataType } from '~/api/interface'; import { InterDataType } from '~/api/interface';
import { cooperationTagType, ProductSpecListType } from '~/api/interface/produceManageType'; import { cooperationTagType, ProductSpecListType } from '~/api/interface/produceManageType';
...@@ -13,23 +13,12 @@ type specType = InterDataType<ProductSpecListType>['list'][0]; ...@@ -13,23 +13,12 @@ type specType = InterDataType<ProductSpecListType>['list'][0];
interface PropsType { interface PropsType {
onCancel: () => void; onCancel: () => void;
data: specType | undefined; data: specType | undefined;
type: number; //产品所属类型
} }
const { Option } = Select; const { Option } = Select;
const SetProduceSpecPriceModal: FC<ModalProps & PropsType> = ({ open, onCancel, data }) => { const SetProduceSpecPriceModal: FC<ModalProps & PropsType> = ({ open, onCancel, data, type }) => {
const tabList = [
{
key: '0',
tab: '销售价格',
},
{
key: '1',
tab: '租赁价格',
},
];
//当前tab
const [currentTab, setCurrentTab] = useState<string>('0');
// 表格事件 // 表格事件
const [form] = Form.useForm(); const [form] = Form.useForm();
// 等级标签列表 // 等级标签列表
...@@ -58,7 +47,6 @@ const SetProduceSpecPriceModal: FC<ModalProps & PropsType> = ({ open, onCancel, ...@@ -58,7 +47,6 @@ const SetProduceSpecPriceModal: FC<ModalProps & PropsType> = ({ open, onCancel,
} }
return pre; return pre;
}, {}); }, {});
console.log('数据-->', setDefaultObj);
form.setFieldsValue({ ...Obj, level: levelNumber, ...setDefaultObj }); form.setFieldsValue({ ...Obj, level: levelNumber, ...setDefaultObj });
} else { } else {
//如果没有返回价格,清楚上一次选择的租期价格 //如果没有返回价格,清楚上一次选择的租期价格
...@@ -97,16 +85,7 @@ const SetProduceSpecPriceModal: FC<ModalProps & PropsType> = ({ open, onCancel, ...@@ -97,16 +85,7 @@ const SetProduceSpecPriceModal: FC<ModalProps & PropsType> = ({ open, onCancel,
}; };
// 关闭弹窗 // 关闭弹窗
const handleClosed = () => { const handleClosed = () => {
setCurrentTab('0'); form.resetFields();
const data = Object.fromEntries(
selectList.map((i) => {
return [i, undefined];
}),
);
form.setFieldsValue({
0: undefined,
...data,
});
setSelectList([]); setSelectList([]);
onCancel(); onCancel();
}; };
...@@ -124,7 +103,7 @@ const SetProduceSpecPriceModal: FC<ModalProps & PropsType> = ({ open, onCancel, ...@@ -124,7 +103,7 @@ const SetProduceSpecPriceModal: FC<ModalProps & PropsType> = ({ open, onCancel,
ProduceManageAPI[isEdit ? 'editProductSpecPrice' : 'setProductSpecPrice']({ ProduceManageAPI[isEdit ? 'editProductSpecPrice' : 'setProductSpecPrice']({
specPrice, specPrice,
productSpecId: data?.id, productSpecId: data?.id,
type: Number(currentTab), type: type,
leaseTerm: values.leaseTerm, leaseTerm: values.leaseTerm,
}).then(({ code }) => { }).then(({ code }) => {
if (code === '200') { if (code === '200') {
...@@ -151,30 +130,15 @@ const SetProduceSpecPriceModal: FC<ModalProps & PropsType> = ({ open, onCancel, ...@@ -151,30 +130,15 @@ const SetProduceSpecPriceModal: FC<ModalProps & PropsType> = ({ open, onCancel,
} }
return Promise.resolve(); return Promise.resolve();
}; };
//tab change
const onTabChange = (key: string) => {
form.resetFields();
switch (key) {
case '0':
getProductSpecPrice(Number(key), data?.id);
break;
case '1':
getProductSpecPrice(Number(key), data?.id, 0);
break;
}
setSelectList([]);
setCurrentTab(key);
};
//租期选择 //租期选择
const rentDateChange = (value: string) => { const rentDateChange = (value: string) => {
getProductSpecPrice(Number(currentTab), data?.id, Number(value)); getProductSpecPrice(type, data?.id, Number(value));
}; };
// componentsDidMounted // componentsDidMounted
useEffect(() => { useEffect(() => {
if (data) { if (data) {
getTagNameList(); getTagNameList();
getProductSpecPrice(Number(currentTab), data?.id); getProductSpecPrice(type, data?.id, type === 0 ? undefined : 0);
} }
}, [data]); }, [data]);
return ( return (
...@@ -193,88 +157,80 @@ const SetProduceSpecPriceModal: FC<ModalProps & PropsType> = ({ open, onCancel, ...@@ -193,88 +157,80 @@ const SetProduceSpecPriceModal: FC<ModalProps & PropsType> = ({ open, onCancel,
</Button>, </Button>,
]} ]}
> >
<Card tabList={tabList} onTabChange={onTabChange}> <Form name='form' form={form} layout='horizontal' labelWrap initialValues={{ leaseTerm: 0 }}>
<Form {type === 1 && (
name='form'
form={form}
layout='horizontal'
labelWrap
initialValues={{ leaseTerm: 0 }}
>
{currentTab === '1' && (
<Form.Item
label='租期'
labelCol={{ span: 5 }}
wrapperCol={{ span: 15 }}
name='leaseTerm'
rules={[{ required: true, message: '请选择租期' }]}
>
<Select onChange={rentDateChange}>
<Select.Option value={0}>1-7天</Select.Option>
<Select.Option value={1}>8-15天</Select.Option>
<Select.Option value={2}>16-30天</Select.Option>
<Select.Option value={3}>31天以上</Select.Option>
</Select>
</Form.Item>
)}
<Form.Item <Form.Item
label='渠道等级' label='租期'
name='level'
rules={[{ required: true, message: '请选择渠道等级' }]}
labelCol={{ span: 5 }} labelCol={{ span: 5 }}
wrapperCol={{ span: 15 }} wrapperCol={{ span: 15 }}
name='leaseTerm'
rules={[{ required: true, message: '请选择租期' }]}
> >
<Select <Select onChange={rentDateChange}>
placeholder='请选择渠道等级' <Select.Option value={0}>1-7天</Select.Option>
allowClear <Select.Option value={1}>8-15天</Select.Option>
mode='multiple' <Select.Option value={2}>16-30天</Select.Option>
onChange={handleChange} <Select.Option value={3}>31天以上</Select.Option>
value={selectList}
>
{tagInfoList.map((i, j) => (
<Option value={i.id} key={j}>
{i.tagName}
</Option>
))}
</Select> </Select>
</Form.Item> </Form.Item>
<Row> )}
<Form.Item
label='渠道等级'
name='level'
rules={[{ required: true, message: '请选择渠道等级' }]}
labelCol={{ span: 5 }}
wrapperCol={{ span: 15 }}
>
<Select
placeholder='请选择渠道等级'
allowClear
mode='multiple'
onChange={handleChange}
value={selectList}
>
{tagInfoList.map((i, j) => (
<Option value={i.id} key={j}>
{i.tagName}
</Option>
))}
</Select>
</Form.Item>
<Row>
<Col span={20}>
<Form.Item
name='0'
label='市场单价'
rules={[{ required: true, validator: priceValidator }]}
labelCol={{ span: 6 }}
wrapperCol={{ span: 18 }}
>
<Input placeholder='请输入市场单价' maxLength={11} allowClear />
</Form.Item>
</Col>
<Col span={4}>
<div style={{ margin: '6px 0 0 10px' }}>元/件</div>
</Col>
</Row>
{selectList.map((i, j) => (
<Row key={j}>
<Col span={20}> <Col span={20}>
<Form.Item <Form.Item
name='0' name={i}
label='市场单价' label={transValtoLabel(i)}
rules={[{ required: true, validator: priceValidator }]} rules={[{ required: true, validator: priceValidator }]}
key={j}
labelCol={{ span: 6 }} labelCol={{ span: 6 }}
wrapperCol={{ span: 18 }} wrapperCol={{ span: 18 }}
> >
<Input placeholder='请输入市场单价' maxLength={11} allowClear /> <Input placeholder='请输入定价金额' maxLength={11} allowClear />
</Form.Item> </Form.Item>
</Col> </Col>
<Col span={4}> <Col span={4}>
<div style={{ margin: '6px 0 0 10px' }}>元/件</div> <div style={{ margin: '6px 0 0 10px' }}>元/件</div>
</Col> </Col>
</Row> </Row>
{selectList.map((i, j) => ( ))}
<Row key={j}> </Form>
<Col span={20}>
<Form.Item
name={i}
label={transValtoLabel(i)}
rules={[{ required: true, validator: priceValidator }]}
key={j}
labelCol={{ span: 6 }}
wrapperCol={{ span: 18 }}
>
<Input placeholder='请输入定价金额' maxLength={11} allowClear />
</Form.Item>
</Col>
<Col span={4}>
<div style={{ margin: '6px 0 0 10px' }}>元/件</div>
</Col>
</Row>
))}
</Form>
</Card>
</Modal> </Modal>
); );
}; };
......
...@@ -245,6 +245,7 @@ function ProduceDetail() { ...@@ -245,6 +245,7 @@ function ProduceDetail() {
open={produceSpecPriceModalShow} open={produceSpecPriceModalShow}
onCancel={produceSpecPriceModalCancel} onCancel={produceSpecPriceModalCancel}
data={addEditData} data={addEditData}
type={detailData?.type || 0}
/> />
</div> </div>
); );
......
...@@ -209,30 +209,15 @@ function ProduceManage() { ...@@ -209,30 +209,15 @@ function ProduceManage() {
pagination.pageSize = Number(searchParams.get('pageSize') || 10); pagination.pageSize = Number(searchParams.get('pageSize') || 10);
(searchRef.current as any).getForm().setFieldsValue({ (searchRef.current as any).getForm().setFieldsValue({
productName: searchParams.get('productName') || undefined, productName: searchParams.get('productName') || undefined,
directoryId: searchParams.get('directoryId') type: searchParams.get('type') ? Number(searchParams.get('type')) : undefined,
? Number(searchParams.get('directoryId'))
: undefined,
categoryId: searchParams.get('categoryId')
? Number(searchParams.get('categoryId'))
: undefined,
}); });
setQuery({ setQuery({
productName: searchParams.get('productName') || undefined, productName: searchParams.get('productName') || undefined,
directoryId: searchParams.get('directoryId') type: searchParams.get('type') ? Number(searchParams.get('type')) : undefined,
? Number(searchParams.get('directoryId'))
: undefined,
categoryId: searchParams.get('categoryId')
? Number(searchParams.get('categoryId'))
: undefined,
}); });
getProduceList({ getProduceList({
productName: searchParams.get('productName') || undefined, productName: searchParams.get('productName') || undefined,
directoryId: searchParams.get('directoryId') type: searchParams.get('type') ? Number(searchParams.get('type')) : undefined,
? Number(searchParams.get('directoryId'))
: undefined,
categoryId: searchParams.get('categoryId')
? Number(searchParams.get('categoryId'))
: undefined,
}); });
}, []); }, []);
......
...@@ -290,7 +290,6 @@ const GoodsAddOrEditOrDetail = () => { ...@@ -290,7 +290,6 @@ const GoodsAddOrEditOrDetail = () => {
open={addOrEditSkuModalShow} open={addOrEditSkuModalShow}
handleCancel={addOrEditSkuModalCancel} handleCancel={addOrEditSkuModalCancel}
handleOk={addOrEditSkuModalOk} handleOk={addOrEditSkuModalOk}
categoryList={categoryList}
skuUnitList={skuUnitList} skuUnitList={skuUnitList}
curtRowData={curtRowData} curtRowData={curtRowData}
goodsType={1} goodsType={1}
......
...@@ -117,6 +117,9 @@ const AddOrEditServiceModal: FC<ModalProps & selfProps> = ({ ...@@ -117,6 +117,9 @@ const AddOrEditServiceModal: FC<ModalProps & selfProps> = ({
if (code === '200') { if (code === '200') {
message.success(currentServiceData ? '编辑服务成功' : '新增服务成功'); message.success(currentServiceData ? '编辑服务成功' : '新增服务成功');
form.resetFields(); form.resetFields();
setCoverPlanFileList([]);
setVideoFileList([]);
setShareCardFileList([]);
handleOk(); handleOk();
} }
}); });
...@@ -124,6 +127,9 @@ const AddOrEditServiceModal: FC<ModalProps & selfProps> = ({ ...@@ -124,6 +127,9 @@ const AddOrEditServiceModal: FC<ModalProps & selfProps> = ({
}; };
const onCancel = () => { const onCancel = () => {
form.resetFields(); form.resetFields();
setCoverPlanFileList([]);
setVideoFileList([]);
setShareCardFileList([]);
handleCancel(); handleCancel();
}; };
//获取单位列表 //获取单位列表
...@@ -175,10 +181,6 @@ const AddOrEditServiceModal: FC<ModalProps & selfProps> = ({ ...@@ -175,10 +181,6 @@ const AddOrEditServiceModal: FC<ModalProps & selfProps> = ({
}, },
]); ]);
} }
} else {
setCoverPlanFileList([]);
setVideoFileList([]);
setShareCardFileList([]);
} }
}, [currentServiceData]); }, [currentServiceData]);
......
...@@ -63,7 +63,6 @@ const AddEditModal: FC<propType> = (props) => { ...@@ -63,7 +63,6 @@ const AddEditModal: FC<propType> = (props) => {
if (!open) return; if (!open) return;
if (!data) return; if (!data) return;
form.setFieldsValue(data); form.setFieldsValue(data);
// console.log('data --->', data);
}, [open]); }, [open]);
return ( return (
<Modal <Modal
...@@ -95,11 +94,7 @@ const AddEditModal: FC<propType> = (props) => { ...@@ -95,11 +94,7 @@ const AddEditModal: FC<propType> = (props) => {
> >
<Input placeholder={'请输入文章来源'} maxLength={50} allowClear /> <Input placeholder={'请输入文章来源'} maxLength={50} allowClear />
</Form.Item> </Form.Item>
<Form.Item <Form.Item label='文章详情' name='caseContents'>
label='文章详情'
name='caseContents'
rules={[{ required: true, message: '请输入文章详情' }]}
>
<RichText <RichText
value={form.getFieldValue('caseContents')} value={form.getFieldValue('caseContents')}
onChange={(e) => form.setFieldValue('caseContents', e)} onChange={(e) => form.setFieldValue('caseContents', e)}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论