Commit 1457a13f authored by 陈万宝's avatar 陈万宝

Merge branch 'feature/20230327_public_takeaway' of...

Merge branch 'feature/20230327_public_takeaway' of http://git.quantgroup.cn/ui/merchant-manage-ui into feature/20230327_public_takeaway
parents aadf31b8 dd6d6ccb
...@@ -170,12 +170,7 @@ class goodsManage extends Component { ...@@ -170,12 +170,7 @@ class goodsManage extends Component {
<Input placeholder="请输入商品名称" allowClear style={selectW} /> <Input placeholder="请输入商品名称" allowClear style={selectW} />
</FormItem> </FormItem>
<FormItem label="商品类型" name="productType"> <FormItem label="商品类型" name="productType">
<Select <Select style={selectW} placeholder="请选择商品类型" onChange={this.onChangeProductType}>
style={selectW}
placeholder="请选择商品类型"
allowClear
onChange={this.onChangeProductType}
>
<Option value={1}>实体商品</Option> <Option value={1}>实体商品</Option>
<Option value={2}>虚拟商品</Option> <Option value={2}>虚拟商品</Option>
<Option value={4}>服务类商品</Option> <Option value={4}>服务类商品</Option>
......
...@@ -40,10 +40,7 @@ const DragTag = ({ text, id, index, changePosition, endChangePosition, edit, del ...@@ -40,10 +40,7 @@ const DragTag = ({ text, id, index, changePosition, endChangePosition, edit, del
item.index = hoverIndex; // 将当前当前移动到Box的index赋值给当前拖动的box,不然会出现两个盒子疯狂抖动! item.index = hoverIndex; // 将当前当前移动到Box的index赋值给当前拖动的box,不然会出现两个盒子疯狂抖动!
}, },
drop: (item, monitor) => { drop: (item, monitor) => {
const dragIndex = item.index; endChangePosition(); // 调用传入的方法完成交换
const hoverIndex = index;
if (dragIndex === hoverIndex) return; // 如果回到自己的坑,那就什么都不做
endChangePosition(dragIndex, hoverIndex); // 调用传入的方法完成交换
}, },
}); });
......
...@@ -34,6 +34,7 @@ const GoodsGroup = options => { ...@@ -34,6 +34,7 @@ const GoodsGroup = options => {
}; };
const getGroupList = async () => { const getGroupList = async () => {
if (options.shopId) {
const res = await apiStorageList({ const res = await apiStorageList({
shopId: options.shopId, shopId: options.shopId,
}); });
...@@ -50,6 +51,10 @@ const GoodsGroup = options => { ...@@ -50,6 +51,10 @@ const GoodsGroup = options => {
setTags([]); setTags([]);
setSelected(0); setSelected(0);
} }
} else {
setTags([]);
setSelected(0);
}
}; };
const handleEdit = async id => { const handleEdit = async id => {
...@@ -65,20 +70,16 @@ const GoodsGroup = options => { ...@@ -65,20 +70,16 @@ const GoodsGroup = options => {
}; };
// 更换位置 // 更换位置
const changePosition = async (dragIndex, hoverIndex) => { const changePosition = async (dIndex, hIndex) => {
const data = tags.slice(); const data = tags.slice();
const temp = data[dragIndex]; const temp = data[dIndex];
// 交换位置 // 交换位置
data[dragIndex] = data[hoverIndex]; data[dIndex] = data[hIndex];
data[hoverIndex] = temp; data[hIndex] = temp;
setTags(data); setTags(data);
}; };
const endChangePosition = async (dragIndex, hoverIndex) => { const endChangePosition = async () => {
const data = tags.slice(); const data = tags.slice();
const temp = data[dragIndex];
// 交换位置
data[dragIndex] = data[hoverIndex];
data[hoverIndex] = temp;
const storageRankList = data.map((item, i) => ({ const storageRankList = data.map((item, i) => ({
id: item.id, id: item.id,
priority: i + 1, priority: i + 1,
...@@ -110,6 +111,7 @@ const GoodsGroup = options => { ...@@ -110,6 +111,7 @@ const GoodsGroup = options => {
return ( return (
<div className={styles.groupBox}> <div className={styles.groupBox}>
{(shops && shops.length && ( {(shops && shops.length && (
<>
<div className={styles['groupBox-title']}> <div className={styles['groupBox-title']}>
<div className={styles['groupBox-title--name']}>所属门店</div> <div className={styles['groupBox-title--name']}>所属门店</div>
<Select <Select
...@@ -123,11 +125,11 @@ const GoodsGroup = options => { ...@@ -123,11 +125,11 @@ const GoodsGroup = options => {
options={shops} options={shops}
/> />
</div> </div>
)) ||
''}
<div className={styles['groupBox-title']}> <div className={styles['groupBox-title']}>
<div className={styles['groupBox-title--name']}>商品分组</div> <div className={styles['groupBox-title--name']}>商品分组</div>
<Button onClick={() => setGroupEdit(!groupEdit)}>{groupEdit ? '完成' : '编辑分组'}</Button> <Button onClick={() => setGroupEdit(!groupEdit)}>
{groupEdit ? '完成' : '编辑分组'}
</Button>
</div> </div>
<div className={styles['groupBox-body']}> <div className={styles['groupBox-body']}>
{groupEdit ? ( {groupEdit ? (
...@@ -166,6 +168,9 @@ const GoodsGroup = options => { ...@@ -166,6 +168,9 @@ const GoodsGroup = options => {
</div> </div>
)} )}
</div> </div>
</>
)) ||
''}
<GroupInfo <GroupInfo
isModalOpen={isModalOpen} isModalOpen={isModalOpen}
id={storageId} id={storageId}
......
...@@ -50,12 +50,7 @@ const GroupInfo = options => { ...@@ -50,12 +50,7 @@ const GroupInfo = options => {
} }
}, [options.id, options.isModalOpen]); }, [options.id, options.isModalOpen]);
const extra = ( const extra = <Alert message="选中后,顾客下单需至少选择1个“下单必选分组”" type="error" />;
<Alert
message="选中后,顾客下单需至少选择1个“下单必选分组”商品每店仅可设置1个必点分组"
type="error"
/>
);
return ( return (
<Modal <Modal
...@@ -63,6 +58,7 @@ const GroupInfo = options => { ...@@ -63,6 +58,7 @@ const GroupInfo = options => {
visible={options.isModalOpen} visible={options.isModalOpen}
destroyOnClose destroyOnClose
maskClosable={false} maskClosable={false}
width="600px"
onOk={handleConfirm} onOk={handleConfirm}
onCancel={handleCancel} onCancel={handleCancel}
> >
......
import React from 'react'; 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 MinimumPurchase = options => {
const [form] = Form.useForm(); const [form] = Form.useForm();
...@@ -36,12 +37,9 @@ const MinimumPurchase = options => { ...@@ -36,12 +37,9 @@ const MinimumPurchase = options => {
<Form.Item <Form.Item
label="最少购买/份" label="最少购买/份"
name="minPurchaseNum" name="minPurchaseNum"
rules={[ rules={[{ required: true, message: '请输入最少购买数量!' }]}
{ required: true, message: '请输入最少购买数量!' },
{ min: 1, message: '最小输入1' },
]}
> >
<Input maxLength={6} type="number" /> <InputNumber min={1} max={999999} className={styles.inputWdith} />
</Form.Item> </Form.Item>
</Form> </Form>
</Modal> </Modal>
......
...@@ -3,6 +3,7 @@ import { Modal, Form, InputNumber, Checkbox, Switch } from 'antd'; ...@@ -3,6 +3,7 @@ import { Modal, Form, InputNumber, Checkbox, Switch } from 'antd';
import { deepClone } from '@/utils/utils'; import { deepClone } from '@/utils/utils';
import styles from '../../style.less'; import styles from '../../style.less';
import { apiProductStock } from '../../service'; import { apiProductStock } from '../../service';
import { isIntegerNotZero } from '@/utils/validator';
const StockModal = options => { const StockModal = options => {
const [stockType, setStockType] = useState(0); const [stockType, setStockType] = useState(0);
...@@ -81,7 +82,7 @@ const StockModal = options => { ...@@ -81,7 +82,7 @@ const StockModal = options => {
} }
}, [options.visible]); }, [options.visible]);
const maxStockRule = []; const maxStockRule = [{ validator: isIntegerNotZero, message: '请输入大于0的整数' }];
if (isChecked) { if (isChecked) {
maxStockRule.push({ required: true, message: '请输入最大库存!' }); maxStockRule.push({ required: true, message: '请输入最大库存!' });
} }
...@@ -111,7 +112,10 @@ const StockModal = options => { ...@@ -111,7 +112,10 @@ const StockModal = options => {
name="productStock" name="productStock"
labelCol={{ span: 6 }} labelCol={{ span: 6 }}
wrapperCol={{ span: 8 }} wrapperCol={{ span: 8 }}
rules={[{ required: true, message: '请输入剩余库存!' }]} rules={[
{ required: true, message: '请输入剩余库存!' },
{ validator: isIntegerNotZero, message: '请输入大于0的整数' },
]}
> >
<InputNumber <InputNumber
min={0} min={0}
......
import React, { useState, useEffect, useCallback, useMemo } from 'react'; 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 { unstable_batchedUpdates } from 'react-dom';
import { MenuOutlined, HolderOutlined, FormOutlined, CloseCircleOutlined } from '@ant-design/icons'; import { MenuOutlined, HolderOutlined, FormOutlined, CloseCircleOutlined } from '@ant-design/icons';
import { SortableContainer, SortableElement, SortableHandle } from 'react-sortable-hoc'; import { SortableContainer, SortableElement, SortableHandle } from 'react-sortable-hoc';
...@@ -21,6 +21,9 @@ const Takeaway = options => { ...@@ -21,6 +21,9 @@ const Takeaway = options => {
const [selectedRowKeys, setSelectedRowKeys] = useState([]); const [selectedRowKeys, setSelectedRowKeys] = useState([]);
const [shopId, setShopId] = useState(0); const [shopId, setShopId] = useState(0);
const [groupId, setGroupId] = 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 [loading, setLoading] = useState(false);
const [actionLoading, setActionLoading] = useState(false); const [actionLoading, setActionLoading] = useState(false);
const [visibleWeekTime, setVisibleWeekTime] = useState(false); const [visibleWeekTime, setVisibleWeekTime] = useState(false);
...@@ -34,12 +37,12 @@ const Takeaway = options => { ...@@ -34,12 +37,12 @@ const Takeaway = options => {
onChange: setSelectedRowKeys, onChange: setSelectedRowKeys,
}; };
const getDataList = async () => { const getDataList = async (page, size) => {
setLoading(true); setLoading(true);
const params = Object.assign({}, options.searchValue, { const params = Object.assign({}, options.searchValue, {
pageNo: 1, pageNo: page || pageNo,
productType: 5, productType: 5,
pageSize: 100000, pageSize: size || pageSize,
storageRackId: groupId, storageRackId: groupId,
}); });
const productCategoryId = options.searchValue?.productCategoryId || []; const productCategoryId = options.searchValue?.productCategoryId || [];
...@@ -49,15 +52,23 @@ const Takeaway = options => { ...@@ -49,15 +52,23 @@ const Takeaway = options => {
setLoading(false); setLoading(false);
if (res && res.data) { if (res && res.data) {
setTableData(res.data.records); 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 }) => { const onSortEnd = async ({ oldIndex, newIndex }) => {
if (oldIndex !== newIndex) { if (oldIndex !== newIndex) {
const newData = arrayMoveImmutable(tableData.slice(), oldIndex, newIndex).filter(el => !!el); const newData = arrayMoveImmutable(tableData.slice(), oldIndex, newIndex).filter(el => !!el);
const skuSorts = newData.map((item, index) => ({ const skuSorts = newData.map((item, index) => ({
skuId: item.skuId, skuId: item.skuId,
sort: index + 1, sort: pageSize * pageNo + index + 1,
})); }));
const params = { const params = {
storageRackId: groupId, storageRackId: groupId,
...@@ -98,6 +109,9 @@ const Takeaway = options => { ...@@ -98,6 +109,9 @@ const Takeaway = options => {
}; };
setActionLoading(true); setActionLoading(true);
const res = await apiGoodsActionBatch(Object.assign({}, json, params)); const res = await apiGoodsActionBatch(Object.assign({}, json, params));
setActionLoading(false);
if (res.businessCode === '0000' && res.code === '0000') {
message.success('处理成功!');
unstable_batchedUpdates(() => { unstable_batchedUpdates(() => {
setActionLoading(false); setActionLoading(false);
setVisibleWeekTime(false); setVisibleWeekTime(false);
...@@ -107,8 +121,6 @@ const Takeaway = options => { ...@@ -107,8 +121,6 @@ const Takeaway = options => {
setVisibleSend(false); setVisibleSend(false);
}); });
getDataList(); getDataList();
if (res.businessCode === '0000' && res.code === '0000') {
message.success('处理成功!');
} }
}; };
...@@ -166,6 +178,7 @@ const Takeaway = options => { ...@@ -166,6 +178,7 @@ const Takeaway = options => {
<div className={styles.takeawayBox}> <div className={styles.takeawayBox}>
<Spin spinning={loading}> <Spin spinning={loading}>
<GoodsGroup shopId={shopId} changeShop={setShopId} changeGroup={setGroupId} /> <GoodsGroup shopId={shopId} changeShop={setShopId} changeGroup={setGroupId} />
{(shopId && (
<ActionBar <ActionBar
selectedRowKeys={selectedRowKeys} selectedRowKeys={selectedRowKeys}
shopId={shopId} shopId={shopId}
...@@ -173,13 +186,15 @@ const Takeaway = options => { ...@@ -173,13 +186,15 @@ const Takeaway = options => {
openModal={openModal} openModal={openModal}
newGoods={onNew} newGoods={onNew}
/> />
)) ||
''}
<Table <Table
dataSource={tableData} dataSource={tableData}
bordered bordered
columns={takeawayColumn(actions)} columns={takeawayColumn(actions)}
rowKey={record => record.skuId} rowKey={record => record.skuId}
pagination={false} pagination={false}
scroll={{ x: '100%', y: 1000 }} scroll={{ x: '100%', y: 500 }}
rowSelection={rowSelection} rowSelection={rowSelection}
components={{ components={{
body: { body: {
...@@ -188,6 +203,20 @@ const Takeaway = options => { ...@@ -188,6 +203,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> </Spin>
<WeekTime <WeekTime
visible={visibleWeekTime} visible={visibleWeekTime}
......
...@@ -307,6 +307,9 @@ class goodsManage extends Component { ...@@ -307,6 +307,9 @@ class goodsManage extends Component {
productType: e || 1, productType: e || 1,
}); });
this.categoryListByType(e); this.categoryListByType(e);
if (e !== 5) {
this.handleSearch(1);
}
}; };
getVirtualCategory = async () => { getVirtualCategory = async () => {
......
...@@ -141,6 +141,11 @@ ...@@ -141,6 +141,11 @@
margin-top: 20px; margin-top: 20px;
padding-bottom: 40px; padding-bottom: 40px;
background-color: #fff; background-color: #fff;
&--page {
padding-top: 10px;
padding-left: 30px;
text-align: left;
}
} }
.groupBox { .groupBox {
padding: 0 24px 15px 24px; padding: 0 24px 15px 24px;
...@@ -283,3 +288,6 @@ ...@@ -283,3 +288,6 @@
width: 100%; 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