|
@@ -53,22 +53,25 @@
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
-import { computed, ref } from "vue";
|
|
|
|
|
|
+import { computed, ref, watch } from "vue";
|
|
import { NumberOutlined, PictureFilled } from "@ant-design/icons-vue";
|
|
import { NumberOutlined, PictureFilled } from "@ant-design/icons-vue";
|
|
import { message } from "ant-design-vue";
|
|
import { message } from "ant-design-vue";
|
|
|
|
|
|
-import CutImageDialog from "./CutImageDialog.vue";
|
|
|
|
-import { uploadSlice } from "@/ap/base";
|
|
|
|
|
|
+import { uploadSlice, cardInfo } from "@/ap/base";
|
|
|
|
+import { CardContent, CardPage } from "@/ap/types/base";
|
|
import { getFileMD5 } from "@/utils/crypto";
|
|
import { getFileMD5 } from "@/utils/crypto";
|
|
-import { useDataCheckStore } from "@/store";
|
|
|
|
|
|
+import { useDataCheckStore, useUserStore } from "@/store";
|
|
import { getFileUrl } from "@/utils/tool";
|
|
import { getFileUrl } from "@/utils/tool";
|
|
|
|
|
|
|
|
+import CutImageDialog from "./CutImageDialog.vue";
|
|
import ImportBtn from "@/components/ImportBtn/index.vue";
|
|
import ImportBtn from "@/components/ImportBtn/index.vue";
|
|
|
|
+import axios from "axios";
|
|
|
|
|
|
defineOptions({
|
|
defineOptions({
|
|
name: "SliceImage",
|
|
name: "SliceImage",
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+const userStore = useUserStore();
|
|
const dataCheckStore = useDataCheckStore();
|
|
const dataCheckStore = useDataCheckStore();
|
|
|
|
|
|
const curStudent = computed(() => {
|
|
const curStudent = computed(() => {
|
|
@@ -84,6 +87,8 @@ const curSliceInfo = ref({
|
|
sheetUri: "",
|
|
sheetUri: "",
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+const cardData = ref<CardPage[]>([]);
|
|
|
|
+
|
|
function getPageTitle(paperNumber, pageIndex) {
|
|
function getPageTitle(paperNumber, pageIndex) {
|
|
return `卡${paperNumber}${pageIndex === 0 ? "正面" : "反面"}`;
|
|
return `卡${paperNumber}${pageIndex === 0 ? "正面" : "反面"}`;
|
|
}
|
|
}
|
|
@@ -101,7 +106,19 @@ function onEditSlice(paperNumber: number, pageIndex: number, index: number) {
|
|
index: index + 1,
|
|
index: index + 1,
|
|
sheetUri: paper.pages[pageIndex].sheetUri,
|
|
sheetUri: paper.pages[pageIndex].sheetUri,
|
|
};
|
|
};
|
|
- curSliceSelection.value = undefined;
|
|
|
|
|
|
+ const paperPageIndex = (paperNumber - 1) * 2 + pageIndex;
|
|
|
|
+ const area = cardData.value[paperPageIndex]?.exchange.answer_area[index].area;
|
|
|
|
+ if (area) {
|
|
|
|
+ curSliceSelection.value = {
|
|
|
|
+ x: area[0],
|
|
|
|
+ y: area[1],
|
|
|
|
+ w: area[2],
|
|
|
|
+ h: area[3],
|
|
|
|
+ };
|
|
|
|
+ } else {
|
|
|
|
+ curSliceSelection.value = undefined;
|
|
|
|
+ }
|
|
|
|
+
|
|
cutImageDialogRef.value?.open();
|
|
cutImageDialogRef.value?.open();
|
|
}
|
|
}
|
|
async function cutImageModified(file: File) {
|
|
async function cutImageModified(file: File) {
|
|
@@ -149,6 +166,28 @@ function updateSliceSuccess(data: { url: string }) {
|
|
});
|
|
});
|
|
message.success("上传成功!");
|
|
message.success("上传成功!");
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+// 卡格式
|
|
|
|
+async function getCardInfo() {
|
|
|
|
+ if (!dataCheckStore.curStudent) return;
|
|
|
|
+
|
|
|
|
+ const res = await cardInfo({
|
|
|
|
+ examId: userStore.curExam.id,
|
|
|
|
+ number: dataCheckStore.curStudent.cardNumber,
|
|
|
|
+ });
|
|
|
|
+ const uri = getFileUrl(res.uri);
|
|
|
|
+ const cardRes = await axios.get(uri);
|
|
|
|
+ cardData.value = (cardRes.data as CardContent).pages;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+watch(
|
|
|
|
+ () => dataCheckStore.curStudent?.id,
|
|
|
|
+ (val) => {
|
|
|
|
+ if (!val) return;
|
|
|
|
+ getCardInfo();
|
|
|
|
+ },
|
|
|
|
+ { immediate: true }
|
|
|
|
+);
|
|
</script>
|
|
</script>
|
|
|
|
|
|
<style lang="less" scoped>
|
|
<style lang="less" scoped>
|