From 55b78c38405bb6e4ff576d4b702b0f37163b9e8e Mon Sep 17 00:00:00 2001 From: xiezhijun <15270898033@163.com> Date: Thu, 13 May 2021 19:59:34 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9B=B4=E6=92=AD=E8=AE=B0=E5=BD=95=E6=8E=92?= =?UTF-8?q?=E7=8F=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../custom/SysLiveSchedulController.java | 197 ++++++ .../stdiet/custom/domain/SysLiveSchedul.java | 83 +++ .../custom/mapper/SysLiveSchedulMapper.java | 80 +++ .../service/ISysLiveSchedulService.java | 80 +++ .../impl/SysLiveSchedulServiceImpl.java | 126 ++++ .../impl/SysOrderPauseServiceImpl.java | 9 +- .../mapper/custom/SysLiveSchedulMapper.xml | 196 ++++++ .../mapper/custom/SysOrderPauseMapper.xml | 4 +- stdiet-ui/src/api/custom/liveSchedul.js | 63 ++ .../src/views/custom/liveSchedul/index.vue | 603 ++++++++++++++++++ 10 files changed, 1436 insertions(+), 5 deletions(-) create mode 100644 stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysLiveSchedulController.java create mode 100644 stdiet-custom/src/main/java/com/stdiet/custom/domain/SysLiveSchedul.java create mode 100644 stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysLiveSchedulMapper.java create mode 100644 stdiet-custom/src/main/java/com/stdiet/custom/service/ISysLiveSchedulService.java create mode 100644 stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysLiveSchedulServiceImpl.java create mode 100644 stdiet-custom/src/main/resources/mapper/custom/SysLiveSchedulMapper.xml create mode 100644 stdiet-ui/src/api/custom/liveSchedul.js create mode 100644 stdiet-ui/src/views/custom/liveSchedul/index.vue diff --git a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysLiveSchedulController.java b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysLiveSchedulController.java new file mode 100644 index 000000000..258244d2a --- /dev/null +++ b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysLiveSchedulController.java @@ -0,0 +1,197 @@ +package com.stdiet.web.controller.custom; + +import java.util.Date; +import java.util.List; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.stdiet.common.annotation.Log; +import com.stdiet.common.core.controller.BaseController; +import com.stdiet.common.core.domain.AjaxResult; +import com.stdiet.common.enums.BusinessType; +import com.stdiet.custom.domain.SysLiveSchedul; +import com.stdiet.custom.service.ISysLiveSchedulService; +import com.stdiet.common.utils.poi.ExcelUtil; +import com.stdiet.common.core.page.TableDataInfo; + +/** + * 直播排班Controller + * + * @author xzj + * @date 2021-05-12 + */ +@RestController +@RequestMapping("/custom/liveSchedul") +public class SysLiveSchedulController extends BaseController +{ + @Autowired + private ISysLiveSchedulService sysLiveSchedulService; + + /** + * 查询直播排班列表 + */ + @PreAuthorize("@ss.hasPermi('custom:liveSchedul:list')") + @GetMapping("/list") + public TableDataInfo list(SysLiveSchedul sysLiveSchedul) + { + startPage(); + List<SysLiveSchedul> list = sysLiveSchedulService.selectSysLiveSchedulList(sysLiveSchedul); + return getDataTable(list); + } + + /** + * 导出直播排班列表 + */ + @PreAuthorize("@ss.hasPermi('custom:liveSchedul:export')") + @Log(title = "直播排班", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(SysLiveSchedul sysLiveSchedul) + { + List<SysLiveSchedul> list = sysLiveSchedulService.selectSysLiveSchedulList(sysLiveSchedul); + ExcelUtil<SysLiveSchedul> util = new ExcelUtil<SysLiveSchedul>(SysLiveSchedul.class); + return util.exportExcel(list, "liveSchedul"); + } + + /** + * 获取直播排班详细信息 + */ + @PreAuthorize("@ss.hasPermi('custom:liveSchedul:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(sysLiveSchedulService.selectSysLiveSchedulById(id)); + } + + /** + * 新增直播排班 + */ + @PreAuthorize("@ss.hasPermi('custom:liveSchedul:add')") + @Log(title = "直播排班", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody SysLiveSchedul sysLiveSchedul) + { + SysLiveSchedul oldLiveSchedul = sysLiveSchedulService.getLiveSchedulByLiveTime(sysLiveSchedul); + if(oldLiveSchedul != null){ + return AjaxResult.error("直播时间冲突,无法添加"); + } + //下播,补全下播时间 + if (sysLiveSchedul.getLiveStatus() != null && sysLiveSchedul.getLiveStatus().longValue() == 2 + && sysLiveSchedul.getLiveEndTime() == null){ + sysLiveSchedul.setLiveEndTime(new Date()); + } + int row = sysLiveSchedulService.insertSysLiveSchedul(sysLiveSchedul); + if(row > 0){ + if(sysLiveSchedul.getLiveStatus() != null){ + //开播 + if(sysLiveSchedul.getLiveStatus().longValue() == 1){ + SysLiveSchedul lastLiveSchedul = sysLiveSchedulService.getLastLiveSchedulById(sysLiveSchedul); + //上一个直播还在直播,需要关闭上一个直播 + if(lastLiveSchedul != null && lastLiveSchedul.getLiveStatus().longValue() == 1){ + lastLiveSchedul.setLiveStatus(2L); + if(lastLiveSchedul.getLiveEndTime() == null){ + lastLiveSchedul.setLiveEndTime(sysLiveSchedul.getLiveStartTime()); + } + row = sysLiveSchedulService.updateSysLiveSchedul(lastLiveSchedul); + } + } + } + } + return toAjax(row); + } + + /** + * 修改直播排班 + */ + @PreAuthorize("@ss.hasPermi('custom:liveSchedul:edit')") + @Log(title = "直播排班", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody SysLiveSchedul sysLiveSchedul) + { + SysLiveSchedul oldLiveSchedul = sysLiveSchedulService.getLiveSchedulByLiveTime(sysLiveSchedul); + if(oldLiveSchedul != null && oldLiveSchedul.getId().longValue() != sysLiveSchedul.getId().longValue()){ + return AjaxResult.error("直播时间冲突,无法修改"); + } + //下播,补全下播时间 + if (sysLiveSchedul.getLiveStatus() != null && sysLiveSchedul.getLiveStatus().longValue() == 2 + && sysLiveSchedul.getLiveEndTime() == null){ + sysLiveSchedul.setLiveEndTime(new Date()); + } + int row = sysLiveSchedulService.updateSysLiveSchedulById(sysLiveSchedul); + if(row > 0){ + if(sysLiveSchedul.getLiveStatus() != null){ + //开播 + if(sysLiveSchedul.getLiveStatus().longValue() == 1){ + SysLiveSchedul lastLiveSchedul = sysLiveSchedulService.getLastLiveSchedulById(sysLiveSchedul); + //上一个直播还在直播,需要关闭上一个直播 + if(lastLiveSchedul != null && lastLiveSchedul.getLiveStatus().longValue() == 1){ + lastLiveSchedul.setLiveStatus(2L); + if(lastLiveSchedul.getLiveEndTime() == null){ + lastLiveSchedul.setLiveEndTime(sysLiveSchedul.getLiveStartTime()); + } + row = sysLiveSchedulService.updateSysLiveSchedul(lastLiveSchedul); + } + } + } + } + return toAjax(row); + } + + /** + * 删除直播排班 + */ + @PreAuthorize("@ss.hasPermi('custom:liveSchedul:remove')") + @Log(title = "直播排班", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(sysLiveSchedulService.deleteSysLiveSchedulByIds(ids)); + } + + /** + * 开播、下播 + */ + @PreAuthorize("@ss.hasPermi('custom:liveSchedul:edit')") + @Log(title = "开播下播", businessType = BusinessType.UPDATE) + @GetMapping(value = "/updateLiveStatus") + public AjaxResult updateLiveStatus(SysLiveSchedul sysLiveSchedul) + { + if(sysLiveSchedul.getId() == null || sysLiveSchedul.getLiveStatus() == null){ + return AjaxResult.error("操作失败"); + } + int row = 0; + if(sysLiveSchedul.getLiveStatus().longValue() == 1){ + row = sysLiveSchedulService.updateSysLiveSchedul(sysLiveSchedul); + if(row > 0){ + sysLiveSchedul = sysLiveSchedulService.selectSysLiveSchedulById(sysLiveSchedul.getId()); + if(sysLiveSchedul != null && sysLiveSchedul.getLiveStatus() != null){ + //开播 + if(sysLiveSchedul.getLiveStatus().longValue() == 1){ + SysLiveSchedul lastLiveSchedul = sysLiveSchedulService.getLastLiveSchedulById(sysLiveSchedul); + //上一个直播还在直播,需要关闭上一个直播 + if(lastLiveSchedul != null && lastLiveSchedul.getLiveStatus().longValue() == 1){ + lastLiveSchedul.setLiveStatus(2L); + if(lastLiveSchedul.getLiveEndTime() == null){ + lastLiveSchedul.setLiveEndTime(sysLiveSchedul.getLiveStartTime()); + } + row = sysLiveSchedulService.updateSysLiveSchedul(lastLiveSchedul); + } + } + } + } + }else{ + SysLiveSchedul newLiveSchedul = sysLiveSchedulService.selectSysLiveSchedulById(sysLiveSchedul.getId()); + if(newLiveSchedul != null && newLiveSchedul.getLiveEndTime() == null){ + sysLiveSchedul.setLiveEndTime(new Date()); + } + row = sysLiveSchedulService.updateSysLiveSchedul(sysLiveSchedul); + } + return toAjax(row); + } +} \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysLiveSchedul.java b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysLiveSchedul.java new file mode 100644 index 000000000..1af68872a --- /dev/null +++ b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysLiveSchedul.java @@ -0,0 +1,83 @@ +package com.stdiet.custom.domain; + +import java.util.Date; +import java.util.List; +import java.util.Map; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.stdiet.common.annotation.Excel; +import com.stdiet.common.core.domain.BaseEntity; +import lombok.Data; + +/** + * 直播排班对象 sys_live_schedul + * + * @author xzj + * @date 2021-05-12 + */ +@Data +public class SysLiveSchedul extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** $column.columnComment */ + private Long id; + + /** 直播间序号 */ + @Excel(name = "直播间序号") + private Integer liveRoom; + + /** 排班日期 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "排班日期", width = 30, dateFormat = "yyyy-MM-dd") + private Date liveSchedulDate; + + /** 直播开始时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm") + @Excel(name = "直播开始时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date liveStartTime; + + /** 直播结束时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm") + @Excel(name = "直播结束时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date liveEndTime; + + /** 直播营养师 */ + @Excel(name = "直播营养师") + private Long liveNutritionistId; + + /** 直播运营 */ + @Excel(name = "直播运营") + private Long liveOperatorId; + + /** 直播策划 */ + @Excel(name = "直播策划") + private Long livePlannerId; + + /** 微信账号管理的进粉渠道 */ + @Excel(name = "微信账号管理的进粉渠道") + private Integer fanChannel; + + /** 直播状态,0未开播 1已开播 2已下播 */ + @Excel(name = "直播状态,0未开播 1已开播 2已下播") + private Long liveStatus; + + /** 删除标识,默认0 */ + private Integer delFlag; + + //微信账号ID + private Long wxAccountId; + + //直播间名称 + private String liveRoomName; + + private String liveNutritionistName; + + private String livePlannerName; + + private String liveOperatorName; + + private String fanChannelName; + + private List<Map<String,Object>> wxAccountList; +} \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysLiveSchedulMapper.java b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysLiveSchedulMapper.java new file mode 100644 index 000000000..a64893bbc --- /dev/null +++ b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysLiveSchedulMapper.java @@ -0,0 +1,80 @@ +package com.stdiet.custom.mapper; + +import java.util.List; +import com.stdiet.custom.domain.SysLiveSchedul; + +/** + * 直播排班Mapper接口 + * + * @author xzj + * @date 2021-05-12 + */ +public interface SysLiveSchedulMapper +{ + /** + * 查询直播排班 + * + * @param id 直播排班ID + * @return 直播排班 + */ + public SysLiveSchedul selectSysLiveSchedulById(Long id); + + /** + * 查询直播排班列表 + * + * @param sysLiveSchedul 直播排班 + * @return 直播排班集合 + */ + public List<SysLiveSchedul> selectSysLiveSchedulList(SysLiveSchedul sysLiveSchedul); + + /** + * 新增直播排班 + * + * @param sysLiveSchedul 直播排班 + * @return 结果 + */ + public int insertSysLiveSchedul(SysLiveSchedul sysLiveSchedul); + + /** + * 修改直播排班 + * + * @param sysLiveSchedul 直播排班 + * @return 结果 + */ + public int updateSysLiveSchedul(SysLiveSchedul sysLiveSchedul); + + /** + * 删除直播排班 + * + * @param id 直播排班ID + * @return 结果 + */ + public int deleteSysLiveSchedulById(Long id); + + /** + * 批量删除直播排班 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deleteSysLiveSchedulByIds(Long[] ids); + + /** + * 根据直播时间查询是否重叠 + */ + public SysLiveSchedul getLiveSchedulByLiveTime(SysLiveSchedul sysLiveSchedul); + + /** + * 更新部分字段 + * @param sysLiveSchedul + * @return + */ + public int updateSysLiveSchedulById(SysLiveSchedul sysLiveSchedul); + + /** + * 根据ID查询上一条记录 + * @param sysLiveSchedul + * @return + */ + public SysLiveSchedul getLastLiveSchedulById(SysLiveSchedul sysLiveSchedul); +} \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysLiveSchedulService.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysLiveSchedulService.java new file mode 100644 index 000000000..cd75428c4 --- /dev/null +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysLiveSchedulService.java @@ -0,0 +1,80 @@ +package com.stdiet.custom.service; + +import java.util.List; +import com.stdiet.custom.domain.SysLiveSchedul; + +/** + * 直播排班Service接口 + * + * @author xzj + * @date 2021-05-12 + */ +public interface ISysLiveSchedulService +{ + /** + * 查询直播排班 + * + * @param id 直播排班ID + * @return 直播排班 + */ + public SysLiveSchedul selectSysLiveSchedulById(Long id); + + /** + * 查询直播排班列表 + * + * @param sysLiveSchedul 直播排班 + * @return 直播排班集合 + */ + public List<SysLiveSchedul> selectSysLiveSchedulList(SysLiveSchedul sysLiveSchedul); + + /** + * 新增直播排班 + * + * @param sysLiveSchedul 直播排班 + * @return 结果 + */ + public int insertSysLiveSchedul(SysLiveSchedul sysLiveSchedul); + + /** + * 修改直播排班 + * + * @param sysLiveSchedul 直播排班 + * @return 结果 + */ + public int updateSysLiveSchedul(SysLiveSchedul sysLiveSchedul); + + /** + * 批量删除直播排班 + * + * @param ids 需要删除的直播排班ID + * @return 结果 + */ + public int deleteSysLiveSchedulByIds(Long[] ids); + + /** + * 删除直播排班信息 + * + * @param id 直播排班ID + * @return 结果 + */ + public int deleteSysLiveSchedulById(Long id); + + /** + * 根据直播时间查询是否重叠 + */ + public SysLiveSchedul getLiveSchedulByLiveTime(SysLiveSchedul sysLiveSchedul); + + /** + * 更新部分字段 + * @param sysLiveSchedul + * @return + */ + public int updateSysLiveSchedulById(SysLiveSchedul sysLiveSchedul); + + /** + * 根据ID查询上一条记录 + * @param sysLiveSchedul + * @return + */ + public SysLiveSchedul getLastLiveSchedulById(SysLiveSchedul sysLiveSchedul); +} \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysLiveSchedulServiceImpl.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysLiveSchedulServiceImpl.java new file mode 100644 index 000000000..8e15c6662 --- /dev/null +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysLiveSchedulServiceImpl.java @@ -0,0 +1,126 @@ +package com.stdiet.custom.service.impl; + +import java.util.List; +import com.stdiet.common.utils.DateUtils; +import lombok.Data; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.stdiet.custom.mapper.SysLiveSchedulMapper; +import com.stdiet.custom.domain.SysLiveSchedul; +import com.stdiet.custom.service.ISysLiveSchedulService; + +/** + * 直播排班Service业务层处理 + * + * @author xzj + * @date 2021-05-12 + */ +@Service +public class SysLiveSchedulServiceImpl implements ISysLiveSchedulService +{ + @Autowired + private SysLiveSchedulMapper sysLiveSchedulMapper; + + /** + * 查询直播排班 + * + * @param id 直播排班ID + * @return 直播排班 + */ + @Override + public SysLiveSchedul selectSysLiveSchedulById(Long id) + { + return sysLiveSchedulMapper.selectSysLiveSchedulById(id); + } + + /** + * 查询直播排班列表 + * + * @param sysLiveSchedul 直播排班 + * @return 直播排班 + */ + @Override + public List<SysLiveSchedul> selectSysLiveSchedulList(SysLiveSchedul sysLiveSchedul) + { + return sysLiveSchedulMapper.selectSysLiveSchedulList(sysLiveSchedul); + } + + /** + * 新增直播排班 + * + * @param sysLiveSchedul 直播排班 + * @return 结果 + */ + @Override + public int insertSysLiveSchedul(SysLiveSchedul sysLiveSchedul) + { + sysLiveSchedul.setCreateTime(DateUtils.getNowDate()); + return sysLiveSchedulMapper.insertSysLiveSchedul(sysLiveSchedul); + } + + /** + * 修改直播排班 + * + * @param sysLiveSchedul 直播排班 + * @return 结果 + */ + @Override + public int updateSysLiveSchedul(SysLiveSchedul sysLiveSchedul) + { + sysLiveSchedul.setUpdateTime(DateUtils.getNowDate()); + return sysLiveSchedulMapper.updateSysLiveSchedul(sysLiveSchedul); + } + + /** + * 批量删除直播排班 + * + * @param ids 需要删除的直播排班ID + * @return 结果 + */ + @Override + public int deleteSysLiveSchedulByIds(Long[] ids) + { + return sysLiveSchedulMapper.deleteSysLiveSchedulByIds(ids); + } + + /** + * 删除直播排班信息 + * + * @param id 直播排班ID + * @return 结果 + */ + @Override + public int deleteSysLiveSchedulById(Long id) + { + return sysLiveSchedulMapper.deleteSysLiveSchedulById(id); + } + + /** + * 根据直播时间查询是否重叠 + */ + @Override + public SysLiveSchedul getLiveSchedulByLiveTime(SysLiveSchedul sysLiveSchedul){ + return sysLiveSchedulMapper.getLiveSchedulByLiveTime(sysLiveSchedul); + } + + /** + * 更新部分字段 + * @param sysLiveSchedul + * @return + */ + @Override + public int updateSysLiveSchedulById(SysLiveSchedul sysLiveSchedul){ + sysLiveSchedul.setUpdateTime(DateUtils.getNowDate()); + return sysLiveSchedulMapper.updateSysLiveSchedulById(sysLiveSchedul); + } + + /** + * 根据ID查询上一条记录 + * @param sysLiveSchedul + * @return + */ + @Override + public SysLiveSchedul getLastLiveSchedulById(SysLiveSchedul sysLiveSchedul){ + return sysLiveSchedulMapper.getLastLiveSchedulById(sysLiveSchedul); + } +} \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysOrderPauseServiceImpl.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysOrderPauseServiceImpl.java index c4255ddfc..9dbdddceb 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysOrderPauseServiceImpl.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysOrderPauseServiceImpl.java @@ -98,10 +98,13 @@ public class SysOrderPauseServiceImpl implements ISysOrderPauseService public int deleteSysOrderPauseByIds(Long[] ids) { SysOrderPause sysOrderPause = selectSysOrderPauseById(ids[0]); - if(sysOrderPauseMapper.deleteSysOrderPauseByIds(ids) > 0){ - return sysOrderService.updateOrderServerStartEndDate(sysOrderPause.getCusId()); + int row = sysOrderPauseMapper.deleteSysOrderPauseByIds(ids); + if(row > 0){ + if(sysOrderPause != null && sysOrderPause.getCusId() != null){ + sysOrderService.updateOrderServerStartEndDate(sysOrderPause.getCusId()); + } } - return 0; + return row; } /** diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysLiveSchedulMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysLiveSchedulMapper.xml new file mode 100644 index 000000000..878d805bc --- /dev/null +++ b/stdiet-custom/src/main/resources/mapper/custom/SysLiveSchedulMapper.xml @@ -0,0 +1,196 @@ +<?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.stdiet.custom.mapper.SysLiveSchedulMapper"> + + <resultMap type="SysLiveSchedul" id="SysLiveSchedulResult"> + <result property="id" column="id" /> + <result property="liveRoom" column="live_room" /> + <result property="liveSchedulDate" column="live_schedul_date" /> + <result property="liveStartTime" column="live_start_time" /> + <result property="liveEndTime" column="live_end_time" /> + <result property="liveNutritionistId" column="live_nutritionist_id" /> + <result property="liveOperatorId" column="live_operator_id" /> + <result property="livePlannerId" column="live_planner_id" /> + <result property="fanChannel" column="fan_channel" /> + <result property="liveStatus" column="live_status" /> + <result property="createTime" column="create_time" /> + <result property="createBy" column="create_by" /> + <result property="updateTime" column="update_time" /> + <result property="updateBy" column="update_by" /> + <result property="delFlag" column="del_flag" /> + + <result property="liveRoomName" column="live_room_name"></result> + <result property="liveNutritionistName" column="live_nutritionist_name"></result> + <result property="livePlannerName" column="live_planner_name"></result> + <result property="liveOperatorName" column="live_operator_name"></result> + <result property="fanChannelName" column="fan_channel_name"></result> + + <!-- 根据渠道查询对应微信号(微信账号分配表中) --> + <association property="wxAccountList" column="fan_channel" select="getWxAccountListByFanChannel"/> + </resultMap> + + <resultMap type="SysLiveSchedul" id="SysLiveSchedulResultSigle"> + <result property="id" column="id" /> + <result property="liveRoom" column="live_room" /> + <result property="liveSchedulDate" column="live_schedul_date" /> + <result property="liveStartTime" column="live_start_time" /> + <result property="liveEndTime" column="live_end_time" /> + <result property="liveNutritionistId" column="live_nutritionist_id" /> + <result property="liveOperatorId" column="live_operator_id" /> + <result property="livePlannerId" column="live_planner_id" /> + <result property="fanChannel" column="fan_channel" /> + <result property="liveStatus" column="live_status" /> + <result property="createTime" column="create_time" /> + <result property="createBy" column="create_by" /> + <result property="updateTime" column="update_time" /> + <result property="updateBy" column="update_by" /> + <result property="delFlag" column="del_flag" /> + </resultMap> + + <sql id="selectSysLiveSchedulVo"> + id, live_room, live_schedul_date,live_start_time, live_end_time, live_nutritionist_id, live_operator_id, live_planner_id, fan_channel, live_status, create_time, create_by, update_time, update_by, del_flag + </sql> + + <select id="selectSysLiveSchedulList" parameterType="SysLiveSchedul" resultMap="SysLiveSchedulResult"> + select + slc.id, slc.live_room, slc.live_schedul_date,slc.live_start_time, slc.live_end_time, slc.live_nutritionist_id, slc.live_operator_id, slc.live_planner_id, slc.fan_channel, slc.live_status, slc.create_time, slc.create_by + ,slt.dict_label as live_room_name,su_nutritionist.nick_name as live_nutritionist_name, su_plan.nick_name as live_planner_name, + su_operator.nick_name as live_operator_name,fc.dict_label as fan_channel_name + from sys_live_schedul slc + left join (SELECT dict_label, dict_value FROM sys_dict_data WHERE dict_type = 'sys_live_type') AS slt ON slt.dict_value = slc.live_room + left join (SELECT dict_label, dict_value FROM sys_dict_data WHERE dict_type = 'fan_channel') AS fc ON fc.dict_value = slc.fan_channel + left join sys_user su_nutritionist on su_nutritionist.user_id = slc.live_nutritionist_id and su_nutritionist.del_flag = 0 + left join sys_user su_plan on su_plan.user_id = slc.live_planner_id and su_plan.del_flag = 0 + left join sys_user su_operator on su_operator.user_id = slc.live_operator_id and su_operator.del_flag = 0 + where slc.del_flag = 0 + <if test="liveSchedulDate != null"> + and date_format(slc.live_schedul_date,'%y%m%d') = date_format(#{liveSchedulDate},'%y%m%d') + </if> + <if test="liveRoom != null"> + and slc.live_room = #{liveRoom} + </if> + <if test="fanChannel != null"> + and slc.fan_channel = #{fanChannel} + </if> + <if test="wxAccountId != null"> + and slc.fan_channel = (SELECT swd.account_id FROM sys_wx_distribution AS swd where swd.wechat_account = #{wxAccountId} and swd.del_flag = 0 limit 1) + </if> + order by slc.live_schedul_date desc,slc.live_start_time desc ,slc.live_room asc + </select> + + <select id="selectSysLiveSchedulById" parameterType="Long" resultMap="SysLiveSchedulResultSigle"> + select + <include refid="selectSysLiveSchedulVo"/> + from sys_live_schedul + where id = #{id} and del_flag = 0 + </select> + + <insert id="insertSysLiveSchedul" parameterType="SysLiveSchedul" useGeneratedKeys="true" keyProperty="id"> + insert into sys_live_schedul + <trim prefix="(" suffix=")" suffixOverrides=","> + <if test="liveRoom != null">live_room,</if> + <if test="liveSchedulDate != null">live_schedul_date,</if> + <if test="liveStartTime != null">live_start_time,</if> + <if test="liveEndTime != null">live_end_time,</if> + <if test="liveNutritionistId != null">live_nutritionist_id,</if> + <if test="liveOperatorId != null">live_operator_id,</if> + <if test="livePlannerId != null">live_planner_id,</if> + <if test="fanChannel != null">fan_channel,</if> + <if test="liveStatus != null">live_status,</if> + <if test="createTime != null">create_time,</if> + <if test="createBy != null">create_by,</if> + <if test="updateTime != null">update_time,</if> + <if test="updateBy != null">update_by,</if> + <if test="delFlag != null">del_flag,</if> + </trim> + <trim prefix="values (" suffix=")" suffixOverrides=","> + <if test="liveRoom != null">#{liveRoom},</if> + <if test="liveSchedulDate != null">#{liveSchedulDate},</if> + <if test="liveStartTime != null">#{liveStartTime},</if> + <if test="liveEndTime != null">#{liveEndTime},</if> + <if test="liveNutritionistId != null">#{liveNutritionistId},</if> + <if test="liveOperatorId != null">#{liveOperatorId},</if> + <if test="livePlannerId != null">#{livePlannerId},</if> + <if test="fanChannel != null">#{fanChannel},</if> + <if test="liveStatus != null">#{liveStatus},</if> + <if test="createTime != null">#{createTime},</if> + <if test="createBy != null">#{createBy},</if> + <if test="updateTime != null">#{updateTime},</if> + <if test="updateBy != null">#{updateBy},</if> + <if test="delFlag != null">#{delFlag},</if> + </trim> + </insert> + + <update id="updateSysLiveSchedul" parameterType="SysLiveSchedul"> + update sys_live_schedul + <trim prefix="SET" suffixOverrides=","> + <if test="liveRoom != null">live_room = #{liveRoom},</if> + <if test="liveSchedulDate != null">live_schedul_date = #{liveSchedulDate},</if> + <if test="liveStartTime != null">live_start_time = #{liveStartTime},</if> + <if test="liveEndTime != null">live_end_time = #{liveEndTime},</if> + <if test="liveNutritionistId != null">live_nutritionist_id = #{liveNutritionistId},</if> + <if test="liveOperatorId != null">live_operator_id = #{liveOperatorId},</if> + <if test="livePlannerId != null">live_planner_id = #{livePlannerId},</if> + <if test="fanChannel != null">fan_channel = #{fanChannel},</if> + <if test="liveStatus != null">live_status = #{liveStatus},</if> + <if test="createTime != null">create_time = #{createTime},</if> + <if test="createBy != null">create_by = #{createBy},</if> + <if test="updateTime != null">update_time = #{updateTime},</if> + <if test="updateBy != null">update_by = #{updateBy},</if> + <if test="delFlag != null">del_flag = #{delFlag},</if> + </trim> + where id = #{id} + </update> + + <update id="updateSysLiveSchedulById" parameterType="SysLiveSchedul"> + update sys_live_schedul set live_room = #{liveRoom},live_schedul_date = #{liveSchedulDate},live_start_time = #{liveStartTime}, + live_end_time = #{liveEndTime},live_nutritionist_id = #{liveNutritionistId},live_operator_id = #{liveOperatorId},live_planner_id = #{livePlannerId}, + fan_channel = #{fanChannel},live_status = #{liveStatus},update_time = #{updateTime} + where id = #{id} + </update> + + <update id="deleteSysLiveSchedulById" parameterType="Long"> + update sys_live_schedul set del_flag = 1 where id = #{id} + </update> + + <update id="deleteSysLiveSchedulByIds" parameterType="String"> + update sys_live_schedul set del_flag = 1 where id in + <foreach item="id" collection="array" open="(" separator="," close=")"> + #{id} + </foreach> + </update> + + <!-- 根据渠道查询该渠道下分配的微信号 --> + <select id="getWxAccountListByFanChannel" parameterType="Integer" resultType="Map"> + SELECT su.nick_name as nickName,swsa.wx_account as wxAccount,asg.dict_label as saleGroupName + FROM sys_wx_distribution AS swd + lEFT JOIN sys_wx_sale_account swsa ON swsa.id = swd.wechat_account and swsa.del_flag = 0 + LEFT JOIN sys_user su ON su.user_id = swd.user_id AND su.del_flag = 0 + LEFT JOIN (SELECT dict_label, dict_value FROM sys_dict_data WHERE dict_type = 'sale_group') AS asg ON asg.dict_value = swd.sale_group_id + where swd.account_id = #{fan_channel} and swd.del_flag = 0 + </select> + + <!-- 查询直播时间范围是否重叠 --> + <select id="getLiveSchedulByLiveTime" parameterType="SysLiveSchedul" resultMap="SysLiveSchedulResultSigle"> + select + <include refid="selectSysLiveSchedulVo"/> + from sys_live_schedul + where live_room = #{liveRoom} and del_flag = 0 + AND ( + (#{liveStartTime} >= live_start_time AND live_end_time > #{liveStartTime}) + <if test="liveEndTime != null"> + OR (#{liveEndTime} > live_start_time AND live_end_time >= #{liveEndTime}) + </if> + ) + limit 1 + </select> + + <select id="getLastLiveSchedulById" parameterType="SysLiveSchedul" resultMap="SysLiveSchedulResultSigle"> + select + <include refid="selectSysLiveSchedulVo"/> + from sys_live_schedul + where id <![CDATA[ < ]]> #{id} and del_flag = 0 and live_room = #{liveRoom} order by live_start_time desc limit 1 + </select> +</mapper> \ No newline at end of file diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysOrderPauseMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysOrderPauseMapper.xml index c81aff4a7..b5af6eb3d 100644 --- a/stdiet-custom/src/main/resources/mapper/custom/SysOrderPauseMapper.xml +++ b/stdiet-custom/src/main/resources/mapper/custom/SysOrderPauseMapper.xml @@ -114,8 +114,8 @@ <!-- 根据用户ID、时间范围查询数量 --> <select id="getCountByCusIdAndPauseDate" parameterType="SysOrderPause" resultType="int"> select count(id) from sys_recipes_pause where del_flag = 0 and cus_id = #{cusId} - AND (#{pauseStartDate} >= pause_start_date AND pause_end_date >= #{pauseStartDate} - OR #{pauseEndDate} >= pause_start_date AND pause_end_date >= #{pauseEndDate}) + AND ((#{pauseStartDate} >= pause_start_date AND pause_end_date >= #{pauseStartDate}) + OR (#{pauseEndDate} >= pause_start_date AND pause_end_date >= #{pauseEndDate})) <if test="id != null"> and id <![CDATA[ <> ]]> #{id} </if> diff --git a/stdiet-ui/src/api/custom/liveSchedul.js b/stdiet-ui/src/api/custom/liveSchedul.js new file mode 100644 index 000000000..1e9b49b5c --- /dev/null +++ b/stdiet-ui/src/api/custom/liveSchedul.js @@ -0,0 +1,63 @@ +import request from '@/utils/request' + +// 查询直播排班列表 +export function listLiveSchedul(query) { + return request({ + url: '/custom/liveSchedul/list', + method: 'get', + params: query + }) +} + +// 查询直播排班详细 +export function getLiveSchedul(id) { + return request({ + url: '/custom/liveSchedul/' + id, + method: 'get' + }) +} + +// 新增直播排班 +export function addLiveSchedul(data) { + return request({ + url: '/custom/liveSchedul', + method: 'post', + data: data + }) +} + +// 修改直播排班 +export function updateLiveSchedul(data) { + return request({ + url: '/custom/liveSchedul', + method: 'put', + data: data + }) +} + +// 删除直播排班 +export function delLiveSchedul(id) { + return request({ + url: '/custom/liveSchedul/' + id, + method: 'delete' + }) +} + +// 导出直播排班 +export function exportLiveSchedul(query) { + return request({ + url: '/custom/liveSchedul/export', + method: 'get', + params: query + }) +} + + +// 更新直播状态 +export function updateLiveStatus(data) { + return request({ + url: '/custom/liveSchedul/updateLiveStatus', + method: 'get', + params: data + }) +} diff --git a/stdiet-ui/src/views/custom/liveSchedul/index.vue b/stdiet-ui/src/views/custom/liveSchedul/index.vue new file mode 100644 index 000000000..36ce6d0c7 --- /dev/null +++ b/stdiet-ui/src/views/custom/liveSchedul/index.vue @@ -0,0 +1,603 @@ +<template> + <div class="app-container"> + <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px"> + <el-form-item label="直播日期" prop="liveSchedulDate"> + <el-date-picker clearable size="small" style="width: 200px" + v-model="queryParams.liveSchedulDate" + type="date" + value-format="yyyy-MM-dd" + placeholder="选择直播日期"> + </el-date-picker> + </el-form-item> + <el-form-item label="直播间" prop="liveRoom"> + <el-select + v-model="queryParams.liveRoom" + placeholder="请选择直播间" + clearable + filterable + size="small" + > + <el-option + v-for="dict in liveTypeOptions" + :key="dict.dictValue" + :label="dict.dictLabel" + :value="parseInt(dict.dictValue)" + /> + </el-select> + </el-form-item> + <el-form-item label="所属账号" prop="fanChannel"> + <el-select + v-model="queryParams.fanChannel" + placeholder="请选择账号渠道" + clearable + filterable + size="small" + > + <el-option + v-for="dict in fanChanneloptions" + :key="dict.dictValue" + :label="dict.dictLabel" + :value="parseInt(dict.dictValue)" + /> + </el-select> + </el-form-item> + <el-form-item label="微信号" prop="wxAccountId"> + <el-select + v-model="queryParams.wxAccountId" + filterable + placeholder="请选择微信号" + clearable + size="small" + > + <el-option + v-for="dict in wxAccountList" + :key="dict.id" + :label="dict.wxAccount" + :value="parseInt(dict.id)" + /> + </el-select> + </el-form-item> + + + + <el-form-item style="margin-left:10px;"> + <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> + <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> + </el-form-item> + </el-form> + + <el-row :gutter="10" class="mb8"> + <el-col :span="1.5"> + <el-button + type="primary" + icon="el-icon-plus" + size="mini" + @click="handleAdd" + v-hasPermi="['custom:liveSchedul:add']" + >新增</el-button> + </el-col> + <el-col :span="1.5"> + <el-button + type="success" + icon="el-icon-edit" + size="mini" + :disabled="single" + @click="handleUpdate" + v-hasPermi="['custom:liveSchedul:edit']" + >修改</el-button> + </el-col> + <el-col :span="1.5"> + <el-button + type="danger" + icon="el-icon-delete" + size="mini" + :disabled="multiple" + @click="handleDelete" + v-hasPermi="['custom:liveSchedul:remove']" + >删除</el-button> + </el-col> + <!--<el-col :span="1.5"> + <el-button + type="warning" + icon="el-icon-download" + size="mini" + @click="handleExport" + v-hasPermi="['custom:liveSchedul:export']" + >导出</el-button> + </el-col>--> + <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> + </el-row> + + <el-table v-loading="loading" :data="liveSchedulList" :span-method="objectSpanMethod" @selection-change="handleSelectionChange"> + <el-table-column type="selection" width="55" align="center" /> + <el-table-column label="直播日期" align="center" prop="liveSchedulDate" width="180"> + <template slot-scope="scope"> + <span>{{ parseTime(scope.row.liveSchedulDate, '{y}-{m}-{d}') }}</span> + </template> + </el-table-column> + <el-table-column label="直播间" align="center" prop="liveRoomName" /> + + <el-table-column label="直播时间" align="center" prop="liveStartTime" width="180"> + <template slot-scope="scope"> + <span>{{ parseTime(scope.row.liveStartTime, '{h}:{i}') }}-{{ parseTime(scope.row.liveEndTime, '{h}:{i}') }}</span> + </template> + </el-table-column> + <el-table-column label="直播状态" align="center" prop="liveStatus"> + <template slot-scope="scope"> + <span><el-tag :type="scope.row.liveStatus == 0 ? 'info' : (scope.row.liveStatus == 1 ? 'success' : '')">{{scope.row.liveStatus == 0 ? '未开播' : (scope.row.liveStatus == 1 ? '直播中' : '已下播')}}</el-tag></span> + </template> + </el-table-column> + <el-table-column label="直播营养师" align="center" prop="liveNutritionistName" /> + <el-table-column label="直播运营" align="center" prop="liveOperatorName" /> + <el-table-column label="直播策划" align="center" prop="livePlannerName" /> + <el-table-column label="所属账号" align="center" prop="fanChannelName" /> + <el-table-column label="接粉微信号" align="center" prop="wxAccountList"> + <template slot-scope="scope"> + <el-popover + placement="left" + width="390" + trigger="click"> + <el-table :data="scope.row.wxAccountList" style="width:370;height: 400px;overflow: auto;"> + <el-table-column width="100" property="nickName" label="销售"></el-table-column> + <el-table-column width="120" property="wxAccount" label="微信号"></el-table-column> + <el-table-column width="120" property="saleGroupName" label="销售组别"></el-table-column> + </el-table> + <el-button slot="reference">详情</el-button> + </el-popover> + </template> + </el-table-column> + <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="300"> + <template slot-scope="scope"><!-- scope.row.statusTrueName,scope.row.statusFalseName --> + <el-switch + v-hasPermi="['custom:liveSchedul:edit']" + v-model="scope.row.status" + :active-text="scope.row.statusTrueName" + :inactive-text="scope.row.statusFalseName" + @change="updateLiveStatus($event, scope.row)" + > + </el-switch> + <el-button + style="margin-left:16px" + size="normal" + type="text" + icon="el-icon-edit" + @click="handleUpdate(scope.row)" + v-hasPermi="['custom:liveSchedul:edit']" + >修改</el-button> + <el-button + size="normal" + type="text" + icon="el-icon-delete" + @click="handleDelete(scope.row)" + v-hasPermi="['custom:liveSchedul:remove']" + >删除</el-button> + </template> + </el-table-column> + </el-table> + + <pagination + v-show="total>0" + :total="total" + :page.sync="queryParams.pageNum" + :limit.sync="queryParams.pageSize" + @pagination="getList" + /> + + <!-- 添加或修改直播排班对话框 --> + <el-dialog :title="title" :visible.sync="open" width="600px" append-to-body> + <el-form ref="form" :model="form" :rules="rules" label-width="80px"> + + <el-form-item label="直播日期" prop="liveSchedulDate"> + <el-date-picker clearable size="small" style="width: 200px" + v-model="form.liveSchedulDate" + type="date" + value-format="yyyy-MM-dd" + placeholder="选择直播日期"> + </el-date-picker> + </el-form-item> + <el-form-item label="直播间" prop="liveRoom"> + <el-select + v-model="form.liveRoom" + placeholder="请选择直播间" + clearable + filterable + size="small" + > + <el-option + v-for="dict in liveTypeOptions" + :key="dict.dictValue" + :label="dict.dictLabel" + :value="parseInt(dict.dictValue)" + /> + </el-select> + </el-form-item> + <!--<el-form-item label="开始时间" prop="liveStartTime"> + <el-date-picker clearable size="small" style="width: 200px" + v-model="form.liveStartTime" + type="date" + value-format="yyyy-MM-dd" + placeholder="选择开始时间"> + </el-date-picker> + </el-form-item>--> + <el-form-item label="直播时间" prop="liveTime"> + <el-time-picker + v-model="form.startTime" + value-format="yyyy-MM-dd HH:mm" + start-placeholder="开始时间" + placeholder="选择开始时间(必须)"> + </el-time-picker> + <span style="margin-left:10px;margin-right:10px">至</span> + <el-time-picker + value-format="yyyy-MM-dd HH:mm" + v-model="form.endTime" + placeholder="选择结束时间(非必须)"> + </el-time-picker> + + <!--<el-time-picker + is-range + value-format="yyyy-MM-dd HH:mm" + v-model="form.liveTime" + range-separator="至" + start-placeholder="开始时间" + end-placeholder="结束时间" + placeholder="选择时间范围"> + </el-time-picker>--> + </el-form-item> + <!--<el-form-item label="结束时间" prop="liveEndTime"> + <el-date-picker clearable size="small" style="width: 200px" + v-model="form.liveEndTime" + type="date" + value-format="yyyy-MM-dd" + placeholder="选择结束时间"> + </el-date-picker> + </el-form-item>--> + <el-form-item label="营养师" prop="liveNutritionistId"> + <el-select + v-model="form.liveNutritionistId" + placeholder="请选择营养师" + clearable + filterable + size="small" + > + <el-option + v-for="dict in nutritionistIdOptions" + :key="dict.dictValue" + :label="dict.dictLabel" + :value="parseInt(dict.dictValue)" + /> + </el-select> + </el-form-item> + <el-form-item label="运营" prop="liveOperatorId"> + <el-select + v-model="form.liveOperatorId" + placeholder="请选择运营" + clearable + filterable + size="small" + > + <el-option + v-for="dict in operatorIdOptions" + :key="dict.dictValue" + :label="dict.dictLabel" + :value="parseInt(dict.dictValue)" + /> + </el-select> + </el-form-item> + <el-form-item label="策划" prop="livePlannerId"> + <el-select + v-model="form.livePlannerId" + placeholder="请选择策划" + clearable + filterable + size="small" + > + <el-option + v-for="dict in plannerIdOptions" + :key="dict.dictValue" + :label="dict.dictLabel" + :value="parseInt(dict.dictValue)" + /> + </el-select> + </el-form-item> + <el-form-item label="所属账号" prop="fanChannel"> + <el-select + v-model="form.fanChannel" + placeholder="请选择所属账号渠道" + clearable + filterable + size="small" + > + <el-option + v-for="dict in fanChanneloptions" + :key="dict.dictValue" + :label="dict.dictLabel" + :value="parseInt(dict.dictValue)" + /> + </el-select> + <span style="margin-left:10px;color:#1890ff">该账号与销售接粉微信号绑定</span> + </el-form-item> + <el-form-item label="直播状态" prop="liveStatus"> + <el-select + v-model="form.liveStatus" + placeholder="请选择状态" + clearable + filterable + size="small" + > + <el-option :key="0" :label="'未开播'" :value="parseInt('0')"/> + <el-option :key="1" :label="'开播中'" :value="parseInt('1')"/> + <el-option :key="2" :label="'已下播'" :value="parseInt('2')"/> + </el-select> + </el-form-item> + </el-form> + <div slot="footer" class="dialog-footer"> + <el-button type="primary" @click="submitForm">确 定</el-button> + <el-button @click="cancel">取 消</el-button> + </div> + </el-dialog> + </div> +</template> + +<script> +import { listLiveSchedul, getLiveSchedul, delLiveSchedul, addLiveSchedul, updateLiveSchedul, exportLiveSchedul,updateLiveStatus } from "@/api/custom/liveSchedul"; +import { listWxAccount } from "@/api/custom/wxAccount"; +import AutoHideInfo from "@/components/AutoHideInfo"; +import dayjs from "dayjs"; +const nowDate = dayjs().format("YYYY-MM-DD"); +const nowTime = dayjs().format("YYYY-MM-DD HH:mm"); +import { mapGetters } from "vuex"; +export default { + name: "LiveSchedul", + data() { + const checkLiveTime = (rule, value, callback) => { + if (!this.form.startTime || this.form.startTime == null) { + return callback(new Error("请选择开始时间")); + } + if (this.form.endTime != undefined && this.form.endTime != null && !dayjs(this.form.startTime).isBefore(dayjs(this.form.endTime))) { + return callback(new Error("结束时间必须在开始时间之后")); + } + callback(); + }; + return { + // 遮罩层 + loading: true, + // 选中数组 + ids: [], + // 非单个禁用 + single: true, + // 非多个禁用 + multiple: true, + // 显示搜索条件 + showSearch: true, + // 总条数 + total: 0, + // 直播排班表格数据 + liveSchedulList: [], + // 弹出层标题 + title: "", + // 是否显示弹出层 + open: false, + // 查询参数 + queryParams: { + pageNum: 1, + pageSize: 10, + liveSchedulDate: nowDate, + liveRoom: null, + fanChannel: null, + wxAccountId: null + }, + // 表单参数 + form: { + }, + // 表单校验 + rules: { + liveSchedulDate: [{ required: true, trigger: "blur", message: "请选择直播日期" }], + liveRoom: [{ required: true, trigger: "blur", message: "请选择直播间" }], + liveTime: [ + //{ required: true, trigger: "blur", message: "请选择直播时间" }, + { required: true, trigger: "blur", validator: checkLiveTime } + ], + liveNutritionistId: [{ required: true, trigger: "blur", message: "请选择营养师" }], + fanChannel: [{ required: true, trigger: "blur", message: "请选择所属账号渠道" }], + }, + //直播间类型 + liveTypeOptions: [], + //接粉渠道 + fanChanneloptions: [], + //所有微信号 + wxAccountList:[] + }; + }, + components:{ + AutoHideInfo + }, + created() { + this.getList(); + this.getDicts("sys_live_type").then((response) => { + this.liveTypeOptions = response.data; + }); + this.getDicts("fan_channel").then((response) => { + this.fanChanneloptions = response.data; + }); + this.getListWxAccount(); + }, + computed: { + ...mapGetters([ + // 主营养师字典 + "nutritionistIdOptions", + // 策划字典 + "plannerIdOptions", + // 运营字典 + "operatorIdOptions" + ]), + }, + methods: { + /** 查询直播排班列表 */ + getList() { + this.loading = true; + listLiveSchedul(this.queryParams).then(response => { + this.liveSchedulList = response.rows; + if(this.liveSchedulList != null && this.liveSchedulList.length > 0){ + this.liveSchedulList.forEach((item,index) => { + item.status = (item.liveStatus == 0 || item.liveStatus == 2) ? false : true; + item.statusFalseName = item.liveStatus == 0 ? '未开播' : '已下播'; + item.statusTrueName = '已开播'; + }); + } + this.total = response.total; + this.loading = false; + }); + }, + //获取所有微信号 + getListWxAccount() { + listWxAccount(this.queryParams).then((response) => { + this.wxAccountList = response.rows; + }); + }, + // 取消按钮 + cancel() { + this.open = false; + this.reset(); + }, + // 表单重置 + reset() { + this.form = { + id: null, + liveRoom: null, + liveSchedulDate: nowDate, + liveStartTime: null, + liveEndTime: null, + startTime: dayjs().format("YYYY-MM-DD HH:mm"), + endTime: null, + liveNutritionistId: null, + liveOperatorId: null, + livePlannerId: null, + fanChannel: null, + liveStatus: 1, + createTime: null, + createBy: null, + updateTime: null, + updateBy: null, + delFlag: null + }; + this.resetForm("form"); + }, + /** 搜索按钮操作 */ + handleQuery() { + this.queryParams.pageNum = 1; + this.getList(); + }, + /** 重置按钮操作 */ + resetQuery() { + this.resetForm("queryForm"); + this.handleQuery(); + }, + // 多选框选中数据 + handleSelectionChange(selection) { + this.ids = selection.map(item => item.id) + this.single = selection.length!==1 + this.multiple = !selection.length + }, + /** 新增按钮操作 */ + handleAdd() { + this.reset(); + this.open = true; + this.title = "添加直播记录"; + }, + /** 修改按钮操作 */ + handleUpdate(row) { + this.reset(); + const id = row.id || this.ids + getLiveSchedul(id).then(response => { + response.data.startTime = response.data.liveStartTime; + response.data.endTime = response.data.liveEndTime; + this.form = response.data; + this.open = true; + this.title = "修改直播记录"; + }); + }, + //修改直播状态 + updateLiveStatus(newStatus, row){ + row.statusFalseName = '已下播'; + row.statusTrueName = '已开播'; + let param = { + id: row.id, + liveStatus: newStatus ? 1 : 2 + }; + updateLiveStatus(param).then(response => { + if(response.code == 200){ + this.getList(); + } + }); + }, + /** 提交按钮 */ + submitForm() { + this.$refs["form"].validate(valid => { + if (valid) { + //处理直播开始时间 + this.form.liveStartTime = this.form.liveSchedulDate + " " + this.form.startTime.substring(this.form.startTime.length - 5); + if(this.form.endTime == undefined || this.form.endTime == null){ + this.form.liveEndTime = ""; + }else{ + this.form.liveEndTime = this.form.liveSchedulDate + " " + this.form.endTime.substring(this.form.endTime.length -5); + } + if (this.form.id != null) { + updateLiveSchedul(this.form).then(response => { + if (response.code === 200) { + this.msgSuccess("修改成功"); + this.open = false; + this.getList(); + } + }); + } else { + addLiveSchedul(this.form).then(response => { + if (response.code === 200) { + this.msgSuccess("新增成功"); + this.open = false; + this.getList(); + } + }); + } + } + }); + }, + /** 删除按钮操作 */ + handleDelete(row) { + const ids = row.id || this.ids; + this.$confirm('是否确认删除直播排班编号为"' + ids + '"的数据项?', "警告", { + confirmButtonText: "确定", + cancelButtonText: "取消", + type: "warning" + }).then(function() { + return delLiveSchedul(ids); + }).then(() => { + this.getList(); + this.msgSuccess("删除成功"); + }).catch(function() {}); + }, + /** 导出按钮操作 */ + handleExport() { + const queryParams = this.queryParams; + this.$confirm('是否确认导出所有直播排班数据项?', "警告", { + confirmButtonText: "确定", + cancelButtonText: "取消", + type: "warning" + }).then(function() { + return exportLiveSchedul(queryParams); + }).then(response => { + this.download(response.msg); + }).catch(function() {}); + }, + objectSpanMethod({ row, column, rowIndex, columnIndex }) { + if (columnIndex === 0) { + return row.userSpan; + } else if (columnIndex === 1) { + return row.postSpan; + } + }, + wxAccountFormat(row){ + return (row.wxAccountList != null && row.wxAccountList.length > 0) ? row.wxAccountList : []; + } + } +}; +</script> \ No newline at end of file