Commit c3672f3a authored by 武广's avatar 武广

fix: 修改排序问题

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