From f9eae6e490106aa98e00206dedf2893edf1bc322 Mon Sep 17 00:00:00 2001
From: 赵士淞 <zhaoss@yhzhg.cn>
Date: Sun, 23 Apr 2023 09:24:48 +0000
Subject: [PATCH] 营业费用(Flowable)

---
 eladmin-master/eladmin-common/src/main/java/me/zhengjie/utils/HttpUtil.java                                                   |   45 ++
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/business/service/impl/BusinessExpenseServiceFlowableImpl.java |  134 +++++++
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/business/rest/BusinessExpenseFlowableController.java          |   76 ++++
 eladmin-web-master/src/api/business/expenseFlowable.js                                                                        |   27 +
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/business/service/dto/BusinessExpenseDto.java                  |    3 
 eladmin-master/eladmin-common/src/main/java/me/zhengjie/utils/ObjectUtil.java                                                 |   48 ++
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/api/Api.java                                                  |   47 ++
 eladmin-web-master/src/views/business/expenseFlowable/approve.vue                                                             |  171 ++++++++++
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/business/service/BusinessExpenseFlowableService.java          |   56 +++
 eladmin-web-master/src/views/business/expenseFlowable/report.vue                                                              |  371 +++++++++++++++++++++
 10 files changed, 978 insertions(+), 0 deletions(-)

