浏览代码

普通报销事件修改

chenjun 1 年之前
父节点
当前提交
527c53fa3e

+ 2 - 2
zjugis-business/src/main/java/com/zjugis/business/flow/commoncost/controller/CommonCostController.java

@@ -55,14 +55,14 @@ public class CommonCostController extends BaseController {
     }
 
     @PostMapping("/update")
-    @Operation(summary = "更新请假流程")
+    @Operation(summary = "更新普通报销流程")
     public String updateCommonCost(@Valid @RequestBody CommonCostUpdateReqVO updateReqVO) {
         commonCostService.updateCommonCost(updateReqVO);
         return success(true);
     }
 
     @DeleteMapping("/delete")
-    @Operation(summary = "删除请假流程")
+    @Operation(summary = "删除普通报销流程")
     @Parameter(name = "id", description = "编号", required = true)
     public String deleteCommonCost(@RequestParam("id") String id) {
         commonCostService.deleteCommonCost(id);

+ 72 - 26
zjugis-business/src/main/java/com/zjugis/business/flow/commoncost/event/CommonCostEvent.java

@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollectionUtil;
 import com.zjugis.business.bean.entity.Project;
 import com.zjugis.business.converter.commoncost.CommonCostConvert;
 import com.zjugis.business.flow.commoncost.entity.CommonCostDO;
+import com.zjugis.business.flow.commoncost.entity.CommonCostDetailDO;
 import com.zjugis.business.flow.commoncost.service.CommonCostDetailService;
 import com.zjugis.business.flow.commoncost.service.CommonCostService;
 import com.zjugis.business.service.ProjectService;
@@ -19,7 +20,6 @@ import com.zjugis.module.system.api.dept.PostApi;
 import com.zjugis.module.system.api.dept.dto.DeptLeaderRespDTO;
 import com.zjugis.module.system.api.dept.dto.DeptRespDTO;
 import com.zjugis.module.system.api.dept.dto.PostRespDTO;
-import com.zjugis.module.system.api.user.dto.AdminUserRespDTO;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -31,6 +31,7 @@ import javax.annotation.Resource;
 import java.math.BigDecimal;
 import java.time.LocalDate;
 import java.util.*;
+import java.util.concurrent.atomic.AtomicBoolean;
 
 import static com.zjugis.business.constants.FlowStatusConstants.*;
 import static com.zjugis.framework.common.util.collection.CollectionUtils.convertSet;
@@ -76,9 +77,15 @@ public class CommonCostEvent extends BaseController {
                 CommonCostDO entity = commonCostService.findByInstanceId(flowInstanceId);
                 entity.setFlowStatus(FLOW_PROCESS);
                 commonCostService.updateCommonCost(CommonCostConvert.INSTANCE.convert(entity));
+                List<CommonCostDetailDO> detailList = commonCostDetailService.getListByCommonCostId(entity.getId());
+                StringBuilder projectName = new StringBuilder();
+                detailList.forEach(x->{
+                    Project project = projectService.selectById(x.getProjectId());
+                    projectName.append(project.getXmmc());
+                    projectName.append(";");
+                });
                 String applyTime = LocalDateTimeUtils.format(entity.getApplyTime(), null);
-                Project project = projectService.selectById(entity.getProjectId());
-                String flowDesc = StringUtils.join(Arrays.asList(entity.getUserNickname(), applyTime, "¥"+entity.getTotalAmount(), project.getXmmc()), "/");
+                String flowDesc = StringUtils.join(Arrays.asList(entity.getUserNickname(), applyTime, "¥"+entity.getTotalAmount(), projectName), "/");
                 flowDesc = flowDesc.length() > 1 ? flowDesc.substring(1) : flowDesc;
                 workflowClient.saveFlowDescribe(flowInstanceId, flowDesc);
                 return ok("true");
@@ -328,12 +335,16 @@ public class CommonCostEvent extends BaseController {
         try {
             String flowInstanceId = flowInstance.get("id").toString();
             CommonCostDO entity = commonCostService.findByInstanceId(flowInstanceId);
-            Project project = projectService.selectById(entity.getProjectId());
-            String xmjlId = project.getXmjlId();
+            List<CommonCostDetailDO> detailList = commonCostDetailService.getListByCommonCostId(entity.getId());
+            Set<String> xmjlList = new HashSet<>();
+            detailList.forEach(x->{
+                Project project = projectService.selectById(x.getProjectId());
+                xmjlList.add(project.getXmjlId());
+            });
             String userId = entity.getUserId();
             List<PostRespDTO> postList = postApi.getPostByUser(userId).getCheckedData();
             Set<String> postCodes = convertSet(postList, PostRespDTO::getCode);
-            if (entity != null && CollectionUtil.contains(postCodes, "ceo") && userId.equals(xmjlId)) {
+            if (entity != null && CollectionUtil.contains(postCodes, "ceo") && xmjlList.contains(userId)) {
                 return "true";
             }
             return "false";
@@ -347,15 +358,26 @@ public class CommonCostEvent extends BaseController {
         try {
             String flowInstanceId = flowInstance.get("id").toString();
             CommonCostDO entity = commonCostService.findByInstanceId(flowInstanceId);
-            Project project = projectService.selectById(entity.getProjectId());
-            String xmjlId = project.getXmjlId();
+            List<CommonCostDetailDO> detailList = commonCostDetailService.getListByCommonCostId(entity.getId());
+            Set<String> zrbmIdList = new HashSet<>();
+            detailList.forEach(x->{
+                Project project = projectService.selectById(x.getProjectId());
+                zrbmIdList.add(project.getZrbmId());
+            });
             String userId = entity.getUserId();
             List<PostRespDTO> postList = postApi.getPostByUser(userId).getCheckedData();
             Set<String> postCodes = convertSet(postList, PostRespDTO::getCode);
             List<DeptRespDTO> deptChildList = deptApi.getChildDeptList(entity.getDeptId()).getCheckedData();
             Set<String> depts = convertSet(deptChildList, DeptRespDTO::getId);
             depts.add(entity.getDeptId());
-            if (entity != null && CollectionUtil.contains(postCodes, "fgslz") && userId.equals(xmjlId) && CollectionUtil.contains(depts, project.getZrbmId()) && userId.equals(xmjlId)) {
+            AtomicBoolean deptFlag = new AtomicBoolean(true);
+            zrbmIdList.forEach(x->{
+               if(!CollectionUtil.contains(depts, zrbmIdList)){
+                   deptFlag.set(false);
+                   return ;
+               }
+            });
+            if (entity != null && CollectionUtil.contains(postCodes, "fgslz") && deptFlag.get()) {
                 return "true";
             }
             return "false";
@@ -369,15 +391,26 @@ public class CommonCostEvent extends BaseController {
         try {
             String flowInstanceId = flowInstance.get("id").toString();
             CommonCostDO entity = commonCostService.findByInstanceId(flowInstanceId);
-            Project project = projectService.selectById(entity.getProjectId());
-            String xmjlId = project.getXmjlId();
+            List<CommonCostDetailDO> detailList = commonCostDetailService.getListByCommonCostId(entity.getId());
+            Set<String> zrbmIdList = new HashSet<>();
+            detailList.forEach(x->{
+                Project project = projectService.selectById(x.getProjectId());
+                zrbmIdList.add(project.getZrbmId());
+            });
             String userId = entity.getUserId();
             List<PostRespDTO> postList = postApi.getPostByUser(userId).getCheckedData();
             Set<String> postCodes = convertSet(postList, PostRespDTO::getCode);
             List<DeptRespDTO> deptChildList = deptApi.getChildDeptList(entity.getDeptId()).getCheckedData();
             Set<String> depts = convertSet(deptChildList, DeptRespDTO::getId);
             depts.add(entity.getDeptId());
-            if (entity != null && CollectionUtil.contains(postCodes, "fgslz") && userId.equals(xmjlId) && !CollectionUtil.contains(depts, project.getZrbmId()) && userId.equals(xmjlId)) {
+            AtomicBoolean deptFlag = new AtomicBoolean(true);
+            zrbmIdList.forEach(x->{
+                if(!CollectionUtil.contains(depts, zrbmIdList)){
+                    deptFlag.set(false);
+                    return ;
+                }
+            });
+            if (entity != null && CollectionUtil.contains(postCodes, "fgslz") && !deptFlag.get()) {
                 return "true";
             }
             return "false";
@@ -405,15 +438,18 @@ public class CommonCostEvent extends BaseController {
         try {
             if (StringUtils.isNotBlank(flowInstanceId)) {
                 CommonCostDO entity = commonCostService.findByInstanceId(flowInstanceId);
-                Project project = projectService.selectById(entity.getProjectId());
+                List<CommonCostDetailDO> detailList = commonCostDetailService.getListByCommonCostId(entity.getId());
+                Set<String> zrbmIdList = new HashSet<>();
+                detailList.forEach(x->{
+                    Project project = projectService.selectById(x.getProjectId());
+                    zrbmIdList.add(project.getZrbmId());
+                });
                 List<Map<String, String>> userMaps = new ArrayList<>();
-                if(StringUtils.isNotBlank(project.getZrbmId())){
-                    DeptRespDTO deptRespDTO = deptApi.getDept(project.getZrbmId()).getCheckedData();
-                    if(deptRespDTO != null && StringUtils.isNotBlank(deptRespDTO.getLeaderUserId())){
-                        HashMap<String,String> map = new HashMap<>();
-                        map.put("id",deptRespDTO.getLeaderUserId());
-                        userMaps.add(map);
-                    }
+                List<DeptRespDTO> deptList = deptApi.getDeptList(zrbmIdList).getCheckedData();
+                for (DeptRespDTO deptRespDTO : deptList) {
+                    HashMap<String,String> map = new HashMap<>();
+                    map.put("id",deptRespDTO.getLeaderUserId());
+                    userMaps.add(map);
                 }
                 return ok(userMaps);
             } else {
@@ -430,10 +466,15 @@ public class CommonCostEvent extends BaseController {
         try {
             if (StringUtils.isNotBlank(flowInstanceId)) {
                 CommonCostDO entity = commonCostService.findByInstanceId(flowInstanceId);
-                Project project = projectService.selectById(entity.getProjectId());
+                List<CommonCostDetailDO> detailList = commonCostDetailService.getListByCommonCostId(entity.getId());
+                Set<String> zrbmIdList = new HashSet<>();
+                detailList.forEach(x->{
+                    Project project = projectService.selectById(x.getProjectId());
+                    zrbmIdList.add(project.getZrbmId());
+                });
                 List<Map<String, String>> userMaps = new ArrayList<>();
-                if(StringUtils.isNotBlank(project.getZrbmId())){
-                    DeptLeaderRespDTO deptLeaderRespDTO = deptLeaderApi.getDeptLeaderByDeptId(project.getZrbmId()).getCheckedData();
+                for (String zrbmId : zrbmIdList){
+                    DeptLeaderRespDTO deptLeaderRespDTO = deptLeaderApi.getDeptLeaderByDeptId(zrbmId).getCheckedData();
                     if(deptLeaderRespDTO != null && StringUtils.isNotBlank(deptLeaderRespDTO.getUserId())){
                         HashMap<String,String> map = new HashMap<>();
                         map.put("id",deptLeaderRespDTO.getUserId());
@@ -455,10 +496,15 @@ public class CommonCostEvent extends BaseController {
         try {
             if (StringUtils.isNotBlank(flowInstanceId)) {
                 CommonCostDO entity = commonCostService.findByInstanceId(flowInstanceId);
-                Project project = projectService.selectById(entity.getProjectId());
+                List<CommonCostDetailDO> detailList = commonCostDetailService.getListByCommonCostId(entity.getId());
+                Set<String> zrbmIdList = new HashSet<>();
+                detailList.forEach(x->{
+                    Project project = projectService.selectById(x.getProjectId());
+                    zrbmIdList.add(project.getZrbmId());
+                });
                 List<Map<String, String>> userMaps = new ArrayList<>();
-                if(StringUtils.isNotBlank(project.getZrbmId())){
-                    DeptRespDTO deptRespDTO = deptApi.getSecondDeptByDeptId(project.getZrbmId()).getCheckedData();
+                for (String zrbmId : zrbmIdList){
+                    DeptRespDTO deptRespDTO = deptApi.getSecondDeptByDeptId(zrbmId).getCheckedData();
                     if(deptRespDTO != null && StringUtils.isNotBlank(deptRespDTO.getLeaderUserId())){
                         HashMap<String,String> map = new HashMap<>();
                         map.put("id",deptRespDTO.getLeaderUserId());

+ 1 - 1
zjugis-business/src/main/resources/templates/CommonCost/agentIndex.ftl

@@ -65,7 +65,7 @@
             <td>
               <div class="form-group">
                 <div class="form-item">
-                  <div class="z-comp-input" name="createReqVO$attendanceNoteNo">
+                  <div class="z-comp-input" name="createReqVO$commonCostNo">
                     <input type="text" value="${formEntity.commonCostNo!}">
                   </div>
                 </div>

+ 11 - 53
zjugis-business/src/main/resources/templates/CommonCost/index.ftl

@@ -64,57 +64,13 @@
             <td>
               <div class="form-group">
                 <div class="form-item">
-                  <div class="z-comp-input" name="createReqVO$attendanceNoteNo">
+                  <div class="z-comp-input" name="createReqVO$commonCostNo">
                     <input type="text" value="${formEntity.commonCostNo!}">
                   </div>
                 </div>
               </div>
             </td>
           </tr>
-          <tr>
-            <td class="th">
-              <div class="form-label">项目:</div>
-            </td>
-            <td colspan="3">
-              <div class="form-group">
-                <div class="form-item btns-form-box">
-                  <input type="hidden" name="createReqVO$projectId" value="${formEntity.projectId!}">
-                  <div class="z-comp-input" name="createReqVO$projectName">
-                    <input type="text" value="${projectName!}">
-                    <div id="selectProject" name="selectProject" style="width: 50px; float: right;">
-                      <div class="btn btn-sm btn-primary">选择</div>
-                    </div>
-                  </div>
-                </div>
-              </div>
-            </td>
-          </tr>
-          <tr>
-            <td class="th">
-              <div class="form-label">项目编号:</div>
-            </td>
-            <td>
-              <div class="form-group">
-                <div class="form-item">
-                  <div class="z-comp-input z-readonly" name="createReqVO$xmbh">
-                    <input type="text" value="${projectXmbh!}">
-                  </div>
-                </div>
-              </div>
-            </td>
-            <td class="th">
-              <div class="form-label">项目责任部门:</div>
-            </td>
-            <td>
-              <div class="form-group">
-                <div class="form-item">
-                  <div class="z-comp-input z-readonly" name="createReqVO$xmzrbm">
-                    <input type="text" value="${projectZrbm!}">
-                  </div>
-                </div>
-              </div>
-            </td>
-          </tr>
           <tr>
             <td class="th">
               <div class="form-label">付款单位:</div>
@@ -214,14 +170,16 @@
       <div class="qjsjxx-box">
         <table class="form-table-info">
           <tr style="height: 37px;">
-            <td style="width: 70px;">序号</td>
-            <td style="width: 200px;">发生日期</td>
-            <td style="width: 300px;">费用实际所属类型</td>
-            <td>发票内容</td>
-            <td style="width: 100px;">单据张数</td>
-            <td style="width: 200px;">金额</td>
-            <td>备注</td>
-            <td>操作</td>
+            <td style="width: 2%;"></td>
+            <td style="width: 20%;">项目名称</td>
+            <td style="width: 10%;">项目部门</td>
+            <td style="width: 9%;">发生日期</td>
+            <td style="width: 13%;">费用实际所属类型</td>
+            <td style="width: 10%;">发票内容</td>
+            <td style="width: 8%;">单据张数</td>
+            <td style="width: 8%;">金额</td>
+            <td style="width: 10%;">备注</td>
+            <td style="width: 10%;">操作</td>
           </tr>
           <tbody class="tbody tbodyQjsq">
           </tbody>

+ 127 - 67
zjugis-business/src/main/resources/templates/CommonCost/js/index.js

@@ -3,6 +3,7 @@
   let viewState = z.ui.comm.getUrlParam("_o");
   let read = z.ui.comm.getUrlParam("read");
   let finance = z.ui.comm.getUrlParam("finance");
+  let detailProjectIndex = 0;
   let costTypeJSON = JSON.parse(document.querySelector('#costTypeJSON').value)
   window.onload = function (ex) {
     let timeObject = document.querySelector('#detailList')
@@ -20,9 +21,12 @@
         invoiceNums: "",
         isvalid: "",
         latestModifyTime: "",
+        projectId: "",
+        projectName: "",
+        projectDeptName: ""
       }
       isTimes.push(obj)
-      generateTableTrHtml(isTimes.length-1)
+      generateTableTrHtml(isTimes.length - 1)
       buildQjsjSeq();
       detailTotalInit()
     })
@@ -46,72 +50,93 @@
           invoiceNums: arrays[i].invoiceNums || '',
           isvalid: arrays[i].isvalid || '',
           latestModifyTime: arrays[i].latestModifyTime || '',
+          projectId: arrays[i].projectId || '',
+          projectName: arrays[i].projectName || '',
+          projectDeptName: arrays[i].projectDeptName || ''
         }
         isTimes.push(obj)
       }
       updateView()
     }
   }
+
   function updateView() {
     let tbodyQjsq = document.querySelector('.tbodyQjsq')
     let html = ''
     for (let i = 0; i < isTimes.length; i++) {
       html += '<tr class="qjsjClass" id="qjsj_' + i + '" style="background:#fff">'
-        + '<td name="qjsj_seq">' + (i + 1) + '</td>'
-        + '<td>'
-        + '<div class="form-flex">'
-        + '<div class="form-item" style="width: 100%;margin-right: 5px;">'
-        + '<div class="z-comp-date" name="CommonCostDetailDO[' + i + ']$costDate">'
-        + '<input type="text" value="' + isTimes[i].costDate + '">'
-        + '</div>'
-        + '</div>'
-        + '</div>'
-        + '</td>'
-        + '<td>'
-        + '<div class="form-flex">'
-        + '<div class="form-item" style="width: 100%;margin-right: 5px;">'
-        + '<div class="z-comp-selecttree" name="costType[' + i + ']">'
-        + '<input type="hidden" name="CommonCostDetailDO[' + i + ']$costType">'
-        + '<div class="z-inputselect-bar">'
-        + '<span></span><i></i>'
-        + '</div>'
-        + '</div>'
-        + '</div>'
-        + '</div>'
-        + '</td>'
-        + '<td>'
-        + '<div class="form-item">'
-        + '<div class="z-comp-input" name="CommonCostDetailDO[' + i + ']$costContent">'
-        + '<input type="text" value="' + isTimes[i].costContent + '">'
-        + '</div>'
-        + '</div>'
-        + '</td>'
-        + '<td>'
-        + '<div class="form-item">'
-        + '<div class="z-comp-input" name="CommonCostDetailDO[' + i + ']$invoiceNums">'
-        + '<input type="number" value="' + isTimes[i].invoiceNums + '">'
-        + '</div>'
-        + '</div>'
-        + '</td>'
-        + '<td>'
-        + '<div class="form-item">'
-        + '<div class="z-comp-input" name="CommonCostDetailDO[' + i + ']$amount">'
-        + '<input type="number" value="' + isTimes[i].amount + '">'
-        + '</div>'
-        + '</div>'
-        + '</td>'
-        + '<td>'
-        + '<div class="form-item">'
-        + '<div class="z-comp-input" name="CommonCostDetailDO[' + i + ']$bz1">'
-        + '<input type="text" value="' + isTimes[i].bz1 + '">'
-        + '</div>'
-        + '</div>'
-        + '</td>'
-        + '<td>'
-        + '<div id="delBtn_' + (i) + '" class="table-btn delBtn_' + (i) + '" data-index="' + (i) + '">'
-        + '<span>删除</span>'
-        + '</div>'
-        + '</td></tr>';
+          + '<td name="qjsj_seq">' + (i + 1) + '</td>'
+          + '<td>'
+          + '<div class="form-flex">'
+          + '<div class="form-item" style="width: 100%;margin-right: 5px;">'
+          + '<input type="hidden" name="CommonCostDetailDO[' + i + ']$projectId" value="">'
+          + '<div class="z-comp-input z-readonly" id="selectProject_' + i + '" name="CommonCostDetailDO[' + i + ']$projectName">'
+          + '<input readonly type="text" value="">'
+          + '</div>'
+          + '</div>'
+          + '</div>'
+          + '</td>'
+          + '<td>'
+          + '<div class="form-item">'
+          + '<div class="z-comp-input z-readonly" name="CommonCostDetailDO[' + i + ']$xmzrbm">'
+          + '<input readonly type="text" value="">'
+          + '</div>'
+          + '</div>'
+          + '</td>'
+          + '<td>'
+          + '<div class="form-flex">'
+          + '<div class="form-item" style="width: 100%;margin-right: 5px;">'
+          + '<div class="z-comp-date" name="CommonCostDetailDO[' + i + ']$costDate">'
+          + '<input type="text" value="' + isTimes[i].costDate + '">'
+          + '</div>'
+          + '</div>'
+          + '</div>'
+          + '</td>'
+          + '<td>'
+          + '<div class="form-flex">'
+          + '<div class="form-item" style="width: 100%;margin-right: 5px;">'
+          + '<div class="z-comp-selecttree" name="costType[' + i + ']">'
+          + '<input type="hidden" name="CommonCostDetailDO[' + i + ']$costType">'
+          + '<div class="z-inputselect-bar">'
+          + '<span></span><i></i>'
+          + '</div>'
+          + '</div>'
+          + '</div>'
+          + '</div>'
+          + '</td>'
+          + '<td>'
+          + '<div class="form-item">'
+          + '<div class="z-comp-input" name="CommonCostDetailDO[' + i + ']$costContent">'
+          + '<input type="text" value="' + isTimes[i].costContent + '">'
+          + '</div>'
+          + '</div>'
+          + '</td>'
+          + '<td>'
+          + '<div class="form-item">'
+          + '<div class="z-comp-input" name="CommonCostDetailDO[' + i + ']$invoiceNums">'
+          + '<input type="number" value="' + isTimes[i].invoiceNums + '">'
+          + '</div>'
+          + '</div>'
+          + '</td>'
+          + '<td>'
+          + '<div class="form-item">'
+          + '<div class="z-comp-input" name="CommonCostDetailDO[' + i + ']$amount">'
+          + '<input type="number" value="' + isTimes[i].amount + '">'
+          + '</div>'
+          + '</div>'
+          + '</td>'
+          + '<td>'
+          + '<div class="form-item">'
+          + '<div class="z-comp-input" name="CommonCostDetailDO[' + i + ']$bz1">'
+          + '<input type="text" value="' + isTimes[i].bz1 + '">'
+          + '</div>'
+          + '</div>'
+          + '</td>'
+          + '<td>'
+          + '<div id="delBtn_' + (i) + '" class="table-btn delBtn_' + (i) + '" data-index="' + (i) + '">'
+          + '<span>删除</span>'
+          + '</div>'
+          + '</td></tr>';
     }
     tbodyQjsq.innerHTML = html
     for (let i = 0; i < isTimes.length; i++) {
@@ -122,6 +147,13 @@
       z.ui.date("[name='CommonCostDetailDO[" + i + "]$costDate']").init()
       z.ui.selecttree("[name='costType[" + i + "]']").setValue(isTimes[i].costType)
       $("[name='CommonCostDetailDO[" + i + "]$costType']").val(isTimes[i].costType);
+      $("[name='CommonCostDetailDO[" + i + "]$projectId']").val(isTimes[i].projectId);
+      z.ui.input("[name='CommonCostDetailDO[" + i + "]$projectName']").setValue(isTimes[i].projectName);
+      z.ui.input("[name='CommonCostDetailDO[" + i + "]$xmzrbm']").setValue(isTimes[i].projectDeptName);
+      $("#selectProject_" + i).click(function () {
+        detailProjectIndex = i;
+        selectProject(null, setProject);
+      })
       $("#delBtn_" + i).click(function () {
         z.ui.confirm("compid").init({
           content: "确定删除吗?",
@@ -139,7 +171,7 @@
         })
 
       })
-      if(viewState === 'v' || read=== '1'){
+      if (viewState === 'v' || read === '1') {
         detailReadonly(i)
       }
     }
@@ -152,6 +184,23 @@
     trDom.id = "qjsj_" + i;
     trDom.className = 'qjsjClass'
     trDom.innerHTML = '<td name="qjsj_seq">' + (i + 1) + '</td>'
+        + '<td>'
+        + '<div class="form-flex">'
+        + '<div class="form-item" style="width: 100%;margin-right: 5px;">'
+        + '<input type="hidden" name="CommonCostDetailDO[' + i + ']$projectId" value="">'
+        + '<div class="z-comp-input z-readonly" id="selectProject_' + i + '" name="CommonCostDetailDO[' + i + ']$projectName">'
+        + '<input readonly type="text" value="">'
+        + '</div>'
+        + '</div>'
+        + '</div>'
+        + '</td>'
+        + '<td>'
+        + '<div class="form-item">'
+        + '<div class="z-comp-input z-readonly" name="CommonCostDetailDO[' + i + ']$xmzrbm">'
+        + '<input readonly type="text" value="">'
+        + '</div>'
+        + '</div>'
+        + '</td>'
         + '<td>'
         + '<div class="form-flex">'
         + '<div class="form-item" style="width: 100%;margin-right: 5px;">'
@@ -214,6 +263,10 @@
     })
     selecttree("[name='costType[" + i + "]']", costTypeJSON, clickCostType, allowChildClick)
     z.ui.date("[name='CommonCostDetailDO[" + i + "]$costDate']").init()
+    $("#selectProject_" + i).click(function () {
+      detailProjectIndex = i;
+      selectProject(null, setProject);
+    })
     $("#delBtn_" + i).click(function () {
       z.ui.confirm("compid").init({
         content: "确定删除吗?",
@@ -233,17 +286,18 @@
     })
   }
 
-  function detailReadonly(i){
+  function detailReadonly(i) {
     //财务审核时可以核减修改金额
-    if(finance === 1){
+    if (finance === 1) {
       //如果单据金额发生修改就代表核减了
     }
-    $("#delBtn_" + i).css("display","none");
+    $("#delBtn_" + i).css("display", "none");
     $("[name='costType[" + i + "]']").addClass("z-readonly");
+    $("#selectProject_" + i).css("pointer-events", "none");
     $("[name='costType[" + i + "]']").css("pointer-events", "none");
     let detailElement = document.getElementById("qjsj_" + i);
     let detailInput = detailElement.getElementsByTagName("input");
-    for (let j = 0; j < detailInput.length; j++){
+    for (let j = 0; j < detailInput.length; j++) {
       detailInput[j].disabled = true;
       detailInput[j].className += "z-readonly"
     }
@@ -261,6 +315,9 @@
       invoiceNums: "",
       isvalid: "",
       latestModifyTime: "",
+      projectId: "",
+      projectName: "",
+      projectDeptName: ""
     }
     for (let i = 0; i < isTimes.length; i++) {
       let inpsJe = $("[name='CommonCostDetailDO[" + i + "]$amount']")[0].children[0]; //金额
@@ -288,6 +345,7 @@
       });
     }
   }
+
   function jeSumInit(idx) {
     let jeSum = 0 //金额汇总
     for (let i = 0; i < isTimes.length; i++) {
@@ -339,22 +397,23 @@
       data: JSON.stringify(postData.createReqVO),
       contentType: "application/json",
       success: function () {
-        all({ success: true });
+        all({success: true});
       },
       error: function () {
-        all({ success: false });
+        all({success: false});
       }
     })
   }
+
   function setProject(res) {
     if (res.data) {
-      $("[name='createReqVO$projectId']").val(res.data.id);
-      z.ui.input("[name='createReqVO$projectName']").setValue(res.data.xmmc);
-      z.ui.input("[name='createReqVO$xmbh']").setValue(res.data.xmbh);
-      z.ui.input("[name='createReqVO$xmzrbm']").setValue(res.data.zrbm);
+      $("[name='CommonCostDetailDO[" + detailProjectIndex + "]$projectId']").val(res.data.id);
+      z.ui.input("[name='CommonCostDetailDO[" + detailProjectIndex + "]$projectName']").setValue(res.data.xmmc);
+      z.ui.input("[name='CommonCostDetailDO[" + detailProjectIndex + "]$xmzrbm']").setValue(res.data.zrbm);
     }
   }
 
+
   function initCompany() {
     z.ui.ajax({
       type: "get",
@@ -373,6 +432,7 @@
   function clickCompany(even, treeId, treeNode) {
     $("[name='createReqVO$paymentCompanyId']").val(treeNode.id);
   }
+
   function clickCostType(even, treeId, treeNode) {
     $("[name='" + treeNode.treeName + "']").val(treeNode.id);
   }