commit:支持后台扩展类

This commit is contained in:
Jerry
2024-09-09 21:28:59 +08:00
parent b7362c6b79
commit 7fe3091e6e
16 changed files with 1145 additions and 68 deletions

View File

@@ -4,6 +4,8 @@
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="./lib/print/print.css"/>
<script src="./lib/print/print.js"></script>
<title>橙单代码生成平台</title>
</head>
<body>

View File

@@ -15,6 +15,7 @@
"ace-builds": "^1.32.2",
"axios": "^1.5.1",
"bpmn-js-token-simulation": "^0.10.0",
"diagram-js": "^6.8.2",
"clipboard": "^2.0.11",
"core-js": "^3.8.3",
"crypto-js": "^4.2.0",
@@ -27,6 +28,7 @@
"json-bigint": "^1.0.0",
"pinia": "^2.1.6",
"pinia-plugin-persist": "^1.0.0",
"print-js": "^1.6.0",
"vant": "^4.7.3",
"vue": "^3.3.8",
"vue-draggable-plus": "0.3.1",
@@ -51,8 +53,8 @@
"@vue/cli-plugin-vuex": "~5.0.0",
"@vue/cli-service": "~5.0.0",
"autoprefixer": "^10.4.16",
"bpmn-js": "^7.4.0",
"bpmn-js-properties-panel": "^0.37.2",
"bpmn-js": "7.5.0",
"bpmn-js-properties-panel": "0.37.6",
"eslint": "^8.30.0",
"eslint-config-prettier": "^8.5.0",
"eslint-import-resolver-typescript": "^3.6.1",

View File

@@ -0,0 +1,97 @@
/*
|--------------------------------------------------------------------------
| Modules
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| Aliases
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| Partials
|--------------------------------------------------------------------------
*/
.printModal {
font-family: sans-serif;
display: flex;
text-align: center;
font-weight: 300;
font-size: 30px;
left: 0;
top: 0;
position: absolute;
color: #045fb4;
width: 100%;
height: 100%;
background-color: rgba(255, 255, 255, 0.9); }
/*
|--------------------------------------------------------------------------
| Close Button
|--------------------------------------------------------------------------
*/
.printClose {
position: absolute;
right: 10px;
top: 10px; }
.printClose:before {
content: "\00D7";
font-family: "Helvetica Neue", sans-serif;
font-weight: 100;
line-height: 1px;
padding-top: 0.5em;
display: block;
font-size: 2em;
text-indent: 1px;
overflow: hidden;
height: 1.25em;
width: 1.25em;
text-align: center;
cursor: pointer; }
.printSpinner {
margin-top: 3px;
margin-left: -40px;
position: absolute;
display: inline-block;
width: 25px;
height: 25px;
border: 2px solid #045fb4;
border-radius: 50%;
animation: spin 0.75s infinite linear; }
.printSpinner::before, .printSpinner::after {
left: -2px;
top: -2px;
display: none;
position: absolute;
content: '';
width: inherit;
height: inherit;
border: inherit;
border-radius: inherit; }
.printSpinner, .printSpinner::before, .printSpinner::after {
display: inline-block;
border-color: transparent;
border-top-color: #045fb4;
animation-duration: 1.2s; }
.printSpinner::before {
transform: rotate(120deg); }
.printSpinner::after {
transform: rotate(240deg); }
/* Keyframes for the animation */
@keyframes spin {
from {
transform: rotate(0deg); }
to {
transform: rotate(360deg); }
}
/*# sourceMappingURL=print.map*/

View File

