ソースを参照

Merge branch 'master' of http://47.100.37.243:10191/wutt/manHourHousekeeper

zx 1 年間 前
コミット
0545b25b88

+ 5 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/CustomerInfoController.java

@@ -182,5 +182,10 @@ public class CustomerInfoController {
         return customerInfoService.importData(request,file);
     }
 
+    @RequestMapping("/exportData")
+    public HttpRespMsg exportData(){
+        return customerInfoService.exportData(request);
+    }
+
 }
 

+ 2 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/CustomerInfoService.java

@@ -18,4 +18,6 @@ import javax.servlet.http.HttpServletRequest;
 public interface CustomerInfoService extends IService<CustomerInfo> {
 
     HttpRespMsg importData(HttpServletRequest request, MultipartFile file);
+
+    HttpRespMsg exportData(HttpServletRequest request);
 }

+ 43 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/CustomerInfoServiceImpl.java

@@ -3,15 +3,20 @@ package com.management.platform.service.impl;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.management.platform.entity.CustomerInfo;
+import com.management.platform.entity.User;
+import com.management.platform.entity.WxCorpInfo;
 import com.management.platform.mapper.CustomerInfoMapper;
 import com.management.platform.mapper.UserMapper;
+import com.management.platform.mapper.WxCorpInfoMapper;
 import com.management.platform.service.CustomerInfoService;
+import com.management.platform.service.ExcelExportService;
 import com.management.platform.util.ExcelUtil;
 import com.management.platform.util.HttpRespMsg;
 import com.management.platform.util.MessageUtils;
 import org.apache.poi.EncryptedDocumentException;
 import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
 import org.apache.poi.ss.usermodel.*;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.util.StringUtils;
 import org.springframework.web.multipart.MultipartFile;
@@ -39,6 +44,44 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
     CustomerInfoMapper customerInfoMapper;
     @Resource
     UserMapper userMapper;
+    @Resource
+    ExcelExportService excelExportService;
+    @Resource
+    WxCorpInfoMapper wxCorpInfoMapper;
+    @Value(value = "${upload.path}")
+    private String path;
+
+    @Override
+    public HttpRespMsg exportData(HttpServletRequest request) {
+        HttpRespMsg msg=new HttpRespMsg();
+        User user = userMapper.selectById(request.getHeader("token"));
+        List<CustomerInfo> customerInfos = customerInfoMapper.selectList(new QueryWrapper<CustomerInfo>().eq("company_id", user.getCompanyId()));
+        WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
+        List<List<String>> dataList=new ArrayList<>();
+        List<String> titleList=new ArrayList<>();
+        titleList.add("客户编号");
+        titleList.add("客户名称");
+        titleList.add("联系人");
+        titleList.add("联系电话");
+        titleList.add("邮箱");
+        titleList.add("地址");
+        dataList.add(titleList);
+        for (CustomerInfo customerInfo : customerInfos) {
+            List<String> item=new ArrayList<>();
+            item.add(customerInfo.getCustomerCode()==null?"":customerInfo.getCustomerCode());
+            item.add(customerInfo.getCustomerName());
+            item.add(customerInfo.getContactName()==null?"":customerInfo.getContactName());
+            item.add(customerInfo.getContactPhone()==null?"":customerInfo.getContactPhone());
+            item.add(customerInfo.getEmail()==null?"":customerInfo.getEmail());
+            item.add(customerInfo.getAddress()==null?"":customerInfo.getAddress());
+            dataList.add(item);
+        }
+        String fileName = "客户管理列表"+System.currentTimeMillis();
+        String resp = ExcelUtil.exportGeneralExcelByTitleAndList(fileName, dataList, path);
+        msg.setData(resp);
+        return msg;
+    }
+
     @Override
     public HttpRespMsg importData(HttpServletRequest request, MultipartFile multipartFile) {
         HttpRespMsg msg=new HttpRespMsg();

+ 25 - 0
fhKeeper/formulahousekeeper/timesheet/src/views/customer/list.vue

@@ -16,6 +16,7 @@
                 <el-form-item style="float:right;">
                     <el-link type="primary" :underline="false" @click="handleAdd(-1,null)">{{ $t('newcustomer') }}</el-link>
                     <el-link type="primary" :underline="false" @click="intocustomerRatio">{{ $t('importingCustomersinBatches') }}</el-link>
+                    <el-link type="primary" :underline="false" @click="exportData()">{{'导出'}}</el-link>
                 </el-form-item>
             </el-form>
         </el-col>
@@ -575,6 +576,30 @@
                 })
                 .catch(() => {});
             },
+            exportData(){
+                this.http.post('/customer-info/exportData', {},
+                res => {
+                    if (res.code == "ok") {
+                        var filePath = res.data;
+                        const a = document.createElement('a'); // 创建a标签
+                        a.setAttribute('download', '客户列表.xlsx');// download属性
+                        a.setAttribute('href', filePath);// href链接
+                        a.click(); //自执行点击事件
+                        a.remove();
+                    } else {
+                        this.$message({
+                        message: res.msg,
+                        type: "error"
+                        });
+                    }
+                },
+                error => {
+                    this.$message({
+                        message: error,
+                        type: "error"
+                    });
+                });
+            },
         },
         created() {
             let height = window.innerHeight;