|
|
@@ -1,3 +1,5 @@
|
|
|
+import { MessageBox, Message } from 'element-ui';
|
|
|
+
|
|
|
// 写一个防抖函数
|
|
|
export function debounce(fn, delay) {
|
|
|
let timer = null
|
|
|
@@ -36,7 +38,7 @@ export function throttle(fn, delay) {
|
|
|
// arrDPI[1] = window.screen.deviceYDPI;
|
|
|
|
|
|
// } else {
|
|
|
-
|
|
|
+
|
|
|
|
|
|
// var tmpNode = document.createElement("DIV");
|
|
|
|
|
|
@@ -61,7 +63,7 @@ export function throttle(fn, delay) {
|
|
|
*/
|
|
|
function getDPI() {
|
|
|
return window.devicePixelRatio * 96; // 通常情况下,1英寸 = 96像素
|
|
|
- }
|
|
|
+}
|
|
|
|
|
|
|
|
|
//毫米转px
|
|
|
@@ -101,7 +103,7 @@ export function fixNumber(num) {
|
|
|
|
|
|
export function pxToMm(px) {
|
|
|
|
|
|
- if (px) {
|
|
|
+ if (px) {
|
|
|
// 获取设备像素比
|
|
|
const devicePixelRatio = window.devicePixelRatio || 1;
|
|
|
// 标准DPI为96,考虑设备像素比进行调整
|
|
|
@@ -132,20 +134,18 @@ export function pxToMm(px) {
|
|
|
|
|
|
// 保留整数 小数 四舍五入
|
|
|
export function mmToPx(num) {
|
|
|
- if(num)
|
|
|
- {
|
|
|
+ if (num) {
|
|
|
// console.log("num",num);
|
|
|
// console.log("转换后",Math.round(1754/297*num));
|
|
|
// let scale=1754/297;
|
|
|
// let result=(scale*num).toFixed(4);
|
|
|
// console.log("scale",scale,result);
|
|
|
- let scale=1754/297;
|
|
|
- return parseFloat((scale*num).toFixed(4)); //高 150dpi 1754 96dpi:1120 1754*2480
|
|
|
+ let scale = 1754 / 297;
|
|
|
+ return parseFloat((scale * num).toFixed(4)); //高 150dpi 1754 96dpi:1120 1754*2480
|
|
|
// return Math.round(1754/297*num)
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- console.log("num",num);
|
|
|
+ else {
|
|
|
+ console.log("num", num);
|
|
|
return 0;
|
|
|
}
|
|
|
}
|
|
|
@@ -168,101 +168,162 @@ export function mmToPx(num) {
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
- //获取显示的状态
|
|
|
- export function getStateName(scannedStatus,studentStatus)
|
|
|
- {
|
|
|
- // console.log(scannedStatus,studentStatus);
|
|
|
- let result='正常';
|
|
|
- if(scannedStatus==1)
|
|
|
- {
|
|
|
- result='正常'
|
|
|
-
|
|
|
- }else if(scannedStatus==2)
|
|
|
- {
|
|
|
- result='缺考'
|
|
|
-
|
|
|
- }else if(scannedStatus==3)
|
|
|
- {
|
|
|
- //异常分类
|
|
|
- if(studentStatus==2)
|
|
|
- {
|
|
|
- result='定位异常'
|
|
|
-
|
|
|
- }else if(studentStatus==3)
|
|
|
- {
|
|
|
- result='考号异常'
|
|
|
-
|
|
|
- }else if(studentStatus==4)
|
|
|
- {
|
|
|
- result='客观题异常'
|
|
|
-
|
|
|
- }else if(studentStatus==5)
|
|
|
- {
|
|
|
- result='选做题异常'
|
|
|
-
|
|
|
- }else if(studentStatus==6)
|
|
|
- {
|
|
|
- result='空白卷异常'
|
|
|
-
|
|
|
- }else if(studentStatus==7)
|
|
|
- {
|
|
|
- result='考号重复'
|
|
|
- }
|
|
|
- }
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- //获取百分比 type progress 表示进度条使用
|
|
|
- export function getPercentage(num1,num2,type)
|
|
|
- {
|
|
|
-
|
|
|
- let result=0;
|
|
|
- let percentage=0;
|
|
|
- if(num1 && num2)
|
|
|
- {
|
|
|
- percentage=(parseFloat(num1)/parseFloat(num2)).toFixed(2);
|
|
|
+//获取显示的状态
|
|
|
+export function getStateName(scannedStatus, studentStatus) {
|
|
|
+ // console.log(scannedStatus,studentStatus);
|
|
|
+ let result = '正常';
|
|
|
+ if (scannedStatus == 1) {
|
|
|
+ result = '正常'
|
|
|
+
|
|
|
+ } else if (scannedStatus == 2) {
|
|
|
+ result = '缺考'
|
|
|
+
|
|
|
+ } else if (scannedStatus == 3) {
|
|
|
+ //异常分类
|
|
|
+ if (studentStatus == 2) {
|
|
|
+ result = '定位异常'
|
|
|
+
|
|
|
+ } else if (studentStatus == 3) {
|
|
|
+ result = '考号异常'
|
|
|
+
|
|
|
+ } else if (studentStatus == 4) {
|
|
|
+ result = '客观题异常'
|
|
|
+
|
|
|
+ } else if (studentStatus == 5) {
|
|
|
+ result = '选做题异常'
|
|
|
+
|
|
|
+ } else if (studentStatus == 6) {
|
|
|
+ result = '空白卷异常'
|
|
|
+
|
|
|
+ } else if (studentStatus == 7) {
|
|
|
+ result = '考号重复'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+//获取百分比 type progress 表示进度条使用
|
|
|
+export function getPercentage(num1, num2, type) {
|
|
|
+
|
|
|
+ let result = 0;
|
|
|
+ let percentage = 0;
|
|
|
+ if (num1 && num2) {
|
|
|
+ percentage = (parseFloat(num1) / parseFloat(num2)).toFixed(2);
|
|
|
|
|
|
}
|
|
|
|
|
|
- result= Math.round(percentage*100);
|
|
|
+ result = Math.round(percentage * 100);
|
|
|
// console.log("num1,num2",num1,num2,percentage,result);
|
|
|
- if(type=='progress')
|
|
|
- {
|
|
|
-
|
|
|
+ if (type == 'progress') {
|
|
|
+
|
|
|
//进度条的值不能超100%
|
|
|
- if(result>100)
|
|
|
- {
|
|
|
- result=100;
|
|
|
+ if (result > 100) {
|
|
|
+ result = 100;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
- if(result<0)
|
|
|
- {
|
|
|
- result=0;
|
|
|
+ if (result < 0) {
|
|
|
+ result = 0;
|
|
|
}
|
|
|
-
|
|
|
-// console.log("打印结果",result);
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
- //获取考试背景颜色值
|
|
|
- export function getExamBackgroundColor(type)
|
|
|
- {
|
|
|
- const examTypesColor={
|
|
|
- "1": {color:'#F56C6C',background:'#F56C6C'},//期末
|
|
|
- "2": {color:'#3ba272',background:'#3ba272'},//期中
|
|
|
- "3": {color:'#ea7acb',background:'#ea7acb'},//模拟
|
|
|
- "4": {color:'#fac858',background:'#fac858'},//月考
|
|
|
- "5": {color:'#995fb3',background:'#995fb3'},//周测
|
|
|
- "6": {color:'#72C0DD',background:'#72C0DD'},//平时
|
|
|
+
|
|
|
+ // console.log("打印结果",result);
|
|
|
+ return result;
|
|
|
+}
|
|
|
+
|
|
|
+//获取考试背景颜色值
|
|
|
+export function getExamBackgroundColor(type) {
|
|
|
+ const examTypesColor = {
|
|
|
+ "1": { color: '#F56C6C', background: '#F56C6C' },//期末
|
|
|
+ "2": { color: '#3ba272', background: '#3ba272' },//期中
|
|
|
+ "3": { color: '#ea7acb', background: '#ea7acb' },//模拟
|
|
|
+ "4": { color: '#fac858', background: '#fac858' },//月考
|
|
|
+ "5": { color: '#995fb3', background: '#995fb3' },//周测
|
|
|
+ "6": { color: '#72C0DD', background: '#72C0DD' },//平时
|
|
|
};
|
|
|
- const result=examTypesColor[type].background;
|
|
|
-
|
|
|
+ const result = examTypesColor[type].background;
|
|
|
+
|
|
|
return result;
|
|
|
- }
|
|
|
- //获取当前接口地址名称
|
|
|
- export function getApiName(){
|
|
|
+}
|
|
|
+//获取当前接口地址名称
|
|
|
+export function getApiName() {
|
|
|
const schoolType = sessionStorage.getItem('schoolType') ?? 1;//1:单校 2:联校
|
|
|
- return schoolType==1?'schoolReport':'jointSchoolReport'
|
|
|
- }
|
|
|
+ return schoolType == 1 ? 'schoolReport' : 'jointSchoolReport'
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+* 显示确认对话框
|
|
|
+* @param {string} title - 对话框标题
|
|
|
+* @param {function} successCallback - 确认按钮回调函数
|
|
|
+* @param {function|string} [cancelCallback='已取消操作'] - 取消按钮回调函数或提示信息
|
|
|
+*/
|
|
|
+export function confirm(title, successCallback, cancelCallback = '已取消操作') {
|
|
|
+ MessageBox.confirm(title, '提示', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning',
|
|
|
+ customClass: 'page_dialog',
|
|
|
+ }).then(successCallback).catch(() => {
|
|
|
+ const type = typeof cancelCallback;
|
|
|
+ if (type === 'function') {
|
|
|
+ cancelCallback();
|
|
|
+ return;
|
|
|
+ } else {
|
|
|
+ info(cancelCallback);
|
|
|
+ }
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * 显示成功消息
|
|
|
+ * @param {string} message - 消息内容
|
|
|
+*/
|
|
|
+export function success(message) {
|
|
|
+ Message({
|
|
|
+ message,
|
|
|
+ type: 'success',
|
|
|
+ duration: 2000
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * 显示错误消息
|
|
|
+ * @param {string} message - 消息内容
|
|
|
+*/
|
|
|
+export function error(message) {
|
|
|
+ Message({
|
|
|
+ message,
|
|
|
+ type: 'error',
|
|
|
+ duration: 2000
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * 显示信息消息
|
|
|
+ * @param {string} message - 消息内容
|
|
|
+*/
|
|
|
+export function info(message) {
|
|
|
+ Message({
|
|
|
+ message,
|
|
|
+ type: 'info',
|
|
|
+ duration: 2000
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * 显示警告消息
|
|
|
+ * @param {string} message - 消息内容
|
|
|
+*/
|
|
|
+export function warning(message) {
|
|
|
+ Message({
|
|
|
+ message,
|
|
|
+ type: 'warning',
|
|
|
+ duration: 2000
|
|
|
+ });
|
|
|
+}
|