Commit c3672f3a authored by 武广's avatar 武广

fix: 修改排序问题

parent 03c6c890
...@@ -7,7 +7,7 @@ import styles from '../../style.less'; ...@@ -7,7 +7,7 @@ import styles from '../../style.less';
const ItemTypes = { const ItemTypes = {
CARD: 'card', CARD: 'card',
}; };
const DragTag = ({ text, id, index, changePosition, endChangePosition, edit, del }) => { const DragTag = ({ text, id, index, changePosition, endChangePosition, edit, del, selected }) => {
const [isEdit, setIsEdit] = useState(false); const [isEdit, setIsEdit] = useState(false);
const [inputValue, setInputValue] = useState(''); const [inputValue, setInputValue] = useState('');
const refInput = useRef(); const refInput = useRef();
...@@ -69,7 +69,7 @@ const DragTag = ({ text, id, index, changePosition, endChangePosition, edit, del ...@@ -69,7 +69,7 @@ const DragTag = ({ text, id, index, changePosition, endChangePosition, edit, del
const groupEditRender = () => ( const groupEditRender = () => (
<Tag <Tag
className={styles['groupBox-body--tag']} className={[styles['groupBox-body--tag']]}
ref={drag(drop(ref))} ref={drag(drop(ref))}
style={{ style={{
opacity: isDragging ? 0.3 : 1, opacity: isDragging ? 0.3 : 1,
......
...@@ -62,11 +62,13 @@ const GoodsGroup = options => { ...@@ -62,11 +62,13 @@ const GoodsGroup = options => {
setIsModalOpen(true); setIsModalOpen(true);
}; };
const handleDelete = async id => { const handleDelete = async id => {
await apiDelStorage({ const res = await apiDelStorage({
shopId: options.shopId, shopId: options.shopId,
id, id,
}); });
getGroupList(); if (res.businessCode === '0000' && res.code === '0000') {
getGroupList();
}
}; };
// 更换位置 // 更换位置
......
...@@ -52,6 +52,18 @@ const WeekTime = options => { ...@@ -52,6 +52,18 @@ const WeekTime = options => {
}); });
}; };
const onTimeValidator = (rule, value, callback) => {
if (value && value.length === 2) {
if (moment(value[0]).format('HH:mm') === moment(value[1]).format('HH:mm')) {
callback(new Error('请输入大于0的数字'));
} else {
callback();
}
} else {
callback();
}
};
const initialValues = Object.assign( const initialValues = Object.assign(
{ {
saleTimeType: 0, saleTimeType: 0,
...@@ -137,6 +149,10 @@ const WeekTime = options => { ...@@ -137,6 +149,10 @@ const WeekTime = options => {
required: true, required: true,
message: '请选择售卖时间', message: '请选择售卖时间',
}, },
{
validator: onTimeValidator,
message: '结束时间不能和开始时间相同',
},
]} ]}
noStyle noStyle
> >
......
...@@ -6,7 +6,12 @@ import { SortableContainer, SortableElement, SortableHandle } from 'react-sortab ...@@ -6,7 +6,12 @@ import { SortableContainer, SortableElement, SortableHandle } from 'react-sortab
import { arrayMoveImmutable } from 'array-move'; import { arrayMoveImmutable } from 'array-move';
import { GOOD_MANAGE } from '@/../config/permission.config'; import { GOOD_MANAGE } from '@/../config/permission.config';
import GoodsGroup from './components/GoodsGroup'; import GoodsGroup from './components/GoodsGroup';
import { apiTakeawayGoods, apiGoodsActionBatch, apiSortTakeawayGoods } from '../service'; import {
apiTakeawayGoods,
apiGoodsActionBatch,
apiSortTakeawayGoods,
apiTopTakeawayGoods,
} from '../service';
import styles from '../style.less'; import styles from '../style.less';
import { takeawayColumn } from '../staticdata'; import { takeawayColumn } from '../staticdata';
// import VirtualTable from './components/VirtualTable'; // import VirtualTable from './components/VirtualTable';
...@@ -38,7 +43,7 @@ const Takeaway = options => { ...@@ -38,7 +43,7 @@ const Takeaway = options => {
onChange: setSelectedRowKeys, onChange: setSelectedRowKeys,
}; };
const getDataList = async (page, size) => { const getDataList = async (page = pageNo, size = pageSize) => {
setLoading(true); setLoading(true);
const params = Object.assign({}, options.searchValue, { const params = Object.assign({}, options.searchValue, {
pageNo: page || pageNo, pageNo: page || pageNo,
...@@ -69,7 +74,7 @@ const Takeaway = options => { ...@@ -69,7 +74,7 @@ const Takeaway = options => {
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: pageSize * pageNo + index + 1, sort: pageSize * (pageNo - 1) + index + 1,
})); }));
const params = { const params = {
storageRackId: groupId, storageRackId: groupId,
...@@ -78,7 +83,7 @@ const Takeaway = options => { ...@@ -78,7 +83,7 @@ const Takeaway = options => {
skuSorts, skuSorts,
}; };
await apiSortTakeawayGoods(params); await apiSortTakeawayGoods(params);
getDataList(); getDataList(pageNo, pageSize);
// setTableData(newData); // setTableData(newData);
} }
}; };
...@@ -121,7 +126,7 @@ const Takeaway = options => { ...@@ -121,7 +126,7 @@ const Takeaway = options => {
setVisibleBuy(false); setVisibleBuy(false);
setVisibleSend(false); setVisibleSend(false);
}); });
getDataList(); getDataList(pageNo, pageSize);
} }
}; };
...@@ -155,13 +160,22 @@ const Takeaway = options => { ...@@ -155,13 +160,22 @@ const Takeaway = options => {
}); });
}; };
// 置顶 // 置顶
const toTop = oldIndex => { const toTop = async ({ skuId }) => {
onSortEnd({ oldIndex, newIndex: 0 }); // onSortEnd({ oldIndex, newIndex: 0 });
const res = await apiTopTakeawayGoods({
productItemId: skuId,
shopId,
storageRackId: groupId,
});
if (res.businessCode === '0000' && res.code === '0000') {
getDataList(pageNo, pageSize);
message.success('处理成功!');
}
}; };
useEffect(() => { useEffect(() => {
if (groupId) { if (groupId) {
getDataList(); getDataList(0, pageSize);
} else { } else {
setTableData([]); setTableData([]);
} }
...@@ -173,6 +187,7 @@ const Takeaway = options => { ...@@ -173,6 +187,7 @@ const Takeaway = options => {
onEdit, onEdit,
getDataList, getDataList,
shopId, shopId,
pageNo,
}; };
const canAddTakeaway = options.permissions[GOOD_MANAGE.ADD_TAKEAWAY_GOODS]; const canAddTakeaway = options.permissions[GOOD_MANAGE.ADD_TAKEAWAY_GOODS];
......
...@@ -312,6 +312,13 @@ export async function apiSortTakeawayGoods(data) { ...@@ -312,6 +312,13 @@ export async function apiSortTakeawayGoods(data) {
data, data,
}); });
} }
// 外卖商品置顶
export async function apiTopTakeawayGoods(data) {
return request.post('/api/merchants/products/sku/storageRack/topping', {
prefix: goodsApi,
data,
});
}
// 获取供应商门店列表 // 获取供应商门店列表
export async function apiSupplierShopList() { export async function apiSupplierShopList() {
return request.get('/api/merchants/shops/getBySupplierId?state=1', { return request.get('/api/merchants/shops/getBySupplierId?state=1', {
......
...@@ -341,8 +341,8 @@ export function takeawayColumn(actions) { ...@@ -341,8 +341,8 @@ export function takeawayColumn(actions) {
> >
修改库存 修改库存
</Button> </Button>
{index > 0 && ( {(index > 0 || actions.pageNo > 1) && (
<Button key="top" className={styles.button} onClick={() => actions.toTop(index)}> <Button key="top" className={styles.button} onClick={() => actions.toTop(row)}>
置顶 置顶
</Button> </Button>
)} )}
......
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