hrsass-components 2.4.4 → 2.4.6
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/lib/hrsass-components.js +150 -78
- package/lib/hrsass-components.min.js +1 -1
- package/package.json +1 -1
- package/rollup.build.css +10492 -0
package/lib/hrsass-components.js
CHANGED
|
@@ -65,7 +65,7 @@ var contentStyle = _interopDefault(require('!!raw-loader!tinymce/skins/content/d
|
|
|
65
65
|
var SvgPanZoom = _interopDefault(require('svg-pan-zoom'));
|
|
66
66
|
var saveSvgAsPng = require('save-svg-as-png');
|
|
67
67
|
|
|
68
|
-
var version = "2.4.
|
|
68
|
+
var version = "2.4.6";
|
|
69
69
|
|
|
70
70
|
/**
|
|
71
71
|
* 版本号
|
|
@@ -12058,94 +12058,93 @@ var index$6 = {
|
|
|
12058
12058
|
},
|
|
12059
12059
|
// 计算导出图片的 scale
|
|
12060
12060
|
calcExportScale: function calcExportScale(svgWidth, svgHeight) {
|
|
12061
|
-
|
|
12062
|
-
|
|
12063
|
-
var
|
|
12064
|
-
//
|
|
12065
|
-
var
|
|
12066
|
-
|
|
12067
|
-
|
|
12068
|
-
|
|
12069
|
-
|
|
12070
|
-
|
|
12071
|
-
|
|
12072
|
-
|
|
12073
|
-
if (scale < 1) scale = 1;
|
|
12074
|
-
if (scale > 3) scale = 3;
|
|
12075
|
-
return Math.round(scale);
|
|
12061
|
+
var realZoom = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
12062
|
+
// 导出图片的宽
|
|
12063
|
+
var exportW = 4800;
|
|
12064
|
+
// svg原始宽
|
|
12065
|
+
var svgW = svgWidth / realZoom;
|
|
12066
|
+
if (svgW > exportW) {
|
|
12067
|
+
exportW = svgW;
|
|
12068
|
+
}
|
|
12069
|
+
|
|
12070
|
+
// 计算scale
|
|
12071
|
+
var scale = exportW / svgW / realZoom;
|
|
12072
|
+
return scale;
|
|
12076
12073
|
},
|
|
12074
|
+
// 导出图片
|
|
12077
12075
|
exportSvg: function exportSvg(fileName) {
|
|
12078
|
-
var svg = this.$refs.hrOrgChartSvg;
|
|
12079
|
-
var bBox = svg.getBBox();
|
|
12080
|
-
var clonedSvg = svg.cloneNode(true);
|
|
12081
|
-
clonedSvg.setAttribute('width', bBox.width);
|
|
12082
|
-
clonedSvg.setAttribute('height', bBox.height);
|
|
12083
|
-
clonedSvg.setAttribute('viewBox', "".concat(bBox.x, " ").concat(bBox.y, " ").concat(bBox.width, " ").concat(bBox.height));
|
|
12084
|
-
var svgStr = new XMLSerializer().serializeToString(clonedSvg);
|
|
12085
|
-
// 使用自适应scale
|
|
12086
|
-
var scale = this.calcExportScale(bBox.width, bBox.height);
|
|
12087
|
-
var options = {
|
|
12088
|
-
scale: scale,
|
|
12089
|
-
width: bBox.width,
|
|
12090
|
-
height: bBox.height,
|
|
12091
|
-
left: 0,
|
|
12092
|
-
top: 0
|
|
12093
|
-
};
|
|
12094
|
-
this.svgToPng(svgStr, options, fileName);
|
|
12095
|
-
// this.setState({
|
|
12096
|
-
// loading: true,
|
|
12097
|
-
// isDownload: true,
|
|
12098
|
-
// })
|
|
12099
|
-
// svgAsDataUri(this.$refs.hrOrgChartSvg, options).then(url => {
|
|
12100
|
-
// let dataUrL = url.split('base64,')[1]
|
|
12101
|
-
// this.$axios.post('/business/org/Company/getOrgDiagram.data', { 'base64Str': dataUrL, name: fileName || 'org.png' }).then(res => {
|
|
12102
|
-
// window.open(`${process.env.VUE_APP_API_BASE_URL}/file.nolog?method=download&fileId=${res}`);
|
|
12103
|
-
// this.setState({
|
|
12104
|
-
// loading: false,
|
|
12105
|
-
// isDownload: false
|
|
12106
|
-
// })
|
|
12107
|
-
// })
|
|
12108
|
-
// });
|
|
12109
|
-
// saveSvgAsPng(this.$refs.hrOrgChartSvg, fileName || 'org.png', {
|
|
12110
|
-
// scale: 1,
|
|
12111
|
-
// width: bBox.width,
|
|
12112
|
-
// height: bBox.height,
|
|
12113
|
-
// top: bBox.y,
|
|
12114
|
-
// left: bBox.x,
|
|
12115
|
-
// });
|
|
12116
|
-
},
|
|
12117
|
-
svgToPng: function svgToPng(svgStr, options, fileName) {
|
|
12118
12076
|
var _this6 = this;
|
|
12119
12077
|
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
12120
|
-
var
|
|
12078
|
+
var svg, bBox, clonedSvg, svgStr, realZoom, scale, options;
|
|
12121
12079
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
12122
12080
|
while (1) switch (_context.prev = _context.next) {
|
|
12081
|
+
case 0:
|
|
12082
|
+
svg = _this6.$refs.hrOrgChartSvg;
|
|
12083
|
+
bBox = svg.getBBox();
|
|
12084
|
+
clonedSvg = svg.cloneNode(true);
|
|
12085
|
+
clonedSvg.setAttribute('width', bBox.width);
|
|
12086
|
+
clonedSvg.setAttribute('height', bBox.height);
|
|
12087
|
+
clonedSvg.setAttribute('viewBox', "".concat(bBox.x, " ").concat(bBox.y, " ").concat(bBox.width, " ").concat(bBox.height));
|
|
12088
|
+
_context.next = 8;
|
|
12089
|
+
return _this6.transformImage(clonedSvg);
|
|
12090
|
+
case 8:
|
|
12091
|
+
clonedSvg = _context.sent;
|
|
12092
|
+
svgStr = new XMLSerializer().serializeToString(clonedSvg); // 获取当前svgPanZoom缩放比例
|
|
12093
|
+
realZoom = 1;
|
|
12094
|
+
if (_this6.svgPanZoom) {
|
|
12095
|
+
realZoom = _this6.svgPanZoom.getSizes().realZoom || 1;
|
|
12096
|
+
}
|
|
12097
|
+
// 使用自适应scale
|
|
12098
|
+
scale = _this6.calcExportScale(bBox.width, bBox.height, realZoom);
|
|
12099
|
+
options = {
|
|
12100
|
+
scale: scale,
|
|
12101
|
+
width: bBox.width,
|
|
12102
|
+
height: bBox.height,
|
|
12103
|
+
left: 0,
|
|
12104
|
+
top: 0
|
|
12105
|
+
};
|
|
12106
|
+
_this6.svgToPng(svgStr, options, fileName);
|
|
12107
|
+
case 15:
|
|
12108
|
+
case "end":
|
|
12109
|
+
return _context.stop();
|
|
12110
|
+
}
|
|
12111
|
+
}, _callee);
|
|
12112
|
+
}))();
|
|
12113
|
+
},
|
|
12114
|
+
// svg转png
|
|
12115
|
+
svgToPng: function svgToPng(svgStr, options, fileName) {
|
|
12116
|
+
var _this7 = this;
|
|
12117
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
12118
|
+
var blob, url, imgData;
|
|
12119
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
12120
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
12123
12121
|
case 0:
|
|
12124
12122
|
blob = new Blob([svgStr], {
|
|
12125
12123
|
type: 'image/svg+xml'
|
|
12126
12124
|
});
|
|
12127
|
-
|
|
12128
|
-
return
|
|
12125
|
+
_context2.next = 3;
|
|
12126
|
+
return _this7.blobToDataUrl(blob);
|
|
12129
12127
|
case 3:
|
|
12130
|
-
url =
|
|
12131
|
-
|
|
12132
|
-
return
|
|
12128
|
+
url = _context2.sent;
|
|
12129
|
+
_context2.next = 6;
|
|
12130
|
+
return _this7.drawToCanvas(url, options);
|
|
12133
12131
|
case 6:
|
|
12134
|
-
imgData =
|
|
12135
|
-
|
|
12132
|
+
imgData = _context2.sent;
|
|
12133
|
+
_this7.downloadFile(imgData, fileName || 'org.png');
|
|
12136
12134
|
case 8:
|
|
12137
12135
|
case "end":
|
|
12138
|
-
return
|
|
12136
|
+
return _context2.stop();
|
|
12139
12137
|
}
|
|
12140
|
-
},
|
|
12138
|
+
}, _callee2);
|
|
12141
12139
|
}))();
|
|
12142
12140
|
},
|
|
12141
|
+
// 生成图片数据url
|
|
12143
12142
|
blobToDataUrl: function blobToDataUrl(blob) {
|
|
12144
|
-
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
12145
|
-
return _regeneratorRuntime.wrap(function
|
|
12146
|
-
while (1) switch (
|
|
12143
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
12144
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
12145
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
12147
12146
|
case 0:
|
|
12148
|
-
return
|
|
12147
|
+
return _context3.abrupt("return", new Promise(function (resolve, reject) {
|
|
12149
12148
|
var reader = new FileReader();
|
|
12150
12149
|
reader.onload = function () {
|
|
12151
12150
|
resolve(reader.result);
|
|
@@ -12155,17 +12154,89 @@ var index$6 = {
|
|
|
12155
12154
|
}));
|
|
12156
12155
|
case 1:
|
|
12157
12156
|
case "end":
|
|
12158
|
-
return
|
|
12157
|
+
return _context3.stop();
|
|
12159
12158
|
}
|
|
12160
|
-
},
|
|
12159
|
+
}, _callee3);
|
|
12160
|
+
}))();
|
|
12161
|
+
},
|
|
12162
|
+
// 处理图片
|
|
12163
|
+
transformImage: function transformImage(svgNode) {
|
|
12164
|
+
var _this8 = this;
|
|
12165
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
|
12166
|
+
var imageList, tasks;
|
|
12167
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
12168
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
12169
|
+
case 0:
|
|
12170
|
+
imageList = _toConsumableArray(svgNode.getElementsByTagName('image') || []);
|
|
12171
|
+
tasks = imageList.map( /*#__PURE__*/function () {
|
|
12172
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(image) {
|
|
12173
|
+
var href, imgData, imgUrl;
|
|
12174
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
12175
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
12176
|
+
case 0:
|
|
12177
|
+
href = image.getAttribute('href') || image.getAttributeNS('http://www.w3.org/1999/xlink', 'href');
|
|
12178
|
+
if (!href) {
|
|
12179
|
+
_context4.next = 11;
|
|
12180
|
+
break;
|
|
12181
|
+
}
|
|
12182
|
+
if (!href.startsWith('data:image/')) {
|
|
12183
|
+
_context4.next = 4;
|
|
12184
|
+
break;
|
|
12185
|
+
}
|
|
12186
|
+
return _context4.abrupt("return");
|
|
12187
|
+
case 4:
|
|
12188
|
+
_context4.next = 6;
|
|
12189
|
+
return _this8.requestImage(href);
|
|
12190
|
+
case 6:
|
|
12191
|
+
imgData = _context4.sent;
|
|
12192
|
+
_context4.next = 9;
|
|
12193
|
+
return _this8.blobToDataUrl(imgData);
|
|
12194
|
+
case 9:
|
|
12195
|
+
imgUrl = _context4.sent;
|
|
12196
|
+
image.setAttribute('href', imgUrl);
|
|
12197
|
+
case 11:
|
|
12198
|
+
case "end":
|
|
12199
|
+
return _context4.stop();
|
|
12200
|
+
}
|
|
12201
|
+
}, _callee4);
|
|
12202
|
+
}));
|
|
12203
|
+
return function (_x2) {
|
|
12204
|
+
return _ref.apply(this, arguments);
|
|
12205
|
+
};
|
|
12206
|
+
}());
|
|
12207
|
+
_context5.next = 4;
|
|
12208
|
+
return Promise.all(tasks);
|
|
12209
|
+
case 4:
|
|
12210
|
+
return _context5.abrupt("return", svgNode);
|
|
12211
|
+
case 5:
|
|
12212
|
+
case "end":
|
|
12213
|
+
return _context5.stop();
|
|
12214
|
+
}
|
|
12215
|
+
}, _callee5);
|
|
12161
12216
|
}))();
|
|
12162
12217
|
},
|
|
12218
|
+
requestImage: function requestImage(url) {
|
|
12219
|
+
var _this9 = this;
|
|
12220
|
+
if (url.startsWith('/platform_web_portal_war_exploded')) {
|
|
12221
|
+
url = url.replace('/platform_web_portal_war_exploded', '');
|
|
12222
|
+
}
|
|
12223
|
+
return new Promise(function (resolve, reject) {
|
|
12224
|
+
_this9.$axios.get(url, {
|
|
12225
|
+
responseType: 'blob'
|
|
12226
|
+
}).then(function (res) {
|
|
12227
|
+
resolve(res);
|
|
12228
|
+
})["catch"](function (err) {
|
|
12229
|
+
reject(err);
|
|
12230
|
+
});
|
|
12231
|
+
});
|
|
12232
|
+
},
|
|
12233
|
+
// 绘制图片到canvas
|
|
12163
12234
|
drawToCanvas: function drawToCanvas(url, options) {
|
|
12164
|
-
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
12165
|
-
return _regeneratorRuntime.wrap(function
|
|
12166
|
-
while (1) switch (
|
|
12235
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
|
|
12236
|
+
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
12237
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
12167
12238
|
case 0:
|
|
12168
|
-
return
|
|
12239
|
+
return _context6.abrupt("return", new Promise(function (resolve, reject) {
|
|
12169
12240
|
var img = new Image();
|
|
12170
12241
|
img.setAttribute('crossOrigin', 'anonymous');
|
|
12171
12242
|
img.onload = function () {
|
|
@@ -12196,11 +12267,12 @@ var index$6 = {
|
|
|
12196
12267
|
}));
|
|
12197
12268
|
case 1:
|
|
12198
12269
|
case "end":
|
|
12199
|
-
return
|
|
12270
|
+
return _context6.stop();
|
|
12200
12271
|
}
|
|
12201
|
-
},
|
|
12272
|
+
}, _callee6);
|
|
12202
12273
|
}))();
|
|
12203
12274
|
},
|
|
12275
|
+
// 下载文件
|
|
12204
12276
|
downloadFile: function downloadFile(data, fileName) {
|
|
12205
12277
|
var a = document.createElement('a');
|
|
12206
12278
|
a.href = data;
|