@@ -0,0 +1,992 @@
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define([], factory);
else if(typeof exports === 'object')
exports["printJS"] = factory();
else
root["printJS"] = factory();
})(window, function() {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ let installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ let module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ let ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value !== 'string') for(let key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ let getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 0);
/******/ })
/************************************************************************/
/******/ ({
/***/ "./src/index.js":
/*! **********************!*\
!*** ./src/index.js ***!
\**********************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ let _sass_index_scss__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sass/index.scss */ "./src/sass/index.scss");
/* harmony import */ let _sass_index_scss__WEBPACK_IMPORTED_MODULE_0___default = /* #__PURE__ */__webpack_require__.n(_sass_index_scss__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ let _js_init__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./js/init */ "./src/js/init.js");
let printJS = _js_init__WEBPACK_IMPORTED_MODULE_1__["default"].init;
if (typeof window !== 'undefined') {
window.printJS = printJS;
}
/* harmony default export */ __webpack_exports__["default"] = (printJS);
/***/ }),
/***/ "./src/js/browser.js":
/*! ***************************!*\
!*** ./src/js/browser.js ***!
\***************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
var Browser = {
// Firefox 1.0+
isFirefox: function isFirefox() {
return typeof InstallTrigger !== 'undefined';
},
// Internet Explorer 6-11
isIE: function isIE() {
return navigator.userAgent.indexOf('MSIE') !== -1 || !!document.documentMode;
},
// Edge 20+
isEdge: function isEdge() {
return !Browser.isIE() && !!window.StyleMedia;
},
// Chrome 1+
isChrome: function isChrome() {
let context = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window;
return !!context.chrome;
},
// At least Safari 3+: "[object HTMLElementConstructor]"
isSafari: function isSafari() {
return Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0 || navigator.userAgent.toLowerCase().indexOf('safari') !== -1;
},
// IOS Chrome
isIOSChrome: function isIOSChrome() {
return navigator.userAgent.toLowerCase().indexOf('crios') !== -1;
}
};
/* harmony default export */ __webpack_exports__["default"] = (Browser);
/***/ }),
/***/ "./src/js/functions.js":
/*! *****************************!*\
!*** ./src/js/functions.js ***!
\*****************************/
/*! exports provided: addWrapper, capitalizePrint, collectStyles, addHeader, cleanUp, isRawHTML */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "addWrapper", function() { return addWrapper; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "capitalizePrint", function() { return capitalizePrint; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "collectStyles", function() { return collectStyles; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "addHeader", function() { return addHeader; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "cleanUp", function() { return cleanUp; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isRawHTML", function() { return isRawHTML; });
/* harmony import */ let _modal__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./modal */ "./src/js/modal.js");
/* harmony import */ let _browser__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./browser */ "./src/js/browser.js");
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function addWrapper(htmlData, params) {
let bodyStyle = 'font-family:' + params.font + ' !important; font-size: ' + params.font_size + ' !important; width:100%;';
return '<div style="' + bodyStyle + '">' + htmlData + '</div>';
}
function capitalizePrint(obj) {
return obj.charAt(0).toUpperCase() + obj.slice(1);
}
function collectStyles(element, params) {
let win = document.defaultView || window; // String variable to hold styling for each element
let elementStyle = ''; // Loop over computed styles
let styles = win.getComputedStyle(element, '');
for (let key = 0; key < styles.length; key++) {
// Check if style should be processed
if (params.targetStyles.indexOf('*') !== -1 || params.targetStyle.indexOf(styles[key]) !== -1 || targetStylesMatch(params.targetStyles, styles[key])) {
if (styles.getPropertyValue(styles[key])) elementStyle += styles[key] + ':' + styles.getPropertyValue(styles[key]) + ';';
}
} // Print friendly defaults (deprecated)
// elementStyle += 'max-width: ' + params.maxWidth + 'px !important; font-size: ' + params.font_size + ' !important;';
elementStyle += 'max-width: ' + params.maxWidth + 'px !important;';
return elementStyle;
}
function targetStylesMatch(styles, value) {
for (let i = 0; i < styles.length; i++) {
if (_typeof(value) === 'object' && value.indexOf(styles[i]) !== -1) return true;
}
return false;
}
function addHeader(printElement, params) {
// Create the header container div
let headerContainer = document.createElement('div'); // Check if the header is text or raw html
if (isRawHTML(params.header)) {
headerContainer.innerHTML = params.header;
} else {
// Create header element
let headerElement = document.createElement('h1'); // Create header text node
let headerNode = document.createTextNode(params.header); // Build and style
headerElement.appendChild(headerNode);
headerElement.setAttribute('style', params.headerStyle);
headerContainer.appendChild(headerElement);
}
printElement.insertBefore(headerContainer, printElement.childNodes[0]);
}
function cleanUp(params) {
// If we are showing a feedback message to user, remove it
if (params.showModal) _modal__WEBPACK_IMPORTED_MODULE_0__["default"].close(); // Check for a finished loading hook function
if (params.onLoadingEnd) params.onLoadingEnd(); // If preloading pdf files, clean blob url
if (params.showModal || params.onLoadingStart) window.URL.revokeObjectURL(params.printable); // Run onPrintDialogClose callback
let event = 'mouseover';
if (_browser__WEBPACK_IMPORTED_MODULE_1__["default"].isChrome() || _browser__WEBPACK_IMPORTED_MODULE_1__["default"].isFirefox()) {
// Ps.: Firefox will require an extra click in the document to fire the focus event.
event = 'focus';
}
let handler = function handler() {
// Make sure the event only happens once.
window.removeEventListener(event, handler);
params.onPrintDialogClose(); // Remove iframe from the DOM
let iframe = document.getElementById(params.frameId);
if (iframe) {
iframe.remove();
}
};
window.addEventListener(event, handler);
}
function isRawHTML(raw) {
let regexHtml = new RegExp('<([A-Za-z][A-Za-z0-9]*)\\b[^>]*>(.*?)</\\1>');
return regexHtml.test(raw);
}
/***/ }),
/***/ "./src/js/html.js":
/*! ************************!*\
!*** ./src/js/html.js ***!
\************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ let _functions__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./functions */ "./src/js/functions.js");
/* harmony import */ let _print__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./print */ "./src/js/print.js");
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
/* harmony default export */ __webpack_exports__["default"] = ({
print: function print(params, printFrame) {
// Get the DOM printable element
let printElement = isHtmlElement(params.printable) ? params.printable : document.getElementById(params.printable); // Check if the element exists
if (!printElement) {
window.console.error('Invalid HTML element id: ' + params.printable);
return;
} // Clone the target element including its children (if available)
params.printableElement = cloneElement(printElement, params); // Add header
if (params.header) {
Object(_functions__WEBPACK_IMPORTED_MODULE_0__["addHeader"])(params.printableElement, params);
} // Print html element contents
_print__WEBPACK_IMPORTED_MODULE_1__["default"].send(params, printFrame);
}
});
function cloneElement(element, params) {
// Clone the main node (if not already inside the recursion process)
let clone = element.cloneNode(); // Loop over and process the children elements / nodes (including text nodes)
let childNodesArray = Array.prototype.slice.call(element.childNodes);
for (let i = 0; i < childNodesArray.length; i++) {
// Check if we are skipping the current element
if (params.ignoreElements.indexOf(childNodesArray[i].id) !== -1) {
continue;
} // Clone the child element
let clonedChild = cloneElement(childNodesArray[i], params); // Attach the cloned child to the cloned parent node
clone.appendChild(clonedChild);
} // Get all styling for print element (for nodes of type element only)
if (params.scanStyles && element.nodeType === 1) {
clone.setAttribute('style', Object(_functions__WEBPACK_IMPORTED_MODULE_0__["collectStyles"])(element, params));
} // Check if the element needs any state processing (copy user input data)
switch (element.tagName) {
case 'SELECT':
// Copy the current selection value to its clone
clone.value = element.value;
break;
case 'CANVAS':
// Copy the canvas content to its clone
clone.getContext('2d').drawImage(element, 0, 0);
break;
}
return clone;
}
function isHtmlElement(printable) {
// Check if element is instance of HTMLElement or has nodeType === 1 (for elements in iframe)
return _typeof(printable) === 'object' && printable && (printable instanceof HTMLElement || printable.nodeType === 1);
}
/***/ }),
/***/ "./src/js/image.js":
/*! *************************!*\
!*** ./src/js/image.js ***!
\*************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ let _functions__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./functions */ "./src/js/functions.js");
/* harmony import */ let _print__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./print */ "./src/js/print.js");
/* harmony import */ let _browser__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./browser */ "./src/js/browser.js");
/* harmony default export */ __webpack_exports__["default"] = ({
print: function print(params, printFrame) {
// Check if we are printing one image or multiple images
if (params.printable.constructor !== Array) {
// Create array with one image
params.printable = [params.printable];
} // Create printable element (container)
params.printableElement = document.createElement('div'); // Create all image elements and append them to the printable container
params.printable.forEach(function (src) {
// Create the image element
let img = document.createElement('img');
img.setAttribute('style', params.imageStyle); // Set image src with the file url
img.src = src; // The following block is for Firefox, which for some reason requires the image's src to be fully qualified in
// order to print it
if (_browser__WEBPACK_IMPORTED_MODULE_2__["default"].isFirefox()) {
let fullyQualifiedSrc = img.src;
img.src = fullyQualifiedSrc;
} // Create the image wrapper
let imageWrapper = document.createElement('div'); // Append image to the wrapper element
imageWrapper.appendChild(img); // Append wrapper to the printable element
params.printableElement.appendChild(imageWrapper);
}); // Check if we are adding a print header
if (params.header) Object(_functions__WEBPACK_IMPORTED_MODULE_0__["addHeader"])(params.printableElement, params); // Print image
_print__WEBPACK_IMPORTED_MODULE_1__["default"].send(params, printFrame);
}
});
/***/ }),
/***/ "./src/js/init.js":
/*! ************************!*\
!*** ./src/js/init.js ***!
\************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ let _browser__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./browser */ "./src/js/browser.js");
/* harmony import */ let _modal__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./modal */ "./src/js/modal.js");
/* harmony import */ let _pdf__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pdf */ "./src/js/pdf.js");
/* harmony import */ let _html__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./html */ "./src/js/html.js");
/* harmony import */ let _raw_html__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./raw-html */ "./src/js/raw-html.js");
/* harmony import */ let _image__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./image */ "./src/js/image.js");
/* harmony import */ let _json__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./json */ "./src/js/json.js");
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
let printTypes = ['pdf', 'html', 'image', 'json', 'raw-html'];
/* harmony default export */ __webpack_exports__["default"] = ({
init: function init() {
let params = {
printable: null,
fallbackPrintable: null,
type: 'pdf',
header: null,
headerStyle: 'font-weight: 300;',
maxWidth: 800,
properties: null,
gridHeaderStyle: 'font-weight: bold; padding: 5px; border: 1px solid #dddddd;',
gridStyle: 'border: 1px solid lightgray; margin-bottom: -1px;',
showModal: false,
onError: function onError(error) {
throw error;
},
onLoadingStart: null,
onLoadingEnd: null,
onPrintDialogClose: function onPrintDialogClose() {},
onIncompatibleBrowser: function onIncompatibleBrowser() {},
modalMessage: 'Retrieving Document...',
frameId: 'printJS',
printableElement: null,
documentTitle: 'Document',
targetStyle: ['clear', 'display', 'width', 'min-width', 'height', 'min-height', 'max-height'],
targetStyles: ['border', 'box', 'break', 'text-decoration'],
ignoreElements: [],
repeatTableHeader: true,
css: null,
style: null,
scanStyles: true,
base64: false,
// Deprecated
onPdfOpen: null,
font: 'TimesNewRoman',
font_size: '12pt',
honorMarginPadding: true,
honorColor: false,
imageStyle: 'max-width: 100%;'
}; // Check if a printable document or object was supplied
let args = arguments[0];
if (args === undefined) {
throw new Error('printJS expects at least 1 attribute.');
} // Process parameters
switch (_typeof(args)) {
case 'string':
params.printable = encodeURI(args);
params.fallbackPrintable = params.printable;
params.type = arguments[1] || params.type;
break;
case 'object':
params.printable = args.printable;
params.fallbackPrintable = typeof args.fallbackPrintable !== 'undefined' ? args.fallbackPrintable : params.printable;
params.fallbackPrintable = params.base64 ? "data:application/pdf;base64,".concat(params.fallbackPrintable) : params.fallbackPrintable;
for (let k in params) {
if (k === 'printable' || k === 'fallbackPrintable') continue;
params[k] = typeof args[k] !== 'undefined' ? args[k] : params[k];
}
break;
default:
throw new Error('Unexpected argument type! Expected "string" or "object", got ' + _typeof(args));
} // Validate printable
if (!params.printable) throw new Error('Missing printable information.'); // Validate type
if (!params.type || typeof params.type !== 'string' || printTypes.indexOf(params.type.toLowerCase()) === -1) {
throw new Error('Invalid print type. Available types are: pdf, html, image and json.');
} // Check if we are showing a feedback message to the user (useful for large files)
if (params.showModal) _modal__WEBPACK_IMPORTED_MODULE_1__["default"].show(params); // Check for a print start hook function
if (params.onLoadingStart) params.onLoadingStart(); // To prevent duplication and issues, remove any used printFrame from the DOM
let usedFrame = document.getElementById(params.frameId);
if (usedFrame) usedFrame.parentNode.removeChild(usedFrame); // Create a new iframe for the print job
let printFrame = document.createElement('iframe');
if (_browser__WEBPACK_IMPORTED_MODULE_0__["default"].isFirefox()) {
// Set the iframe to be is visible on the page (guaranteed by fixed position) but hidden using opacity 0, because
// this works in Firefox. The height needs to be sufficient for some part of the document other than the PDF
// viewer's toolbar to be visible in the page
printFrame.setAttribute('style', 'width: 1px; height: 100px; position: fixed; left: 0; top: 0; opacity: 0; border-width: 0; margin: 0; padding: 0');
} else {
// Hide the iframe in other browsers
printFrame.setAttribute('style', 'visibility: hidden; height: 0; width: 0; position: absolute; border: 0');
} // Set iframe element id
printFrame.setAttribute('id', params.frameId); // For non pdf printing, pass an html document string to srcdoc (force onload callback)
if (params.type !== 'pdf') {
printFrame.srcdoc = '<html><head><title>' + params.documentTitle + '</title>'; // Attach css files
if (params.css) {
// Add support for single file
if (!Array.isArray(params.css)) params.css = [params.css]; // Create link tags for each css file
params.css.forEach(function (file) {
printFrame.srcdoc += '<link rel="stylesheet" href="' + file + '">';
});
}
printFrame.srcdoc += '</head><body></body></html>';
} // Check printable type
switch (params.type) {
case 'pdf':
// Check browser support for pdf and if not supported we will just open the pdf file instead
if (_browser__WEBPACK_IMPORTED_MODULE_0__["default"].isIE()) {
try {
console.info('Print.js doesn\'t support PDF printing in Internet Explorer.');
let win = window.open(params.fallbackPrintable, '_blank');
win.focus();
params.onIncompatibleBrowser();
} catch (error) {
params.onError(error);
} finally {
// Make sure there is no loading modal opened
if (params.showModal) _modal__WEBPACK_IMPORTED_MODULE_1__["default"].close();
if (params.onLoadingEnd) params.onLoadingEnd();
}
} else {
_pdf__WEBPACK_IMPORTED_MODULE_2__["default"].print(params, printFrame);
}
break;
case 'image':
_image__WEBPACK_IMPORTED_MODULE_5__["default"].print(params, printFrame);
break;
case 'html':
_html__WEBPACK_IMPORTED_MODULE_3__["default"].print(params, printFrame);
break;
case 'raw-html':
_raw_html__WEBPACK_IMPORTED_MODULE_4__["default"].print(params, printFrame);
break;
case 'json':
_json__WEBPACK_IMPORTED_MODULE_6__["default"].print(params, printFrame);
break;
}
}
});
/***/ }),
/***/ "./src/js/json.js":
/*! ************************!*\
!*** ./src/js/json.js ***!
\************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ let _functions__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./functions */ "./src/js/functions.js");
/* harmony import */ let _print__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./print */ "./src/js/print.js");
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
/* harmony default export */ __webpack_exports__["default"] = ({
print: function print(params, printFrame) {
// Check if we received proper data
if (_typeof(params.printable) !== 'object') {
throw new Error('Invalid javascript data object (JSON).');
} // Validate repeatTableHeader
if (typeof params.repeatTableHeader !== 'boolean') {
throw new Error('Invalid value for repeatTableHeader attribute (JSON).');
} // Validate properties
if (!params.properties || !Array.isArray(params.properties)) {
throw new Error('Invalid properties array for your JSON data.');
} // We will format the property objects to keep the JSON api compatible with older releases
params.properties = params.properties.map(function (property) {
return {
field: _typeof(property) === 'object' ? property.field : property,
displayName: _typeof(property) === 'object' ? property.displayName : property,
columnSize: _typeof(property) === 'object' && property.columnSize ? property.columnSize + ';' : 100 / params.properties.length + '%;'
};
}); // Create a print container element
params.printableElement = document.createElement('div'); // Check if we are adding a print header
if (params.header) {
Object(_functions__WEBPACK_IMPORTED_MODULE_0__["addHeader"])(params.printableElement, params);
} // Build the printable html data
params.printableElement.innerHTML += jsonToHTML(params); // Print the json data
_print__WEBPACK_IMPORTED_MODULE_1__["default"].send(params, printFrame);
}
});
function jsonToHTML(params) {
// Get the row and column data
let data = params.printable;
let properties = params.properties; // Create a html table
let htmlData = '<table style="border-collapse: collapse; width: 100%;">'; // Check if the header should be repeated
if (params.repeatTableHeader) {
htmlData += '<thead>';
} // Add the table header row
htmlData += '<tr>'; // Add the table header columns
for (let a = 0; a < properties.length; a++) {
htmlData += '<th style="width:' + properties[a].columnSize + ';' + params.gridHeaderStyle + '">' + Object(_functions__WEBPACK_IMPORTED_MODULE_0__["capitalizePrint"])(properties[a].displayName) + '</th>';
} // Add the closing tag for the table header row
htmlData += '</tr>'; // If the table header is marked as repeated, add the closing tag
if (params.repeatTableHeader) {
htmlData += '</thead>';
} // Create the table body
htmlData += '<tbody>'; // Add the table data rows
for (let i = 0; i < data.length; i++) {
// Add the row starting tag
htmlData += '<tr>'; // Print selected properties only
for (let n = 0; n < properties.length; n++) {
let stringData = data[i]; // Support nested objects
let property = properties[n].field.split('.');
if (property.length > 1) {
for (let p = 0; p < property.length; p++) {
stringData = stringData[property[p]];
}
} else {
stringData = stringData[properties[n].field];
} // Add the row contents and styles
htmlData += '<td style="width:' + properties[n].columnSize + params.gridStyle + '">' + stringData + '</td>';
} // Add the row closing tag
htmlData += '</tr>';
} // Add the table and body closing tags
htmlData += '</tbody></table>';
return htmlData;
}
/***/ }),
/***/ "./src/js/modal.js":
/*! *************************!*\
!*** ./src/js/modal.js ***!
\*************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
var Modal = {
show: function show(params) {
// Build modal
let modalStyle = 'font-family:sans-serif; ' + 'display:table; ' + 'text-align:center; ' + 'font-weight:300; ' + 'font-size:30px; ' + 'left:0; top:0;' + 'position:fixed; ' + 'z-index: 9990;' + 'color: #0460B5; ' + 'width: 100%; ' + 'height: 100%; ' + 'background-color:rgba(255,255,255,.9);' + 'transition: opacity .3s ease;'; // Create wrapper
let printModal = document.createElement('div');
printModal.setAttribute('style', modalStyle);
printModal.setAttribute('id', 'printJS-Modal'); // Create content div
let contentDiv = document.createElement('div');
contentDiv.setAttribute('style', 'display:table-cell; vertical-align:middle; padding-bottom:100px;'); // Add close button (requires print.css)
let closeButton = document.createElement('div');
closeButton.setAttribute('class', 'printClose');
closeButton.setAttribute('id', 'printClose');
contentDiv.appendChild(closeButton); // Add spinner (requires print.css)
let spinner = document.createElement('span');
spinner.setAttribute('class', 'printSpinner');
contentDiv.appendChild(spinner); // Add message
let messageNode = document.createTextNode(params.modalMessage);
contentDiv.appendChild(messageNode); // Add contentDiv to printModal
printModal.appendChild(contentDiv); // Append print modal element to document body
document.getElementsByTagName('body')[0].appendChild(printModal); // Add event listener to close button
document.getElementById('printClose').addEventListener('click', function () {
Modal.close();
});
},
close: function close() {
let printModal = document.getElementById('printJS-Modal');
if (printModal) {
printModal.parentNode.removeChild(printModal);
}
}
};
/* harmony default export */ __webpack_exports__["default"] = (Modal);
/***/ }),
/***/ "./src/js/pdf.js":
/*! ***********************!*\
!*** ./src/js/pdf.js ***!
\***********************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ let _print__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./print */ "./src/js/print.js");
/* harmony import */ let _functions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./functions */ "./src/js/functions.js");
/* harmony default export */ __webpack_exports__["default"] = ({
print: function print(params, printFrame) {
// Check if we have base64 data
if (params.base64) {
let bytesArray = Uint8Array.from(atob(params.printable), function (c) {
return c.charCodeAt(0);
});
createBlobAndPrint(params, printFrame, bytesArray);
return;
} // Format pdf url
params.printable = /^(blob|http|\/\/)/i.test(params.printable) ? params.printable : window.location.origin + (params.printable.charAt(0) !== '/' ? '/' + params.printable : params.printable); // Get the file through a http request (Preload)
let req = new window.XMLHttpRequest();
req.responseType = 'arraybuffer';
req.addEventListener('error', function () {
Object(_functions__WEBPACK_IMPORTED_MODULE_1__["cleanUp"])(params);
params.onError(req.statusText, req); // Since we don't have a pdf document available, we will stop the print job
});
req.addEventListener('load', function () {
// Check for errors
if ([200, 201].indexOf(req.status) === -1) {
Object(_functions__WEBPACK_IMPORTED_MODULE_1__["cleanUp"])(params);
params.onError(req.statusText, req); // Since we don't have a pdf document available, we will stop the print job
return;
} // Print requested document
createBlobAndPrint(params, printFrame, req.response);
});
req.open('GET', params.printable, true);
req.send();
}
});
function createBlobAndPrint(params, printFrame, data) {
// Pass response or base64 data to a blob and create a local object url
let localPdf = new window.Blob([data], {
type: 'application/pdf'
});
localPdf = window.URL.createObjectURL(localPdf); // Set iframe src with pdf document url
printFrame.setAttribute('src', localPdf);
_print__WEBPACK_IMPORTED_MODULE_0__["default"].send(params, printFrame);
}
/***/ }),
/***/ "./src/js/print.js":
/*! *************************!*\
!*** ./src/js/print.js ***!
\*************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ let _browser__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./browser */ "./src/js/browser.js");
/* harmony import */ let _functions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./functions */ "./src/js/functions.js");
let Print = {
send: function send(params, printFrame) {
// Append iframe element to document body
document.getElementsByTagName('body')[0].appendChild(printFrame); // Get iframe element
let iframeElement = document.getElementById(params.frameId); // Wait for iframe to load all content
iframeElement.onload = function () {
if (params.type === 'pdf') {
// Add a delay for Firefox. In my tests, 1000ms was sufficient but 100ms was not
if (_browser__WEBPACK_IMPORTED_MODULE_0__["default"].isFirefox()) {
setTimeout(function () {
return performPrint(iframeElement, params);
}, 1000);
} else {
performPrint(iframeElement, params);
}
return;
} // Get iframe element document
let printDocument = iframeElement.contentWindow || iframeElement.contentDocument;
if (printDocument.document) printDocument = printDocument.document; // Append printable element to the iframe body
printDocument.body.appendChild(params.printableElement); // Add custom style
if (params.type !== 'pdf' && params.style) {
// Create style element
let style = document.createElement('style');
style.innerHTML = params.style; // Append style element to iframe's head
printDocument.head.appendChild(style);
} // If printing images, wait for them to load inside the iframe
let images = printDocument.getElementsByTagName('img');
if (images.length > 0) {
loadIframeImages(Array.from(images)).then(function () {
return performPrint(iframeElement, params);
});
} else {
performPrint(iframeElement, params);
}
};
}
};
function performPrint(iframeElement, params) {
try {
iframeElement.focus(); // If Edge or IE, try catch with execCommand
if (_browser__WEBPACK_IMPORTED_MODULE_0__["default"].isEdge() || _browser__WEBPACK_IMPORTED_MODULE_0__["default"].isIE()) {
try {
iframeElement.contentWindow.document.execCommand('print', false, null);
} catch (e) {
iframeElement.contentWindow.print();
}
} else {
// Other browsers
iframeElement.contentWindow.print();
}
} catch (error) {
params.onError(error);
} finally {
if (_browser__WEBPACK_IMPORTED_MODULE_0__["default"].isFirefox()) {
// Move the iframe element off-screen and make it invisible
iframeElement.style.visibility = 'hidden';
iframeElement.style.left = '-1px';
}
Object(_functions__WEBPACK_IMPORTED_MODULE_1__["cleanUp"])(params);
}
}
function loadIframeImages(images) {
let promises = images.map(function (image) {
if (image.src && image.src !== window.location.href) {
return loadIframeImage(image);
}
});
return Promise.all(promises);
}
function loadIframeImage(image) {
return new Promise(function (resolve) {
let pollImage = function pollImage() {
!image || typeof image.naturalWidth === 'undefined' || image.naturalWidth === 0 || !image.complete ? setTimeout(pollImage, 500) : resolve();
};
pollImage();
});
}
/* harmony default export */ __webpack_exports__["default"] = (Print);
/***/ }),
/***/ "./src/js/raw-html.js":
/*! ****************************!*\
!*** ./src/js/raw-html.js ***!
\****************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ let _print__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./print */ "./src/js/print.js");
/* harmony default export */ __webpack_exports__["default"] = ({
print: function print(params, printFrame) {
// Create printable element (container)
params.printableElement = document.createElement('div');
params.printableElement.setAttribute('style', 'width:100%'); // Set our raw html as the printable element inner html content
params.printableElement.innerHTML = params.printable; // Print html contents
_print__WEBPACK_IMPORTED_MODULE_0__["default"].send(params, printFrame);
}
});
/***/ }),
/***/ "./src/sass/index.scss":
/*! *****************************!*\
!*** ./src/sass/index.scss ***!
\*****************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
// extracted by mini-css-extract-plugin
/***/ }),
/***/ 0:
/*! ****************************!*\
!*** multi ./src/index.js ***!
\****************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(/*! ./src/index.js */"./src/index.js");
/***/ })
/******/ })["default"];
});
// # sourceMappingURL=print.map