diff --git a/eladmin-master/eladmin-common/src/main/java/me/zhengjie/utils/HttpUtil.java b/eladmin-master/eladmin-common/src/main/java/me/zhengjie/utils/HttpUtil.java
new file mode 100644
index 0000000..ed4c862
--- /dev/null
+++ b/eladmin-master/eladmin-common/src/main/java/me/zhengjie/utils/HttpUtil.java
@@ -0,0 +1,45 @@
+package me.zhengjie.utils;
+
+import nl.basjes.shaded.org.springframework.util.ObjectUtils;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.client.RestTemplate;
+
+import java.util.Map;
+
+public class HttpUtil {
+
+    /**
+     * POST通信
+     */
+    public static <T> ResponseEntity<T> post(String url, Map body, HttpHeaders httpHeaders, Class<T> responseType){
+        return new RestTemplate().postForEntity(url, new HttpEntity<>(body, httpHeaders), responseType);
+    }
+
+    /**
+     * GET通信
+     */
+    public static <T> ResponseEntity<T> get(String url, Map<String, Object> params, HttpHeaders httpHeaders, Class<T> responseType){
+        return new RestTemplate().exchange(url + toStringParams(params), HttpMethod.GET, new HttpEntity<>(httpHeaders), responseType);
+    }
+
+    /**
+     * 通信参数字符串化
+     */
+    public static String toStringParams(Map<String, Object> params) {
+        StringBuilder stringBuilder = new StringBuilder();
+        if (!ObjectUtils.isEmpty(params)) {
+            stringBuilder.append("?");
+            for (Map.Entry entry : params.entrySet()) {
+                stringBuilder.append(entry.getKey());
+                stringBuilder.append("=");
+                stringBuilder.append(entry.getValue());
+                stringBuilder.append("&");
+            }
+        }
+        return stringBuilder.toString();
+    }
+
+}
diff --git a/eladmin-master/eladmin-common/src/main/java/me/zhengjie/utils/ObjectUtil.java b/eladmin-master/eladmin-common/src/main/java/me/zhengjie/utils/ObjectUtil.java
new file mode 100644
index 0000000..8cdff3e
--- /dev/null
+++ b/eladmin-master/eladmin-common/src/main/java/me/zhengjie/utils/ObjectUtil.java
@@ -0,0 +1,48 @@
+package me.zhengjie.utils;
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class ObjectUtil {
+
+    /**
+     * Object 转 Map
+     * @param obj
+     * @return
+     * @throws IllegalAccessException
+     */
+    public static Map<String, Object> toObjectMap(Object obj) throws IllegalAccessException {
+        Map<String, Object> map = new HashMap<String, Object>();
+        Class<?> cla = obj.getClass();
+        Field[] fields = cla.getDeclaredFields();
+        for (Field field : fields) {
+            field.setAccessible(true);
+            String keyName = field.getName();
+            Object value = field.get(obj);
+            if (value == null)
+                value = "";
+            map.put(keyName, value);
+        }
+        return map;
+    }
+
+    /**
+     * Object 转 List
+     * @param obj
+     * @return
+     */
+    public static List<Object> toObjectList(Object obj) {
+        List<Object> list = new ArrayList<Object>();
+        if (obj instanceof ArrayList<?>) {
+            for (Object o : (List<?>) obj) {
+                list.add(o);
+            }
+            return list;
+        }
+        return null;
+    }
+
+}
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/api/Api.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/api/Api.java
new file mode 100644
index 0000000..ea16c61
--- /dev/null
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/api/Api.java
@@ -0,0 +1,47 @@
+package me.zhengjie.modules.api;
+
+import com.alibaba.fastjson.JSONObject;
+import me.zhengjie.exception.BadRequestException;
+import me.zhengjie.utils.HttpUtil;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Component;
+
+import java.util.Map;
+
+@Component
+public class Api {
+
+    public Object get(String getUrl, Map<String, Object> getParams) {
+        // 发起通信
+        ResponseEntity<String> strRes = HttpUtil.get(getUrl, getParams, new HttpHeaders(), String.class);
+        // 通信结构
+        JSONObject objBody = JSONObject.parseObject(strRes.getBody());
+        // 结果集
+        return recordSet(objBody);
+    }
+
+    public Object post(String postUrl, Map<String, Object> postParams) {
+        // 发起通信
+        ResponseEntity<String> strRes = HttpUtil.post(postUrl, postParams, new HttpHeaders(), String.class);
+        // 通信结构
+        JSONObject objBody = JSONObject.parseObject(strRes.getBody());
+        // 结果集
+        return recordSet(objBody);
+
+    }
+
+    private Object recordSet(JSONObject objBody) {
+        // 判断通信错误码
+        if (objBody != null && objBody.get("msg") != null) {
+            // 错误信息
+            throw new BadRequestException(objBody.get("msg").toString());
+        } else if (objBody != null && objBody.get("result") != null) {
+            // 通信结果
+            return objBody.get("result");
+        } else {
+            // 通信结果
+            return null;
+        }
+    }
+}
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/business/rest/BusinessExpenseFlowableController.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/business/rest/BusinessExpenseFlowableController.java
new file mode 100644
index 0000000..d0e8243
--- /dev/null
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/business/rest/BusinessExpenseFlowableController.java
@@ -0,0 +1,76 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.business.rest;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.RequiredArgsConstructor;
+import me.zhengjie.annotation.Log;
+import me.zhengjie.modules.business.service.BusinessExpenseFlowableService;
+import me.zhengjie.modules.business.service.dto.BusinessExpenseDto;
+import me.zhengjie.modules.business.service.dto.BusinessExpenseQueryCriteria;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+/**
+* @website https://eladmin.vip
+* @author 赵士淞
+* @date 2023-04-13
+**/
+@RestController
+@RequiredArgsConstructor
+@Api(tags = "营业费用管理")
+@RequestMapping("/api/businessExpenseFlowable")
+public class BusinessExpenseFlowableController {
+
+    private final BusinessExpenseFlowableService businessExpenseFlowableService;
+
+    @GetMapping
+    @Log("查询营业费用(Flowable)")
+    @ApiOperation("查询营业费用(Flowable)")
+    @PreAuthorize("@el.check('businessExpense:list')")
+    public ResponseEntity<Object> queryBusinessExpense(BusinessExpenseQueryCriteria criteria) throws Exception {
+        return new ResponseEntity<>(businessExpenseFlowableService.queryAll(criteria),HttpStatus.OK);
+    }
+
+    @PostMapping
+    @Log("新增营业费用(Flowable)")
+    @ApiOperation("新增营业费用(Flowable)")
+    @PreAuthorize("@el.check('businessExpenseFlowable:add')")
+    public ResponseEntity<Object> createBusinessExpense(@Validated @RequestBody BusinessExpenseDto resources) throws Exception {
+        businessExpenseFlowableService.create(resources);
+        return new ResponseEntity<>(HttpStatus.CREATED);
+    }
+
+    @PostMapping(value = "/agree")
+    @Log("同意营业费用(Flowable)")
+    @ApiOperation("同意营业费用(Flowable)")
+    public ResponseEntity<Object> agreeBusinessExpense(@RequestBody String processInstanceId) throws Exception {
+        businessExpenseFlowableService.agree(processInstanceId);
+        return new ResponseEntity<>(HttpStatus.OK);
+    }
+
+    @PostMapping(value = "/reject")
+    @Log("拒绝营业费用(Flowable)")
+    @ApiOperation("拒绝营业费用(Flowable)")
+    public ResponseEntity<Object> rejectBusinessExpense(@RequestBody String processInstanceId) throws Exception {
+        businessExpenseFlowableService.reject(processInstanceId);
+        return new ResponseEntity<>(HttpStatus.OK);
+    }
+}
\ No newline at end of file
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/business/service/BusinessExpenseFlowableService.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/business/service/BusinessExpenseFlowableService.java
new file mode 100644
index 0000000..4b267a2
--- /dev/null
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/business/service/BusinessExpenseFlowableService.java
@@ -0,0 +1,56 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.business.service;
+
+import me.zhengjie.modules.business.service.dto.BusinessExpenseDto;
+import me.zhengjie.modules.business.service.dto.BusinessExpenseQueryCriteria;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+* @website https://eladmin.vip
+* @description 服务接口
+* @author 赵士淞
+* @date 2023-04-13
+**/
+public interface BusinessExpenseFlowableService {
+
+    /**
+     * 查询所有数据不分页
+     * @param criteria 条件参数
+     * @return List<BusinessExpenseDto>
+     */
+    Map<String, Object> queryAll(BusinessExpenseQueryCriteria criteria) throws Exception;
+
+    /**
+     * 创建
+     * @param resources /
+     */
+    void create(BusinessExpenseDto resources) throws Exception;
+
+    /**
+     * 同意
+     * @param processInstanceId /
+     */
+    void agree(String processInstanceId) throws Exception;
+
+    /**
+     * 拒绝
+     * @param processInstanceId /
+     */
+    void reject(String processInstanceId) throws Exception;
+}
\ No newline at end of file
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/business/service/dto/BusinessExpenseDto.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/business/service/dto/BusinessExpenseDto.java
index 7660597..f89a781 100644
--- a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/business/service/dto/BusinessExpenseDto.java
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/business/service/dto/BusinessExpenseDto.java
@@ -59,4 +59,7 @@
 
     /** 报销金额总计 */
     private BigDecimal amountReimbursementAmount;
