yh-hiprint 2.3.6 → 2.4.1

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.
Files changed (56) hide show
  1. package/HiprintDesigner.vue +494 -86
  2. package/hooks/useHiprint.js +48 -27
  3. package/libs/hiprint.bundle.js +11 -1
  4. package/libs/jquery.js +1 -0
  5. package/libs/jsbarcode/JsBarcode.js +64 -72
  6. package/libs/jsbarcode/barcodes/Barcode.js +9 -17
  7. package/libs/jsbarcode/barcodes/CODE128/CODE128.js +93 -133
  8. package/libs/jsbarcode/barcodes/CODE128/CODE128A.js +10 -38
  9. package/libs/jsbarcode/barcodes/CODE128/CODE128B.js +10 -38
  10. package/libs/jsbarcode/barcodes/CODE128/CODE128C.js +10 -38
  11. package/libs/jsbarcode/barcodes/CODE128/CODE128_AUTO.js +10 -36
  12. package/libs/jsbarcode/barcodes/CODE128/auto.js +32 -37
  13. package/libs/jsbarcode/barcodes/CODE128/constants.js +47 -30
  14. package/libs/jsbarcode/barcodes/CODE128/index.js +5 -28
  15. package/libs/jsbarcode/barcodes/CODE39/index.js +61 -61
  16. package/libs/jsbarcode/barcodes/EAN_UPC/EAN.js +58 -78
  17. package/libs/jsbarcode/barcodes/EAN_UPC/EAN13.js +66 -95
  18. package/libs/jsbarcode/barcodes/EAN_UPC/EAN2.js +22 -50
  19. package/libs/jsbarcode/barcodes/EAN_UPC/EAN5.js +29 -54
  20. package/libs/jsbarcode/barcodes/EAN_UPC/EAN8.js +42 -66
  21. package/libs/jsbarcode/barcodes/EAN_UPC/UPC.js +92 -125
  22. package/libs/jsbarcode/barcodes/EAN_UPC/UPCE.js +134 -142
  23. package/libs/jsbarcode/barcodes/EAN_UPC/constants.js +32 -21
  24. package/libs/jsbarcode/barcodes/EAN_UPC/encoder.js +11 -18
  25. package/libs/jsbarcode/barcodes/EAN_UPC/index.js +8 -39
  26. package/libs/jsbarcode/barcodes/GenericBarcode/index.js +16 -49
  27. package/libs/jsbarcode/barcodes/ITF/ITF.js +31 -63
  28. package/libs/jsbarcode/barcodes/ITF/ITF14.js +18 -40
  29. package/libs/jsbarcode/barcodes/ITF/constants.js +6 -8
  30. package/libs/jsbarcode/barcodes/ITF/index.js +3 -18
  31. package/libs/jsbarcode/barcodes/MSI/MSI.js +31 -57
  32. package/libs/jsbarcode/barcodes/MSI/MSI10.js +7 -30
  33. package/libs/jsbarcode/barcodes/MSI/MSI1010.js +10 -33
  34. package/libs/jsbarcode/barcodes/MSI/MSI11.js +7 -30
  35. package/libs/jsbarcode/barcodes/MSI/MSI1110.js +10 -33
  36. package/libs/jsbarcode/barcodes/MSI/checksums.js +11 -17
  37. package/libs/jsbarcode/barcodes/MSI/index.js +6 -33
  38. package/libs/jsbarcode/barcodes/codabar/index.js +49 -78
  39. package/libs/jsbarcode/barcodes/index.js +20 -33
  40. package/libs/jsbarcode/barcodes/pharmacode/index.js +32 -62
  41. package/libs/jsbarcode/exceptions/ErrorHandler.js +28 -43
  42. package/libs/jsbarcode/exceptions/exceptions.js +21 -59
  43. package/libs/jsbarcode/help/fixOptions.js +3 -9
  44. package/libs/jsbarcode/help/getOptionsFromElement.js +10 -23
  45. package/libs/jsbarcode/help/getRenderProperties.js +63 -69
  46. package/libs/jsbarcode/help/linearizeEncodings.js +8 -13
  47. package/libs/jsbarcode/help/merge.js +1 -11
  48. package/libs/jsbarcode/help/optionsFromStrings.js +19 -15
  49. package/libs/jsbarcode/options/defaults.js +2 -7
  50. package/libs/jsbarcode/renderers/canvas.js +106 -127
  51. package/libs/jsbarcode/renderers/index.js +4 -20
  52. package/libs/jsbarcode/renderers/object.js +7 -23
  53. package/libs/jsbarcode/renderers/shared.js +32 -39
  54. package/libs/jsbarcode/renderers/svg.js +136 -154
  55. package/package.json +1 -1
  56. package/libs/jsbarcode/barcodes/index.tmp.js +0 -33
