Jelajahi Sumber

仓储列表功能

liujiankang 7 tahun lalu
induk
melakukan
51518fdbcf

+ 1 - 1
watero-rst-service/src/main/java/com/iamberry/rst/service/pts/MachinePartsServiceImpl.java

@@ -87,7 +87,7 @@ public class MachinePartsServiceImpl implements MachinePartsService {
                 PtsSupplier ptsSupplier = new PtsSupplier();
                 ptsSupplier.setSupplierNumber(heads.get(1));
                 ptsSupplier = machineSupplierMapper.getPtsSupplier(ptsSupplier);
-                ptsComponents.setSupplierId(ptsSupplier.getSupplierId() == null?null:ptsSupplier.getSupplierId());
+                ptsComponents.setSupplierId(ptsSupplier.getSupplierId());
                 ptsComponents.setComponentsName(heads.get(2));
                 ptsComponents.setComponentsStatus(heads.get(3).equals("正常使用" )? 1 : 0);
                 ptsComponents.setComponentsCost(Integer.valueOf(heads.get(4)) * 100);//元转换为分

+ 5 - 5
watero-rst-web/src/main/java/com/iamberry/rst/controllers/pts/AdminMachinePartsController.java

@@ -105,12 +105,12 @@ public class AdminMachinePartsController {
      * **/
     @RequestMapping("/excelAdd")
     @ResponseBody
-    public boolean excelAdd(@RequestParam("sourceFile") MultipartFile sourceFile, HttpServletRequest request, HttpServletResponse response)throws IOException  {
+    public boolean excelAdd(@RequestParam("sourceFile") String sourceFile, HttpServletRequest request, HttpServletResponse response)throws IOException  {
         //判断文件是否为空
         if (sourceFile==null) {
             return false;
         }
-        //获取文件名
+        /*//获取文件名
         String name=sourceFile.getOriginalFilename();
         long size =sourceFile.getSize();
         if (name==null ||("").equals(name) && size==0) {
@@ -130,12 +130,12 @@ public class AdminMachinePartsController {
         } catch (Exception e) {
             e.printStackTrace();
         }
-
+*/
         // 获取Workbook
-        InputStream inputStream = new BufferedInputStream(new FileInputStream(file1));
+        InputStream inputStream = new BufferedInputStream(new FileInputStream(request.getServletContext().getRealPath(sourceFile)));
         Workbook wb  = null;
 
-        if (name.endsWith("xls")) {
+        if (sourceFile.endsWith("xls")) {
             wb = new HSSFWorkbook(inputStream);
         } else {
             wb = new XSSFWorkbook(inputStream);

+ 60 - 8
watero-rst-web/src/main/webapp/WEB-INF/views/pts/machinePtras/parts_list.ftl

@@ -56,12 +56,14 @@
             <input type="text" class="my-input"  style="width:80px" value="${componentsName!}" placeholder="零件名称" id="componentsName" name="componentsName">
             <button type="submit" class="btn" style="background: #32a3d8;color: #fff;-webkit-transform:translateY(-5%);" id="" name=""><i class="Hui-iconfont">&#xe665;</i> 搜索</button>
         </form>
-        <form id="sourcefile" name="sourcefile" action=""  method="post" enctype="multipart/form-data" style="width: 42%;display: inline-block;">
+        <#--<form id="sourcefile" name="sourcefile" action=""  method="post" enctype="multipart/form-data" style="width: 42%;display: inline-block;">
             <input class="my-btn-search" data-loading-text="请勿重复提交" type="button" value="上传EXCEL" onClick="upPolicy()">
             <input style="width: 125px;" id="source_file" name="sourceFile" type="file" value="" />
             <button type="button" style="cursor:pointer;" class="my-btn-search" onclick="toExcel();">导出Excel</button>
             <button type="button" style="cursor:pointer;" class="my-btn-search" onclick="downloadExcel();">下载模板</button>
-        </form>
+        </form>-->
+        <button onClick="upFiles();" class="btn radius" style="background: #32a3d8;color: #fff;" type="button"><i class="Hui-iconfont">&#xe632;</i> 上传Excel</button>
+        <button type="button" style="cursor:pointer;" class="my-btn-search" onclick="downloadExcel();">下载模板</button>
     </div>
 
     <div class="mt-20">
@@ -125,14 +127,64 @@
 <tfoot>
 <#include "/base/page_util.ftl">
 </tfoot>
+<script type="text/javascript" src="${path}/common/lib/ueditor/1.4.3/ueditor.config.js"></script>
+<script type="text/javascript" src="${path}/common/lib/ueditor/1.4.3/ueditor.all.min.js"> </script>
+<script type="text/javascript" src="${path}/common/lib/ueditor/1.4.3/lang/zh-cn/zh-cn.js"></script>
+<script type="text/plain" id="upload_ue"></script>
 <script type="text/javascript">
+    var _editor;
+    $(function() {
+        //重新实例化一个编辑器,防止在上面的editor编辑器中显示上传的图片或者文件
+        _editor = UE.getEditor('upload_ue',{
+            initialFrameWidth : 375,
+            initialFrameHeight: 600
+        });
+        _editor.ready(function () {
+            _editor.setDisabled("attachment");//设置编辑器不可用
+            _editor.hide();//隐藏编辑器,因为不会用到这个编辑器实例,所以要隐藏
+            //侦听图片上传
+            _editor.addListener('beforeInsertImage', function (t, arg) {
+                console.log(arg[0].src);
+                $("#picture").attr("value", arg[0].src);//将地址赋值给相应的input,只去第一张图片的路径
+                $("#preview").attr("src", arg[0].src);  //图片预览
+            });
+            //侦听文件上传,取上传文件列表中第一个上传的文件的路径
+            _editor.addListener('afterUpfile', function (t, arg) {
+                console.log(arg[0].url);
+                /*window.location.href=root_path + '/admin/machineParts/excelAdd?sourceFile='+arg[0].url;*/
+                $.ajax({
+                    cache: true,
+                    type: "POST",
+                    data: {"sourceFile":arg[0].url},
+                    contentType: false,
+                    processData: false,
+                    url: "${path}/admin/machineParts/excelAdd",
+                    async: false,
+                    success: function(data){
+                        if (data) {
+                            layer.msg('添加成功!', {icon: 1, time: 2000},function () {
+                                window.location.href = '${path}/admin/machineParts/_parts_list'
+                            });
 
-
-    /*管理员-编辑*/
-    function parts_edit(title,url,id,w,h){
-        layer_show(title,url,w,h);
+                        }else{
+                            layer.msg('添加失败!', {icon: 2, time: 2000});
+                        }
+                    },
+                    error: function(XmlHttpRequest, textStatus, errorThrown){
+                        layer.msg('添加失败!', {icon: 2, time: 2000});
+                    }
+                });
+                $("#source_file").attr("value", _editor.options.filePath + arg[0].url);
+            });
+        });
+    });
+    //弹出文件上传的对话框
+    function upFiles() {
+            var myFiles = _editor.getDialog("attachment");
+            myFiles.open();
     }
 
+
     /* 修改二级菜单状态 */
     function update_FAQState(detaId) {
         layer.confirm('确认要停用吗?',function(index){
@@ -153,7 +205,7 @@
 
 </script>
 <script type="text/javascript">
-    function upPolicy() {
+    /*function upPolicy() {
         if($('#source_file').val().length > 0){
             var formData = new FormData($( "#sourcefile" )[0]);
             $.ajax({
@@ -182,7 +234,7 @@
          layer.msg('请先上传文件!', {icon: 2, time: 2000});
         }
 
-    }
+    }*/
     /**
      * 跳转到添加零件页面
      */