forked from syncfusion/ej2-vue-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupca.vue
395 lines (381 loc) · 12.6 KB
/
upca.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
<template>
<div >
<div class="col-lg-8 control-section" style="width: 64%">
<div class="content-wrapper" style="width: 100%;height: 590px;">
<div class="barcodecenter">
<div class="centercontrol">
<ejs-barcodegenerator
id="barcode"
:invalid="invalidInput"
ref="barcodeControl"
:width="width"
:height="height"
:type="type"
:value="value"
:mode="mode"
></ejs-barcodegenerator>
</div>
</div>
<div
class="allowedText"
style=" margin-left: 14px;margin-right: 17px;margin-top: 14px;width: auto;height: auto;"
>
<span style="font-weight: 600;"> Allowed Input characters :</span> This barocode supports 11 numbers as input.
</div>
</div>
</div>
<div class="col-lg-4 property-section" style="padding-right: 0px;
padding-left: 18px;">
<div class="property-panel-header">Appearance</div>
<div id="propertypanel" class="e-remove-selection"></div>
<div class="property-section-content">
<div class="row sb-child-row">
<div class="col-xs-2 top" style="padding-left: 0px; margin-top: 10px;">Value</div>
<div class="col-xs-10" style="padding-left: 0px">
<form id="form-element" class="form-horizontal">
<div id="barcodevaluediv">
<ejs-textbox id="textbox" name="password" value="123456789" :change="textboxchange"></ejs-textbox>
</div>
</form>
</div>
</div>
<div class="row sb-child-row">
<div>
<div class="col-xs-2 top" style="padding-left: 0px;padding-right: 20px;">Width</div>
<div class="col-xs-3" style="width: 33%;padding-left: 0px">
<ejs-numerictextbox
ref="widthObj"
id="width"
format="###.##"
:value="200"
:step="2"
:min="150"
:max="250"
:change="widthchange"
></ejs-numerictextbox>
</div>
</div>
<div>
<div class="rightProperty">Height</div>
<div class="col-xs-3" style="width: 33%;padding-left: 0px;">
<ejs-numerictextbox
ref="heightObj"
id="height"
format="###.##"
value="150"
:step="2"
:min="100"
:max="200"
:change="heightchange"
></ejs-numerictextbox>
</div>
</div>
</div>
<div class="row sb-child-row" style="margin-top: 20px;">
<div class="col-xs-6" style="padding-left: 0px;">
<div class="col-xs-1" style="padding-left: 0px;">
<ejs-checkbox id="textVisibility" :checked="true" :change="textVisibilitychange"></ejs-checkbox>
</div>
<div class="col-xs-10">Text Visibility</div>
</div>
<div class="col-xs-4" style="padding-left: 0;margin-left: 13px;">
<div class="col-xs-1" style="padding-left: 0px;">
<ejs-checkbox id="svgMode" :checked="true" :change="svgModechange"></ejs-checkbox>
</div>
<div class="svgTextClass">SVG Mode</div>
</div>
</div>
<div class="row sb-child-row">
<div style="margin-top: 15px">
<div class="col-xs-2" style="margin-top: 5px;padding-left: 0px;">BG Color</div>
<div class="col-xs-4" style="padding-left: 0px;">
<ejs-colorpicker
ref="bgColor"
id="bgColor"
:value="fontcolorvalue"
:change="bgColorchange"
></ejs-colorpicker>
</div>
<div
class="col-xs-2"
style="width: 18%;
padding-left: 12px;
margin-top: 5px;"
>Fore Color</div>
<div class="col-xs-3" style="padding-left: 2px;">
<ejs-colorpicker
ref="foreColor"
id="foreColor"
:value="fontcolorvalue"
:change="foreColorchange"
></ejs-colorpicker>
</div>
</div>
</div>
<div class="property-panel-header">Margin</div>
<div class="row sb-child-row">
<div class="col-xs-2 top" style="padding-left: 0px;">Left</div>
<div class="col-xs-3" style="width: 33%;padding-left: 0px;">
<ejs-numerictextbox
id="marginLeft"
format="###.##"
value="10"
:step="1"
:min="-10"
:max="30"
:change="MarginLeftchange"
></ejs-numerictextbox>
</div>
<div class="rightProperty">Right</div>
<div class="col-xs-3" style="width: 33%;padding-left: 0px;">
<ejs-numerictextbox
id="MarginRight"
format="###.##"
value="10"
:step="1"
:min="-10"
:max="30"
:change="MarginRightchange"
></ejs-numerictextbox>
</div>
</div>
<div class="row sb-child-row">
<div class="col-xs-2 top" style="padding-left: 0px;">Top</div>
<div class="col-xs-3" style="width: 33%;padding-left: 0px;">
<div style="padding-bottom: 8px">
<ejs-numerictextbox
id="marginTop"
format="###.##"
value="10"
:step="1"
:min="-10"
:max="30"
:change="MarginTopchange"
></ejs-numerictextbox>
</div>
</div>
<div class="rightProperty">Bottom</div>
<div class="col-xs-3" style="width: 33%;padding-left: 0px;">
<ejs-numerictextbox
id="MarginBottom"
format="###.##"
value="10"
:step="1"
:min="-10"
:max="30"
:change="MarginBottomchange"
></ejs-numerictextbox>
</div>
</div>
<div class="property-panel-header">Text Properties</div>
<div class="row sb-child-row">
<div class="col-xs-2 top" style="padding-left: 0px;">Top</div>
<div class="col-xs-3" style="width: 33%;padding-left: 0px;">
<ejs-numerictextbox
id="TextmarginTop"
format="###.##"
value="0"
:step="1"
:min="-10"
:max="20"
:change="TextMarginTopchange"
></ejs-numerictextbox>
</div>
<div class="rightProperty">Bottom</div>
<div class="col-xs-3" style="width: 33%;padding-left: 0px;">
<ejs-numerictextbox
id="TextMarginBottom"
format="###.##"
value="0"
:step="1"
:min="-10"
:max="20"
:change="TextMarginBottomchange"
></ejs-numerictextbox>
</div>
</div>
<div class="row sb-child-row">
<div class="col-xs-2 top" style="padding-left: 0px;">Position</div>
<div class="textPropertyClass">
<ejs-dropdownlist
ref="textPosition"
id="textPosition"
:dataSource="textPositiondataSource"
:fields="ftextPositionfields"
:popupWidth="150"
:width="textPositionwidth"
value="Bottom"
:index="0"
:change="textPositionchange"
/>
</div>
</div>
<div class="row sb-child-row">
<div class="col-xs-2 top" style="padding-left: 0px;">Alignment</div>
<div class="textPropertyClass">
<ejs-dropdownlist
ref="textAlignment"
id="textAlignment"
:dataSource="textAlignmentdataSource"
:fields="ftextPositionfields"
:popupWidth="150"
:width="textPositionwidth"
value="Center"
:index="0"
:change="textAlignmentchange"
/>
</div>
</div>
<div class="row sb-child-row">
<div class="col-xs-3 top" style="width: 17%;padding-left: 0px;">Display Text</div>
<div class="textProperty">
<ejs-textbox id="displayText" value="123456789" :change="displayTextchange"></ejs-textbox>
</div>
</div>
</div>
</div>
<div id="action-description">
<p>This sample visualizes a consumer good identification number. A UPC-A barcode consists of four areas: number system, manufacturer code, product code, and check digit.</p>
</div>
<div id="description">
<p>
This sample shows how to create the UPC-A barcode. The `type` property can be used to set the barcode type as `UpcA`. By default, `enableCheckSum` is set as true, but the checksum can be disabled by assigning false to it.
</p>
<br>
</div>
</div>
</template>
<script>
import Vue from "vue";
import {
Button,
ButtonPlugin,
CheckBoxPlugin
} from "@syncfusion/ej2-vue-buttons";
import { Browser } from "@syncfusion/ej2-base";
import { BarcodeGeneratorPlugin } from "@syncfusion/ej2-vue-barcode-generator";
import {
NumericTextBox,
ColorPicker,
NumericTextBoxPlugin,
TextBoxPlugin,
ColorPickerPlugin,
ColorPickerEventArgs,
FormValidator
} from "@syncfusion/ej2-vue-inputs";
Vue.use(NumericTextBoxPlugin);
Vue.use(BarcodeGeneratorPlugin);
Vue.use(NumericTextBoxPlugin);
Vue.use(CheckBoxPlugin);
Vue.use(ColorPickerPlugin);
Vue.use(TextBoxPlugin);
let barCodeInstance;
let canShowError = false;
var customFn = args => {
if (canShowError) {
return false;
}
return true;
};
let options = {
rules: {
password: { minLength: [customFn, "Invalid input"] }
},
keyup() {
if (canShowError) {
canShowError = false;
}
},
focusout(args) {
displayText.value = barcode.value = document.getElementById(
"barcodevaluediv"
).value;
//barcode.dataBind();
}
};
let formObject;
let textPositiondataSourceValue = [
{ type: "Bottom", text: "Bottom" },
{ type: "Top", text: "Top" }
];
let textAlignmentdataSourceValue = [
{ type: "Center", text: "Center" },
{ type: "Left", text: "Left" },
{ type: "Right", text: "Right" }
];
export default Vue.extend({
data: function() {
return {
width: "200px",
height: "150px",
mode: "SVG",
type: "UpcA",
value: "72527273070",
fontcolorvalue: "#000",
textPositionwidth: "100%",
ftextPositionfields: { value: "type", text: "text" },
textPositiondataSource: textPositiondataSourceValue,
textAlignmentdataSource: textAlignmentdataSourceValue,
invalidInput: arg => {
canShowError = true;
formObject.validate();
},
textboxchange: arg => {
barCodeInstance.value = arg.value;
},
widthchange: arg => {
barCodeInstance.width = arg.value;
},
heightchange: arg => {
barCodeInstance.height = arg.value;
},
textVisibilitychange: arg => {
barCodeInstance.displayText.visibility = arg.checked;
},
svgModechange: arg => {
barCodeInstance.mode = arg.checked ? "SVG" : "Canvas";
},
bgColorchange: arg => {
barCodeInstance.backgroundColor = arg.currentValue.hex;
},
foreColorchange: arg => {
barCodeInstance.foreColor = arg.currentValue.hex;
},
MarginLeftchange: arg => {
barCodeInstance.margin.left = arg.value;
},
MarginRightchange: arg => {
barCodeInstance.margin.right = arg.value;
},
MarginTopchange: arg => {
barCodeInstance.margin.top = arg.value;
},
MarginBottomchange: arg => {
barCodeInstance.margin.bottom = arg.value;
},
TextMarginTopchange: arg => {
barCodeInstance.displayText.margin.top = arg.value;
},
TextMarginBottomchange: arg => {
barCodeInstance.displayText.margin.bottom = arg.value;
},
textPositionchange: arg => {
barCodeInstance.displayText.position = arg.value;
},
textAlignmentchange: arg => {
barCodeInstance.displayText.alignment = arg.value;
},
displayTextchange: arg => {
barCodeInstance.displayText.text = arg.value.toString();
},
created: args => {
addEvents();
}
};
},
mounted: function() {
barCodeInstance = this.$refs.barcodeControl.ej2Instances;
formObject = new FormValidator("#form-element", options);
}
});
</script>