barcodeUpdate.jsp 15.4 KB
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 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412
<%@ page import="com.myproject.webapp.controller.webService.DataCache" %><%--
  Created by IntelliJ IDEA.
  User: kangmor
  Date: 2015/12/2
  Time: 21:31
--%>
<%@ include file="/common/taglibs.jsp" %>
<%@ page language="java" pageEncoding="UTF-8"%>

<!-- BEGIN PAGE HEADER-->
<h3 class="page-title">
  <fmt:message key="barcode.updateTitle"/>
</h3>

<!--Begin of update-->
<div class="row">
  <div class="col-md-12">
    <!-- BEGIN PORTLET-->
    <div class="portlet box green-jungle">
      <div class="portlet-title">
        <div class="caption">
          <i class="fa fa-pencil"></i><fmt:message key="barcode.updateTitle"/>
        </div>

        <div class="actions">
          <a href="${ctx}/barcode/barcodeUpdate.html" class="btn btn-default btn-sm">
            <i class="fa fa-plus"></i> <fmt:message key="button.add"/> </a>
          <a href="barcodeSearch.html" class="btn btn-default btn-sm">
            <i class="fa fa-reply"></i> <fmt:message key="button.return"/> </a>
        </div>
      </div>
      <div class="portlet-body form">
        <!-- BEGIN FORM-->
        <form:form commandName="barcode" class="form-horizontal form-bordered" action="barcodeUpdate.html">
          <form:hidden path="id"/>
          <form:hidden path="type"/>

          <div class="form-body">
            <%@include file="/common/success.jsp"%>
            <%@include file="/common/error.jsp"%>

     <c:if test='<%=!DataCache.isProductionFor("ChengDuKaiTian") %>'>
            <div class="form-group">
              <label class="control-label col-md-2"><fmt:message key="barcode.barcode"/></label>
              <div class="col-md-4">
                <div style="text-align:left" class="input-group">
                  <form:input type="text" id="barcodeStr" path="barcode" class="form-control"/>
                  <c:if test="${barcode.id != null}">
                    <span class="input-group-addon">
                      <a onclick="printFun();"><fmt:message key="barcode.print"/> </a>
                    </span>
                  </c:if>
                  <form:errors path="barcode" cssStyle="color: red"/>
                </div>
              </div>

              <label class="control-label col-md-2"><fmt:message key="barcode.partNumber"/></label>
              <div class="col-md-4">
                <div style="text-align:left" class="input-group">
                  <form:input type="text" id="partNumber" path="partNumber" class="form-control"/>
                  <form:errors path="partNumber" cssStyle="color: red"/>
                </div>
              </div>
            </div>
            <div class="form-group">

              <label class="control-label col-md-2"><fmt:message key="barcode.plateSize"/></label>
              <div class="col-md-4">
                <div style="text-align:left" class="input-group">
                  <form:input type="text" id="plateSize" path="plateSize" class="form-control"/>
                </div>
              </div>

              <label class="control-label col-md-2"><fmt:message key="barcode.height"/></label>
              <div class="col-md-4">
                <div style="text-align:left" class="input-group">
                  <form:input type="text" id="height" path="height" class="form-control"/>
                </div>
              </div>
            </div>

            <div class="form-group">
              <label class="control-label col-md-2"><fmt:message key="barcode.amount"/></label>
              <div class="col-md-4">
                <div style="text-align:left" class="input-group">
                  <form:input type="text" id="amount" path="amount" class="form-control"/>
                </div>
              </div>


              <label class="control-label col-md-2"><fmt:message key="累计数量"/></label>
              <div class="col-md-4">
                <div style="text-align:left" class="input-group">
                  <form:input type="text" id="usedQty" path="usedQty" class="form-control"/>
                </div>
              </div>

              <label class="control-label col-md-2"><fmt:message key="barcode.expireDate"/></label>
              <div class="col-md-4">
                <div style="text-align:left" class="input-group">
                  <form:input type="text" path="expireDate" class="form-control form-control-inline input-medium date-picker" />
                </div>
              </div>


              <label class="control-label col-md-2"><fmt:message key="使用上限"/></label>
              <div class="col-md-4">
                <div style="text-align:left" class="input-group">
                  <form:input type="text" id="maxUsedQty" path="maxUsedQty" class="form-control"/>
                </div>
              </div>
            </div>

           <%--<div class="form-group">--%>
             <%--<label class="control-label col-md-2"><fmt:message key="barcode.memo"/></label>--%>
             <%--<div class="col-md-9">--%>
               <%--<div style="text-align:left;width:100%;" class="input-group">--%>
                 <%--<form:textarea id="memo" path="memo" class="form-control" style="height:100px;" />--%>
               <%--</div>--%>
             <%--</div>--%>
           <%--</div>--%>

     </c:if>
