CZT
2023-07-15 2bab6bdfaa240bab8bf3197a4d43a27d352f16b6
优化出入库补单文件上传-增加删除及名称命名
已修改2个文件
83 ■■■■ 文件已修改
igds-inout/src/main/java/com/ld/igds/inout/view/InoutDataPR.java 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
igds-inout/src/main/java/com/ld/igds/inout/view/InoutHand.view.xml 52 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
igds-inout/src/main/java/com/ld/igds/inout/view/InoutDataPR.java
@@ -1,6 +1,7 @@
package com.ld.igds.inout.view;
import java.io.File;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -259,12 +260,18 @@
     */
    @FileResolver
    public String uploadImage(UploadFile file, Map<String, Object> parameter) {
        //车牌
        String plateNum = (String) parameter.get("plateNum");
        //流程
        String bizTag = (String) parameter.get("bizTag");
        String newFileName = null;
        try {
            String basePath = fileService.getInoutFilePath(new Date());
            // 获取新的ID
            newFileName = DateFormatUtils.format(new Date(), "yyyyMMddHHmmss");
            if(StringUtils.isNotEmpty(bizTag)){
                newFileName = bizTag + "_" + newFileName;
            }
            // 文件后缀名
            String suffixName = file.getFileName().substring(file.getFileName().lastIndexOf("."));
            // 合成新的文件名
@@ -278,4 +285,28 @@
        return newFileName;
    }
    /**
     * inoutDataPR#delImage
     *
     * @param parameter
     * @return
     */
    @Expose
    public String delImage(Map<String, Object> parameter) throws Exception {
        String fileName = (String) parameter.get("fileName");
        Date createTime = (Date) parameter.get("createTime");
        if (null == createTime) createTime = new Date();
        fileName = URLDecoder.decode(fileName, "UTF-8");
        File file = new File(fileService.getInoutFilePath(createTime), fileName);
        if (!file.exists()) {
            return "删除失败,系统未找到当前附件";
        }
        file.delete();
        return null;
    }
}
igds-inout/src/main/java/com/ld/igds/inout/view/InoutHand.view.xml
@@ -185,6 +185,22 @@
&#xD;
        }&#xD;
    });&#xD;
}&#xD;
&#xD;
//删除附件&#xD;
delFile = function(){&#xD;
    var entity = view.get(&quot;#dgFiles&quot;).getCurrentItem();&#xD;
    view.get(&quot;#ajaxDelFile&quot;).set(&quot;parameter&quot;,{&#xD;
        fileName:entity.get(&quot;fileName&quot;),&#xD;
        createTime:entity.get(&quot;createTime&quot;)&#xD;
    }).execute(function(result){&#xD;
        if(result){&#xD;
            $alert(result);&#xD;
        }else{&#xD;
            entity.remove();&#xD;
            $alert(&quot;删除成功!&quot;);&#xD;
        }&#xD;
    });&#xD;
}</ClientEvent>
    <Property name="packages">font-awesome,css-common</Property>
    <Property name="javaScriptFile">./static/plugins/lodop/LodopFuncs.js</Property>
@@ -747,6 +763,16 @@
              <DataColumn name="fileName">
                <Property name="property">fileName</Property>
              </DataColumn>
              <DataColumn>
                <ClientEvent name="onRenderCell">arg.dom.innerHTML = &quot;&lt;a href='javascript:;' onClick='delFile()'>删除&lt;/a>&quot;;&#xD;
</ClientEvent>
                <Property name="property">fileId</Property>
                <Property name="name">fileId</Property>
                <Property name="align">center</Property>
                <Property name="caption">操作</Property>
                <Property name="readOnly">true</Property>
                <Property name="width">80</Property>
              </DataColumn>
            </DataGrid>
          </Children>
        </FieldSet>