@@ -6,12 +6,12 @@ import "../libs/hiprint.config.js";
6
6
  // 样式
7
7
  import "../libs/css/hiprint.css";
8
8
  import "../libs/css/print-lock.css";
9
- import { ref, computed, watch } from "vue";
9
+ import { ref, computed, watch, reactive, nextTick } from "vue";
10
10
 
11
11
  export const hiprint = h;
12
12
  export const defaultElementTypeProvider = p;
13
13
 
14
- export function print(provider = defaultElementTypeProvider, template, ...args) {
14
+ export function print (provider = defaultElementTypeProvider, template, ...args) {
15
15
  hiprint.init({
16
16
  providers: [new provider()],
17
17
  });
@@ -22,7 +22,7 @@ export function print(provider = defaultElementTypeProvider, template, ...args)
22
22
  return hiprintTemplate;
23
23
  }
24
24
 
25
- export function print2(provider = defaultElementTypeProvider, template, ...args) {
25
+ export function print2 (provider = defaultElementTypeProvider, template, ...args) {
26
26
  hiprint.init({
27
27
  providers: [new provider()],
28
28
  });
@@ -33,11 +33,28 @@ export function print2(provider = defaultElementTypeProvider, template, ...args)
33
33
  return hiprintTemplate;
34
34
  }
35
35
 
36
- export function usePaper() {
36
+ export function usePaper () {
37
37
  const paperType = ref("A4");
38
+ const paperTypeName = computed(() => {
39
+ const paperTypeObj = paperTypesObj.find((item) => item.value === paperType.value);
40
+ if (paperTypeObj) {
41
+ return paperTypeObj.label;
42
+ } else {
43
+ return "自定义";
44
+ }
45
+ });
38
46
  const paperWidth = ref(210);
39
47
  const paperHeight = ref(296.6);
40
48
 
49
+ const paperTypesObj = reactive([
50
+ { label: "A3", value: "A3" },
51
+ { label: "A4", value: "A4" },
52
+ { label: "A5", value: "A5" },
53
+ { label: "B3", value: "B3" },
54
+ { label: "B4", value: "B4" },
55
+ { label: "B5", value: "B5" },
56
+ ]);
57
+
41
58
  const paperTypes = {
42
59
  A3: {
43
60
  width: 420,
@@ -65,7 +82,7 @@ export function usePaper() {
65
82
  },
66
83
  };
67
84
 
68
- function setPaper(type, callback) {
85
+ function setPaper (type, callback) {
69
86
  if (type !== "other") {
70
87
  let { width, height } = paperTypes[type];
71
88
  paperWidth.value = width;
@@ -74,33 +91,37 @@ export function usePaper() {
74
91
  callback();
75
92
  }
76
93
 
77
- watch([paperWidth, paperHeight], (width, height) => {
78
- if (width === 420 && height === 297) {
79
- paperType.value = "A3";
80
- } else if (width === 210 && height === 297) {
81
- paperType.value = "A4";
82
- } else if (width === 210 && height === 148) {
83
- paperType.value = "A5";
84
- } else if (width === 500 && height === 353) {
85
- paperType.value = "B3";
86
- } else if (width === 250 && height === 353) {
87
- paperType.value = "B4";
88
- } else if (width === 250 && height === 176) {
89
- paperType.value = "B5";
90
- } else {
91
- paperType.value = "other";
92
- }
94
+ watch([paperWidth, paperHeight], ([width, height], [oldW, oldH]) => {
95
+ nextTick(() => {
96
+ if (width === 420 && height === 297) {
97
+ paperType.value = "A3";
98
+ } else if (width === 210 && height === 297) {
99
+ paperType.value = "A4";
100
+ } else if (width === 210 && height === 148) {
101
+ paperType.value = "A5";
102
+ } else if (width === 500 && height === 353) {
103
+ paperType.value = "B3";
104
+ } else if (width === 250 && height === 353) {
105
+ paperType.value = "B4";
106
+ } else if (width === 250 && height === 176) {
107
+ paperType.value = "B5";
108
+ } else {
109
+ paperType.value = "other";
110
+ }
111
+ });
93
112
  });
94
113
 
95
114
  return {
96
115
  paperType,
97
116
  paperWidth,
98
117
  paperHeight,
118
+ paperTypesObj,
119
+ paperTypeName,
99
120
  setPaper,
100
121
  };
101
122
  }
102
123
 
103
- export function useScale(callback) {
124
+ export function useScale (callback) {
104
125
  const scaleValue = ref(1);
105
126
  const scalePercentage = computed(() => {
106
127
  return `${(scaleValue.value * 100).toFixed(0)}%`;
@@ -111,11 +132,11 @@ export function useScale(callback) {
111
132
  const canZoomOut = computed(() => {
112
133
  return scaleValue.value < 4;
113
134
  });
114
- function zoomIn() {
135
+ function zoomIn () {
115
136
  scaleValue.value = scaleValue.value - 0.1;
116
137
  callback();
117
138
  }
118
- function zoomOut() {
139
+ function zoomOut () {
119
140
  scaleValue.value = scaleValue.value + 0.1;
120
141
  callback();
121
142
  }
@@ -129,9 +150,9 @@ export function useScale(callback) {
129
150
  };
130
151
  }
131
152
 
132
- export function useDataSource(axios) {
153
+ export function useDataSource (axios) {
133
154
  const detailData = ref();
134
- function getDetail(id) {
155
+ function getDetail (id) {
135
156
  return axios
136
157
  .request({
137
158
  url: `/printTemplate/get/${id}`,
@@ -171,7 +192,7 @@ export function useDataSource(axios) {
171
192
  });
172
193
  const dataSourceForm = ref([]);
173
194
  const codeMapDataSource = ref({});
174
- function getDataSourceList() {
195
+ function getDataSourceList () {
175
196
  return axios
176
197
  .request({
177
198
  url: "/printTemplate/getDsList",
@@ -2649,7 +2649,17 @@ var hiprint = (function (t) {
2649
2649
  (n += " </select>\n </div>\n </div>"),
2650
2650
  (this.target = hiprintJQuery(n));
2651
2651
  } else {
2652
- this.target = hiprintJQuery(' <div class="hiprint-option-item">\n <div class="hiprint-option-item-label">\n 字体\n </div>\n <div class="hiprint-option-item-field">\n <select class="auto-submit">\n <option value="" >默认</option>\n <option value="SimSun" >宋体</option>\n <option value="Microsoft YaHei" >微软雅黑</option>\n </select>\n </div>\n </div>');
2652
+ this.target = hiprintJQuery(`<div class="hiprint-option-item">
2653
+ <div class="hiprint-option-item-label">字体</div>
2654
+ <div class="hiprint-option-item-field">
2655
+ <select class="auto-submit">
2656
+ <option value="" >默认</option>
2657
+ <option value="SimSun" >宋体</option>
2658
+ <option value="Microsoft YaHei" >微软雅黑</option>
2659
+ <option value="Times New Roman" >Times New Roman</option>
2660
+ </select>
2661
+ </div>
2662
+ </div>`);
2653
2663
  }
2654
2664
  return this.target;
2655
2665
  }),
package/libs/jquery.js CHANGED
@@ -10616,5 +10616,6 @@ jQuery.trim = function (text) {
10616
10616
  (text + "").replace(rtrim, "$1");
10617
10617
  };
10618
10618
 
10619
+ export default jQuery;
10619
10620
 
10620
10621
  window.hiprintJQuery = jQuery;
@@ -1,39 +1,27 @@
1
- var _barcodes = require('./barcodes/');
2
- var _barcodes2 = _interopRequireDefault(_barcodes);
3
- var _merge = require('./help/merge.js');
4
- var _merge2 = _interopRequireDefault(_merge);
5
- var _linearizeEncodings = require('./help/linearizeEncodings.js');
6
- var _linearizeEncodings2 = _interopRequireDefault(_linearizeEncodings);
7
- var _fixOptions = require('./help/fixOptions.js');
8
- var _fixOptions2 = _interopRequireDefault(_fixOptions);
9
- var _getRenderProperties = require('./help/getRenderProperties.js');
10
- var _getRenderProperties2 = _interopRequireDefault(_getRenderProperties);
11
- var _optionsFromStrings = require('./help/optionsFromStrings.js');
12
- var _optionsFromStrings2 = _interopRequireDefault(_optionsFromStrings);
13
- var _ErrorHandler = require('./exceptions/ErrorHandler.js');
14
- var _ErrorHandler2 = _interopRequireDefault(_ErrorHandler);
15
- var _exceptions = require('./exceptions/exceptions.js');
16
- var _defaults = require('./options/defaults.js');
17
- var _defaults2 = _interopRequireDefault(_defaults);
18
- function _interopRequireDefault (obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
-
20
- // The protype of the object returned from the JsBarcode() call
21
-
1
+ // Import all the barcodes
2
+ import barcodes from './barcodes/';
22
3
 
23
4
  // Help functions
24
- var API = function API () {};
25
-
26
- // The first call of the library API
27
- // Will return an object with all barcodes calls and the data that is used
28
- // by the renderers
5
+ import merge from './help/merge.js';
6
+ import linearizeEncodings from './help/linearizeEncodings.js';
7
+ import fixOptions from './help/fixOptions.js';
8
+ import getRenderProperties from './help/getRenderProperties.js';
9
+ import optionsFromStrings from './help/optionsFromStrings.js';
29
10
 
11
+ // Exceptions
12
+ import ErrorHandler from './exceptions/ErrorHandler.js';
13
+ import { InvalidInputException, NoElementException } from './exceptions/exceptions.js';
30
14
 
31
15
  // Default values
16
+ import defaults from './options/defaults.js';
32
17
 
18
+ // The protype of the object returned from the JsBarcode() call
19
+ let API = function () {};
33
20
 
34
- // Exceptions
35
- // Import all the barcodes
36
- var JsBarcode = function JsBarcode (element, text, options) {
21
+ // The first call of the library API
22
+ // Will return an object with all barcodes calls and the data that is used
23
+ // by the renderers
24
+ let JsBarcode = function (element, text, options) {
37
25
  var api = new API();
38
26
 
39
27
  if (typeof element === "undefined") {
@@ -41,10 +29,10 @@ var JsBarcode = function JsBarcode (element, text, options) {
41
29
  }
42
30
 
43
31
  // Variables that will be pased through the API calls
44
- api._renderProperties = (0, _getRenderProperties2.default)(element);
32
+ api._renderProperties = getRenderProperties(element);
45
33
  api._encodings = [];
46
- api._options = _defaults2.default;
47
- api._errorHandler = new _ErrorHandler2.default(api);
34
+ api._options = defaults;
35
+ api._errorHandler = new ErrorHandler(api);
48
36
 
49
37
  // If text is set, use the simple syntax (render the barcode directly)
50
38
  if (typeof text !== "undefined") {
@@ -62,32 +50,34 @@ var JsBarcode = function JsBarcode (element, text, options) {
62
50
 
63
51
  // To make tests work TODO: remove
64
52
  JsBarcode.getModule = function (name) {
65
- return _barcodes2.default[name];
53
+ return barcodes[name];
66
54
  };
67
55
 
68
56
  // Register all barcodes
69
- for (var name in _barcodes2.default) {
70
- if (_barcodes2.default.hasOwnProperty(name)) {
71
- // Security check if the propery is a prototype property
72
- registerBarcode(_barcodes2.default, name);
57
+ for (var name in barcodes) {
58
+ if (barcodes.hasOwnProperty(name)) { // Security check if the propery is a prototype property
59
+ registerBarcode(barcodes, name);
73
60
  }
74
61
  }
75
62
  function registerBarcode (barcodes, name) {
76
- API.prototype[name] = API.prototype[name.toUpperCase()] = API.prototype[name.toLowerCase()] = function (text, options) {
77
- var api = this;
78
- return api._errorHandler.wrapBarcodeCall(function () {
79
- // Ensure text is options.text
80
- options.text = typeof options.text === 'undefined' ? undefined : '' + options.text;
81
-
82
- var newOptions = (0, _merge2.default)(api._options, options);
83
- newOptions = (0, _optionsFromStrings2.default)(newOptions);
84
- var Encoder = barcodes[name];
85
- var encoded = encode(text, Encoder, newOptions);
86
- api._encodings.push(encoded);
87
-
88
- return api;
89
- });
90
- };
63
+ API.prototype[name] =
64
+ API.prototype[name.toUpperCase()] =
65
+ API.prototype[name.toLowerCase()] =
66
+ function (text, options) {
67
+ var api = this;
68
+ return api._errorHandler.wrapBarcodeCall(function () {
69
+ // Ensure text is options.text
70
+ options.text = typeof options.text === 'undefined' ? undefined : '' + options.text;
71
+
72
+ var newOptions = merge(api._options, options);
73
+ newOptions = optionsFromStrings(newOptions);
74
+ var Encoder = barcodes[name];
75
+ var encoded = encode(text, Encoder, newOptions);
76
+ api._encodings.push(encoded);
77
+
78
+ return api;
79
+ });
80
+ };
91
81
  }
92
82
 
93
83
  // encode() handles the Encoder call and builds the binary string to be rendered
@@ -100,7 +90,7 @@ function encode (text, Encoder, options) {
100
90
  // If the input is not valid for the encoder, throw error.
101
91
  // If the valid callback option is set, call it instead of throwing error
102
92
  if (!encoder.valid()) {
103
- throw new _exceptions.InvalidInputException(encoder.constructor.name, text);
93
+ throw new InvalidInputException(encoder.constructor.name, text);
104
94
  }
105
95
 
106
96
  // Make a request for the binary data (and other infromation) that should be rendered
@@ -108,11 +98,11 @@ function encode (text, Encoder, options) {
108
98
 
109
99
  // Encodings can be nestled like [[1-1, 1-2], 2, [3-1, 3-2]
110
100
  // Convert to [1-1, 1-2, 2, 3-1, 3-2]
111
- encoded = (0, _linearizeEncodings2.default)(encoded);
101
+ encoded = linearizeEncodings(encoded);
112
102
 
113
103
  // Merge
114
- for (var i = 0; i < encoded.length; i++) {
115
- encoded[i].options = (0, _merge2.default)(options, encoded[i].options);
104
+ for (let i = 0; i < encoded.length; i++) {
105
+ encoded[i].options = merge(options, encoded[i].options);
116
106
  }
117
107
 
118
108
  return encoded;
@@ -120,24 +110,24 @@ function encode (text, Encoder, options) {
120
110
 
121
111
  function autoSelectBarcode () {
122
112
  // If CODE128 exists. Use it
123
- if (_barcodes2.default["CODE128"]) {
113
+ if (barcodes["CODE128"]) {
124
114
  return "CODE128";
125
115
  }
126
116
 
127
117
  // Else, take the first (probably only) barcode
128
- return Object.keys(_barcodes2.default)[0];
118
+ return Object.keys(barcodes)[0];
129
119
  }
130
120
 
131
121
  // Sets global encoder options
132
122
  // Added to the api by the JsBarcode function
133
123
  API.prototype.options = function (options) {
134
- this._options = (0, _merge2.default)(this._options, options);
124
+ this._options = merge(this._options, options);
135
125
  return this;
136
126
  };
137
127
 
138
128
  // Will create a blank space (usually in between barcodes)
139
129
  API.prototype.blank = function (size) {
140
- var zeroes = new Array(size + 1).join("0");
130
+ const zeroes = new Array(size + 1).join("0");
141
131
  this._encodings.push({ data: zeroes });
142
132
  return this;
143
133
  };
@@ -155,9 +145,9 @@ API.prototype.init = function () {
155
145
  }
156
146
 
157
147
  var renderProperty;
158
- for (var i in this._renderProperties) {
148
+ for (let i in this._renderProperties) {
159
149
  renderProperty = this._renderProperties[i];
160
- var options = (0, _merge2.default)(this._options, renderProperty.options);
150
+ var options = merge(this._options, renderProperty.options);
161
151
 
162
152
  if (options.format == "auto") {
163
153
  options.format = autoSelectBarcode();
@@ -165,7 +155,7 @@ API.prototype.init = function () {
165
155
 
166
156
  this._errorHandler.wrapBarcodeCall(function () {
167
157
  var text = options.value;
168
- var Encoder = _barcodes2.default[options.format.toUpperCase()];
158
+ var Encoder = barcodes[options.format.toUpperCase()];
169
159
  var encoded = encode(text, Encoder, options);
170
160
 
171
161
  render(renderProperty, encoded, options);
@@ -173,35 +163,37 @@ API.prototype.init = function () {
173
163
  }
174
164
  };
175
165
 
166
+
176
167
  // The render API call. Calls the real render function.
177
168
  API.prototype.render = function () {
178
169
  if (!this._renderProperties) {
179
- throw new _exceptions.NoElementException();
170
+ throw new NoElementException();
180
171
  }
181
172
 
182
173
  if (Array.isArray(this._renderProperties)) {
183
174
  for (var i = 0; i < this._renderProperties.length; i++) {
184
175
  render(this._renderProperties[i], this._encodings, this._options);
185
176
  }
186
- } else {
177
+ }
178
+ else {
187
179
  render(this._renderProperties, this._encodings, this._options);
188
180
  }
189
181
 
190
182
  return this;
191
183
  };
192
184
 
193
- API.prototype._defaults = _defaults2.default;
185
+ API.prototype._defaults = defaults;
194
186
 
195
187
  // Prepares the encodings and calls the renderer
196
188
  function render (renderProperties, encodings, options) {
197
- encodings = (0, _linearizeEncodings2.default)(encodings);
189
+ encodings = linearizeEncodings(encodings);
198
190
 
199
- for (var i = 0; i < encodings.length; i++) {
200
- encodings[i].options = (0, _merge2.default)(options, encodings[i].options);
201
- (0, _fixOptions2.default)(encodings[i].options);
191
+ for (let i = 0; i < encodings.length; i++) {
192
+ encodings[i].options = merge(options, encodings[i].options);
193
+ fixOptions(encodings[i].options);
202
194
  }
203
195
 
204
- (0, _fixOptions2.default)(options);
196
+ fixOptions(options);
205
197
 
206
198
  var Renderer = renderProperties.renderer;
207
199
  var renderer = new Renderer(renderProperties.element, encodings, options);
@@ -230,4 +222,4 @@ if (typeof hiprintJQuery !== 'undefined') {
230
222
  }
231
223
 
232
224
  // Export to commonJS
233
- module.exports = JsBarcode;
225
+ export default JsBarcode;
@@ -1,17 +1,9 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
-
7
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
8
-
9
- var Barcode = function Barcode(data, options) {
10
- _classCallCheck(this, Barcode);
11
-
12
- this.data = data;
13
- this.text = options.text || data;
14
- this.options = options;
15
- };
16
-
17
- exports.default = Barcode;
1
+ class Barcode{
2
+ constructor(data, options){
3
+ this.data = data;
4
+ this.text = options.text || data;
5
+ this.options = options;
6
+ }
7
+ }
8
+
9
+ export default Barcode;