Browse Source

费用报销的项目经理审核模式下,针对非项目按部门负责人审核

seyason 1 month ago
parent
commit
1dec74b1b3

+ 7 - 2
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/ExpenseSheetController.java

@@ -60,8 +60,13 @@ public class ExpenseSheetController {
     @RequestMapping("/add")
     @RequestMapping("/add")
     public HttpRespMsg add(ExpenseSheet sheet, String items) {
     public HttpRespMsg add(ExpenseSheet sheet, String items) {
         String userId = request.getHeader("Token");
         String userId = request.getHeader("Token");
-        return expenseSheetService.add(sheet, items, userId);
-
+        try {
+            return expenseSheetService.add(sheet, items, userId);
+        } catch (Exception e) {
+            HttpRespMsg msg = new HttpRespMsg();
+            msg.setError("验证失败:"+e.getMessage());
+            return msg;
+        }
     }
     }
 
 
     @RequestMapping("/delete")
     @RequestMapping("/delete")

+ 10 - 4
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/ExpenseItem.java

@@ -15,7 +15,7 @@ import lombok.experimental.Accessors;
  * </p>
  * </p>
  *
  *
  * @author Seyason
  * @author Seyason
- * @since 2023-07-20
+ * @since 2025-03-23
  */
  */
 @Data
 @Data
 @EqualsAndHashCode(callSuper = false)
 @EqualsAndHashCode(callSuper = false)
@@ -99,6 +99,12 @@ public class ExpenseItem extends Model<ExpenseItem> {
     @TableField("status")
     @TableField("status")
     private Integer status;
     private Integer status;
 
 
+    /**
+     * 项目经理审核模式下的审核人id
+     */
+    @TableField("auditor_id")
+    private String auditorId;
+
 
 
     @TableField(exist = false)
     @TableField(exist = false)
     private String projectName;
     private String projectName;
@@ -106,10 +112,10 @@ public class ExpenseItem extends Model<ExpenseItem> {
     @TableField(exist = false)
     @TableField(exist = false)
     private Integer isIncharger;
     private Integer isIncharger;
 
 
+//    @TableField(exist = false)
+//    private String projectManagerId;
     @TableField(exist = false)
     @TableField(exist = false)
-    private String projectManagerId;
-    @TableField(exist = false)
-    private String projectManagerName;
+    private String auditorName;
 
 
     @Override
     @Override
     protected Serializable pkVal() {
     protected Serializable pkVal() {

+ 1 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/ExpenseSheetService.java

@@ -18,7 +18,7 @@ import java.util.List;
  */
  */
 public interface ExpenseSheetService extends IService<ExpenseSheet> {
 public interface ExpenseSheetService extends IService<ExpenseSheet> {
 
 
-    HttpRespMsg add(ExpenseSheet sheet, String items, String userId);
+    HttpRespMsg add(ExpenseSheet sheet, String items, String userId) throws Exception;
 
 
     HttpRespMsg delete(Integer id);
     HttpRespMsg delete(Integer id);
 
 

+ 54 - 13
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ExpenseSheetServiceImpl.java

@@ -70,6 +70,8 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
     @Resource
     @Resource
     private ExpenseItemService expenseItemService;
     private ExpenseItemService expenseItemService;
     @Resource
     @Resource
+    private DepartmentMapper departmentMapper;
+    @Resource
     private ExpenseItemMapper expenseItemMapper;
     private ExpenseItemMapper expenseItemMapper;
     @Resource
     @Resource
     private ProjectMapper projectMapper;
     private ProjectMapper projectMapper;
@@ -108,7 +110,7 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
 
 
 
 
     @Override
     @Override
-    public HttpRespMsg add(ExpenseSheet sheet, String items, String userId) {
+    public HttpRespMsg add(ExpenseSheet sheet, String items, String userId) throws Exception {
         HttpRespMsg msg = new HttpRespMsg();
         HttpRespMsg msg = new HttpRespMsg();
         User user = userMapper.selectById(userId);
         User user = userMapper.selectById(userId);
         ExpenseAuditSetting auditSetting = expenseAuditSettingMapper.selectById(user.getCompanyId());
         ExpenseAuditSetting auditSetting = expenseAuditSettingMapper.selectById(user.getCompanyId());
@@ -318,6 +320,30 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
                 JSONObject obj = array.getJSONObject(i);
                 JSONObject obj = array.getJSONObject(i);
                 ExpenseItem expenseItem = JSONObject.toJavaObject(obj, ExpenseItem.class);
                 ExpenseItem expenseItem = JSONObject.toJavaObject(obj, ExpenseItem.class);
                 expenseItem.setExpenseId(sheet.getId());
                 expenseItem.setExpenseId(sheet.getId());
+                //按项目经理审核时,非项目是部门负责人审核,需要设置审核人
+                if (auditSetting != null && auditSetting.getAuditType() == 1) {
+                    Project project = projectMapper.selectById(expenseItem.getProjectId());
+                    if (project.getIsPublic() == 0) {
+                        if (project.getInchargerId() == null) {
+                            throw new Exception("请先设置项目【"+project.getProjectName()+"】的项目经理");
+                        } else {
+                            expenseItem.setAuditorId(project.getInchargerId());
+                        }
+                    } else {
+                        //非项目
+                        User owner = userMapper.selectById(sheet.getOwnerId());
+                        if (owner.getDepartmentId() == null) {
+                            throw new Exception("请先设置报销人【"+owner.getName()+"】的部门");
+                        } else {
+                            Department department = departmentMapper.selectById(owner.getDepartmentId());
+                            if (department.getManagerId() == null) {
+                                throw new Exception("请先设置部门【"+department.getDepartmentName()+"】的负责人");
+                            } else {
+                                expenseItem.setAuditorId(department.getManagerId());
+                            }
+                        }
+                    }
+                }
                 itemList.add(expenseItem);
                 itemList.add(expenseItem);
             }
             }
         }
         }
@@ -547,13 +573,9 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
         } else if(expenseAuditSetting.getAuditType() == 1){
         } else if(expenseAuditSetting.getAuditType() == 1){
             //增加按项目经理审核模式下,项目经理可以查看相关费用报销单的条件
             //增加按项目经理审核模式下,项目经理可以查看相关费用报销单的条件
             if (sheet.getStatus() != null) {
             if (sheet.getStatus() != null) {
-                //取待审核的
-                //项目经理审核模式下,只能查看自己项目的费用报销单
-                List<Integer> projectIds = projectMapper.selectList(new QueryWrapper<Project>().eq("incharger_id", token)).stream().map(Project::getId).collect(Collectors.toList());
-                System.out.println("项目经理的项目id"+projectIds);
-                if (projectIds.size() > 0) {
-                    List<Integer> expenseIds = expenseItemMapper.selectList(new QueryWrapper<ExpenseItem>().in("project_id", projectIds)).stream().map(ExpenseItem::getExpenseId).distinct().collect(Collectors.toList());
-                    System.out.println("项目经理的项目的费用报销单id"+expenseIds);
+                //项目经理审核模式下,只能查看自己需要审核的单据
+                List<Integer> expenseIds = expenseItemMapper.selectList(new QueryWrapper<ExpenseItem>().eq("auditor_id", token)).stream().map(ExpenseItem::getExpenseId).distinct().collect(Collectors.toList());
+                if (expenseIds.size() > 0) {
                     queryWrapper.in("id", expenseIds);
                     queryWrapper.in("id", expenseIds);
                 } else {
                 } else {
                     //没有项目的项目经理,不显示任何数据
                     //没有项目的项目经理,不显示任何数据
@@ -724,7 +746,7 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
         for (ExpenseItem expenseItem : list) {
         for (ExpenseItem expenseItem : list) {
             for (Project project : Project) {
             for (Project project : Project) {
                 if ((project.getId().equals(expenseItem.getProjectId()))){
                 if ((project.getId().equals(expenseItem.getProjectId()))){
-                    if (token.equals(project.getInchargerId())) {
+                    if (token.equals(expenseItem.getAuditorId())) {
                         expenseItem.setIsIncharger(1);
                         expenseItem.setIsIncharger(1);
                     } else {
                     } else {
                         expenseItem.setIsIncharger(0);
                         expenseItem.setIsIncharger(0);
@@ -732,11 +754,10 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
                     expenseItem.setProjectName(project.getProjectName());
                     expenseItem.setProjectName(project.getProjectName());
                     //获取审核人姓名
                     //获取审核人姓名
                     if (!(expenseAuditSetting == null || expenseAuditSetting.getAuditType() == 0)) {
                     if (!(expenseAuditSetting == null || expenseAuditSetting.getAuditType() == 0)) {
-                        expenseItem.setProjectManagerId(project.getInchargerId());
-                        if (project.getInchargerId() != null) {
-                            User user = userMapper.selectById(project.getInchargerId());
+                        if (expenseItem.getAuditorId() != null) {
+                            User user = userMapper.selectById(expenseItem.getAuditorId());
                             if (user != null) {
                             if (user != null) {
-                                expenseItem.setProjectManagerName(user.getName());
+                                expenseItem.setAuditorName(user.getName());
                             }
                             }
                         }
                         }
                     }
                     }
@@ -979,6 +1000,7 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
                 List<SysRichFunction> functionList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "费用审核");
                 List<SysRichFunction> functionList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "费用审核");
                 List<ExpenseMainType> expenseMainTypeList = expenseMainTypeService.list(new QueryWrapper<ExpenseMainType>().eq("company_id", user.getCompanyId()));
                 List<ExpenseMainType> expenseMainTypeList = expenseMainTypeService.list(new QueryWrapper<ExpenseMainType>().eq("company_id", user.getCompanyId()));
                 List<ExpenseType> expenseTypeList = expenseTypeMapper.selectList(new QueryWrapper<ExpenseType>().eq("company_id",user.getCompanyId()));
                 List<ExpenseType> expenseTypeList = expenseTypeMapper.selectList(new QueryWrapper<ExpenseType>().eq("company_id",user.getCompanyId()));
+                ExpenseAuditSetting expenseAuditSetting = expenseAuditSettingMapper.selectById(user.getCompanyId());
                 //由于第一行需要指明报销人列对应的标题
                 //由于第一行需要指明报销人列对应的标题
                 XSSFRow firstRow = sheet.getRow(2);
                 XSSFRow firstRow = sheet.getRow(2);
                 if (firstRow == null) {
                 if (firstRow == null) {
@@ -1158,6 +1180,25 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
                             || (StringUtils.isEmpty(pro.getProjectName())?"":pro.getProjectName()).equals(codeCell.getStringCellValue())).findFirst();
                             || (StringUtils.isEmpty(pro.getProjectName())?"":pro.getProjectName()).equals(codeCell.getStringCellValue())).findFirst();
                     if (project.isPresent()) {
                     if (project.isPresent()) {
                         expenseItem.setProjectId(project.get().getId());
                         expenseItem.setProjectId(project.get().getId());
+                        if (expenseAuditSetting != null && expenseAuditSetting.getAuditType() == 1) {
+                            //按项目和非项目分别设置审核人
+                            if (project.get().getIsPublic() == 0) {
+                                expenseItem.setAuditorId(project.get().getInchargerId());
+                            } else {
+                                //非项目,设置部门负责人为审核人
+                                User user1 = userList.stream().filter(us -> us.getId().equals(user.getId())).findFirst().get();
+                                if (user1.getDepartmentId() == null) {
+                                    throw new Exception("当前用户没有部门信息");
+                                } else {
+                                    Department dept = departmentMapper.selectById(user1.getDepartmentId());
+                                    if (dept.getManagerId() == null) {
+                                        throw new Exception("当前用户所在部门没有负责人");
+                                    } else {
+                                        expenseItem.setAuditorId(dept.getManagerId());
+                                    }
+                                }
+                            }
+                        }
                     }
                     }
                     expenseItem.setExpenseId(expenseSheet.getId());
                     expenseItem.setExpenseId(expenseSheet.getId());
                     if(happenDateCell!=null && !happenDateCell.toString().trim().equals("")){
                     if(happenDateCell!=null && !happenDateCell.toString().trim().equals("")){

+ 6 - 5
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/ExpenseItemMapper.xml

@@ -17,6 +17,7 @@
         <result column="expense_type" property="expenseType" />
         <result column="expense_type" property="expenseType" />
         <result column="pic" property="pic" />
         <result column="pic" property="pic" />
         <result column="status" property="status" />
         <result column="status" property="status" />
+        <result column="auditor_id" property="auditorId" />
     </resultMap>
     </resultMap>
     <resultMap id="UserBaseResultMap" type="com.management.platform.entity.vo.ExpenseItemVO">
     <resultMap id="UserBaseResultMap" type="com.management.platform.entity.vo.ExpenseItemVO">
         <id column="id" property="id" />
         <id column="id" property="id" />
@@ -40,15 +41,15 @@
     </resultMap>
     </resultMap>
     <!-- 通用查询结果列 -->
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
     <sql id="Base_Column_List">
-        id, expense_id, project_id, happen_date, invoice_type, invoice_no, tax_percent, tax_value, amount, remark, expense_type, pic, status
+        id, expense_id, project_id, happen_date, invoice_type, invoice_no, tax_percent, tax_value, amount, remark, expense_type, pic, status, auditor_id
     </sql>
     </sql>
     <select id="getUserExpenseDetail" resultMap="UserBaseResultMap">
     <select id="getUserExpenseDetail" resultMap="UserBaseResultMap">
         select a.id, a.expense_id, a.project_id, a.happen_date, a.invoice_type, a.tax_percent, a.tax_value, a.amount, a.remark, a.expense_type, a.pic,a.status,
         select a.id, a.expense_id, a.project_id, a.happen_date, a.invoice_type, a.tax_percent, a.tax_value, a.amount, a.remark, a.expense_type, a.pic,a.status,
-        user.name as username,user.corpwx_userid as corpwxUserId, department.department_name,department.corpwx_deptid as corpwxDeptId,department.dd_deptid as corpDdDeptId
+               user.name as username,user.corpwx_userid as corpwxUserId, department.department_name,department.corpwx_deptid as corpwxDeptId,department.dd_deptid as corpDdDeptId
         from expense_item a
         from expense_item a
-        left join expense_sheet b on a.expense_id = b.id
-        left join user on user.id = b.owner_id
-        left join department on department.department_id = user.department_id
+                 left join expense_sheet b on a.expense_id = b.id
+                 left join user on user.id = b.owner_id
+                 left join department on department.department_id = user.department_id
         where a.project_id = #{projectId}  and b.status=0  order by a.happen_date desc
         where a.project_id = #{projectId}  and b.status=0  order by a.happen_date desc
     </select>
     </select>
 
 

+ 11 - 9
fhKeeper/formulahousekeeper/timesheet/src/views/expense/expense.vue

@@ -469,7 +469,8 @@
               <template slot-scope="scope">
               <template slot-scope="scope">
                 <span v-if="scope.row.status == 1" class="waiting">{{ statusTxt[scope.row.status] }}</span>
                 <span v-if="scope.row.status == 1" class="waiting">{{ statusTxt[scope.row.status] }}</span>
                 <span v-if="scope.row.status == 2" class="rejected">{{ statusTxt[scope.row.status] }}</span>
                 <span v-if="scope.row.status == 2" class="rejected">{{ statusTxt[scope.row.status] }}</span>
-                <span v-if="scope.row.status == 0 || scope.row.status == 3">{{ statusTxt[scope.row.status] }}</span>
+                <span v-if="scope.row.status == 0" class="pass">{{ statusTxt[scope.row.status] }}</span>
+                <span v-if="scope.row.status == 3">{{ statusTxt[scope.row.status] }}</span>
                 <span v-if="scope.row.status == 4" style="color: red">{{ statusTxt[scope.row.status] }}</span>
                 <span v-if="scope.row.status == 4" style="color: red">{{ statusTxt[scope.row.status] }}</span>
               </template>
               </template>
             </el-table-column>
             </el-table-column>
@@ -661,15 +662,16 @@
             <template slot-scope="scope">
             <template slot-scope="scope">
               <span v-if="scope.row.status == 1" class="waiting">{{ statusTxt[scope.row.status] }}</span>
               <span v-if="scope.row.status == 1" class="waiting">{{ statusTxt[scope.row.status] }}</span>
               <span v-if="scope.row.status == 2" class="rejected">{{ statusTxt[scope.row.status] }}</span>
               <span v-if="scope.row.status == 2" class="rejected">{{ statusTxt[scope.row.status] }}</span>
-              <span v-if="scope.row.status == 0 || scope.row.status == 3">{{ statusTxt[scope.row.status] }}</span>
+              <span v-if="scope.row.status == 0" class="pass">{{ statusTxt[scope.row.status] }}</span>
+              <span v-if="scope.row.status == 3">{{ statusTxt[scope.row.status] }}</span>
             </template>
             </template>
           </el-table-column>
           </el-table-column>
           <el-table-column v-if="auditTypeItem.auditType == 1" width="172" :label="$t('other.reviewer')">
           <el-table-column v-if="auditTypeItem.auditType == 1" width="172" :label="$t('other.reviewer')">
             <template slot-scope="scope">
             <template slot-scope="scope">
               <span v-if="user.userNameNeedTranslate == 1">
               <span v-if="user.userNameNeedTranslate == 1">
-                <TranslationOpenDataText type='userName' :openid='scope.row.projectManagerName'></TranslationOpenDataText>
+                <TranslationOpenDataText type='userName' :openid='scope.row.auditorName'></TranslationOpenDataText>
               </span>
               </span>
-              <span v-else>{{ scope.row.projectManagerName }}</span>
+              <span v-else>{{ scope.row.auditorName }}</span>
             </template>
             </template>
           </el-table-column>
           </el-table-column>
           <el-table-column prop="projectId" :label="$t('other.project')" width="155">
           <el-table-column prop="projectId" :label="$t('other.project')" width="155">
@@ -1132,7 +1134,8 @@
               <span class="detail-item-content">
               <span class="detail-item-content">
                 <span v-if="item.status == 1" class="waiting">{{ statusTxt[item.status] }}</span>
                 <span v-if="item.status == 1" class="waiting">{{ statusTxt[item.status] }}</span>
                 <span v-if="item.status == 2" class="rejected">{{ statusTxt[item.status] }}</span>
                 <span v-if="item.status == 2" class="rejected">{{ statusTxt[item.status] }}</span>
-                <span v-if="item.status == 0 || item.status == 3">{{ statusTxt[item.status] }}</span>
+                <span v-if="item.status == 0" class="pass">{{ statusTxt[item.status] }}</span>
+                <span v-if="item.status == 3">{{ statusTxt[item.status] }}</span>
               </span>
               </span>
             </div>
             </div>
             <div class="detail-item">
             <div class="detail-item">
@@ -2466,20 +2469,16 @@ export default {
       }, 0)
       }, 0)
     },
     },
     zhi(e) {
     zhi(e) {
-      // console.log('看看值', e)
       var i = e
       var i = e
       if (this.invoiceList[i].amount == null || this.invoiceList[i].amount == 'null' || this.invoiceList[i].taxPercent == null || this.invoiceList[i].taxPercent == 'null') {
       if (this.invoiceList[i].amount == null || this.invoiceList[i].amount == 'null' || this.invoiceList[i].taxPercent == null || this.invoiceList[i].taxPercent == 'null') {
         return
         return
       }
       }
       this.invoiceList[i].taxValue = this.invoiceList[i].amount * this.invoiceList[i].taxPercent / 100
       this.invoiceList[i].taxValue = this.invoiceList[i].amount * this.invoiceList[i].taxPercent / 100
-      // console.log(this.invoiceList[i].amount, this.invoiceList[i].taxPercent)
       var shui = this.invoiceList[i].taxPercent / 100 // 税率
       var shui = this.invoiceList[i].taxPercent / 100 // 税率
       var zhi = this.invoiceList[i].amount / (1 + shui) * shui
       var zhi = this.invoiceList[i].amount / (1 + shui) * shui
       this.invoiceList[i].taxValue = zhi.toFixed(2)
       this.invoiceList[i].taxValue = zhi.toFixed(2)
     },
     },
     zhiNum(i, val) {
     zhiNum(i, val) {
-      // console.log('看看值', i, val)
-      // console.log(this.ParticularsList.invoiceList)
       if (this.ParticularsList.invoiceList[i].amount == null || this.ParticularsList.invoiceList[i].amount == 'null' || this.ParticularsList.invoiceList[i].taxPercent == null || this.ParticularsList.invoiceList[i].taxPercent == 'null') {
       if (this.ParticularsList.invoiceList[i].amount == null || this.ParticularsList.invoiceList[i].amount == 'null' || this.ParticularsList.invoiceList[i].taxPercent == null || this.ParticularsList.invoiceList[i].taxPercent == 'null') {
         return
         return
       }
       }
@@ -3151,6 +3150,9 @@ export default {
 .rejected {
 .rejected {
   color: red;
   color: red;
 }
 }
+.pass {
+  color:green;
+}
 
 
 .newInvoice {
 .newInvoice {
   position: absolute;
   position: absolute;

+ 0 - 1
fhKeeper/formulahousekeeper/timesheet/src/views/team/index.vue

@@ -3342,7 +3342,6 @@ export default {
           };
           };
           that.depTitle = this.$t('addsubdepartment');
           that.depTitle = this.$t('addsubdepartment');
         } else {
         } else {
-          console.log(that.depData, '看看值')
           if (that.depData.managerId == "null") {
           if (that.depData.managerId == "null") {
             that.depData.managerId = "";
             that.depData.managerId = "";
           }
           }