@@ -890,9 +916,9 @@
    <UploadAction id="uploadImg">
      <ClientEvent name="beforeFileUploaded">var data = view.get(&quot;#dsMain.data:#&quot;)&#xD;
var plateNum = data.get(&quot;plateNum&quot;);&#xD;
var bizTag = &quot;EMPTY&quot;;&#xD;
self.set(&quot;parameter&quot;,{&#xD;
    plateNum:plateNum,&#xD;
    bizTag:&quot;EMPTY_WEIGHT&quot;&#xD;
    bizTag: bizTag&#xD;
})</ClientEvent>
      <ClientEvent name="onFileUploaded">//附件上传完成后添加业务数据&#xD;
var mainData = view.get(&quot;#dsMain.data&quot;);&#xD;
@@ -902,8 +928,9 @@
      <ClientEvent name="beforeFileUploaded">var data = view.get(&quot;#dsMain.data:#&quot;)&#xD;
if(data){&#xD;
    var plateNum = data.get(&quot;plateNum&quot;);&#xD;
    var bizTag = &quot;EMPTY&quot;;&#xD;
    self.set(&quot;parameter&quot;,{&#xD;
        plateNum:plateNum&#xD;
        bizTag:bizTag&#xD;
    })&#xD;
}</ClientEvent>
      <Property name="maxFileSize">20MB</Property>
@@ -916,9 +943,9 @@
      <ClientEvent name="beforeFileUploaded">var data = view.get(&quot;#dsMain.data:#&quot;)&#xD;
&#xD;
var plateNum = data.get(&quot;plateNum&quot;);&#xD;
var bizTag = &quot;FULL&quot;;&#xD;
self.set(&quot;parameter&quot;,{&#xD;
    plateNum:plateNum,&#xD;
    bizTag:&quot;FULL_WEIGHT&quot;&#xD;
    bizTag: bizTag&#xD;
})</ClientEvent>
      <ClientEvent name="onFileUploaded">//附件上传完成后添加业务数据&#xD;
var mainData = view.get(&quot;#dsMain.data&quot;);&#xD;
@@ -928,8 +955,9 @@
      <ClientEvent name="beforeFileUploaded">var data = view.get(&quot;#dsMain.data:#&quot;)&#xD;
if(data){&#xD;
    var plateNum = data.get(&quot;plateNum&quot;);&#xD;
    var bizTag = &quot;FULL&quot;;&#xD;
    self.set(&quot;parameter&quot;,{&#xD;
        plateNum:plateNum&#xD;
        bizTag:bizTag&#xD;
    })&#xD;
}</ClientEvent>
      <Property name="maxFileSize">20MB</Property>
@@ -942,9 +970,9 @@
      <ClientEvent name="beforeFileUploaded">var data = view.get(&quot;#dsMain.data:#&quot;)&#xD;
&#xD;
var plateNum = data.get(&quot;plateNum&quot;);&#xD;
var bizTag = &quot;HANDLE&quot;;&#xD;
self.set(&quot;parameter&quot;,{&#xD;
    plateNum:plateNum,&#xD;
    bizTag:&quot;HAND&quot;&#xD;
    bizTag: bizTag&#xD;
})</ClientEvent>
      <ClientEvent name="onFileUploaded">//附件上传完成后添加业务数据&#xD;
var mainData = view.get(&quot;#dsMain.data&quot;);&#xD;
@@ -954,8 +982,9 @@
      <ClientEvent name="beforeFileUploaded">var data = view.get(&quot;#dsMain.data:#&quot;)&#xD;
if(data){&#xD;
    var plateNum = data.get(&quot;plateNum&quot;);&#xD;
    var bizTag = &quot;HANDLE&quot;;&#xD;
    self.set(&quot;parameter&quot;,{&#xD;
        plateNum:plateNum&#xD;
        bizTag:bizTag&#xD;
    })&#xD;
}</ClientEvent>
      <Property name="maxFileSize">20MB</Property>
@@ -964,5 +993,10 @@
      <Property name="fileResolver">inoutDataPR#uploadImage</Property>
      <Filters/>
    </UploadAction>
    <AjaxAction id="ajaxDelFile">
      <Property name="service">inoutDataPR#delImage</Property>
      <Property name="async">true</Property>
      <Property name="confirmMessage">确定要删除么?</Property>
    </AjaxAction>
  </View>
</ViewConfig>