<c:if test='<%=DataCache.isProductionFor("ChengDuKaiTian") %>'>
  <div class="form-group">
                              <label class="control-label col-md-2"><fmt:message key="component.auto.scancode"/></label>

                              <div class="col-md-8">
                                  <div style="text-align:left">
                                      <input type="text" id="scan-code" class="form-control" autofocus placeholder="产品型号@组件型号@配套单号@元器件型号@上级库位置号@检验编号@数量"/>
                                      <span id="code-errors" style="color: red"></span>
                                  </div>
                              </div>
                          </div>
  <form:hidden id="partNumber" path="partNumber"/>
  <div class="form-group">
    <label class="control-label col-md-2"><fmt:message key="barcode.barcode"/></label>
    <div class="col-md-4">
      <div style="text-align:left" class="input-group">
        <form:input type="text" id="barcodeStr" path="barcode" class="form-control"/>
                    <span class="input-group-addon">
                      <a onclick="printFun();"><fmt:message key="barcode.print"/> </a>
                    </span>
        <form:errors path="barcode" cssStyle="color: red"/>
      </div>
    </div>

    <label class="control-label col-md-2"><fmt:message key="产品型号"/></label>
    <div class="col-md-4">
      <div style="text-align:left" class="input-group">
        <form:input type="text" path="otherField2" class="form-control" id="otherField2"/>
      </div>
    </div>
  </div>
  <div class="form-group">

    <label class="control-label col-md-2"><fmt:message key="组件型号"/></label>
    <div class="col-md-4">
      <div style="text-align:left" class="input-group">
        <form:input type="text" path="otherField3" class="form-control" id="otherField3"/>
      </div>
    </div>


    <label class="control-label col-md-2"><fmt:message key="配套单号"/></label>
    <div class="col-md-4">
      <div style="text-align:left" class="input-group">
        <form:input type="text" path="otherField1" class="form-control" id="otherField1"/>
      </div>
    </div>
  </div>
  <div class="form-group">

    <label class="control-label col-md-2"><fmt:message key="元器件型号"/></label>
    <div class="col-md-4">
      <div style="text-align:left" class="input-group">
        <form:input type="text" path="otherField4" class="form-control" id="otherField4"/>
      </div>
    </div>


    <label class="control-label col-md-2"><fmt:message key="检验编号"/></label>
    <div class="col-md-4">
      <div style="text-align:left" class="input-group">
        <form:input type="text" path="otherField5" class="form-control" id="otherField5"/>
      </div>
    </div>

  </div>

  <div class="form-group extraInfo">

    <label class="control-label col-md-2"><fmt:message key="barcode.amount"/></label>
    <div class="col-md-4">
      <div style="text-align:left" class="input-group">
        <form:input type="text" id="amount" path="amount" class="form-control"/>
      </div>
    </div>


    <form:hidden id="plateSize" path="plateSize"/>
    <form:hidden id="height" path="height"/>
    <label class="control-label col-md-2"><fmt:message key="barcode.plateSize"/></label>
    <div class="col-md-4">
      <select class="form-control input-small" id="size">
        <option value="7x8">7 x 8</option>
        <option value="7x12">7 x 12</option>
        <option value="7x16">7 x 16</option>
        <option value="8x20"selected="true">散料夹具</option>
        <option value="8.0x20" >格料夹具</option>
      </select>
    </div>
  </div>



  <div class="form-group extraInfo">

      <%--备注--%>
    <label class="control-label col-md-2"><fmt:message key="备注"/></label>

    <div class="col-md-6">

      <form:textarea id="description" path="otherField6" class="form-control"/>

    </div>
  </div>

</c:if>

          <div class="form-actions">
            <div class="row">
              <div class="col-md-offset-3 col-md-9">
                <button class="btn green" type="submit" name="method" value="add"><i class="fa fa-save"></i><fmt:message key="button.save"/></button>
                <c:if test="${not empty barcode.id}">
                  <button class="btn red" type="submit" name="method" value="delete"><i class="fa fa-trash-o"></i><fmt:message key="button.delete"/></button>
                </c:if>
                <button type="button" class="btn default" onclick="window.location=''"><i class="fa fa-history"></i><fmt:message key="button.cancel"/></button>
              </div>
            </div>
          </div>
        </form:form>
        <!-- END FORM-->
      </div>
    </div>
    <!-- END PORTLET-->
  </div>