+
+    /** 流程实例ID */
+    private String processInstanceId;
 }
\ No newline at end of file
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/business/service/impl/BusinessExpenseServiceFlowableImpl.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/business/service/impl/BusinessExpenseServiceFlowableImpl.java
new file mode 100644
index 0000000..63d6be9
--- /dev/null
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/business/service/impl/BusinessExpenseServiceFlowableImpl.java
@@ -0,0 +1,134 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.business.service.impl;
+
+import com.alibaba.fastjson.JSONArray;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import lombok.RequiredArgsConstructor;
+import me.zhengjie.modules.api.Api;
+import me.zhengjie.modules.business.service.BusinessExpenseFlowableService;
+import me.zhengjie.modules.business.service.BusinessPlanService;
+import me.zhengjie.modules.business.service.dto.BusinessExpenseDto;
+import me.zhengjie.modules.business.service.dto.BusinessExpenseQueryCriteria;
+import me.zhengjie.modules.business.service.dto.BusinessExpenseReimbursementDto;
+import me.zhengjie.modules.business.service.dto.BusinessPlanDto;
+import me.zhengjie.modules.project.service.ProjectService;
+import me.zhengjie.modules.project.service.dto.ProjectDto;
+import me.zhengjie.utils.HttpUtil;
+import me.zhengjie.utils.ObjectUtil;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+* @website https://eladmin.vip
+* @description 服务实现
+* @author 赵士淞
+* @date 2023-04-13
+**/
+@Service
+@RequiredArgsConstructor
+public class BusinessExpenseServiceFlowableImpl implements BusinessExpenseFlowableService {
+
+    private final Api api;
+    private final BusinessPlanService businessPlanService;
+    private final ProjectService projectService;
+
+    /**
+     * 查询
+     * @param criteria 条件参数
+     * @return
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Map<String, Object> queryAll(BusinessExpenseQueryCriteria criteria) throws Exception {
+        // 返回结果
+        Map<String, Object> returnMap = new HashMap<>();
+        // 发起通信
+        Object returnObject = api.post("http://localhost:8888/api/common/query?key=" + "businessExpenseApply", ObjectUtil.toObjectMap(criteria));
+        // 通信结果转DTO
+        List<BusinessExpenseDto> businessExpenseDtoList = ((JSONArray) returnObject).toJavaList(BusinessExpenseDto.class);
+        // 循环DTO
+        for (BusinessExpenseDto businessExpenseDto : businessExpenseDtoList) {
+            // 获取营业计划
+            BusinessPlanDto businessPlanDto = businessPlanService.findById(businessExpenseDto.getBusinessPlanId());
+            businessExpenseDto.setBusinessPlanContent(businessPlanDto.getBusinessContent());
+            // 获取项目
+            if (businessExpenseDto.getProjectId() != null) {
+                ProjectDto projectDto = projectService.findById(businessExpenseDto.getProjectId());
+                businessExpenseDto.setProjectName(projectDto.getName());
+            }
+            // 报销金额总计
+            BigDecimal amountReimbursementAmount = new BigDecimal(0);
+            // 获取营业费用明细
+            List<BusinessExpenseReimbursementDto> businessExpenseReimbursementDtoList = businessExpenseDto.getBusinessExpenseReimbursementDtoList();
+            for (BusinessExpenseReimbursementDto businessExpenseReimbursementDto : businessExpenseReimbursementDtoList) {
+                amountReimbursementAmount = amountReimbursementAmount.add(businessExpenseReimbursementDto.getReimbursementAmount());
+            }
+            businessExpenseDto.setAmountReimbursementAmount(amountReimbursementAmount);
+        }
+        // 返回结果
+        returnMap.put("content", businessExpenseDtoList);
+        returnMap.put("totalElements", businessExpenseDtoList.size());
+        return returnMap;
+    }
+
+    /**
+     * 创建
+     * @param resources /
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void create(BusinessExpenseDto resources) throws Exception {
+        // 发起通信
+        api.post("http://localhost:8888/api/common/run?key=" + "businessExpenseApply", ObjectUtil.toObjectMap(resources));
+    }
+
+    /**
+     * 同意
+     * @param processInstanceId /
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void agree(String processInstanceId) throws Exception {
+        // 参数
+        Map<String, Object> paramsMap = new HashMap<>();
+        paramsMap.put("approve", "true");
+        // 发起通信
+        api.post("http://localhost:8888/api/common/next?processInstanceId=" + processInstanceId, paramsMap);
+    }
+
+    /**
+     * 拒绝
+     * @param processInstanceId /
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void reject(String processInstanceId) throws Exception {
+        // 参数
+        Map<String, Object> paramsMap = new HashMap<>();
+        paramsMap.put("approve", "false");
+        // 发起通信
+        api.post("http://localhost:8888/api/common/next?processInstanceId=" + processInstanceId, paramsMap);
+    }
+}
\ No newline at end of file
diff --git a/eladmin-web-master/src/api/business/expenseFlowable.js b/eladmin-web-master/src/api/business/expenseFlowable.js
new file mode 100644
index 0000000..1d0f1f7
--- /dev/null
+++ b/eladmin-web-master/src/api/business/expenseFlowable.js
@@ -0,0 +1,27 @@
+import request from '@/utils/request'
+
+export function add(data) {
+  return request({
+    url: 'api/businessExpenseFlowable',
+    method: 'post',
+    data
+  })
+}
+
+export function agree(processInstanceId) {
+  return request({
+    url: 'api/businessExpenseFlowable/agree',
+    method: 'post',
+    data: processInstanceId
+  })
+}
+
+export function reject(processInstanceId) {
+  return request({
+    url: 'api/businessExpenseFlowable/reject',
+    method: 'post',
+    data: processInstanceId
+  })
+}
+
+export default { add, agree, reject }
diff --git a/eladmin-web-master/src/views/business/expenseFlowable/approve.vue b/eladmin-web-master/src/views/business/expenseFlowable/approve.vue
new file mode 100644
index 0000000..1b84c41
--- /dev/null
+++ b/eladmin-web-master/src/views/business/expenseFlowable/approve.vue
@@ -0,0 +1,171 @@
+<template>
+  <div class="app-container">
+    <!--工具栏-->
+    <div class="head-container">
+      <!--表格渲染-->
+      <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
+        <el-table-column type="selection" width="55" />
+        <el-table-column type="expand">
+          <template slot-scope="props">
+            <el-table :data="props.row.businessExpenseReimbursementDtoList" style="margin: 10px 20px 10px 105px; width: calc(100% - 20px - 105px);">
+              <el-table-column :show-overflow-tooltip="true" prop="reimbursementContent" label="报销内容" />
+              <el-table-column :show-overflow-tooltip="true" prop="reimbursementAmount" label="报销金额">
+                <template slot-scope="scope">
+                  {{ crud.toMoney(scope.row.reimbursementAmount) }}
+                </template>
+              </el-table-column>
+              <el-table-column :show-overflow-tooltip="true" prop="reimbursementVoucher" label="报销凭证">
+                <template slot-scope="scope">
+                  <el-image
+                    :src="scope.row.reimbursementVoucher != null && scope.row.reimbursementVoucher !== '' ? baseApi + scope.row.reimbursementVoucher.split(',')[0] : ''"
+                    :preview-src-list="scope.row.reimbursementVoucher != null && scope.row.reimbursementVoucher !== '' ? scope.row.reimbursementVoucher.split(',').map(item => { return baseApi + item }) : []"
+                    style="width: 100px;"
+                  >
+                    <div slot="placeholder" class="image-slot">
+                      加载中...
+                    </div>
+                    <div slot="error" class="image-slot">
+                      暂无图片
+                    </div>
+                  </el-image>
+                </template>
+              </el-table-column>
+              <el-table-column :show-overflow-tooltip="true" prop="remarks" label="备注" />
+            </el-table>
+          </template>
+        </el-table-column>
+        <el-table-column prop="expenseType" label="费用类型">
+          <template slot-scope="scope">
+            {{ dict.label[expenseType][scope.row.expenseType] }}
+          </template>
+        </el-table-column>
+        <el-table-column prop="businessPlanContent" label="所属营业计划" />
+        <el-table-column prop="projectName" label="所属项目" />
+        <el-table-column prop="amountReimbursementAmount" label="报销总金额">
+          <template slot-scope="scope">
+            {{ crud.toMoney(scope.row.amountReimbursementAmount) }}
+          </template>
+        </el-table-column>
+        <el-table-column prop="remarks" label="备注" />
+        <el-table-column prop="createTime" label="创建时间" />
+        <el-table-column v-if="checkPer(['admin','businessExpenseFlowable:agree','businessExpenseFlowable:reject'])" label="操作" width="150px" align="center">
+          <template slot-scope="scope">
+            <el-popover
+              :ref="`agree_${scope.row.processInstanceId}`"
+              v-permission="permission.agree"
+              width="200"
+              placement="top"
+            >
+              <p>您确定同意这条申请吗?</p>
+              <div style="text-align: right; margin: 0">
+                <el-button size="mini" type="text" @click="canelAgree(scope.row)">取消</el-button>
+                <el-button size="mini" type="primary" :loading="agreeLoading" @click="toAgree(scope.row)">确定</el-button>
+              </div>
+              <el-button slot="reference" size="mini" type="success" icon="el-icon-check" />
+            </el-popover>
+            <el-popover
+              :ref="`reject_${scope.row.processInstanceId}`"
+              v-permission="permission.reject"
+              width="200"
+              placement="top"
+            >
+              <p>您确定拒绝这条申请吗?</p>
+              <div style="text-align: right; margin: 0">
+                <el-button size="mini" type="text" @click="canelReject(scope.row)">取消</el-button>
+                <el-button size="mini" type="primary" :loading="rejectLoading" @click="toReject(scope.row)">确定</el-button>
+              </div>
+              <el-button slot="reference" size="mini" type="danger" icon="el-icon-close" />
+            </el-popover>
+          </template>
+        </el-table-column>
+      </el-table>
+      <!--分页组件-->
+      <pagination />
+    </div>
+  </div>
+</template>
+
+<script>
+import crudBusinessExpenseFlowable from '@/api/business/expenseFlowable'
+import CRUD, { presenter, header, crud } from '@crud/crud'
+import pagination from '@crud/Pagination'
+import constant from '../../../utils/constant'
+import { mapGetters } from 'vuex'
+
+export default {
+  name: 'BusinessExpenseFlowableApprove',
+  components: { pagination },
+  mixins: [presenter(), header(), crud()],
+  dicts: [constant.EXPENSE_TYPE],
+  cruds() {
+    return CRUD({ title: '营业费用审批', url: 'api/businessExpenseFlowable', idField: 'id', sort: 'id,desc', crudMethod: { ...crudBusinessExpenseFlowable }})
+  },
+  data() {
+    return {
+      permission: {
+        agree: ['admin', 'businessExpenseFlowable:agree'],
+        reject: ['admin', 'businessExpenseFlowable:reject']
+      },
+      // 字典:费用类型
+      expenseType: constant.EXPENSE_TYPE,
+      // 同意按钮加载状态
+      agreeLoading: false,
+      // 拒绝按钮加载状态
+      rejectLoading: false
+    }
+  },
+  computed: {
+    ...mapGetters([
+      'baseApi'
+    ])
+  },
+  methods: {
+    // 钩子:在获取表格数据之前执行,false 则代表不获取数据
+    [CRUD.HOOK.beforeRefresh]() {
+      return true
+    },
+    // 同意
+    toAgree(data) {
+      // 同意按钮加载状态
+      this.agreeLoading = true
+      // 同意
+      crudBusinessExpenseFlowable.agree(data.processInstanceId).then(res => {
+        // 关闭弹出框
+        this.$refs[`agree_${data.processInstanceId}`].showPopper = false
+        // 查询
+        this.crud.toQuery()
+      }).finally(() => {
+        // 同意按钮加载状态
+        this.agreeLoading = false
+      })
+    },
+    canelAgree(data) {
+      // 关闭弹出框
+      this.$refs[`agree_${data.processInstanceId}`].showPopper = false
+    },
+    // 拒接
+    toReject(data) {
+      // 拒绝按钮加载状态
+      this.rejectLoading = true
+      // 拒绝
+      crudBusinessExpenseFlowable.reject(data.processInstanceId).then(res => {
+        // 关闭弹出框
+        this.$refs[`reject_${data.processInstanceId}`].showPopper = false
+        // 查询
+        this.crud.toQuery()
+      }).finally(() => {
+        // 拒绝按钮加载状态
+        this.rejectLoading = false
+      })
+    },
+    canelReject(data) {
+      // 关闭弹出框
+      this.$refs[`reject_${data.processInstanceId}`].showPopper = false
+    }
+  }
+}
+</script>
+
+<style scoped>
+
+</style>
diff --git a/eladmin-web-master/src/views/business/expenseFlowable/report.vue b/eladmin-web-master/src/views/business/expenseFlowable/report.vue
new file mode 100644
index 0000000..89ff43e
--- /dev/null
+++ b/eladmin-web-master/src/views/business/expenseFlowable/report.vue
@@ -0,0 +1,371 @@
+<template>
+  <div class="app-container">
+    <!--工具栏-->
+    <div class="head-container">
+      <!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'-->
+      <crudOperation :permission="permission" />
+      <!--表单组件-->
+      <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="600px">
+        <el-form ref="form" :model="form" :rules="rules" size="small" label-width="110px">
+          <el-form-item label="费用类型" prop="expenseType">
+            <el-select v-model="form.expenseType" placeholder="请选择" filterable clearable style="width: 440px;">
+              <el-option
+                v-for="item in dict[expenseType]"
+                :key="item.id"
+                :label="item.label"
+                :value="item.value"
+              />
+            </el-select>
+          </el-form-item>
+          <el-form-item label="所属营业计划" prop="businessPlanId">
+            <el-select v-model="form.businessPlanId" placeholder="请选择" filterable clearable style="width: 440px;">
+              <el-option
+                v-for="item in businessPlanList"
+                :key="item.id"
+                :label="item.businessContent"
+                :value="item.id"
+              />
+            </el-select>
+          </el-form-item>
+          <el-form-item label="所属项目">
+            <el-select v-model="form.projectId" placeholder="请选择" filterable clearable style="width: 440px;">
+              <el-option
+                v-for="item in projectList"
+                :key="item.id"
+                :label="item.name"
+                :value="item.id"
+              />
+            </el-select>
+          </el-form-item>
+          <el-button size="mini" type="primary" icon="el-icon-plus" style="position: relative; left: 464px;" @click="reimbursementAdd()" />
+          <el-table ref="table" :data="form.businessExpenseReimbursementDtoList" size="small" style="width: 100%;">
+            <el-table-column :show-overflow-tooltip="true" prop="reimbursementContent" label="报销内容" />
+            <el-table-column :show-overflow-tooltip="true" prop="reimbursementAmount" label="报销金额">
+              <template slot-scope="scope">
+                {{ crud.toMoney(scope.row.reimbursementAmount) }}
+              </template>
+            </el-table-column>
+            <el-table-column :show-overflow-tooltip="true" prop="reimbursementVoucher" label="报销凭证">
+              <template slot-scope="scope">
+                <el-image
+                  :src="scope.row.reimbursementVoucher != null && scope.row.reimbursementVoucher !== '' ? baseApi + scope.row.reimbursementVoucher.split(',')[0] : ''"
+                  :preview-src-list="scope.row.reimbursementVoucher != null && scope.row.reimbursementVoucher !== '' ? scope.row.reimbursementVoucher.split(',').map(item => { return baseApi + item }) : []"
+                  style="width: 100px;"
+                >
+                  <div slot="placeholder" class="image-slot">
+                    加载中...
+                  </div>
+                  <div slot="error" class="image-slot">
+                    暂无图片
+                  </div>
+                </el-image>
+              </template>
+            </el-table-column>
+            <el-table-column label="操作" width="150px" align="center">
+              <template slot-scope="scope">
+                <el-button size="mini" type="primary" icon="el-icon-edit" @click="reimbursementEdit(scope.row)" />
+                <el-button size="mini" type="danger" icon="el-icon-delete" @click="reimbursementDelete(scope.row)" />
+              </template>
+            </el-table-column>
+          </el-table>
+          <el-form-item label="备注" style="margin-top: 20px;">
+            <el-input v-model="form.remarks" :rows="3" type="textarea" style="width: 440px;" />
+          </el-form-item>
+        </el-form>
+        <div slot="footer" class="dialog-footer">
+          <el-button type="text" @click="crud.cancelCU">取消</el-button>
+          <el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
+        </div>
+      </el-dialog>
+      <!--表格渲染-->
+      <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
+        <el-table-column type="selection" width="55" />
+        <el-table-column type="expand">
+          <template slot-scope="props">
+            <el-table :data="props.row.businessExpenseReimbursementDtoList" style="margin: 10px 20px 10px 105px; width: calc(100% - 20px - 105px);">
+              <el-table-column :show-overflow-tooltip="true" prop="reimbursementContent" label="报销内容" />
+              <el-table-column :show-overflow-tooltip="true" prop="reimbursementAmount" label="报销金额">
+                <template slot-scope="scope">
+                  {{ crud.toMoney(scope.row.reimbursementAmount) }}
+                </template>
+              </el-table-column>
+              <el-table-column :show-overflow-tooltip="true" prop="reimbursementVoucher" label="报销凭证">
+                <template slot-scope="scope">
+                  <el-image
+                    :src="scope.row.reimbursementVoucher != null && scope.row.reimbursementVoucher !== '' ? baseApi + scope.row.reimbursementVoucher.split(',')[0] : ''"
+                    :preview-src-list="scope.row.reimbursementVoucher != null && scope.row.reimbursementVoucher !== '' ? scope.row.reimbursementVoucher.split(',').map(item => { return baseApi + item }) : []"
+                    style="width: 100px;"
+                  >
+                    <div slot="placeholder" class="image-slot">
+                      加载中...
+                    </div>
+                    <div slot="error" class="image-slot">
+                      暂无图片
+                    </div>
+                  </el-image>
+                </template>
+              </el-table-column>
+              <el-table-column :show-overflow-tooltip="true" prop="remarks" label="备注" />
+            </el-table>
+          </template>
+        </el-table-column>
+        <el-table-column prop="expenseType" label="费用类型">
+          <template slot-scope="scope">
+            {{ dict.label[expenseType][scope.row.expenseType] }}
+          </template>
+        </el-table-column>
+        <el-table-column prop="businessPlanContent" label="所属营业计划" />
+        <el-table-column prop="projectName" label="所属项目" />
+        <el-table-column prop="amountReimbursementAmount" label="报销总金额">
+          <template slot-scope="scope">
+            {{ crud.toMoney(scope.row.amountReimbursementAmount) }}
+          </template>
+        </el-table-column>
+        <el-table-column prop="remarks" label="备注" />
+        <el-table-column prop="createTime" label="创建时间" />
+        <el-table-column label="操作" width="150px" align="center">
+          <template slot-scope="scope">
+            {{ scope.row.id }}
+          </template>
+        </el-table-column>
+      </el-table>
+      <!--分页组件-->
+      <pagination />
+      <!--表单组件-->
+      <el-dialog :close-on-click-modal="false" :before-close="reimbursementCancel" :visible.sync="reimbursementStatus" :title="reimbursementTitle" width="600px">
+        <el-form ref="reimbursementForm" :model="reimbursementForm" :rules="reimbursementRules" size="small" label-width="140px">
+          <el-form-item label="报销内容" prop="reimbursementContent">
+            <el-input v-model="reimbursementForm.reimbursementContent" style="width: 340px;" />
+          </el-form-item>
+          <el-form-item label="报销金额" prop="reimbursementAmount">
+            <money-input :key="random" v-model="reimbursementForm.reimbursementAmount" :width="340" />
+          </el-form-item>
+          <el-form-item label="报销凭证">
+            <image-upload ref="imageUpload" :key="random" :image-url="reimbursementForm.reimbursementVoucher == null || reimbursementForm.reimbursementVoucher === '' ? null : reimbursementForm.reimbursementVoucher" :limit="3" @imageInfo="getImageInfo" />
+          </el-form-item>
+          <el-form-item label="备注">
+            <el-input v-model="reimbursementForm.remarks" :rows="3" type="textarea" style="width: 340px;" />
+          </el-form-item>
+        </el-form>
+        <div slot="footer" class="dialog-footer">
+          <el-button type="text" @click="reimbursementCancel">取消</el-button>
+          <el-button :loading="reimbursementLoading" type="primary" @click="reimbursementSubmit('reimbursementForm')">确认</el-button>
+        </div>
+      </el-dialog>
+    </div>
+  </div>
+</template>
+
+<script>
+import crudBusinessExpenseFlowable from '@/api/business/expenseFlowable'
+import CRUD, { presenter, header, form, crud } from '@crud/crud'
+import crudOperation from '@crud/CRUD.operation'
+import pagination from '@crud/Pagination'
+import constant from '../../../utils/constant'
+import crudBusinessPlan from '@/api/business/plan'
+import crudProject from '@/api/project/project'
+import moneyInput from '../../assembly/moneyInput/index.vue'
+import imageUpload from '../../assembly/imageUpload/index.vue'
+import { mapGetters } from 'vuex'
+
+const defaultForm = { id: null, expenseType: null, businessPlanId: null, projectId: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null, businessExpenseReimbursementDtoList: [] }
+export default {
+  name: 'BusinessExpenseFlowableReport',
+  components: { pagination, crudOperation, moneyInput, imageUpload },
+  mixins: [presenter(), header(), form(defaultForm), crud()],
+  dicts: [constant.EXPENSE_TYPE],
+  cruds() {
+    return CRUD({ title: '营业费用', url: 'api/businessExpenseFlowable', idField: 'id', sort: 'id,desc', crudMethod: { ...crudBusinessExpenseFlowable }})
+  },
+  data() {
+    return {
+      permission: {
+        add: ['admin', 'businessExpenseFlowable:add'],
+        edit: ['admin', 'businessExpenseFlowable:edit'],
+        del: ['admin', 'businessExpenseFlowable:del'],
+        download: ['admin', 'businessExpenseFlowable:download']
+      },
+      rules: {
+        expenseType: [
+          { required: true, message: '费用类型不能为空', trigger: 'change' }
+        ],
+        businessPlanId: [
+          { required: true, message: '所属营业计划不能为空', trigger: 'change' }
+        ]
+      },
+      // 字典:费用类型
+      expenseType: constant.EXPENSE_TYPE,
+      // 随机数
+      random: 0,
+      // 营业计划列表
+      businessPlanList: [],
+      // 项目列表
+      projectList: [],
+      // 营业费用明细弹窗状态
+      reimbursementStatus: false,
+      // 营业费用明细弹窗标题
+      reimbursementTitle: '营业费用明细',
+      // 营业费用明细弹窗表单
+      reimbursementForm: {},
+      // 营业费用明细弹窗验证
+      reimbursementRules: {
+        businessExpenseId: [
+          { required: true, message: '所属营业费用不能为空', trigger: 'change' }
+        ],
+        reimbursementContent: [
+          { required: true, message: '报销内容不能为空', trigger: 'blur' },
+          { min: 2, max: 20, message: '长度在 2 到 20 个字符', trigger: 'blur' }
+        ],
+        reimbursementAmount: [
+          { required: true, message: '报销金额不能为空', trigger: 'blur' }
+        ]
+      },
+      // 营业费用明细弹窗操作
+      reimbursementExecute: {},
+      // 营业费用明细弹窗加载
+      reimbursementLoading: false
+    }
+  },
+  computed: {
+    ...mapGetters([
+      'baseApi'
+    ])
+  },
+  methods: {
+    // 钩子:在获取表格数据之前执行,false 则代表不获取数据
+    [CRUD.HOOK.beforeRefresh]() {
+      // 获取营业计划
+      this.getBusinessPlan()
+      // 获取项目
+      this.getProject()
+      return true
+    },
+    // 获取营业计划
+    getBusinessPlan() {
+      // 获取营业计划
+      crudBusinessPlan.getAll().then(res => {
+        // 营业计划列表
+        this.businessPlanList = res
+      })
+    },
+    // 获取项目
+    getProject() {
+      // 获取项目
+      crudProject.getAll().then(res => {
+        // 项目列表
+        this.projectList = res
+      })
+    },
+    // 营业费用明细弹窗新增
+    reimbursementAdd() {
+      // 指针重定义
+      const _this = this
+      // 营业费用明细弹窗表单
+      this.reimbursementForm = {}
+      // 营业费用明细弹窗状态
+      this.reimbursementStatus = true
+      // 营业费用明细弹窗操作
+      this.reimbursementExecute = {}
+      // 表单清空
+      setTimeout(function() {
+        _this.$refs['reimbursementForm'].clearValidate()
+      }, 3)
+      // 随机数
+      this.random = Math.random()
+    },
+    // 营业费用明细弹窗修改
+    reimbursementEdit(data) {
+      // 营业费用明细弹窗表单
+      this.reimbursementForm = JSON.parse(JSON.stringify(data))
+      // 营业费用明细弹窗状态
+      this.reimbursementStatus = true
+      // 营业费用明细弹窗操作
+      this.reimbursementExecute = JSON.parse(JSON.stringify(data))
+      // 随机数
+      this.random = Math.random()
+    },
+    // 营业费用明细弹窗删除
+    reimbursementDelete(data) {
+      // 筛选费用明细人员
+      const reimbursementInfo = this.crud.form.businessExpenseReimbursementDtoList.filter(function(item) {
+        return item.reimbursementContent === data.reimbursementContent && item.reimbursementAmount === data.reimbursementAmount
+      })
+      // 获取下标
+      const subscript = this.crud.form.businessExpenseReimbursementDtoList.indexOf(reimbursementInfo[0])
+      // 营业费用明细移除元素
+      this.crud.form.businessExpenseReimbursementDtoList.splice(subscript, 1)
+    },
+    // 营业费用明细弹窗关闭
+    reimbursementCancel() {
+      // 营业费用明细弹窗状态
+      this.reimbursementStatus = false
+    },
+    // 营业费用明细弹窗提交
+    reimbursementSubmit(formName) {
+      this.$refs[formName].validate((valid) => {
+        if (valid) {
+          // 通过“this.$refs.imageUpload”找到子页面,“submit”是子页面的方法。
+          this.$refs.imageUpload.submit()
+        } else {
+          return false
+        }
+      })
+    },
+    // 获取图片信息
+    getImageInfo(info) {
+      // 判断返回数据
+      if (info.length === 0) {
+        // 表单图片路径赋值
+        this.reimbursementForm.reimbursementVoucher = null
+        // 表单提交
+        this.reimbursementSubmitCU()
+        // 终止
+        return
+      }
+      // 循环返回数据
+      for (let i = 0; i < info.length; i++) {
+        // 判断循环下标
+        if (i === 0) {
+          // 表单图片路径赋值
+          this.reimbursementForm.reimbursementVoucher = info[i].response == null || info[i].response === '' ? info[i].url.substring(info[i].url.indexOf('/file/'), info[i].url.length) : '/file/' + info[i].response.type + '/' + info[i].response.realName
+        } else {
+          // 表单图片路径赋值
+          this.reimbursementForm.reimbursementVoucher += info[i].response == null || info[i].response === '' ? ',' + info[i].url.substring(info[i].url.indexOf('/file/'), info[i].url.length) : ',/file/' + info[i].response.type + '/' + info[i].response.realName
+        }
+        // 判断循环是否结束
+        if (i === info.length - 1) {
+          // 表单提交
+          this.reimbursementSubmitCU()
+        }
+      }
+    },
+    // 表单提交
+    reimbursementSubmitCU() {
+      // 判断营业费用明细弹窗操作
+      if (this.reimbursementExecute.reimbursementContent !== undefined) {
+        // 营业费用明细弹编辑
+        // 指针重定义
+        const _this = this
+        // 筛选营业费用明细弹
+        const reimbursementInfo = this.crud.form.businessExpenseReimbursementDtoList.filter(function(item) {
+          return item.reimbursementContent === _this.reimbursementExecute.reimbursementContent && item.reimbursementAmount === _this.reimbursementExecute.reimbursementAmount
+        })
+        // 营业费用明细弹更新
+        reimbursementInfo[0].reimbursementContent = this.reimbursementForm.reimbursementContent
+        reimbursementInfo[0].reimbursementAmount = this.reimbursementForm.reimbursementAmount
+        reimbursementInfo[0].reimbursementVoucher = this.reimbursementForm.reimbursementVoucher
+        reimbursementInfo[0].remarks = this.reimbursementForm.remarks
+      } else {
+        // 营业费用明细新增
+        this.crud.form.businessExpenseReimbursementDtoList.push(this.reimbursementForm)
+      }
+      // 营业费用明细弹窗关闭
+      this.reimbursementCancel()
+    }
+  }
+}
+</script>
+
+<style scoped>
+
+</style>

--
Gitblit v1.9.3