xh-lab-rc 0.18.48 → 0.18.50
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/dist/LabAltimeter/KemiAlt/index.js +3 -10
- package/dist/LabAltimeter/index.js +6 -19
- package/dist/LabAttachmentPreview/index.d.ts +23 -0
- package/dist/LabAttachmentPreview/index.js +484 -0
- package/dist/LabAttachmentPreview/style.less +196 -0
- package/dist/LabDGTreeSelect/index.js +3 -9
- package/dist/LabFilePreview/index.js +5 -19
- package/dist/LabGTreeSelect/index.js +4 -15
- package/dist/LabGroupTree/index.js +5 -12
- package/dist/LabIconFont/index.js +1 -6
- package/dist/LabMultipleSelect/index.js +3 -9
- package/dist/LabOffice/index.js +4 -15
- package/dist/LabOperateTree/index.js +4 -16
- package/dist/LabPSwitchPreview/index.js +2 -12
- package/dist/LabPdfView/index.js +3 -10
- package/dist/LabPdfViewMobile/index.js +3 -10
- package/dist/LabPictureCarousel/index.js +3 -16
- package/dist/components/Iconfont/iconfont.js +13 -13
- package/dist/components/Iconfont/index.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/utils/utils.d.ts +6 -1
- package/dist/utils/utils.js +14 -9
- package/package.json +7 -7
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
5
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
6
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
7
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
8
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
9
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
10
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
1
|
+
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
3
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
11
4
|
/*
|
|
12
5
|
* @Author: xqy
|
|
13
6
|
* @Date: 2024-06-28 14:07:14
|
|
@@ -1,22 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
8
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
9
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
10
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
11
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
12
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
13
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
14
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
15
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
16
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
17
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
18
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
19
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
1
|
+
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
3
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
4
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
5
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
6
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
20
7
|
/*
|
|
21
8
|
* @Author: xqy
|
|
22
9
|
* @Date: 2024-04-23 13:43:55
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { FC } from 'react';
|
|
2
|
+
import './style.less';
|
|
3
|
+
interface IndexProps {
|
|
4
|
+
imgList: any;
|
|
5
|
+
curImgIndex?: number;
|
|
6
|
+
fileField?: FileField;
|
|
7
|
+
isCanvasImg?: boolean;
|
|
8
|
+
getRotateImg?: (file?: any) => void;
|
|
9
|
+
styles?: object;
|
|
10
|
+
contDivStyle?: object;
|
|
11
|
+
footerStyle?: object;
|
|
12
|
+
ref?: any;
|
|
13
|
+
baseUrl?: string;
|
|
14
|
+
pdfjsSrc?: string;
|
|
15
|
+
isBtnSwitch?: boolean;
|
|
16
|
+
}
|
|
17
|
+
interface FileField {
|
|
18
|
+
filePath?: string;
|
|
19
|
+
fileName?: string;
|
|
20
|
+
[key: string]: any;
|
|
21
|
+
}
|
|
22
|
+
declare const LabAttachmentPreview: FC<IndexProps>;
|
|
23
|
+
export default LabAttachmentPreview;
|
|
@@ -0,0 +1,484 @@
|
|
|
1
|
+
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
2
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
4
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
5
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
6
|
+
/*
|
|
7
|
+
* @Author: xqy
|
|
8
|
+
* @Date: 2026-03-16 09:43:38
|
|
9
|
+
* @LastEditors: xqy
|
|
10
|
+
* @LastEditTime: 2026-03-19 14:02:09
|
|
11
|
+
* @Description: 横向附件预览(支持pdf切换预览)
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { Iconfont } from "../components";
|
|
15
|
+
import { downloadFileWithBlob, labCanvasToFile } from "../utils/utils";
|
|
16
|
+
import { FileTextOutlined, LeftOutlined, RightOutlined, RotateLeftOutlined, RotateRightOutlined, ZoomInOutlined, ZoomOutOutlined } from '@ant-design/icons';
|
|
17
|
+
import { Splitter } from 'antd';
|
|
18
|
+
import axios from 'axios';
|
|
19
|
+
import cn from 'classnames';
|
|
20
|
+
import React, { forwardRef, useEffect, useRef, useState } from 'react';
|
|
21
|
+
import { LabPdf } from "./..";
|
|
22
|
+
import "./style.less";
|
|
23
|
+
var LabAttachmentPreview = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
24
|
+
var _list$curIndex5, _list$curIndex6, _list$curIndex7;
|
|
25
|
+
var imgList = _ref.imgList,
|
|
26
|
+
_ref$curImgIndex = _ref.curImgIndex,
|
|
27
|
+
curImgIndex = _ref$curImgIndex === void 0 ? 0 : _ref$curImgIndex,
|
|
28
|
+
_ref$fileField = _ref.fileField,
|
|
29
|
+
fileField = _ref$fileField === void 0 ? {
|
|
30
|
+
filePath: 'filePath',
|
|
31
|
+
fileName: 'fileName',
|
|
32
|
+
fileType: 'fileType'
|
|
33
|
+
} : _ref$fileField,
|
|
34
|
+
_ref$isCanvasImg = _ref.isCanvasImg,
|
|
35
|
+
isCanvasImg = _ref$isCanvasImg === void 0 ? false : _ref$isCanvasImg,
|
|
36
|
+
getRotateImg = _ref.getRotateImg,
|
|
37
|
+
styles = _ref.styles,
|
|
38
|
+
contDivStyle = _ref.contDivStyle,
|
|
39
|
+
footerStyle = _ref.footerStyle,
|
|
40
|
+
_ref$baseUrl = _ref.baseUrl,
|
|
41
|
+
baseUrl = _ref$baseUrl === void 0 ? '' : _ref$baseUrl,
|
|
42
|
+
_ref$pdfjsSrc = _ref.pdfjsSrc,
|
|
43
|
+
pdfjsSrc = _ref$pdfjsSrc === void 0 ? "".concat(baseUrl, "/statics/pdfjs/web/viewer.html") : _ref$pdfjsSrc,
|
|
44
|
+
_ref$isBtnSwitch = _ref.isBtnSwitch,
|
|
45
|
+
isBtnSwitch = _ref$isBtnSwitch === void 0 ? false : _ref$isBtnSwitch;
|
|
46
|
+
var _useState = useState(curImgIndex),
|
|
47
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
48
|
+
curIndex = _useState2[0],
|
|
49
|
+
setCurIndex = _useState2[1];
|
|
50
|
+
var _useState3 = useState(1),
|
|
51
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
52
|
+
scale = _useState4[0],
|
|
53
|
+
setScale = _useState4[1]; //初始缩放比例
|
|
54
|
+
var _useState5 = useState([]),
|
|
55
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
56
|
+
list = _useState6[0],
|
|
57
|
+
setList = _useState6[1]; //图片的数组
|
|
58
|
+
var _useState7 = useState(0),
|
|
59
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
60
|
+
rotatinNum = _useState8[0],
|
|
61
|
+
setRotatinNum = _useState8[1]; //旋转次数
|
|
62
|
+
var canvasRef = useRef(null);
|
|
63
|
+
var _useState9 = useState(false),
|
|
64
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
65
|
+
dragging = _useState10[0],
|
|
66
|
+
setDragging = _useState10[1]; //拖拽状态
|
|
67
|
+
var _useState11 = useState({
|
|
68
|
+
left: 'auto',
|
|
69
|
+
top: 'auto'
|
|
70
|
+
}),
|
|
71
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
72
|
+
position = _useState12[0],
|
|
73
|
+
setPosition = _useState12[1]; // 用于存储图片位置的状态
|
|
74
|
+
var _useState13 = useState({
|
|
75
|
+
left: 0,
|
|
76
|
+
top: 0
|
|
77
|
+
}),
|
|
78
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
79
|
+
initialPosition = _useState14[0],
|
|
80
|
+
setInitialPosition = _useState14[1]; //(被点击元素相对于页面偏移量))
|
|
81
|
+
var _useState15 = useState({
|
|
82
|
+
x: 0,
|
|
83
|
+
y: 0
|
|
84
|
+
}),
|
|
85
|
+
_useState16 = _slicedToArray(_useState15, 2),
|
|
86
|
+
initialMousePosition = _useState16[0],
|
|
87
|
+
setInitialMousePosition = _useState16[1]; //鼠标按下的坐标
|
|
88
|
+
|
|
89
|
+
//底部操作按钮
|
|
90
|
+
var _useState17 = useState([{
|
|
91
|
+
type: 'enlarge',
|
|
92
|
+
typeName: '放大(+)',
|
|
93
|
+
icon: /*#__PURE__*/React.createElement(ZoomInOutlined, {
|
|
94
|
+
className: "footer-icon"
|
|
95
|
+
}),
|
|
96
|
+
disabled: false,
|
|
97
|
+
disableName: '已是最大比例'
|
|
98
|
+
}, {
|
|
99
|
+
type: 'narrow',
|
|
100
|
+
typeName: '缩小(-)',
|
|
101
|
+
icon: /*#__PURE__*/React.createElement(ZoomOutOutlined, {
|
|
102
|
+
className: "footer-icon"
|
|
103
|
+
}),
|
|
104
|
+
disabled: false,
|
|
105
|
+
disableName: '已是最小比例'
|
|
106
|
+
}, {
|
|
107
|
+
type: 'turnLeft',
|
|
108
|
+
typeName: '向左旋转',
|
|
109
|
+
icon: /*#__PURE__*/React.createElement(RotateLeftOutlined, {
|
|
110
|
+
className: "footer-icon"
|
|
111
|
+
}),
|
|
112
|
+
disabled: false
|
|
113
|
+
}, {
|
|
114
|
+
type: 'turnRight',
|
|
115
|
+
typeName: '向右旋转',
|
|
116
|
+
icon: /*#__PURE__*/React.createElement(RotateRightOutlined, {
|
|
117
|
+
className: "footer-icon"
|
|
118
|
+
}),
|
|
119
|
+
disabled: false
|
|
120
|
+
}, {
|
|
121
|
+
type: 'downLoad',
|
|
122
|
+
typeName: '下载',
|
|
123
|
+
icon: /*#__PURE__*/React.createElement(Iconfont, {
|
|
124
|
+
type: "icon-xiazai1",
|
|
125
|
+
style: {
|
|
126
|
+
fontSize: '16px',
|
|
127
|
+
color: '#FFFFFF',
|
|
128
|
+
cursor: 'pointer'
|
|
129
|
+
}
|
|
130
|
+
}),
|
|
131
|
+
disabled: false
|
|
132
|
+
}]),
|
|
133
|
+
_useState18 = _slicedToArray(_useState17, 2),
|
|
134
|
+
footerBtns = _useState18[0],
|
|
135
|
+
setFooterBtns = _useState18[1];
|
|
136
|
+
|
|
137
|
+
/**鼠标滚轮实现图片的放大缩小 */
|
|
138
|
+
var handleWheel = function handleWheel(event) {
|
|
139
|
+
// event.preventDefault() //阻止默认的滚动行为,防止浏览器默认进行页面滚动
|
|
140
|
+
var scaleChange = event.deltaY > 0 ? -0.1 : 0.1;
|
|
141
|
+
//计算缩放比例,限制缩放比例在(0.5到4之间),防止过大或过小
|
|
142
|
+
var newScale = Math.min(Math.max(0.2, scale + scaleChange), 4);
|
|
143
|
+
//更新缩放的那一张比例
|
|
144
|
+
var updatedList = _toConsumableArray(list);
|
|
145
|
+
updatedList[curIndex].scale = newScale;
|
|
146
|
+
setList(updatedList);
|
|
147
|
+
setScale(newScale);
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
//图片放大缩小
|
|
151
|
+
var toZoomInOut = function toZoomInOut(type) {
|
|
152
|
+
var ratios = type === 'enlarge' ? scale + 0.2 : scale - 0.2; //比例
|
|
153
|
+
var newScale = Math.min(Math.max(0.2, ratios), 4);
|
|
154
|
+
var updatedList = _toConsumableArray(list);
|
|
155
|
+
updatedList[curIndex].scale = newScale;
|
|
156
|
+
setList(updatedList);
|
|
157
|
+
setScale(newScale);
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
//左右旋转图片
|
|
161
|
+
var toTurnHandle = /*#__PURE__*/function () {
|
|
162
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(direction) {
|
|
163
|
+
var newRotateNum, updatedList, newFiles;
|
|
164
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
165
|
+
while (1) switch (_context.prev = _context.next) {
|
|
166
|
+
case 0:
|
|
167
|
+
newRotateNum = rotatinNum;
|
|
168
|
+
if (direction === 'l') {
|
|
169
|
+
newRotateNum = rotatinNum - 1;
|
|
170
|
+
} else {
|
|
171
|
+
newRotateNum = rotatinNum + 1;
|
|
172
|
+
}
|
|
173
|
+
//更新缩放的那一张比例
|
|
174
|
+
updatedList = _toConsumableArray(list);
|
|
175
|
+
updatedList[curIndex].roteAngle = newRotateNum * 90;
|
|
176
|
+
//旋转之后,利用canvas生成新的二进制图片
|
|
177
|
+
if (!isCanvasImg) {
|
|
178
|
+
_context.next = 18;
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
181
|
+
//生成新图,在新图的基础上只需要旋转90
|
|
182
|
+
updatedList[curIndex].roteAngle = direction === 'l' ? -90 : 90;
|
|
183
|
+
_context.prev = 6;
|
|
184
|
+
_context.next = 9;
|
|
185
|
+
return labCanvasToFile(canvasRef, updatedList[curIndex]);
|
|
186
|
+
case 9:
|
|
187
|
+
newFiles = _context.sent;
|
|
188
|
+
updatedList[curIndex].filePath = URL.createObjectURL(newFiles);
|
|
189
|
+
updatedList[curIndex].blobFilePath = newFiles;
|
|
190
|
+
getRotateImg === null || getRotateImg === void 0 || getRotateImg(_objectSpread(_objectSpread({}, updatedList[curIndex]), {}, {
|
|
191
|
+
blobFilePath: newFiles
|
|
192
|
+
}));
|
|
193
|
+
_context.next = 18;
|
|
194
|
+
break;
|
|
195
|
+
case 15:
|
|
196
|
+
_context.prev = 15;
|
|
197
|
+
_context.t0 = _context["catch"](6);
|
|
198
|
+
console.error('图片旋转失败:', _context.t0);
|
|
199
|
+
case 18:
|
|
200
|
+
setRotatinNum(newRotateNum);
|
|
201
|
+
setList(updatedList);
|
|
202
|
+
case 20:
|
|
203
|
+
case "end":
|
|
204
|
+
return _context.stop();
|
|
205
|
+
}
|
|
206
|
+
}, _callee, null, [[6, 15]]);
|
|
207
|
+
}));
|
|
208
|
+
return function toTurnHandle(_x) {
|
|
209
|
+
return _ref2.apply(this, arguments);
|
|
210
|
+
};
|
|
211
|
+
}();
|
|
212
|
+
|
|
213
|
+
//底部按钮点击事件(enlarge - 放大,narrow - 缩小,turnLeft - 左转, turnRight - 右转)
|
|
214
|
+
var clickHandle = /*#__PURE__*/function () {
|
|
215
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(type) {
|
|
216
|
+
var _list$curIndex, _list$curIndex2, _list$curIndex3;
|
|
217
|
+
var res;
|
|
218
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
219
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
220
|
+
case 0:
|
|
221
|
+
_context2.t0 = type;
|
|
222
|
+
_context2.next = _context2.t0 === 'enlarge' ? 3 : _context2.t0 === 'narrow' ? 5 : _context2.t0 === 'turnLeft' ? 7 : _context2.t0 === 'turnRight' ? 9 : _context2.t0 === 'downLoad' ? 11 : 16;
|
|
223
|
+
break;
|
|
224
|
+
case 3:
|
|
225
|
+
toZoomInOut('enlarge');
|
|
226
|
+
return _context2.abrupt("break", 17);
|
|
227
|
+
case 5:
|
|
228
|
+
toZoomInOut('narrow');
|
|
229
|
+
return _context2.abrupt("break", 17);
|
|
230
|
+
case 7:
|
|
231
|
+
toTurnHandle('l');
|
|
232
|
+
return _context2.abrupt("break", 17);
|
|
233
|
+
case 9:
|
|
234
|
+
toTurnHandle('r');
|
|
235
|
+
return _context2.abrupt("break", 17);
|
|
236
|
+
case 11:
|
|
237
|
+
_context2.next = 13;
|
|
238
|
+
return axios.get(((_list$curIndex = list[curIndex]) === null || _list$curIndex === void 0 ? void 0 : _list$curIndex.filePath) + '', {
|
|
239
|
+
responseType: 'blob'
|
|
240
|
+
});
|
|
241
|
+
case 13:
|
|
242
|
+
res = _context2.sent;
|
|
243
|
+
downloadFileWithBlob({
|
|
244
|
+
name: ((_list$curIndex2 = list[curIndex]) === null || _list$curIndex2 === void 0 ? void 0 : _list$curIndex2.fileName) || '',
|
|
245
|
+
blob: res.data,
|
|
246
|
+
suffix: ((_list$curIndex3 = list[curIndex]) === null || _list$curIndex3 === void 0 || (_list$curIndex3 = _list$curIndex3.filePath) === null || _list$curIndex3 === void 0 ? void 0 : _list$curIndex3.split('.').pop()) || ''
|
|
247
|
+
});
|
|
248
|
+
return _context2.abrupt("break", 17);
|
|
249
|
+
case 16:
|
|
250
|
+
return _context2.abrupt("break", 17);
|
|
251
|
+
case 17:
|
|
252
|
+
case "end":
|
|
253
|
+
return _context2.stop();
|
|
254
|
+
}
|
|
255
|
+
}, _callee2);
|
|
256
|
+
}));
|
|
257
|
+
return function clickHandle(_x2) {
|
|
258
|
+
return _ref3.apply(this, arguments);
|
|
259
|
+
};
|
|
260
|
+
}();
|
|
261
|
+
|
|
262
|
+
//图片拖拽(鼠标按下,开始拖拽)
|
|
263
|
+
var handleMouseDown = function handleMouseDown(event) {
|
|
264
|
+
event.preventDefault();
|
|
265
|
+
setDragging(true);
|
|
266
|
+
// 鼠标按下开始坐标
|
|
267
|
+
setInitialMousePosition({
|
|
268
|
+
x: event.clientX,
|
|
269
|
+
y: event.clientY
|
|
270
|
+
});
|
|
271
|
+
//被点击元素相对于页面的偏移量
|
|
272
|
+
setInitialPosition({
|
|
273
|
+
left: event.currentTarget.offsetLeft,
|
|
274
|
+
top: event.currentTarget.offsetTop
|
|
275
|
+
});
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
//图片拖拽(拖拽移动中)
|
|
279
|
+
var handleMouseMove = function handleMouseMove(event) {
|
|
280
|
+
if (dragging) {
|
|
281
|
+
//计算拖拽移动距离
|
|
282
|
+
var dx = event.clientX - initialMousePosition.x;
|
|
283
|
+
var dy = event.clientY - initialMousePosition.y;
|
|
284
|
+
setPosition({
|
|
285
|
+
left: "".concat(initialPosition.left + dx, "px"),
|
|
286
|
+
top: "".concat(initialPosition.top + dy, "px")
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
// 图片拖拽(鼠标松开,结束拖拽)
|
|
292
|
+
var handleMouseUp = function handleMouseUp() {
|
|
293
|
+
setDragging(false);
|
|
294
|
+
setPosition({
|
|
295
|
+
left: 'auto',
|
|
296
|
+
top: 'auto'
|
|
297
|
+
});
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
//点击左右切换事件
|
|
301
|
+
var carouselClick = function carouselClick(type) {
|
|
302
|
+
setScale(1); //重置初始的缩放比例
|
|
303
|
+
setRotatinNum(0); //重置初始的缩放比例
|
|
304
|
+
if (type === 'l') {
|
|
305
|
+
//向左切换
|
|
306
|
+
if (curIndex === 0) {
|
|
307
|
+
//当前的索引为0,获取最后一张图片
|
|
308
|
+
setCurIndex((list === null || list === void 0 ? void 0 : list.length) - 1);
|
|
309
|
+
return;
|
|
310
|
+
} else {
|
|
311
|
+
//获取上一张的图片
|
|
312
|
+
setCurIndex(curIndex - 1);
|
|
313
|
+
}
|
|
314
|
+
} else {
|
|
315
|
+
//向右切换
|
|
316
|
+
if (curIndex === (list === null || list === void 0 ? void 0 : list.length) - 1) {
|
|
317
|
+
//索引为最后一张,还切换就是切换到第一张
|
|
318
|
+
setCurIndex(0);
|
|
319
|
+
} else {
|
|
320
|
+
//获取下一张的图片
|
|
321
|
+
setCurIndex(curIndex + 1);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
};
|
|
325
|
+
useEffect(function () {
|
|
326
|
+
setCurIndex(curImgIndex !== null && curImgIndex !== void 0 ? curImgIndex : 0);
|
|
327
|
+
//重置旋转次数、缩放、角度比例
|
|
328
|
+
setRotatinNum(0);
|
|
329
|
+
setScale(1);
|
|
330
|
+
if (Array.isArray(imgList) && imgList.length) {
|
|
331
|
+
var arr = imgList.map(function (i) {
|
|
332
|
+
var _Object$keys, _type;
|
|
333
|
+
var name = i === null || i === void 0 ? void 0 : i.fileName;
|
|
334
|
+
var path = i === null || i === void 0 ? void 0 : i.filePath;
|
|
335
|
+
var type = i === null || i === void 0 ? void 0 : i.fileType;
|
|
336
|
+
if ((_Object$keys = Object.keys(fileField)) !== null && _Object$keys !== void 0 && _Object$keys.length) {
|
|
337
|
+
var _i$filePath, _i$filePath2, _i$filePath3;
|
|
338
|
+
var _fileField$filePath = fileField.filePath,
|
|
339
|
+
filePath = _fileField$filePath === void 0 ? '' : _fileField$filePath,
|
|
340
|
+
_fileField$fileName = fileField.fileName,
|
|
341
|
+
fileName = _fileField$fileName === void 0 ? '' : _fileField$fileName,
|
|
342
|
+
_fileField$fileType = fileField.fileType,
|
|
343
|
+
fileType = _fileField$fileType === void 0 ? '' : _fileField$fileType;
|
|
344
|
+
name = name ? name : i[fileName] ? i[fileName] : (_i$filePath = i[filePath]) === null || _i$filePath === void 0 || (_i$filePath = _i$filePath.split('/')) === null || _i$filePath === void 0 ? void 0 : _i$filePath.pop();
|
|
345
|
+
type = type ? type : i[fileType] ? i[fileType] : (_i$filePath2 = i[filePath]) === null || _i$filePath2 === void 0 ? void 0 : _i$filePath2.substring(((_i$filePath3 = i[filePath]) === null || _i$filePath3 === void 0 ? void 0 : _i$filePath3.lastIndexOf('.')) + 1);
|
|
346
|
+
path = path ? path : i[filePath];
|
|
347
|
+
}
|
|
348
|
+
return _objectSpread(_objectSpread({}, i), {}, {
|
|
349
|
+
fileType: (_type = type) === null || _type === void 0 ? void 0 : _type.toLowerCase(),
|
|
350
|
+
filePath: path,
|
|
351
|
+
fileName: name,
|
|
352
|
+
scale: 1,
|
|
353
|
+
roteAngle: 0
|
|
354
|
+
});
|
|
355
|
+
});
|
|
356
|
+
setList(arr);
|
|
357
|
+
}
|
|
358
|
+
}, [imgList]);
|
|
359
|
+
useEffect(function () {
|
|
360
|
+
var newBtns = _toConsumableArray(footerBtns);
|
|
361
|
+
if (scale <= 0.2) {
|
|
362
|
+
//最小的放大比例,缩小禁用
|
|
363
|
+
newBtns[1].disabled = true;
|
|
364
|
+
newBtns[0].disabled = false;
|
|
365
|
+
} else if (scale >= 4) {
|
|
366
|
+
//放大禁用
|
|
367
|
+
newBtns[1].disabled = false;
|
|
368
|
+
newBtns[0].disabled = true;
|
|
369
|
+
} else {
|
|
370
|
+
newBtns[1].disabled = false;
|
|
371
|
+
newBtns[0].disabled = false;
|
|
372
|
+
}
|
|
373
|
+
setFooterBtns(newBtns);
|
|
374
|
+
}, [scale]);
|
|
375
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
376
|
+
className: 'lab-attach-perview',
|
|
377
|
+
style: styles
|
|
378
|
+
}, /*#__PURE__*/React.createElement(Splitter, {
|
|
379
|
+
style: {
|
|
380
|
+
width: '100%',
|
|
381
|
+
height: '100%'
|
|
382
|
+
}
|
|
383
|
+
}, (imgList === null || imgList === void 0 ? void 0 : imgList.length) > 1 && !isBtnSwitch && /*#__PURE__*/React.createElement(Splitter.Panel, {
|
|
384
|
+
defaultSize: 359,
|
|
385
|
+
size: 359,
|
|
386
|
+
min: "20%",
|
|
387
|
+
max: "70%"
|
|
388
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
389
|
+
className: "left"
|
|
390
|
+
}, /*#__PURE__*/React.createElement("ul", null, list.map(function (v, index) {
|
|
391
|
+
var _list$curIndex4;
|
|
392
|
+
return /*#__PURE__*/React.createElement("li", {
|
|
393
|
+
key: v.filePath,
|
|
394
|
+
style: {
|
|
395
|
+
backgroundColor: ((_list$curIndex4 = list[curIndex]) === null || _list$curIndex4 === void 0 ? void 0 : _list$curIndex4.filePath) === (v === null || v === void 0 ? void 0 : v.filePath) ? '#D0E4FF' : ''
|
|
396
|
+
}
|
|
397
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
398
|
+
title: "".concat(v.fileName),
|
|
399
|
+
onClick: function onClick() {
|
|
400
|
+
setCurIndex(index);
|
|
401
|
+
setRotatinNum(0);
|
|
402
|
+
setScale(1);
|
|
403
|
+
}
|
|
404
|
+
}, /*#__PURE__*/React.createElement("i", null, /*#__PURE__*/React.createElement(FileTextOutlined, {
|
|
405
|
+
style: {
|
|
406
|
+
fontSize: '13px',
|
|
407
|
+
color: '#868B9C',
|
|
408
|
+
margin: '0 6px'
|
|
409
|
+
}
|
|
410
|
+
})), v.fileName, ".", v === null || v === void 0 ? void 0 : v.fileType));
|
|
411
|
+
})))), /*#__PURE__*/React.createElement(Splitter.Panel, null, /*#__PURE__*/React.createElement("div", {
|
|
412
|
+
className: "right",
|
|
413
|
+
style: {
|
|
414
|
+
border: ((_list$curIndex5 = list[curIndex]) === null || _list$curIndex5 === void 0 ? void 0 : _list$curIndex5.fileType) !== 'pdf' && isBtnSwitch ? 'none' : '1px solid #D9D9D9',
|
|
415
|
+
borderLeft: (imgList === null || imgList === void 0 ? void 0 : imgList.length) > 1 ? 'none' : '1px solid #D9D9D9',
|
|
416
|
+
backgroundColor: isBtnSwitch ? '#fff' : '#F7F7F7'
|
|
417
|
+
}
|
|
418
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
419
|
+
className: "contentPart"
|
|
420
|
+
}, list[curIndex] && Object.keys(list[curIndex]).length && /*#__PURE__*/React.createElement("div", {
|
|
421
|
+
className: cn('contentDiv', list[curIndex].fileType === 'pdf' && 'pdfStyle'),
|
|
422
|
+
style: contDivStyle
|
|
423
|
+
}, ((_list$curIndex6 = list[curIndex]) === null || _list$curIndex6 === void 0 ? void 0 : _list$curIndex6.fileType) === 'pdf' ? /*#__PURE__*/React.createElement(LabPdf, {
|
|
424
|
+
baseUrl: baseUrl,
|
|
425
|
+
src: list[curIndex].filePath,
|
|
426
|
+
pdfjsSrc: pdfjsSrc
|
|
427
|
+
}) : /*#__PURE__*/React.createElement("img", {
|
|
428
|
+
style: {
|
|
429
|
+
maxWidth: '100%',
|
|
430
|
+
maxHeight: '100%',
|
|
431
|
+
transform: "".concat(isCanvasImg ? '' : "rotate(".concat(list[curIndex].roteAngle, "deg)"), "\n scale3d(").concat(list[curIndex].scale, ", ").concat(list[curIndex].scale, ", 1)"),
|
|
432
|
+
transition: 'transform ease-in-out 0.2s',
|
|
433
|
+
// 添加平滑的缩放过渡效果
|
|
434
|
+
cursor: dragging ? 'grabbing' : 'grab',
|
|
435
|
+
position: 'absolute',
|
|
436
|
+
left: "".concat(position === null || position === void 0 ? void 0 : position.left),
|
|
437
|
+
top: "".concat(position === null || position === void 0 ? void 0 : position.top)
|
|
438
|
+
},
|
|
439
|
+
id: "previewImg",
|
|
440
|
+
src: "".concat(baseUrl).concat(list[curIndex].filePath),
|
|
441
|
+
onWheel: handleWheel,
|
|
442
|
+
key: list[curIndex].filePath,
|
|
443
|
+
onMouseDown: handleMouseDown,
|
|
444
|
+
onMouseMove: handleMouseMove,
|
|
445
|
+
onMouseUp: handleMouseUp
|
|
446
|
+
}))), ((_list$curIndex7 = list[curIndex]) === null || _list$curIndex7 === void 0 ? void 0 : _list$curIndex7.fileType) !== 'pdf' && /*#__PURE__*/React.createElement("div", {
|
|
447
|
+
className: "footer",
|
|
448
|
+
style: footerStyle
|
|
449
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
450
|
+
className: "operate-btn"
|
|
451
|
+
}, footerBtns.map(function (item, index) {
|
|
452
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
453
|
+
onClick: function onClick() {
|
|
454
|
+
return clickHandle(item.type);
|
|
455
|
+
},
|
|
456
|
+
key: item.type,
|
|
457
|
+
className: item.disabled ? 'disable-btn' : '',
|
|
458
|
+
title: item.disabled ? item.disableName : item.typeName,
|
|
459
|
+
style: {
|
|
460
|
+
paddingLeft: index > 0 ? '28px' : '0'
|
|
461
|
+
}
|
|
462
|
+
}, item.icon);
|
|
463
|
+
}))), /*#__PURE__*/React.createElement("canvas", {
|
|
464
|
+
ref: canvasRef,
|
|
465
|
+
style: {
|
|
466
|
+
display: 'none'
|
|
467
|
+
}
|
|
468
|
+
})))), isBtnSwitch && (list === null || list === void 0 ? void 0 : list.length) > 1 && curIndex > 0 && /*#__PURE__*/React.createElement("span", {
|
|
469
|
+
onClick: function onClick() {
|
|
470
|
+
return carouselClick('l');
|
|
471
|
+
},
|
|
472
|
+
className: "toggleIcon leftIcon"
|
|
473
|
+
}, /*#__PURE__*/React.createElement(LeftOutlined, {
|
|
474
|
+
className: "spanIcon"
|
|
475
|
+
})), isBtnSwitch && (list === null || list === void 0 ? void 0 : list.length) > 1 && curIndex < (list === null || list === void 0 ? void 0 : list.length) - 1 && /*#__PURE__*/React.createElement("span", {
|
|
476
|
+
onClick: function onClick() {
|
|
477
|
+
return carouselClick('r');
|
|
478
|
+
},
|
|
479
|
+
className: "toggleIcon rightIcon"
|
|
480
|
+
}, /*#__PURE__*/React.createElement(RightOutlined, {
|
|
481
|
+
className: "spanIcon"
|
|
482
|
+
})));
|
|
483
|
+
});
|
|
484
|
+
export default LabAttachmentPreview;
|