Explorar el Código

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

# Conflicts:
#	fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/UserService.java
wutt hace 5 años
padre
commit
f58d540318
Se han modificado 19 ficheros con 292 adiciones y 78 borrados
  1. 8 1
      fhKeeper/formulahousekeeper/management-platform/pom.xml
  2. 11 0
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/UserController.java
  3. 2 1
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/mapper/ScreenshotMapper.java
  4. 1 1
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/UserService.java
  5. 16 15
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ReportServiceImpl.java
  6. 7 5
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ScreenshotServiceImpl.java
  7. 0 1
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/TimeCalculationServiceImpl.java
  8. 37 6
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/UserServiceImpl.java
  9. 1 1
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/util/CheckPicUtil.java
  10. 38 32
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/util/ImageReconizeUtil.java
  11. 0 1
      fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/ReportMapper.xml
  12. 3 0
      fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/ScreenshotMapper.xml
  13. 14 0
      fhKeeper/formulahousekeeper/mywork/home.cpp
  14. 1 0
      fhKeeper/formulahousekeeper/mywork/home.h
  15. 13 8
      fhKeeper/formulahousekeeper/timesheet/src/http.js
  16. 3 1
      fhKeeper/formulahousekeeper/timesheet/src/port.js
  17. 2 3
      fhKeeper/formulahousekeeper/timesheet/src/views/desktop/index.vue
  18. 93 1
      fhKeeper/formulahousekeeper/timesheet/src/views/team/index.vue
  19. 42 1
      fhKeeper/formulahousekeeper/timesheet/src/views/workReport/daily.vue

+ 8 - 1
fhKeeper/formulahousekeeper/management-platform/pom.xml

@@ -104,7 +104,14 @@
             <artifactId>tess4j</artifactId>
         </dependency>
 
-
+        <!--手动引入opencv 否则无法maven打包-->
+        <dependency>
+            <groupId>org.opencv</groupId>
+            <artifactId>opencv</artifactId>
+            <version>4.2.0</version>
+            <scope>system</scope>
+            <systemPath>${basedir}/opencv/opencv-420.jar</systemPath>
+        </dependency>
     </dependencies>
 
 

+ 11 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/UserController.java

@@ -115,5 +115,16 @@ public class UserController {
     public HttpRespMsg importUser(@RequestParam MultipartFile file) {
         return userService.importUser(file, request);
     }
+
+
+    /**
+     * 切换权限
+     * 负责人可以将本公司的管理员切换至普通员工或者反之
+     * id 目标id
+     */
+    @RequestMapping("/switchPermission")
+    public HttpRespMsg switchPermission(@RequestParam String id) {
+        return userService.switchPermission(id, request);
+    }
 }
 

+ 2 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/mapper/ScreenshotMapper.java

@@ -18,7 +18,8 @@ import java.util.Map;
  * @since 2020-01-02
  */
 public interface ScreenshotMapper extends BaseMapper<Screenshot> {
-    List<Map<String, Object>> getLatestScreenshotList(@Param("companyId")Integer companyId);
+    List<Map<String, Object>> getLatestScreenshotList(@Param("companyId")Integer companyId,
+                                                      @Param("date")String date);
 
     HttpRespMsg saveAndProcessImage(ScreenshotVO screenshotvo);
 }

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

@@ -3,7 +3,6 @@ package com.management.platform.service;
 import com.management.platform.entity.User;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.management.platform.util.HttpRespMsg;
-import org.apache.commons.lang3.time.DateUtils;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletRequest;
@@ -35,4 +34,5 @@ public interface UserService extends IService<User> {
 
     HttpRespMsg importUser(MultipartFile multipartFile, HttpServletRequest request);
 
+    HttpRespMsg switchPermission(String id, HttpServletRequest request);
 }

+ 16 - 15
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ReportServiceImpl.java

@@ -18,6 +18,7 @@ import org.springframework.stereotype.Service;
 
 import java.io.FileOutputStream;
 import java.io.IOException;
+import java.sql.Timestamp;
 import java.text.SimpleDateFormat;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
