|
@@ -1,10 +1,6 @@
|
|
|
<template>
|
|
|
<div class="slice-image">
|
|
|
- <div
|
|
|
- v-for="item in studentSlice.papers"
|
|
|
- :key="item.number"
|
|
|
- class="image-paper"
|
|
|
- >
|
|
|
+ <div v-for="item in studentSlice.papers" :key="item.id" class="image-paper">
|
|
|
<div
|
|
|
v-for="(page, pindex) in item.pages"
|
|
|
:key="pindex"
|
|
@@ -25,7 +21,7 @@
|
|
|
</a-button>
|
|
|
<a-button
|
|
|
class="image-slice"
|
|
|
- @click="onEditSlice(item.number, pindex, sindex)"
|
|
|
+ @click="onEditSlice(item.id, pindex, sindex)"
|
|
|
>
|
|
|
<template #icon><NumberOutlined /></template>
|
|
|
</a-button>
|
|
@@ -40,13 +36,16 @@
|
|
|
ref="cutImageDialogRef"
|
|
|
:sheet-url="sheetUrl"
|
|
|
:slice-selection="curSliceSelection"
|
|
|
+ @confirm="cutImageModified"
|
|
|
/>
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
+import { ref } from "vue";
|
|
|
import { NumberOutlined, PictureFilled } from "@ant-design/icons-vue";
|
|
|
import CutImageDialog from "./CutImageDialog.vue";
|
|
|
-import { ref } from "vue";
|
|
|
+import { uploadSlice } from "@/ap/base";
|
|
|
+import { getFileMD5 } from "@/utils/crypto";
|
|
|
|
|
|
defineOptions({
|
|
|
name: "SliceImage",
|
|
@@ -54,20 +53,42 @@ defineOptions({
|
|
|
|
|
|
const props = defineProps<{
|
|
|
sheetUrl: string;
|
|
|
- studentSlice: StudentSliceImgs;
|
|
|
+ sliceData: StudentSliceData;
|
|
|
}>();
|
|
|
|
|
|
const curSliceSelection = ref<AreaSize>();
|
|
|
+const curSliceInfo = ref({
|
|
|
+ paperIndex: 0,
|
|
|
+ paperId: 0,
|
|
|
+ pageIndex: 0,
|
|
|
+ index: 0,
|
|
|
+});
|
|
|
|
|
|
function getPageTitle(paperNumber, pageIndex) {
|
|
|
return `卡${paperNumber}${pageIndex === 0 ? "正面" : "反面"}`;
|
|
|
}
|
|
|
|
|
|
const cutImageDialogRef = ref();
|
|
|
-function onEditSlice(paperNumber: number, pageIndex: number, index: number) {
|
|
|
- // TODO:get slice selection
|
|
|
+function onEditSlice(paperId: number, pageIndex: number, index: number) {
|
|
|
+ const paperIndex = props.sliceData.papers.findIndex((p) => p.id === paperId);
|
|
|
+ curSliceInfo.value = { paperIndex, pageIndex, paperId, index };
|
|
|
curSliceSelection.value = undefined;
|
|
|
-
|
|
|
cutImageDialogRef.value?.open();
|
|
|
}
|
|
|
+async function cutImageModified(file: File) {
|
|
|
+ const md5 = await getFileMD5(file);
|
|
|
+
|
|
|
+ const { paperId, pageIndex, index, paperIndex } = curSliceInfo.value;
|
|
|
+ const datas = {
|
|
|
+ paperId,
|
|
|
+ pageIndex,
|
|
|
+ index,
|
|
|
+ file,
|
|
|
+ md5,
|
|
|
+ };
|
|
|
+ const res = await uploadSlice(datas).catch(() => {});
|
|
|
+ if (!res) return;
|
|
|
+
|
|
|
+ props.sliceData.papers[paperIndex].pages[pageIndex].sliceUri[index] = res.uri;
|
|
|
+}
|
|
|
</script>
|