Browse Source

归档批次-添加文件信息

[user3] 4 years ago
parent
commit
07f7236209

+ 42 - 27
src/main/java/com/jeeplus/modules/projectFilingBatch/service/ProjectFilingBatchService.java

@@ -995,34 +995,49 @@ public class ProjectFilingBatchService extends CrudService<ProjectFilingBatchDao
      * 添加--项目附件info
      */
     @Transactional(readOnly = false)
-    public void insertProInfo(String[] proInfos){
-        for (int i=0;i<proInfos.length;i++){
-           if (proInfos[i]!="") {
-               JSONArray jsonArray = JSONArray.fromObject(proInfos[i]);
-               for (int j = 0; j < jsonArray.size(); j++) {
-                   ProjectFilingBatchProInfo info = new ProjectFilingBatchProInfo();
-                   Object o = jsonArray.get(j);
-                   JSONObject json = JSONObject.fromObject(o);
-                   info.setProId(json.get("proId").toString());
-                   info.setId(IdGen.uuid());
-                   info.setProInfofilingBatch(json.get("filingId").toString());
-                   info.setProInfoName(json.get("names").toString());
-                   info.setProInfoType(json.get("types").toString());
-                   proInfoDao.proInfoInsert(info);
-               }
-           }
-
+    public void insertProInfo(String[] proInfos,String[] flags,String[] proId,String filingId){
+        String pro="";
+        JSONObject json = null;
+        if (flags.length!=0 && proId.length==1){
+            int count=0;
+            for (int s=0;s< proInfos.length;s++){
+                count++;
+                pro+=proInfos[s];
+                if(count!=proInfos.length){
+                    pro+=",";
+                }
+            }
+            json = JSONObject.fromObject(pro);
+            ProjectFilingBatchProInfo info = new ProjectFilingBatchProInfo();
+            info.setId(IdGen.uuid());
+            info.setProId(json.get("proId").toString());
+            info.setProInfofilingBatch(json.get("filingId").toString());
+            info.setProInfoName(json.get("names").toString());
+            info.setProInfoType(json.get("types").toString());
+            DelProInfo(info);
+            proInfoDao.proInfoInsert(info);
+        }else{
+            for (int i=0;i<proInfos.length;i++){
+                if (proInfos[i]!="") {
+                    json = JSONObject.fromObject(proInfos[i]);
+                    ProjectFilingBatchProInfo info = new ProjectFilingBatchProInfo();
+                    info.setId(IdGen.uuid());
+                    info.setProId(json.get("proId").toString());
+                    info.setProInfofilingBatch(json.get("filingId").toString());
+                    info.setProInfoName(json.get("names").toString());
+                    info.setProInfoType(json.get("types").toString());
+                    if(i==0){ DelProInfo(info);}
+                    proInfoDao.proInfoInsert(info);
+                }
+            }
         }
 
     }
-//    /**
-//     * 添加--项目附件info
-//     * @param proInfo
-//     */
-//    public ProjectFilingBatchProInfo insertProInfo(ProjectFilingBatchProInfo proInfo){
-//        if(StringUtils.isNotEmpty(proInfo.getProInfoType())){
-//            proInfo.setId(IdGen.uuid());
-//            proInfoDao.insert(proInfo);
-//        }
-//    }
+    /**
+     * 删除--项目附件info
+     * @param proInfo
+     */
+    public void DelProInfo(ProjectFilingBatchProInfo proInfo){
+        proInfoDao.delete(proInfo);
+    }
 }

+ 8 - 3
src/main/java/com/jeeplus/modules/projectFilingBatch/web/ProjectFilingBatchController.java

@@ -345,7 +345,7 @@ public class ProjectFilingBatchController extends BaseController {
      */
     @RequiresPermissions(value = {"projectFilingBatch:projectFilingBatchInfo:add", "projectFilingBatch:projectFilingBatchInfo:edit"}, logical = Logical.OR)
     @RequestMapping(value = "save")
-    public String save(ProjectFilingBatch projectFilingBatch, Model model, RedirectAttributes redirectAttributes, @RequestParam("proId")String[] proId, String[] proInfos) throws Exception {
+    public String save(ProjectFilingBatch projectFilingBatch, Model model, RedirectAttributes redirectAttributes, @RequestParam("proId")String[] proId, String[] proInfos,String[] flags) throws Exception {
         if (!beanValidator(model, projectFilingBatch)){
             return form(projectFilingBatch, model);
         }
@@ -355,7 +355,10 @@ public class ProjectFilingBatchController extends BaseController {
                 if (t.getFilingStatus() == 3 ||t.getFilingStatus()==1){
                     MyBeanUtils.copyBeanNotNull2Bean(projectFilingBatch, t);//将编辑表单中的非NULL值覆盖数据库记录中的值
                     projectFilingBatchService.saveProject(proId,t, ProjectStatusEnum.IN_APRL);//保存
-                    projectFilingBatchService.insertProInfo(proInfos);
+                    if (proInfos!=null){
+                        projectFilingBatchService.insertProInfo(proInfos,flags,proId,projectFilingBatch.getId());
+                    }
+
                 }else if(t.getFilingStatus() == 2){
                     addMessage(redirectAttributes, "归档批次已送审,无法暂存");
                     return "redirect:"+Global.getAdminPath()+"/projectFilingBatch/projectFilingBatchInfo/?repage";
@@ -367,7 +370,9 @@ public class ProjectFilingBatchController extends BaseController {
                 projectFilingBatch.setFilingStatus(1);
                 projectFilingBatchService.saveProject(proId,projectFilingBatch, ProjectStatusEnum.IN_APRL);//保存
                 //新增项目树形信息
-                projectFilingBatchService.insertProInfo(proInfos);
+                if (proInfos!=null) {
+                    projectFilingBatchService.insertProInfo(proInfos, flags, proId,projectFilingBatch.getId());
+                }
             }
             addMessage(redirectAttributes, "归档送审成功");
         }catch (Exception e){

+ 5 - 0
src/main/resources/mappings/modules/projectGuidang/ProjectFilingBatchProInfoDao.xml

@@ -36,4 +36,9 @@
 		where filing_batch=#{filingBatchId}
 	</select>
 
+	<delete id="delete">
+		delete from project_filingbatch_proinfo
+		where filing_batch=#{proInfofilingBatch} and project_id=#{proId}
+	</delete>
+
 </mapper>

+ 2 - 2
src/main/webapp/webpage/modules/projectFilingBatch/ProjectFilingBatchProInfoForm.jsp

@@ -104,7 +104,7 @@
 					"<td style=\"text-align: center\" width=\"20%\"><input name='ProInfoName' style='text-align: center' class=\"form-control\"></input></td>"+
 					"<td width=\"20%\">" +
 					// "<span href=javascript:void(0); onclick=\"accordingBtn(this)\"   class=\"op-btn op-btn-edit\" title=\"上传附件\"><i class=\"glyphicon glyphicon-edit\"></i>&nbsp;编辑</span>" +
-					"<span class=\"op-btn op-btn-delete\" onclick=\"delListInfoRow(this)\" title=\"删除\"><i class=\"glyphicon glyphicon-remove\"></i>&nbsp;删除</span>" +
+					"<div class=\"op-btn-box\" ><span class=\"op-btn op-btn-delete\" onclick=\"delListInfoRow(this)\" title=\"删除\"><i class=\"glyphicon glyphicon-remove\"></i>&nbsp;删除</span></div>" +
 					"</td>"+
 					"</tr>"
 			)
@@ -178,7 +178,7 @@
 						<thead>
 						<tr>
 								<%-- <th>序号</th>--%>
-							<th>审定单</th>
+							<th>文件类型</th>
 							<th>文件描述</th>
 							<th width="150px">操作</th>
 						</tr>

+ 45 - 22
src/main/webapp/webpage/modules/projectFilingBatch/projectFilingBatchForm.jsp

@@ -74,9 +74,9 @@
                 $(span).find("span").attr("class","treeTable-icon open")
             });
         }
+        var edit;
+        var editId;
         $(document).ready(function() {
-
-
             var filingId=$("#filingId").val();
             if(filingId!=""){
                 $.ajax({
@@ -90,6 +90,8 @@
                             var id="projectList_"+obj.id;
                             var pid="project_"+obj.id;
                             var tid="project_"+obj.id+"_proId";
+                            editId=id;
+                            edit=tid;
                             var inId="#"+tid;
                             var size=$("#projectList .rowSize").size();
                             var flag=true;
@@ -112,7 +114,7 @@
                                 $("#projectList").append("<tr class='"+obj.id+"' style='display: none;'> <td colspan='4' style='padding: 0px;'>" +
                                     "<table style=\"width: 100%;padding: 0px;margin: 0px;\" class=\"table table-bordered table-condensed details\">" +
                                     "<tbody id='" + id + "'>" +
-                                    "<input type='text' id='" + id + "_json' style='display: none;' name='proInfos' />"+
+                                    "<input type='text' id='" + id + "_len' style='display: none;' name='flags' />"+
                                     "</tbody>" +
 
                                     "</table>" +
@@ -138,12 +140,14 @@
                                                 // "<input type='hidden' style='display: none;' id='attId' value='"+value.id+"'/>"+
                                                 // "<input type='hidden' style='display: none;' id='fileUrl' value='"+value.url+"'/>"+
                                                 // "</td>"+
-                                                "<td style=\"text-align: center;position: relative;\" width=\"20%\"><span style='color: red;float: left;position: absolute;left: 10px;top: 15px;'>*</span><input name='proInfoType' onChange='upwType(this)' style='text-align: center' class=\"form-control required\" value='"+value.proInfoType+"'/></td>"+
-                                                "<td style=\"text-align: center\" width=\"20%\"><input name='proInfoName' style='text-align: center' class=\"form-control required\" value='"+value.proInfoName+"'/></td>"+
+                                                "<td style=\"text-align: center;position: relative;\" width=\"20%\">" +
+                                                "<input name='proInfoType' onChange='upwType(this)' style='text-align: center' readonly='true' class=\"form-control required\" value='"+value.proInfoType+"'/></td>"+
+                                                "<td style=\"text-align: center\" width=\"20%\"><input  readonly='true' name='proInfoName' style='text-align: center' class=\"form-control required\" value='"+value.proInfoName+"'/></td>"+
                                                 "<td style=\"text-align: center\" width=\"20%\"></td>"+
                                                 "<td width=\"20%\">" +
-                                                // "<span href=javascript:void(0); onclick=\"accordingBtn(this)\"   class=\"op-btn op-btn-edit\" title=\"上传附件\"><i class=\"glyphicon glyphicon-edit\"></i>&nbsp;编辑</span>" +
+                                                "<span href=javascript:void(0); onclick=\"addRowInfoForm("+tid+","+id+")\"   class=\"op-btn op-btn-edit\" title=\"上传附件\"><i class=\"glyphicon glyphicon-edit\"></i>&nbsp;编辑</span>" +
                                                 "<span class=\"op-btn op-btn-delete\" onclick=\"delListInfoRow(this)\" title=\"删除\"><i class=\"glyphicon glyphicon-remove\"></i>&nbsp;删除</span>" +
+                                                "<input type='text' class='" + id + "_json' style='display: none;' name='proInfos' />"+
                                                 "</td>"+
                                                 "</tr>"
                                             )
@@ -520,6 +524,8 @@
                         var id="projectList_"+d.id;
                         var pid="project_"+d.id;
                         var tid="project_"+d.id+"_proId";
+                        edit=tid;
+                        editId=id;
                         var inId="#"+tid;
                         var size=$("#projectList .rowSize").size();
                         var flag=true;
@@ -542,9 +548,8 @@
                             $("#projectList").append("<tr class='"+d.id+"' style='display: none;'> <td colspan='4' style='padding: 0px;'>" +
                                 "<table style=\"width: 100%;padding: 0px;margin: 0px;\" class=\"table table-bordered table-condensed details\">" +
                                 "<tbody id='" + id + "'>" +
-                                "<input type='text' id='" + id + "_json' style='display: none;' name='proInfos' />"+
                                 "</tbody>" +
-
+                                "<input type='text' id='" + id + "_len' style='display: none;' name='flags' />"+
                                 "</table>" +
                                 "</td></tr>")
                         }
@@ -599,30 +604,42 @@
                 yes: function(index, layero){
                     var body = top.layer.getChildFrame('body', index);
                     var tbodyId="#"+tbody.id;
+                    var JsonId="."+tbody.id;
                     var iframeWin = layero.find('iframe')[0]; //得到iframe页的窗口对象,执行iframe页的方法:iframeWin.method();
                     var types=iframeWin.contentWindow.proInfoType();
                     var names=iframeWin.contentWindow.proInfoValue();
-                    var proJson=iframeWin.contentWindow.proInfoJson();
-                    var jsonInput=tbodyId+"_json"
-                    var json=JSON.stringify(proJson)
-                    $(jsonInput).val(json);
+                    var proJsons=iframeWin.contentWindow.proInfoJson();
+                    var jsonInput=JsonId+"_json"
+                    // $(jsonInput).val(json);
                     if(iframeWin.contentWindow.proInfoValue() ){
                         $(tbodyId).html("")
                         for (var i=0;i<types.length;i++){
                             var s=$(body).find("#file_attachment tr").eq(i).html();
                             var name=names[i];
                             var type=types[i];
+                            var proJson=proJsons[i];
                             $(tbodyId).append(
                                 "<tr class='listInfo'>"+
-                                "<td style=\"text-align: center;position: relative;\" width=\"20%\"><span style='color: red;float: left;position: absolute;left: 15px;top: 15px;'>*</span><input name='ProInfoType' style='text-align: center'  class=\"form-control required\" value='"+type+"'></td>"+
-                                "<td style=\"text-align: center\" width=\"20%\"><input name='ProInfoName' style='text-align: center' class=\"form-control\" value='"+name+"'></input></td>"+
+                                "<td style=\"text-align: center;position: relative;\" width=\"20%\">" +
+                                "<input  readonly='true' name='ProInfoType' style='text-align: center'  class=\"form-control required\" value='"+type+"'></td>"+
+                                "<td style=\"text-align: center\" width=\"20%\"><input  readonly='true' name='ProInfoName' style='text-align: center' class=\"form-control\" value='"+name+"'></input></td>"+
                                 "<td style=\"text-align: center\" width=\"20%\"></td>"+
                                 "<td width=\"20%\">" +
+                                "<span href=javascript:void(0); onclick=\"addRowInfoForm("+edit+","+editId+")\"   class=\"op-btn op-btn-edit\" title=\"上传附件\"><i class=\"glyphicon glyphicon-edit\"></i>&nbsp;编辑</span>" +
                                 "<span class=\"op-btn op-btn-delete\" onclick=\"delListInfoRow(this)\" title=\"删除\"><i class=\"glyphicon glyphicon-remove\"></i>&nbsp;删除</span>" +
+                                "<input type='text' class='" + jsonInput + "'  name='proInfos' style='display: none;' value='"+proJson+"' />"+
                                 "</td>"+
                                 "</tr>"
                             )
                         }
+                        if(types.length==1){
+                            var lenId=tbodyId+"_len"
+                            $(lenId).val("123");
+                            var ssss=$(lenId).val()
+                        }else{
+                            var lenId=tbodyId+"_len"
+                            $(lenId).val("");
+                        }
                         top.layer.close(index);//关闭对话框。
                         // top.window[iframeName].frames.location.reload();//刷新父亲
                     }
@@ -648,12 +665,12 @@
                 // "<input type='hidden' style='display: none;' id='attId' value=''/>"+
                 // "<input type='hidden' style='display: none;' id='fileUrl' value=''/>"+
                 // "</td>"+
-                "<td style=\"text-align: center;position: relative;\" width=\"20%\"><span style='color: red;float: left;position: absolute;left: 10px;top: 15px;'>*</span><input name='ProInfoType' style='text-align: center' onChange='upwType(this)' class=\"form-control required\"/></td>"+
-                "<td style=\"text-align: center\" width=\"20%\"><input name='ProInfoName' style='text-align: center' class=\"form-control\"/></td>"+
+                "<td style=\"text-align: center;position: relative;\" width=\"20%\"><input name='ProInfoType'  readonly='true' style='text-align: center' onChange='upwType(this)' class=\"form-control required\"/></td>"+
+                "<td style=\"text-align: center\" width=\"20%\"><input name='ProInfoName'  readonly='true' style='text-align: center' class=\"form-control\"/></td>"+
                 "<td style=\"text-align: center\" width=\"20%\"></td>"+
                 "<td width=\"20%\">" +
                 // "<span href=javascript:void(0); onclick=\"accordingBtn(this)\"   class=\"op-btn op-btn-edit\" title=\"上传附件\"><i class=\"glyphicon glyphicon-edit\"></i>&nbsp;编辑</span>" +
-                "<span class=\"op-btn op-btn-delete\" onclick=\"delListInfoRow(this)\" title=\"删除\"><i class=\"glyphicon glyphicon-remove\"></i>&nbsp;删除</span>" +
+                // "<span class=\"op-btn op-btn-delete\" onclick=\"delListInfoRow(this)\" title=\"删除\"><i class=\"glyphicon glyphicon-remove\"></i>&nbsp;删除</span>" +
                 "</td>"+
                 "</tr>"
             )
@@ -727,11 +744,17 @@
             });
         }
         function delListRow(o,obj){
-            $(o).parent().parent().remove();
-            $(obj).parent().parent().parent().remove();
-           var fu= $(obj).parent().parent().parent().html();
+            var tr=obj.id+" tr"
+            var html=$(tr).html()
+            if(html!="undefined"){
+                $(o).parent().parent().remove();
+                $(obj).parent().parent().parent().remove();
+            }
+
+
+           // var fu= $(obj).parent().parent().parent().html();
             // if ()
-            $(obj).parent().parent().parent().hide();
+            // $(obj).parent().parent().parent().hide();
         }
         function delListInfoRow(obj, prefix){
             var tr=$(obj).parent().parent();
@@ -991,7 +1014,7 @@
                         <thead>
                         <tr>
                             <th class="hide"></th>
-                            <th style="text-align: center" width="20%">归档项目编号/审定单</th>
+                            <th style="text-align: center" width="20%">归档项目编号/文件类型</th>
                             <th style="text-align: center" width="20%">归档项目名称/文件描述</th>
                             <th style="text-align: center" width="20%">报告号</th>
                             <th width="20%">操作</th>