File diff suppressed because one or more lines are too long

View File

@@ -39,6 +39,7 @@ $table-row-height: 50px;
$--color-white: #FFF !default;
$--border-color-base: #DCDFE6;
$--color-primary: #F70 !default;
$--color-sidebar-title-text: #FFF;
$--color-menu-background: #2D3039;
$--color-text-secondary: #909399 !default;
@@ -57,71 +58,71 @@ $--color-primary-light-9: color-mix(in srgb, $--color-white 90%, $--color-primar
/**
* 弹窗样式封装的layer的弹窗
**/
.layui-layer-page .layui-layer-title{
body .layui-layer-page .layui-layer-title{
border:1px solid #01000000;
border-radius: 4px 4px 0 0;
background-color: #f8f8f8;
}
.layui-layer-page .slot-fragment {
body .layui-layer-page .slot-fragment {
height: 100%;
}
.layui-layer-page .layui-layer-setwin {color: #fff}
body .layui-layer-page .layui-layer-setwin {color: #fff}
.layui-layer-page {
body .layui-layer-page {
border:1px solid #01000000;
border-radius: 4px;
}
.layui-layer-page .layui-layer-content {
body .layui-layer-page .layui-layer-content {
padding: $box-padding-size;
}
.layui-layer-page.one_to_one_query .layui-layer-content {
body .layui-layer-page.one_to_one_query .layui-layer-content {
padding: 0;
}
.layui-layer-page.layui-layer-iframe .layui-layer-content {
body .layui-layer-page.layui-layer-iframe .layui-layer-content {
padding: 0!important;
}
/**
* 左树右表弹窗样式
*/
.layer-advance-dialog {
body .layer-advance-dialog {
background-color: #F8F8F8;
border:1px solid #01000000;
border-radius: 4px;
}
.layer-advance-dialog .layui-layer-title{
body .layer-advance-dialog .layui-layer-title{
border:1px solid #01000000;
border-radius: 4px 4px 0 0;
}
.layer-advance-dialog .layui-layer-content {
body .layer-advance-dialog .layui-layer-content {
padding: 5px 15px;
}
/**
* 全屏弹窗样式
*/
.fullscreen-dialog {
body .fullscreen-dialog {
background-color: #F8F8F8;
border: none;
border-radius: 0;
}
.fullscreen-dialog .layui-layer-title {
body .fullscreen-dialog .layui-layer-title {
display: none;
}
.fullscreen-dialog .layui-layer-setwin {
body .fullscreen-dialog .layui-layer-setwin {
display: none;
}
.fullscreen-dialog .layui-layer-content {
body .fullscreen-dialog .layui-layer-content {
height: 100vh!important;
padding: 0;
}
@@ -762,6 +763,10 @@ $--color-primary-light-9: color-mix(in srgb, $--color-white 90%, $--color-primar
}
}
.relation-select-popper {
display: none;
}
.vxe-table--render-default.border--full .vxe-body--column {
background-size: 1px 100%,100% 0!important;
border-bottom: 1px solid #e8eaec;

View File

@@ -245,7 +245,7 @@ export const download = async (
url: string,
params: ANY_OBJECT,
filename: string,
method?: RequestMethods,
method: RequestMethods = 'post',
options?: RequestOption,
) => {
return new Promise((resolve, reject) => {

View File

@@ -347,7 +347,7 @@ const handleCommand = (command: string) => {
Dialog.show('修改头像', FormModifyHeadImage, { area: '500px' }, {});
break;
default:
ElMessage.warning(`click on item ${command}`);
ElMessage.warning(`click on item `);
break;
}
};

View File

@@ -12,7 +12,10 @@
:change="onValueChange"
@widgetClick="onWidgetClick"
>
<template v-if="form().mode === 'pc' && widget.widgetType !== SysCustomWidgetType.Cascader" v-slot="scope">
<template
v-if="form().mode === 'pc' && widget.widgetType !== SysCustomWidgetType.Cascader"
v-slot="scope"
>
<template v-if="widget.widgetType === SysCustomWidgetType.Radio">
<el-radio v-for="item in getAllDropdownData" :key="item.id" :value="item.id">
{{ item.name }}

View File

@@ -88,15 +88,6 @@
<vxe-column title="工单状态" field="flowStatusShowName" :min-width="100" />
<vxe-column title="操作" :width="160" fixed="right" :show-overflow="false">
<template #default="{ row }">
<el-button
link
:size="layoutStore.defaultFormItemSize"
v-if="getPrintOperation != null"
:class="getPrintOperation.btnClass"
@click.stop="onPrint(getPrintOperation, row)"
>
{{ getPrintOperation.name || '打印' }}
</el-button>
<el-button
link
type="primary"
@@ -250,7 +241,7 @@ const remoteSort = computed(() => {
});
const getPrintOperation = computed(() => {
let operation = findItemFromList(
form().operationList,
props.widget.operationList,
SysCustomWidgetOperationType.PRINT,
'type',
);
@@ -398,36 +389,6 @@ const getPrintParamItem = (row: ANY_OBJECT, printParamList: ANY_OBJECT[]) => {
return param;
};
const onPrint = (operation: ANY_OBJECT, row: ANY_OBJECT) => {
if (operation == null || row == null || row.processDefinitionKey == null) return;
let printParam;
let temp = getPrintParamItem(row, operation.printParamList);
printParam = temp ? [temp] : [];
let params = {
printId: operation.printTemplateId,
printParams: printParam,
};
post<string>(
API_CONTEXT + '/flow/flowOnlineOperation/printWorkOrder/' + row.processDefinitionKey,
params,
)
.then(res => {
let downloadUrl = res.data;
downloadBlob(downloadUrl, {})
.then((blobData: Blob) => {
let pdfUrl = window.URL.createObjectURL(blobData);
window.open('./lib/pdfjs/web/viewer.html?file=' + pdfUrl);
})
.catch(e => {
console.log(e);
ElMessage.error(e);
});
})
.catch(e => {
console.warn(e);
});
};
const formatListData = (data: ANY_OBJECT) => {
Object.keys(data).forEach(key => {
let subData = data[key];

View File

@@ -34,6 +34,15 @@
<el-input v-model="formPageData.pageName" @change="dirty = true" />
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="后台扩展类">
<el-input
v-model="formPageData.extraJson.extendClass"
placeholder="请输入包含包名的完整类名称"
@change="dirty = true"
/>
</el-form-item>
</el-col>
</el-form>
</div>
</template>
@@ -85,6 +94,7 @@ const savePageInfo = (status: number) => {
let params = {
onlinePageDto: {
...formPageData.value,
extraJson: JSON.stringify(formPageData.value.extraJson || {}),
status: status,
published: false,
},

View File

@@ -1,6 +1,12 @@
<template>
<el-row>
<el-form label-position="left" label-width="115px" size="default" @submit.prevent>
<el-form
label-position="left"
label-width="115px"
size="default"
style="width: 100%"
@submit.prevent
>
<el-col :span="24">
<el-form-item label="弹窗表单选择">
<el-select

View File

@@ -156,7 +156,7 @@ export const useFormConfig = () => {
maskFieldList: [],
allowEventList: [OnlineFormEventType.AFTER_CREATE_FORM],
fullscreen: true,
supportOperation: true,
supportOperation: false,
width: 800,
};

View File

@@ -92,7 +92,7 @@ export const useWidgetToolkit = () => {
break;
case SysCustomWidgetType.Switch:
case SysCustomWidgetType.MobileSwitchFilter:
disabled = columnFieldType !== 'Boolean';
disabled = columnFieldType !== 'Boolean' && columnFieldType !== 'Number';
break;
case SysCustomWidgetType.Slider:
case SysCustomWidgetType.Stepper:
@@ -147,5 +147,6 @@ export const useWidgetToolkit = () => {
}
return {
columnIsValidByWidgetType,
getColumnDataType,
};
};

View File

@@ -249,12 +249,6 @@ const onSetOnlineFormAuth = () => {
{
formAuth: formData.value.formAuth || {},
formWidgetConfig: tempConfig,
path: 'thirdSetOnlineFormAuth',
},
{
width: '1000px',
height: '700px',
pathName: '/thirdParty/formSetOnlineFormAuth',
},
)
.then(res => {

View File

@@ -5,4 +5,7 @@ export interface FormPage {
pageType?: number;
published: boolean;
status: number;
extraJson: {
extendClass?: string;
};
}