zwq 2 rokov pred
rodič
commit
4f31a11365

+ 72 - 0
nngkxxdp/src/main/java/com/example/nngkxxdp/controller/CanteenController.java

@@ -0,0 +1,72 @@
+package com.example.nngkxxdp.controller;
+
+import com.example.nngkxxdp.entity.CanteenDO;
+import com.example.nngkxxdp.service.CanteenService;
+import com.example.nngkxxdp.util.Blank;
+import com.example.nngkxxdp.util.ConstStr;
+import com.example.nngkxxdp.util.SendUtil;
+import lombok.AllArgsConstructor;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.IOException;
+import java.util.Map;
+
+/**
+ * 食堂表(SCanteen)表控制层
+ *
+ * @author zwq
+ * @since 2022-08-31 11:51:04
+ */
+@RestController
+@AllArgsConstructor
+@RequestMapping("canteen")
+public class CanteenController {
+
+    private final CanteenService canteenService;
+
+    @GetMapping("/page")
+    public Map<String,Object> page(Integer page, Integer limit, String canteenName) {
+        if (Blank.isEmpty(page, limit)) {
+            return SendUtil.send(false, ConstStr.REQUEST_WRONGPARAMS);
+        }
+        return canteenService.page(page, limit, canteenName);
+    }
+    
+    @PostMapping("/add")
+    public Map<String,Object> add(String canteenName, Integer founder, String supplyTimeId, MultipartFile[] files) throws IOException {
+        if (Blank.isEmpty(canteenName, founder)) {
+            return SendUtil.send(false, ConstStr.REQUEST_WRONGPARAMS);
+        }
+        if (canteenName.length() > 64) {
+            return SendUtil.send(false, ConstStr.REQUEST_WRONGPARAMS, "名称最长为64字符");
+        }
+        CanteenDO canteenDO = new CanteenDO();
+        canteenDO.setCanteenName(canteenName);
+        canteenDO.setFounder(founder);
+        canteenDO.setSupplyTimeId(supplyTimeId);
+        return canteenService.add(canteenDO, files);
+    }
+    
+    @PostMapping("/update")
+    public Map<String,Object> update(String id, String canteenName, String supplyTimeId, String canteenPhotoPath, MultipartFile[] files) throws IOException {
+        if (Blank.isEmpty(id, canteenName)) {
+            return SendUtil.send(false, ConstStr.REQUEST_WRONGPARAMS);
+        }
+        if (canteenName.length() > 64) {
+            return SendUtil.send(false, ConstStr.REQUEST_WRONGPARAMS, "名称最长为64字符");
+        }
+        CanteenDO canteenDO = new CanteenDO();
+        canteenDO.setId(id);
+        canteenDO.setCanteenName(canteenName);
+        canteenDO.setCanteenPhotoPath(canteenPhotoPath);
+        canteenDO.setSupplyTimeId(supplyTimeId);
+        return canteenService.update(canteenDO, files);
+    }
+    
+    @PostMapping("/delete")
+    public Map<String,Object> delete(String id) {
+        return canteenService.deleteById(id);
+    }
+
+}

+ 5 - 0
nngkxxdp/src/main/java/com/example/nngkxxdp/controller/SupplyTimeController.java

@@ -67,4 +67,9 @@ public class SupplyTimeController {
         return supplyTimeService.deleteById(id);
     }
 
+    @GetMapping("/list")
+    public Map<String,Object> deleteSupplyTimeById(Integer timeNode) {
+        return supplyTimeService.listByNode(timeNode);
+    }
+
 }

+ 75 - 0
nngkxxdp/src/main/java/com/example/nngkxxdp/dao/CanteenDao.java

@@ -0,0 +1,75 @@
+package com.example.nngkxxdp.dao;
+
+import com.example.nngkxxdp.entity.CanteenDO;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 食堂表(SCanteen)DAO
+ *
+ * @author zwq
+ * @date 2022/08/31 11:51
+ */
+@Repository
+public interface CanteenDao {
+
+    /**
+     * description: 查询单个
+     * @author zwq
+     * @date 2022/8/31 16:03
+     * @param id ID
+     * @return com.example.nngkxxdp.entity.SCanteenDO
+     */
+    CanteenDO queryById(@Param("id") String id);
+
+    /**
+     * description: 分页计数
+     * @author zwq
+     * @date 2022/8/31 16:03
+     * @param canteenName 食堂名称
+     * @return long 计数
+     */
+    long pageCount(@Param("canteenName") String canteenName);
+
+    /**
+     * description: 分页列表
+     * @author zwq
+     * @date 2022/8/31 16:04
+     * @param startRows 分页参数
+     * @param limit 分页参数
+     * @param canteenName 食堂名称
+     * @return java.util.Map 数据
+     */
+    List<Map<String, Object>> pageList(Integer startRows, Integer limit, @Param("canteenName") String canteenName);
+
+    /**
+     * description: 新增
+     * @author zwq
+     * @date 2022/8/31 16:04
+     * @param canteenDO 数据
+     * @return java.lang.Integer
+     */
+    Integer addSCanteen(CanteenDO canteenDO);
+
+    /**
+     * description: 修改
+     * @author zwq
+     * @date 2022/8/31 16:04
+     * @param canteenDO 数据
+     * @return java.lang.Integer
+     */
+    Integer updateSCanteen(CanteenDO canteenDO);
+
+    /**
+     * description: 删除
+     * @author zwq
+     * @date 2022/8/31 16:05
+     * @param id ID
+     * @return java.lang.Integer
+     */
+    Integer deleteSCanteenById(@Param("id") String id);
+
+}

+ 9 - 0
nngkxxdp/src/main/java/com/example/nngkxxdp/dao/SupplyTimeDao.java