@@ -82,10 +83,10 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
             HSSFRow headRow = sheet.createRow(0);
             //设置列宽 setColumnWidth的第二个参数要乘以256,这个参数的单位是1/256个字符宽度
             sheet.setColumnWidth(0, 5 * 256);
-            sheet.setColumnWidth(1, 18 * 256);
-            sheet.setColumnWidth(2, 18 * 256);
-            sheet.setColumnWidth(3, 18 * 256);
-            sheet.setColumnWidth(4, 30 * 256);
+            sheet.setColumnWidth(1, 10 * 256);
+            sheet.setColumnWidth(2, 20 * 256);
+            sheet.setColumnWidth(3, 10 * 256);
+            sheet.setColumnWidth(4, 50 * 256);
             sheet.setColumnWidth(5, 18 * 256);
             //设置为居中加粗
             HSSFCellStyle headStyle = workbook.createCellStyle();
@@ -123,27 +124,27 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                 row.createCell(0).setCellValue(rowNum);
                 row.createCell(1).setCellValue((String) map.get("name"));
                 row.createCell(2).setCellValue((String) map.get("project"));
-                row.createCell(3).setCellValue((String) map.get("duration"));
+                row.createCell(3).setCellValue(map.get("duration").toString());
                 row.createCell(4).setCellValue((String) map.get("content"));
                 HSSFCell cell = row.createCell(5);
-                cell.setCellValue((String) map.get("time"));
+                cell.setCellValue(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
+                        .format((Timestamp) map.get("time")));
                 cell.setCellStyle(style);
                 rowNum++;
             }
 
             //生成Excel文件
             String fileUrlSuffix = date + "日报" + new SimpleDateFormat("hh-mm-ss").format(new Date()) + ".xls";
-            try {
-                FileOutputStream fos = new FileOutputStream(path + fileUrlSuffix);
-                workbook.write(fos);
-                fos.flush();
-                fos.close();
-            } catch (Exception e) {
-                e.printStackTrace();
-            }
+            FileOutputStream fos = new FileOutputStream(path + fileUrlSuffix);
+            workbook.write(fos);
+            fos.flush();
+            fos.close();
             httpRespMsg.data = "/upload/" + fileUrlSuffix;
         } catch (NullPointerException e) {
-            httpRespMsg.setError("验证失败");
+            httpRespMsg.setError("验证失败或缺少数据");
+            return httpRespMsg;
+        } catch (IOException e) {
+            httpRespMsg.setError("文件生成错误");
             return httpRespMsg;
         }
         return httpRespMsg;

+ 7 - 5
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ScreenshotServiceImpl.java

