xiongzhu преди 6 години
родител
ревизия
71b281c439

+ 33 - 56
src/main/java/com/izouma/zhumj/service/CheckinInfoService.java

@@ -26,8 +26,13 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.context.ApplicationContext;
+import org.springframework.data.jpa.domain.Specification;
 import org.springframework.stereotype.Service;
 
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Predicate;
+import javax.persistence.criteria.Root;
 import javax.transaction.Transactional;
 import java.math.BigDecimal;
 import java.time.LocalDateTime;
@@ -351,63 +356,35 @@ public class CheckinInfoService {
                 .findByStoreIdAndCheckoutTrueAndCheckoutTimeBetweenOrderByCheckoutTime(storeId, start, end);
     }
 
-    public List<CheckinInfoReportDTO> getCheckinList(Long storeId, LocalDateTime start, LocalDateTime end) {
-
+    public List<CheckinInfoReportDTO> getCheckinList(Long storeId, LocalDateTime start, LocalDateTime end, Long customerId, Long contractId) {
         List<CheckinInfo> checkinInfoList = checkinInfoRepo
-                .findByStoreIdAndCheckoutFalseAndCheckinTimeBetweenOrderByCheckinTime(storeId, start, end);
-        List<MemberInfo> memberInfoList = memberRepo
-                .findAllById(checkinInfoList.stream().map(CheckinInfo::getIdNo).filter(Objects::nonNull)
-                        .collect(Collectors.toSet()));
-        List<RoomInfo> roomInfoList = roomInfoRepo.findAllById(checkinInfoList.stream()
-                .map(CheckinInfo::getRoomId).filter(Objects::nonNull).collect(Collectors.toSet()));
-        List<BedInfo> bedInfoList = bedInfoRepo.findAllById(checkinInfoList.stream()
-                .map(CheckinInfo::getBedId).filter(Objects::nonNull).collect(Collectors.toSet()));
-        List<User> userList = userRepo
-                .findAllByIdNoIn(checkinInfoList.stream().map(CheckinInfo::getIdNo).filter(Objects::nonNull)
-                        .collect(Collectors.toSet()));
-
-        List<CheckinInfoReportDTO> checkinInfoReportDTOList = new ArrayList<>();
-        for (CheckinInfo checkinInfo : checkinInfoList) {
-            BigDecimal money = memberInfoList.stream()
-                    .filter(memberInfo -> memberInfo.getIdNo().equalsIgnoreCase(checkinInfo.getIdNo()))
-                    .findAny().map(MemberInfo::getMoney).orElse(BigDecimal.ZERO);
-            String roomName = roomInfoList.stream().filter(roomInfo -> roomInfo.getId().equals(checkinInfo.getRoomId()))
-                    .findAny().map(RoomInfo::getRoomName).orElse(null);
-            String bedName = bedInfoList.stream().filter(bedInfo -> bedInfo.getId().equals(checkinInfo.getBedId()))
-                    .findAny().map(BedInfo::getBedName).orElse(null);
-            boolean hasWx = userList.stream()
-                    .anyMatch(userDTO -> userDTO.getIdNo().equalsIgnoreCase(checkinInfo.getIdNo())
-                            && userDTO.getOpenId() != null
-                            && !userDTO.isTemporal());
-            checkinInfoReportDTOList.add(CheckinInfoReportDTO.builder()
-                    .id(checkinInfo.getId())
-                    .roomName(roomName)
-                    .name(checkinInfo.getName())
-                    .idNo(checkinInfo.getIdNo())
-                    .monthRate(checkinInfo.getMonthRate())
-                    .dayRate(checkinInfo.getDayRate())
-                    .depositAmount(checkinInfo.getDepositAmount())
-                    .checkinTime(checkinInfo.getCheckinTime())
-                    .checkoutTime(checkinInfo.getCheckoutTime())
-                    .planOutTime(checkinInfo.getPlanOutTime())
-                    .remark(checkinInfo.getRemark())
-                    .address(checkinInfo.getAddress())
-                    .depositStatus(checkinInfo.getDepositStatus().getDescription())
-                    .sex(checkinInfo.getSex())
-                    .phone(checkinInfo.getPhone())
-                    .money(money)
-                    .teamName(checkinInfo.getTeamName())
-                    .bedName(bedName)
-                    .checkinType(checkinInfo.getCheckInType().getDescription())
-                    .hasWx(hasWx)
-                    .build());
-        }
-        return checkinInfoReportDTOList;
-    }
-
-    public List<CheckinInfoReportDTO> getCheckinListByStoreId(Long storeId) {
-
-        List<CheckinInfo> checkinInfoList = checkinInfoRepo.findAllByStoreIdAndCheckoutIsFalse(storeId);
+                .findAll((Specification<CheckinInfo>) (root, criteriaQuery, criteriaBuilder) -> {
+                    List<Predicate> and = new ArrayList<>();
+                    and.add(criteriaBuilder.equal(root.get("storeId"), storeId));
+                    and.add(criteriaBuilder.equal(root.get("checkout"), false));
+                    if (start != null && end != null) {
+                        and.add(criteriaBuilder.between(root.get("checkinTime"), start, end));
+                    }
+                    Set<Long> contractIds = new HashSet<>();
+                    boolean queryContractId = false;
+                    if (contractId != null) {
+                        queryContractId = true;
+                        contractIds.add(contractId);
+                    }
+                    if (customerId != null) {
+                        queryContractId = true;
+                        contractIds.addAll(contractRepo.findAllByCustomerId(customerId)
+                                .stream().map(Contract::getId).collect(Collectors.toSet()));
+                    }
+                    if (queryContractId) {
+                        if (contractIds.isEmpty()) {
+                            and.add(criteriaBuilder.disjunction());
+                        } else {
+                            and.add(root.get("orderId").in(contractIds));
+                        }
+                    }
+                    return criteriaBuilder.and(and.toArray(new Predicate[0]));
+                });
         List<MemberInfo> memberInfoList = memberRepo
                 .findAllById(checkinInfoList.stream().map(CheckinInfo::getIdNo).filter(Objects::nonNull)
                         .collect(Collectors.toSet()));

+ 22 - 27
src/main/java/com/izouma/zhumj/service/sale/ContractService.java

@@ -32,18 +32,16 @@ import org.springframework.data.jpa.domain.Specification;
 import org.springframework.stereotype.Service;
 import org.springframework.util.ObjectUtils;
 
-import javax.persistence.criteria.CriteriaBuilder;
-import javax.persistence.criteria.Path;
 import javax.persistence.criteria.Predicate;
 import javax.transaction.Transactional;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.LocalTime;
 import java.util.*;
+import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.stream.Collectors;
 
-import static com.izouma.zhumj.web.BaseController.toPageRequest;
-import static com.izouma.zhumj.web.BaseController.toSpecification;
+import static com.izouma.zhumj.web.BaseController.*;
 
 @Service
 @AllArgsConstructor
@@ -65,26 +63,8 @@ public class ContractService {
     private DepartmentService    departmentService;
 
     public Page<Contract> all(PageQuery pageQuery, Integer contractType) {
-        Specification<Contract> specification = toSpecification(pageQuery, Contract.class,
-                (search, root, criteriaQuery, criteriaBuilder) -> {
-                    // 自定义搜索
-                    String like = "%" + search + "%";
-                    List<Predicate> or = new ArrayList<>(Arrays.asList(
-                            criteriaBuilder.like(root.get("contractNumber"), like),
-                            criteriaBuilder.like(root.get("firstContractNumber"), like),
-                            criteriaBuilder.like(root.join("customer").get("customerNumber"), like),
-                            criteriaBuilder.like(root.join("customer").get("coFullName"), like),
-                            criteriaBuilder.like(root.join("customer").get("coSimpleName"), like)
-                    ));
-                    if (StringUtils.isNumeric(search)) {
-                        or.add(criteriaBuilder.equal(root.get("id"), Long.parseLong(search)));
-                        or.add(criteriaBuilder.equal(root.get("customerId"), Long.parseLong(search)));
-                    }
-                    return criteriaBuilder.or(or.toArray(new Predicate[0]));
-                });
-
-        specification = specification.and((Specification<Contract>) (root, criteriaQuery, criteriaBuilder) -> {
-            List<Predicate> predicates = new ArrayList<>();
+        return contractRepo.findAll((Specification<Contract>) (root, criteriaQuery, criteriaBuilder) -> {
+            List<Predicate> predicates = toPredicates(pageQuery, Contract.class, root, criteriaQuery, criteriaBuilder);
             if (contractType != null) {
                 switch (contractType) {
                     case 1://预定单,合同开始时间大于当前时间
@@ -135,10 +115,25 @@ public class ContractService {
                     predicates.add(criteriaBuilder.and(criteriaBuilder.equal(root.get("saleId"), saleId)));
                 }
             }
-            return criteriaBuilder.and(predicates.toArray(new Predicate[0]));
-        });
 
-        return contractRepo.findAll(specification, toPageRequest(pageQuery));
+            if (StringUtils.isNotBlank(pageQuery.getSearch())) {
+                String like = "%" + pageQuery.getSearch() + "%";
+                List<Predicate> or = new ArrayList<>(Arrays.asList(
+                        criteriaBuilder.like(root.get("contractNumber"), like),
+                        criteriaBuilder.like(root.get("firstContractNumber"), like),
+                        criteriaBuilder.like(root.join("customer").get("customerNumber"), like),
+                        criteriaBuilder.like(root.join("customer").get("coFullName"), like),
+                        criteriaBuilder.like(root.join("customer").get("coSimpleName"), like)
+                ));
+                if (StringUtils.isNumeric(pageQuery.getSearch())) {
+                    or.add(criteriaBuilder.equal(root.get("id"), Long.parseLong(pageQuery.getSearch())));
+                    or.add(criteriaBuilder
+                            .equal(root.get("customerId"), Long.parseLong(pageQuery.getSearch())));
+                }
+                predicates.add(criteriaBuilder.or(or.toArray(new Predicate[0])));
+            }
+            return criteriaBuilder.and(predicates.toArray(new Predicate[0]));
+        }, toPageRequest(pageQuery));
     }
 
     @Transactional(rollbackOn = {Exception.class})

+ 109 - 103
src/main/java/com/izouma/zhumj/web/BaseController.java

@@ -48,114 +48,13 @@ public class BaseController {
         return pageRequest;
     }
 
-    public static <T> Specification<T> toSpecification(PageQuery pageQuery, Class queryClass) {
+    public static <T> Specification<T> toSpecification(PageQuery pageQuery, Class<T> queryClass) {
         return toSpecification(pageQuery, queryClass, null);
     }
 
     public static <T> Specification<T> toSpecification(PageQuery pageQuery, Class<T> queryClass, BaseController.CustomSearch<T> customSearch) {
         return (Specification<T>) (root, criteriaQuery, criteriaBuilder) -> {
-            List<Predicate> and = new ArrayList<>();
-            pageQuery.getQuery().forEach((property, value) -> {
-                if (value == null) {
-                    return;
-                }
-                if (String.class.equals(value.getClass())) {
-                    if (StringUtils.isEmpty((String) value)) {
-                        return;
-                    }
-                    if ("true".equals(value) || "false".equals(value)) {
-                        and.add(criteriaBuilder
-                                .and(criteriaBuilder.equal(root.get(property), Boolean.valueOf((String) value))));
-                        return;
-                    }
-                }
-                if (property.equals("createdAt") && !StringUtils.isEmpty(value.toString())) {
-                    DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
-                    and.add(criteriaBuilder.between(root.get(property), LocalDateTime
-                            .parse(value.toString().split(",")[0], df), LocalDateTime
-                            .parse(value.toString().split(",")[1], df)));
-                } else {
-                    try {
-                        Field field = queryClass.getDeclaredField(property);
-                        Class fieldType = field.getType();
-                        if (Enum.class.isAssignableFrom(fieldType)) {
-                            if (value instanceof Collection) {
-                                if (!((Collection) value).isEmpty()) {
-                                    List list = new ArrayList();
-                                    for (Object o : ((Collection) value)) {
-                                        list.add(Enum.valueOf(fieldType, String.valueOf(o)));
-                                    }
-                                    and.add(root.get(property).in(list));
-                                }
-                            } else if (value instanceof String && StringUtils.isNotEmpty((String) value)) {
-                                if (((String) value).contains(",")) {
-                                    String[] arr = ((String) value).split(",");
-                                    List list = new ArrayList();
-                                    for (String s : arr) {
-                                        list.add(Enum.valueOf(fieldType, s));
-                                    }
-                                    and.add(root.get(property).in(list));
-                                } else {
-                                    and.add(criteriaBuilder.and(criteriaBuilder
-                                            .equal(root.get(property), Enum
-                                                    .valueOf(fieldType, String.valueOf(value)))));
-                                }
-                            }
-                        } else if (LocalDateTime.class == fieldType) {
-                            if (value instanceof List) {
-                                List list = (List) value;
-                                if (list.size() == 1) {
-                                    LocalDateTime start = DateTimeUtils
-                                            .toLocalDateTime((String) list.get(0), "yyyy-MM-dd HH:mm:ss");
-                                    and.add(criteriaBuilder.greaterThanOrEqualTo(root.get(property), start));
-                                } else if (list.size() == 2) {
-                                    LocalDateTime end = DateTimeUtils
-                                            .toLocalDateTime((String) list.get(1), "yyyy-MM-dd HH:mm:ss");
-                                    and.add(criteriaBuilder.lessThanOrEqualTo(root.get(property), end));
-                                }
-                            } else if (value instanceof String && Pattern
-                                    .matches("^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2},\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}$", (String) value)) {
-                                String[] arr = ((String) value).split(",");
-                                LocalDateTime start = DateTimeUtils.toLocalDateTime(arr[0], "yyyy-MM-dd HH:mm:ss");
-                                and.add(criteriaBuilder.greaterThanOrEqualTo(root.get(property), start));
-                                LocalDateTime end = DateTimeUtils.toLocalDateTime(arr[1], "yyyy-MM-dd HH:mm:ss");
-                                and.add(criteriaBuilder.lessThanOrEqualTo(root.get(property), end));
-                            } else {
-                                and.add(criteriaBuilder.and(criteriaBuilder.equal(root.get(property), DateTimeUtils
-                                        .toLocalDateTime((String) value, "yyyy-MM-dd HH:mm:ss"))));
-                            }
-                        } else if (LocalDate.class == fieldType) {
-                            if (value instanceof List) {
-                                List list = (List) value;
-                                if (list.size() == 1) {
-                                    LocalDate start = DateTimeUtils
-                                            .toLocalDate((String) list.get(0), "yyyy-MM-dd");
-                                    and.add(criteriaBuilder.greaterThanOrEqualTo(root.get(property), start));
-                                } else if (list.size() == 2) {
-                                    LocalDate end = DateTimeUtils
-                                            .toLocalDate((String) list.get(1), "yyyy-MM-dd");
-                                    and.add(criteriaBuilder.lessThanOrEqualTo(root.get(property), end));
-                                }
-                            } else if (value instanceof String && Pattern
-                                    .matches("^\\d{4}-\\d{2}-\\d{2},\\d{4}-\\d{2}-\\d{2}$", (String) value)) {
-                                String[] arr = ((String) value).split(",");
-                                LocalDate start = DateTimeUtils.toLocalDate(arr[0], "yyyy-MM-dd");
-                                and.add(criteriaBuilder.greaterThanOrEqualTo(root.get(property), start));
-                                LocalDate end = DateTimeUtils.toLocalDate(arr[1], "yyyy-MM-dd");
-                                and.add(criteriaBuilder.lessThanOrEqualTo(root.get(property), end));
-                            } else {
-                                and.add(criteriaBuilder.and(criteriaBuilder.equal(root.get(property), DateTimeUtils
-                                        .toLocalDateTime((String) value, "yyyy-MM-dd"))));
-                            }
-                        } else {
-                            and.add(criteriaBuilder.and(criteriaBuilder.equal(root.get(property), value)));
-                        }
-                    } catch (Exception e) {
-                        e.printStackTrace();
-                    }
-
-                }
-            });
+            List<Predicate> and = toPredicates(pageQuery, queryClass, root, criteriaQuery, criteriaBuilder);
             if (StringUtils.isNotEmpty(pageQuery.getSearch())) {
                 if (customSearch != null) {
                     and.add(customSearch.toPredicate(pageQuery.getSearch(), root, criteriaQuery, criteriaBuilder));
@@ -183,4 +82,111 @@ public class BaseController {
             return criteriaBuilder.and(and.toArray(new Predicate[0]));
         };
     }
+
+    public static <T> List<Predicate> toPredicates(PageQuery pageQuery, Class<T> queryClass, Root<T> root,
+                                                   CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
+        List<Predicate> and = new ArrayList<>();
+        pageQuery.getQuery().forEach((property, value) -> {
+            if (value == null) {
+                return;
+            }
+            if (String.class.equals(value.getClass())) {
+                if (StringUtils.isEmpty((String) value)) {
+                    return;
+                }
+                if ("true".equals(value) || "false".equals(value)) {
+                    and.add(criteriaBuilder
+                            .and(criteriaBuilder.equal(root.get(property), Boolean.valueOf((String) value))));
+                    return;
+                }
+            }
+            if (property.equals("createdAt") && !StringUtils.isEmpty(value.toString())) {
+                DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+                and.add(criteriaBuilder.between(root.get(property), LocalDateTime
+                        .parse(value.toString().split(",")[0], df), LocalDateTime
+                        .parse(value.toString().split(",")[1], df)));
+            } else {
+                try {
+                    Field field = queryClass.getDeclaredField(property);
+                    Class fieldType = field.getType();
+                    if (Enum.class.isAssignableFrom(fieldType)) {
+                        if (value instanceof Collection) {
+                            if (!((Collection) value).isEmpty()) {
+                                List list = new ArrayList();
+                                for (Object o : ((Collection) value)) {
+                                    list.add(Enum.valueOf(fieldType, String.valueOf(o)));
+                                }
+                                and.add(root.get(property).in(list));
+                            }
+                        } else if (value instanceof String && StringUtils.isNotEmpty((String) value)) {
+                            if (((String) value).contains(",")) {
+                                String[] arr = ((String) value).split(",");
+                                List list = new ArrayList();
+                                for (String s : arr) {
+                                    list.add(Enum.valueOf(fieldType, s));
+                                }
+                                and.add(root.get(property).in(list));
+                            } else {
+                                and.add(criteriaBuilder.and(criteriaBuilder
+                                        .equal(root.get(property), Enum
+                                                .valueOf(fieldType, String.valueOf(value)))));
+                            }
+                        }
+                    } else if (LocalDateTime.class == fieldType) {
+                        if (value instanceof List) {
+                            List list = (List) value;
+                            if (list.size() == 1) {
+                                LocalDateTime start = DateTimeUtils
+                                        .toLocalDateTime((String) list.get(0), "yyyy-MM-dd HH:mm:ss");
+                                and.add(criteriaBuilder.greaterThanOrEqualTo(root.get(property), start));
+                            } else if (list.size() == 2) {
+                                LocalDateTime end = DateTimeUtils
+                                        .toLocalDateTime((String) list.get(1), "yyyy-MM-dd HH:mm:ss");
+                                and.add(criteriaBuilder.lessThanOrEqualTo(root.get(property), end));
+                            }
+                        } else if (value instanceof String && Pattern
+                                .matches("^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2},\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}$", (String) value)) {
+                            String[] arr = ((String) value).split(",");
+                            LocalDateTime start = DateTimeUtils.toLocalDateTime(arr[0], "yyyy-MM-dd HH:mm:ss");
+                            and.add(criteriaBuilder.greaterThanOrEqualTo(root.get(property), start));
+                            LocalDateTime end = DateTimeUtils.toLocalDateTime(arr[1], "yyyy-MM-dd HH:mm:ss");
+                            and.add(criteriaBuilder.lessThanOrEqualTo(root.get(property), end));
+                        } else {
+                            and.add(criteriaBuilder.and(criteriaBuilder.equal(root.get(property), DateTimeUtils
+                                    .toLocalDateTime((String) value, "yyyy-MM-dd HH:mm:ss"))));
+                        }
+                    } else if (LocalDate.class == fieldType) {
+                        if (value instanceof List) {
+                            List list = (List) value;
+                            if (list.size() == 1) {
+                                LocalDate start = DateTimeUtils
+                                        .toLocalDate((String) list.get(0), "yyyy-MM-dd");
+                                and.add(criteriaBuilder.greaterThanOrEqualTo(root.get(property), start));
+                            } else if (list.size() == 2) {
+                                LocalDate end = DateTimeUtils
+                                        .toLocalDate((String) list.get(1), "yyyy-MM-dd");
+                                and.add(criteriaBuilder.lessThanOrEqualTo(root.get(property), end));
+                            }
+                        } else if (value instanceof String && Pattern
+                                .matches("^\\d{4}-\\d{2}-\\d{2},\\d{4}-\\d{2}-\\d{2}$", (String) value)) {
+                            String[] arr = ((String) value).split(",");
+                            LocalDate start = DateTimeUtils.toLocalDate(arr[0], "yyyy-MM-dd");
+                            and.add(criteriaBuilder.greaterThanOrEqualTo(root.get(property), start));
+                            LocalDate end = DateTimeUtils.toLocalDate(arr[1], "yyyy-MM-dd");
+                            and.add(criteriaBuilder.lessThanOrEqualTo(root.get(property), end));
+                        } else {
+                            and.add(criteriaBuilder.and(criteriaBuilder.equal(root.get(property), DateTimeUtils
+                                    .toLocalDateTime((String) value, "yyyy-MM-dd"))));
+                        }
+                    } else {
+                        and.add(criteriaBuilder.and(criteriaBuilder.equal(root.get(property), value)));
+                    }
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+
+            }
+        });
+        return and;
+    }
 }

+ 11 - 9
src/main/java/com/izouma/zhumj/web/CheckinInfoController.java

@@ -87,19 +87,21 @@ public class CheckinInfoController extends BaseController {
     }
 
     @GetMapping("/checkinList")
-    public List<CheckinInfoReportDTO> checkinList(@RequestParam Long storeId, @RequestParam(required = false) LocalDateTime start, @RequestParam(required = false) LocalDateTime end) {
-        if(start!=null && end !=null){
-            return checkinInfoService.getCheckinList(storeId, start, end);
-        }
-        else {
-            return  checkinInfoService.getCheckinListByStoreId(storeId);
-        }
+    public List<CheckinInfoReportDTO> checkinList(
+            @RequestParam Long storeId, @RequestParam(required = false) LocalDateTime start,
+            @RequestParam(required = false) LocalDateTime end, @RequestParam(required = false) Long customerId,
+            @RequestParam(required = false) Long contractId) {
+        return checkinInfoService.getCheckinList(storeId, start, end, customerId, contractId);
     }
 
     @GetMapping("/excelCheckinInfoListReport")
     @ResponseBody
-    public void excelCheckinInfoListReport(HttpServletResponse response, @RequestParam Long storeId, @RequestParam LocalDateTime start, @RequestParam LocalDateTime end) throws IOException {
-        ExcelUtils.export(response, checkinList(storeId, start, end), CheckinInfoReportDTO.class);
+    public void excelCheckinInfoListReport(
+            HttpServletResponse response, @RequestParam Long storeId, @RequestParam(required = false) LocalDateTime start,
+            @RequestParam(required = false) LocalDateTime end, @RequestParam(required = false) Long customerId,
+            @RequestParam(required = false) Long contractId) throws IOException {
+        ExcelUtils.export(response, checkinList(storeId, start, end, customerId, contractId),
+                CheckinInfoReportDTO.class);
     }
 
     @GetMapping("/excelCheckoutInfoListReport")

+ 75 - 2
src/main/vue/src/views/CheckinInfoReport.vue

@@ -12,6 +12,39 @@
                 class="filter-item"
             >
             </el-date-picker>
+            <el-select
+                v-model="customerId"
+                filterable
+                remote
+                reserve-keyword
+                clearable
+                placeholder="筛选团队"
+                :remote-method="searchCustomer"
+                :loading="searchingCustomer"
+                class="filter-item"
+            >
+                <el-option
+                    v-for="(item, index) in customerOptions"
+                    :key="index"
+                    :label="item.coSimpleName + '(' + item.coFullName + ')'"
+                    :value="item.id"
+                >
+                </el-option>
+            </el-select>
+            <el-select
+                v-model="contractId"
+                filterable
+                remote
+                reserve-keyword
+                clearable
+                placeholder="筛选合同"
+                :remote-method="searchContract"
+                :loading="searchingContract"
+                class="filter-item"
+            >
+                <el-option v-for="item in contractOptions" :key="item.id" :label="item.contractNumber" :value="item.id">
+                </el-option>
+            </el-select>
             <el-button type="primary" @click="getData" class="filter-item" :loading="loading">查询 </el-button>
             <el-button
                 @click="download"
@@ -110,12 +143,22 @@ export default {
                 ]
             },
             downloading: false,
-            loading: false
+            loading: false,
+            customerOptions: [],
+            searchingCustomer: false,
+            customerId: null,
+            contractOptions: null,
+            searchingContract: false,
+            contractId: null
         };
     },
     computed: {
         ...mapState(['selectedStoreId'])
     },
+    created() {
+        this.searchCustomer();
+        this.searchContract();
+    },
     methods: {
         beforeOnCreate() {
             // const date = new Date();
@@ -126,7 +169,9 @@ export default {
         },
         getData() {
             var data = {
-                storeId: this.selectedStoreId
+                storeId: this.selectedStoreId,
+                customerId: this.customerId,
+                contractId: this.contractId
             };
             if (this.dateRange.length === 2) {
                 data.start = this.dateRange[0];
@@ -172,6 +217,34 @@ export default {
                     this.downloading = false;
                     this.$message.error(e.error);
                 });
+        },
+        searchCustomer(query) {
+            if (this.searchingCustomer) return;
+            this.searchingCustomer = true;
+            this.$http
+                .get(`/customer/all`, { search: query })
+                .then(res => {
+                    this.searchingCustomer = false;
+                    this.customerOptions = res.content;
+                })
+                .catch(e => {
+                    this.searchingCustomer = false;
+                    this.$message.error(e.error);
+                });
+        },
+        searchContract(query) {
+            if (this.searchingContract) return;
+            this.searchingContract = true;
+            this.$http
+                .get(`/contract/all`, { search: query, storeId: this.selectedStoreId })
+                .then(res => {
+                    this.searchingContract = false;
+                    this.contractOptions = res.content;
+                })
+                .catch(e => {
+                    this.searchingContract = false;
+                    this.$message.error(e.error);
+                });
         }
     },
     watch: {