diff --git a/src/apis.js b/src/apis.js index d597fdc..9a02fb9 100644 --- a/src/apis.js +++ b/src/apis.js @@ -374,7 +374,7 @@ export const savePointBookAPI = async ( targetType, groups, arrows, - group_data = [] + data = [] ) => { return request("POST", "/user/score/sheet/report", { bowType, @@ -382,15 +382,27 @@ export const savePointBookAPI = async ( targetType, groups, arrows, - group_data, + group_data: data.map((item) => + item.map((i) => ({ + ...i, + ring: i.ring === "M" ? -1 : i.ring === "X" ? 0 : Number(i.ring), + })) + ), }); }; -export const getPointBookListAPI = async (page = 1, size = 10) => { - return request( - "GET", - `/user/score/sheet/list?pageNum=${page}&pageSize=${size}` - ); +export const getPointBookListAPI = async ( + page = 1, + bowType, + distance, + targetType +) => { + let url = `/user/score/sheet/list?pageNum=${page}&pageSize=10`; + if (bowType) url += `&bowType=${bowType}`; + if (distance) url += `&distance=${distance}`; + if (targetType) url += `&targetType=${targetType}`; + const result = await request("GET", url); + return result.list || []; }; export const getPointBookDetailAPI = async (id) => { diff --git a/src/components/BowTargetEdit.vue b/src/components/BowTargetEdit.vue index 25830dc..57ea4ba 100644 --- a/src/components/BowTargetEdit.vue +++ b/src/components/BowTargetEdit.vue @@ -17,7 +17,7 @@ const props = defineProps({ }, onChange: { type: Function, - default: (arrow) => {}, + default: null, }, }); @@ -28,7 +28,7 @@ const dragStartPos = ref({ x: 0, y: 0 }); // 点击靶纸创建新的点 const onClick = async (e) => { - if (arrow.value !== null) return; + if (arrow.value !== null || !props.onChange) return; const newArrow = { x: e.detail.x - (rect.value.width * 0.1) / 2, y: e.detail.y - rect.value.top - 10, @@ -45,7 +45,8 @@ const onClick = async (e) => { // 确认添加箭矢 const confirmAdd = () => { - props.onChange(arrow.value); + if (props.onChange) + props.onChange({ ...arrow.value, ring: arrow.value.ring || "M" }); arrow.value = null; }; diff --git a/src/components/EditOption.vue b/src/components/EditOption.vue index 2450d31..34f7587 100644 --- a/src/components/EditOption.vue +++ b/src/components/EditOption.vue @@ -65,7 +65,10 @@ const onMeterChange = (e) => { watch( () => props.value, (newValue) => { - if (!newValue) return; + if (!newValue) { + selectedIndex.value = -1; + return; + } if (props.itemIndex === 0 || props.itemIndex === 2) { data.value.forEach((item, index) => { if (item.name === newValue) { @@ -93,7 +96,6 @@ onMounted(() => { } else if (props.itemIndex === 2) { data.value = config.targetOption; } - // props.onSelect(props.itemIndex, config[props.itemIndex]); } }); diff --git a/src/components/PointRecord.vue b/src/components/PointRecord.vue index f9817b1..6b1459b 100644 --- a/src/components/PointRecord.vue +++ b/src/components/PointRecord.vue @@ -1,29 +1,49 @@