@@ -82,7 +82,8 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
         //获取每一个人最后一张截图
         try {
             List<Map<String, Object>> resultMap = screenshotMapper
-                    .getLatestScreenshotList(userMapper.selectById(request.getHeader("Token")).getCompanyId());
+                    .getLatestScreenshotList(userMapper.selectById(request.getHeader("Token")).getCompanyId(),
+                            LocalDate.now(ZoneOffset.of("+8")).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
             for (Map<String, Object> map : resultMap) {
                 //对于每一张图 将时间戳转换为时间
                 map.put("time", new SimpleDateFormat("HH:mm:ss").format(map.get("indate")));
@@ -297,7 +298,7 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
 //        isEntertainment(new File("C://Users/seya/Desktop/1.jpg"));
         String browserName = null;
         try {
-            browserName = isBrowser(new File("C://Users/seya/Desktop/360.jpg"));
+            browserName = isBrowser(new File("C://Users/seya/Desktop/chrome.jpg"));
             System.out.println(
                     "找到浏览器==" + browserName
             );
@@ -505,15 +506,16 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
             String browserName = null;
             for (File subFolder : files) {
                 File[] targetFile = subFolder.listFiles();
-                int matchCnt = 0;
+                boolean isMatch = false;
                 for (File targetPic : targetFile) {
                     System.out.println("targetPic==" + targetPic.getAbsolutePath());
                     boolean matchPic = ImageReconizeUtil.isTemplateMatch(pic.getAbsolutePath(), targetPic.getAbsolutePath());
                     if (matchPic) {
-                        matchCnt++;
+                        isMatch = true;
+                        break;
                     }
                 }
-                if (matchCnt >= 4) {
+                if (isMatch) {
                     browserName = subFolder.getName();
                     break;
                 }

+ 0 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/TimeCalculationServiceImpl.java

@@ -13,7 +13,6 @@ import org.springframework.stereotype.Service;
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import java.time.LocalDate;
-import java.time.LocalDateTime;
 import java.time.ZoneOffset;
 import java.time.format.DateTimeFormatter;
 import java.time.format.DateTimeParseException;

+ 37 - 6
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/UserServiceImpl.java

@@ -12,10 +12,7 @@ import com.management.platform.util.MD5Util;
 import com.management.platform.util.SnowFlake;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
-import org.apache.poi.ss.usermodel.Cell;
-import org.apache.poi.ss.usermodel.Row;
-import org.apache.poi.ss.usermodel.Sheet;
-import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.ss.usermodel.*;
 import org.apache.poi.xssf.usermodel.XSSFCell;
 import org.apache.poi.xssf.usermodel.XSSFRow;
 import org.apache.poi.xssf.usermodel.XSSFSheet;
@@ -111,6 +108,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
                     .eq("company_id", userMapper.selectById(request.getHeader("Token")).getCompanyId()));
         } catch (NullPointerException e) {
             httpRespMsg.setError("验证失败");
+            return httpRespMsg;
         }
         return httpRespMsg;
     }
@@ -138,6 +136,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
             }
         } catch (NullPointerException e) {
             httpRespMsg.setError("验证失败");
+            return httpRespMsg;
         }
         return httpRespMsg;
     }
@@ -157,6 +156,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
             }
         } catch (NullPointerException e) {
             httpRespMsg.setError("验证失败");
+            return httpRespMsg;
         }
         return httpRespMsg;
     }
@@ -221,6 +221,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
             }
         } catch (NullPointerException e) {
             httpRespMsg.setError("验证失败");
+            return httpRespMsg;
         }
         return httpRespMsg;
     }
@@ -259,8 +260,12 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
                 }
                 //此处新建账号 默认密码为000000 默认 姓名第一列 手机号第二列
                 Long id = SnowFlake.nextId();
-                String name = row.getCell(0).getStringCellValue();
-                String phone = row.getCell(1).getStringCellValue();
+                XSSFCell nameCell = row.getCell(0);
+                XSSFCell phoneCell = row.getCell(1);
+                nameCell.setCellType(CellType.STRING);
+                phoneCell.setCellType(CellType.STRING);
+                String name = nameCell.getStringCellValue();
+                String phone = phoneCell.getStringCellValue();
                 phoneList.add(phone);
                 userList.add(new User()
                         .setId(id.toString())
@@ -288,6 +293,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
             httpRespMsg.setError("文件处理出错");
             return httpRespMsg;
         } catch (NullPointerException e) {
+            e.printStackTrace();
             httpRespMsg.setError("数据格式有误或存在空数据 导出失败");
             return httpRespMsg;
         } catch (Exception e) {
@@ -297,4 +303,29 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
         }
         return httpRespMsg;
     }
+
+    //切换权限状态
+    @Override
+    public HttpRespMsg switchPermission(String id, HttpServletRequest request) {
+        HttpRespMsg httpRespMsg = new HttpRespMsg();
+        try {
+            User requester = userMapper.selectById(request.getHeader("Token")),
+                    target = userMapper.selectById(id);
+            //管理员只能新增员工
+            if (requester.getRole() != 1) {
+                httpRespMsg.setError("仅负责人有权限更改其他人员权限");
+            } else if (!target.getCompanyId().equals(requester.getCompanyId())) {
+                httpRespMsg.setError("只可修改同一公司人员的权限");
+            } else if (target.getRole() == 1) {
+                httpRespMsg.setError("不可修改负责人的权限");
+            } else {
+                target.setRole(target.getRole() == 0 ? 2 : 0);
+                userMapper.updateById(target);
+            }
+        } catch (NullPointerException e) {
+            httpRespMsg.setError("缺少数据 未查询到相应人员信息");
+            return httpRespMsg;
+        }
+        return httpRespMsg;
+    }
 }

