@focus-teach/ui 1.1.5 → 1.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@focus-teach/ui",
3
3
  "packageName": "ui",
4
4
  "publishName": "@focus-teach/ui",
5
- "version": "1.1.5",
5
+ "version": "1.1.7",
6
6
  "private": false,
7
7
  "main": "lib/ui.umd.min.js",
8
8
  "scripts": {
@@ -22,7 +22,9 @@
22
22
  "babel-loader": "^8.0.0",
23
23
  "core-js": "^3.6.5",
24
24
  "crypto-js": "^4.2.0",
25
+ "echarts": "^5.3.3",
25
26
  "element-ui": "^2.15.1",
27
+ "fabric-with-erasing": "^1.0.1",
26
28
  "html2canvas": "^1.4.1",
27
29
  "lodash": "^4.17.21",
28
30
  "md5": "^2.3.0",
package/utils/common.js CHANGED
@@ -662,4 +662,158 @@ export function sleep(time = 0){
662
662
  resolve()
663
663
  },time);
664
664
  })
665
- }
665
+ }
666
+
667
+ export function toDecimal2NoZero(x) {
668
+ var f = Math.round(x * 100) / 100;
669
+ var s = f.toString();
670
+ return s;
671
+ }
672
+ export function getScoreRateLevel(scoreRate) {
673
+ scoreRate = +scoreRate;
674
+ if (scoreRate < 60) return 'l';
675
+ if (scoreRate < 80) return 'm';
676
+ if (scoreRate <= 100) return 'h'
677
+ }
678
+ export function handleExcellentTypicalData(examItemList, i, type, _this) {
679
+ for (var j = 0; j < examItemList[i][type].length; j++) {
680
+ // 处理每个学生的题目图片
681
+ var imageFileId = examItemList[i][type][j].imageFileId
682
+ var imgArr = this.getImageFileIdList(examSource, imageFileId)
683
+ if (imgArr.length > 1) {
684
+ var indexList = []
685
+ for (var a = 0; a < imgArr.length; a++) {
686
+ indexList.push({
687
+ id: imgArr[a],
688
+ index: getImageFileIdIndex(examSource, imgArr[a], a)
689
+ })
690
+ }
691
+ indexList.sort(function (a, b) {
692
+ return a.index - b.index
693
+ })
694
+ var result = []
695
+ for (var b = 0; b < indexList.length; b++) {
696
+ result.push({
697
+ id: indexList[b].id,
698
+ index: 'img' + indexList[b].index
699
+ })
700
+ }
701
+ handleExcellentTypicalImage(i, j, result, type, _this, yjdcCallBack)
702
+ }
703
+ }
704
+ }
705
+ function getImageFileIdList(examSource, imageFileId) {//查找图片的索引
706
+ let list = []
707
+ switch (examSource) {
708
+ case 'WY':
709
+ list = imageFileId.split(';')
710
+ break;
711
+ default:
712
+ list = imageFileId.split(',')
713
+ break;
714
+ }
715
+ return list
716
+ }
717
+ function handleExcellentTypicalImage(firstIndex, secondIndex, imgArr, type, _this, callback) {
718
+ var loadNum = 0
719
+ var imgTotal = imgArr.length
720
+ var imgInfo = {}
721
+ for (var j = 0; j < imgTotal; j++) {
722
+ imgInfo[imgArr[j].index] = {
723
+ image: ''
724
+ }
725
+ }
726
+ for (var i = 0; i < imgTotal; i++) {
727
+ imgInfo[imgArr[i].index].image = new Image()
728
+ imgInfo[imgArr[i].index].image.src = getImageSrc(imgArr[i].id);
729
+ imgInfo[imgArr[i].index].image.crossOrigin = 'Anonymous';
730
+ imgInfo[imgArr[i].index].image.onload = function () {
731
+ loadNum++
732
+ if (loadNum == imgTotal) {
733
+ var imgInfoList = []
734
+ var widthList = []
735
+ var heightSum = 0
736
+ for (var item in imgInfo) {
737
+ imgInfoList.push({
738
+ width: imgInfo[item].image.width,
739
+ height: imgInfo[item].image.height,
740
+ image: imgInfo[item].image
741
+ })
742
+ widthList.push(imgInfo[item].image.width)
743
+ heightSum += imgInfo[item].image.height
744
+ }
745
+ var canvas = document.createElement("canvas");
746
+ canvas.width = Math.max.apply(null, widthList);
747
+ canvas.height = heightSum;
748
+ var context = canvas.getContext("2d");
749
+ context.rect(0, 0, canvas.width, canvas.height);
750
+ context.fillStyle = "#fff";
751
+ context.fill();
752
+ console.log(imgInfoList);
753
+ for (var imgInfoListIndex = 0; imgInfoListIndex < imgInfoList.length; imgInfoListIndex++) {
754
+ if (imgInfoListIndex == 0) {
755
+ context.drawImage(imgInfoList[imgInfoListIndex].image, 0, 0, canvas.width, imgInfoList[imgInfoListIndex].height);
756
+ } else {
757
+ var renderHeight = getHeight(imgInfoList, 'height', imgInfoListIndex - 1)
758
+ console.log("renderHeight", renderHeight);
759
+ context.drawImage(imgInfoList[imgInfoListIndex].image, 0, renderHeight, canvas.width, imgInfoList[imgInfoListIndex].height);
760
+ }
761
+ }
762
+ var base64 = canvas.toDataURL("image/jpeg", 0.4); //"image/png" 这里注意一下
763
+ this.examItemList[firstIndex][type][secondIndex].imageFileId = base64
764
+ this.examItemList[firstIndex][type][secondIndex].handled = true
765
+
766
+ if (examItemList[firstIndex][type].length - 1 == secondIndex) {
767
+ console.log("当前类型图片处理完", type, secondIndex);
768
+ yjdcLoadCount++
769
+ if (yjdcLoadCount == yjdcCount) {
770
+ console.log("执行回调函数");
771
+ callback(_this, firstIndex, type)
772
+ }
773
+ }
774
+ }
775
+ }
776
+ }
777
+ }
778
+ function getImageSrc(imageFileId) {
779
+ return isStartHttp(imageFileId) ? imageFileId : "/files/" + imageFileId + "?type=2"
780
+ }
781
+ function isStartHttp(url) {
782
+ try {
783
+ if (url.startsWith("http://") || url.startsWith("https://")) {
784
+ return true
785
+ }
786
+ } catch (e) {
787
+ return false
788
+ }
789
+ }
790
+ function getImageFileIdIndex(examSource, imageFileId, index) {//查找图片的索引
791
+ console.log('imageFileId', imageFileId)
792
+ let idx = ''
793
+ switch (examSource) {
794
+ case 'WY':
795
+ // idx = parseInt(imageFileId.match(/_(\d*).jpg/g)[0].match(/\d/g).join(''))
796
+ idx = index
797
+ break;
798
+ default:
799
+ idx = parseInt(imageFileId.match(/-(\d*)jpg/g)[0].match(/\d/g).join(''))
800
+ break;
801
+ }
802
+ return idx
803
+ }
804
+ function getHeight(arr, prop, index) {
805
+ var total = 0
806
+ for (var i = 0; i < arr.length; i++) {
807
+ if (i <= index) {
808
+ total += arr[i][prop]
809
+ }
810
+ }
811
+ return total
812
+ }
813
+
814
+
815
+
816
+
817
+
818
+
819
+