|
@@ -67,7 +67,6 @@
|
|
|
<el-form-item label="志愿填报">
|
|
|
<p>本人已知晓{{supervisorData.nickname}}对研究生毕业时学术成果的发表要求,特申请加入{{supervisorData.nickname}}课题组进行研究生阶段的学习和研究。</p>
|
|
|
<p v-if="userInfo.userType=='1'">★ 本人签字
|
|
|
- <!-- <el-input v-model="formData.studentSignature" placeholder="" /> -->
|
|
|
</p>
|
|
|
<div v-if="userInfo.userType=='1'">
|
|
|
<canvas
|
|
@@ -85,9 +84,17 @@
|
|
|
<el-button @click="ClearStudentSignature" size="small">清空</el-button>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <p v-if="userInfo.userType==='3' || formType === 'end'">★ 本人签字</p>
|
|
|
- <img v-if="userInfo.userType==='3' || formType === 'end'" :src="formData.studentSignature" alt="学生签名" style="width: 300px; height: 100px; margin-right: 10px; background-color: white;"/>
|
|
|
- <p v-if="userInfo.userType==='3' || formType === 'end'">日期:{{formattedStudentSignDate}}</p>
|
|
|
+ <div>
|
|
|
+ <p v-if="userInfo.userType==='3' || formType === 'end'">★ 本人签字</p>
|
|
|
+ <div>
|
|
|
+ <img v-if="(userInfo.userType==='3' || formType === 'end') && formData.studentSignature" :src="formData.studentSignature" alt="学生签名" style="width: 300px; height: 100px; margin-right: 10px; background-color: white;"/>
|
|
|
+ <img v-else src="/none.png" />
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ <p v-if="(userInfo.userType==='3' || formType === 'end') && formData.studentSignature">日期:{{formattedStudentSignDate}}</p>
|
|
|
+ <p v-else></p>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
@@ -111,12 +118,12 @@
|
|
|
</div>
|
|
|
<div v-show="!lastSupervisorSignature">
|
|
|
<canvas
|
|
|
- id="canvas"
|
|
|
- ref="canvas"
|
|
|
+ id="canvasT"
|
|
|
+ ref="canvasT"
|
|
|
width="400"
|
|
|
height="100"
|
|
|
- @mousedown="handleMouseDown"
|
|
|
- @mousemove="handleMouseMove"
|
|
|
+ @mousedown="handleMouseDownT"
|
|
|
+ @mousemove="handleMouseMoveT"
|
|
|
@mouseup="handleMouseUp"
|
|
|
style="border:1px solid #e0e0e0; border-radius: 4px; background-color: white;"
|
|
|
></canvas>
|
|
@@ -128,9 +135,17 @@
|
|
|
<!-- <p v-if="userInfo.userType==='4'">日期:{{formData.supervisorSignDate}}</p> -->
|
|
|
</div>
|
|
|
<div class="section" v-if="formType === 'end'">
|
|
|
- <p style="font-weight: bold;">★ 导师签字</p>
|
|
|
- <img :src="formData.supervisorSignature" alt="导师签名" style="width: 300px; height: 100px; margin-right: 10px; background-color: white;"/>
|
|
|
- <p>日期:{{formattedSupervisorSignDate}}</p>
|
|
|
+ <div>
|
|
|
+ <p v-if="formType === 'end'" style="font-weight: bold;">★ 导师签字</p>
|
|
|
+ <div>
|
|
|
+ <img v-if="formType === 'end' && formData.supervisorSignature" :src="formData.supervisorSignature" alt="导师签名" />
|
|
|
+ <img v-else src="/none.png" />
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ <p v-if="formType === 'end' && formData.supervisorSignature">日期:{{formattedSupervisorSignDate}}</p>
|
|
|
+ <p v-else></p>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
<div class="section" v-if="userInfo.userType==='4' && formType === 'update' || userInfo.userType==='4' && formType === 'updatetwo' || userInfo.userType==='4' && formType === 'updateone'">
|
|
|
<el-form-item label="参与导师" prop="supervisorId">
|
|
@@ -173,6 +188,7 @@ import { studentSelectionProjectApi, studentSelectionProjectVO } from '@/api/sys
|
|
|
/** 师生互选记录 表单 */
|
|
|
defineOptions({ name: 'StudentSelectSupervisorRecordForm' })
|
|
|
const canvas = ref();
|
|
|
+const canvasT = ref();
|
|
|
|
|
|
const { t } = useI18n() // 国际化
|
|
|
const message = useMessage() // 消息弹窗
|
|
@@ -271,23 +287,24 @@ const getSupervisorSignature = async() => {
|
|
|
|
|
|
const showPrintButton = ref(false); // 控制打印按钮的显示
|
|
|
/** 打开弹窗 */
|
|
|
-const open = async (type: string, projectId?: number, supervisorId?:number, id?:number, studentId?:number, recordId?:number) => {
|
|
|
+const open = async (type: string, projectId?: number, supervisorId?:number, id?:number, studentId?:number) => {
|
|
|
dialogVisible.value = true;
|
|
|
- await nextTick(() => {
|
|
|
- if (canvas.value) {
|
|
|
- context.value = canvas.value.getContext('2d');
|
|
|
- context.value.lineWidth = 2; // 设置线条宽度
|
|
|
- context.value.lineCap = 'round'; // 设置线条末端样式
|
|
|
- context.value.strokeStyle = 'black'; // 设置线条颜色
|
|
|
- } else {
|
|
|
- console.error('Canvas element is not found');
|
|
|
- }
|
|
|
- })
|
|
|
+
|
|
|
if (type === 'create'){
|
|
|
dialogTitle.value = '志愿填报'
|
|
|
submitFormText.value = '选择'
|
|
|
formType.value = type
|
|
|
resetForm()
|
|
|
+ await nextTick(() => {
|
|
|
+ if (canvas.value) {
|
|
|
+ context.value = canvas.value.getContext('2d');
|
|
|
+ context.value.lineWidth = 2; // 设置线条宽度
|
|
|
+ context.value.lineCap = 'round'; // 设置线条末端样式
|
|
|
+ context.value.strokeStyle = 'black'; // 设置线条颜色
|
|
|
+ } else {
|
|
|
+ console.error('Canvas element is not found');
|
|
|
+ }
|
|
|
+ })
|
|
|
if (supervisorId) {
|
|
|
formLoading.value = true
|
|
|
try {
|
|
@@ -313,6 +330,16 @@ const open = async (type: string, projectId?: number, supervisorId?:number, id?:
|
|
|
submitFormText.value = '接受'
|
|
|
formType.value = type
|
|
|
resetForm()
|
|
|
+ await nextTick(() => {
|
|
|
+ if (canvasT.value) {
|
|
|
+ contextT.value = canvasT.value.getContext('2d');
|
|
|
+ contextT.value.lineWidth = 2; // 设置线条宽度
|
|
|
+ contextT.value.lineCap = 'round'; // 设置线条末端样式
|
|
|
+ contextT.value.strokeStyle = 'black'; // 设置线条颜色
|
|
|
+ } else {
|
|
|
+ console.error('Canvas element is not found');
|
|
|
+ }
|
|
|
+ })
|
|
|
if (studentId) {
|
|
|
formLoading.value = true
|
|
|
try {
|
|
@@ -398,10 +425,10 @@ const open = async (type: string, projectId?: number, supervisorId?:number, id?:
|
|
|
submitFormText.value = '编辑'
|
|
|
formType.value = type
|
|
|
resetForm()
|
|
|
- if (id) {
|
|
|
+ if (studentId) {
|
|
|
formLoading.value = true
|
|
|
try {
|
|
|
- const result =await UserApi.getUser(id)
|
|
|
+ const result =await UserApi.getUser(studentId)
|
|
|
studentData.value.nickname=result.nickname
|
|
|
studentData.value.userNumber=result.userNumber
|
|
|
studentData.value.major=result.major
|
|
@@ -410,8 +437,9 @@ const open = async (type: string, projectId?: number, supervisorId?:number, id?:
|
|
|
formLoading.value = false
|
|
|
}
|
|
|
}
|
|
|
- if (recordId){
|
|
|
- formData.value = await studentSelectSupervisorRecordApi.getStudentSelectSupervisorRecord(recordId)
|
|
|
+ if (id){
|
|
|
+ formData.value.id = id
|
|
|
+ formData.value = await studentSelectSupervisorRecordApi.getStudentSelectSupervisorRecord(id)
|
|
|
// console.log(formData.value,'formData.value');
|
|
|
}
|
|
|
await getProjectSupervisors()
|
|
@@ -421,12 +449,11 @@ const open = async (type: string, projectId?: number, supervisorId?:number, id?:
|
|
|
submitFormText.value = '编辑'
|
|
|
formType.value = type
|
|
|
resetForm()
|
|
|
- if (id) {
|
|
|
+ if (studentId) {
|
|
|
formLoading.value = true
|
|
|
try {
|
|
|
- const result =await UserApi.getUser(id)
|
|
|
+ const result =await UserApi.getUser(studentId)
|
|
|
formData.value.supervisorId = supervisorId
|
|
|
- formData.value.studentId = id
|
|
|
studentData.value.nickname=result.nickname
|
|
|
studentData.value.userNumber=result.userNumber
|
|
|
studentData.value.major=result.major
|
|
@@ -492,7 +519,7 @@ const handleExport = (row) => {
|
|
|
|
|
|
const isDrawing = ref(false) // 是否正在画
|
|
|
const context = ref() // 签名画布的上下文
|
|
|
-
|
|
|
+const contextT = ref()
|
|
|
const handleMouseDown = (event: MouseEvent) => {
|
|
|
if (!canvas.value || !context.value) {
|
|
|
console.warn('Canvas or context is not initialized yet');
|
|
@@ -503,24 +530,45 @@ const handleMouseDown = (event: MouseEvent) => {
|
|
|
context.value.beginPath();
|
|
|
context.value.moveTo(offsetX, offsetY);
|
|
|
}
|
|
|
+const handleMouseDownT = (event: MouseEvent) => {
|
|
|
+ if (!canvasT.value || !contextT.value) {
|
|
|
+ console.warn('Canvas or context is not initialized yet');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ isDrawing.value = true;
|
|
|
+ const { offsetX, offsetY } = event;
|
|
|
+ contextT.value.beginPath();
|
|
|
+ contextT.value.moveTo(offsetX, offsetY);
|
|
|
+}
|
|
|
|
|
|
const handleMouseMove = (event: MouseEvent) => {
|
|
|
if (!isDrawing.value || !canvas.value || !context.value) return;
|
|
|
-
|
|
|
const rect = canvas.value.getBoundingClientRect();
|
|
|
const offsetX = event.clientX - rect.left; // 计算鼠标相对于画布左上角的坐标
|
|
|
const offsetY = event.clientY - rect.top; // 计算鼠标相对于画布左上角的坐标
|
|
|
-
|
|
|
// 检查鼠标位置是否超出画布边界
|
|
|
if (offsetX < 0 || offsetX > 400 || offsetY < 0 || offsetY > 100) {
|
|
|
isDrawing.value = false;
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
// 如果未超出边界,继续进行绘制
|
|
|
context.value.lineTo(offsetX, offsetY);
|
|
|
context.value.stroke();
|
|
|
}
|
|
|
+const handleMouseMoveT = (event: MouseEvent) => {
|
|
|
+ if (!isDrawing.value || !canvasT.value || !contextT.value) return;
|
|
|
+ const rect = canvasT.value.getBoundingClientRect();
|
|
|
+ const offsetX = event.clientX - rect.left; // 计算鼠标相对于画布左上角的坐标
|
|
|
+ const offsetY = event.clientY - rect.top; // 计算鼠标相对于画布左上角的坐标
|
|
|
+ // 检查鼠标位置是否超出画布边界
|
|
|
+ if (offsetX < 0 || offsetX > 400 || offsetY < 0 || offsetY > 100) {
|
|
|
+ isDrawing.value = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 如果未超出边界,继续进行绘制
|
|
|
+ contextT.value.lineTo(offsetX, offsetY);
|
|
|
+ contextT.value.stroke();
|
|
|
+}
|
|
|
|
|
|
const handleMouseUp = () => {
|
|
|
isDrawing.value = false
|
|
@@ -531,16 +579,16 @@ const handleResign = async () => {
|
|
|
formData.value.supervisorSignature = ''; // 清空当前签名
|
|
|
lastSupervisorSignature.value = ''; // 清空历史签名
|
|
|
ClearSupervisorSignature(); // 清空签名画布
|
|
|
- console.log(canvas.value,'canvas.value')
|
|
|
- if (canvas.value) {
|
|
|
- context.value = canvas.value.getContext('2d'); // 获取上下文
|
|
|
- context.value.clearRect(0, 0, canvas.value.width, canvas.value.height); // 清空画布
|
|
|
- context.value.lineWidth = 2; // 设置线条宽度
|
|
|
- context.value.lineCap = 'round'; // 设置线条末端样式
|
|
|
- context.value.strokeStyle = 'black'; // 设置线条颜色
|
|
|
+ console.log(canvasT.value,'canvasT.value')
|
|
|
+ if (canvasT.value) {
|
|
|
+ contextT.value = canvasT.value.getContext('2d'); // 获取上下文
|
|
|
+ contextT.value.clearRect(0, 0, canvasT.value.width, canvasT.value.height); // 清空画布
|
|
|
+ contextT.value.lineWidth = 2; // 设置线条宽度
|
|
|
+ contextT.value.lineCap = 'round'; // 设置线条末端样式
|
|
|
+ contextT.value.strokeStyle = 'black'; // 设置线条颜色
|
|
|
message.success('导师签名已重置');
|
|
|
} else {
|
|
|
- console.error('Canvas element is not found');
|
|
|
+ console.error('CanvasT element is not found');
|
|
|
}
|
|
|
};
|
|
|
|
|
@@ -566,9 +614,9 @@ const handleStudentSignatureSave = () => {
|
|
|
};
|
|
|
|
|
|
const ClearSupervisorSignature = () => {
|
|
|
- if (canvas.value && context.value) {
|
|
|
+ if (canvasT.value && contextT.value) {
|
|
|
formData.value.supervisorSignature = "";
|
|
|
- context.value.clearRect(0, 0, canvas.value.width, canvas.value.height);
|
|
|
+ contextT.value.clearRect(0, 0, canvasT.value.width, canvasT.value.height);
|
|
|
message.success('签名已清空');
|
|
|
} else {
|
|
|
console.warn('Canvas context is not initialized yet');
|
|
@@ -576,8 +624,8 @@ const ClearSupervisorSignature = () => {
|
|
|
}
|
|
|
|
|
|
const handleSupervisorSignatureSave = () => {
|
|
|
- if (canvas.value) {
|
|
|
- const dataURL = canvas.value.toDataURL();
|
|
|
+ if (canvasT.value) {
|
|
|
+ const dataURL = canvasT.value.toDataURL();
|
|
|
console.log(dataURL);
|
|
|
formData.value.supervisorSignature = dataURL; // 保存学生签名数据
|
|
|
message.success('导师签名保存成功');
|
|
@@ -593,27 +641,27 @@ const emit = defineEmits(['success']) // 定义 success 事件,用于操作成
|
|
|
const submitForm = async () => {
|
|
|
formLoading.value = true;
|
|
|
try {
|
|
|
- const isStudentSignatureSaved = formData.value.studentSignature.startsWith('data:image/png;base64,');
|
|
|
- const isSupervisorSignatureSaved = formData.value.supervisorSignature.startsWith('data:image/png;base64,');
|
|
|
- if (!isStudentSignatureSaved && (userInfo.value.userType === '1')) {
|
|
|
- message.error('请先保存签名');
|
|
|
- formLoading.value = false;
|
|
|
- return;
|
|
|
- }
|
|
|
- if (!isSupervisorSignatureSaved && (userInfo.value.userType === '3')) {
|
|
|
- message.error('请先保存签名');
|
|
|
- formLoading.value = false;
|
|
|
- return;
|
|
|
- }
|
|
|
const data = formData.value as unknown as studentSelectSupervisorRecordVO;
|
|
|
console.log(data)
|
|
|
if (formType.value === 'create') {
|
|
|
+ const isStudentSignatureSaved = formData.value.studentSignature.startsWith('data:image/png;base64,');
|
|
|
+ if (!isStudentSignatureSaved && (userInfo.value.userType === '1')) {
|
|
|
+ message.error('请先保存签名');
|
|
|
+ formLoading.value = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
await studentSelectSupervisorRecordApi.createStudentSelectSupervisorRecord(data);
|
|
|
message.success(t('common.createSuccess'));
|
|
|
} else if (formType.value === 'update') {
|
|
|
await studentSelectSupervisorRecordApi.updateStudentSelectSupervisorRecord(data);
|
|
|
message.success(t('common.updateSuccess'));
|
|
|
} else if (formType.value === 'agree') {
|
|
|
+ const isSupervisorSignatureSaved = formData.value.supervisorSignature.startsWith('data:image/png;base64,');
|
|
|
+ if (!isSupervisorSignatureSaved && (userInfo.value.userType === '3'|| userInfo.value.userType === '5')) {
|
|
|
+ message.error('请先保存签名');
|
|
|
+ formLoading.value = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
await studentSelectSupervisorRecordApi.agreeStudentSelectSupervisorRecord(data);
|
|
|
message.success("已经同意申请");
|
|
|
}else if (formType.value === 'updateone') {
|
|
@@ -622,7 +670,7 @@ const submitForm = async () => {
|
|
|
}else if (formType.value === 'updatetwo') {
|
|
|
// const id = data.studentId
|
|
|
await studentSelectSupervisorRecordApi.collegeCreate(data);
|
|
|
- message.success("common.createSuccess");
|
|
|
+ message.success(t('common.updateSuccess'));
|
|
|
}
|
|
|
dialogVisible.value = false;
|
|
|
emit('success');
|