+ 1 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/util/CheckPicUtil.java

@@ -127,7 +127,7 @@ public class CheckPicUtil {
     }
 
     public static void main(String[] args) {
-//        CheckPicUtil.generalPicTextContent("D:\\360MoveData\\Users\\Administrator\\Desktop\\idea.jpg",(String)AuthService.getAuth().get("access_token"));
+        CheckPicUtil.generalPicTextContent("D:\\xlsx1.jpg",(String)AuthService.getAuth().get("accessToken"));
 
         System.out.println("m]- IntelliJ IDEA(Administrator)".contains("Intellij IDEA"));
 

+ 38 - 32
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/util/ImageReconizeUtil.java

@@ -1,7 +1,6 @@
 package com.management.platform.util;
 
 import org.opencv.core.*;
-import org.opencv.highgui.HighGui;
 import org.opencv.imgcodecs.Imgcodecs;
 import org.opencv.imgproc.Imgproc;
 
@@ -10,17 +9,24 @@ import java.io.File;
 import static java.lang.Math.E;
 
 public class ImageReconizeUtil {
-    public static final double YUZHI = Math.pow(0.1, 10);
+    public static final double YUZHI = 5*Math.pow(0.1, 11);
     static {
         System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
         //注意程序运行的时候需要在VM option添加该行 指明opencv的dll文件所在路径
         //-Djava.library.path=$PROJECT_DIR$\opencv\x64
     }
     public static void main(String[] args) {
-//        boolean match = isTemplateMatch("C:\\Users\\seya\\Desktop\\360_2.jpg",
-//                "C:\\picrecongnize\\360Safe\\2.jpg");
-        boolean match = isTemplateMatch("C:\\Users\\seya\\Desktop\\qyt_2.jpg",
-                "C:\\\\picrecongnize\\\\360Safe\\\\2.jpg");
+        boolean match = isTemplateMatch("C:\\Users\\seya\\Desktop\\loading.jpg",
+                "C:\\\\picrecongnize\\\\Chrome\\\\4-125.jpg");
+//        match = isTemplateMatch("C:\\Users\\seya\\Desktop\\chrome_gray.jpg",
+//                "C:\\\\picrecongnize\\\\Chrome\\\\4-125.jpg");
+//        match = isTemplateMatch("C:\\Users\\seya\\Desktop\\chrome_gray.jpg",
+//                "C:\\\\picrecongnize\\\\Chrome\\\\2-125.jpg");
+//        match = isTemplateMatch("C:\\Users\\seya\\Desktop\\chrome_gray.jpg",
+//                "C:\\\\picrecongnize\\\\Chrome\\\\3-125.jpg");
+
+//        boolean match = isTemplateMatch("C:\\Users\\seya\\Desktop\\chrome2.jpg",
+//                "C:\\picrecongnize\\Chrome\\bar125.jpg");
     }
 
     public static boolean isTemplateMatch(String sourcePic, String targetPic) {
@@ -52,11 +58,11 @@ public class ImageReconizeUtil {
         // 1 获取待匹配图片
         Mat templete=Imgcodecs.imread(sourcePic);
         //将rgb灰化处理
-        Imgproc.cvtColor(templete, templete,Imgproc.COLOR_BGR2GRAY);
-
+//        Imgproc.cvtColor(templete, templete,Imgproc.COLOR_BGR2GRAY);
+//
         // 2 获取匹配模板
         Mat demo=Imgcodecs.imread(targetPic);
-        Imgproc.cvtColor(demo, demo,Imgproc.COLOR_BGR2GRAY);
+//        Imgproc.cvtColor(demo, demo,Imgproc.COLOR_BGR2GRAY);
 
         Core.MinMaxLocResult mmr = getLocResult(method, templete, demo);
         // 7 绘制匹配到的结果
@@ -72,34 +78,34 @@ public class ImageReconizeUtil {
             matchVal = mmr.maxVal;
         }
         //if not match , resize the targetPic and try to match again!
-        if (Math.abs(matchVal) > YUZHI) {
-            System.out.println("第一次没匹配上, 尝试125%尺寸再次匹配~~");
-            Mat demoResize = demo.clone();
-            float scale=1.25f;
-            float widthT=demo.width();
-            float heightT=demo.height();
-            Imgproc.resize(demo, demoResize, new Size(widthT*scale,heightT*scale));
-            demo = demoResize;
-            mmr = getLocResult(method, templete, demo);
-            // 7 绘制匹配到的结果
-            matchVal = 0;
-            if (method==Imgproc.TM_SQDIFF_NORMED || method==Imgproc.TM_SQDIFF) {
-                x = mmr.minLoc.x;
-                y = mmr.minLoc.y;
-                matchVal = mmr.minVal;
-            } else {
-                x = mmr.maxLoc.x;
-                y = mmr.maxLoc.y;
-                matchVal = mmr.maxVal;
-            }
-        }
+//        if (Math.abs(matchVal) > YUZHI) {
+//            System.out.println("第一次没匹配上, 尝试125%尺寸再次匹配~~");
+//            Mat demoResize = demo.clone();
+//            float scale=1.25f;
+//            float widthT=demo.width();
+//            float heightT=demo.height();
+//            Imgproc.resize(demo, demoResize, new Size(widthT*scale,heightT*scale));
+//            demo = demoResize;
+//            mmr = getLocResult(method, templete, demo);
+//            // 7 绘制匹配到的结果
+//            matchVal = 0;
+//            if (method==Imgproc.TM_SQDIFF_NORMED || method==Imgproc.TM_SQDIFF) {
+//                x = mmr.minLoc.x;
+//                y = mmr.minLoc.y;
+//                matchVal = mmr.minVal;
+//            } else {
+//                x = mmr.maxLoc.x;
+//                y = mmr.maxLoc.y;
+//                matchVal = mmr.maxVal;
+//            }
+//        }
         System.out.println("匹配度=="+matchVal);
         System.out.println("x="+x+", y=" + y);
         Imgproc.rectangle(templete,new Point(x,y),new Point(x+demo.cols(),y+demo.rows()),new Scalar( 0, 0, 255),2,Imgproc.LINE_AA);
         Imgproc.putText(templete,"Match Success",new Point(x,y),Imgproc.FONT_HERSHEY_SCRIPT_COMPLEX, 1.0, new Scalar(0, 255, 0),1,Imgproc.LINE_AA);
 //        // 8 显示结果
-        HighGui.imshow("模板匹配", templete);
-        HighGui.waitKey(0);
+//        HighGui.imshow("模板匹配", templete);
+//        HighGui.waitKey(0);
         return matchVal;
     }
 

+ 0 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/ReportMapper.xml

@@ -28,7 +28,6 @@
         <if test="date != null and date != ''">
             AND a.create_date=#{date}
         </if>
-        AND a.creator_id=#{id}
         ORDER BY a.creator_id ASC
     </select>
 

+ 3 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/ScreenshotMapper.xml

@@ -36,6 +36,9 @@
         <if test="companyId != null and companyId != ''">
             AND c.company_id=#{companyId}
         </if>
+        <if test="date != null and date != ''">
+            AND a.date_str=#{date}
+        </if>
     </select>
 
 </mapper>

+ 14 - 0
fhKeeper/formulahousekeeper/mywork/home.cpp

@@ -235,3 +235,17 @@ Home::~Home()
 {
     delete ui;
 }
+void Home::closeEvent ( QCloseEvent * e )
+{
+    if( QMessageBox::question(this,
+                             tr("退出"),
+                             tr("Are you sure to quit this application?"),
+                              QMessageBox::Yes, QMessageBox::No )
+                   == QMessageBox::Yes){
+        e->accept();//不会将事件传递给组件的父组件
+
+        qDebug()<<"ok";
+    }
+    else
+      e->ignore();
+}

+ 1 - 0
fhKeeper/formulahousekeeper/mywork/home.h

@@ -20,6 +20,7 @@ class Home : public QMainWindow
 public:
     explicit Home(QWidget *parent = nullptr);
     ~Home();
+    void closeEvent(QCloseEvent *event);
 public slots:
     void captureScreen();
     QString getProcessList();

+ 13 - 8
fhKeeper/formulahousekeeper/timesheet/src/http.js

@@ -36,7 +36,7 @@ export default {
      * @param exception 异常的回调函数
      */
     post (url, data, response, exception) {
-        var user = sessionStorage.getItem('user') , token = "";
+        let user = sessionStorage.getItem('user') , token = "";
         if(user != null){
             token = JSON.parse(user).id
             // data.token = token
@@ -72,15 +72,17 @@ export default {
      * @param exception 异常的回调函数
      */
     get (url , response, exception) {
-        var user = sessionStorage.getItem('user') , token = "";
+        let user = sessionStorage.getItem('user') , token = "";
         if(user != null){
-            token = JSON.parse(user).headImgurl
+            token = JSON.parse(user).id
+            // data.token = token
         }
         axios({
             method: 'get',
             url: handleUrl(url),
             headers: {
-                'Content-Type': 'application/json; charset=UTF-8'
+                'Content-Type': 'application/json; charset=UTF-8',
+                'Token': token
             }
         }).then(
             (result) => {
@@ -104,10 +106,10 @@ export default {
      * @param exception 异常的回调函数
      */
     uploadFile (url, data, response, exception) {
-        var user = sessionStorage.getItem('user') , token = "";
+        let user = sessionStorage.getItem('user') , token = "";
         if(user != null){
-            token = JSON.parse(user).headImgurl
-            data.append("token", token);
+            token = JSON.parse(user).id
+            // data.token = token
         }
         axios({
             method: 'post',
@@ -115,7 +117,10 @@ export default {
             data: handleParams(data),
             dataType: 'json',
             processData: false,
-            contentType: false
+            contentType: false,
+            headers: {
+                'Token': token
+            }
         }).then(
             (result) => {
                 response(handleResults(result, data))

+ 3 - 1
fhKeeper/formulahousekeeper/timesheet/src/port.js

@@ -5,6 +5,7 @@ export default {
         delete: '/user/deleteUser', //删除用户
         insert: '/user/insertUser', //单独新增用户
         import: '/user/importUser', //批量导入用户
+        permission: '/user/switchPermission', //切换权限
     },
 
     //时间
@@ -29,6 +30,7 @@ export default {
 
     //日报
     report: {
-        list: '/report/getReportList',  //获取报告列表
+        list: '/report/getReportList', //获取报告列表
+        export: '/report/exportReport', //导出报告
     }
 }

+ 2 - 3
fhKeeper/formulahousekeeper/timesheet/src/views/desktop/index.vue

@@ -10,6 +10,7 @@
 
     <!-- 卡片列表 -->
     <div>
+      <el-col :span="24" v-if="desktopList.length == 0" style="padding: 20px">今日暂无截图</el-col>
       <el-col :span="6" v-for="(item, index) in desktopList" :key="index" class="one_div">
         <el-card :body-style="{ padding: '0px' }" shadow="hover" class="one_card">
           <div class="one_card_img">
@@ -25,9 +26,7 @@
             </div>
           </div>
           <div class="one_card_txt">
-            <!-- pic_type 这里需要一个巨长的三目运算符 -->
-            <!-- 0-编程,1-查资料,2-看文档,3-做设计,4-美工,5-运营,6-看小说,7-打游戏,8-听音乐 -->
-            <!-- 现在基本都是null -->
+            <!-- null 0-编程,1-查资料,2-看文档,3-做设计,4-美工,5-运营,6-看小说,7-打游戏,8-听音乐 后续需要重新约定 -->
             <span>{{converType(item.pic_type == null ? 0 : item.pic_type)}}</span>
             <div class="bottom clearfix">
               <el-link>

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

@@ -7,7 +7,15 @@
           <el-link type="primary" :underline="false" @click="openInsertDialog">添加人员</el-link>
         </el-form-item>
         <el-form-item style="float:right;">
-          <el-link type="primary" :underline="false">批量导入N/A</el-link>
+          <el-upload
+            ref="upload"
+            action="#"
+            :limit="1"
+            :http-request="importUser"
+            :show-file-list="false"
+          >
+            <el-link type="primary" :underline="false">批量导入</el-link>
+          </el-upload>
         </el-form-item>
       </el-form>
     </el-col>
@@ -31,6 +39,16 @@
       </el-table-column>
       <el-table-column label="操作">
         <template slot-scope="scope">
+          <el-button
+            size="small"
+            v-if="scope.row.role == 0 && user.role == 1"
+            @click="switchRole(scope.$index)"
+          >切换为管理员</el-button>
+          <el-button
+            size="small"
+            v-if="scope.row.role == 2 && user.role == 1"
+            @click="switchRole(scope.$index)"
+          >切换为员工</el-button>
           <el-button size="small" type="danger" @click="deleteUser(scope.$index)">删除</el-button>
         </template>
       </el-table-column>
@@ -174,6 +192,80 @@ export default {
       });
     },
 
+    //获取所有员工的列表
+    importUser(item) {
+      //首先判断文件类型
+      let str = item.file.name.split(".");
+      let format = str[str.length - 1];
+      if (format != "xls" && format != "xlsx") {
+        this.$message({
+          message: "请选择.xls或.xlsx文件",
+          type: "error"
+        });
+      } else {
+        this.listLoading = true;
+        let formData = new FormData();
+        formData.append("file", item.file);
+        this.http.uploadFile(
+          this.port.manage.import,
+          formData,
+          res => {
+            this.$refs.upload.clearFiles();
+            this.listLoading = false;
+            if (res.code == "ok") {
+              //重新读取列表
+              this.getUser();
+            } else {
+              this.$message({
+                message: res.msg,
+                type: "error"
+              });
+            }
+          },
+          error => {
+            this.$refs.upload.clearFiles();
+            this.listLoading = false;
+            this.$message({
+              message: error,
+              type: "error"
+            });
+          }
+        );
+      }
+    },
+
+    //切换角色 0/2
+    switchRole(index) {
+      this.listLoading = true;
+      this.http.post(
+        this.port.manage.permission,
+        { id: this.list[index].id },
+        res => {
+          this.listLoading = false;
+          if (res.code == "ok") {
+            this.$message({
+              message: "切换角色成功",
+              type: "success"
+            });
+            //重新读取列表
+            this.getUser();
+          } else {
+            this.$message({
+              message: res.msg,
+              type: "error"
+            });
+          }
+        },
+        error => {
+          this.listLoading = false;
+          this.$message({
+            message: error,
+            type: "error"
+          });
+        }
+      );
+    },
+
     //三天之内删了你 数据库都给你清了
     deleteUser(index) {
       this.$confirm(

+ 42 - 1
fhKeeper/formulahousekeeper/timesheet/src/views/workReport/daily.vue

@@ -16,7 +16,7 @@
           ></el-date-picker>
         </el-form-item>
         <el-form-item style="float:right;">
-          <el-link type="primary" :underline="false">导出日报</el-link>
+          <el-link type="primary" :underline="false" @click="exportReport">导出日报</el-link>
         </el-form-item>
         <el-form-item style="float:right;">
           <el-link type="primary" :underline="false" @click="projectDialogVisible=true">项目管理</el-link>
@@ -314,6 +314,47 @@ export default {
       );
     },
 
+    //导出日报
+    exportReport() {
+      if (this.reportList.length > 0) {
+        this.listLoading = true;
+        //首先处理日期
+        let day =
+          this.choseDay > 9
+            ? "-" + (this.choseDay + 1)
+            : "-0" + (this.choseDay + 1);
+        this.http.post(
+          this.port.report.export,
+          {
+            date: this.date + day
+          },
+          res => {
+            this.listLoading = false;
+            if (res.code == "ok") {
+              location.href = res.data;
+            } else {
+              this.$message({
+                message: res.msg,
+                type: "error"
+              });
+            }
+          },
+          error => {
+            this.listLoading = false;
+            this.$message({
+              message: error,
+              type: "error"
+            });
+          }
+        );
+      } else {
+        this.$message({
+          message: "当天没有报告 无法导出",
+          type: "info"
+        });
+      }
+    },
+
     // 获取异常列表
     getUnusual() {
       this.listLoading = true;