@@ -47,6 +47,15 @@ public interface SupplyTimeDao {
     List<Map<String, Object>> pageList(Integer startRows, Integer limit, @Param("timeNode") Integer timeNode);
 
     /**
+     * description: 列表
+     * @author zwq
+     * @date 2022/9/1 15:26
+     * @param timeNode 时间节点
+     * @return java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
+     */
+    List<Map<String, Object>> listByNode(Integer timeNode);
+
+    /**
      * description: 新增
      * @author zwq
      * @date 2022/8/31 17:10

+ 59 - 0
nngkxxdp/src/main/java/com/example/nngkxxdp/entity/CanteenDO.java

@@ -0,0 +1,59 @@
+package com.example.nngkxxdp.entity;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 食堂表(SCanteen)实体类
+ *
+ * @author zwq
+ * @date 2022/08/31 11:51
+ */
+@Data
+public class CanteenDO implements Serializable {
+
+    private static final long serialVersionUID = -20050883709036677L;
+    
+    /**
+    * 食堂id
+    */
+    private String id;
+    
+    /**
+    * 食堂名称
+    */
+    private String canteenName;
+    
+    /**
+    * 食堂照片
+    */
+    private String canteenPhotoPath;
+    
+    /**
+    * 供应时间id
+    */
+    private String supplyTimeId;
+    
+    /**
+    * 创建人id
+    */
+    private Integer founder;
+    
+    /**
+    * 创建时间
+    */
+    private Date createTime;
+    
+    /**
+    * 更新时间
+    */
+    private Date updateTime;
+    
+    /**
+    * 是否删除0:未删除 1:删除
+    */
+    private Integer isdel;
+    
+}

+ 65 - 0
nngkxxdp/src/main/java/com/example/nngkxxdp/service/CanteenService.java

@@ -0,0 +1,65 @@
+package com.example.nngkxxdp.service;
+
+
+import com.example.nngkxxdp.entity.CanteenDO;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.IOException;
+import java.util.Map;
+
+/**
+ * 食堂表(SCanteen)表服务接口
+ *
+ * @author zwq
+ * @since 2022-08-31 11:51:03
+ */
+public interface CanteenService {
+
+    /**
+     * 通过ID查询单条数据
+     *
+     * @param id 主键
+     * @return java.util.Map<java.lang.String,java.lang.Object> 数据
+     */
+    CanteenDO queryById(String id);
+
+    /**
+     * description: 分页查询
+     * @author zwq
+     * @date 2022/8/31 16:01
+     * @param startRows 分页参数
+     * @param limit 分页参数
+     * @param canteenName 食堂名称
+     * @return java.util.Map<java.lang.String,java.lang.Object>
+     */
+    Map<String, Object> page(Integer startRows, Integer limit, String canteenName);
+
+    /**
+     * description: 新增数据
+     * @author zwq
+     * @date 2022/9/2 9:26
+     * @param canteenDO 数据
+     * @param files 食堂图片
+     * @return java.util.Map<java.lang.String,java.lang.Object>
+     */
+    Map<String, Object> add(CanteenDO canteenDO, MultipartFile[] files) throws IOException;
+
+    /**
+     * description: 更新数据
+     * @author zwq
+     * @date 2022/9/2 10:22
+     * @param canteenDO 数据
+     * @param files 图片
+     * @return java.util.Map<java.lang.String,java.lang.Object>
+     */
+    Map<String, Object> update(CanteenDO canteenDO, MultipartFile[] files) throws IOException;
+
+    /**
+     * 通过主键删除数据
+     *
+     * @param id 主键
+     * @return java.util.Map<java.lang.String,java.lang.Object> 数据
+     */
+    Map<String, Object> deleteById(String id);
+
+}

+ 10 - 0
nngkxxdp/src/main/java/com/example/nngkxxdp/service/SupplyTimeService.java

@@ -3,6 +3,7 @@ package com.example.nngkxxdp.service;
 
 import com.example.nngkxxdp.entity.SupplyTimeDO;
 
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -56,4 +57,13 @@ public interface SupplyTimeService {
      */
     Map<String, Object> deleteById(String id);
 
+    /**
+     * description: 查询列表
+     * @author zwq
+     * @date 2022/9/1 15:27
+     * @param timeNode 时间节点
+     * @return java.util.Map<java.lang.String,java.lang.Object>
+     */
+    Map<String, Object> listByNode(Integer timeNode);
+
 }

+ 223 - 0
nngkxxdp/src/main/java/com/example/nngkxxdp/service/impl/CanteenServiceImpl.java

@@ -0,0 +1,223 @@
+package com.example.nngkxxdp.service.impl;
+
+import cn.hutool.core.io.FileTypeUtil;
+import cn.hutool.core.lang.UUID;
+import com.example.nngkxxdp.dao.CanteenDao;
+import com.example.nngkxxdp.dao.FileDao;
+import com.example.nngkxxdp.entity.CanteenDO;
+import com.example.nngkxxdp.entity.SFile;
+import com.example.nngkxxdp.service.CanteenService;
+import com.example.nngkxxdp.util.Blank;
+import com.example.nngkxxdp.util.ConstStr;
+import com.example.nngkxxdp.util.SendUtil;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.annotation.Resource;
+import java.io.File;
+import java.io.IOException;
+import java.util.*;
+
+/**
+ * 食堂表(SCanteen)表服务实现类
+ *
+ * @author zwq
+ * @since 2022-08-31 11:51:03
+ */
+@Service("sCanteenService")
+public class CanteenServiceImpl implements CanteenService {
+
+    @Resource
+    private CanteenDao canteenDao;
+
+    @Resource
+    private FileDao fileDao;
+
+    @Value("${file.location}")
+    private String location;
+
+    /**
+     * 通过ID查询单条数据
+     *
+     * @param id 主键
+     * @return java.util.Map<java.lang.String, java.lang.Object> 数据
+     */
+    @Override
+    public CanteenDO queryById(String id) {
+        return canteenDao.queryById(id);
+    }
+
+    /**
+     * description: 分页查询
+     * @author zwq
+     * @date 2022/8/31 16:01
+     * @param startRows 分页参数
+     * @param limit 分页参数
+     * @param canteenName 食堂名称
+     * @return java.util.Map<java.lang.String,java.lang.Object>
+     */
+    @Override
+    public Map<String, Object> page(Integer startRows, Integer limit, String canteenName) {
+        long count = canteenDao.pageCount(canteenName);
+        if (count == 0) {
+            return SendUtil.layuiTable(count, null);
+        }
+        startRows = (startRows - 1) * limit;
+        List<Map<String, Object>> pageList = canteenDao.pageList(startRows, limit, canteenName);
+        if (!pageList.isEmpty()) {
+            return SendUtil.layuiTable(count, pageList);
+        }
+        return SendUtil.send(false, ConstStr.RESULT_FAILED);
+    }
+
+    /**
+     * description: 新增数据
+     * @author zwq
+     * @date 2022/9/2 9:26
+     * @param canteenDO 数据
+     * @param files 食堂图片
+     * @return java.util.Map<java.lang.String,java.lang.Object>
+     */
+    @Override
+    public Map<String, Object> add(CanteenDO canteenDO, MultipartFile[] files) throws IOException {
+        // 图片处理
+        if (Blank.isNotEmpty(files)) {
+            File pathFile = new File(location);
+            if (!pathFile.isDirectory()) {
+                pathFile.mkdirs();
+            }
+            ArrayList<String> picPathList = new ArrayList<>();
+            for (MultipartFile file : files) {
+                //获取上传过来的文件名
+                File temporaryFile = new File(location + file.getOriginalFilename());
+                file.transferTo(temporaryFile);
+                String type = FileTypeUtil.getType(temporaryFile);
+                if (!(type.equals("jpg") || type.equals("png") || type.equals("bmp") || type.equals("jpeg"))) {
+                    return SendUtil.send(false, ConstStr.ADD_FAILED, "上传的格式必须是jpg或png或bmp或jpeg");
+                }
+                String newName = (new Date()).getTime() + ((int) (Math.random() * 9000) + 1000) + "." + type;
+                String filePath = location + newName;
+                File newFile = new File(filePath);
+                if (!temporaryFile.renameTo(newFile)) {
+                    return SendUtil.send(false, ConstStr.ADD_FAILED, "");
+                }
+                // 增加数据到s_file表
+                SFile sFile = new SFile();
+                sFile.setPath(newName);
+                sFile.setSuffix(type);
+                if (fileDao.addFile(sFile) <= 0) {
+                    return SendUtil.send(false, ConstStr.ADD_FAILED, "");
+                }
+                picPathList.add(sFile.getId().toString());
+            }
+            String picPath = String.join(",", picPathList);
+            canteenDO.setCanteenPhotoPath(picPath);
+        }
+        canteenDO.setId(UUID.randomUUID().toString());
+        canteenDO.setCreateTime(new Date());
+        canteenDO.setUpdateTime(new Date());
+        canteenDO.setIsdel(0);
+        if (canteenDao.addSCanteen(canteenDO) <= 0) {
+            return SendUtil.send(false, ConstStr.RESULT_FAILED);
+        }
+        return SendUtil.send(true, ConstStr.RESULT_SUCCESS);
+    }
+
+    /**
+     * description: 更新数据
+     * @author zwq
+     * @date 2022/9/2 10:23
+     * @param canteenDO 数据
+     * @param files 文件
+     * @return java.util.Map<java.lang.String,java.lang.Object>
+     */
+    @Override
+    public Map<String, Object> update(CanteenDO canteenDO, MultipartFile[] files) throws IOException {
+        CanteenDO old = canteenDao.queryById(canteenDO.getId());
+        if (old == null) {
+            return SendUtil.send(false, ConstStr.RESULT_FAILED, "数据不存在");
+        }
+        List<String> newPicList = new ArrayList<>();
+        if (Blank.isNotEmpty(canteenDO.getCanteenPhotoPath())) {
+            newPicList = new ArrayList<>(Arrays.asList(canteenDO.getCanteenPhotoPath().split(",")));
+            // 清理旧图片
+            for (int i = 0; i < newPicList.size(); i++) {
+                String s = newPicList.get(i);
+                // 如果有该后缀表示该文件为旧文件
+                if (s.substring(s.length() - 1).equals("x")) {
+                    Integer id = Integer.valueOf(s.substring(0, s.length() - 1));
+                    SFile sFile = fileDao.selectById(id);
+                    //删除旧图片
+                    if (Blank.isNotEmpty(sFile)) {
+                        if (fileDao.deleteFile(id) <= 0) {
+                            return SendUtil.send(false, ConstStr.UPDATEUSER_FAILED, "");
+                        }
+                        File oldFile = new File(location + sFile.getPath());
+                        if (!oldFile.delete()) {
+                            return SendUtil.send(false, ConstStr.UPDATEUSER_FAILED, "");
+                        }
+                        newPicList.remove(s);
+                    }
+                }
+            }
+        }
+        old.setCanteenPhotoPath(String.join(",", newPicList));
+        // 当存在file表示上传了新图片
+        if (Blank.isNotEmpty(files)) {
+            File pathFile = new File(location);
+            if (!pathFile.isDirectory()) {
+                pathFile.mkdirs();
+            }
+            for (MultipartFile file : files) {
+                //获取上传过来的文件名
+                File temporaryFile = new File(location + file.getOriginalFilename());
+                file.transferTo(temporaryFile);
+                String type = FileTypeUtil.getType(temporaryFile);
+                if (!(type.equals("jpg") || type.equals("png") || type.equals("bmp"))) {
+                    return SendUtil.send(false, ConstStr.ADD_FAILED, "上传的格式必须是jpg或png或bmp");
+                }
+                String newName = (new Date()).getTime() + ((int) (Math.random() * 9000) + 1000) + "." + type;
+                String filePath = location + newName;
+                File newFile = new File(filePath);
+                if (!temporaryFile.renameTo(newFile)) {
+                    return SendUtil.send(false, ConstStr.ADD_FAILED, "");
+                }
+                // 增加数据到s_file表
+                SFile sFile = new SFile();
+                sFile.setPath(newName);
+                sFile.setSuffix(type);
+                if (fileDao.addFile(sFile) <= 0) {
+                    return SendUtil.send(false, ConstStr.ADD_FAILED, "");
+                }
+                newPicList.add(sFile.getId().toString());
+            }
+            old.setCanteenPhotoPath(String.join(",", newPicList));
+        }
+        old.setUpdateTime(new Date());
+        if (Blank.isEmpty(canteenDO.getSupplyTimeId())) {
+            canteenDO.setSupplyTimeId(null);
+        }
+        old.setSupplyTimeId(canteenDO.getSupplyTimeId());
+        old.setCanteenName(canteenDO.getCanteenName());
+        if (canteenDao.updateSCanteen(old) <= 0) {
+            return SendUtil.send(false, ConstStr.RESULT_FAILED);
+        }
+        return SendUtil.send(true, ConstStr.RESULT_SUCCESS);
+    }
+
+    /**
+     * 通过主键删除数据
+     *
+     * @param id 主键
+     * @return java.util.Map<java.lang.String, java.lang.Object> 数据
+     */
+    @Override
+    public Map<String, Object> deleteById(String id) {
+        if (canteenDao.deleteSCanteenById(id) <= 0) {
+            return SendUtil.send(false, ConstStr.RESULT_FAILED);
+        }
+        return SendUtil.send(true, ConstStr.RESULT_SUCCESS);
+    }
+}

+ 14 - 0
nngkxxdp/src/main/java/com/example/nngkxxdp/service/impl/SupplyTimeServiceImpl.java

@@ -114,4 +114,18 @@ public class SupplyTimeServiceImpl implements SupplyTimeService {
         }
         return SendUtil.send(true, ConstStr.RESULT_SUCCESS);
     }
