Commit edbef29f authored by 武广's avatar 武广

Merge branch 'feature/goods-list' of git.quantgroup.cn:ui/merchant-manage-ui...

Merge branch 'feature/goods-list' of git.quantgroup.cn:ui/merchant-manage-ui into feature/20230327_public_takeaway
parents 8f1a428f 02c6f082
......@@ -40,10 +40,7 @@ const DragTag = ({ text, id, index, changePosition, endChangePosition, edit, del
item.index = hoverIndex; // 将当前当前移动到Box的index赋值给当前拖动的box,不然会出现两个盒子疯狂抖动!
},
drop: (item, monitor) => {
const dragIndex = item.index;
const hoverIndex = index;
if (dragIndex === hoverIndex) return; // 如果回到自己的坑,那就什么都不做
endChangePosition(dragIndex, hoverIndex); // 调用传入的方法完成交换
endChangePosition(); // 调用传入的方法完成交换
},
});
......
......@@ -34,6 +34,7 @@ const GoodsGroup = options => {
};
const getGroupList = async () => {
if (options.shopId) {
const res = await apiStorageList({
shopId: options.shopId,
});
......@@ -50,6 +51,10 @@ const GoodsGroup = options => {
setTags([]);
setSelected(0);
}
} else {
setTags([]);
setSelected(0);
}
};
const handleEdit = async id => {
......@@ -65,20 +70,16 @@ const GoodsGroup = options => {
};
// 更换位置
const changePosition = async (dragIndex, hoverIndex) => {
const changePosition = async (dIndex, hIndex) => {
const data = tags.slice();
const temp = data[dragIndex];
const temp = data[dIndex];
// 交换位置
data[dragIndex] = data[hoverIndex];
data[hoverIndex] = temp;
data[dIndex] = data[hIndex];
data[hIndex] = temp;
setTags(data);
};
const endChangePosition = async (dragIndex, hoverIndex) => {
const endChangePosition = async () => {
const data = tags.slice();
const temp = data[dragIndex];
// 交换位置
data[dragIndex] = data[hoverIndex];
data[hoverIndex] = temp;
const storageRankList = data.map((item, i) => ({
id: item.id,
priority: i + 1,
......
import React from 'react';
import { Modal, Form, Input } from 'antd';
import { Modal, Form, InputNumber } from 'antd';
import styles from '../../style.less';
const MinimumPurchase = options => {
const [form] = Form.useForm();
......@@ -36,12 +37,9 @@ const MinimumPurchase = options => {
<Form.Item
label="最少购买/份"
name="minPurchaseNum"
rules={[
{ required: true, message: '请输入最少购买数量!' },
{ min: 1, message: '最小输入1' },
]}
rules={[{ required: true, message: '请输入最少购买数量!' }]}
>
<Input maxLength={6} type="number" />
<InputNumber min={1} max={999999} className={styles.inputWdith} />
</Form.Item>
</Form>
</Modal>
......
import React, { useState, useEffect, useCallback, useMemo } from 'react';
import { Spin, Table, Modal, message, notification } from 'antd';
import { Spin, Table, Pagination, message, notification } from 'antd';
import { unstable_batchedUpdates } from 'react-dom';
import { MenuOutlined, HolderOutlined, FormOutlined, CloseCircleOutlined } from '@ant-design/icons';
import { SortableContainer, SortableElement, SortableHandle } from 'react-sortable-hoc';
......@@ -21,6 +21,9 @@ const Takeaway = options => {
const [selectedRowKeys, setSelectedRowKeys] = useState([]);
const [shopId, setShopId] = useState(0);
const [groupId, setGroupId] = useState(0);
const [pageNo, setPageNo] = useState(1);
const [pageSize, setPageSize] = useState(50);
const [total, setTotal] = useState(0);
const [loading, setLoading] = useState(false);
const [actionLoading, setActionLoading] = useState(false);
const [visibleWeekTime, setVisibleWeekTime] = useState(false);
......@@ -34,12 +37,12 @@ const Takeaway = options => {
onChange: setSelectedRowKeys,
};
const getDataList = async () => {
const getDataList = async (page, size) => {
setLoading(true);
const params = Object.assign({}, options.searchValue, {
pageNo: 1,
pageNo: page || pageNo,
productType: 5,
pageSize: 100000,
pageSize: size || pageSize,
storageRackId: groupId,
});
const productCategoryId = options.searchValue?.productCategoryId || [];
......@@ -49,15 +52,23 @@ const Takeaway = options => {
setLoading(false);
if (res && res.data) {
setTableData(res.data.records);
setTotal(res.data.total);
}
};
const onPageChange = (page, size) => {
unstable_batchedUpdates(() => {
setPageNo(page);
setPageSize(size);
});
getDataList(page, size);
};
const onSortEnd = async ({ oldIndex, newIndex }) => {
if (oldIndex !== newIndex) {
const newData = arrayMoveImmutable(tableData.slice(), oldIndex, newIndex).filter(el => !!el);
const skuSorts = newData.map((item, index) => ({
skuId: item.skuId,
sort: index + 1,
sort: pageSize * pageNo + index + 1,
}));
const params = {
storageRackId: groupId,
......@@ -98,6 +109,8 @@ const Takeaway = options => {
};
setActionLoading(true);
const res = await apiGoodsActionBatch(Object.assign({}, json, params));
if (res.businessCode === '0000' && res.code === '0000') {
message.success('处理成功!');
unstable_batchedUpdates(() => {
setActionLoading(false);
setVisibleWeekTime(false);
......@@ -107,8 +120,6 @@ const Takeaway = options => {
setVisibleSend(false);
});
getDataList();
if (res.businessCode === '0000' && res.code === '0000') {
message.success('处理成功!');
}
};
......@@ -179,7 +190,7 @@ const Takeaway = options => {
columns={takeawayColumn(actions)}
rowKey={record => record.skuId}
pagination={false}
scroll={{ x: '100%', y: 1000 }}
scroll={{ x: '100%', y: 500 }}
rowSelection={rowSelection}
components={{
body: {
......@@ -188,6 +199,20 @@ const Takeaway = options => {
},
}}
/>
<br />
{(tableData && (
<Pagination
className={styles['takeawayBox--page']}
onChange={onPageChange}
total={total}
showTotal={o => `共${o}条`}
current={pageNo}
pageSize={pageSize}
showSizeChanger
onShowSizeChange={onPageChange}
/>
)) ||
''}
</Spin>
<WeekTime
visible={visibleWeekTime}
......
......@@ -141,6 +141,11 @@
margin-top: 20px;
padding-bottom: 40px;
background-color: #fff;
&--page {
padding-top: 10px;
padding-left: 30px;
text-align: left;
}
}
.groupBox {
padding: 0 24px 15px 24px;
......@@ -283,3 +288,6 @@
width: 100%;
}
}
.inputWdith {
width: 100%;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment