提交 a8f737ae 作者: 龚洪江

修复:产品价格配置

上级 267240fc
// 分类详情
import { InterFunction, InterItemFunction } from '~/api/interface';
export interface GoodsInfo {
goodsId: number;
goodsImg: string;
goodsName: string;
shelfStatus: number;
showCode: number;
}
// 分类列表
export interface categoryEntity {
id: number;
......@@ -75,3 +65,10 @@ export type directoryProductType = InterFunction<
type: number;
}[]
>;
//分类-详情
export type categoryDetailsType = InterFunction<
{ id: number },
{ classifyName: string; description: string; icon: string; id: number; remark: string }
>;
//分类-关联列表
export type categoryRelevantType = InterFunction<{ id: number; type: number }, any>;
......@@ -21,6 +21,7 @@ export type listGoodsType = InterItemFunction<
imgUrl: string;
isCoupons: number;
status: number;
id: number;
}[]
>;
//商品-新增
......@@ -100,3 +101,5 @@ export type skuUnitType = InterFunction<any, { id: number; unitName: string }[]>
export type batchOnShelfOrTakeDownType = InterFunction<{ goodsIds: number[]; status: number }, any>;
//商品批量删除
export type batchRemoveWareInfoType = InterFunction<number[], any>;
//商品-上下移动
export type exchangeGoodsInfoType = InterFunction<{ firstId: number; secondId: number }, any>;
......@@ -144,6 +144,7 @@ export type serviceType = InterItemFunction<
industryId: number;
id: number;
companyId: number;
sort: number;
}[]
>;
//服务-上下架-批量
......@@ -171,3 +172,5 @@ export type serviceDetailType = InterFunction<
companyName: string;
}
>;
//服务-上下移动
export type exChangeServiceType = InterFunction<{ id: number; sort: number }[], any>;
......@@ -140,7 +140,7 @@ export type editProductSpecPriceType = InterFunction<
productSpecId?: number;
specPrice: { cooperationTag: number; price: number }[];
type: number;
},
}[],
null
>;
//加盟标签-列表
......
import axios from '../request';
import {
categoryDetailsType,
categoryListType,
categoryRelevantType,
directoryListType,
directoryPageListType,
GoodsInfo,
} from '~/api/interface/categoryManage';
export class CategoryManageAPI {
......@@ -24,9 +25,12 @@ export class CategoryManageAPI {
return axios.get('/pms/classify/getDirectoryList', { params });
};
// 新增或编辑目录
static addOrEditDirectory = (
data: { id?: number; directoryName: string; type: number; show: number[] },
) => {
static addOrEditDirectory = (data: {
id?: number;
directoryName: string;
type: number;
show: number[];
}) => {
return axios.post('/pms/classify/addOrEditDirectory', data);
};
......@@ -49,16 +53,6 @@ export class CategoryManageAPI {
return axios.post('/pms/classify/getClassificationList', data);
};
// PC端-根据分类信息新增自定义规格-下拉选项 (只查产品类型)
static getProductTypeInfoList = (): any => {
return axios.get('uavgoods/mgoods/getGoodsTypeInfoList');
};
// 所有分类信息
static getGoodsTypeListByOneLevel = (): any => {
return axios.get('uavgoods/mgoods/listGoodsTypeListByOneLevel');
};
// 分类修改
static updateClassification = (data: object): any => {
return axios.post('/pms/classify/updateClassification', data);
......@@ -69,35 +63,20 @@ export class CategoryManageAPI {
return axios.get('/pms/classify/deleteRelevantBusiness', { params });
};
// 删除子分类
static deleteGoodsTypeByChildren = (params: object): any => {
return axios.get('uavgoods/mgoods/deleteGoodsTypeByChildren', { params });
};
// 查询二级分类
static listGoodsTypeListByTwoLevel = (params: object): any => {
return axios.get('uavgoods/mgoods/listGoodsTypeListByTwoLevel', { params });
};
// 查询其它服务
static listOtherService = (): any => {
return axios.get('uavgoods/mgoods/listOtherService');
};
// 分类上下移动
static exchangeSortType = (params: object): any => {
return axios.get('/pms/classify/exchangeSortType', { params });
};
// 分类详情
static getGoodsTypeDetail = (obj: { id: number }) => {
return axios.get('/pms/classify/getClassifyDetails', { params: obj });
static getGoodsTypeDetail: categoryDetailsType = (params) => {
return axios.get('/pms/classify/getClassifyDetails', { params });
};
// 分类详情-安全编码开发修改
static updateIsShowCode = (params: Pick<GoodsInfo, 'goodsId' | 'showCode'>) => {
return axios.get('uavgoods/appgoods/updateIsShowCode', { params });
};
// static updateIsShowCode = (params: Pick<GoodsInfo, 'goodsId' | 'showCode'>) => {
// return axios.get('uavgoods/appgoods/updateIsShowCode', { params });
// };
// 分类详情-商品排序
static exchangeGoodsInfo = (firstId: number, secondId: number) => {
......@@ -114,4 +93,8 @@ export class CategoryManageAPI {
static getAppletQRCode(params: { page: string; scene: string }) {
return axios.get('malluser/wechat/getAppletQRCode', { params });
}
// 分类关联列表
static getRelevantBusiness: categoryRelevantType = (params) => {
return axios.get('/pms/classify/queryRelevantBusiness', { params });
};
}
......@@ -4,6 +4,7 @@ import {
batchRemoveWareInfoType,
detailGoodsType,
editGoodsType,
exchangeGoodsInfoType,
listGoodsType,
otherServiceType,
skuUnitType,
......@@ -43,5 +44,9 @@ class GoodsAPI {
static batchRemoveWareInfo: batchRemoveWareInfoType = (data) => {
return axios.post('/pms/goods/batchRemoveWareInfo', data);
};
// 商品-上下移动
static exchangeGoodsInfo: exchangeGoodsInfoType = (params) => {
return axios.get('/pms/goods/exchangeGoodsInfo', { params });
};
}
export default GoodsAPI;
......@@ -12,6 +12,7 @@ import {
batchUpAndDownWorkServiceType,
deleteServiceType,
serviceDetailType,
exChangeServiceType,
} from '~/api/interface/mallManageType';
export class MallManageAPI {
......@@ -52,4 +53,7 @@ export class MallManageAPI {
// 服务-详情
static getServiceDetail: serviceDetailType = (params) =>
axios.get('/pms/backstage/work/queryWorkService', { params });
// 服务-上下移
static exChangeService: exChangeServiceType = (data) =>
axios.post('/pms/backstage/work/exchange', data);
}
......@@ -206,11 +206,11 @@ const AddOrEditSkuModal: React.FC<ModalProps & selfProps> = ({
);
};
//产品-规格
const getProductSpecList = (productSkuId: number) => {
const getProductSpecList = (productSkuId: number, isDetail?: boolean) => {
ProduceManageAPI.listPageProductSpec({ pageNo: 1, pageSize: 9999, productSkuId }).then(
({ result }) => {
setProductSpecList(result.list || []);
if (result.list) {
if (result.list && !isDetail) {
const ids: number[] = result.list.reduce((pre: number[], cur) => {
return cur.priceList || goodsType === 1 ? [...pre, cur.id] : pre;
}, []);
......@@ -380,7 +380,7 @@ const AddOrEditSkuModal: React.FC<ModalProps & selfProps> = ({
if (Object.keys(curtRowData).length !== 0) {
setDialogTitle('编辑');
if (!curtRowData.flag) {
getProductSpecList(curtRowData.skuId as number);
getProductSpecList(curtRowData.skuId as number, true);
}
const specIds: number[] =
curtRowData.specIds && curtRowData.specIds.map((i: any) => i.mallSpecId);
......
......@@ -5,10 +5,6 @@ import './index.scss';
import { ColumnsType } from 'antd/es/table';
import { customizeEntity, skuUnitType, specEntity } from '~/api/interface/goodsType';
import { InterDataType } from '~/api/interface';
import { categoryListType } from '~/api/interface/categoryManage';
//分类返回类型
type categoryType = InterDataType<categoryListType>['list'];
//产品-规格单位返回类型
type unitType = InterDataType<skuUnitType>;
......@@ -16,7 +12,6 @@ type unitType = InterDataType<skuUnitType>;
interface selfProps {
addOrEditSku: (record?: specEntity) => void;
specData: specEntity[];
categoryList: categoryType;
skuUnitList: unitType;
deleteSku: (record: specEntity) => void;
isDetail: boolean;
......@@ -25,7 +20,6 @@ interface selfProps {
const StockSku: React.FC<selfProps> = ({
addOrEditSku,
specData,
categoryList,
skuUnitList,
deleteSku,
isDetail,
......
import { DeleteOutlined, EditOutlined, PlusOutlined } from '@ant-design/icons';
import { Tag, Space, Button, Table, Pagination, message, Modal } from 'antd';
import { Space, Button, Table, message, Modal } from 'antd';
import { ColumnsType, TablePaginationConfig } from 'antd/es/table';
import type { FilterValue, SorterResult } from 'antd/es/table/interface';
import { FC, useEffect, useState } from 'react';
import { useEffect, useState } from 'react';
import { CategoryManageAPI } from '~/api';
import { categoryEntity, categoryDec } from '~/api/interface/categoryManage';
import { categoryDec } from '~/api/interface/categoryManage';
import AddOrEditDec from './components/addOrEditDec';
interface DataType {
title: string;
dataIndex: string;
key: string;
align: string;
}
const typeOptions = [
{
value: 0,
......@@ -29,7 +21,7 @@ const typeOptions = [
},
{
value: 3,
label: '飞手服务分类',
label: '飞手培训分类',
},
{
value: 4,
......@@ -37,7 +29,7 @@ const typeOptions = [
},
];
const DirectoryManage: FC = (props: any) => {
const DirectoryManage = () => {
const [data, setData] = useState<categoryDec[]>(); //table数据
const [loading, setLoading] = useState(false); //table获取数据的loading
const [pagination, setPagination] = useState<TablePaginationConfig>({
......@@ -52,7 +44,7 @@ const DirectoryManage: FC = (props: any) => {
const [isAddOrEditDecModal, setIsAddOrEditDecModal] = useState<boolean>(false);
const [editData, setEditData] = useState<categoryDec | null>(null);
const columns: ColumnsType<DataType> = [
const columns: ColumnsType<categoryDec> = [
{
title: '目录名称',
dataIndex: 'directoryName',
......@@ -70,7 +62,7 @@ const DirectoryManage: FC = (props: any) => {
});
return <div>{find?.label}</div>;
},
} /*
} /*
{
title: '目录类型',
dataIndex: 'directoryType',
......@@ -132,7 +124,7 @@ const DirectoryManage: FC = (props: any) => {
pageNo: pagination!.current!,
pageSize: pagination!.pageSize!,
})
.then((res) => {
.then((res: any) => {
setData(
res.result?.list.map((item: categoryDec) => {
if (item.pid) {
......@@ -151,7 +143,7 @@ const DirectoryManage: FC = (props: any) => {
total: res.result.totalCount,
});
})
.catch((err) => {
.catch(() => {
setData([]);
setLoading(false);
});
......@@ -163,7 +155,7 @@ const DirectoryManage: FC = (props: any) => {
title: '目录删除',
content: '确认删除该目录?',
onOk() {
CategoryManageAPI.removeDirectory(id).then((res) => {
CategoryManageAPI.removeDirectory(id).then((res: any) => {
if (res.code == 200) {
message.success('删除成功');
getDirectoryList();
......@@ -175,13 +167,8 @@ const DirectoryManage: FC = (props: any) => {
});
};
const handleTableChange = (
pagination: TablePaginationConfig,
filters: Record<string, FilterValue>,
sorter: SorterResult<DataType>,
) => {
const handleTableChange = (pagination: TablePaginationConfig) => {
setPagination(pagination);
// `dataSource` is useless since `pageSize` changed
if (pagination.pageSize !== pagination?.pageSize) {
setData([]);
......
......@@ -271,7 +271,6 @@ const GoodsAddOrEditOrDetail = () => {
<StockSku
addOrEditSku={addOrEditSkuShowEvent}
specData={specData}
categoryList={categoryList}
skuUnitList={skuUnitList}
deleteSku={deleteSkuEvent}
isDetail={isDetail}
......
......@@ -19,7 +19,7 @@ import qs from 'query-string';
//商品返回类型
type goodsType = InterDataType<listGoodsType>['list'];
//商品列表筛选类型
type goodsSearchParameters = Omit<InterReqType<listGoodsType>, 'pageNo' | 'pageSize' | 'goodsType'>;
type goodsSearchParameters = Omit<InterReqType<listGoodsType>, 'goodsType'>;
const GoodsList = () => {
//筛选ref
......@@ -101,12 +101,16 @@ const GoodsList = () => {
},
];
const [tableData, setTableData] = useState<goodsType>([]);
const [allGoods, setAllGoods] = useState<goodsType>([]);
const [loading, setLoading] = useState<boolean>(false);
//分页
const [pagination, setPagination] = useState<PaginationProps & { totalCount: number }>({
const [pagination, setPagination] = useState<
PaginationProps & { totalCount: number; totalPage: number }
>({
pageNo: 1,
pageSize: 10,
totalCount: 0,
totalPage: 1,
});
//筛选
const [query, setQuery] = useState<goodsSearchParameters>({ status: undefined });
......@@ -126,6 +130,7 @@ const GoodsList = () => {
}),
);
getGoodsList(query);
getGoodsList({ ...query, pageNo: 1, pageSize: 9999 }, true);
setQuery(query);
setActiveTabKey(key);
};
......@@ -141,6 +146,7 @@ const GoodsList = () => {
}),
);
getGoodsList(query);
getGoodsList({ ...query, pageNo: 1, pageSize: 9999 }, true);
};
//筛选
const searchSuccess = (data: any) => {
......@@ -148,6 +154,10 @@ const GoodsList = () => {
pagination.pageSize = 10;
setQuery({ ...filterObjAttr(data, ['time']), status: query.status });
getGoodsList({ ...filterObjAttr(data, ['time']), status: query.status });
getGoodsList(
{ ...filterObjAttr(data, ['time']), status: query.status, pageSize: 9999, pageNo: 1 },
true,
);
setSearchParams(
qs.stringify({
pageNo: 1,
......@@ -158,7 +168,7 @@ const GoodsList = () => {
);
};
//商品列表
const getGoodsList = (query?: goodsSearchParameters) => {
const getGoodsList = (query?: goodsSearchParameters, isAll?: boolean) => {
setLoading(true);
GoodsAPI.getGoodsList({
pageNo: pagination.pageNo,
......@@ -167,9 +177,14 @@ const GoodsList = () => {
...query,
}).then(({ result }) => {
setLoading(false);
setTableData(result.list || []);
pagination.totalCount = result.totalCount;
setPagination(pagination);
if (isAll) {
setAllGoods(result.list || []);
} else {
setTableData(result.list || []);
pagination.totalCount = result.totalCount;
pagination.totalPage = result.totalPage;
setPagination(pagination);
}
});
};
//新增商品
......@@ -241,11 +256,97 @@ const GoodsList = () => {
},
});
};
//上移
const upGoodsClick = () => {
if (selectedRowKeys.length === 0) {
message.warning('请选择商品');
} else if (selectedRowKeys.length > 1) {
message.warning('最多选择一个商品');
} else {
const index = tableData.findIndex((v) => v.id === selectedRowKeys[0]);
const allIndex = allGoods.findIndex((v) => v.id === selectedRowKeys[0]);
if (index === 0 && pagination.pageNo === 1) {
message.warning('位置已到最前列,无法上移');
} else {
const exReqData =
index === 0
? allGoods
.filter((_v, index) => index === allIndex - 1 || index === allIndex)
.map((v) => ({ id: v.id }))
: tableData
.filter((_v, i) => index - 1 === i || index === i)
.map((v) => ({ id: v.id }));
GoodsAPI.exchangeGoodsInfo({ firstId: exReqData[0].id, secondId: exReqData[1].id }).then(
({ code }) => {
if (code === '200') {
message.success('上移成功');
if (index === 0 && pagination.pageNo !== 1) {
pagination.pageNo -= 1;
setSearchParams(
qs.stringify({
pageNo: pagination.pageNo,
pageSize: pagination.pageSize,
...query,
status: query.status === undefined ? 'all' : query.status,
}),
);
}
getGoodsList(query);
getGoodsList({ ...query, pageNo: 1, pageSize: 9999 }, true);
}
},
);
}
}
};
//下移
const downGoodsClick = () => {
if (selectedRowKeys.length === 0) {
message.warning('请选择商品');
} else if (selectedRowKeys.length > 1) {
message.warning('最多选择一个商品');
} else {
const index = tableData.findIndex((v) => v.id === selectedRowKeys[0]);
const allIndex = allGoods.findIndex((v) => v.id === selectedRowKeys[0]);
if (index === tableData.length - 1 && pagination.pageNo === pagination.totalPage) {
message.warning('位置已到最后,无法下移');
} else {
const exReqData =
index === tableData.length - 1
? allGoods
.filter((_v, index) => index === allIndex + 1 || index === allIndex)
.map((v) => ({ id: v.id }))
: tableData
.filter((_v, i) => index + 1 === i || index === i)
.map((v) => ({ id: v.id }));
GoodsAPI.exchangeGoodsInfo({ firstId: exReqData[0].id, secondId: exReqData[1].id }).then(
({ code }) => {
if (code === '200') {
message.success('下移成功');
if (index === tableData.length - 1 && pagination.pageNo !== pagination.totalPage) {
pagination.pageNo += 1;
setSearchParams(
qs.stringify({
pageNo: pagination.pageNo,
pageSize: pagination.pageSize,
...query,
status: query.status === undefined ? 'all' : query.status,
}),
);
}
getGoodsList(query);
getGoodsList({ ...query, pageNo: 1, pageSize: 9999 }, true);
}
},
);
}
}
};
useEffect(() => {
getDirectoryList();
pagination.pageNo = Number(searchParams.get('pageNo') || 1);
pagination.pageSize = Number(searchParams.get('pageSize') || 10);
getGoodsList({
const queryObj = {
goodsName: searchParams.get('goodsName') || undefined,
directoryId: searchParams.get('directoryId')
? Number(searchParams.get('directoryId'))
......@@ -256,7 +357,9 @@ const GoodsList = () => {
searchParams.get('status') === 'all' || searchParams.get('status') === null
? undefined
: Number(searchParams.get('status')),
});
};
getGoodsList(queryObj);
getGoodsList({ ...queryObj, pageNo: 1, pageSize: 9999 }, true);
setActiveTabKey(
searchParams.get('status') === 'all' || searchParams.get('status') === null
? '1'
......@@ -288,10 +391,20 @@ const GoodsList = () => {
/>
<Card tabList={tabList} activeTabKey={activeTabKey} onTabChange={onTabChange}>
<div className='header-operate' style={{ marginBottom: '10px' }}>
<Button type='primary' style={{ marginRight: '10px' }} icon={<ArrowUpOutlined />}>
<Button
type='primary'
style={{ marginRight: '10px' }}
icon={<ArrowUpOutlined />}
onClick={upGoodsClick}
>
上移
</Button>
<Button type='primary' style={{ marginRight: '10px' }} icon={<ArrowDownOutlined />}>
<Button
type='primary'
style={{ marginRight: '10px' }}
icon={<ArrowDownOutlined />}
onClick={downGoodsClick}
>
下移
</Button>
{activeTabKey !== '2' && (
......
......@@ -86,6 +86,9 @@ const AddOrEditProduceSpecModal: FC<ModalProps & PropsType> = ({
url: data.specImage,
},
]);
} else {
form.resetFields();
setFileList([]);
}
}, [data]);
return (
......
import React, { FC, useEffect, useState } from 'react';
import { Form, Input, message, Modal, Select, Row, Col, Button, ModalProps } from 'antd';
import { ProduceManageAPI } from '~/api';
import { InterDataType } from '~/api/interface';
import { cooperationTagType, ProductSpecListType } from '~/api/interface/produceManageType';
import { filterObjAttr } from '~/utils';
import { InterDataType, InterReqType } from '~/api/interface';
import {
cooperationTagType,
editProductSpecPriceType,
ProductSpecListType,
} from '~/api/interface/produceManageType';
import _ from 'lodash';
//加盟标签返回类型
type cooperationTagResponseType = InterDataType<cooperationTagType>;
//产品规格返回类型
type specType = InterDataType<ProductSpecListType>['list'][0];
//配置价格参数类型
type setPriceParametersType = InterReqType<editProductSpecPriceType>;
interface PropsType {
onCancel: () => void;
......@@ -16,6 +22,25 @@ interface PropsType {
type: number; //产品所属类型
}
const rentDateData = [
{
value: 0,
label: '1-7天',
},
{
value: 1,
label: '8-15天',
},
{
value: 2,
label: '16-30天',
},
{
value: 3,
label: '31天以上',
},
];
const { Option } = Select;
const SetProduceSpecPriceModal: FC<ModalProps & PropsType> = ({ open, onCancel, data, type }) => {
......@@ -25,42 +50,50 @@ const SetProduceSpecPriceModal: FC<ModalProps & PropsType> = ({ open, onCancel,
const [tagInfoList, setTagInfoList] = useState<cooperationTagResponseType>([]);
// 选择的列表
const [selectList, setSelectList] = useState<number[]>([]);
//是否编辑
const [isEdit, setIsEdit] = useState<boolean>(false);
//配置价格参数
const [priceParameters, setPriceParameters] = useState<setPriceParametersType>([]);
//当前租期
const [currentLeaseTerm, setCurrentLeaseTerm] = useState<number>(0);
// 获取当前规格的价格
const getProductSpecPrice = (type: number, productSpecId?: number, leaseTerm?: number) => {
ProduceManageAPI.getProductSpecPrice({ type, productSpecId, leaseTerm }).then(({ result }) => {
setIsEdit(!!result.length);
const levelNumber: number[] = result
const priceInfoList =
type === 1
? //租赁
rentDateData.map((v) => {
const specPrice = result
.filter((i) => i.leaseTerm === v.value) //type 判断商城商品
.map((v) => ({ cooperationTag: v.cooperationTag, id: v.id, price: v.price }));
return {
leaseTerm: v.value,
productSpecId: data?.id,
specPrice,
type: type,
};
})
: //销售商品
[
{
productSpecId: data?.id,
specPrice: result.map((v) => ({
cooperationTag: v.cooperationTag,
id: v.id,
price: v.price,
})),
type: type,
},
];
setPriceParameters(priceInfoList);
const levelNumber: number[] = priceInfoList[0].specPrice
.filter((v) => v.cooperationTag != 0)
.map((v) => v.cooperationTag);
const Obj: any = result.reduce((pre: any, cur) => {
const Obj: any = priceInfoList[0].specPrice.reduce((pre: any, cur) => {
pre[cur.cooperationTag] = cur.price;
return { ...pre };
}, {});
if (result.length) {
//没有设置价格的清空
const setDefaultObj = tagInfoList.reduce((pre: any, cur) => {
if (!Object.keys(Obj).includes(cur.id.toString())) {
pre[cur.id] = undefined;
}
return pre;
}, {});
form.setFieldsValue({ ...Obj, level: levelNumber, ...setDefaultObj });
} else {
//如果没有返回价格,清楚上一次选择的租期价格
const defaultObj = tagInfoList.reduce((pre: any, cur) => {
pre[cur.id] = undefined;
return pre;
}, {});
form.setFieldsValue({
0: undefined,
level: undefined,
...defaultObj,
});
}
const arr = result
form.setFieldsValue({ ...Obj, level: levelNumber });
const arr = priceInfoList[0].specPrice
.map((i) => {
return i.cooperationTag;
})
......@@ -94,23 +127,29 @@ const SetProduceSpecPriceModal: FC<ModalProps & PropsType> = ({ open, onCancel,
form
.validateFields()
.then(async (values) => {
const specPrice = Object.keys(filterObjAttr(values, ['leaseTerm', 'level'])).reduce(
(pre: any, cur: string) => {
const specPrice = Object.getOwnPropertyNames(values)
.filter((v) => !['leaseTerm', 'level'].includes(v))
.reduce((pre: any, cur: string) => {
return [...pre, { price: values[cur], cooperationTag: Number(cur) }];
},
[],
);
ProduceManageAPI[isEdit ? 'editProductSpecPrice' : 'setProductSpecPrice']({
specPrice,
productSpecId: data?.id,
type: type,
leaseTerm: values.leaseTerm,
}).then(({ code }) => {
if (code === '200') {
message.success('操作成功');
handleClosed();
}, []);
if (priceParameters) {
priceParameters[currentLeaseTerm].specPrice = specPrice;
const obj = priceParameters
.filter((v) => v.specPrice.length)
.find((v) => v.specPrice.some((v) => v.price === undefined));
if (obj && !_.isNull(obj.leaseTerm)) {
return message.warning(`${rentDateData[obj.leaseTerm!].label}存在价格未配置`);
}
});
setPriceParameters([...priceParameters]);
ProduceManageAPI['editProductSpecPrice'](
priceParameters.filter((v) => v.specPrice.length),
).then(({ code }) => {
if (code === '200') {
message.success('操作成功');
handleClosed();
}
});
}
})
.catch((err) => {
message.warning(err.errorFields[0].errors[0]).then();
......@@ -132,7 +171,51 @@ const SetProduceSpecPriceModal: FC<ModalProps & PropsType> = ({ open, onCancel,
};
//租期选择
const rentDateChange = (value: string) => {
getProductSpecPrice(type, data?.id, Number(value));
const values = form.getFieldsValue();
const specPrice = Object.getOwnPropertyNames(values)
.filter((v) => !['leaseTerm', 'level'].includes(v))
.reduce((pre: any, cur: string) => {
return [...pre, { price: values[cur], cooperationTag: Number(cur) }];
}, []);
if (priceParameters) {
priceParameters[currentLeaseTerm].specPrice = specPrice;
setPriceParameters([...priceParameters]);
}
setCurrentLeaseTerm(Number(value));
if (priceParameters && priceParameters[Number(value)].specPrice.length) {
const Obj: any = priceParameters[Number(value)].specPrice.reduce((pre: any, cur) => {
pre[cur.cooperationTag] = cur.price;
return { ...pre };
}, {});
const levelNumber: number[] = priceParameters[Number(value)].specPrice
.filter((v) => v.cooperationTag != 0)
.map((v) => v.cooperationTag);
//没有设置价格的清空
const setDefaultObj = tagInfoList.reduce((pre: any, cur) => {
if (!Object.keys(Obj).includes(cur.id.toString())) {
pre[cur.id] = undefined;
}
return pre;
}, {});
form.setFieldsValue({ ...Obj, level: levelNumber, ...setDefaultObj });
const arr = priceParameters[Number(value)].specPrice
.map((i) => {
return i.cooperationTag;
})
.filter((i: number) => i !== 0);
setSelectList(arr);
} else {
const defaultObj = tagInfoList.reduce((pre: any, cur) => {
pre[cur.id] = undefined;
return pre;
}, {});
form.setFieldsValue({
0: undefined,
level: undefined,
...defaultObj,
});
setSelectList([]);
}
};
// componentsDidMounted
useEffect(() => {
......@@ -167,10 +250,11 @@ const SetProduceSpecPriceModal: FC<ModalProps & PropsType> = ({ open, onCancel,
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>
{rentDateData.map((v) => (
<Select.Option value={v.value} key={v.value}>
{v.label}
</Select.Option>
))}
</Select>
</Form.Item>
)}
......
......@@ -163,6 +163,7 @@ function ProduceDetail() {
};
const produceSpecPriceModalCancel = () => {
setProduceSpecPriceModalShow(false);
setAddEditData(undefined);
};
// 返回上一页
const handleBack = () => {
......
......@@ -271,7 +271,6 @@ const GoodsAddOrEditOrDetail = () => {
<StockSku
addOrEditSku={addOrEditSkuShowEvent}
specData={specData}
categoryList={categoryList}
skuUnitList={skuUnitList}
deleteSku={deleteSkuEvent}
isDetail={isDetail}
......
......@@ -19,7 +19,7 @@ import qs from 'query-string';
//商品返回类型
type goodsType = InterDataType<listGoodsType>['list'];
//商品列表筛选类型
type goodsSearchParameters = Omit<InterReqType<listGoodsType>, 'pageNo' | 'pageSize' | 'goodsType'>;
type goodsSearchParameters = Omit<InterReqType<listGoodsType>, 'goodsType'>;
const RentList = () => {
//筛选ref
const searchRef = useRef();
......@@ -100,12 +100,16 @@ const RentList = () => {
},
];
const [tableData, setTableData] = useState<goodsType>([]);
const [allRentGoods, setAllRentGoods] = useState<goodsType>([]);
const [loading, setLoading] = useState<boolean>(false);
//分页
const [pagination, setPagination] = useState<PaginationProps & { totalCount: number }>({
const [pagination, setPagination] = useState<
PaginationProps & { totalCount: number; totalPage: number }
>({
pageNo: 1,
pageSize: 10,
totalCount: 0,
totalPage: 1,
});
//筛选
const [query, setQuery] = useState<goodsSearchParameters>({ status: undefined });
......@@ -125,6 +129,7 @@ const RentList = () => {
}),
);
getGoodsList(query);
getGoodsList({ ...query, pageNo: 1, pageSize: 9999 }, true);
setQuery(query);
setActiveTabKey(key);
};
......@@ -140,6 +145,7 @@ const RentList = () => {
}),
);
getGoodsList(query);
getGoodsList({ ...query, pageNo: 1, pageSize: 9999 }, true);
};
//筛选
const searchSuccess = (data: any) => {
......@@ -147,6 +153,10 @@ const RentList = () => {
pagination.pageSize = 10;
setQuery({ ...filterObjAttr(data, ['time']), status: query.status });
getGoodsList({ ...filterObjAttr(data, ['time']), status: query.status });
getGoodsList(
{ ...filterObjAttr(data, ['time']), status: query.status, pageNo: 1, pageSize: 9999 },
true,
);
setSearchParams(
qs.stringify({
pageNo: 1,
......@@ -157,7 +167,7 @@ const RentList = () => {
);
};
//商品列表
const getGoodsList = (query?: goodsSearchParameters) => {
const getGoodsList = (query?: goodsSearchParameters, isAll?: boolean) => {
setLoading(true);
GoodsAPI.getGoodsList({
pageNo: pagination.pageNo,
......@@ -166,9 +176,14 @@ const RentList = () => {
...query,
}).then(({ result }) => {
setLoading(false);
setTableData(result.list || []);
pagination.totalCount = result.totalCount;
setPagination(pagination);
if (isAll) {
setAllRentGoods(result.list || []);
} else {
setTableData(result.list || []);
pagination.totalCount = result.totalCount;
pagination.totalPage = result.totalPage;
setPagination(pagination);
}
});
};
//新增商品
......@@ -238,11 +253,98 @@ const RentList = () => {
},
});
};
//上移
const upGoodsRentClick = () => {
if (selectedRowKeys.length === 0) {
message.warning('请选择商品');
} else if (selectedRowKeys.length > 1) {
message.warning('最多选择一个商品');
} else {
const index = tableData.findIndex((v) => v.id === selectedRowKeys[0]);
const allIndex = allRentGoods.findIndex((v) => v.id === selectedRowKeys[0]);
if (index === 0 && pagination.pageNo === 1) {
message.warning('位置已到最前列,无法上移');
} else {
const exReqData =
index === 0
? allRentGoods
.filter((_v, index) => index === allIndex - 1 || index === allIndex)
.map((v) => ({ id: v.id }))
: tableData
.filter((_v, i) => index - 1 === i || index === i)
.map((v) => ({ id: v.id }));
GoodsAPI.exchangeGoodsInfo({ firstId: exReqData[0].id, secondId: exReqData[1].id }).then(
({ code }) => {
if (code === '200') {
message.success('上移成功');
if (index === 0 && pagination.pageNo !== 1) {
pagination.pageNo -= 1;
setSearchParams(
qs.stringify({
pageNo: pagination.pageNo,
pageSize: pagination.pageSize,
...query,
status: query.status === undefined ? 'all' : query.status,
}),
);
}
getGoodsList(query);
getGoodsList({ ...query, pageNo: 1, pageSize: 9999 }, true);
}
},
);
}
}
};
//下移
const downRentGoodsClick = () => {
if (selectedRowKeys.length === 0) {
message.warning('请选择商品');
} else if (selectedRowKeys.length > 1) {
message.warning('最多选择一个商品');
} else {
const index = tableData.findIndex((v) => v.id === selectedRowKeys[0]);
const allIndex = allRentGoods.findIndex((v) => v.id === selectedRowKeys[0]);
if (index === tableData.length - 1 && pagination.pageNo === pagination.totalPage) {
message.warning('位置已到最后,无法下移');
} else {
const exReqData =
index === tableData.length - 1
? allRentGoods
.filter((_v, index) => index === allIndex + 1 || index === allIndex)
.map((v) => ({ id: v.id }))
: tableData
.filter((_v, i) => index + 1 === i || index === i)
.map((v) => ({ id: v.id }));
GoodsAPI.exchangeGoodsInfo({ firstId: exReqData[0].id, secondId: exReqData[1].id }).then(
({ code }) => {
if (code === '200') {
message.success('下移成功');
if (index === tableData.length - 1 && pagination.pageNo !== pagination.totalPage) {
pagination.pageNo += 1;
setSearchParams(
qs.stringify({
pageNo: pagination.pageNo,
pageSize: pagination.pageSize,
...query,
status: query.status === undefined ? 'all' : query.status,
}),
);
}
getGoodsList(query);
getGoodsList({ ...query, pageNo: 1, pageSize: 9999 }, true);
}
},
);
}
}
};
useEffect(() => {
getDirectoryList();
pagination.pageNo = Number(searchParams.get('pageNo') || 1);
pagination.pageSize = Number(searchParams.get('pageSize') || 10);
getGoodsList({
const queryObj = {
goodsName: searchParams.get('goodsName') || undefined,
directoryId: searchParams.get('directoryId')
? Number(searchParams.get('directoryId'))
......@@ -253,7 +355,9 @@ const RentList = () => {
searchParams.get('status') === 'all' || searchParams.get('status') === null
? undefined
: Number(searchParams.get('status')),
});
};
getGoodsList(queryObj);
getGoodsList({ ...queryObj, pageSize: 9999, pageNo: 1 }, true);
setActiveTabKey(
searchParams.get('status') === 'all' || searchParams.get('status') === null
? '1'
......@@ -285,10 +389,20 @@ const RentList = () => {
/>
<Card tabList={tabList} activeTabKey={activeTabKey} onTabChange={onTabChange}>
<div className='header-operate' style={{ marginBottom: '10px' }}>
<Button type='primary' style={{ marginRight: '10px' }} icon={<ArrowUpOutlined />}>
<Button
type='primary'
style={{ marginRight: '10px' }}
icon={<ArrowUpOutlined />}
onClick={upGoodsRentClick}
>
上移
</Button>
<Button type='primary' style={{ marginRight: '10px' }} icon={<ArrowDownOutlined />}>
<Button
type='primary'
style={{ marginRight: '10px' }}
icon={<ArrowDownOutlined />}
onClick={downRentGoodsClick}
>
下移
</Button>
{activeTabKey !== '2' && (
......
......@@ -23,7 +23,7 @@ type categoryType = InterDataType<categoryListType>['list'];
//服务返回类型
type serviceListType = InterDataType<serviceType>['list'];
//服务列表请求类型
type serviceParametersType = Omit<InterReqType<serviceType>, 'pageSize' | 'pageNo'>;
type serviceParametersType = InterReqType<serviceType>;
const ServiceList: FC<any> = () => {
const searchRef = useRef<any>();
......@@ -133,14 +133,18 @@ const ServiceList: FC<any> = () => {
},
];
const [loading, setLoading] = useState<boolean>(false);
const [tableData, setTableData] = useState<serviceListType>([]);
const [tableData, setTableData] = useState<serviceListType>([]); //表格数据
const [allServiceData, setAllServiceData] = useState<serviceListType>([]);
const [currentServiceData, setCurrentServiceData] = useState<serviceListType[0]>();
// 表格多选
const [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>([]);
const [pagination, setPagination] = useState<PaginationProps & { totalCount: number }>({
const [pagination, setPagination] = useState<
PaginationProps & { totalCount: number; totalPage: number }
>({
pageNo: 1,
pageSize: 10,
totalCount: 0,
totalPage: 1,
});
//筛选
const [query, setQuery] = useState<serviceParametersType>({
......@@ -166,6 +170,15 @@ const ServiceList: FC<any> = () => {
);
setActiveTabKey(key);
getServiceList({ ...query, displayState: key === '1' ? undefined : key === '2' ? 0 : 1 });
getServiceList(
{
...query,
displayState: key === '1' ? undefined : key === '2' ? 0 : 1,
pageNo: 1,
pageSize: 9999,
},
true,
);
};
//新增服务
const addOrEditServiceModalShow = (record?: serviceListType[0]) => {
......@@ -182,7 +195,7 @@ const ServiceList: FC<any> = () => {
getServiceList(query);
};
//服务-列表
const getServiceList = (query?: serviceParametersType) => {
const getServiceList = (query?: serviceParametersType, isAll?: boolean) => {
setLoading(true);
MallManageAPI.getServiceList({
pageNo: pagination.pageNo,
......@@ -190,9 +203,14 @@ const ServiceList: FC<any> = () => {
...query,
}).then(({ result }) => {
setLoading(false);
setTableData(result.list || []);
pagination.totalCount = result.totalCount;
setPagination(pagination);
if (isAll) {
setAllServiceData(result.list || []);
} else {
setTableData(result.list || []);
pagination.totalCount = result.totalCount;
pagination.totalPage = result.totalPage;
setPagination(pagination);
}
});
};
//行业分类列表
......@@ -283,6 +301,7 @@ const ServiceList: FC<any> = () => {
}),
);
getServiceList(query);
getServiceList({ ...query, pageNo: 1, pageSize: 9999 }, true);
};
// 表格多选事件
const onSelectChange = (newSelectedRowKeys: React.Key[]) => {
......@@ -302,6 +321,7 @@ const ServiceList: FC<any> = () => {
);
setQuery(data);
getServiceList(data);
getServiceList({ ...data, pageNo: 1, pageSize: 9999 }, true);
};
//预览视频
const previewVideo = (url: string) => {
......@@ -311,6 +331,88 @@ const ServiceList: FC<any> = () => {
const previewCancel = () => {
setPreviewShow(false);
};
//上移
const upServiceClick = () => {
if (selectedRowKeys.length === 0) {
message.warning('请选择服务');
} else if (selectedRowKeys.length > 1) {
message.warning('最多选择一个服务');
} else {
const index = tableData.findIndex((v) => v.id === selectedRowKeys[0]);
const allIndex = allServiceData.findIndex((v) => v.id === selectedRowKeys[0]);
if (index === 0 && pagination.pageNo === 1) {
message.warning('位置已到最前列,无法上移');
} else {
const exReqData =
index === 0
? allServiceData
.filter((_v, index) => index === allIndex - 1 || index === allIndex)
.map((v) => ({ id: v.id, sort: v.sort }))
: tableData
.filter((_v, i) => index - 1 === i || index === i)
.map((v) => ({ id: v.id, sort: v.sort }));
MallManageAPI.exChangeService(exReqData).then(({ code }) => {
if (code === '200') {
message.success('上移成功');
if (index === 0 && pagination.pageNo !== 1) {
pagination.pageNo -= 1;
setSearchParams(
qs.stringify({
...query,
pageNo: pagination.pageNo,
pageSize: pagination.pageSize,
displayState: query.displayState === undefined ? 'all' : query.displayState,
}),
);
}
getServiceList(query);
getServiceList({ ...query, pageNo: 1, pageSize: 9999 }, true);
}
});
}
}
};
//下移
const downServiceClick = () => {
if (selectedRowKeys.length === 0) {
message.warning('请选择服务');
} else if (selectedRowKeys.length > 1) {
message.warning('最多选择一个服务');
} else {
const index = tableData.findIndex((v) => v.id === selectedRowKeys[0]);
const allIndex = allServiceData.findIndex((v) => v.id === selectedRowKeys[0]);
if (index === tableData.length - 1 && pagination.pageNo === pagination.totalPage) {
message.warning('位置已到最后,无法下移');
} else {
const exReqData =
index === tableData.length - 1
? allServiceData
.filter((_v, index) => index === allIndex + 1 || index === allIndex)
.map((v) => ({ id: v.id, sort: v.sort }))
: tableData
.filter((_v, i) => index + 1 === i || index === i)
.map((v) => ({ id: v.id, sort: v.sort }));
MallManageAPI.exChangeService(exReqData).then(({ code }) => {
if (code === '200') {
message.success('下移成功');
if (index === tableData.length - 1 && pagination.pageNo !== pagination.totalPage) {
pagination.pageNo += 1;
setSearchParams(
qs.stringify({
...query,
pageNo: pagination.pageNo,
pageSize: pagination.pageSize,
displayState: query.displayState === undefined ? 'all' : query.displayState,
}),
);
}
getServiceList(query);
getServiceList({ ...query, pageNo: 1, pageSize: 9999 }, true);
}
});
}
}
};
useEffect(() => {
pagination.pageNo = Number(searchParams.get('pageNo') || 1);
pagination.pageSize = Number(searchParams.get('pageSize') || 10);
......@@ -345,6 +447,7 @@ const ServiceList: FC<any> = () => {
: '3',
);
getServiceList(queryObj);
getServiceList({ ...queryObj, pageNo: 1, pageSize: 9999 }, true);
getIndustryCategoryList();
getApplicationCategoryList();
}, []);
......@@ -367,10 +470,20 @@ const ServiceList: FC<any> = () => {
/>
<Card tabList={tabList} activeTabKey={activeTabKey} onTabChange={onTabChange}>
<div className='header-operate' style={{ marginBottom: '10px' }}>
<Button type='primary' style={{ marginRight: '10px' }} icon={<ArrowUpOutlined />}>
<Button
type='primary'
style={{ marginRight: '10px' }}
icon={<ArrowUpOutlined />}
onClick={upServiceClick}
>
上移
</Button>
<Button type='primary' style={{ marginRight: '10px' }} icon={<ArrowDownOutlined />}>
<Button
type='primary'
style={{ marginRight: '10px' }}
icon={<ArrowDownOutlined />}
onClick={downServiceClick}
>
下移
</Button>
{activeTabKey !== '2' ? (
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论