</div>
<!--End of update-->


  <c:set var="scripts" scope="request">
  <script>
    function printFun(){
      var codeStr = $("#barcodeStr").val();
      window.open('${ctx}/qrcode.html?barcode=' + codeStr);
    }
      $("#partNumber").autocomplete({
        source: function (request, response) {
          $.ajax({
            url: "${ctx}/component/fetchComponent",
            dataType: "json",
            data: {
              pn: request.term
            },
            success: function (data) {
              response($.map(data, function (item) {
                return {
                  label: item.partNumber,
                  id: item.id,
                  partNumber: item.partNumber,
                  plateSize: item.plateSize,
                  height:item.height,
                  amount:item.amount,
                  type:item.type
                };
              }));
            }
          });
        },
        minLength: 1,
        select: function( event, ui ) {
//                    log( ui.item ?
//                    "Selected: " + ui.item.label :
//                    "Nothing selected, input was " + this.value);
          $("#plateSize").val(ui.item.plateSize);
          $("#partNumber").val(ui.item.partNumber);
          $("#height").val(ui.item.height);
          $("#amount").val(ui.item.amount);
          $("#type").val(ui.item.type);
        }
      });

    function saveBarcode() {
      $("#operation").val("save");
      $("#barcodeGenerateForm").submit();
    }



    $("#scan-code").change(function (){
      $("#code-errors").text("");
      var codeValue = $(this).val();
      $(this).val("");
      var strs= codeValue.split("@"); //字符分割
      if(strs.length == 7){
        //产品型号@组件型号@配套单号@元器件型号@上级库位置号@检验编号@数量
        $("#code-errors").text("");
        $("#otherField1").val(strs[2]);
        $("#otherField2").val(strs[0]);
        $("#otherField3").val(strs[1]);
        $("#otherField4").val(strs[3]);
        $("#otherField5").val(strs[5]);
        $("#amount").val(strs[6]);
        return;
      }
      $("#code-errors").text("格式为  产品型号@组件型号@配套单号@元器件型号@上级库位置号@检验编号@数量  的条码信息才可以正确解析");
    })

    $('#size').change(function(){

      var selectValue = $(this).children('option:selected').val();
      if(selectValue != ""){
        var strs = selectValue.split("x");
        $("#plateSize").val(strs[0]);
        $("#height").val(strs[1]);
        if(strs[0] == '8'){
          //散料夹具
          $('#partNumber').val("BULK_TRAY");
        }else if(strs[0] == '8.0'){
          //隔料夹具
          $("#plateSize").val("8");
          $('#partNumber').val("SPLIT_BULK_TRAY");
        }else{
          //盘料
          $('#partNumber').val("COMPONENT");
        }
      }
    })

    if(${barcode.plateSize > 0}){
      var sizeOptionValue = "${barcode.plateSize}x${barcode.height}";
      var sizeOption = $("#size option[value="+sizeOptionValue+"]");
      if(sizeOption.length <= 0){
        $("#size").append("<option value='"+sizeOptionValue+"'>"+sizeOptionValue+"</option>");
      }
      $('#size').val(sizeOptionValue);
    }else{
      //$('#partNumber').val("BULK_TRAY");
    }


    fetchBarcode = function(fieldStr){
      var opt = {
        source: function (request, response) {
          $.ajax({
            url: "${ctx}/service/store/fetchBarcode",
            dataType: "json",
            data: {
              fieldStr: fieldStr,
              fieldVal: request.term,
            },
            success: function (data) {
              response($.map(data, function (item) {
                return {
                  label: eval("item."+fieldStr),
                  id: item.id,
                  otherField1: item.otherField1,
                  otherField2: item.otherField2,
                  otherField3: item.otherField3,
                  otherField4: item.otherField4,
                  otherField5: item.otherField5,
                  otherField6: item.otherField6,
                  amount: item.amount,
                  partNumber: item.partNumber,
                  plateSize: item.plateSize,
                  height: item.height
                };
              }));
            }
          });
        },
        minLength: 1,
        select: function( event, ui ) {
          $("#otherField1").val(ui.item.otherField1);
          $("#otherField2").val(ui.item.otherField2);
          $("#otherField3").val(ui.item.otherField3);
          $("#amount").val(ui.item.amount);
          $("#otherField4").val(ui.item.otherField4);
          $("#otherField5").val(ui.item.otherField5);
          $("#otherField6").val(ui.item.otherField5);
          $('#partNumber').val(ui.item.partNumber);
          $('#plateSize').val(ui.item.plateSize);
          $('#height').val(ui.item.height);
          var sizeOptionValue = ui.item.plateSize + "x"+ ui.item.height;
          var sizeOption = $("#size option[value="+sizeOptionValue+"]");
          if(sizeOption.length <= 0){
            $("#size").append("<option value='"+sizeOptionValue+"'>"+sizeOptionValue+"</option>");
          }
          $('#size').val(sizeOptionValue);
        }
      }
      return opt;
    }

      $("#otherField2").autocomplete(fetchBarcode("otherField2"));
      $("#otherField1").autocomplete(fetchBarcode("otherField1"));
      $("#otherField3").autocomplete(fetchBarcode("otherField3"));
      $("#otherField4").autocomplete(fetchBarcode("otherField4"));
      $("#otherField5").autocomplete(fetchBarcode("otherField5"));
  </script>
  </c:set>