提交 a8f737ae 作者: 龚洪江

修复:产品价格配置

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