|
@@ -0,0 +1,152 @@
|
|
|
|
|
+<% layout('/layouts/default.html', {title: '条码转码', libs: ['validate']}){ %>
|
|
|
|
|
+<div class="main-content">
|
|
|
|
|
+ <div class="box box-main">
|
|
|
|
|
+ <div class="box-header with-border">
|
|
|
|
|
+ <div class="box-title">
|
|
|
|
|
+ <i class="fa fa-exchange"></i> ${text('条码转码')}
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div class="box-tools pull-right">
|
|
|
|
|
+ <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <form id="transcodeForm" class="form-horizontal">
|
|
|
|
|
+ <div class="box-body">
|
|
|
|
|
+ <div class="form-unit">${text('转码:2400170 → AAB70;解码:AAB70 → 2400170')}</div>
|
|
|
|
|
+ <div class="row">
|
|
|
|
|
+ <div class="col-xs-10">
|
|
|
|
|
+ <div class="form-group">
|
|
|
|
|
+ <label class="control-label col-sm-2">
|
|
|
|
|
+ <span class="required">*</span> ${text('输入条码')}:
|
|
|
|
|
+ </label>
|
|
|
|
|
+ <div class="col-sm-8">
|
|
|
|
|
+ <input type="text" id="inputBarcode" name="inputBarcode" maxlength="30"
|
|
|
|
|
+ class="form-control required" placeholder="${text('请输入条码')}"
|
|
|
|
|
+ autocomplete="off"/>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div class="row">
|
|
|
|
|
+ <div class="col-xs-10">
|
|
|
|
|
+ <div class="form-group">
|
|
|
|
|
+ <label class="control-label col-sm-2">${text('输出条码')}:</label>
|
|
|
|
|
+ <div class="col-sm-8">
|
|
|
|
|
+ <input type="text" id="outputBarcode" name="outputBarcode" readonly
|
|
|
|
|
+ class="form-control" placeholder="${text('转换结果')}"/>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div class="box-footer">
|
|
|
|
|
+ <div class="row">
|
|
|
|
|
+ <div class="col-sm-offset-2 col-sm-10">
|
|
|
|
|
+ <button type="button" class="btn btn-sm btn-primary" id="btnTranscode"><i class="fa fa-exchange"></i> ${text('转 码')}</button>
|
|
|
|
|
+ <button type="button" class="btn btn-sm btn-success" id="btnDecode"><i class="fa fa-undo"></i> ${text('解 码')}</button>
|
|
|
|
|
+ <button type="button" class="btn btn-sm btn-default" id="btnClear"><i class="fa fa-eraser"></i> ${text('清 空')}</button>
|
|
|
|
|
+ <button type="button" class="btn btn-sm btn-default" id="btnCopy" disabled><i class="fa fa-copy"></i> ${text('复 制')}</button>
|
|
|
|
|
+ <button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> ${text('关 闭')}</button>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </form>
|
|
|
|
|
+ </div>
|
|
|
|
|
+</div>
|
|
|
|
|
+<% } %>
|
|
|
|
|
+<script>
|
|
|
|
|
+(function () {
|
|
|
|
|
+ var FROM = '2400170';
|
|
|
|
|
+ var TO = 'AAB70';
|
|
|
|
|
+
|
|
|
|
|
+ function resetOutput() {
|
|
|
|
|
+ $('#outputBarcode').val('');
|
|
|
|
|
+ $('#btnCopy').prop('disabled', true);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function setOutput(output) {
|
|
|
|
|
+ $('#outputBarcode').val(output);
|
|
|
|
|
+ $('#btnCopy').prop('disabled', false);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function doTranscode() {
|
|
|
|
|
+ var input = $.trim($('#inputBarcode').val());
|
|
|
|
|
+ if (!input) {
|
|
|
|
|
+ js.showMessage('${text("请输入条码")}');
|
|
|
|
|
+ resetOutput();
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (input.length !== 30) {
|
|
|
|
|
+ js.showMessage('${text("转码条码长度必须为30位")}');
|
|
|
|
|
+ resetOutput();
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (input.indexOf(FROM) < 0) {
|
|
|
|
|
+ js.showMessage('${text("条码中未找到 2400170,无法转码")}');
|
|
|
|
|
+ resetOutput();
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ setOutput(input.replace(FROM, TO));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function doDecode() {
|
|
|
|
|
+ var input = $.trim($('#inputBarcode').val());
|
|
|
|
|
+ if (!input) {
|
|
|
|
|
+ js.showMessage('${text("请输入条码")}');
|
|
|
|
|
+ resetOutput();
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (input.indexOf(TO) < 0) {
|
|
|
|
|
+ js.showMessage('${text("条码中未找到 AAB70,无法解码")}');
|
|
|
|
|
+ resetOutput();
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ setOutput(input.replace(TO, FROM));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function copyOutput() {
|
|
|
|
|
+ var output = $('#outputBarcode').val();
|
|
|
|
|
+ if (!output) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (navigator.clipboard && navigator.clipboard.writeText) {
|
|
|
|
|
+ navigator.clipboard.writeText(output).then(function () {
|
|
|
|
|
+ js.showMessage('${text("已复制到剪贴板")}');
|
|
|
|
|
+ }).catch(function () {
|
|
|
|
|
+ fallbackCopy(output);
|
|
|
|
|
+ });
|
|
|
|
|
+ } else {
|
|
|
|
|
+ fallbackCopy(output);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function fallbackCopy(text) {
|
|
|
|
|
+ var $tmp = $('<input>');
|
|
|
|
|
+ $('body').append($tmp);
|
|
|
|
|
+ $tmp.val(text).select();
|
|
|
|
|
+ try {
|
|
|
|
|
+ document.execCommand('copy');
|
|
|
|
|
+ js.showMessage('${text("已复制到剪贴板")}');
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ js.showMessage('${text("复制失败,请手动复制")}');
|
|
|
|
|
+ }
|
|
|
|
|
+ $tmp.remove();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function clearForm() {
|
|
|
|
|
+ $('#inputBarcode').val('');
|
|
|
|
|
+ resetOutput();
|
|
|
|
|
+ $('#inputBarcode').focus();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $('#btnTranscode').on('click', doTranscode);
|
|
|
|
|
+ $('#btnDecode').on('click', doDecode);
|
|
|
|
|
+ $('#btnClear').on('click', clearForm);
|
|
|
|
|
+ $('#btnCopy').on('click', copyOutput);
|
|
|
|
|
+ $('#inputBarcode').on('keydown', function (e) {
|
|
|
|
|
+ if (e.keyCode === 13) {
|
|
|
|
|
+ e.preventDefault();
|
|
|
|
|
+ doTranscode();
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+})();
|
|
|
|
|
+</script>
|