+
+    /**
+     * description: 查询列表
+     *
+     * @param timeNode 时间节点
+     * @return java.util.Map<java.lang.String, java.lang.Object>
+     * @author zwq
+     * @date 2022/9/1 15:27
+     */
+    @Override
+    public Map<String, Object> listByNode(Integer timeNode) {
+        List<Map<String, Object>> list = supplyTimeDao.listByNode(timeNode);
+        return SendUtil.send(true, ConstStr.RESULT_SUCCESS, list);
+    }
 }

+ 91 - 0
nngkxxdp/src/main/resources/mapper/CanteenDao.xml

@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.example.nngkxxdp.dao.CanteenDao">
+
+    <resultMap type="com.example.nngkxxdp.entity.CanteenDO" id="SCanteenMap">
+        <result property="id" column="id" jdbcType="VARCHAR"/>
+        <result property="canteenName" column="canteen_name" jdbcType="VARCHAR"/>
+        <result property="canteenPhotoPath" column="canteen_photo_path" jdbcType="VARCHAR"/>
+        <result property="supplyTimeId" column="supply_time_id" jdbcType="VARCHAR"/>
+        <result property="founder" column="founder" jdbcType="INTEGER"/>
+        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
+        <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
+        <result property="isdel" column="isdel" jdbcType="INTEGER"/>
+    </resultMap>
+
+    <!--查询单个-->
+    <select id="queryById" resultMap="SCanteenMap">
+        SELECT
+          id, canteen_name, canteen_photo_path, supply_time_id, founder, create_time, update_time, isdel
+        FROM s_canteen
+        WHERE id = #{id}
+    </select>
+    
+    <!--分页计数-->
+    <select id="pageCount" resultType="java.lang.Long">
+        SELECT COUNT(*)
+        FROM s_canteen
+        <where>
+          s_canteen.isdel = 0
+          <if test="canteenName != null and canteenName != ''">
+             AND canteen_name LIKE CONCAT('%', #{canteenName}, '%')
+          </if>
+        </where>
+    </select>
+
+    <!--分页列表-->
+    <select id="pageList" resultType="java.util.Map">
+        SELECT
+          s_canteen.id, canteen_name, canteen_photo_path, supply_time_id, u.user_name founder, s_canteen.create_time, s_canteen.update_time, s_canteen.isdel
+        FROM s_canteen
+        LEFT JOIN p_user u
+        ON u.id = s_canteen.founder
+        <where>
+          s_canteen.isdel = 0
+          <if test="canteenName != null and canteenName != ''">
+            AND canteen_name LIKE CONCAT('%', #{canteenName}, '%')
+          </if>
+        </where>
+        ORDER BY s_canteen.update_time DESC
+        LIMIT #{startRows}, #{limit}
+    </select>
+
+    <!--新增所有列-->
+    <insert id="addSCanteen">
+        INSERT INTO s_canteen(id, canteen_name, canteen_photo_path, supply_time_id, founder, create_time, update_time, isdel)
+        VALUES (#{id}, #{canteenName}, #{canteenPhotoPath}, #{supplyTimeId}, #{founder}, #{createTime}, #{updateTime}, #{isdel})
+    </insert>
+
+    <!--通过主键修改数据-->
+    <update id="updateSCanteen">
+        UPDATE s_canteen
+        <set>
+            <if test="canteenName != null and canteenName != ''">
+                canteen_name = #{canteenName},
+            </if>
+            canteen_photo_path = #{canteenPhotoPath},
+            supply_time_id = #{supplyTimeId},
+            <if test="founder != null">
+                founder = #{founder},
+            </if>
+            <if test="createTime != null">
+                create_time = #{createTime},
+            </if>
+            <if test="updateTime != null">
+                update_time = #{updateTime},
+            </if>
+            <if test="isdel != null">
+                isdel = #{isdel},
+            </if>
+        </set>
+        WHERE id = #{id}
+    </update>
+
+    <!--通过主键删除-->
+    <delete id="deleteSCanteenById">
+        UPDATE s_canteen
+        SET s_canteen.isdel = 1
+        WHERE id = #{id}
+    </delete>
+
+</mapper>

+ 16 - 0
nngkxxdp/src/main/resources/mapper/SupplyTimeDao.xml

@@ -47,9 +47,25 @@
                 AND time_node = #{timeNode}
             </if>
         </where>
+        ORDER BY s_supply_time.supply_start_time
         LIMIT #{startRows}, #{limit}
     </select>
 
+    <!--列表-->
+    <select id="listByNode" resultType="java.util.Map">
+        SELECT
+        s_supply_time.id, supply_start_time, supply_end_time, time_node, founder,
+        s_supply_time.create_time, s_supply_time.update_time, s_supply_time.isdel
+        FROM s_supply_time
+        <where>
+            s_supply_time.isdel = 0
+            <if test="timeNode != null and timeNode > 0">
+                AND time_node = #{timeNode}
+            </if>
+        </where>
+        ORDER BY s_supply_time.supply_start_time
+    </select>
+
     <!--新增所有列-->
     <insert id="addSupplyTime">
         INSERT INTO s_supply_time(id, supply_start_time, supply_end_time, time_node, founder, create_time, update_time, isdel)

+ 5 - 1
nngkxxdp/src/main/resources/static/naqwzsjtj/naqwzsjtj/src/api/index.js

@@ -320,6 +320,10 @@ export default {
   markEvaluation(data) {
     return request.post('evaluation/mark', data)
   },
+  // 供应时间列表
+  supplyTimeList(data) {
+    return request.get('supplyTime/list', data)
+  },
 
 }
 
@@ -333,4 +337,4 @@ export default {
 // 			limit:pageSize,
 // 		}
 // 	})
-// }
+// }

+ 697 - 387
nngkxxdp/src/main/resources/static/naqwzsjtj/naqwzsjtj/src/views/canteen/CanteenManage.vue

@@ -1,430 +1,740 @@
 <template>
-    <div class="yxnaContent">
-        <!--操作栏-->
-        <div style="display: flex;justify-content: space-between;margin-bottom: 10px">
-            <div>
-                <el-button type="primary" class="add" @click="openAddWork">新增</el-button>
-            </div>
-            <div style="display: flex">
-                <el-input v-model.trim="query.canteenName" clearable placeholder="请输入食堂名称"
-                    style="margin: 0 10px;width: 200px" />
-                <el-button type="primary" class="search" @click="searchData">搜索</el-button>
-                <el-button type="primary" class="search" @click="reset" style="margin-left: 5px">重置</el-button>
-            </div>
-        </div>
-        <!--表格-->
-        <el-table :data="tableData" border ref='multipleTable' :height="tableH" stripe
-            :header-cell-style="{ background: '#e5e8ed', color: '#666', textAlign: 'center' }" :cell-style="tableStyle"
-            style="cursor: default">
-            <el-table-column width="50" label="序号">
-                <template slot-scope="scope">
-                    {{ (sorts.page - 1) * sorts.limit + scope.$index + 1 }}
-                </template>
-            </el-table-column>
-            <el-table-column prop="canteenName" label="食堂名称" />
-            <el-table-column prop="canteenPhotoPath" :show-overflow-tooltip="true" label="照片" />
-            <el-table-column prop="supplyTimeId" :show-overflow-tooltip="true" label="供应时间ID" />
-            <el-table-column prop="founder" label="创建人" />
-            <el-table-column prop="createTime" label="创建时间" />
-            <el-table-column label="操作" width="230">
-                <template slot-scope="scope">
-                    <el-button class="but" type="primary" @click="openModifyWorkDialog(scope.row)">
-                        编辑</el-button>
-                    <el-button class="but" type="danger" @click="handleDelete(scope.row.id, scope.$index)">删除
-                    </el-button>
-                </template>
-            </el-table-column>
-        </el-table>
-        <div class="block">
-            <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
-                :current-page="sorts.page" :page-sizes="[10, 20, 30, 40, 50]" :page-size="sorts.limit"
-                layout="prev, pager,next,jumper,total,sizes" :total="total">
-            </el-pagination>
-        </div>
-        <!-- 新增/编辑食堂 -->
-        <el-dialog :visible.sync="workDialog" width="60%" class="detailDialog" :close-on-click-modal="false" top="40px">
-            <div slot="title">
-                <div class="addTitle">{{workTitle}}</div>
-            </div>
-            <div style="height:65vh;overflow: auto;padding-right: 20px">
-                <el-form :model="postManagement" label-width="140px">
-                    <el-row>
-                        <el-col :span="12">
-                            <el-form-item label="食堂名称" prop="canteenName">
-                                <el-input v-model="postManagement.canteenName" placeholder="请输入食堂名称">
-                                </el-input>
-                            </el-form-item>
-                        </el-col>
-                    </el-row>
-                    <el-row>
-                        <el-col :span="12">
-                            <el-form-item label="供应时间" prop="url">
-                                <el-input v-model="postManagement.supplyTimeId" placeholder="供应时间id">
-                                </el-input>
-                            </el-form-item>
-                        </el-col>
-                    </el-row>
-                    <el-row>
-                        <el-col :span="24">
-                            <el-form-item label="食堂图片" prop="url">
-                            </el-form-item>
-                            <el-upload
-                                element-loading-text="数据上传中请等待..."
-                                action=""
-                                class="upload-demo"
-                                :on-change="handleChange"
-                                :multiple="false"
-                                :auto-upload="false"
-                                :http-request="saveWork"
-                                list-type="picture-card"
-                                accept=".jpg,.png"
-                                :show-file-list="true"
-                                :file-list="fileList"
-                                >
-                                <i class="el-icon-plus"></i>
-                                <div slot="tip" class="el-upload__tip">只能上传jps或png文件</div>
-                            </el-upload>
-                        </el-col>
-                    </el-row>
-                </el-form>
-            </div>
-            <div slot="footer" class="dialog-footer">
-                <el-button type="primary" size="mini" @click="saveWork">提交</el-button>
-                <el-button @click="workDialog = false" size="mini">返回</el-button>
-            </div>
-        </el-dialog>
+  <div class="yxnaContent">
+    <!--操作栏-->
+    <div
+      style="display: flex; justify-content: space-between; margin-bottom: 10px"
+    >
+      <div>
+        <el-button type="primary" class="add" @click="openAddWork"
+          >新增</el-button
+        >
+      </div>
+      <div style="display: flex">
+        <el-input
+          v-model.trim="query.canteenName"
+          clearable
+          placeholder="请输入食堂名称"
+          style="margin: 0 10px; width: 200px"
+        />
+        <el-button type="primary" class="search" @click="searchData"
+          >搜索</el-button
+        >
+        <el-button
+          type="primary"
+          class="search"
+          @click="reset"
+          style="margin-left: 5px"
+          >重置</el-button
+        >
+      </div>
     </div>
+    <!--表格-->
+    <el-table
+      :data="tableData"
+      border
+      ref="multipleTable"
+      :height="tableH"
+      stripe
+      :header-cell-style="{
+        background: '#e5e8ed',
+        color: '#666',
+        textAlign: 'center',
+      }"
+      :cell-style="tableStyle"
+      style="cursor: default"
+    >
+      <el-table-column width="50" label="序号">
+        <template slot-scope="scope">
+          {{ (sorts.page - 1) * sorts.limit + scope.$index + 1 }}
+        </template>
+      </el-table-column>
+      <el-table-column prop="canteenName" label="食堂名称" />
+      <!-- <el-table-column
+        prop="canteenPhotoPath"
+        :show-overflow-tooltip="true"
+        label="照片"
+      />
+      <el-table-column
+        prop="supplyTimeId"
+        :show-overflow-tooltip="true"
+        label="供应时间ID"
+      /> -->
+      <el-table-column prop="founder" label="创建人" />
+      <el-table-column prop="createTime" label="创建时间" />
+      <el-table-column label="操作" width="230">
+        <template slot-scope="scope">
+          <el-button
+            class="but"
+            type="primary"
+            @click="openModifyWorkDialog(scope.row)"
+          >
+            编辑</el-button
+          >
+          <el-button
+            class="but"
+            type="danger"
+            @click="handleDelete(scope.row.id, scope.$index)"
+            >删除
+          </el-button>
+        </template>
+      </el-table-column>
+    </el-table>
+    <div class="block">
+      <el-pagination
+        @size-change="handleSizeChange"
+        @current-change="handleCurrentChange"
+        :current-page="sorts.page"
+        :page-sizes="[10, 20, 30, 40, 50]"
+        :page-size="sorts.limit"
+        layout="prev, pager,next,jumper,total,sizes"
+        :total="total"
+      >
+      </el-pagination>
+    </div>
+    <!-- 新增/编辑食堂 -->
+    <el-dialog
+      :visible.sync="workDialog"
+      width="60%"
+      class="detailDialog"
+      :close-on-click-modal="false"
+      top="40px"
+    >
+      <div slot="title">
+        <div class="addTitle">{{ workTitle }}</div>
+      </div>
+      <div style="height: 65vh; overflow: auto; padding-right: 20px">
+        <el-form :model="postManagement" label-width="140px">
+          <el-row>
+            <el-col :span="24">
+              <el-form-item label="食堂名称" prop="canteenName">
+                <el-input
+                  v-model="postManagement.canteenName"
+                  placeholder="请输入食堂名称"
+                  style="width: 55%"
+                >
+                </el-input>
+              </el-form-item>
+            </el-col>
+          </el-row>
+          <el-row>
+            <el-col :span="24">
+              <el-form-item label="供应时间" prop="url">
+                <el-select
+                  v-model="postManagement.supplyTimeId"
+                  @change="timeNodeChange"
+                  @remove-tag="timeNodeChange"
+                  @visible-change="timeNodeChange"
+                  multiple
+                  placeholder="请选择"
+                  style="width: 55%; height: 110%"
+                >
+                  <el-option-group
+                    v-for="group in timeNodeOptions"
+                    :key="group.label"
+                    :label="group.label"
+                  >
+                    <el-option
+                      v-for="item in group.options"
+                      :key="item.id"
+                      :label="
+                        item.supplyStartTime + ' —— ' + item.supplyEndTime
+                      "
+                      :value="item.id"
+                      :disabled="item.disabled"
+                    >
+                    </el-option>
+                  </el-option-group>
+                </el-select>
+              </el-form-item>
+            </el-col>
+          </el-row>
+          <el-row>
+            <el-col :span="24">
+              <el-form-item label="食堂图片" prop="url"> </el-form-item>
+              <el-upload
+                element-loading-text="数据上传中请等待..."
+                action=""
+                class="upload-demo"
+                :on-change="handleChange"
+                :multiple="false"
+                :auto-upload="false"
+                :http-request="saveWork"
+                list-type="picture-card"
+                accept="image/png,image/jpg,image/jpeg,image/bmp"
+                :show-file-list="true"
+                :file-list="fileList"
+                :on-remove="picRemove"
+              >
+                <i class="el-icon-plus"></i>
+              </el-upload>
+            </el-col>
+          </el-row>
+        </el-form>
+      </div>
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" size="mini" @click="saveWork">提交</el-button>
+        <el-button @click="workDialog = false" size="mini">返回</el-button>
+      </div>
+    </el-dialog>
+  </div>
 </template>
 
 <script>
-    import api from '../../api/index'
+import api from "../../api/index";
+
+export default {
+  name: "CanteenManage",
+  created() {
+    this.getData();
+  },
+  data() {
+    return {
+      tableStyle: {
+        textAlign: "center",
+      },
+      tableH: "calc(100vh - 230px)",
+      // 搜索参数
+      query: {
+        canteenName: "",
+      },
+      timeNodeList: [],
+      // 整体分组
+      timeNodeOptions: [],
+      timeNodeOption1: {
+        label: "早餐",
+        options: [],
+      },
+      timeNodeOption2: {
+        label: "中餐",
+        options: [],
+      },
+      timeNodeOption3: {
+        label: "晚餐",
+        options: [],
+      },
+      timeNodeOption4: {
+        label: "外卖",
+        options: [],
+      },
 
-    export default {
-        name: 'CanteenManage',
-        created() {
-            this.getData()
-        },
-        data() {
-            return {
-                tableStyle: {
-                    textAlign: 'center',
-                },
-                tableH: 'calc(100vh - 230px)',
-                // 搜索参数
-                query: {
-                    canteenName: ''
-                },
-                // 列表数据
-                tableData: [],
-                // 总数
-                total: 0,
-                //新增/编辑食堂界面
-                workDialog: false,
-                //新增/编辑食堂标题
-                workTitle: '新增食堂',
-                // 新增/编辑表单
-                postManagement: {
-                    canteenName: '',
-                    canteenPhotoPath: '',
-                    supplyTimeId: ''
-                },
-                // 分页
-                sorts: {
-                    page: 1,
-                    limit: 10,
-                },
-                uploadFiles: [],
-                fileList: []
+      // 早餐列表
+      timeNodeList1: [],
+      // 中餐列表
+      timeNodeList2: [],
+      timeNodeList3: [],
+      timeNodeList4: [],
+      // 列表数据
+      tableData: [],
+      // 总数
+      total: 0,
+      //新增/编辑食堂界面
+      workDialog: false,
+      //新增/编辑食堂标题
+      workTitle: "新增食堂",
+      // 新增/编辑表单
+      postManagement: {
+        canteenName: "",
+        canteenPhotoPath: "",
+        supplyTimeId: [],
+      },
+      // 分页
+      sorts: {
+        page: 1,
+        limit: 10,
+      },
+      uploadFiles: [],
+      fileList: [],
+    };
+  },
+  methods: {
+    //删除文件
+    picRemove(file, fileList) {
+      if (this.postManagement.canteenPhotoPath) {
+        let temp = this.postManagement.canteenPhotoPath.split(",");
+        for (let i = 0; i < temp.length; i++) {
+          if (temp[i] == file.name) {
+            temp[i] = temp[i] + "x";
+            break;
+          }
+        }
+        this.postManagement.canteenPhotoPath = temp.join(",");
+      }
+      this.uploadFiles = fileList;
+    },
+    // 根据选择的时间节点,禁用相同类型的选项
+    timeNodeChange() {
+      // 分别代表早中晚快递选择的数量
+      let timeNodeNum1 = 0;
+      let timeNodeNum2 = 0;
+      let timeNodeNum3 = 0;
+      let timeNodeNum4 = 0;
+      if (
+        this.postManagement.supplyTimeId &&
+        this.postManagement.supplyTimeId.length > 0
+      ) {
+        // 遍历已选择的选项
+        this.postManagement.supplyTimeId.forEach((item) => {
+          let index = this.timeNodeList.findIndex(function (node) {
+            return item === node.id;
+          });
+          // 找到时间节点类型
+          if (index !== -1) {
+            let nodeType = this.timeNodeList[index].timeNode;
+            switch (nodeType) {
+              case 1:
+                timeNodeNum1++;
+                break;
+              case 2:
+                timeNodeNum2++;
+                break;
+              case 3:
+                timeNodeNum3++;
+                break;
+              case 4:
+                timeNodeNum4++;
+                break;
             }
-        },
-        methods: {
-            handleChange(file, fileList) {
-            // 文件改变
-            this.uploadFiles = fileList
-            },
-            //打开新增食堂界面
-            openAddWork() {
-                this.postManagement = {
-                    canteenName: '',
-                    canteenPhotoPath: '',
-                    supplyTimeId: ''
-                };
-                this.workTitle = '新增食堂'
-                this.workDialog = true;
-            },
-            //打开修改食堂界面
-            openModifyWorkDialog(data) {
-                this.workTitle = '编辑食堂';
-                this.postManagement = JSON.parse(JSON.stringify(data));
-                this.workDialog = true;
-            },
-            //保存
-            saveWork() {
-                if (!this.postManagement.canteenName) {
-                    this.$message.error('请输入食堂名称!');
-                    return;
-                }
-                if (this.workTitle == '编辑食堂') {
-                    api.updateCanteen(this.postManagement).then(r => {
-                        if (r.data.result) {
-                            this.$message.success('编辑成功');
-                            this.getData();
-                            this.workDialog = false;
-                        } else {
-                            this.$message.error("编辑失败");
-                        }
-                    }).catch(() => {
-                        this.$message.error("编辑失败");
-                    })
-                } else {
-                    let files = []
-                    console.log('uploadFiles', this.uploadFiles)
-                    this.uploadFiles.forEach((item) => {
-                        console.log(item)
-                        files.push(item.raw)
-                    })
-                    var params = new FormData()
-                    this.postManagement.founder = sessionStorage.getItem('pid')
-                    console.log(files)
-                    console.log(this.postManagement)
-                    params.append('files', files)
-                    params.append('canteenName', this.postManagement.canteenName)
-                    console.log('params', params)
-                    api.addCanteen(params).then(r => {
-                        if (r.data.result) {
-                            this.$message.success('新增成功');
-                            this.getData();
-                            this.workDialog = false;
-                        } else {
-                            this.$message.error("新增失败");
-                        }
-                    }).catch(() => {
-                        this.$message.error("新增失败");
-                    })
-                }
-            },
-            //切换列表条数
-            handleSizeChange(pageSize) {
-                this.sorts.limit = pageSize
-                this.sorts.page = 1;
-                this.getData();
-            },
-            //切换页码
-            handleCurrentChange(currentPage) {
-                this.$refs.multipleTable.bodyWrapper.scrollTop = 0;
-                this.sorts.page = currentPage;
-                this.getData();
-            },
-            //删除
-            handleDelete(id, index) {
-                this.$confirm("您确定要删除该数据吗?", "提示", {
-                    cancelButtonClass: "btn-custom-cancel",
-                    confirmButtonText: "确定",
-                    cancelButtonText: "取消",
-                    type: "warning"
-                }).then(() => {
-                    let fd = new FormData();
-                    fd.append('id', id);
-                    api.deleteCanteenById(fd).then(res => {
-                        if (res.data.result) {
-                            this.$message({
-                                type: 'success',
-                                message: '删除成功!'
-                            });
-                            this.tableData.splice(index, 1);
-                            this.getData();
-                        } else {
-                            this.$message({
-                                type: 'info',
-                                message: '删除失败!'
-                            });
-                        }
-                    })
-                }).catch(() => {
-                    this.$message({
-                        type: 'info',
-                        message: '已取消删除'
-                    });
-                })
-            },
-            // 获取列表数据
-            getData() {
-                let params = {
-                    page: this.sorts.page,
-                    limit: this.sorts.limit,
-                    canteenName: this.query.canteenName
-                }
-                api.canteenPage({
-                    params
-                }).then(r => {
-                    this.total = r.data.count
-                    this.tableData = r.data.data
+          }
+        });
+      }
+      if (timeNodeNum1 > 0) {
+        this.timeNodeList1.forEach((node1) => {
+          node1.disabled = true;
+        });
+      } else {
+        this.timeNodeList1.forEach((node1) => {
+          node1.disabled = false;
+        });
+      }
+      if (timeNodeNum2 > 0) {
+        this.timeNodeList2.forEach((node1) => {
+          node1.disabled = true;
+        });
+      } else {
+        this.timeNodeList2.forEach((node1) => {
+          node1.disabled = false;
+        });
+      }
+      if (timeNodeNum3 > 0) {
+        this.timeNodeList3.forEach((node1) => {
+          node1.disabled = true;
+        });
+      } else {
+        this.timeNodeList3.forEach((node1) => {
+          node1.disabled = false;
+        });
+      }
+      if (timeNodeNum4 > 0) {
+        this.timeNodeList4.forEach((node1) => {
+          node1.disabled = true;
+        });
+      } else {
+        this.timeNodeList4.forEach((node1) => {
+          node1.disabled = false;
+        });
+      }
+    },
+    handleChange(file, fileList) {
+      // 文件改变
+      this.uploadFiles = fileList;
+    },
+    //打开新增食堂界面
+    openAddWork() {
+      api
+        .supplyTimeList()
+        .then((r) => {
+          if (r.data.result) {
+            // 拿到时间节点,并分组
+            this.timeNodeList = r.data.data;
+            this.timeNodeList1 = this.timeNodeList.filter((item) => {
+              return item.timeNode === 1;
+            });
+            this.timeNodeList2 = this.timeNodeList.filter((item) => {
+              return item.timeNode === 2;
+            });
+            this.timeNodeList3 = this.timeNodeList.filter((item) => {
+              return item.timeNode === 3;
+            });
+            this.timeNodeList4 = this.timeNodeList.filter((item) => {
+              return item.timeNode === 4;
+            });
+            this.timeNodeOption1.options = this.timeNodeList1;
+            this.timeNodeOption2.options = this.timeNodeList2;
+            this.timeNodeOption3.options = this.timeNodeList3;
+            this.timeNodeOption4.options = this.timeNodeList4;
+            this.timeNodeOptions = [];
+            this.timeNodeOptions.push(
+              this.timeNodeOption1,
+              this.timeNodeOption2,
+              this.timeNodeOption3,
+              this.timeNodeOption4
+            );
+          } else {
+            this.$message.error("获取时间节点列表失败");
+          }
+        })
+        .catch(() => {
+          this.$message.error("获取时间节点列表失败");
+        });
+      this.postManagement = {
+        canteenName: "",
+        canteenPhotoPath: "",
+        supplyTimeId: [],
+      };
+      this.fileList = [];
+      this.workTitle = "新增食堂";
+      this.workDialog = true;
+    },
+    //打开修改食堂界面
+    openModifyWorkDialog(data) {
+      api
+        .supplyTimeList()
+        .then((r) => {
+          if (r.data.result) {
+            // 拿到时间节点列表,并分组
+            this.timeNodeList = r.data.data;
+            this.timeNodeList1 = this.timeNodeList.filter((item) => {
+              return item.timeNode === 1;
+            });
+            this.timeNodeList2 = this.timeNodeList.filter((item) => {
+              return item.timeNode === 2;
+            });
+            this.timeNodeList3 = this.timeNodeList.filter((item) => {
+              return item.timeNode === 3;
+            });
+            this.timeNodeList4 = this.timeNodeList.filter((item) => {
+              return item.timeNode === 4;
+            });
+            this.timeNodeOption1.options = this.timeNodeList1;
+            this.timeNodeOption2.options = this.timeNodeList2;
+            this.timeNodeOption3.options = this.timeNodeList3;
+            this.timeNodeOption4.options = this.timeNodeList4;
+            this.timeNodeOptions = [];
+            this.timeNodeOptions.push(
+              this.timeNodeOption1,
+              this.timeNodeOption2,
+              this.timeNodeOption3,
+              this.timeNodeOption4
+            );
+            this.postManagement = JSON.parse(JSON.stringify(data));
+            if (this.postManagement.supplyTimeId && this.postManagement.supplyTimeId !== '') {
+              this.postManagement.supplyTimeId =
+              this.postManagement.supplyTimeId.split(",");
+            }
+            this.timeNodeChange();
+            this.fileList = [];
+            let params = {
+              picId: this.postManagement.canteenPhotoPath,
+            };
+            if (params.picId && params.picId !== "") {
+              api
+                .getFoodPicByPicId({
+                  params,
                 })
-            },
-            // 搜索
-            searchData() {
-                this.sorts.page = 1;
-                this.getData()
-            },
-            // 清空输入框
-            reset() {
-                this.query.canteenName = ''
-                this.sorts.page = 1
-                this.getData()
+                .then((res) => {
+                  if (res.data.result) {
+                    this.fileList = res.data.data.map((item) => {
+                      return {
+                        url: item.path,
+                        name: item.id,
+                      };
+                    });
+                  }
+                });
+            }
+          } else {
+            this.$message.error("获取时间节点列表失败");
+          }
+        })
+        .catch(() => {
+          this.$message.error("获取时间节点列表失败");
+        });
+      this.workTitle = "编辑食堂";
+      this.postManagement = JSON.parse(JSON.stringify(data));
+      this.workDialog = true;
+    },
+    //保存
+    saveWork() {
+      if (!this.postManagement.canteenName) {
+        this.$message.error("请输入食堂名称!");
+        return;
+      }
+      let params = new FormData();
+      this.uploadFiles.forEach((item) => {
+        params.append("files", item.raw);
+      });
+      params.append("id", this.postManagement.id);
+      if (this.postManagement.supplyTimeId) {
+        params.append("supplyTimeId", this.postManagement.supplyTimeId);
+      }
+      params.append("canteenName", this.postManagement.canteenName);
+      if (this.postManagement.canteenPhotoPath) {
+        params.append("canteenPhotoPath", this.postManagement.canteenPhotoPath);
+      }
+      if (this.workTitle == "编辑食堂") {
+        api
+          .updateCanteen(params)
+          .then((r) => {
+            if (r.data.result) {
+              this.$message.success("编辑成功");
+              this.getData();
+              this.workDialog = false;
+            } else {
+              this.$message.error(r.data.msg);
+            }
+          })
+          .catch(() => {
+            this.$message.error(r.data.msg);
+          });
+      } else {
+        let params = new FormData();
+        this.uploadFiles.forEach((item) => {
+          params.append("files", item.raw);
+        });
+        params.append("founder", sessionStorage.getItem("pid"));
+        params.append("supplyTimeId", this.postManagement.supplyTimeId);
+        params.append("canteenName", this.postManagement.canteenName);
+        api
+          .addCanteen(params)
+          .then((r) => {
+            if (r.data.result) {
+              this.$message.success("新增成功");
+              this.getData();
+              this.workDialog = false;
+            } else {
+              this.$message.error(r.data.msg);
             }
-        },
-    }
+          })
+          .catch(() => {
+            this.$message.error(r.data.msg);
+          });
+      }
+    },
+    //切换列表条数
+    handleSizeChange(pageSize) {
+      this.sorts.limit = pageSize;
+      this.sorts.page = 1;
+      this.getData();
+    },
+    //切换页码
+    handleCurrentChange(currentPage) {
+      this.$refs.multipleTable.bodyWrapper.scrollTop = 0;
+      this.sorts.page = currentPage;
+      this.getData();
+    },
+    //删除
+    handleDelete(id, index) {
+      this.$confirm("您确定要删除该数据吗?", "提示", {
+        cancelButtonClass: "btn-custom-cancel",
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning",
+      })
+        .then(() => {
+          let fd = new FormData();
+          fd.append("id", id);
+          api.deleteCanteenById(fd).then((res) => {
+            if (res.data.result) {
+              this.$message({
+                type: "success",
+                message: "删除成功!",
+              });
+              this.tableData.splice(index, 1);
+              this.getData();
+            } else {
+              this.$message({
+                type: "info",
+                message: "删除失败!",
+              });
+            }
+          });
+        })
+        .catch(() => {
+          this.$message({
+            type: "info",
+            message: "已取消删除",
+          });
+        });
+    },
+    // 获取列表数据
+    getData() {
+      let params = {
+        page: this.sorts.page,
+        limit: this.sorts.limit,
+        canteenName: this.query.canteenName,
+      };
+      api
+        .canteenPage({
+          params,
+        })
+        .then((r) => {
+          this.total = r.data.count;
+          this.tableData = r.data.data;
+        });
+    },
+    // 搜索
+    searchData() {
+      this.sorts.page = 1;
+      this.getData();
+    },
+    // 清空输入框
+    reset() {
+      this.query.canteenName = "";
+      this.sorts.page = 1;
+      this.getData();
+    },
+  },
+};
 </script>
 
 <style>
-    /* 全局取消按钮 */
-    .btn-custom-cancel {
-        margin-left: 10px !important;
-        float: right;
-    }
+/* 全局取消按钮 */
+.btn-custom-cancel {
+  margin-left: 10px !important;
+  float: right;
+}
 </style>
 
 <style scoped lang="less">
-    /* 禁用后的勾选*/
-    /deep/ .el-checkbox__input.is-disabled.is-checked .el-checkbox__inner::after {
-        border-color: #def5cb;
-    }
-
-    /deep/ .el-checkbox__input.is-disabled.is-checked .el-checkbox__inner {
-        background-color: #157de9;
-        border-color: #DCDFE6;
-    }
+/* 禁用后的勾选*/
+/deep/ .el-checkbox__input.is-disabled.is-checked .el-checkbox__inner::after {
+  border-color: #def5cb;
+}
 
-    /deep/ .el-dialog__body {
-        padding: 0 0 30px 20px;
-        color: #606266;
-        font-size: 14px;
-        word-break: break-all;
-    }
+/deep/ .el-checkbox__input.is-disabled.is-checked .el-checkbox__inner {
+  background-color: #157de9;
+  border-color: #dcdfe6;
+}
 
-    /deep/ .el-dialog {
-        margin: 0 auto 0;
-    }
+/deep/ .el-dialog__body {
+  padding: 0 0 30px 20px;
+  color: #606266;
+  font-size: 14px;
+  word-break: break-all;
+}
 
-    /deep/ .el-form-item__label {
-        padding: 0;
-    }
+/deep/ .el-dialog {
+  margin: 0 auto 0;
+}
 
-    .yxnaContent {
-        padding: 10px;
-    }
+/deep/ .el-form-item__label {
+  padding: 0;
+}
 
-    .addTitle {
-        font-size: 18px;
-        font-weight: bold;
-        margin-bottom: 10px;
-    }
+.yxnaContent {
+  padding: 10px;
+}
 
-    .add {
-        width: 66px;
-        height: 38px;
-        margin-left: 0;
-    }
+.addTitle {
+  font-size: 18px;
+  font-weight: bold;
+  margin-bottom: 10px;
+}
 
-    /deep/ .el-col-12 {
-        width: 50%;
-        text-align: left;
-    }
+.add {
+  width: 66px;
+  height: 38px;
+  margin-left: 0;
+}
 
-    .search {
-        width: 66px;
-        height: 38px;
-        margin-left: 0;
-    }
+/deep/ .el-col-12 {
+  width: 50%;
+  text-align: left;
+}
 
-    /deep/ .el-form-item__label {
-        height: 40px;
-        width: 110px;
-        background-color: #FAFAFA;
-        text-align: center;
-        border: 1px solid #DCDFE6;
-        border-radius: 2px 0 0 2px;
-    }
+.search {
+  width: 66px;
+  height: 38px;
+  margin-left: 0;
+}
 
-    /deep/ .el-button.is-disabled {
-        color: #C0C4CC !important;
-    }
+/deep/ .el-form-item__label {
+  height: 40px;
+  width: 110px;
+  background-color: #fafafa;
+  text-align: center;
+  border: 1px solid #dcdfe6;
+  border-radius: 2px 0 0 2px;
+}
 
-    /deep/.el-button--primary.is-disabled {
-        color: #FFF !important;
-    }
+/deep/ .el-button.is-disabled {
+  color: #c0c4cc !important;
+}
 
-    /deep/ .el-input__inner {
-        border-radius: 2px 0 0 2px;
-    }
+/deep/.el-button--primary.is-disabled {
+  color: #fff !important;
+}
 
-    .el-select>.el-input {
-        width: 200px;
-    }
+/deep/ .el-input__inner {
+  border-radius: 2px 0 0 2px;
+}
 
-    /deep/ .el-textarea__inner {
-        height: 100px;
-    }
+.el-select > .el-input {
+  width: 200px;
+}
 
+/deep/ .el-textarea__inner {
+  height: 100px;
+}
 
-    /deep/ .el-dialog__title {
-        font-size: 14px;
-    }
+/deep/ .el-dialog__title {
+  font-size: 14px;
+}
 
-    /deep/ .el-pagination__total {
-        margin-left: 10px !important;
-    }
+/deep/ .el-pagination__total {
+  margin-left: 10px !important;
+}
 
-    .el-pagination {
-        margin: 0;
-        margin-top: 10px;
-        /* position: fixed;
+.el-pagination {
+  margin: 0;
+  margin-top: 10px;
+  /* position: fixed;
         left: 13rem; */
-    }
+}
 
-    /deep/ .el-table--scrollable-x .el-table__body-wrapper {
-        z-index: 2;
-    }
+/deep/ .el-table--scrollable-x .el-table__body-wrapper {
+  z-index: 2;
+}
 
-    .imgBox {
-        width: 100%;
-        /*height: 55vh;*/
-        height: 100%;
-    }
+.imgBox {
+  width: 100%;
+  /*height: 55vh;*/
+  height: 100%;
+}
 
-    .but {
-        width: 36px;
-        height: 22px;
-        padding: 0;
-        font-size: 12px;
-    }
+.but {
+  width: 36px;
+  height: 22px;
+  padding: 0;
+  font-size: 12px;
+}
 
-    .el-checkbox {
-        margin: 0;
-        margin-right: 10px;
-    }
+.el-checkbox {
+  margin: 0;
+  margin-right: 10px;
+}
 
-    /deep/ .bewrite>.el-form-item__label {
-        width: 100%;
-        text-align: left;
-        padding-left: 21px;
-    }
+/deep/ .bewrite > .el-form-item__label {
+  width: 100%;
+  text-align: left;
+  padding-left: 21px;
+}
 
-    /deep/ .el-form--inline .el-form-item {
-        margin-right: 0px;
-    }
+/deep/ .el-form--inline .el-form-item {
+  margin-right: 0px;
+}
 
-    /deep/ [data-v-2cde7735] .el-form-item__label {
-        border: 1px solid #DCDFE6;
-        /*border-right: transparent;*/
-    }
+/deep/ [data-v-2cde7735] .el-form-item__label {
+  border: 1px solid #dcdfe6;
+  /*border-right: transparent;*/
+}
 
-    /*    空白框*/
-    /deep/ .formTempBox {
-        height: 38px;
-        border: 1px solid #DCDFE6;
-        width: 100%;
-        border-left: transparent;
-        background-color: #FAFAFA;
-    }
+/*    空白框*/
+/deep/ .formTempBox {
+  height: 38px;
+  border: 1px solid #dcdfe6;
+  width: 100%;
+  border-left: transparent;
+  background-color: #fafafa;
+}
 </style>