This commit is contained in:
xiezhijun 2021-02-23 15:36:23 +08:00
commit 9de0e2bffc
69 changed files with 5156 additions and 2200 deletions

View File

@ -148,6 +148,7 @@ mybatis:
mapperLocations: classpath*:mapper/**/*Mapper.xml
# 加载全局的配置文件
configLocation: classpath:mybatis/mybatis-config.xml
typeHandlersPackage: com.stdiet.**.typehandler
# PageHelper分页插件
pagehelper:

View File

@ -148,6 +148,7 @@ mybatis:
mapperLocations: classpath*:mapper/**/*Mapper.xml
# 加载全局的配置文件
configLocation: classpath:mybatis/mybatis-config.xml
typeHandlersPackage: com.stdiet.**.typehandler
# PageHelper分页插件
pagehelper:

View File

@ -148,6 +148,7 @@ mybatis:
mapperLocations: classpath*:mapper/**/*Mapper.xml
# 加载全局的配置文件
configLocation: classpath:mybatis/mybatis-config.xml
typeHandlersPackage: com.stdiet.**.typehandler
# PageHelper分页插件
pagehelper:

View File

@ -1,23 +1,82 @@
package com.stdiet.web.controller.custom;
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.SysRecipes;
import com.stdiet.custom.domain.SysRecipesDailyDishes;
import com.stdiet.custom.service.ISysRecipesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/recipes")
@RequestMapping("/custom/recipes")
public class SysRecipesController extends BaseController {
@Autowired
private ISysRecipesService sysRecipesService;
/**
* 获取食谱详情
*
* @param resipesId
* @return
*/
@GetMapping(value = "/{resipesId}")
public AjaxResult getInfo(@PathVariable("resipesId") Long resipesId) {
return AjaxResult.success(sysRecipesService.selectSysRecipesByRecipesId(resipesId));
}
@Log(title = "食谱", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult addRecipes(@RequestBody SysRecipes sysRecipes) {
int rows = sysRecipesService.addRecipes(sysRecipes);
if (rows > 0) {
return AjaxResult.success(sysRecipes.getId());
} else {
return AjaxResult.error();
}
}
/**
* 修改食谱菜品
*
* @param sysRecipesDailyDishes
* @return
*/
@Log(title = "食谱菜品", businessType = BusinessType.UPDATE)
@PutMapping(value = "/dishes")
public AjaxResult edit(@RequestBody SysRecipesDailyDishes sysRecipesDailyDishes) {
return toAjax(sysRecipesService.updateDishesDetail(sysRecipesDailyDishes));
}
/**
* 添加菜品
*
* @param sysRecipesDailyDishes
* @return
*/
@Log(title = "食谱菜品", businessType = BusinessType.INSERT)
@PostMapping(value = "/dishes")
public AjaxResult add(@RequestBody SysRecipesDailyDishes sysRecipesDailyDishes) {
int rows = sysRecipesService.addDishes(sysRecipesDailyDishes);
if (rows > 0) {
return AjaxResult.success(sysRecipesDailyDishes.getId());
} else {
return AjaxResult.error();
}
}
/**
* 删除菜品
*
* @param id
* @return
*/
@Log(title = "食谱菜品", businessType = BusinessType.DELETE)
@DeleteMapping("/dishes/{id}")
public AjaxResult delete(@PathVariable Long id) {
return toAjax(sysRecipesService.deleteDishes(id));
}
}

View File

@ -1,5 +1,6 @@
package com.stdiet.custom.domain;
import com.alibaba.fastjson.JSONArray;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.stdiet.common.annotation.Excel;
import lombok.Data;
@ -74,6 +75,4 @@ public class SysDishes {
private List<SysDishesIngredient> igdList;
private List<SysDishesIngredient> detail;
}

View File

@ -1,8 +1,6 @@
package com.stdiet.custom.domain;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.math.BigDecimal;
@ -27,4 +25,11 @@ public class SysDishesIngredient extends SysIngredient {
private String remark;
private Long id;
private String cus_unit;
private String cus_weight;
}

View File

@ -1,47 +1,17 @@
package com.stdiet.custom.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.util.Date;
import java.util.List;
@Data
public class SysRecipes {
private static final long serialVersionUID = 1L;
private Long id;
private Integer numDay;
private Long cusId;
private List<SysDishes> dishes;
private Long planId;
private Integer reviewStatus;
/**
* 创建者
*/
private String createBy;
/**
* 创建时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
/**
* 更新者
*/
private String updateBy;
/**
* 更新时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
/**
* 备注
*/
private String remark;
private List<SysRecipesDaily> menus;
}

View File

@ -0,0 +1,34 @@
package com.stdiet.custom.domain;
import lombok.Data;
import java.util.Date;
import java.util.List;
@Data
public class SysRecipesDaily {
private Long id;
private Integer numDay;
private Date date;
private Long recipesId;
private Long cusId;
private Integer reviewStatus;
private Date createTime;
private String createBy;
private Date updateTime;
private String updateBy;
private String remark;
private List<SysRecipesDailyDishes> dishes;
}

View File

@ -0,0 +1,28 @@
package com.stdiet.custom.domain;
import com.alibaba.fastjson.JSONArray;
import lombok.Data;
import java.util.Date;
import java.util.List;
@Data
public class SysRecipesDailyDishes {
private Long id;
private Long menuId;
private String name;
private Long dishesId;
private JSONArray detail;
private String methods;
private List<SysDishesIngredient> igdList;
private String type;
private Integer isMain;
}

View File

@ -26,6 +26,8 @@ public class SysRecipesPlan extends BaseEntity
//@Excel(name = "订单ID")
private Long orderId;
private Long cusId;
//客户ID
private Long customerId;

View File

@ -1,10 +1,28 @@
package com.stdiet.custom.mapper;
import com.stdiet.custom.domain.SysRecipes;
import com.stdiet.custom.domain.SysRecipesDaily;
import com.stdiet.custom.domain.SysRecipesDailyDishes;
import java.util.List;
public interface SysRecipesMapper {
public int addRecipes(SysRecipes sysRecipes);
public int bashAddDishes(List<SysRecipesDailyDishes> dishes);
public int bashAddMenus(List<SysRecipesDaily> menus);
public int getNumDayByCusId(Long id);
public List<SysRecipes> selectSysRecipesByRecipesId(Long id);
public int updateDishesDetail(SysRecipesDailyDishes sysRecipesDaily);
public int addDishes(SysRecipesDailyDishes sysRecipesDaily);
public int deleteDishes(Long id);
}

View File

@ -1,9 +1,20 @@
package com.stdiet.custom.service;
import com.stdiet.custom.domain.SysRecipes;
import com.stdiet.custom.domain.SysRecipesDaily;
import com.stdiet.custom.domain.SysRecipesDailyDishes;
import java.util.List;
public interface ISysRecipesService {
public int addRecipes(SysRecipes sysRecipes);
public List<SysRecipes> selectSysRecipesByRecipesId(Long id);
public int updateDishesDetail(SysRecipesDailyDishes sysRecipesDaily);
public int addDishes(SysRecipesDailyDishes sysRecipesDaily);
public int deleteDishes(Long id);
}

View File

@ -1,24 +1,24 @@
package com.stdiet.custom.service.impl;
import com.stdiet.common.utils.DateUtils;
import com.stdiet.common.utils.SynchrolockUtil;
import com.stdiet.custom.domain.SysOrder;
import com.stdiet.custom.domain.SysOrderPause;
import com.stdiet.custom.domain.SysRecipesPlan;
import com.stdiet.custom.mapper.SysRecipesPlanMapper;
import com.stdiet.custom.service.ISysOrderPauseService;
import com.stdiet.custom.service.ISysOrderService;
import com.stdiet.custom.service.ISysRecipesPlanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.stdiet.common.utils.DateUtils;
import com.stdiet.common.utils.SynchrolockUtil;
import com.stdiet.custom.domain.SysOrder;
import com.stdiet.custom.domain.SysOrderPause;
import com.stdiet.custom.service.ISysOrderPauseService;
import com.stdiet.custom.service.ISysOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.annotation.QueryAnnotation;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import com.stdiet.custom.mapper.SysRecipesPlanMapper;
import com.stdiet.custom.domain.SysRecipesPlan;
import com.stdiet.custom.service.ISysRecipesPlanService;
import org.springframework.transaction.annotation.Transactional;
/**
* 食谱计划Service业务层处理
@ -28,22 +28,17 @@ import org.springframework.transaction.annotation.Transactional;
*/
@Service("sysRecipesPlanService")
@Transactional
public class SysRecipesPlanServiceImpl implements ISysRecipesPlanService
{
public class SysRecipesPlanServiceImpl implements ISysRecipesPlanService {
public static final String generateRecipesPlanLockKey = "generateRecipesPlanLock::%s";
@Autowired
private SysRecipesPlanMapper sysRecipesPlanMapper;
@Autowired
private ISysOrderService sysOrderService;
@Autowired
private ISysOrderPauseService sysOrderPauseService;
@Autowired
private SynchrolockUtil synchrolockUtil;
public static final String generateRecipesPlanLockKey = "generateRecipesPlanLock::%s";
/**
* 查询食谱计划
*
@ -51,8 +46,7 @@ public class SysRecipesPlanServiceImpl implements ISysRecipesPlanService
* @return 食谱计划
*/
@Override
public SysRecipesPlan selectSysRecipesPlanById(Long id)
{
public SysRecipesPlan selectSysRecipesPlanById(Long id) {
return sysRecipesPlanMapper.selectSysRecipesPlanById(id);
}
@ -63,8 +57,7 @@ public class SysRecipesPlanServiceImpl implements ISysRecipesPlanService
* @return 食谱计划
*/
@Override
public List<SysRecipesPlan> selectSysRecipesPlanList(SysRecipesPlan sysRecipesPlan)
{
public List<SysRecipesPlan> selectSysRecipesPlanList(SysRecipesPlan sysRecipesPlan) {
return sysRecipesPlanMapper.selectSysRecipesPlanList(sysRecipesPlan);
}
@ -75,8 +68,7 @@ public class SysRecipesPlanServiceImpl implements ISysRecipesPlanService
* @return 结果
*/
@Override
public int insertSysRecipesPlan(SysRecipesPlan sysRecipesPlan)
{
public int insertSysRecipesPlan(SysRecipesPlan sysRecipesPlan) {
sysRecipesPlan.setCreateTime(DateUtils.getNowDate());
return sysRecipesPlanMapper.insertSysRecipesPlan(sysRecipesPlan);
}
@ -88,8 +80,7 @@ public class SysRecipesPlanServiceImpl implements ISysRecipesPlanService
* @return 结果
*/
@Override
public int updateSysRecipesPlan(SysRecipesPlan sysRecipesPlan)
{
public int updateSysRecipesPlan(SysRecipesPlan sysRecipesPlan) {
sysRecipesPlan.setUpdateTime(DateUtils.getNowDate());
//目前只能修改发送状态所以修改时加上发送时间
sysRecipesPlan.setSendTime(DateUtils.getNowDate());
@ -103,8 +94,7 @@ public class SysRecipesPlanServiceImpl implements ISysRecipesPlanService
* @return 结果
*/
@Override
public int deleteSysRecipesPlanByIds(Long[] ids)
{
public int deleteSysRecipesPlanByIds(Long[] ids) {
return sysRecipesPlanMapper.deleteSysRecipesPlanByIds(ids);
}
@ -115,8 +105,7 @@ public class SysRecipesPlanServiceImpl implements ISysRecipesPlanService
* @return 结果
*/
@Override
public int deleteSysRecipesPlanById(Long id)
{
public int deleteSysRecipesPlanById(Long id) {
return sysRecipesPlanMapper.deleteSysRecipesPlanById(id);
}
@ -128,47 +117,47 @@ public class SysRecipesPlanServiceImpl implements ISysRecipesPlanService
*/
@Override
@Async
public void regenerateRecipesPlan(Long orderId){
if(orderId == null || orderId <= 0){
public void regenerateRecipesPlan(Long orderId) {
if (orderId == null || orderId <= 0) {
return;
}
SysOrder sysOrder = sysOrderService.selectSysOrderById(orderId);
//订单为空金额小于0不进行食谱生成更新只对2021年开始的订单进行食谱计划生成
if(sysOrder == null && DateUtils.dateToLocalDate(sysOrder.getOrderTime()).getYear() < 2021){
if (sysOrder == null && DateUtils.dateToLocalDate(sysOrder.getOrderTime()).getYear() < 2021) {
return;
}
System.out.println(DateUtils.dateToLocalDate(sysOrder.getOrderTime()).getYear());
try{
// System.out.println(DateUtils.dateToLocalDate(sysOrder.getOrderTime()).getYear());
try {
//获取redis中该订单对应的锁
if(synchrolockUtil.lock(String.format(generateRecipesPlanLockKey, orderId))){
if (synchrolockUtil.lock(String.format(generateRecipesPlanLockKey, orderId))) {
SysRecipesPlan queryParam = new SysRecipesPlan();
queryParam.setOrderId(orderId);
List<SysRecipesPlan> oldRecipesPlanList = sysRecipesPlanMapper.selectSysRecipesPlanList(queryParam);
//判断是否已存在食谱
if(oldRecipesPlanList != null && oldRecipesPlanList.size() > 0){
if (oldRecipesPlanList != null && oldRecipesPlanList.size() > 0) {
Long[] orderIdArray = new Long[1];
orderIdArray[0] = orderId;
//删除该订单对于食谱
delRecipesPlanByOrderId(orderIdArray);
}
//判断订单金额开始时间结束时间为空则直接返回不重新生成食谱计划
if(sysOrder.getAmount().floatValue() <= 0 || sysOrder.getStartTime() == null || sysOrder.getServerEndTime() == null){
if (sysOrder.getAmount().floatValue() <= 0 || sysOrder.getStartTime() == null || sysOrder.getServerEndTime() == null) {
return;
}
SysOrderPause pauseParam = new SysOrderPause();
pauseParam.setOrderId(sysOrder.getOrderId());
//暂停记录列表
List<SysOrderPause> pauseList = sysOrderPauseService.selectSysOrderPauseList(pauseParam);
List<SysRecipesPlan> planList = generatePlan(orderId, oldRecipesPlanList, DateUtils.dateToLocalDate(sysOrder.getStartTime()), DateUtils.dateToLocalDate(sysOrder.getServerEndTime()), pauseList);
if(planList != null && planList.size() > 0){
List<SysRecipesPlan> planList = generatePlan(sysOrder, oldRecipesPlanList,
DateUtils.dateToLocalDate(sysOrder.getStartTime()), DateUtils.dateToLocalDate(sysOrder.getServerEndTime()), pauseList);
if (planList != null && planList.size() > 0) {
sysRecipesPlanMapper.insertBatch(planList);
}
/*for (SysRecipesPlan sysRecipesPlan : planList) {
getTestDate(sysRecipesPlan.getStartDate(), sysRecipesPlan.getEndDate());
}*/
}
}
catch (Exception e) {
} catch (Exception e) {
e.printStackTrace();
} finally {
// 一定要释放锁
@ -176,32 +165,34 @@ public class SysRecipesPlanServiceImpl implements ISysRecipesPlanService
}
}
public void getTestDate(Date date, Date date2){
public void getTestDate(Date date, Date date2) {
LocalDate d = DateUtils.dateToLocalDate(date);
LocalDate d2 = DateUtils.dateToLocalDate(date2);
String s1 = d.getYear() +"-" + d.getMonthValue() + "-" + d.getDayOfMonth();
String s2 = d2.getYear() +"-" + d2.getMonthValue() + "-" + d2.getDayOfMonth();
String s1 = d.getYear() + "-" + d.getMonthValue() + "-" + d.getDayOfMonth();
String s2 = d2.getYear() + "-" + d2.getMonthValue() + "-" + d2.getDayOfMonth();
System.out.println(s1 + " " + s2);
}
/**
* 根据订单ID订单开始服务时间结束时间暂停列表生成食谱计划列表
* @param orderId 订单ID
*
* @param sysOrder 订单对象
* @param oldRecipesPlanList 旧的食谱计划
* @param serverStartDate 服务开始时间
* @param serverEndDate 服务结束时间
* @param pauseList 暂停列表
* @return
*/
public List<SysRecipesPlan> generatePlan(Long orderId, List<SysRecipesPlan> oldRecipesPlanList, LocalDate serverStartDate, LocalDate serverEndDate, List<SysOrderPause> pauseList){
public List<SysRecipesPlan> generatePlan(SysOrder sysOrder, List<SysRecipesPlan> oldRecipesPlanList,
LocalDate serverStartDate, LocalDate serverEndDate, List<SysOrderPause> pauseList) {
List<SysRecipesPlan> planList = new ArrayList<>();
boolean breakFlag = false;
LocalDate planStartDate = serverStartDate;
LocalDate planEndDate = planStartDate.plusDays(6);
while (true){
while (true) {
SysRecipesPlan sysRecipesPlan = new SysRecipesPlan();
//判断是否大于服务到期时间
if(ChronoUnit.DAYS.between(planEndDate, serverEndDate) <= 0){
if (ChronoUnit.DAYS.between(planEndDate, serverEndDate) <= 0) {
planEndDate = serverEndDate;
breakFlag = true;
}
@ -210,14 +201,15 @@ public class SysRecipesPlanServiceImpl implements ISysRecipesPlanService
planEndDate = planEndDate.plusDays(pauseDay);
sysRecipesPlan.setStartDate(DateUtils.localDateToDate(planStartDate));
sysRecipesPlan.setEndDate(DateUtils.localDateToDate(planEndDate));
sysRecipesPlan.setOrderId(orderId);
sysRecipesPlan.setOrderId(sysOrder.getOrderId());
sysRecipesPlan.setCusId(sysOrder.getCusId());
/*//当开始时间小于等于当前时间默认为已发送发送时间为前一天
if(ChronoUnit.DAYS.between(planStartDate, LocalDate.now()) >= 0){
sysRecipesPlan.setSendFlag(1);
sysRecipesPlan.setSendTime(DateUtils.localDateToDate(LocalDate.now().minusDays(1)));
}*/
//将旧食谱计划中的发送状态发送时间食谱复制到新食谱计划中
boolean existFlag =oldRecipesPlanList.size() >= planList.size()+1;
boolean existFlag = oldRecipesPlanList.size() >= planList.size() + 1;
sysRecipesPlan.setSendFlag(existFlag ? oldRecipesPlanList.get(planList.size()).getSendFlag() : 0);
sysRecipesPlan.setSendTime(existFlag ? oldRecipesPlanList.get(planList.size()).getSendTime() : null);
sysRecipesPlan.setRecipesId(existFlag ? oldRecipesPlanList.get(planList.size()).getRecipesId() : null);
@ -227,7 +219,7 @@ public class SysRecipesPlanServiceImpl implements ISysRecipesPlanService
planStartDate = planEndDate.plusDays(1);
planEndDate = planStartDate.plusDays(6);
if(breakFlag){
if (breakFlag) {
break;
}
}
@ -236,25 +228,26 @@ public class SysRecipesPlanServiceImpl implements ISysRecipesPlanService
/**
* 根据食谱开始时间结束时间暂停列表获取在食谱计划范围内的暂停天数
*
* @param planStartDate 计划开始时间
* @param planEndDate 计划结束时间
* @param pauseList 暂停列表
* @return
*/
public long getPauseDayeCount(LocalDate planStartDate, LocalDate planEndDate, List<SysOrderPause> pauseList){
public long getPauseDayeCount(LocalDate planStartDate, LocalDate planEndDate, List<SysOrderPause> pauseList) {
long pauseDay = 0;
//判断这个时间内是否存在暂停
if(pauseList != null && pauseList.size() > 0){
for(SysOrderPause sysOrderPause : pauseList){
if (pauseList != null && pauseList.size() > 0) {
for (SysOrderPause sysOrderPause : pauseList) {
LocalDate pauseStartDate = DateUtils.dateToLocalDate(sysOrderPause.getPauseStartDate());
LocalDate pauseEndDate = DateUtils.dateToLocalDate(sysOrderPause.getPauseEndDate());
if(ChronoUnit.DAYS.between(pauseEndDate, planStartDate) > 0 || ChronoUnit.DAYS.between(planEndDate, pauseStartDate) > 0){
if (ChronoUnit.DAYS.between(pauseEndDate, planStartDate) > 0 || ChronoUnit.DAYS.between(planEndDate, pauseStartDate) > 0) {
continue;
}
if(ChronoUnit.DAYS.between(pauseStartDate, planStartDate) > 0){
if (ChronoUnit.DAYS.between(pauseStartDate, planStartDate) > 0) {
pauseStartDate = planStartDate;
}
if(ChronoUnit.DAYS.between(planEndDate, pauseEndDate) > 0){
if (ChronoUnit.DAYS.between(planEndDate, pauseEndDate) > 0) {
pauseEndDate = planEndDate;
}
pauseDay += ChronoUnit.DAYS.between(pauseStartDate, pauseEndDate);
@ -265,31 +258,34 @@ public class SysRecipesPlanServiceImpl implements ISysRecipesPlanService
/**
* 根据订单ID删除所有食谱安排计划
*
* @param orderIds 订单ID
* @return
*/
@Override
public int delRecipesPlanByOrderId(Long[] orderIds){
public int delRecipesPlanByOrderId(Long[] orderIds) {
return sysRecipesPlanMapper.delRecipesPlanByOrderId(orderIds);
}
/**
* 多条件查询食谱计划列表
*
* @param sysRecipesPlan
* @return
*/
@Override
public List<SysRecipesPlan> selectPlanListByCondition(SysRecipesPlan sysRecipesPlan){
public List<SysRecipesPlan> selectPlanListByCondition(SysRecipesPlan sysRecipesPlan) {
return sysRecipesPlanMapper.selectPlanListByCondition(sysRecipesPlan);
}
/**
* 根据订单ID查询食谱计划
*
* @param sysRecipesPlan
* @return
*/
@Override
public List<SysRecipesPlan> selectPlanListByOrderId(SysRecipesPlan sysRecipesPlan){
public List<SysRecipesPlan> selectPlanListByOrderId(SysRecipesPlan sysRecipesPlan) {
return sysRecipesPlanMapper.selectPlanListByOrderId(sysRecipesPlan);
}
}

View File

@ -1,12 +1,18 @@
package com.stdiet.custom.service.impl;
import com.stdiet.custom.domain.SysRecipes;
import com.stdiet.custom.domain.SysRecipesDaily;
import com.stdiet.custom.domain.SysRecipesDailyDishes;
import com.stdiet.custom.domain.SysRecipesPlan;
import com.stdiet.custom.mapper.SysRecipesMapper;
import com.stdiet.custom.mapper.SysRecipesPlanMapper;
import com.stdiet.custom.service.ISysRecipesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Service
@ -16,8 +22,64 @@ public class SysRecipesServiceImpl implements ISysRecipesService {
@Autowired
private SysRecipesMapper sysRecipesMapper;
@Autowired
private SysRecipesPlanMapper sysRecipesPlanMapper;
@Override
public int addRecipes(SysRecipes sysRecipes) {
int rows = sysRecipesMapper.addRecipes(sysRecipes);
if (rows > 0) {
int count = sysRecipesMapper.getNumDayByCusId(sysRecipes.getCusId());
List<SysRecipesDaily> menus = sysRecipes.getMenus();
List<SysRecipesDailyDishes> dishes = new ArrayList<>();
int size = menus.size();
for (int i = 0; i < size; i++) {
SysRecipesDaily tarMenu = menus.get(i);
// 计算menuId
long dailyId = sysRecipes.getId() + new Date().getTime() + i;
tarMenu.setId(dailyId);
// 插入recipiesId
tarMenu.setRecipesId(sysRecipes.getId());
// 插入numDay
tarMenu.setNumDay(count + i + 1);
for (SysRecipesDailyDishes tmpDishes : tarMenu.getDishes()) {
// 让菜品插入menuId
tmpDishes.setMenuId(dailyId);
dishes.add(tmpDishes);
}
}
// 插入每天食谱
sysRecipesMapper.bashAddMenus(menus);
// 插入每天菜品
sysRecipesMapper.bashAddDishes(dishes);
// 更新食谱计划
SysRecipesPlan sysRecipesPlan = new SysRecipesPlan();
sysRecipesPlan.setId(sysRecipes.getPlanId());
sysRecipesPlan.setRecipesId(sysRecipes.getId());
sysRecipesPlanMapper.updateSysRecipesPlan(sysRecipesPlan);
}
return rows;
}
@Override
public List<SysRecipes> selectSysRecipesByRecipesId(Long id) {
return sysRecipesMapper.selectSysRecipesByRecipesId(id);
}
@Override
public int updateDishesDetail(SysRecipesDailyDishes sysRecipesDailyDishes) {
return sysRecipesMapper.updateDishesDetail(sysRecipesDailyDishes);
}
@Override
public int addDishes(SysRecipesDailyDishes sysRecipesDailyDishes) {
return sysRecipesMapper.addDishes(sysRecipesDailyDishes);
}
@Override
public int deleteDishes(Long id) {
return sysRecipesMapper.deleteDishes(id);
}
}

View File

@ -4,7 +4,7 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.stdiet.custom.mapper.SysRecipesMapper">
<resultMap type="SysRecipes" id="SysRecipesResult">
<resultMap type="SysRecipesDaily" id="SysRecipesResult">
<result property="id" column="id"/>
<result property="numDay" column="num_day"/>
<result property="updateBy" column="update_by"/>
@ -15,14 +15,16 @@
<association property="dishes" column="id" select="selectDishesByMenuId"/>
</resultMap>
<resultMap id="SysDishesResult" type="SysDishes">
<result property="id" column="dishes_id"/>
<resultMap id="SysDishesResult" type="SysRecipesDailyDishes">
<result property="dishesId" column="dishes_id"/>
<result property="menuId" column="menu_id"/>
<result property="id" column="id" />
<result property="name" column="name"/>
<result property="type" column="type"/>
<result property="methods" column="methods"/>
<result property="isMain" column="is_main"/>
<result property="detail" column="detail" typeHandler="com.stdiet.custom.typehandler.ArrayJsonHandler"
javaType="com.stdiet.custom.domain.SysDishesIngredientInfo"/>
javaType="com.stdiet.custom.domain.SysDishesIngredient"/>
<association property="igdList" column="dishes_id" select="selectIngredientsByDishesId"/>
</resultMap>
@ -76,4 +78,67 @@
) ing USING(id)
</select>
<!-- 更新菜品-->
<update id="updateDishesDetail" parameterType="SysRecipesDailyDishes">
update sys_customer_menu_dishes
<trim prefix="SET" suffixOverrides=",">
<if test="detail != null">detail = #{detail, jdbcType=OTHER, typeHandler=com.stdiet.custom.typehandler.ArrayJsonHandler},</if>
</trim>
where id = #{id}
</update>
<!-- 插入菜品-->
<insert id="addDishes" parameterType="SysRecipesDailyDishes" useGeneratedKeys="true" keyProperty="id">
insert into sys_customer_menu_dishes
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="menuId != null">menu_id,</if>
<if test="dishesId != null">dishes_id,</if>
<if test="type != null">type,</if>
<if test="detail != null">detail,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="menuId != null">#{menuId},</if>
<if test="dishesId != null">#{dishesId},</if>
<if test="type != null">#{type},</if>
<if test="detail != null">#{detail, jdbcType=OTHER, typeHandler=com.stdiet.custom.typehandler.ArrayJsonHandler},</if>
</trim>
</insert>
<!-- 删除菜品-->
<delete id="deleteDishes" parameterType="Long">
delete from sys_customer_menu_dishes where id = #{id}
</delete>
<!-- 查询已有食谱天数-->
<select id="getNumDayByCusId" parameterType="Long" resultType="Integer">
select count(*) from sys_customer_daily_menu where cus_id = #{id}
</select>
<!-- 新增食谱 -->
<insert id="addRecipes" parameterType="SysRecipes" useGeneratedKeys="true" keyProperty="id">
insert into sys_customer_menu
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="cusId != null">cus_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="cusId != null">#{cusId},</if>
</trim>
</insert>
<!-- 新增每菜单 -->
<insert id="bashAddMenus">
insert into sys_customer_daily_menu (id, num_day, date, recipes_id, cus_id) values
<foreach collection="list" separator="," item="item" index="index">
(#{item.id}, #{item.numDay}, #{item.date}, #{item.recipesId}, #{item.cusId})
</foreach>
</insert>
<!-- 新增菜单对应菜品-->
<insert id="bashAddDishes" >
insert into sys_customer_menu_dishes (menu_id, type, dishes_id, detail) values
<foreach collection="list" separator="," item="item" index="index">
(#{item.menuId}, #{item.type}, #{item.dishesId}, #{item.detail, jdbcType=OTHER, typeHandler=com.stdiet.custom.typehandler.ArrayJsonHandler})
</foreach>
</insert>
</mapper>

View File

@ -17,6 +17,7 @@
<result property="updateTime" column="update_time" />
<result property="updateBy" column="update_by" />
<result property="delFlag" column="del_flag" />
<result property="cusId" column="cus_id" />
<!-- 非持久化字段 -->
<result property="customerId" column="cus_id"></result><!-- 客户ID -->
<result property="customer" column="customer" /><!-- 客户姓名 -->
@ -127,7 +128,7 @@
<!-- 食谱计划、订单表联查 -->
<select id="selectPlanListByCondition" parameterType="SysRecipesPlan" resultMap="SysRecipesPlanResult">
SELECT srp.id,srp.order_id,sr.customer,sr.cus_id,sr.phone,su_nutritionist.nick_name nutritionist,su_nutritionist_assis.nick_name AS nutritionist_assis,sr.start_time,sr.server_end_time, srp.start_date,srp.end_date,srp.send_flag,srp.send_time
SELECT srp.id,srp.order_id,srp.recipes_id,sr.customer,sr.cus_id,sr.phone,su_nutritionist.nick_name nutritionist,su_nutritionist_assis.nick_name AS nutritionist_assis,sr.start_time,sr.server_end_time, srp.start_date,srp.end_date,srp.send_flag,srp.send_time
FROM sys_recipes_plan srp
LEFT JOIN sys_order sr ON sr.order_id = srp.order_id
LEFT JOIN sys_user su_nutritionist ON su_nutritionist.user_id = sr.nutritionist_id AND su_nutritionist.del_flag = 0

10
stdiet-ui/jsconfig.json Normal file
View File

@ -0,0 +1,10 @@
{
"compilerOptions": {
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
}
}

View File

@ -46,13 +46,15 @@
"clipboard": "^2.0.6",
"core-js": "3.6.5",
"dayjs": "^1.9.1",
"echarts": "4.2.1",
"echarts": "4.7.0",
"element-ui": "2.13.2",
"file-saver": "2.0.1",
"fuse.js": "3.4.4",
"immer": "^8.0.1",
"js-beautify": "1.10.2",
"js-cookie": "2.2.0",
"jsencrypt": "3.0.0-rc.1",
"lodash": "^4.17.20",
"normalize.css": "7.0.0",
"nprogress": "0.2.0",
"path-to-regexp": "2.4.0",

View File

@ -5,7 +5,8 @@
</template>
<script>
export default {
name: 'App'
}
name: "App",
};
</script>

View File

@ -0,0 +1,8 @@
import request from "@/utils/request";
export function getOptions() {
return request({
url: "/custom/post/options",
method: "get"
});
}

View File

@ -1,69 +1,62 @@
import request from '@/utils/request'
import request from "@/utils/request";
// 查询销售订单列表
export function listOrder(params) {
return request({
url: '/custom/order/list',
method: 'get',
url: "/custom/order/list",
method: "get",
params: params
})
});
}
// 查询销售订单详细
export function getOrder(orderId) {
return request({
url: '/custom/order/' + orderId,
method: 'get'
})
url: "/custom/order/" + orderId,
method: "get"
});
}
// 新增销售订单
export function addOrder(data) {
return request({
url: '/custom/order',
method: 'post',
url: "/custom/order",
method: "post",
data: data
})
});
}
// 修改销售订单
export function updateOrder(data) {
return request({
url: '/custom/order',
method: 'put',
url: "/custom/order",
method: "put",
data: data
})
});
}
// 删除销售订单
export function delOrder(orderId) {
return request({
url: '/custom/order/' + orderId,
method: 'delete'
})
url: "/custom/order/" + orderId,
method: "delete"
});
}
// 导出销售订单
export function exportOrder(query) {
return request({
url: '/custom/order/export',
method: 'get',
url: "/custom/order/export",
method: "get",
params: query
})
}
export function getOptions() {
return request({
url: '/custom/post/options',
method: 'get'
})
});
}
// 查询销售订单详细
export function getInfoDetail(query) {
return request({
url: '/custom/order/getInfoDetail',
method: 'get',
url: "/custom/order/getInfoDetail",
method: "get",
params: query
})
});
}

View File

@ -1,8 +1,39 @@
import request from "@/utils/request";
export function getRecipes(id) {
export function addRecipesApi(data) {
return request({
url: "/recipes/" + id,
url: "/custom/recipes/",
method: "post",
data
});
}
export function getRecipesApi(id) {
return request({
url: "/custom/recipes/" + id,
method: "get"
});
}
export function updateDishesDetailApi(data) {
return request({
url: "/custom/recipes/dishes",
method: "put",
data
});
}
export function addDishesApi(data) {
return request({
url: "/custom/recipes/dishes",
method: "post",
data
});
}
export function deleteDishesApi(id) {
return request({
url: "/custom/recipes/dishes/" + id,
method: "delete"
});
}

View File

@ -3,9 +3,14 @@
<div v-for="item in mData" :key="item">
{{ item }}
</div>
<div v-if="data.length > 3">
<div>...</div>
<el-popover placement="top-start" width="200" popper-class="autohideinfo_detial" trigger="hover">
<div v-if="data.length > line">
<div v-if="line > 0">...</div>
<el-popover
placement="top-start"
width="200"
popper-class="autohideinfo_detial"
trigger="hover"
>
<div v-for="item in data" :key="item">{{ item }}</div>
<el-button type="text" slot="reference">详情</el-button>
</el-popover>
@ -14,37 +19,39 @@
</template>
<script>
export default {
export default {
name: "AutoHideInfo",
data() {
return {
};
return {};
},
props: {
data: {
type: Array,
default: '',
default: "",
// required: true,
},
line: {
type: Number,
default: 3,
},
},
computed: {
mData: function () {
if (this.data instanceof Array) {
return this.data.slice(0, 3);
return this.data.slice(0, this.line);
}
return [];
},
},
};
};
</script>
<style>
.autohideinfo_wrapper {
<style scoped>
.autohideinfo_wrapper {
}
}
.autohideinfo_detial {
.autohideinfo_detial {
max-height: 240px;
overflow: auto;
}
}
</style>

View File

@ -36,7 +36,7 @@
};
</script>
<style>
<style scoped>
.autohideinfo_wrapper {
}

View File

@ -3,28 +3,51 @@
<el-dialog :title="title" :visible.sync="open" width="550px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
<el-form-item label="调理项目" prop="projectId">
<el-select v-model="form.projectId" placeholder="请选择调理项目" filterable clearable size="small">
<el-option v-for="dict in conditioningProjectIdOption"
<el-select
v-model="form.projectId"
placeholder="请选择调理项目"
filterable
clearable
size="small"
>
<el-option
v-for="dict in conditioningProjectIdOption"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="parseInt(dict.dictValue)"/>
:value="parseInt(dict.dictValue)"
/>
</el-select>
</el-form-item>
<!--<el-form-item label="客户姓名" prop="name">
<el-input v-model="form.name" placeholder="请输入客户姓名"/>
</el-form-item>-->
<el-form-item label="金额" prop="amount" style="width: 300px;">
<el-input v-model="form.amount" placeholder="请输入金额"/>
<el-form-item label="金额" prop="amount" style="width: 300px">
<el-input v-model="form.amount" placeholder="请输入金额" />
</el-form-item>
<el-form-item label="服务承诺" prop="servePromise" v-show="form.projectId == 0" >
<el-input style="width: 200px;" v-model="form.servePromise" placeholder="请输入服务承诺"/><span style="margin-left: 5px;"></span>
<el-form-item
label="服务承诺"
prop="servePromise"
v-show="form.projectId == 0"
>
<el-input
style="width: 200px"
v-model="form.servePromise"
placeholder="请输入服务承诺"
/><span style="margin-left: 5px"></span>
</el-form-item>
<el-form-item label="营养师" prop="nutritionistId">
<el-select v-model="form.nutritionistId" placeholder="请选择营养师" clearable size="small">
<el-option v-for="dict in nutritionistIdOptions"
<el-select
v-model="form.nutritionistId"
placeholder="请选择营养师"
clearable
size="small"
>
<el-option
v-for="dict in nutritionistIdOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="parseInt(dict.dictValue)"/>
:value="parseInt(dict.dictValue)"
/>
</el-select>
</el-form-item>
<el-form-item label="服务时间" prop="serveTime">
@ -38,7 +61,11 @@
</el-select>
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容"/>
<el-input
v-model="form.remark"
type="textarea"
placeholder="请输入内容"
/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
@ -48,20 +75,17 @@
</el-dialog>
</template>
<script>
import {addContract} from "@/api/custom/contract";
import {getOptions} from "@/api/custom/order";
import { addContract } from "@/api/custom/contract";
import { mapState } from "vuex";
export default {
name: "ContractAdd",
components: {
},
components: {},
props: {},
data() {
const checkServePromise = (rule, value, callback) => {
if (this.form.projectId == 0 && !value) {
return callback(new Error('请输入服务承诺'))
return callback(new Error("请输入服务承诺"));
}
callback();
};
@ -75,14 +99,14 @@ export default {
form: {},
//
rules: {
projectId:[
{required: true, message: "请选择调理项目", trigger: "blur"}
projectId: [
{ required: true, message: "请选择调理项目", trigger: "blur" },
],
/*name: [
{required: true, message: "请输入客户姓名", trigger: "blur"}
],*/
amount: [
{required: true, message: "请输入签订金额", trigger: "blur"},
{ required: true, message: "请输入签订金额", trigger: "blur" },
{
required: true,
trigger: "blur",
@ -91,35 +115,31 @@ export default {
},
],
servePromise: [
{required: true, trigger: "blur", validator: checkServePromise}
{ required: true, trigger: "blur", validator: checkServePromise },
],
serveTime: [
{required: true, message: "请选择服务时间", trigger: "blur"}
{ required: true, message: "请选择服务时间", trigger: "blur" },
],
nutritionistId: [
{required: true, message: "请选择营养师", trigger: "blur"}
]
{ required: true, message: "请选择营养师", trigger: "blur" },
],
},
conditioningProjectIdOption:[],
serveTimeOptions:[],
nutritionistIdOptions:[]
conditioningProjectIdOption: [],
serveTimeOptions: [],
// nutritionistIdOptions: [],
};
},
computed: {
...mapState({
nutritionistIdOptions: (state) =>
state.global.nutritionistIdOptions.slice(1),
}),
},
created() {
getOptions().then(response => {
const options = response.data.reduce((opts, cur) => {
if (!opts[cur.postCode]) {
opts[cur.postCode] = [];
}
opts[cur.postCode].push({dictValue: cur.userId, dictLabel: cur.userName, remark: cur.remark})
return opts;
}, {})
this.nutritionistIdOptions = options['nutri'] || [];
})
this.getDicts("cus_serve_time").then(response => {
this.getDicts("cus_serve_time").then((response) => {
this.serveTimeOptions = response.data;
});
this.getDicts("conditioning_project").then(response => {
this.getDicts("conditioning_project").then((response) => {
this.conditioningProjectIdOption = response.data;
});
},
@ -127,29 +147,37 @@ export default {
showDialog(data, callback) {
this.callback = callback;
this.reset(data);
this.title = "新增"+`${data.customer}」客户合同`;
this.title = "新增" + `${data.customer}」客户合同`;
this.open = true;
},
//
reset(obj) {
const defaultNutritionist = this.nutritionistIdOptions.find(opt => opt.dictValue === obj.nutritionistId);
const defaultProjectIdOption = this.conditioningProjectIdOption.find(opt => opt.remark === 'default');
const defaultNutritionist = this.nutritionistIdOptions.find(
(opt) => opt.dictValue === obj.nutritionistId
);
const defaultProjectIdOption = this.conditioningProjectIdOption.find(
(opt) => opt.remark === "default"
);
this.form = {
id: null,
customerId: obj.customerId,
projectId: defaultProjectIdOption ? parseInt(defaultProjectIdOption.dictValue) : null,
projectId: defaultProjectIdOption
? parseInt(defaultProjectIdOption.dictValue)
: null,
name: obj.customer,
phone: null,
serveTime: null,
amount: null,
path: null,
createBy: null,
nutritionistId: defaultNutritionist ? parseInt(defaultNutritionist.dictValue) : null,
nutritionistId: defaultNutritionist
? parseInt(defaultNutritionist.dictValue)
: null,
createTime: null,
updateBy: null,
updateTime: null,
remark: null
remark: null,
};
this.resetForm("form");
},
@ -159,13 +187,16 @@ export default {
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
this.$refs["form"].validate((valid) => {
if (valid) {
this.form.tutor = this.selectDictLabel(this.nutritionistIdOptions, this.form.nutritionistId)
if(this.form.projectId != 0){
this.form.tutor = this.selectDictLabel(
this.nutritionistIdOptions,
this.form.nutritionistId
);
if (this.form.projectId != 0) {
this.form.servePromise = null;
}
addContract(this.form).then(response => {
addContract(this.form).then((response) => {
if (response.code === 200) {
this.msgSuccess("新增成功");
this.open = false;
@ -174,7 +205,7 @@ export default {
});
}
});
}
}
},
},
};
</script>

View File

@ -4,6 +4,7 @@
:title="title"
:close-on-press-escape="false"
:visible.sync="visible"
:wrapperClosable="false"
@closed="handleOnClosed"
size="40%"
>
@ -22,22 +23,48 @@
</el-row>
<el-table :data="contractList">
<el-table-column label="合同编号" align="center" prop="id" width="150"/>
<el-table-column label="合同状态" align="center" prop="status" width="80" >
<el-table-column
label="合同编号"
align="center"
prop="id"
width="150"
/>
<el-table-column
label="合同状态"
align="center"
prop="status"
width="80"
>
<template slot-scope="scope">
<el-tag
:type="scope.row.status === 'yes' ? 'success' : 'danger'"
disable-transitions>
{{scope.row.status === 'yes' ? '已签订':'未签订'}}
disable-transitions
>
{{ scope.row.status === "yes" ? "已签订" : "未签订" }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="客户姓名" align="center" prop="name" width="200"/>
<el-table-column
label="客户姓名"
align="center"
prop="name"
width="200"
/>
<el-table-column label="合同地址" align="center" prop="path" width="80">
<el-table-column
label="合同地址"
align="center"
prop="path"
width="80"
>
<template slot-scope="scope">
<el-button type="text" icon="el-icon-copy-document" @click="handleCopy(scope.row.path)" class="copyBtn"
:data-clipboard-text="copyValue">复制
<el-button
type="text"
icon="el-icon-copy-document"
@click="handleCopy(scope.row.path)"
class="copyBtn"
:data-clipboard-text="copyValue"
>复制
</el-button>
</template>
</el-table-column>
@ -51,7 +78,7 @@
>详情
</el-button>
<el-button
v-if="scope.row.status==='yes'"
v-if="scope.row.status === 'yes'"
size="mini"
type="text"
icon="el-icon-view"
@ -78,23 +105,23 @@
</div>
</template>
<script>
import {delContract, listContract} from "@/api/custom/contract";
import ContractDetail from "@/components/ContractDetail";
import Clipboard from 'clipboard';
import ContractAdd from "@/components/ContractAdd";
import { delContract, listContract } from "@/api/custom/contract";
import ContractDetail from "@/components/ContractDetail";
import Clipboard from "clipboard";
import ContractAdd from "@/components/ContractAdd";
export default {
name: "CustomerContractDrawer",
components: {
'contract-detail': ContractDetail,
'add-contract':ContractAdd
"contract-detail": ContractDetail,
"add-contract": ContractAdd,
},
data() {
return {
visible: false,
title: "",
data: undefined,
copyValue:"",
copyValue: "",
contractList: [],
};
},
@ -108,7 +135,7 @@ export default {
this.fetchContractList(data.id);
},
fetchContractList(cusId) {
listContract({"customerId": cusId }).then((res) => {
listContract({ customerId: cusId }).then((res) => {
this.contractList = res.rows;
this.visible = true;
});
@ -118,7 +145,7 @@ export default {
{
customer: this.data.name,
customerId: this.data.id,
nutritionistId: this.data.mainDietitian
nutritionistId: this.data.mainDietitian,
},
() => {
this.fetchContractList(this.data.id);
@ -131,9 +158,7 @@ export default {
handleOnDetailClick(data) {
this.$refs.contractDetailRef.showDialog(data.id);
},
handleOnEditClick(data) {
},
handleOnEditClick(data) {},
handleOnDeleteClick(data) {
const contractIds = data.id;
this.$confirm(
@ -155,18 +180,18 @@ export default {
.catch(function () {});
},
handleCopy(path) {
this.copyValue = window.location.origin.replace('manage', 'sign') + path;
const btnCopy = new Clipboard('.copyBtn');
this.copyValue = window.location.origin.replace("manage", "sign") + path;
const btnCopy = new Clipboard(".copyBtn");
this.$message({
message: '拷贝成功',
type: 'success'
message: "拷贝成功",
type: "success",
});
},
handleLook(path) {
const url = window.location.origin.replace('manage', 'sign') + path;
const url = window.location.origin.replace("manage", "sign") + path;
// const url = "http://stsign.busyinn.com" + path;
window.open(url, '_blank');
}
window.open(url, "_blank");
},
},
};
</script>

View File

@ -113,7 +113,7 @@ export default {
};
</script>
<style>
<style scoped>
.editor, .ql-toolbar {
white-space: pre-wrap!important;
line-height: normal !important;

View File

@ -14,15 +14,25 @@
<el-cascader
v-model="form.orderType"
:options="orderTypeOptions"
style="width: 100%">
style="width: 100%"
>
</el-cascader>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="自动创建售后提成订单" prop="secondAfterSaleFlag" label-width="200px">
<el-select v-model="form.secondAfterSaleFlag" :disabled="secondAfterSaleFlagShow" style="width: 100px" placeholder="请选择">
<el-option :key="0" label="否" :value="0"/>
<el-option :key="1" label="是" :value="1"/>
<el-form-item
label="自动创建售后提成订单"
prop="secondAfterSaleFlag"
label-width="200px"
>
<el-select
v-model="form.secondAfterSaleFlag"
:disabled="secondAfterSaleFlagShow"
style="width: 100px"
placeholder="请选择"
>
<el-option :key="0" label="否" :value="0" />
<el-option :key="1" label="是" :value="1" />
</el-select>
</el-form-item>
</el-col>
@ -120,7 +130,11 @@
</el-col>
<el-col :span="8">
<el-form-item label="主营养师" prop="nutritionistIdList">
<el-select v-model="form.nutritionistIdList" multiple placeholder="请选择">
<el-select
v-model="form.nutritionistIdList"
multiple
placeholder="请选择"
>
<el-option
v-for="dict in nutritionistIdOptions"
:key="dict.dictValue"
@ -132,7 +146,11 @@
</el-col>
<el-col :span="8">
<el-form-item label="拆分比例" prop="nutritionistRate">
<el-select v-model="form.nutritionistRate" :disabled="orderRateOptionsShow" placeholder="请选择" >
<el-select
v-model="form.nutritionistRate"
:disabled="orderRateOptionsShow"
placeholder="请选择"
>
<el-option
v-for="dict in orderRateOptions"
:key="dict.dictValue"
@ -264,9 +282,11 @@
</el-dialog>
</template>
<script>
import { addOrder, getOptions, updateOrder } from "@/api/custom/order";
import { addOrder, updateOrder } from "@/api/custom/order";
import dayjs from "dayjs";
import * as orderTypeData from "@/utils/orderType";
import { mapGetters } from "vuex";
export default {
name: "OrderEdit",
props: {
@ -383,16 +403,6 @@ export default {
},
//
payTypeIdOptions: [],
//
preSaleIdOptions: [],
//
afterSaleIdOptions: [],
//
nutritionistIdOptions: [],
//
nutriAssisIdOptions: [],
//
plannerIdOptions: [],
//
accountIdOptions: [],
//
@ -401,54 +411,25 @@ export default {
giveTimeIdOption: [],
//
conditioningProjectIdOption: [],
//
plannerAssisIdOptions: [],
//
operatorIdOptions: [],
//
reviewStatusOptions: [],
//
operatorAssisIdOptions: [],
//()
orderDropdownCorrespondingOptions: [],
//
orderTypeOptions: orderTypeData['orderTypeArray'],
orderTypeOptions: orderTypeData["orderTypeArray"],
secondAfterSaleFlagShow: true,
//
orderRateOptions: orderTypeData['orderRateArray'],
orderRateOptionsShow: true
orderRateOptions: orderTypeData["orderRateArray"],
orderRateOptionsShow: true,
};
},
created() {
getOptions().then((res) => {
const options = res.data.reduce((opts, cur) => {
if (!opts[cur.postCode]) {
opts[cur.postCode] = [
{ dictValue: 0, dictLabel: "无", remark: null },
];
}
opts[cur.postCode].push({
dictValue: cur.userId,
dictLabel: cur.userName,
remark: cur.remark,
});
return opts;
}, {});
this.preSaleIdOptions = options["pre_sale"] || [];
this.afterSaleIdOptions = options["after_sale"] || [];
this.nutritionistIdOptions = options["nutri"] || [];
this.nutriAssisIdOptions = options["nutri_assis"] || [];
this.plannerIdOptions = options["planner"] || [];
this.plannerAssisIdOptions = options["planner_assis"] || [];
this.operatorIdOptions = options["operator"] || [];
this.operatorAssisIdOptions = options["operator_assis"] || [];
});
this.getDicts("cus_pay_type").then((response) => {
this.payTypeIdOptions = response.data;
});
this.getDicts("cus_account").then((response) => {
this.accountIdOptions = response.data;
console.log(response.data);
// console.log(response.data);
this.accountIdOptions.splice(0, 0, {
dictLabel: "无",
dictValue: "0",
@ -484,6 +465,26 @@ export default {
this.orderTypeOptions = response.data;
});*/
},
computed: {
...mapGetters([
//
"preSaleIdOptions",
//
"afterSaleIdOptions",
//
"nutritionistIdOptions",
//
"nutriAssisIdOptions",
//
"plannerIdOptions",
//
"plannerAssisIdOptions",
//
"operatorIdOptions",
//
"operatorAssisIdOptions",
]),
},
methods: {
showDialog(data, callback) {
// this.data = data;
@ -554,7 +555,9 @@ export default {
(opt) => parseInt(opt.dictValue) === accountId
);
const defaultOrderRate = this.orderRateOptions.find((opt) => opt.remark === "default");
const defaultOrderRate = this.orderRateOptions.find(
(opt) => opt.remark === "default"
);
const [
plannerId,
@ -590,7 +593,9 @@ export default {
updateBy: null,
updateTime: null,
nutritionistId: null,
nutritionistIdList: defaultNutritionist ? [parseInt(defaultNutritionist.dictValue)] : null,
nutritionistIdList: defaultNutritionist
? [parseInt(defaultNutritionist.dictValue)]
: null,
nutritionistRate: defaultOrderRate ? defaultOrderRate.dictValue : null,
remark: null,
nutriAssisId: defaultNutriAssis
@ -647,9 +652,9 @@ export default {
};
}
},
handleOrderTypeChange(){
handleOrderTypeChange() {
console.log(this.form.orderType);
}
},
},
watch: {
//
@ -658,18 +663,18 @@ export default {
},
"form.orderType": function (newVal, oldVal) {
//
if(newVal[1] == 1){
if (newVal[1] == 1) {
this.form.secondAfterSaleFlag = 1;
this.secondAfterSaleFlagShow = false;
}else{
} else {
this.form.secondAfterSaleFlag = 0;
this.secondAfterSaleFlagShow = true;
}
//
if(newVal[0] == 1){
if (newVal[0] == 1) {
this.orderRateOptionsShow = false;
this.form.nutritionistRate = "2,8";
}else{
} else {
this.orderRateOptionsShow = true;
this.form.nutritionistRate = "0,10";
}

View File

@ -4,6 +4,7 @@
:title="title"
:close-on-press-escape="false"
:visible.sync="visible"
:wrapperClosable="false"
@closed="handleOnClosed"
size="40%"
>

View File

@ -235,8 +235,9 @@
</el-dialog>
</template>
<script>
import { addOrder, getOptions, updateOrder } from "@/api/custom/order";
import { addOrder, updateOrder } from "@/api/custom/order";
import dayjs from "dayjs";
import { mapGetters } from "vuex";
export default {
name: "OrderEdit",
@ -354,16 +355,6 @@ export default {
},
//
payTypeIdOptions: [],
//
preSaleIdOptions: [],
//
afterSaleIdOptions: [],
//
nutritionistIdOptions: [],
//
nutriAssisIdOptions: [],
//
plannerIdOptions: [],
//
accountIdOptions: [],
//
@ -372,42 +363,13 @@ export default {
giveTimeIdOption: [],
//
conditioningProjectIdOption: [],
//
plannerAssisIdOptions: [],
//
operatorIdOptions: [],
//
reviewStatusOptions: [],
//
operatorAssisIdOptions: [],
//()
orderDropdownCorrespondingOptions: [],
};
},
created() {
getOptions().then((res) => {
const options = res.data.reduce((opts, cur) => {
if (!opts[cur.postCode]) {
opts[cur.postCode] = [
{ dictValue: 0, dictLabel: "无", remark: null },
];
}
opts[cur.postCode].push({
dictValue: cur.userId,
dictLabel: cur.userName,
remark: cur.remark,
});
return opts;
}, {});
this.preSaleIdOptions = options["pre_sale"] || [];
this.afterSaleIdOptions = options["after_sale"] || [];
this.nutritionistIdOptions = options["nutri"] || [];
this.nutriAssisIdOptions = options["nutri_assis"] || [];
this.plannerIdOptions = options["planner"] || [];
this.plannerAssisIdOptions = options["planner_assis"] || [];
this.operatorIdOptions = options["operator"] || [];
this.operatorAssisIdOptions = options["operator_assis"] || [];
});
this.getDicts("cus_pay_type").then((response) => {
this.payTypeIdOptions = response.data;
});
@ -435,6 +397,26 @@ export default {
this.orderDropdownCorrespondingOptions = response.data;
});
},
computed: {
...mapGetters([
//
"preSaleIdOptions",
//
"afterSaleIdOptions",
//
"nutritionistIdOptions",
//
"nutriAssisIdOptions",
//
"plannerIdOptions",
//
"plannerAssisIdOptions",
//
"operatorIdOptions",
//
"operatorAssisIdOptions",
]),
},
methods: {
showDialog(data, callback) {
// this.data = data;

View File

@ -472,7 +472,7 @@ export default {
};
</script>
<style>
<style scoped>
.margin-top-20{
margin-top:20px;
}

View File

@ -176,7 +176,7 @@ export default {
};
</script>
<style>
<style scoped>
.margin-top-20{
margin-top:20px;
}

View File

@ -76,7 +76,7 @@ export default {
};
</script>
<style>
<style scoped>
.margin-top-20{
margin-top:20px;
}

View File

@ -1,87 +0,0 @@
<template>
<div class="main">
<div class="aspect">指标</div>
<div class="recipes">
<el-table :data="mData" border :span-method="spanMethod" size="mini">
<el-table-column :label="`${name}第${num}天`"></el-table-column>
<el-table-column label="菜品" prop="name"></el-table-column>
</el-table>
</div>
</div>
</template>
<script>
export default {
name: "RecipesCom",
props: {
data: {
type: Array,
default: [],
required: true,
},
name: {
type: String,
default: "",
},
num: {
type: Number,
default: 0,
},
},
components: {},
mounted() {
// console.log(this.data);
},
data() {
return {};
},
computed: {
mData() {
if (!this.data.dishes) {
return [];
}
const mData = this.data.dishes.reduce((arr, cur) => {
if (cur.id > 0) {
cur.igdList.forEach((igd) => {
if (igd.id > 0) {
const tarDetail = cur.detail.find((det) => det.id == igd.id);
arr.push({
id: cur.id,
name: cur.name,
type: cur.type,
isMain: cur.isMain,
methods: cur.methods,
igdId: igd.id,
igdName: igd.name,
proteinRatio: igd.proteinRatio,
fatRatio: igd.fatRatio,
carbonRatio: igd.carbonRatio,
rec: igd.rec,
notRec: igd.notRec,
weight: tarDetail ? tarDetail.weight : igd.weight,
cusWeight: tarDetail ? tarDetail.cus_weight : igd.cusWeight,
cusUnit: tarDetail ? tarDetail.cus_unit : igd.cusUnit,
});
}
});
}
return arr;
}, []);
// console.log(mData);
return mData;
},
},
methods: {
spanMethod({ row, column, rowIndex, columnIndex }) {},
},
};
</script>
<style rel="stylesheet/scss" lang="scss">
.main {
.aspect {
}
.recipies {
}
}
</style>

View File

@ -1,10 +1,10 @@
<template>
<div :class="classname">
<span class="title">{{ title }}</span>
<span class="info_title">{{ title }}</span>
<span v-if="newLine">
<div v-for="value in mValue" :key="value">{{ value }}</div>
</span>
<span v-else class="value">{{ mValue }}</span>
<span v-else class="info_value">{{ mValue }}</span>
</div>
</template>
<script>
@ -32,19 +32,19 @@ export default {
props: ["title", "value", "extraclass"],
};
</script>
<style rel="stylesheet/scss" lang="scss">
<style lang="scss" >
.text_info_wrapper {
display: flex;
margin-right: 24px;
min-width: 120px;
font-size: 14px;
.title {
.info_title {
color: #8c8c8c;
width: auto;
}
.value {
.info_value {
/* color: #696969; */
flex: 1 1 0;
}

View File

@ -1,11 +1,16 @@
<template>
<div class="navbar">
<hamburger id="hamburger-container" :is-active="sidebar.opened" class="hamburger-container" @toggleClick="toggleSideBar" />
<hamburger
id="hamburger-container"
:is-active="sidebar.opened"
class="hamburger-container"
@toggleClick="toggleSideBar"
/>
<breadcrumb id="breadcrumb-container" class="breadcrumb-container" />
<div class="right-menu">
<template v-if="device!=='mobile'">
<template v-if="device !== 'mobile'">
<search id="header-search" class="right-menu-item" />
<!-- <el-tooltip content="源码地址" effect="dark" placement="bottom">
@ -21,12 +26,14 @@
<el-tooltip content="布局大小" effect="dark" placement="bottom">
<size-select id="size-select" class="right-menu-item hover-effect" />
</el-tooltip>
</template>
<el-dropdown class="avatar-container right-menu-item hover-effect" trigger="click">
<el-dropdown
class="avatar-container right-menu-item hover-effect"
trigger="click"
>
<div class="avatar-wrapper">
<img :src="avatar" class="user-avatar">
<img :src="avatar" class="user-avatar" />
<i class="el-icon-caret-bottom" />
</div>
<el-dropdown-menu slot="dropdown">
@ -46,14 +53,14 @@
</template>
<script>
import { mapGetters } from 'vuex'
import Breadcrumb from '@/components/Breadcrumb'
import Hamburger from '@/components/Hamburger'
import Screenfull from '@/components/Screenfull'
import SizeSelect from '@/components/SizeSelect'
import Search from '@/components/HeaderSearch'
import RuoYiGit from '@/components/RuoYi/Git'
import RuoYiDoc from '@/components/RuoYi/Doc'
import { mapGetters, mapActions } from "vuex";
import Breadcrumb from "@/components/Breadcrumb";
import Hamburger from "@/components/Hamburger";
import Screenfull from "@/components/Screenfull";
import SizeSelect from "@/components/SizeSelect";
import Search from "@/components/HeaderSearch";
import RuoYiGit from "@/components/RuoYi/Git";
import RuoYiDoc from "@/components/RuoYi/Doc";
export default {
components: {
@ -63,43 +70,43 @@ export default {
SizeSelect,
Search,
RuoYiGit,
RuoYiDoc
RuoYiDoc,
},
created() {
this.init();
},
computed: {
...mapGetters([
'sidebar',
'avatar',
'device'
]),
...mapGetters(["sidebar", "avatar", "device"]),
setting: {
get() {
return this.$store.state.settings.showSettings
return this.$store.state.settings.showSettings;
},
set(val) {
this.$store.dispatch('settings/changeSetting', {
key: 'showSettings',
value: val
})
}
}
this.$store.dispatch("settings/changeSetting", {
key: "showSettings",
value: val,
});
},
},
},
methods: {
...mapActions(["init"]),
toggleSideBar() {
this.$store.dispatch('app/toggleSideBar')
this.$store.dispatch("app/toggleSideBar");
},
async logout() {
this.$confirm('确定注销并退出系统吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
this.$confirm("确定注销并退出系统吗?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
}).then(() => {
this.$store.dispatch('LogOut').then(() => {
location.href = '/index';
})
})
}
}
}
this.$store.dispatch("LogOut").then(() => {
location.href = "/index";
});
});
},
},
};
</script>
<style lang="scss" scoped>
@ -108,18 +115,18 @@ export default {
overflow: hidden;
position: relative;
background: #fff;
box-shadow: 0 1px 4px rgba(0,21,41,.08);
box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
.hamburger-container {
line-height: 46px;
height: 100%;
float: left;
cursor: pointer;
transition: background .3s;
-webkit-tap-highlight-color:transparent;
transition: background 0.3s;
-webkit-tap-highlight-color: transparent;
&:hover {
background: rgba(0, 0, 0, .025)
background: rgba(0, 0, 0, 0.025);
}
}
@ -151,10 +158,10 @@ export default {
&.hover-effect {
cursor: pointer;
transition: background .3s;
transition: background 0.3s;
&:hover {
background: rgba(0, 0, 0, .025)
background: rgba(0, 0, 0, 0.025);
}
}
}

View File

@ -145,7 +145,7 @@ export const constantRoutes = [
hidden: true,
children: [
{
path: "build/:cusId/:planId/:recipesId",
path: "build",
component: resolve =>
require(["@/views/custom/recipesBuild"], resolve),
name: "RecipiesBuild",

View File

@ -0,0 +1,7 @@
const actions = {
async init({ dispatch }, payload) {
dispatch("global/init", payload);
}
};
export default actions;

View File

@ -11,6 +11,15 @@ const getters = {
roles: state => state.user.roles,
permissions: state => state.user.permissions,
userId: state => state.user.userId,
permission_routes: state => state.permission.routes
}
export default getters
permission_routes: state => state.permission.routes,
//
nutritionistIdOptions: state => state.global.nutritionistIdOptions,
nutriAssisIdOptions: state => state.global.nutriAssisIdOptions,
preSaleIdOptions: state => state.global.preSaleIdOptions,
afterSaleIdOptions: state => state.global.afterSaleIdOptions,
plannerIdOptions: state => state.global.plannerIdOptions,
plannerAssisIdOptions: state => state.global.plannerAssisIdOptions,
operatorIdOptions: state => state.global.operatorIdOptions,
operatorAssisIdOptions: state => state.global.operatorAssisIdOptions
};
export default getters;

View File

@ -6,8 +6,10 @@ import tagsView from "./modules/tagsView";
import permission from "./modules/permission";
import settings from "./modules/settings";
import recipes from "./modules/recipes";
import global from "./modules/global";
import getters from "./getters";
import actions from "./actions";
Vue.use(Vuex);
@ -18,9 +20,11 @@ const store = new Vuex.Store({
tagsView,
permission,
settings,
recipes
recipes,
global
},
getters
getters,
actions
});
export default store;

View File

@ -0,0 +1,60 @@
import { getOptions } from "@/api/custom/global";
const oriState = {
nutritionistIdOptions: [],
nutriAssisIdOptions: [],
preSaleIdOptions: [],
afterSaleIdOptions: [],
plannerIdOptions: [],
plannerAssisIdOptions: [],
operatorIdOptions: [],
operatorAssisIdOptions: []
};
const mutations = {
save(state, payload) {
Object.keys(payload).forEach(key => {
state[key] = payload[key];
});
},
clean(state) {
Object.keys(oriState).forEach(key => {
state[key] = oriState[key];
});
}
};
const actions = {
async init({ commit }, payload) {
const { data: optionsData } = await getOptions();
const options = optionsData.reduce((opts, cur) => {
if (!opts[cur.postCode]) {
opts[cur.postCode] = [{ dictValue: 0, dictLabel: "无", remark: null }];
}
opts[cur.postCode].push({
dictValue: cur.userId,
dictLabel: cur.userName,
remark: cur.remark
});
return opts;
}, {});
commit("save", {
nutritionistIdOptions: options["nutri"] || [],
nutriAssisIdOptions: options["nutri_assis"] || [],
preSaleIdOptions: options["pre_sale"] || [],
afterSaleIdOptions: options["after_sale"] || [],
plannerIdOptions: options["planner"] || [],
plannerAssisIdOptions: options["planner_assis"] || [],
operatorIdOptions: options["operator"] || [],
operatorAssisIdOptions: options["operator_assis"] || []
});
}
};
const getters = {};
export default {
namespaced: true,
state: Object.assign({}, oriState),
mutations,
actions,
getters
};

View File

@ -1,22 +1,68 @@
import { getOrder } from "@/api/custom/order";
import { getCustomerPhysicalSignsByCusId } from "@/api/custom/customer";
import { dealHealthy } from "@/utils/healthyData";
import { getRecipesPlan } from "@/api/custom/recipesPlan";
import { getRecipes } from "@/api/custom/recipes";
import {
getRecipesApi,
updateDishesDetailApi,
addDishesApi,
deleteDishesApi,
addRecipesApi
} from "@/api/custom/recipes";
import { getDicts } from "@/api/system/dict/data";
import dayjs from "dayjs";
const oriState = {
cusId: undefined,
planId: undefined,
recipesId: undefined,
healthyData: {},
healthDataLoading: false,
healthyDataType: 0,
recipesData: []
recipesData: [],
recipesDataLoading: false,
cusUnitOptions: [],
cusWeightOptions: [],
dishesTypeOptions: [],
typeOptions: [],
currentDay: -1,
startDate: "",
endDate: ""
};
const mutations = {
setHealtyData(state, payload) {
state.healthyDataType = payload.healthyDataType;
state.healthyData = payload.healthyData;
updateRecipesDishesDetail(state, payload) {
const tarDishes = state.recipesData[payload.num].dishes.find(
obj => obj.dishesId === payload.dishesId
);
if (tarDishes) {
const tarIgd = tarDishes.igdList.find(obj => obj.id === payload.igdId);
if (tarIgd) {
Object.keys(payload).forEach(key => {
tarIgd[key] = payload[key];
});
}
}
},
setRecipesData(state, payload) {
state.recipesData = payload.recipesData;
addRecipesDishes(state, payload) {
state.recipesData[payload.num].dishes.push(payload.data);
},
setCurrentDay(state, payload) {
state.currentDay =
payload.currentDay === state.currentDay ? -1 : payload.currentDay;
},
deleteSomeDayDishes(state, payload) {
// console.log(payload);
state.recipesData[payload.num].dishes = state.recipesData[
payload.num
].dishes.filter(obj => obj.id !== payload.id);
},
updateStateData(state, payload) {
Object.keys(payload).forEach(key => {
state[key] = payload[key];
});
},
setDate(state, payload) {
state.startDate = payload.startDate;
state.endDate = payload.endDate;
},
clean(state) {
// console.log("clean");
@ -27,40 +73,281 @@ const mutations = {
};
const actions = {
async init({ commit }, payload) {
const orderResult = await getOrder(payload.cusId);
if (!orderResult.data.cusId) {
throw new Error("未找到用户id");
}
async init({ commit, dispatch }, payload) {
// console.log(payload);
//
commit("updateStateData", payload);
//
getDicts("cus_cus_unit").then(response => {
commit("updateStateData", { cusUnitOptions: response.data });
});
getDicts("cus_cus_weight").then(response => {
commit("updateStateData", { cusWeightOptions: response.data });
});
getDicts("cus_dishes_type").then(response => {
commit("updateStateData", { typeOptions: response.data });
});
getDicts("cus_dishes_type").then(response => {
commit("updateStateData", { dishesTypeOptions: response.data });
});
// 健康数据
const healthyDataResult = await getCustomerPhysicalSignsByCusId(
orderResult.data.cusId
);
if (healthyDataResult.code === 200) {
commit("setHealtyData", {
healthyDataType: healthyDataResult.data.type,
healthyData: dealHealthy(healthyDataResult.data.customerHealthy)
});
} else {
throw new Error(healthyDataResult.msg);
if (payload.cusId) {
dispatch("getHealthyData", payload);
}
// 食谱数据
if (payload.recipesId) {
const recipesDataResult = await getRecipes(payload.recipesId);
dispatch("getRecipesInfo", payload);
}
},
async getHealthyData({ commit }, payload) {
commit("updateStateData", { healthDataLoading: true });
const healthyDataResult = await getCustomerPhysicalSignsByCusId(
payload.cusId
);
let healthyData = undefined,
healthyDataType = 0;
if (healthyDataResult.code === 200) {
if (!healthyDataResult.data.customerHealthy) {
throw new Error("客户还没填写健康评估表");
}
healthyDataType = healthyDataResult.data.type;
healthyData = dealHealthy(healthyDataResult.data.customerHealthy);
} else {
throw new Error(healthyDataResult.msg);
}
commit("updateStateData", {
healthDataLoading: false,
healthyDataType,
healthyData
});
},
async getRecipesInfo({ commit }, payload) {
commit("updateStateData", {
recipesDataLoading: true
});
const recipesDataResult = await getRecipesApi(payload.recipesId);
let recipesData = undefined;
if (recipesDataResult.code === 200) {
commit("setRecipesData", {
recipesData: recipesDataResult.data
recipesData = recipesDataResult.data.map(dayData => {
return {
id: dayData.id,
numDay: dayData.numDay,
dishes: dayData.dishes.reduce((arr, cur) => {
if (
cur.dishesId > -1 &&
cur.name &&
cur.igdList.length > 0 &&
cur.type !== "0"
) {
arr.push({
id: cur.id,
dishesId: cur.dishesId,
name: cur.name,
menuId: cur.menuId,
methods: cur.methods,
type: cur.type,
isMain: cur.isMain,
igdList: cur.igdList.reduce((igdArr, igdData) => {
if (igdData.id > 0) {
const tarDetail = cur.detail.find(
obj => obj.id === igdData.id
);
igdArr.push({
id: igdData.id,
name: igdData.name,
carbonRatio: igdData.carbonRatio,
fatRatio: igdData.fatRatio,
proteinRatio: igdData.proteinRatio,
cusUnit: tarDetail ? tarDetail.cus_unit : igdData.cusUnit,
cusWeight: tarDetail
? parseFloat(tarDetail.cus_weight)
: igdData.cusWeight,
weight: tarDetail
? parseFloat(tarDetail.weight)
: igdData.weight,
notRec: igdData.notRec,
rec: igdData.rec,
type: igdData.type
});
}
return igdArr;
}, [])
});
}
return arr;
}, [])
};
});
} else {
throw new Error(recipesDataResult.msg);
}
commit("updateStateData", { recipesDataLoading: false, recipesData });
},
async saveRecipes({ commit, dispatch, state }, payload) {
const { recipesData, cusId, planId } = state;
const params = {
cusId,
planId,
menus: recipesData.map((menu, idx) => ({
date: dayjs(state.startDate)
.add(idx, "day")
.format("YYYY-MM-DD"),
cusId,
dishes: menu.dishes.map(dObj => ({
dishesId: dObj.dishesId,
type: dObj.type,
detail: dObj.igdList.map(igd => ({
id: igd.id,
weight: igd.weight,
cus_unit: igd.cusUnit,
cus_weight: igd.cusWeight
}))
}))
}))
};
const result = await addRecipesApi(params);
if (result.code === 200) {
const recipesId = result.data;
commit("updateStateData", { recipesId });
dispatch("getRecipesInfo", { recipesId });
}
// console.log(params);
},
async addDishes({ commit, state }, payload) {
if (state.recipesId) {
const tarRecipesObj = state.recipesData[payload.num];
if (tarRecipesObj && payload.data) {
const { dishesId, type, igdList } = payload.data;
const params = {
type,
dishesId,
menuId: tarRecipesObj.id,
detail: igdList.map(igd => ({
id: igd.id,
weight: igd.weight,
cus_unit: igd.cusUnit,
cus_weight: igd.cusWeight
}))
};
const result = await addDishesApi(params);
if (result.code === 200) {
payload.menuId = tarRecipesObj.id;
// 更新id
payload.data.id = result.data;
commit("addRecipesDishes", payload);
}
}
// console.log(result);
} else {
commit("addRecipesDishes", payload);
}
},
async updateDishes({ commit, state }, payload) {
if (state.recipesId) {
const tarDishes = state.recipesData[payload.num].dishes.find(
obj => obj.dishesId === payload.dishesId
);
if (tarDishes) {
const mTarDishes = JSON.parse(JSON.stringify(tarDishes));
const tarIgd = mTarDishes.igdList.find(obj => obj.id === payload.igdId);
if (tarIgd) {
payload.weight && (tarIgd.weight = payload.weight);
payload.cusWeight && (tarIgd.cusWeight = payload.cusWeight);
payload.cusUnit && (tarIgd.cusUnit = payload.cusUnit);
const params = {
id: mTarDishes.id,
detail: mTarDishes.igdList.map(igd => ({
id: igd.id,
weight: igd.weight,
cus_unit: igd.cusUnit,
cus_weight: igd.cusWeight
}))
};
const result = await updateDishesDetailApi(params);
if (result.code === 200) {
commit("updateRecipesDishesDetail", payload);
}
}
} else {
commit("updateRecipesDishesDetail", payload);
}
}
},
async deleteDishes({ commit, state }, payload) {
if (state.recipesId) {
const tarDishes = state.recipesData[payload.num].dishes.find(
obj => obj.id === payload.id
);
if (tarDishes) {
const result = await deleteDishesApi(tarDishes.id);
if (result.code === 200) {
commit("deleteSomeDayDishes", payload);
}
// console.log(params);
}
} else {
commit("deleteSomeDayDishes", payload);
}
},
async deleteMenu({ commit }, payload) {}
};
const getters = {};
const getters = {
analyseData: state => {
if (!state.recipesData.length) {
return [];
}
const datas =
state.currentDay > -1
? [state.recipesData[state.currentDay]]
: state.recipesData;
const nutriData = datas.map(data =>
data.dishes.reduce(
(obj, cur) => {
cur.igdList.forEach(igd => {
obj.pWeight += (igd.weight / 100) * igd.proteinRatio;
obj.pHeat = obj.pWeight * 4;
obj.fWeight += (igd.weight / 100) * igd.fatRatio;
obj.fHeat = obj.fWeight * 9;
obj.cWeight += (igd.weight / 100) * igd.carbonRatio;
obj.cHeat = obj.cWeight * 4;
});
return obj;
},
{
name: `${data.numDay}`,
pWeight: 0,
fWeight: 0,
cWeight: 0,
pHeat: 0,
fHeat: 0,
cHeat: 0
}
)
);
// console.log(nutriData);
return nutriData;
},
cusUnitDict: state =>
state.cusUnitOptions.reduce((obj, cur) => {
obj[cur.dictValue] = cur.dictLabel;
return obj;
}, {}),
cusWeightDict: state =>
state.cusWeightOptions.reduce((obj, cur) => {
obj[cur.dictValue] = cur.dictLabel;
return obj;
}, {}),
typeDict: state =>
state.typeOptions.reduce((obj, cur) => {
obj[cur.dictValue] = cur.dictLabel;
return obj;
}, {})
};
export default {
namespaced: true,

View File

@ -0,0 +1,257 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['exports', 'echarts'], factory);
} else if (
typeof exports === 'object' &&
typeof exports.nodeName !== 'string'
) {
// CommonJS
factory(exports, require('echarts'));
} else {
// Browser globals
factory({}, root.echarts);
}
})(this, function(exports, echarts) {
var log = function(msg) {
if (typeof console !== 'undefined') {
console && console.error && console.error(msg);
}
};
if (!echarts) {
log('ECharts is not Loaded');
return;
}
var colorPalette = [
'#c12e34',
'#e6b600',
'#0098d9',
'#2b821d',
'#005eaa',
'#339ca8',
'#cda819',
'#32a487'
];
var theme = {
color: colorPalette,
title: {
textStyle: {
fontWeight: 'normal',
fontSize: 14
}
},
visualMap: {
color: ['#1790cf', '#a2d4e6']
},
toolbox: {
iconStyle: {
normal: {
borderColor: '#06467c'
}
}
},
tooltip: {
textStyle: {
color: '#262626',
fontSize: 12
},
backgroundColor: 'rgba(255,255,255,0.9)',
borderWidth: 1,
padding: 10,
borderColor: '#ccc',
extraCssText: 'box-shadow: 0 0 3px rgba(0, 0, 0, 0.3);',
},
categoryAxis: {
axisLine: {
show: true,
lineStyle: {
color: '#ebebeb',
},
},
axisTick: {
show: false,
lineStyle: {
color: '#ebebeb',
},
},
axisLabel: {
show: true,
textStyle: {
color: '#262626',
},
},
splitLine: {
show: false,
lineStyle: {
color: ['#ccc'],
},
},
splitArea: {
show: false,
areaStyle: {
color: ['rgba(250,250,250,0.3)', 'rgba(200,200,200,0.3)'],
},
},
},
valueAxis: {
axisLine: {
show: true,
lineStyle: {
color: '#ebebeb',
},
},
axisTick: {
show: false,
lineStyle: {
color: '#ebebeb',
},
},
axisLabel: {
show: true,
textStyle: {
color: '#262626',
},
},
splitLine: {
show: false,
lineStyle: {
color: ['#ccc'],
},
},
splitArea: {
show: false,
areaStyle: {
color: ['rgba(250,250,250,0.3)', 'rgba(200,200,200,0.3)'],
},
},
},
dataZoom: {
dataBackgroundColor: '#dedede',
fillerColor: 'rgba(154,217,247,0.2)',
handleColor: '#005eaa'
},
timeline: {
lineStyle: {
color: '#005eaa'
},
controlStyle: {
color: '#005eaa',
borderColor: '#005eaa'
}
},
candlestick: {
itemStyle: {
color: '#c12e34',
color0: '#2b821d'
},
lineStyle: {
width: 1,
color: '#c12e34',
color0: '#2b821d'
},
areaStyle: {
color: '#e6b600',
color0: '#005eaa'
}
},
graph: {
itemStyle: {
color: '#e6b600'
},
linkStyle: {
color: '#005eaa'
}
},
map: {
itemStyle: {
color: '#f2385a',
borderColor: '#eee',
areaColor: '#ddd'
},
areaStyle: {
color: '#ddd'
},
label: {
color: '#c12e34'
}
},
gauge: {
axisLine: {
show: true,
lineStyle: {
color: [
[0.2, '#2b821d'],
[0.8, '#005eaa'],
[1, '#c12e34']
],
width: 5
}
},
axisTick: {
splitNumber: 10,
length: 8,
lineStyle: {
color: 'auto'
}
},
axisLabel: {
textStyle: {
color: 'auto'
}
},
splitLine: {
length: 12,
lineStyle: {
color: 'auto'
}
},
pointer: {
length: '90%',
width: 3,
color: 'auto'
},
title: {
textStyle: {
color: '#333'
}
},
detail: {
textStyle: {
color: 'auto'
}
}
}
};
echarts.registerTheme('myShine', theme);
});

View File

@ -384,7 +384,8 @@ export const yesNoName = [
"longEatDrugFlag",
"allergyFlag",
"smokeFlag",
"secondSmoke"
"secondSmoke",
"sleepDrugFlag"
];
export const dictName = [
@ -550,7 +551,7 @@ export function dealHealthy(customerHealthy) {
customerHealthy.getupTime += "点";
}
if (customerHealthy.hasOwnProperty("signList")) {
customerHealthy.signStr = customerHealthy.signList
customerHealthy.signStr = (customerHealthy.signList || [])
.map(obj => obj.name)
.join("");
}

View File

@ -1,8 +1,20 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<el-form
:model="queryParams"
ref="queryForm"
:inline="true"
v-show="showSearch"
label-width="68px"
>
<el-form-item label="岗位" prop="postId">
<el-select v-model="queryParams.postId" placeholder="请选择岗位" clearable size="small" @change="searchPostChange">
<el-select
v-model="queryParams.postId"
placeholder="请选择岗位"
clearable
size="small"
@change="searchPostChange"
>
<el-option
v-for="dict in postIdOptions"
:key="dict.dictValue"
@ -12,7 +24,12 @@
</el-select>
</el-form-item>
<el-form-item label="业务员" prop="userId">
<el-select v-model="queryParams.userId" placeholder="请选择业务员" clearable size="small">
<el-select
v-model="queryParams.userId"
placeholder="请选择业务员"
clearable
size="small"
>
<el-option
v-for="dict in searchUserIdOptions"
:key="dict.dictValue"
@ -22,8 +39,16 @@
</el-select>
</el-form-item>
<el-form-item>
<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-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>
@ -70,25 +95,36 @@
<!-- >导出-->
<!-- </el-button>-->
<!-- </el-col>-->
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
<right-toolbar
:showSearch.sync="showSearch"
@queryTable="getList"
></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="commisionList" :span-method="objectSpanMethod"
@selection-change="handleSelectionChange">
<el-table-column label="业务员" align="center" prop="userName"/>
<el-table-column label="岗位" align="center" prop="postName"/>
<el-table
v-loading="loading"
:data="commisionList"
:span-method="objectSpanMethod"
@selection-change="handleSelectionChange"
>
<el-table-column label="业务员" align="center" prop="userName" />
<el-table-column label="岗位" align="center" prop="postName" />
<el-table-column label="金额" align="center" prop="amount">
<template scope="scope">
{{toThousands(scope.row.amount)}}
{{ toThousands(scope.row.amount) }}
</template>
</el-table-column>
<el-table-column label="比例" align="center" prop="rate">
<template scope="scope">
{{scope.row.rate + '%'}}
{{ scope.row.rate + "%" }}
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remark"/>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column
label="操作"
align="center"
class-name="small-padding fixed-width"
>
<template slot-scope="scope">
<el-button
size="mini"
@ -111,7 +147,7 @@
</el-table>
<pagination
v-show="total>0"
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@ -124,7 +160,11 @@
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-col :span="12">
<el-form-item label="岗位" prop="postId">
<el-select v-model="form.postId" placeholder="请选择岗位" @change="postChange">
<el-select
v-model="form.postId"
placeholder="请选择岗位"
@change="postChange"
>
<el-option
v-for="dict in postIdOptions"
:key="dict.dictValue"
@ -148,17 +188,21 @@
</el-col>
<el-col :span="12">
<el-form-item label="金额" prop="amount">
<el-input v-model="form.amount" placeholder="请输入金额"/>
<el-input v-model="form.amount" placeholder="请输入金额" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="分成比例" prop="rate">
<el-input v-model="form.rate" placeholder="请输入比例"/>
<el-input v-model="form.rate" placeholder="请输入比例" />
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容"/>
<el-input
v-model="form.remark"
type="textarea"
placeholder="请输入内容"
/>
</el-form-item>
</el-col>
</el-form>
@ -172,18 +216,18 @@
</template>
<script>
import {
import {
listCommision,
getCommision,
delCommision,
addCommision,
updateCommision,
exportCommision,
} from "@/api/custom/commision";
} from "@/api/custom/commision";
import {getOptions} from "@/api/custom/order";
import { getOptions } from "@/api/custom/global";
export default {
export default {
name: "CommisionConfig",
data() {
return {
@ -229,23 +273,21 @@
//
rules: {
userId: [
{required: true, message: "业务员不能为空", trigger: "change"}
{ required: true, message: "业务员不能为空", trigger: "change" },
],
postId: [
{required: true, message: "岗位不能为空", trigger: "change"}
],
amount: [
{required: true, message: "金额不能为空", trigger: "blur"}
{ required: true, message: "岗位不能为空", trigger: "change" },
],
amount: [{ required: true, message: "金额不能为空", trigger: "blur" }],
rate: [
{required: true, message: "分成比例不能为空", trigger: "blur"}
{ required: true, message: "分成比例不能为空", trigger: "blur" },
],
}
},
};
},
created() {
this.getList();
getOptions().then(response => {
getOptions().then((response) => {
this.options = response.data.reduce((opts, cur) => {
// if (cur.postCode.startsWith('planner')) {
// return opts;
@ -253,28 +295,42 @@
if (!opts[cur.postId]) {
opts[cur.postId] = [];
}
opts[cur.postId].push({dictValue: cur.userId, dictLabel: cur.userName});
opts[cur.postId].push({
dictValue: cur.userId,
dictLabel: cur.userName,
});
if (!this.postIdOptions.some(opt => opt.dictValue === cur.postId)) {
this.postIdOptions.push({dictValue: cur.postId, dictLabel: cur.postName});
if (!this.postIdOptions.some((opt) => opt.dictValue === cur.postId)) {
this.postIdOptions.push({
dictValue: cur.postId,
dictLabel: cur.postName,
});
}
if (!this.totalUserIdOptions.some(opt => opt.dictValue === cur.userId)) {
this.totalUserIdOptions.push({dictValue: cur.userId, dictLabel: cur.userName});
if (
!this.totalUserIdOptions.some((opt) => opt.dictValue === cur.userId)
) {
this.totalUserIdOptions.push({
dictValue: cur.userId,
dictLabel: cur.userName,
});
}
return opts;
}, {});
this.searchUserIdOptions = this.totalUserIdOptions.slice();
});
},
methods: {
/** 查询业务提成比例列表 */
getList() {
this.loading = true;
listCommision(this.queryParams).then(response => {
listCommision(this.queryParams).then((response) => {
this.commisionList = response.rows.reduce((arr, cur, idx, oriArr) => {
for (let i = 0; i < arr.length; i++) {
if (arr[i].some(e => e.userId === cur.userId && e.postId === cur.postId)) {
if (
arr[i].some(
(e) => e.userId === cur.userId && e.postId === cur.postId
)
) {
arr[i].push(cur);
break;
} else if (i === arr.length - 1) {
@ -287,27 +343,32 @@
}
if (idx === oriArr.length - 1) {
const finalArr = [];
arr.forEach(tmpArr => {
tmpArr.sort((a, b) => a.amount - b.amount)
arr.forEach((tmpArr) => {
tmpArr
.sort((a, b) => a.amount - b.amount)
.forEach((elm, elmIdx) => {
finalArr.push({
...elm,
userSpan: elmIdx ? {
userSpan: elmIdx
? {
rowspan: 0,
colspan: 0
} : {
rowspan: tmpArr.length,
colspan: 1
},
postSpan: elmIdx ? {
rowspan: 0,
colspan: 0
} : {
rowspan: tmpArr.length,
colspan: 1
colspan: 0,
}
})
})
: {
rowspan: tmpArr.length,
colspan: 1,
},
postSpan: elmIdx
? {
rowspan: 0,
colspan: 0,
}
: {
rowspan: tmpArr.length,
colspan: 1,
},
});
});
});
return finalArr;
}
@ -339,7 +400,7 @@
createTime: null,
updateBy: null,
updateTime: null,
remark: null
remark: null,
};
this.resetForm("form");
},
@ -356,9 +417,9 @@
},
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.ruleId)
this.single = selection.length !== 1
this.multiple = !selection.length
this.ids = selection.map((item) => item.ruleId);
this.single = selection.length !== 1;
this.multiple = !selection.length;
},
/** 新增按钮操作 */
handleAdd() {
@ -369,8 +430,8 @@
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const ruleId = row.ruleId || this.ids
getCommision(ruleId, row.postId).then(response => {
const ruleId = row.ruleId || this.ids;
getCommision(ruleId, row.postId).then((response) => {
this.form = response.data;
this.userIdOptions = this.options[this.form.postId];
this.open = true;
@ -379,10 +440,10 @@
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
this.$refs["form"].validate((valid) => {
if (valid) {
if (this.form.ruleId != null) {
updateCommision(this.form).then(response => {
updateCommision(this.form).then((response) => {
if (response.code === 200) {
this.msgSuccess("修改成功");
this.open = false;
@ -390,7 +451,7 @@
}
});
} else {
addCommision(this.form).then(response => {
addCommision(this.form).then((response) => {
if (response.code === 200) {
this.msgSuccess("新增成功");
this.open = false;
@ -404,33 +465,41 @@
/** 删除按钮操作 */
handleDelete(row) {
const ruleIds = row.ruleId || this.ids;
this.$confirm('是否确认删除业务提成比例编号为"' + ruleIds + '"的数据项?', "警告", {
this.$confirm(
'是否确认删除业务提成比例编号为"' + ruleIds + '"的数据项?',
"警告",
{
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function () {
type: "warning",
}
)
.then(function () {
return delCommision(ruleIds);
}).then(() => {
})
.then(() => {
this.getList();
this.msgSuccess("删除成功");
}).catch(function () {
});
})
.catch(function () {});
},
/** 导出按钮操作 */
handleExport() {
const queryParams = this.queryParams;
this.$confirm('是否确认导出所有业务提成比例数据项?', "警告", {
this.$confirm("是否确认导出所有业务提成比例数据项?", "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function () {
type: "warning",
})
.then(function () {
return exportCommision(queryParams);
}).then(response => {
})
.then((response) => {
this.download(response.msg);
}).catch(function () {
});
})
.catch(function () {});
},
objectSpanMethod({row, column, rowIndex, columnIndex}) {
objectSpanMethod({ row, column, rowIndex, columnIndex }) {
if (columnIndex === 0) {
return row.userSpan;
} else if (columnIndex === 1) {
@ -447,7 +516,7 @@
}
this.searchUserIdOptions = this.options[postId];
this.queryParams.userId = null;
}
}
};
},
},
};
</script>

View File

@ -1,8 +1,20 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<el-form
:model="queryParams"
ref="queryForm"
:inline="true"
v-show="showSearch"
label-width="68px"
>
<el-form-item label="岗位" prop="postId">
<el-select v-model="queryParams.postId" placeholder="请选择岗位" clearable size="small" @change="searchPostChange">
<el-select
v-model="queryParams.postId"
placeholder="请选择岗位"
clearable
size="small"
@change="searchPostChange"
>
<el-option
v-for="dict in postIdOptions"
:key="dict.dictValue"
@ -12,7 +24,13 @@
</el-select>
</el-form-item>
<el-form-item label="业务员" prop="userId">
<el-select v-model="queryParams.userId" filterable placeholder="请选择业务员" clearable size="small">
<el-select
v-model="queryParams.userId"
filterable
placeholder="请选择业务员"
clearable
size="small"
>
<el-option
v-for="dict in searchUserIdOptions"
:key="dict.dictValue"
@ -26,12 +44,21 @@
v-model="month"
@change="monthRangeChange"
type="month"
placeholder="选择月">
placeholder="选择月"
>
</el-date-picker>
</el-form-item>
<el-form-item>
<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-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>
@ -46,37 +73,43 @@
>导出
</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
<right-toolbar
:showSearch.sync="showSearch"
@queryTable="getList"
></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="commisionList"
@selection-change="handleSelectionChange">
<el-table-column label="业务员" align="center" prop="userName"/>
<el-table-column label="岗位" align="center" prop="postName"/>
<el-table
v-loading="loading"
:data="commisionList"
@selection-change="handleSelectionChange"
>
<el-table-column label="业务员" align="center" prop="userName" />
<el-table-column label="岗位" align="center" prop="postName" />
<el-table-column label="总金额" align="center" prop="amount">
<template scope="scope">
{{toThousands(scope.row.amount)}}
{{ toThousands(scope.row.amount) }}
</template>
</el-table-column>
<el-table-column label="比例" align="center" prop="rate">
<template scope="scope">
{{scope.row.rate + '%'}}
{{ scope.row.rate + "%" }}
</template>
</el-table-column>
<el-table-column label="提成" align="center" prop="commision">
<template scope="scope">
{{scope.row.commision.toFixed(2)}}
{{ scope.row.commision.toFixed(2) }}
</template>
</el-table-column>
<el-table-column label="下月应发提成" align="center" prop="commision">
<template scope="scope">
{{scope.row.commision.toFixed(2)}}
{{ scope.row.commision.toFixed(2) }}
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@ -86,16 +119,13 @@
</template>
<script>
import {
detailCommision,
exportCommision,
} from "@/api/custom/commision";
import { detailCommision, exportCommision } from "@/api/custom/commision";
import {getOptions} from "@/api/custom/order";
import { getOptions } from "@/api/custom/global";
import dayjs from 'dayjs';
import dayjs from "dayjs";
export default {
export default {
name: "CommisionDetail",
data() {
return {
@ -138,7 +168,7 @@
},
created() {
this.getList();
getOptions().then(response => {
getOptions().then((response) => {
this.options = response.data.reduce((opts, cur) => {
// if (cur.postCode.startsWith('planner')) {
// return opts;
@ -146,32 +176,49 @@
if (!opts[cur.postId]) {
opts[cur.postId] = [];
}
opts[cur.postId].push({dictValue: cur.userId, dictLabel: cur.userName});
opts[cur.postId].push({
dictValue: cur.userId,
dictLabel: cur.userName,
});
if (!this.postIdOptions.some(opt => opt.dictValue === cur.postId)) {
this.postIdOptions.push({dictValue: cur.postId, dictLabel: cur.postName});
if (!this.postIdOptions.some((opt) => opt.dictValue === cur.postId)) {
this.postIdOptions.push({
dictValue: cur.postId,
dictLabel: cur.postName,
});
}
if (!this.totalUserIdOptions.some(opt => opt.dictValue === cur.userId)) {
this.totalUserIdOptions.push({dictValue: cur.userId, dictLabel: cur.userName});
if (
!this.totalUserIdOptions.some((opt) => opt.dictValue === cur.userId)
) {
this.totalUserIdOptions.push({
dictValue: cur.userId,
dictLabel: cur.userName,
});
}
return opts;
}, {});
this.postIdOptions = this.postIdOptions.sort((a, b) => a.dictValue - b.dictValue);
this.postIdOptions = this.postIdOptions.sort(
(a, b) => a.dictValue - b.dictValue
);
this.searchUserIdOptions = this.totalUserIdOptions.slice();
})
});
},
methods: {
/** 查询业务提成比例列表 */
getList() {
this.loading = true;
const dateRange = [dayjs(this.month).startOf('month').format('YYYY-MM-DD'), dayjs(this.month).endOf('month').format('YYYY-MM-DD')];
const dateRange = [
dayjs(this.month).startOf("month").format("YYYY-MM-DD"),
dayjs(this.month).endOf("month").format("YYYY-MM-DD"),
];
// console.log(dateRange)
detailCommision(this.addDateRange(this.queryParams, dateRange)).then(response => {
detailCommision(this.addDateRange(this.queryParams, dateRange)).then(
(response) => {
this.commisionList = response.rows;
this.total = response.total;
this.loading = false;
});
}
);
},
//
userIdFormat(row, column) {
@ -195,23 +242,25 @@
},
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.ruleId)
this.single = selection.length !== 1
this.multiple = !selection.length
this.ids = selection.map((item) => item.ruleId);
this.single = selection.length !== 1;
this.multiple = !selection.length;
},
/** 导出按钮操作 */
handleExport() {
const queryParams = this.queryParams;
this.$confirm('是否确认导出所有业务提成比例数据项?', "警告", {
this.$confirm("是否确认导出所有业务提成比例数据项?", "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function () {
type: "warning",
})
.then(function () {
return exportCommision(queryParams);
}).then(response => {
})
.then((response) => {
this.download(response.msg);
}).catch(function () {
});
})
.catch(function () {});
},
monthRangeChange(time) {
this.month = time;
@ -226,7 +275,7 @@
}
this.searchUserIdOptions = this.options[postId];
this.queryParams.userId = null;
}
}
};
},
},
};
</script>

View File

@ -1,8 +1,20 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<el-form
:model="queryParams"
ref="queryForm"
:inline="true"
v-show="showSearch"
label-width="68px"
>
<el-form-item label="岗位" prop="postId">
<el-select v-model="queryParams.postId" placeholder="请选择岗位" clearable size="small" @change="searchPostChange">
<el-select
v-model="queryParams.postId"
placeholder="请选择岗位"
clearable
size="small"
@change="searchPostChange"
>
<el-option
v-for="dict in postIdOptions"
:key="dict.dictValue"
@ -12,7 +24,13 @@
</el-select>
</el-form-item>
<el-form-item label="业务员" prop="userId">
<el-select v-model="queryParams.userId" filterable placeholder="请选择业务员" clearable size="small">
<el-select
v-model="queryParams.userId"
filterable
placeholder="请选择业务员"
clearable
size="small"
>
<el-option
v-for="dict in searchUserIdOptions"
:key="dict.dictValue"
@ -26,20 +44,31 @@
v-model="month"
@change="monthRangeChange"
type="month"
placeholder="选择月份">
placeholder="选择月份"
>
</el-date-picker>
</el-form-item>
<el-form-item>
<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-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>
<div><span style="color:#E6A23C;font-family:PingFang SC">
<div>
<span style="color: #e6a23c; font-family: PingFang SC">
注意事项
<br/>12021年1月开始的订单才开始按天计算提成只计算已审核的订单
<br/>2发工资日期定为每月15号若当前日期大于15号则认定上个月的工资已发放
</span></div>
<el-row :gutter="10" class="mb8" style="margin-top:10px;">
<br />12021年1月开始的订单才开始按天计算提成只计算已审核的订单
<br />2发工资日期定为每月15号若当前日期大于15号则认定上个月的工资已发放
</span>
</div>
<el-row :gutter="10" class="mb8" style="margin-top: 10px">
<el-col :span="1.5">
<el-button
type="warning"
@ -50,71 +79,113 @@
>导出
</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
<right-toolbar
:showSearch.sync="showSearch"
@queryTable="getList"
></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="commisionList"
@selection-change="handleSelectionChange" stripe :row-class-name="tableRowClassName">
<el-table
v-loading="loading"
:data="commisionList"
@selection-change="handleSelectionChange"
stripe
:row-class-name="tableRowClassName"
>
<el-table-column label="业务员" align="center" prop="nickName">
<template slot-scope="scope">
<span>{{ scope.row.nickName }}</span>
</template>
</el-table-column>
<el-table-column label="岗位" align="center" prop="postName"/>
<el-table-column label="总提成" align="center" prop="totalCommissionAmount">
<el-table-column label="岗位" align="center" prop="postName" />
<el-table-column
label="总提成"
align="center"
prop="totalCommissionAmount"
>
<template scope="scope">
{{scope.row.totalCommissionAmount.toFixed(fixLength)}}
{{ scope.row.totalCommissionAmount.toFixed(fixLength) }}
</template>
</el-table-column>
<el-table-column label="已发放提成" align="center" prop="totalHasSentCommissionAmount">
<el-table-column
label="已发放提成"
align="center"
prop="totalHasSentCommissionAmount"
>
<template scope="scope">
{{scope.row.totalHasSentCommissionAmount.toFixed(fixLength)}}
{{ scope.row.totalHasSentCommissionAmount.toFixed(fixLength) }}
</template>
</el-table-column>
<el-table-column label="未发放提成" align="center" prop="totalNotSentCommissionAmount">
<el-table-column
label="未发放提成"
align="center"
prop="totalNotSentCommissionAmount"
>
<template scope="scope">
{{scope.row.totalNotSentCommissionAmount.toFixed(fixLength)}}
{{ scope.row.totalNotSentCommissionAmount.toFixed(fixLength) }}
</template>
</el-table-column>
<el-table-column label="下月应发提成" align="center" prop="nextMonthCommission">
<el-table-column
label="下月应发提成"
align="center"
prop="nextMonthCommission"
>
<template scope="scope">
{{scope.row.nextMonthCommission.toFixed(fixLength)}}
{{ scope.row.nextMonthCommission.toFixed(fixLength) }}
</template>
</el-table-column>
<el-table-column label="操作" align="center">
<template scope="scope">
<el-button type="text" @click="openFormDialog('查看发放计划', scope.row)">查看发放计划</el-button>
<el-button
type="text"
@click="openFormDialog('查看发放计划', scope.row)"
>查看发放计划</el-button
>
</template>
</el-table-column>
<!--<el-table-column label="提成" align="center" prop="commissionTotalAmount"></el-table-column>-->
</el-table>
<pagination
v-show="total>0"
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<el-dialog title="提成发放计划" :visible.sync="sendCommissionPlanTable" width="40%" align="center">
<el-table :data="sendCommissionPlan.list" show-summary :summary-method="getSummaries">
<el-table-column property="nickName" label="姓名" width="150"></el-table-column>
<el-dialog
title="提成发放计划"
:visible.sync="sendCommissionPlanTable"
width="40%"
align="center"
>
<el-table
:data="sendCommissionPlan.list"
show-summary
:summary-method="getSummaries"
>
<el-table-column
property="nickName"
label="姓名"
width="150"
></el-table-column>
<el-table-column property="yearMonth" label="提成月份" width="200">
<template scope="scope">
{{scope.row.yearMonth.substring(0, 4)}}{{scope.row.yearMonth.substring(4)}}
{{ scope.row.yearMonth.substring(0, 4) }}{{
scope.row.yearMonth.substring(4)
}}
</template>
</el-table-column>
<el-table-column property="yearMonthCommission" label="提成金额" width="100">
<el-table-column
property="yearMonthCommission"
label="提成金额"
width="100"
>
<template scope="scope">
{{scope.row.yearMonthCommission.toFixed(fixLength)}}
{{ scope.row.yearMonthCommission.toFixed(fixLength) }}
</template>
</el-table-column>
</el-table>
@ -123,25 +194,24 @@
</template>
<style>
.el-table .warning-row {
.el-table .warning-row {
background: oldlace;
}
}
.el-table .success-row {
.el-table .success-row {
/*background: #1890FF;*/
color: #1890FF
}
color: #1890ff;
}
</style>
<script>
import {
detailDayCommision, exportDayCommision} from "@/api/custom/commision";
import { detailDayCommision, exportDayCommision } from "@/api/custom/commision";
import {getOptions} from "@/api/custom/order";
import { getOptions } from "@/api/custom/global";
import dayjs from 'dayjs';
import dayjs from "dayjs";
export default {
export default {
name: "CommisionDayDetail",
data() {
return {
@ -181,46 +251,63 @@
postId: null,
},
sendCommissionPlanTable: false,
sendCommissionPlan:{},
fixLength: 2
sendCommissionPlan: {},
fixLength: 2,
};
},
created() {
this.getList();
getOptions().then(response => {
getOptions().then((response) => {
this.options = response.data.reduce((opts, cur) => {
if (cur.postCode != ('after_sale') && cur.postCode != 'nutri') {
if (cur.postCode != "after_sale" && cur.postCode != "nutri") {
return opts;
}
if (!opts[cur.postId]) {
opts[cur.postId] = [];
}
opts[cur.postId].push({dictValue: cur.userId, dictLabel: cur.userName});
opts[cur.postId].push({
dictValue: cur.userId,
dictLabel: cur.userName,
});
if (!this.postIdOptions.some(opt => opt.dictValue === cur.postId)) {
this.postIdOptions.push({dictValue: cur.postId, dictLabel: cur.postName});
if (!this.postIdOptions.some((opt) => opt.dictValue === cur.postId)) {
this.postIdOptions.push({
dictValue: cur.postId,
dictLabel: cur.postName,
});
}
if (!this.totalUserIdOptions.some(opt => opt.dictValue === cur.userId)) {
this.totalUserIdOptions.push({dictValue: cur.userId, dictLabel: cur.userName});
if (
!this.totalUserIdOptions.some((opt) => opt.dictValue === cur.userId)
) {
this.totalUserIdOptions.push({
dictValue: cur.userId,
dictLabel: cur.userName,
});
}
return opts;
}, {});
this.postIdOptions = this.postIdOptions.sort((a, b) => a.dictValue - b.dictValue);
this.postIdOptions = this.postIdOptions.sort(
(a, b) => a.dictValue - b.dictValue
);
this.searchUserIdOptions = this.totalUserIdOptions.slice();
})
});
},
methods: {
/** 查询业务提成比例列表 */
getList() {
this.loading = true;
const dateRange = [dayjs(this.month).startOf('month').format('YYYY-MM-DD'), dayjs(this.month).endOf('month').format('YYYY-MM-DD')];
const dateRange = [
dayjs(this.month).startOf("month").format("YYYY-MM-DD"),
dayjs(this.month).endOf("month").format("YYYY-MM-DD"),
];
// console.log(dateRange)
detailDayCommision(this.addDateRange(this.queryParams, dateRange)).then(response => {
detailDayCommision(this.addDateRange(this.queryParams, dateRange)).then(
(response) => {
this.commisionList = response.rows;
this.total = response.total;
this.loading = false;
});
}
);
},
//
userIdFormat(row, column) {
@ -244,23 +331,25 @@
},
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.ruleId)
this.single = selection.length !== 1
this.multiple = !selection.length
this.ids = selection.map((item) => item.ruleId);
this.single = selection.length !== 1;
this.multiple = !selection.length;
},
/** 导出按钮操作 */
handleExport() {
const queryParams = this.queryParams;
this.$confirm('是否确认导出所有业务提成比例数据项?', "警告", {
this.$confirm("是否确认导出所有业务提成比例数据项?", "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function () {
type: "warning",
})
.then(function () {
return exportDayCommision(queryParams);
}).then(response => {
})
.then((response) => {
this.download(response.msg);
}).catch(function () {
});
})
.catch(function () {});
},
monthRangeChange(time) {
this.month = time;
@ -276,10 +365,10 @@
this.searchUserIdOptions = this.options[postId];
this.queryParams.userId = null;
},
openFormDialog(title, row){
openFormDialog(title, row) {
this.sendCommissionPlan = {};
var total = 0;
if(row.sendDetailList != null){
if (row.sendDetailList != null) {
row.sendDetailList.forEach(function (e) {
e.nickName = row.nickName;
total += e.yearMonthCommission;
@ -295,25 +384,25 @@
const sums = [];
columns.forEach((column, index) => {
if (index === 0) {
sums[index] = '合计';
sums[index] = "合计";
return;
}
if(index == 1){
sums[index] = data.length +"个月";
return
if (index == 1) {
sums[index] = data.length + "个月";
return;
}
if(index == 2){
if (index == 2) {
sums[index] = this.sendCommissionPlan.total;
}
});
return sums;
},
tableRowClassName({row, rowIndex}) {
if(this.commisionList.length == rowIndex+1){
tableRowClassName({ row, rowIndex }) {
if (this.commisionList.length == rowIndex + 1) {
return "success-row";
}
return '';
}
}
};
return "";
},
},
};
</script>

View File

@ -1,6 +1,12 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<el-form
:model="queryParams"
ref="queryForm"
:inline="true"
v-show="showSearch"
label-width="68px"
>
<el-form-item label="合同编号" prop="id">
<el-input
v-model="queryParams.id"
@ -29,11 +35,18 @@
/>
</el-form-item>
<el-form-item label="主营养师" prop="nutritionistId">
<el-select v-model="queryParams.nutritionistId" placeholder="请选择主营养师" clearable size="small">
<el-option v-for="dict in nutritionistIdOptions"
<el-select
v-model="queryParams.nutritionistId"
placeholder="请选择主营养师"
clearable
size="small"
>
<el-option
v-for="dict in nutritionistIdOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="parseInt(dict.dictValue)"/>
:value="parseInt(dict.dictValue)"
/>
</el-select>
</el-form-item>
<el-form-item label="合同状态" prop="status">
@ -47,8 +60,16 @@
</el-select>
</el-form-item>
<el-form-item>
<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-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>
@ -92,45 +113,103 @@
<!-- v-hasPermi="['custom:contract:export']"-->
<!-- >导出</el-button>-->
<!-- </el-col>-->
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
<right-toolbar
:showSearch.sync="showSearch"
@queryTable="getList"
></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="contractList" @selection-change="handleSelectionChange">
<el-table
v-loading="loading"
:data="contractList"
@selection-change="handleSelectionChange"
>
<!-- <el-table-column type="selection" width="55" align="center" />-->
<el-table-column label="合同编号" align="center" prop="id" fixed="left" width="150"/>
<el-table-column label="合同状态" align="center" prop="status" width="80" fixed="left">
<el-table-column
label="合同编号"
align="center"
prop="id"
fixed="left"
width="150"
/>
<el-table-column
label="合同状态"
align="center"
prop="status"
width="80"
fixed="left"
>
<template slot-scope="scope">
<el-tag
:type="scope.row.status === 'yes' ? 'success' : 'danger'"
disable-transitions>
{{scope.row.status === 'yes' ? '已签订':'未签订'}}
disable-transitions
>
{{ scope.row.status === "yes" ? "已签订" : "未签订" }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="客户姓名" align="center" prop="name" fixed="left" width="200"/>
<el-table-column label="证件号" align="center" prop="cusId" width="190"/>
<el-table-column label="电话" align="center" prop="phone" width="120"/>
<el-table-column label="服务时间" align="center" prop="serveTime" :formatter="serveTimeFormat" width="100"/>
<el-table-column label="服务承诺" align="center" prop="servePromise" width="100">
<el-table-column
label="客户姓名"
align="center"
prop="name"
fixed="left"
width="200"
/>
<el-table-column label="证件号" align="center" prop="cusId" width="190" />
<el-table-column label="电话" align="center" prop="phone" width="120" />
<el-table-column
label="服务时间"
align="center"
prop="serveTime"
:formatter="serveTimeFormat"
width="100"
/>
<el-table-column
label="服务承诺"
align="center"
prop="servePromise"
width="100"
>
<template slot-scope="scope">
{{scope.row.servePromise ? `${scope.row.servePromise}`: ''}}
{{ scope.row.servePromise ? `${scope.row.servePromise}` : "" }}
</template>
</el-table-column>
<el-table-column label="金额" align="center" prop="amount" width="100"/>
<el-table-column label="调理项目" align="center" prop="projectName" width="100"/>
<el-table-column label="签订时间" align="center" prop="updateTime" width="180"/>
<el-table-column label="金额" align="center" prop="amount" width="100" />
<el-table-column
label="调理项目"
align="center"
prop="projectName"
width="100"
/>
<el-table-column
label="签订时间"
align="center"
prop="updateTime"
width="180"
/>
<el-table-column label="合同地址" align="center" prop="path" width="80">
<template slot-scope="scope">
<el-button type="text" icon="el-icon-copy-document" @click="handleCopy(scope.row.path)" class="copyBtn"
:data-clipboard-text="copyValue">复制
<el-button
type="text"
icon="el-icon-copy-document"
@click="handleCopy(scope.row.path)"
class="copyBtn"
:data-clipboard-text="copyValue"
>复制
</el-button>
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remark" width="120"/>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="150">
<el-table-column label="备注" align="center" prop="remark" width="120" />
<el-table-column
label="操作"
align="center"
class-name="small-padding fixed-width"
fixed="right"
width="150"
>
<template slot-scope="scope">
<el-button
v-if="scope.row.status==='yes'"
v-if="scope.row.status === 'yes'"
size="mini"
type="text"
icon="el-icon-view"
@ -150,7 +229,7 @@
</el-table>
<pagination
v-show="total>0"
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@ -161,29 +240,52 @@
<el-dialog :title="title" :visible.sync="open" width="550px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
<el-form-item label="调理项目" prop="projectId">
<el-select v-model="form.projectId" placeholder="请选择调理项目" filterable clearable size="small">
<el-option v-for="dict in conditioningProjectIdOption"
<el-select
v-model="form.projectId"
placeholder="请选择调理项目"
filterable
clearable
size="small"
>
<el-option
v-for="dict in conditioningProjectIdOption"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="parseInt(dict.dictValue)"/>
:value="parseInt(dict.dictValue)"
/>
</el-select>
</el-form-item>
<el-form-item label="客户姓名" prop="name">
<el-input v-model="form.name" placeholder="请输入客户姓名"/>
<el-input v-model="form.name" placeholder="请输入客户姓名" />
</el-form-item>
<el-form-item label="金额" prop="amount">
<el-input v-model="form.amount" placeholder="请输入金额"/>
<el-input v-model="form.amount" placeholder="请输入金额" />
</el-form-item>
<el-form-item label="服务承诺" prop="servePromise" v-show="form.projectId == 0">
<el-input style="width: 193px; margin-right: 12px" v-model="form.servePromise" placeholder="请输入服务承诺"/>
<el-form-item
label="服务承诺"
prop="servePromise"
v-show="form.projectId == 0"
>
<el-input
style="width: 193px; margin-right: 12px"
v-model="form.servePromise"
placeholder="请输入服务承诺"
/>
</el-form-item>
<el-form-item label="营养师" prop="nutritionistId">
<el-select v-model="form.nutritionistId" placeholder="请选择营养师" clearable size="small">
<el-option v-for="dict in nutritionistIdOptions"
<el-select
v-model="form.nutritionistId"
placeholder="请选择营养师"
clearable
size="small"
>
<el-option
v-for="dict in nutritionistIdOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="parseInt(dict.dictValue)"/>
:value="parseInt(dict.dictValue)"
/>
</el-select>
</el-form-item>
<el-form-item label="服务时间" prop="serveTime">
@ -197,7 +299,11 @@
</el-select>
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容"/>
<el-input
v-model="form.remark"
type="textarea"
placeholder="请输入内容"
/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
@ -209,18 +315,18 @@
</template>
<script>
import {addContract, delContract, listContract} from "@/api/custom/contract";
import { addContract, delContract, listContract } from "@/api/custom/contract";
import {getOptions} from "@/api/custom/order";
import Clipboard from "clipboard";
import Clipboard from 'clipboard';
import { mapGetters } from "vuex";
export default {
export default {
name: "Contract",
data() {
const checkServePromise = (rule, value, callback) => {
if (this.form.projectId == 0 && !value) {
return callback(new Error('请输入服务承诺'))
return callback(new Error("请输入服务承诺"));
}
callback();
};
@ -250,9 +356,9 @@
//
signStatusOptions: [],
//
conditioningProjectIdOption:[],
conditioningProjectIdOption: [],
//
copyValue: '',
copyValue: "",
//
queryParams: {
pageNum: 1,
@ -266,14 +372,12 @@
form: {},
//
rules: {
projectId:[
{required: true, message: "请选择调理项目", trigger: "blur"}
],
name: [
{required: true, message: "请输入客户姓名", trigger: "blur"}
projectId: [
{ required: true, message: "请选择调理项目", trigger: "blur" },
],
name: [{ required: true, message: "请输入客户姓名", trigger: "blur" }],
amount: [
{required: true, message: "请输入签订金额", trigger: "blur"},
{ required: true, message: "请输入签订金额", trigger: "blur" },
{
required: true,
trigger: "blur",
@ -282,44 +386,38 @@
},
],
servePromise: [
{required: true, trigger: "blur", validator: checkServePromise}
{ required: true, trigger: "blur", validator: checkServePromise },
],
serveTime: [
{required: true, message: "请选择服务时间", trigger: "blur"}
{ required: true, message: "请选择服务时间", trigger: "blur" },
],
nutritionistId: [
{required: true, message: "请选择营养师", trigger: "blur"}
]
}
{ required: true, message: "请选择营养师", trigger: "blur" },
],
},
};
},
created() {
this.getList();
getOptions().then(response => {
const options = response.data.reduce((opts, cur) => {
if (!opts[cur.postCode]) {
opts[cur.postCode] = [{dictValue: 0, dictLabel: ' ', remark: null}];
}
opts[cur.postCode].push({dictValue: cur.userId, dictLabel: cur.userName, remark: cur.remark})
return opts;
}, {})
this.nutritionistIdOptions = options['nutri'] || [];
})
this.getDicts("cus_serve_time").then(response => {
this.getDicts("cus_serve_time").then((response) => {
this.serveTimeOptions = response.data;
});
this.getDicts("cus_sign_status").then(response => {
this.getDicts("cus_sign_status").then((response) => {
this.signStatusOptions = response.data;
});
this.getDicts("conditioning_project").then(response => {
this.getDicts("conditioning_project").then((response) => {
this.conditioningProjectIdOption = response.data;
});
},
computed: {
...mapGetters(["nutritionistIdOptions"]),
},
methods: {
/** 查询合同列表 */
getList() {
this.loading = true;
listContract(this.queryParams).then(response => {
listContract(this.queryParams).then((response) => {
this.contractList = response.rows;
this.total = response.total;
this.loading = false;
@ -339,29 +437,40 @@
},
//
reset() {
const defaultNutritionist = this.nutritionistIdOptions.find(opt => opt.remark === 'default');
const defaultProjectIdOption = this.conditioningProjectIdOption.find(opt => opt.remark === 'default');
const defaultNutritionist = this.nutritionistIdOptions.find(
(opt) => opt.remark === "default"
);
const defaultProjectIdOption = this.conditioningProjectIdOption.find(
(opt) => opt.remark === "default"
);
this.form = {
id: null,
projectId: defaultProjectIdOption ? parseInt(defaultProjectIdOption.dictValue) : null,
projectId: defaultProjectIdOption
? parseInt(defaultProjectIdOption.dictValue)
: null,
name: null,
phone: null,
serveTime: null,
amount: null,
path: null,
createBy: null,
nutritionistId: defaultNutritionist ? parseInt(defaultNutritionist.dictValue) : null,
nutritionistId: defaultNutritionist
? parseInt(defaultNutritionist.dictValue)
: null,
createTime: null,
updateBy: null,
updateTime: null,
remark: null
remark: null,
};
this.resetForm("form");
},
//
nutritionistIdFormat(row, column) {
return this.selectDictLabel(this.nutritionistIdOptions, row.nutritionistId);
return this.selectDictLabel(
this.nutritionistIdOptions,
row.nutritionistId
);
},
/** 搜索按钮操作 */
handleQuery() {
@ -375,9 +484,9 @@
},
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length !== 1
this.multiple = !selection.length
this.ids = selection.map((item) => item.id);
this.single = selection.length !== 1;
this.multiple = !selection.length;
},
/** 新增按钮操作 */
handleAdd() {
@ -397,7 +506,7 @@
// },
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
this.$refs["form"].validate((valid) => {
if (valid) {
// if (this.form.id != null) {
// updateContract(this.form).then(response => {
@ -408,11 +517,14 @@
// }
// });
// } else {
this.form.tutor = this.selectDictLabel(this.nutritionistIdOptions, this.form.nutritionistId)
if(this.form.projectId != 0){
this.form.tutor = this.selectDictLabel(
this.nutritionistIdOptions,
this.form.nutritionistId
);
if (this.form.projectId != 0) {
this.form.servePromise = null;
}
addContract(this.form).then(response => {
addContract(this.form).then((response) => {
if (response.code === 200) {
this.msgSuccess("新增成功");
this.open = false;
@ -429,14 +541,16 @@
this.$confirm('是否确认删除合同编号为"' + ids + '"的数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function () {
type: "warning",
})
.then(function () {
return delContract(ids);
}).then(() => {
})
.then(() => {
this.getList();
this.msgSuccess("删除成功");
}).catch(function () {
});
})
.catch(function () {});
},
/** 导出按钮操作 */
// handleExport() {
@ -453,19 +567,19 @@
// });
// },
handleCopy(path) {
this.copyValue = window.location.origin.replace('manage', 'sign') + path;
const btnCopy = new Clipboard('.copyBtn');
this.copyValue = window.location.origin.replace("manage", "sign") + path;
const btnCopy = new Clipboard(".copyBtn");
this.$message({
message: '拷贝成功',
type: 'success'
message: "拷贝成功",
type: "success",
});
// btnCopy.destroy();
},
handleLook(path) {
const url = window.location.origin.replace('manage', 'sign') + path;
const url = window.location.origin.replace("manage", "sign") + path;
// const url = "http://stsign.busyinn.com" + path;
window.open(url, '_blank');
}
}
};
window.open(url, "_blank");
},
},
};
</script>

View File

@ -149,7 +149,11 @@
prop="salesman"
:formatter="preSaleIdFormat"
/>
<el-table-column label="订单" align="center" v-hasPermi="['custom:order:list']">
<el-table-column
label="订单"
align="center"
v-hasPermi="['custom:order:list']"
>
<template slot-scope="scope">
<el-button
size="mini"
@ -159,7 +163,11 @@
</el-button>
</template>
</el-table-column>
<el-table-column label="合同" align="center" v-hasPermi="['custom:contract:list']">
<el-table-column
label="合同"
align="center"
v-hasPermi="['custom:contract:list']"
>
<template slot-scope="scope">
<el-button
size="mini"
@ -169,7 +177,11 @@
</el-button>
</template>
</el-table-column>
<el-table-column label="健康评估" align="center" v-hasPermi="['custom:healthy:list']">
<el-table-column
label="健康评估"
align="center"
v-hasPermi="['custom:healthy:list']"
>
<template slot-scope="scope">
<el-button
size="mini"
@ -179,7 +191,11 @@
</el-button>
</template>
</el-table-column>
<el-table-column label="外食热量统计" align="center" v-hasPermi="['custom:foodHeatStatistics:list']">
<el-table-column
label="外食热量统计"
align="center"
v-hasPermi="['custom:foodHeatStatistics:list']"
>
<template slot-scope="scope">
<el-button
size="mini"
@ -189,7 +205,11 @@
</el-button>
</template>
</el-table-column>
<el-table-column label="食谱计划" align="center" v-hasPermi="['recipes:recipesPlan:list']">
<el-table-column
label="食谱计划"
align="center"
v-hasPermi="['recipes:recipesPlan:list']"
>
<template slot-scope="scope">
<el-button
size="mini"
@ -339,13 +359,11 @@ import {
} from "@/api/custom/customer";
import store from "@/store";
import { getOptions } from "@/api/custom/order";
import OrderDrawer from "@/components/OrderDrawer";
import PhysicalSignsDialog from "@/components/PhysicalSignsDialog";
import ContractDrawer from "@/components/ContractDrawer";
import HeatStatisticsDrawer from "@/components/HeatStatisticsDrawer";
import { mapGetters } from "vuex";
export default {
name: "Customer",
@ -353,7 +371,7 @@ export default {
"order-drawer": OrderDrawer,
"physical-signs-dialog": PhysicalSignsDialog,
"contract-drawer": ContractDrawer,
"heatStatisticsDrawer": HeatStatisticsDrawer
heatStatisticsDrawer: HeatStatisticsDrawer,
},
data() {
const userId = store.getters && store.getters.userId;
@ -374,13 +392,13 @@ export default {
//
customerCenterList: [],
//
preSaleIdOptions: [],
// preSaleIdOptions: [],
//
afterSaleIdOptions: [],
// afterSaleIdOptions: [],
//
nutritionistIdOptions: [],
// nutritionistIdOptions: [],
//
nutriAssisIdOptions: [],
// nutriAssisIdOptions: [],
//
title: "",
//
@ -437,25 +455,14 @@ export default {
},
created() {
this.getList();
getOptions().then((response) => {
const options = response.data.reduce((opts, cur) => {
if (!opts[cur.postCode]) {
opts[cur.postCode] = [
{ dictValue: 0, dictLabel: "无", remark: null },
];
}
opts[cur.postCode].push({
dictValue: cur.userId,
dictLabel: cur.userName,
remark: cur.remark,
});
return opts;
}, {});
this.preSaleIdOptions = options["pre_sale"] || [];
this.afterSaleIdOptions = options["after_sale"] || [];
this.nutritionistIdOptions = options["nutri"] || [];
this.nutriAssisIdOptions = options["nutri_assis"] || [];
});
},
computed: {
...mapGetters([
"preSaleIdOptions",
"afterSaleIdOptions",
"nutritionistIdOptions",
"nutriAssisIdOptions",
]),
},
methods: {
/** 查询客户档案列表 */
@ -504,7 +511,7 @@ export default {
handleOnMenuClick(row) {
// console.log(row);
},
handleClickHeatStatistics(row){
handleClickHeatStatistics(row) {
this.$refs["heatStatisticsRef"].showDrawer(row);
},
//

View File

@ -162,9 +162,9 @@
<el-drawer
:title="title"
:visible.sync="open"
:wrapperClosable="false"
size="50%"
:close-on-press-escape="false"
:close-on-click-modal="false"
>
<div class="drawer_content">
<el-row class="content_detail">
@ -675,13 +675,13 @@ export default {
.catch(function () {});
},
handleChange(value, direction, movedKeys) {
console.log({
oriIgdList: this.oriDataList,
selIgdList: this.form.igdList,
ingDataList: this.ingDataList,
value,
ingType: this.ingType,
});
// console.log({
// oriIgdList: this.oriDataList,
// selIgdList: this.form.igdList,
// ingDataList: this.ingDataList,
// value,
// ingType: this.ingType,
// });
const newTableData = [];
this.selRec = [];
this.selNotRec = [];

View File

@ -1,16 +1,30 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<el-form
:model="queryParams"
ref="queryForm"
:inline="true"
v-show="showSearch"
label-width="68px"
>
<el-form-item label="进粉日期" prop="fanTime">
<el-date-picker clearable style="width: 200px"
<el-date-picker
clearable
style="width: 200px"
v-model="queryParams.fanTime"
type="date"
value-format="yyyy-MM-dd"
placeholder="选择日期">
placeholder="选择日期"
>
</el-date-picker>
</el-form-item>
<el-form-item label="销售" prop="userId" label-width="68px">
<el-select v-model="queryParams.userId" placeholder="请选择销售" filterable clearable>
<el-select
v-model="queryParams.userId"
placeholder="请选择销售"
filterable
clearable
>
<el-option
v-for="dict in preSaleIdOptions"
:key="dict.dictValue"
@ -20,7 +34,12 @@
</el-select>
</el-form-item>
<el-form-item label="进粉渠道" prop="accountId" label-width="88px">
<el-select v-model="queryParams.accountId" filterable placeholder="请选择渠道" clearable>
<el-select
v-model="queryParams.accountId"
filterable
placeholder="请选择渠道"
clearable
>
<el-option
v-for="dict in accountIdOptions"
:key="dict.dictValue"
@ -30,8 +49,16 @@
</el-select>
</el-form-item>
<el-form-item style="margin-left: 20px">
<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-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>
@ -43,7 +70,8 @@
size="mini"
@click="handleAdd"
v-hasPermi="['custom:fanStatistics:add']"
>新增</el-button>
>新增</el-button
>
</el-col>
<el-col :span="1.5">
<el-button
@ -53,7 +81,8 @@
:disabled="single"
@click="handleUpdate"
v-hasPermi="['custom:fanStatistics:edit']"
>修改</el-button>
>修改</el-button
>
</el-col>
<el-col :span="1.5">
<el-button
@ -63,7 +92,8 @@
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['custom:fanStatistics:remove']"
>删除</el-button>
>删除</el-button
>
</el-col>
<el-col :span="1.5">
<el-button
@ -72,16 +102,30 @@
size="mini"
@click="handleExport"
v-hasPermi="['custom:fanStatistics:export']"
>导出</el-button>
>导出</el-button
>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
<right-toolbar
:showSearch.sync="showSearch"
@queryTable="getList"
></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="fanStatisticsList" stripe @selection-change="handleSelectionChange">
<el-table
v-loading="loading"
:data="fanStatisticsList"
stripe
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="进粉日期" align="center" prop="fanTime" width="180">
<el-table-column
label="进粉日期"
align="center"
prop="fanTime"
width="180"
>
<template slot-scope="scope">
<span>{{ parseTime(scope.row.fanTime, '{y}-{m}-{d}') }}</span>
<span>{{ parseTime(scope.row.fanTime, "{y}-{m}-{d}") }}</span>
</template>
</el-table-column>
<el-table-column label="销售" align="center" prop="userName" />
@ -94,7 +138,11 @@
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>-->
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<el-table-column
label="操作"
align="center"
class-name="small-padding fixed-width"
>
<template slot-scope="scope">
<el-button
size="mini"
@ -102,43 +150,55 @@
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['custom:fanStatistics:edit']"
>修改</el-button>
>修改</el-button
>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['custom:fanStatistics:remove']"
>删除</el-button>
>删除</el-button
>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
layout="total, slot, sizes, prev, pager, next, jumper"
@pagination="getList"
>
<span style="margin-right: 12px;font-size:13px;color:rgb(134 136 140)">总计进粉量 {{totalFanNum}}</span>
<span style="margin-right: 12px; font-size: 13px; color: rgb(134 136 140)"
>总计进粉量 {{ totalFanNum }}</span
>
</pagination>
<!-- 添加进粉统计对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="进粉日期" prop="fanTime">
<el-date-picker clearable style="width: 200px"
<el-date-picker
clearable
style="width: 200px"
v-model="form.fanTime"
type="date"
value-format="yyyy-MM-dd"
placeholder="选择日期">
placeholder="选择日期"
>
</el-date-picker>
</el-form-item>
<el-form-item label="销售" prop="userId">
<el-select v-model="form.userId" placeholder="请选择销售" filterable clearable size="small">
<el-select
v-model="form.userId"
placeholder="请选择销售"
filterable
clearable
size="small"
>
<el-option
v-for="dict in preSaleIdOptions"
:key="dict.dictValue"
@ -147,53 +207,83 @@
/>
</el-select>
</el-form-item>
<p style="margin: 20px auto 20px 40px;font-size: 16px;">请先选择销售再填写每个微信号对应进粉数量</p>
<p style="margin: 20px auto 20px 40px; font-size: 16px">
请先选择销售再填写每个微信号对应进粉数量
</p>
<div v-if="showWxFlag">
<div v-for="(item, index) in wxList" style="margin: 10px auto auto 40px;">
<span>{{item.wxAccount}}</span><el-input-number controls-position="right" v-model="form.fanNum[index]" style="width: 150px;margin-left: 10px" :min="0" :max="1000000000"></el-input-number>
<div
v-for="(item, index) in wxList"
style="margin: 10px auto auto 40px"
>
<span>{{ item.wxAccount }}</span
><el-input-number
controls-position="right"
v-model="form.fanNum[index]"
style="width: 150px; margin-left: 10px"
:min="0"
:max="1000000000"
></el-input-number>
</div>
</div>
</el-form>
<div slot="footer" class="dialog-footer" >
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
<!-- 修改进粉统计对话框 -->
<el-dialog :title="title" :visible.sync="editOpen" width="500px" append-to-body>
<el-dialog
:title="title"
:visible.sync="editOpen"
width="500px"
append-to-body
>
<el-form ref="editForm" :model="editForm" :rules="editRules">
<el-form-item label="进粉日期" prop="fanTime">
<el-date-picker clearable style="width: 200px"
<el-date-picker
clearable
style="width: 200px"
v-model="editForm.fanTime"
type="date"
value-format="yyyy-MM-dd"
placeholder="选择日期">
placeholder="选择日期"
>
</el-date-picker>
</el-form-item>
<el-form-item label="进粉数量" prop="fanNum">
<el-input-number controls-position="right" v-model="editForm.fanNum" :min="0" :max="1000000000"></el-input-number>
<el-input-number
controls-position="right"
v-model="editForm.fanNum"
:min="0"
:max="1000000000"
></el-input-number>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer" >
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="editSubmit"> </el-button>
<el-button @click="editCancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listFanStatistics, getFanStatistics, delFanStatistics, addFanStatistics, updateFanStatistics, exportFanStatistics, getWxByUserId } from "@/api/custom/fanStatistics";
import { getOptions } from "@/api/custom/order";
import store from "@/store";
import dayjs from "dayjs";
const loginUserId = store.getters && store.getters.userId;
const nowDate = dayjs().subtract(1, 'day').format("YYYY-MM-DD");
export default {
import {
listFanStatistics,
getFanStatistics,
delFanStatistics,
addFanStatistics,
updateFanStatistics,
exportFanStatistics,
getWxByUserId,
} from "@/api/custom/fanStatistics";
import store from "@/store";
import dayjs from "dayjs";
import { mapState } from "vuex";
const loginUserId = store.getters && store.getters.userId;
const nowDate = dayjs().subtract(1, "day").format("YYYY-MM-DD");
export default {
name: "FanStatistics",
data() {
const checkOrderTime = (rule, value, callback) => {
@ -229,46 +319,54 @@
pageSize: 10,
fanTime: nowDate,
userId: null,
accountId: null
accountId: null,
},
//
form: {},
//
rules: {
fanTime: [{ required: true, trigger: "blur", message: "请选择日期" }],
userId: [{ required: true, trigger: "blur", message: "请选择销售" }]
userId: [{ required: true, trigger: "blur", message: "请选择销售" }],
},
showWxFlag:false,
showWxFlag: false,
//
wxList:[],
//
preSaleIdOptions:[],
wxList: [],
//
accountIdOptions:[],
accountIdOptions: [],
editOpen: false,
editForm:{},
editForm: {},
//
editRules: {
fanTime: [{ required: true, trigger: "blur", message: "请选择日期" }],
fanNum: [{ required: true, trigger: "blur", message: "请输入进粉数量" }],
fanNum: [
{ required: true, trigger: "blur", message: "请输入进粉数量" },
],
},
};
},
created() {
this.getList();
this.getSaleUserList();
this.getDicts("fan_channel").then((response) => {
this.accountIdOptions = response.data;
});
},
computed: {
...mapState({
//
preSaleIdOptions: (state) => state.global.preSaleIdOptions.slice(1),
}),
},
methods: {
/** 查询进粉统计列表 */
getList() {
this.loading = true;
listFanStatistics(this.queryParams).then(response => {
listFanStatistics(this.queryParams).then((response) => {
this.fanStatisticsList = response.rows;
this.totalFanNum = 0;
if(this.fanStatisticsList != null && this.fanStatisticsList.length > 0){
if (
this.fanStatisticsList != null &&
this.fanStatisticsList.length > 0
) {
this.totalFanNum = this.fanStatisticsList[0].totalFanNum;
}
this.total = response.total;
@ -291,18 +389,18 @@
userId: null,
fanTime: nowDate,
wxId: [],
fanNum: []
fanNum: [],
};
this.wxList = [];
this.showWxFlag = false;
this.resetForm("form");
},
editFormReset(){
editFormReset() {
this.editForm = {
id: null,
wxId: null,
fanTime: null,
fanNum: 0
fanNum: 0,
};
},
/** 搜索按钮操作 */
@ -317,9 +415,9 @@
},
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length!==1
this.multiple = !selection.length
this.ids = selection.map((item) => item.id);
this.single = selection.length !== 1;
this.multiple = !selection.length;
},
/** 新增按钮操作 */
handleAdd() {
@ -328,7 +426,7 @@
const defaultUserId = this.preSaleIdOptions.find(
(opt) => opt.dictValue === loginUserId
);
if (defaultUserId){
if (defaultUserId) {
this.form.userId = defaultUserId.dictValue;
}
this.open = true;
@ -337,36 +435,34 @@
/** 修改按钮操作 */
handleUpdate(row) {
this.editFormReset();
const id = row.id || this.ids
getFanStatistics(id).then(response => {
const id = row.id || this.ids;
getFanStatistics(id).then((response) => {
this.editForm.id = response.data.id;
this.editForm.wxId = response.data.wxId;
this.editForm.fanTime = response.data.fanTime;
this.editForm.fanNum = response.data.fanNum;
this.editOpen = true;
this.title = "修改「"+row.wxAccount+"」的进粉统计";
this.title = "修改「" + row.wxAccount + "」的进粉统计";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
this.$refs["form"].validate((valid) => {
if (valid) {
if(this.form.wxId.length == 0){
if (this.form.wxId.length == 0) {
this.msgError("该销售未被分配微信");
return;
}
let flag = true;
this.form.fanNum.forEach( (value, index) => {
if(value == null || value == undefined){
this.form.fanNum.forEach((value, index) => {
if (value == null || value == undefined) {
this.msgError("请填写进粉数量");
flag = false;
return;
}
});
if(flag){
addFanStatistics(this.form).then(response => {
if (flag) {
addFanStatistics(this.form).then((response) => {
if (response.code === 200) {
this.msgSuccess("新增成功");
this.open = false;
@ -375,22 +471,22 @@
}
});
}
}else{
} else {
this.msgError("数据未填写完整");
}
});
},
editSubmit(){
this.$refs["editForm"].validate(valid => {
editSubmit() {
this.$refs["editForm"].validate((valid) => {
if (valid) {
updateFanStatistics(this.editForm).then(response => {
updateFanStatistics(this.editForm).then((response) => {
if (response.code === 200) {
this.msgSuccess("修改成功");
this.editOpen = false;
this.getList();
}
});
}else{
} else {
this.msgError("数据未填写完整");
}
});
@ -398,61 +494,54 @@
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$confirm('是否确认删除进粉统计编号为"' + ids + '"的数据项?', "警告", {
this.$confirm(
'是否确认删除进粉统计编号为"' + ids + '"的数据项?',
"警告",
{
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
type: "warning",
}
)
.then(function () {
return delFanStatistics(ids);
}).then(() => {
})
.then(() => {
this.getList();
this.msgSuccess("删除成功");
}).catch(function() {});
})
.catch(function () {});
},
/** 导出按钮操作 */
handleExport() {
const queryParams = this.queryParams;
this.$confirm('是否确认导出所有进粉统计数据项?', "警告", {
this.$confirm("是否确认导出所有进粉统计数据项?", "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
type: "warning",
})
.then(function () {
return exportFanStatistics(queryParams);
}).then(response => {
})
.then((response) => {
this.download(response.msg);
}).catch(function() {});
},
//
getSaleUserList(){
getOptions().then((response) => {
const options = response.data.reduce((opts, cur) => {
if (!opts[cur.postCode]) {
opts[cur.postCode] = [];
}
opts[cur.postCode].push({
dictValue: cur.userId,
dictLabel: cur.userName,
remark: cur.remark,
});
return opts;
}, {});
this.preSaleIdOptions = options["pre_sale"] || [];
});
})
.catch(function () {});
},
//ID
getWxByUserId(userId){
getWxByUserId(userId) {
this.showWxFlag = false;
this.form.wxId = [];
this.form.fanNum = [];
this.wxList = [];
if(userId == null || userId == undefined || userId == ""){
if (userId == null || userId == undefined || userId == "") {
return;
}
getWxByUserId(userId).then(response => {
getWxByUserId(userId).then((response) => {
if (response.code === 200) {
this.wxList = response.data ? response.data : [];
if(this.wxList.length > 0){
for(let i=0; i < this.wxList.length; i++){
if (this.wxList.length > 0) {
for (let i = 0; i < this.wxList.length; i++) {
this.form.wxId[i] = this.wxList[i].wechatAccount;
this.form.fanNum[i] = 0;
}
@ -467,6 +556,6 @@
"form.userId": function (newVal, oldVal) {
this.getWxByUserId(newVal);
},
}
};
},
};
</script>

View File

@ -335,7 +335,7 @@
</template>
</el-table-column>
<el-table-column label="客户姓名" align="center" prop="customer" />
<el-table-column label="手机号" align="center" prop="phone" width="100" />
<!-- <el-table-column label="手机号" align="center" prop="phone" width="100" /> -->
<el-table-column label="成交金额" align="center" prop="amount">
<template slot-scope="scope">
{{ toThousands(scope.row.amount) }}
@ -455,6 +455,7 @@ import orderPause from "./orderPause";
import OrderDetail from "@/components/OrderDetail";
import OrderEdit from "@/components/OrderEdit";
import AutoHideMessage from "@/components/AutoHideMessage";
import { mapGetters } from "vuex";
const beginTime = dayjs().startOf("month").format("YYYY-MM-DD");
const endTime = dayjs().format("YYYY-MM-DD");
@ -492,16 +493,6 @@ export default {
daterange: [beginTime, endTime],
//
payTypeIdOptions: [],
//
preSaleIdOptions: [],
//
afterSaleIdOptions: [],
//
nutritionistIdOptions: [],
//
nutriAssisIdOptions: [],
//
plannerIdOptions: [],
//
accountIdOptions: [],
//
@ -510,12 +501,6 @@ export default {
conditioningProjectIdOption: [],
//
reviewStatusOptions: [],
//
plannerAssisIdOptions: [],
//
operatorIdOptions: [],
//
operatorAssisIdOptions: [],
//
queryParams: {
pageNum: 1,
@ -539,32 +524,28 @@ export default {
},
};
},
computed: {
...mapGetters([
//
"preSaleIdOptions",
//
"afterSaleIdOptions",
//
"nutritionistIdOptions",
//
"nutriAssisIdOptions",
//
"plannerIdOptions",
//
"plannerAssisIdOptions",
//
"operatorIdOptions",
//
"operatorAssisIdOptions",
]),
},
created() {
this.getList();
getOptions().then((response) => {
const options = response.data.reduce((opts, cur) => {
if (!opts[cur.postCode]) {
opts[cur.postCode] = [
// { dictValue: 0, dictLabel: "", remark: null },
];
}
opts[cur.postCode].push({
dictValue: cur.userId,
dictLabel: cur.userName,
remark: cur.remark,
});
return opts;
}, {});
this.preSaleIdOptions = options["pre_sale"] || [];
this.afterSaleIdOptions = options["after_sale"] || [];
this.nutritionistIdOptions = options["nutri"] || [];
this.nutriAssisIdOptions = options["nutri_assis"] || [];
this.plannerIdOptions = options["planner"] || [];
this.plannerAssisIdOptions = options["planner_assis"] || [];
this.operatorIdOptions = options["operator"] || [];
this.operatorAssisIdOptions = options["operator_assis"] || [];
});
this.getDicts("cus_pay_type").then((response) => {
this.payTypeIdOptions = response.data;
});

View File

@ -15,7 +15,7 @@
</div>
</template>
<script>
import TextInfo from "./TextInfo.vue";
import TextInfo from "@/components/TextInfo";
export default {
name: "BodySignView",

View File

@ -31,7 +31,7 @@
</div>
</template>
<script>
import TextInfo from "./TextInfo.vue";
import TextInfo from "@/components/TextInfo";
export default {
name: "HealthyView",
@ -166,6 +166,7 @@ export default {
{ title: "是否出现过过敏症状", value: "allergyFlag" },
{ title: "过敏症状", value: "allergySituation" },
{ title: "过敏源", value: "allergen" },
{ title: "忌口过敏食物", value: "dishesIngredient" },
],
},
{

View File

@ -1,17 +0,0 @@
<template>
<div>
<RecipesCom v-for="item in data" :key="item.id" :data="item" />
</div>
</template>
<script>
import RecipesCom from "@/components/RecipesCom";
export default {
name: "RecipesView",
components: {
RecipesCom,
},
props: ["data"],
};
</script>
<style rel="stylesheet/scss" lang="scss">
</style>

View File

@ -0,0 +1,148 @@
<template>
<div :class="className" :style="{ height: height, width: width }" />
</template>
<script>
import echarts from "echarts";
require("@/utils/echarts/myShine");
import resize from "@/views/dashboard/mixins/resize";
const animationDuration = 6000;
export default {
mixins: [resize],
props: {
className: {
type: String,
default: "chart",
},
width: {
type: String,
default: "100%",
},
height: {
type: String,
default: "300px",
},
data: {
type: Array,
default: [],
},
},
data() {
return {
chart: null,
nameDict: {
pHeat: "蛋白质",
fHeat: "脂肪",
cHeat: "碳水",
},
};
},
mounted() {
this.$nextTick(() => {
this.initChart();
});
},
beforeDestroy() {
if (!this.chart) {
return;
}
this.chart.dispose();
this.chart = null;
},
updated() {
// console.log("updated");
},
methods: {
initChart() {
this.chart = echarts.init(this.$el, "myShine");
this.updateChart(this.data.length > 0 ? this.data : {});
},
updateChart(source) {
this.chart.clear();
this.chart.setOption({
title: {
text: "营养统计",
},
tooltip: {
trigger: "axis",
appendToBody: true,
formatter: (params) => {
// console.log(params);
const [param] = params;
const { name } = param;
let totalHeat = 0;
const tooltips = params.reduce(
(arr, cur) => {
const { value, seriesName } = cur;
const nutriName = this.nameDict[seriesName];
totalHeat += value[seriesName];
const heatVal = value[seriesName].toFixed(1);
const weightVal = value[
`${seriesName.substring(0, 1)}Weight`
].toFixed(1);
arr.push(
`${cur.marker} ${nutriName}${heatVal}千卡(${weightVal}克)`
);
return arr;
},
[name]
);
tooltips[0] += ` - 共${totalHeat.toFixed(1)}千卡`;
return tooltips.join("</br>");
},
},
dataset: {
dimensions: [
"name",
"pWeight",
"pHeat",
"fWeight",
"fHeat",
"cWeight",
"cHeat",
],
source,
},
grid: {
top: 40,
left: 20,
right: 20,
bottom: 10,
containLabel: true,
},
xAxis: {
type: "category",
},
yAxis: {
type: "value",
},
series: ["pHeat", "fHeat", "cHeat"].map((dim, idx) => ({
name: dim,
type: "bar",
barWidth: 26,
stack: "bar",
encode: {
y: dim,
x: 0,
},
itemStyle: {
borderWidth: 2,
borderColor: "#fff",
},
})),
});
},
},
watch: {
data(newVal, oldVal) {
if (newVal) {
this.$nextTick(() => {
this.updateChart(newVal);
});
}
},
},
};
</script>

View File

@ -0,0 +1,202 @@
<template>
<div
:class="`aspect_pie_chart_wrapper ${className || ''}`"
:style="{ height: height, width: width }"
>
<div ref="echart" :style="{ height: height, width: '200px' }" />
<div>
<el-table
:data="mData"
size="mini"
border
:cell-style="{ padding: '2px 0' }"
:header-cell-style="{ padding: '4px 0', height: 'unset' }"
class="small_table"
>
<el-table-column label="营养" prop="type" align="center" width="60" />
<el-table-column
label="重量(g)"
prop="weight"
align="center"
width="80"
/>
<el-table-column
label="热量(Kcal)"
prop="heat"
align="center"
width="90"
/>
<el-table-column
label="热量占比"
prop="heatRate"
align="center"
width="80"
/>
</el-table>
</div>
</div>
</template>
<script>
import echarts from "echarts";
require("@/utils/echarts/myShine");
import resize from "@/views/dashboard/mixins/resize";
import TextInfo from "@/components/TextInfo";
export default {
mixins: [resize],
components: {
TextInfo,
},
props: {
className: {
type: String,
default: "chart",
},
width: {
type: String,
default: "100%",
},
height: {
type: String,
default: "300px",
},
data: {
type: Array,
default: [],
},
},
data() {
return {
chart: null,
nameDict: {
p: "蛋白质",
f: "脂肪",
c: "碳水",
},
};
},
computed: {
mData() {
const [data] = this.data;
let totalHeat = 0;
return data
? ["p", "f", "c"].map((type) => {
if (totalHeat === 0) {
totalHeat = ["p", "f", "c"].reduce((heat, cur) => {
heat += data[`${cur}Heat`];
return heat;
}, 0);
}
return {
type: this.nameDict[type],
weight: data[`${type}Weight`].toFixed(1),
heat: data[`${type}Heat`].toFixed(1),
heatRate: `${((data[`${type}Heat`] / totalHeat) * 100).toFixed(
2
)}%`,
};
})
: [];
},
},
mounted() {
this.$nextTick(() => {
this.initChart();
});
},
beforeDestroy() {
if (!this.chart) {
return;
}
this.chart.dispose();
this.chart = null;
},
methods: {
initChart() {
this.chart = echarts.init(this.$refs.echart, "myShine");
this.updateChart(this.data.length > 0 ? this.data[0] : {});
},
updateChart(data) {
this.chart.clear();
this.chart.setOption({
title: {
text: `${data.name}营养统计`,
},
tooltip: {
trigger: "item",
appendToBody: true,
formatter: (params) => {
const {
name,
marker,
percent,
data: { value, oriData, dim },
} = params;
return [
`${marker} ${name}`,
`含量:${oriData[`${dim}Weight`].toFixed(1)}`,
`热量:${value.toFixed(1)}千卡`,
`热量占比:${percent}%`,
].join("</br>");
},
},
series: [
{
name: data.name,
type: "pie",
radius: [0, 50],
center: ["50%", "50%"],
data: ["p", "f", "c"].map((dim) => ({
dim,
value: data[`${dim}Heat`],
name: this.nameDict[dim],
oriData: data,
})),
labelLine: {
length: 5,
length2: 5,
},
// label: {
// show: true,
// position: "inside",
// color: '#fff'
// },
itemStyle: {
borderWidth: 1,
borderColor: "#fff",
},
},
],
});
},
},
watch: {
data(newVal, oldVal) {
if (newVal) {
this.$nextTick(() => {
this.updateChart(newVal[0]);
});
}
},
},
};
</script>
<style lang="scss" scoped>
.aspect_pie_chart_wrapper {
width: 100%;
display: flex;
& > div:nth-child(1) {
// width: 200px
}
// & > div:nth-child(2) {
.small_table {
.my_cell {
padding: 2px 0 !important;
}
}
// }
}
</style>

View File

@ -0,0 +1,82 @@
<template>
<div
class="recipes_aspect_wrapper"
:style="`height: ${collapse ? 30 : 200}px`"
>
<div class="header">
<el-button
v-if="!recipesId"
size="mini"
type="primary"
@click="handleOnSave"
>生成食谱</el-button
>
<el-button size="mini" type="text" @click="handleCollapseClick">{{
`${collapse ? "展开分析" : "收起分析"}`
}}</el-button>
</div>
<div
class="content"
:style="`visibility: ${collapse ? 'hidden' : 'visible'};`"
>
<BarChart
v-if="data.length > 1"
:data="data"
height="170px"
width="500px"
/>
<PieChart
v-if="data.length === 1"
:data="data"
height="170px"
width="500px"
/>
</div>
</div>
</template>
<script>
import BarChart from "./BarChart";
import PieChart from "./PieChart";
import { createNamespacedHelpers } from "vuex";
const { mapActions, mapState } = createNamespacedHelpers("recipes");
export default {
name: "RecipesAspectCom",
components: {
BarChart,
PieChart,
},
data() {
return {};
},
updated() {
// console.log(this.data);
},
props: ["collapse", "data"],
computed: {
...mapState(["recipesId"]),
},
methods: {
handleCollapseClick() {
this.$emit("update:collapse", !this.collapse);
},
handleOnSave() {
this.saveRecipes();
},
...mapActions(["saveRecipes"]),
},
};
</script>
<style rel="stylesheet/scss" lang="scss" scope>
.recipes_aspect_wrapper {
transition: all 0.3s;
padding-bottom: 12px;
.header {
text-align: right;
height: 30px;
}
.content {
}
}
</style>

View File

@ -0,0 +1,165 @@
<template>
<el-form>
<el-form-item label="菜品名">
<span style="color: #262626; font-size: 16px; font-weight: bold">{{
name
}}</span>
</el-form-item>
<el-form-item label="菜品类型">
<el-radio-group v-model="type" @change="handleOnTypeChange">
<el-radio
v-for="item in typeOptions"
:key="item.dictValue"
:label="item.dictValue"
>{{ item.dictLabel }}</el-radio
>
</el-radio-group>
</el-form-item>
<el-form-item label="食材分量">
<el-table
:data="igdList"
border
show-summary
size="mini"
:summary-method="getSummaries"
>
<el-table-column prop="name" label="食材" align="center" />
<el-table-column label="分量估算" align="center">
<template slot-scope="scope">
<EditableUnit
:weight="scope.row.cusWeight"
:unit="scope.row.cusUnit"
@onChange="(val) => handleOnCustomUnitChange(scope.row, val)"
/>
</template>
</el-table-column>
<el-table-column prop="weight" label="重量(g)" align="center">
<template slot-scope="scope">
<EditableText
:value="scope.row.weight"
@onChange="(val) => handleOnWeightChange(scope.row, val)"
/>
</template>
</el-table-column>
<el-table-column
prop="proteinRatio"
label="P/100g"
align="center"
/>
<el-table-column prop="fatRatio" label="F/100g" align="center" />
<el-table-column prop="carbonRatio" label="C/100g" align="center" />
</el-table>
</el-form-item>
<el-form-item label="推荐人群">
<el-tag
style="margin-right: 4px"
v-for="rec in recTags"
:key="rec"
type="success"
>
{{ rec }}
</el-tag>
</el-form-item>
<el-form-item label="忌口人群">
<el-tag
style="margin-right: 4px"
v-for="notRec in notRecTags"
:key="notRec"
type="danger"
>
{{ notRec }}
</el-tag>
</el-form-item>
</el-form>
</template>
<script>
import produce from "immer";
import EditableText from "../EditableText";
import EditableUnit from "../EditableUnit";
export default {
name: "ConfigDishes",
data() {
return {
nType: this.type,
};
},
props: {
name: {
type: String,
default: "",
},
type: {
type: String,
default: "",
},
igdList: {
type: Array,
default: [],
},
typeOptions: {
type: Array,
default: [],
},
notRecTags: {
type: Array,
default: [],
},
recTags: {
type: Array,
default: [],
},
},
components: {
EditableText,
EditableUnit,
},
computed: {},
methods: {
handleOnTypeChange(type) {
this.$emit("onChane", { type });
},
handleOnWeightChange(data, val) {
// console.log({ data, val });
this.$emit("onChane", {
igdList: produce(this.igdList, (draftState) => {
const tarIgd = draftState.find((obj) => obj.id === data.id);
if (tarIgd) {
tarIgd.weight = val;
}
}),
});
},
handleOnCustomUnitChange(data, val) {
// console.log({ data, val });
this.$emit("onChane", {
igdList: produce(this.igdList, (draftState) => {
const tarIgd = draftState.find((obj) => obj.id === data.id);
if (tarIgd) {
tarIgd.cusWeight = val.cusWeight;
tarIgd.cusUnit = val.cusUnit;
}
}),
});
},
getSummaries(param) {
const { columns, data } = param;
return columns.reduce(
(arr, cur, idx) => {
if (idx > 1) {
arr[idx] = data.reduce((acc, dAcc) => {
if (idx === 2) {
return acc + parseFloat(dAcc.weight);
}
return parseFloat(
(acc + (dAcc[cur.property] * dAcc.weight) / 100).toFixed(1)
);
}, 0);
}
return arr;
},
["合计"]
);
},
},
};
</script>

View File

@ -0,0 +1,172 @@
<template>
<div>
<el-form
:model="queryParams"
ref="queryForm"
:inline="true"
label-width="68px"
>
<el-form-item label="菜品名称" prop="name">
<el-input
v-model="queryParams.name"
placeholder="请输入菜品名称"
clearable
size="mini"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="菜品类型" prop="type">
<el-select
v-model="queryParams.type"
placeholder="请选择菜品类型"
clearable
size="mini"
>
<el-option
v-for="dict in typeOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="dict.dictValue"
/>
</el-select>
</el-form-item>
<el-form-item>
<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-table
v-loading="loading"
size="mini"
:data="dishesList"
height="600"
highlight-current-row
@current-change="handleCurrentChange"
>
<el-table-column label="菜品名称" align="center" prop="name" />
<el-table-column label="菜品类型" align="center" prop="type">
<template slot-scope="scope">
<AutoHideInfo :data="typeFormat(scope.row)" />
</template>
</el-table-column>
<el-table-column label="包含食材" align="center">
<template slot-scope="scope">
<div v-for="igd in scope.row.igdList" :key="igd.id">
{{ igd.name }}
</div>
</template>
</el-table-column>
<el-table-column label="推荐人群" align="center">
<template slot-scope="scope">
<AutoHideInfo :data="scope.row.recTags" :line="0" />
</template>
</el-table-column>
<el-table-column label="忌口人群" align="center">
<template slot-scope="scope">
<AutoHideInfo :data="scope.row.notRecTags" :line="0" />
</template>
</el-table-column>
</el-table>
<pagination
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
layout="total, prev, pager, next"
@pagination="getList"
/>
</div>
</template>
<script>
import AutoHideInfo from "@/components/AutoHideInfo";
import { listDishes } from "@/api/custom/dishes";
import { createNamespacedHelpers } from "vuex";
const { mapState } = createNamespacedHelpers("recipes");
export default {
name: "SelectDishes",
props: [],
data() {
return {
loading: false,
total: 0,
dishesList: [],
queryParams: {
pageNum: 1,
pageSize: 10,
name: null,
type: null,
reviewStatus: "yes",
},
};
},
components: {
AutoHideInfo,
},
computed: {
...mapState(["typeOptions"]),
},
methods: {
getList() {
// console.log('getList')
this.loading = true;
listDishes(this.queryParams).then((result) => {
this.dishesList = result.rows.map((d) => {
const recTags = [],
notRecTags = [];
d.igdList.forEach((igd) => {
if (igd.rec) {
igd.rec.split(",").forEach((rec) => {
if (!recTags.includes(rec)) {
recTags.push(rec);
}
});
}
if (igd.notRec) {
igd.notRec.split(",").forEach((notRec) => {
if (!notRecTags.includes(notRec)) {
notRecTags.push(notRec);
}
});
}
});
return {
...d,
recTags,
notRecTags,
};
});
this.total = result.total;
this.loading = false;
});
},
handleCurrentChange(data) {
this.$emit("onChange", data);
},
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
typeFormat(row, column) {
return !row.type
? ""
: row.type
.split(",")
.map((type) => this.selectDictLabel(this.typeOptions, type));
},
},
};
</script>

View File

@ -0,0 +1,185 @@
<template>
<el-drawer
title="添加菜品"
:visible.sync="visible"
:close-on-press-escape="false"
:before-close="handleOnClosed"
:wrapperClosable="false"
class="add_dishes_drawer_wrapper"
direction="ltr"
size="40%"
>
<div class="content_wrapper">
<div class="content_detail">
<el-steps :active="active" style="margin-bottom: 20px">
<el-step title="选择菜品" />
<el-step title="配置菜品" />
</el-steps>
<SelectDishes
ref="dishesRef"
v-show="active === 0"
@onChange="handleCurrentChange"
/>
<ConfigDishes
v-show="active === 1"
v-bind="selDishes"
:typeOptions="typeOptions"
@onChange="handleOnConfigChange"
/>
</div>
<div slot="footer" class="dialog-footer">
<el-button
size="small"
v-show="active === 1"
type="info"
@click="handleOnLastStepClick"
>上一步</el-button
>
<el-button
size="small"
v-show="active === 1"
type="primary"
@click="handleOnConfirmClick"
> </el-button
>
<el-button size="small" @click="handleOnCancelClick"> </el-button>
</div>
</div>
</el-drawer>
</template>
<script>
import { createNamespacedHelpers } from "vuex";
const { mapState } = createNamespacedHelpers("recipes");
import SelectDishes from "./SelectDishes";
import ConfigDishes from "./ConfigDishes";
export default {
name: "AddDishesDrawer",
components: {
SelectDishes,
ConfigDishes,
},
data() {
return {
visible: false,
active: 0,
typeOptions: [],
selDishes: {
name: "",
type: "",
igdList: [],
recTags: [],
notRecTags: [],
},
};
},
computed: {
...mapState(["dishesTypeOptions"]),
},
methods: {
showDrawer() {
this.visible = true;
this.$nextTick(() => {
this.$refs.dishesRef.getList();
});
},
handleOnClosed(done) {
done();
},
handleCurrentChange(data) {
if (!data) {
return;
}
// console.log(data);
this.selDishes = data;
this.active = 1;
this.typeOptions = data.type.split(",").reduce((arr, cur, idx) => {
if (idx === 0) {
this.selDishes.type = cur;
}
const tarOpt = this.dishesTypeOptions.find(
(obj) => obj.dictValue === cur
);
if (tarOpt) {
arr.push(tarOpt);
}
return arr;
}, []);
},
handleOnConfigChange(val) {
Object.keys(val).forEach((key) => {
this.selDishes[key] = val[key];
});
},
handleOnCancelClick() {
this.visible = false;
this.active = 0;
},
handleOnLastStepClick() {
this.active = 0;
},
handleOnConfirmClick() {
this.visible = false;
this.active = 0;
const {
id,
methods,
name,
notRecTags,
recTags,
type,
igdList,
} = this.selDishes;
this.$emit("onConfirm", {
id: -1,
dishesId: id,
methods,
name,
notRecTags,
recTags,
type,
igdList,
});
// console.log(this.selDishes);
},
},
};
</script>
<style lang="scss" scoped>
/deep/ :focus {
outline: 0;
}
.add_dishes_drawer_wrapper {
.content_wrapper {
padding: 16px 20px;
height: 100%;
overflow: auto;
display: flex;
flex-direction: column;
.content_detail {
flex: 1 1 0;
padding: 12px;
overflow: auto;
}
.dialog-footer {
flex: 0 0 45px;
display: inline-flex;
align-items: center;
justify-content: flex-end;
padding: 0 12px;
}
}
}
</style>
<style lang="scss">
.add_dishes_drawer_wrapper {
#el-drawer__title {
margin-bottom: 0 !important;
}
}
</style>

View File

@ -0,0 +1,69 @@
<template>
<div class="editable_text_wrapper">
<div class="value" v-if="!editing" @click="handleOnClick">{{ value }}</div>
<input
v-else
class="input"
ref="inputRef"
type="number"
:step="5"
:value="value"
@blur="handleOnBlur"
/>
</div>
</template>
<script>
export default {
name: "EditableText",
data() {
return {
editing: false,
};
},
props: ["value"],
methods: {
handleOnClick(e) {
if (!this.editing) {
this.editing = true;
this.$nextTick(() => {
this.$refs["inputRef"].focus();
});
}
},
handleOnBlur(e) {
const { value } = e.target;
if (value > 0) {
this.editing = false;
const mValue = parseFloat(value)
if (mValue !== parseFloat(this.value)) {
this.$emit("onChange", mValue);
}
} else {
this.$message.error("数字必须大于0");
}
},
},
};
</script>
<style lang="scss" scoped>
.editable_text_wrapper {
.value {
cursor: pointer;
}
.input {
width: 96%;
text-align: center;
border-radius: 4px;
border: 1px solid #dcdfe6;
&:hover {
border-color: #409eff;
}
&:focus {
outline: none;
border-color: #409eff;
}
}
}
</style>

View File

@ -0,0 +1,147 @@
<template>
<div class="editable_unit_wrapper">
<div class="value" v-if="!editing" @click="handleOnClick">
<span>{{ unitWeight }}</span>
</div>
<div v-else class="selector">
<select
:value="mWeight"
@click="handleOnSelectClick"
@change="handleOnWeightChange"
>
<option
v-for="item in cusWeightOptions"
:key="item.dictValue"
:value="item.dictValue"
>
{{ item.dictLabel }}
</option>
</select>
<select
:value="mUnit"
@click="handleOnSelectClick"
@change="handleOnUnitChange"
>
<option
v-for="item in cusUnitOptions"
:key="item.dictValue"
:value="item.dictValue"
>
{{ item.dictLabel }}
</option>
</select>
</div>
</div>
</template>
<script>
import { createNamespacedHelpers } from "vuex";
const { mapState, mapGetters } = createNamespacedHelpers("recipes");
export default {
name: "EditableUnit",
props: ["weight", "unit"],
mounted() {
window.addEventListener("click", this.handleOnWindowClick);
},
unmounted() {
window.removeEventListener("click", this.handleOnWindowClick);
},
data() {
return {
editing: false,
mWeight: this.weight,
mUnit: this.unit,
};
},
methods: {
handleOnClick(e) {
if (!this.editing) {
setTimeout(() => {
this.editing = true;
}, 0);
}
},
handleOnWindowClick(e) {
if (this.editing) {
// console.log("handleOnWindowClick");
this.editing = false;
if (
String(this.mWeight) !== String(this.weight) ||
String(this.mUnit) !== String(this.unit)
) {
// console.log({
// mWeight: this.mWeight,
// mUnit: this.mUnit,
// weight: this.weight,
// unit: this.unit,
// });
this.$emit("onChange", {
cusWeight: this.mWeight,
cusUnit: this.mUnit,
});
}
}
},
handleOnSelectClick(e) {
if (this.editing) {
e.stopPropagation();
}
},
handleOnWeightChange(e) {
const { value } = e.target;
this.mWeight = value;
},
handleOnUnitChange(e) {
const { value } = e.target;
this.mUnit = value;
},
},
computed: {
unitWeight() {
return (
`${this.cusWeightDict[this.mWeight] || ""}${
this.cusUnitDict[this.mUnit] || ""
}` || "_"
);
},
...mapState(["cusUnitOptions", "cusWeightOptions"]),
...mapGetters(["cusUnitDict", "cusWeightDict"]),
},
};
</script>
<style lang="scss" scoped>
.editable_unit_wrapper {
.value {
cursor: pointer;
}
.selector {
display: flex;
select:nth-child(1) {
margin-right: 2px;
}
select {
font-size: 11px;
border: solid 1px #dcdfe6;
border-radius: 4px;
appearance: none;
-moz-appearance: none;
-webkit-appearance: none;
padding: 3px 6px;
&:hover {
border-color: #409eff;
}
&:focus {
outline: none;
border-color: #409eff;
}
}
/*清除ie的默认选择框样式清除隐藏下拉箭头*/
select::-ms-expand {
display: none;
}
}
}
</style>

View File

@ -0,0 +1,326 @@
<template>
<div class="recipes_com_wrapper">
<el-table
:data="mData"
border
:span-method="spanMethod"
:cell-style="{ padding: '2px 0' }"
:header-cell-style="{ padding: '4px 0', height: 'unset' }"
size="mini"
:style="`outline: ${
currentDay + 1 === num ? '1px solid #d96969' : 'none'
}`"
>
<el-table-column prop="type" :width="100" align="center">
<template slot="header">
<span class="num_day" @click="handleOnOneDayAnalysis">{{
`${name}${num}`
}}</span>
</template>
<template slot-scope="scope">
<span style="font-weight: bold; font-size: 14px">{{
typeFormatter(scope.row)
}}</span>
</template>
</el-table-column>
<el-table-column label="菜品" prop="name" align="center">
<template slot="header">
<el-tooltip
class="item"
effect="dark"
content="点击添加菜品"
placement="top"
>
<span class="num_day" @click="handleOnAdd">菜品</span>
</el-tooltip>
</template>
<template slot-scope="scope">
<el-popover placement="right" trigger="hover">
<div>
<el-button
type="danger"
size="mini"
icon="el-icon-delete"
class="fun_button"
@click="handleOnDelete(scope.row)"
>删除</el-button
>
</div>
<span class="num_day" slot="reference">{{ scope.row.name }}</span>
</el-popover>
</template>
</el-table-column>
<el-table-column label="食材" prop="igdName" align="center" />
<el-table-column label="分量估算" :width="80" align="center">
<template slot-scope="scope">
<EditableUnit
:weight="scope.row.cusWeight"
:unit="scope.row.cusUnit"
@onChange="(val) => handleOnCustomUnitChange(scope.row, val)"
/>
</template>
</el-table-column>
<el-table-column label="重量(g)" prop="weight" :width="80" align="center">
<template slot-scope="scope">
<EditableText
:value="scope.row.weight"
@onChange="(val) => handleOnWeightChange(scope.row, val)"
/>
</template>
</el-table-column>
<el-table-column
label="蛋白质/100g"
prop="proteinRatio"
:width="100"
align="center"
/>
<el-table-column
label="脂肪/100g"
prop="fatRatio"
:width="90"
align="center"
/>
<el-table-column
label="碳水/100g"
prop="carbonRatio"
:width="90"
align="center"
/>
<el-table-column
label="蛋白质含量"
prop="proteinRatio"
:width="90"
align="center"
:formatter="nutriFormatter"
/>
<el-table-column
label="脂肪含量"
prop="fatRatio"
:width="90"
align="center"
:formatter="nutriFormatter"
/>
<el-table-column
label="碳水含量"
prop="carbonRatio"
:width="90"
align="center"
:formatter="nutriFormatter"
/>
<el-table-column label="做法" prop="methods" />
</el-table>
<AddDishesDrawer ref="drawerRef" @onConfirm="handleOnDishesConfirm" />
</div>
</template>
<script>
import { createNamespacedHelpers } from "vuex";
const {
mapActions,
mapGetters,
mapState,
mapMutations,
} = createNamespacedHelpers("recipes");
import EditableText from "./EditableText";
import EditableUnit from "./EditableUnit";
import AddDishesDrawer from "./AddDishesDrawer";
export default {
name: "RecipesCom",
props: {
data: {
type: Object,
default: [],
required: true,
},
name: {
type: String,
default: "",
},
num: {
type: Number,
default: 0,
},
},
components: {
EditableText,
EditableUnit,
AddDishesDrawer,
},
mounted() {
// console.log(this.data);
},
data() {
return {};
},
computed: {
mData() {
if (!this.data.dishes) {
return [];
}
const mData = this.data.dishes
.sort((a, b) => a.type - b.type)
.reduce((arr, cur, idx) => {
if (cur.dishesId > 0 && cur.type !== "0") {
cur.igdList.forEach((igd) => {
let lastTypeHit = false,
lastNameHit = false;
if (arr.length > 0) {
//
lastTypeHit = arr[arr.length - 1].type === cur.type;
if (lastTypeHit) {
let typePos = arr.length - 1;
for (let i = typePos; i >= 0; i--) {
if (arr[i].type !== cur.type) {
break;
}
typePos = i;
}
arr[typePos].typeSpan.rowspan += 1;
}
lastNameHit = arr[arr.length - 1].name === cur.name;
if (lastNameHit) {
let namePos = arr.length - 1;
for (let i = namePos; i >= 0; i--) {
if (arr[i].name !== cur.name) {
break;
}
namePos = i;
}
arr[namePos].nameSpan.rowspan += 1;
arr[namePos].methodsSpan.rowspan += 1;
}
}
arr.push({
id: cur.id,
dishesId: cur.dishesId,
menuId: cur.menuId,
name: cur.name,
type: cur.type,
isMain: cur.isMain,
methods: cur.methods,
igdId: igd.id,
igdName: igd.name,
proteinRatio: igd.proteinRatio,
fatRatio: igd.fatRatio,
carbonRatio: igd.carbonRatio,
rec: igd.rec,
notRec: igd.notRec,
weight: igd.weight,
cusWeight: igd.cusWeight,
cusUnit: igd.cusUnit,
typeSpan: lastTypeHit
? {
rowspan: 0,
colspan: 0,
}
: {
rowspan: 1,
colspan: 1,
},
nameSpan: lastNameHit
? {
rowspan: 0,
colspan: 0,
}
: {
rowspan: 1,
colspan: 1,
},
methodsSpan: lastNameHit
? {
rowspan: 0,
colspan: 0,
}
: {
rowspan: 1,
colspan: 1,
},
});
});
}
return arr;
}, []);
// console.log(mData);
return mData;
},
...mapGetters(["typeDict"]),
...mapState(["currentDay"]),
},
methods: {
spanMethod({ row, column, rowIndex, columnIndex }) {
if (columnIndex === 0) {
return row.typeSpan;
} else if (columnIndex === 1) {
return row.nameSpan;
} else if (columnIndex === 11) {
return row.methodsSpan;
}
},
typeFormatter(row) {
return this.typeDict[row.type];
},
nutriFormatter(row, col) {
return ((row.weight / 100) * row[col.property]).toFixed(1);
},
handleOnOneDayAnalysis(e) {
//
this.setCurrentDay({ currentDay: this.num - 1 });
},
handleOnAdd() {
// console.log(this.num);
this.$refs.drawerRef.showDrawer();
},
handleOnDelete(data) {
// console.log(data);
this.deleteDishes({ num: this.num - 1, id: data.id });
},
handleOnWeightChange(data, weight) {
// console.log({ data, weight });
this.updateDishes({
num: this.num - 1,
dishesId: data.dishesId,
igdId: data.igdId,
weight,
});
},
handleOnCustomUnitChange(data, { cusWeight, cusUnit }) {
// console.log({ data, cusWeight, cusUnit });
this.updateDishes({
num: this.num - 1,
dishesId: data.dishesId,
igdId: data.igdId,
cusWeight,
cusUnit,
});
},
handleOnDishesConfirm(data) {
// console.log(data);
this.addDishes({
num: this.num - 1,
data,
});
},
...mapActions(["updateDishes", "addDishes", "deleteDishes"]),
...mapMutations(["setCurrentDay"]),
},
};
</script>
<style lang="scss" scoped>
.recipes_com_wrapper {
margin-bottom: 24px;
padding: 1px;
.num_day {
cursor: pointer;
outline: none;
}
}
</style>
<style lang="scss">
.fun_button {
font-size: 12px;
padding: 4px 8px;
}
</style>

View File

@ -0,0 +1,49 @@
<template>
<div class="recipes_view_wrapper">
<RecipesAspectCom :collapse.sync="collapse" :data="analyseData" />
<div
class="recipes_content"
:style="`height: calc(100vh - ${collapse ? 142 : 312}px)`"
>
<RecipesCom
v-for="(item, index) in data"
:key="item.id"
:data="item"
:name="name"
:num="index + 1"
/>
</div>
</div>
</template>
<script>
import RecipesCom from "./RecipesCom";
import RecipesAspectCom from "./RecipesAspectCom";
export default {
name: "RecipesView",
components: {
RecipesCom,
RecipesAspectCom,
},
computed: {
mCollapse() {
return analyseData.length ? this.collapse : false;
},
},
data() {
return {
collapse: false,
};
},
props: ["data", "analyseData", "name", "numRange"],
};
</script>
<style lang="scss" scoped >
.recipes_view_wrapper {
// padding-right: 20px;
.recipes_content {
overflow: auto;
background: white;
}
}
</style>

View File

@ -0,0 +1,22 @@
<template>
<el-button @click="handleOnClick">推荐</el-button>
</template>
<script>
import { createNamespacedHelpers } from "vuex";
const {
mapActions,
mapState,
mapMutations,
mapGetters,
} = createNamespacedHelpers("recipes");
export default {
name: "RecommondView",
methods: {
handleOnClick() {
this.getRecipesInfo({ recipesId: 73 });
},
...mapActions(["getRecipesInfo"]),
},
};
</script>

View File

@ -1,26 +1,33 @@
<template>
<div class="app-container">
<div class="content">
<div class="left">
<RecipesView :data="recipesData" />
<div class="recipes_build_wrapper">
<div class="left" v-loading="recipesDataLoading">
<RecipesView
v-if="!!recipesData.length"
:data="recipesData"
:name="healthyData.name"
:analyseData="analyseData"
/>
<RecommondView v-else />
</div>
<div class="right">
<div class="right" v-loading="healthDataLoading">
<HealthyView :data="healthyData" v-if="healthyDataType === 0" />
<BodySignView :data="healthyData" v-else />
</div>
</div>
</div>
</template>
<script>
import { createNamespacedHelpers } from "vuex";
const { mapActions, mapState, mapMutations } = createNamespacedHelpers(
"recipes"
);
const {
mapActions,
mapState,
mapMutations,
mapGetters,
} = createNamespacedHelpers("recipes");
import HealthyView from "./HealthyView";
import BodySignView from "./BodySignView";
import RecipesView from "./RecipesView";
import RecipesView from "./RecipesView/index";
import RecommondView from "./RecommondView";
export default {
name: "BuildRecipies",
@ -28,12 +35,15 @@ export default {
return {};
},
mounted() {
//
// console.log({
// cusId: this.cusId,
// recipesId: this.recipesId,
// });
this.init({ cusId: this.cusId, recipesId: this.recipesId }).catch((err) => {
const { cusId, planId, startDate, endDate, recipesId } = this.$route.query;
this.init({
cusId,
planId,
startDate,
endDate,
recipesId,
}).catch((err) => {
this.$message.error(err.message);
});
},
@ -45,14 +55,18 @@ export default {
HealthyView,
BodySignView,
RecipesView,
RecommondView,
},
props: ["planId", "cusId", "recipesId"],
// props: ["cusId", "planId", "recipesId", "startDate", "endDate"],
computed: {
...mapState({
healthyData: (state) => state.healthyData,
healthyDataType: (state) => state.healthyDataType,
recipesData: (state) => state.recipesData,
}),
...mapState([
"healthyData",
"healthyDataType",
"recipesData",
"recipesDataLoading",
"healthDataLoading",
]),
...mapGetters(["analyseData"]),
},
methods: {
...mapActions(["init"]),
@ -60,15 +74,17 @@ export default {
},
};
</script>
<style rel="stylesheet/scss" lang="scss">
.content {
<style lang="scss" scoped>
.recipes_build_wrapper {
padding: 16px;
display: flex;
height: calc(100vh - 124px);
height: calc(100vh - 86px);
.left {
flex: 4;
border-right: 1px solid #e6ebf5;
height: 100%;
overflow: auto;
overflow: hidden;
padding-right: 20px;
}
.right {
flex: 1;

View File

@ -111,14 +111,14 @@
:data="recipesPlanList"
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" width="55" align="center" />
<!-- <el-table-column type="selection" width="55" align="center" /> -->
<el-table-column label="客户姓名" align="center" prop="customer" />
<el-table-column
<!-- <el-table-column
label="客户手机号"
align="center"
prop="hidePhone"
width="180"
/>
/> -->
<el-table-column
label="食谱日期范围"
align="center"
@ -170,14 +170,14 @@
<el-button
size="mini"
type="text"
icon="el-icon-edit"
icon="el-icon-view"
@click="
allRecipesPlanQueryParam.orderId = scope.row.orderId;
getAllPlanByOrderId();
"
>查看完整计划
</el-button>
<el-button
<!-- <el-button
size="mini"
type="text"
icon="el-icon-edit"
@ -192,13 +192,15 @@
@click="getCustomerSign(scope.row)"
v-hasPermi="['custom:customer:query']"
>查看体征
</el-button>
</el-button> -->
<el-button
size="mini"
type="text"
icon="el-icon-edit"
:icon="`${
scope.row.recipesId ? 'el-icon-edit' : 'el-icon-edit-outline'
}`"
@click="handleBuild(scope.row)"
>{{ `${scope.row.recipes_id ? "编辑" : "制作"}食谱` }}</el-button
>{{ `${scope.row.recipesId ? "编辑" : "制作"}食谱` }}</el-button
>
</template>
</el-table-column>
@ -234,8 +236,7 @@
<!-- 查看完整计划 -->
<el-dialog
title="食谱计划表"
v-if="allRecipesPlanOpen"
:title="allRecipesPlanTitle"
:visible.sync="allRecipesPlanOpen"
width="800px"
append-to-body
@ -267,7 +268,7 @@
</el-form>
<el-table v-loading="loading" :data="allRecipesPlanList" width="700px">
<el-table-column label="客户姓名" align="center" prop="customer" />
<!-- <el-table-column label="客户姓名" align="center" prop="customer" /> -->
<!--<el-table-column label="营养师名称" align="center" prop="nutritionist" />
<el-table-column label="营养师助理名称" align="center" prop="nutritionistAssis" />-->
@ -311,9 +312,9 @@
</el-dialog>
<!-- 查看订单 -->
<order-dialog ref="orderDialog" />
<!-- <order-dialog ref="orderDialog" /> -->
<!-- 查看体征 -->
<body_sign_dialog ref="bodySignDialog" />
<!-- <body_sign_dialog ref="bodySignDialog" /> -->
</div>
</template>
@ -325,10 +326,11 @@ import {
updateRecipesPlan,
} from "@/api/custom/recipesPlan";
import { getOptions } from "@/api/custom/order";
import OrderDetail from "@/components/OrderDetail";
import BodySignDetail from "@/components/BodySignDetail";
// import OrderDetail from "@/components/OrderDetail";
// import BodySignDetail from "@/components/BodySignDetail";
import dayjs from "dayjs";
import store from "@/store";
import { mapState } from "vuex";
const nextDate = dayjs().add(1, "day").format("YYYY-MM-DD");
const weekDate = dayjs().add(6, "day").format("YYYY-MM-DD");
@ -376,6 +378,7 @@ export default {
allRecipesPlanList: [],
//
allRecipesPlanOpen: false,
allRecipesPlanTitle: "",
//
allRecipesPlanQueryParam: {
pageNum: 1,
@ -385,47 +388,41 @@ export default {
},
//
allRecipesPlanTotal: 0,
//
nutritionistIdOptions: [],
//
nutriAssisIdOptions: [],
};
},
components: {
"order-dialog": OrderDetail,
body_sign_dialog: BodySignDetail,
// "order-dialog": OrderDetail,
// body_sign_dialog: BodySignDetail,
},
created() {
getOptions().then((response) => {
const options = response.data.reduce((opts, cur) => {
if (!opts[cur.postCode]) {
opts[cur.postCode] = [
{ dictValue: null, dictLabel: "全部", remark: null },
];
}
opts[cur.postCode].push({
dictValue: cur.userId,
dictLabel: cur.userName,
remark: cur.remark,
});
return opts;
}, {});
this.nutritionistIdOptions = options["nutri"] || [];
this.nutriAssisIdOptions = options["nutri_assis"] || [];
const defaultNutritionist = this.nutritionistIdOptions.find(
(opt) => opt.dictValue == userId
);
const defaultNutriAssisId = this.nutriAssisIdOptions.find(
(opt) => opt.dictValue == userId
);
if (defaultNutritionist) {
computed: {
...mapState({
//
nutritionistIdOptions: (state) =>
state.global.nutritionistIdOptions.slice(1),
//
nutriAssisIdOptions: (state) => state.global.nutriAssisIdOptions.slice(1),
}),
},
watch: {
nutritionistIdOptions: function (val, oldVal) {
if (val.length && !oldVal.length) {
const tarObj = val.find((opt) => opt.dictValue == userId);
if (tarObj) {
this.queryParams.nutritionistId = userId;
}
if (defaultNutriAssisId) {
}
},
nutriAssisIdOptions: function (val, oldVal) {
if (val.length && !oldVal.length) {
const tarObj = val.find((opt) => opt.dictValue == userId);
if (tarObj) {
this.queryParams.nutritionistAssisId = userId;
}
}
},
},
created() {
this.getList();
});
},
methods: {
/** 查询食谱计划列表 */
@ -474,6 +471,7 @@ export default {
dayjs(item.endDate).format("YYYY-MM-DD");
});
this.allRecipesPlanOpen = true;
this.allRecipesPlanTitle = `${this.allRecipesPlanList[0].customer}」食谱计划表`;
this.allRecipesPlanTotal = response.total;
});
},
@ -604,20 +602,26 @@ export default {
}
},
handleBuild(data) {
// console.log(data);
const { startDate, endDate, id, cusId, recipesId } = data;
// const params = { id: data.id, cusId: data.orderId };
let path = `/recipes/build/${data.orderId}/${data.id}`;
if (data.recipes_id) {
// params.recipesId = data.recipes_id;
path += `/${data.recipes_id}`;
}
// test
// params.recipesId = "61";
path += '/73';
// const path = `/recipes/build/${orderId}/${id}/${recipesId || 0}`;
// this.$router.push({
// name: "build",
// params,
// });
this.$router.push(path);
const queryParam = {
planId: id,
cusId,
};
if (!recipesId) {
queryParam.startDate = startDate;
queryParam.endDate = endDate;
} else {
queryParam.recipesId = recipesId;
}
this.$router.push({ path: "/recipes/build", query: queryParam });
},
},
};

View File

@ -1,8 +1,20 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<el-form
:model="queryParams"
ref="queryForm"
:inline="true"
v-show="showSearch"
label-width="68px"
>
<el-form-item label="销售" prop="userId">
<el-select v-model="queryParams.userId" placeholder="请选择销售" filterable clearable size="small">
<el-select
v-model="queryParams.userId"
placeholder="请选择销售"
filterable
clearable
size="small"
>
<el-option
v-for="dict in preSaleIdOptions"
:key="dict.dictValue"
@ -12,7 +24,13 @@
</el-select>
</el-form-item>
<el-form-item label="销售组别" prop="saleGroupId">
<el-select v-model="queryParams.saleGroupId" placeholder="请选择组别" filterable clearable size="small">
<el-select
v-model="queryParams.saleGroupId"
placeholder="请选择组别"
filterable
clearable
size="small"
>
<el-option
v-for="dict in saleGroupOptions"
:key="dict.dictValue"
@ -22,7 +40,13 @@
</el-select>
</el-form-item>
<el-form-item label="进粉渠道" prop="accountId">
<el-select v-model="queryParams.accountId" filterable placeholder="请选择渠道" clearable size="small">
<el-select
v-model="queryParams.accountId"
filterable
placeholder="请选择渠道"
clearable
size="small"
>
<el-option
v-for="dict in accountIdOptions"
:key="dict.dictValue"
@ -41,8 +65,16 @@
/>
</el-form-item>-->
<el-form-item>
<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-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>
@ -54,7 +86,8 @@
size="mini"
@click="handleAdd"
v-hasPermi="['custom:wxDistribution:add']"
>新增</el-button>
>新增</el-button
>
</el-col>
<el-col :span="1.5">
<el-button
@ -64,7 +97,8 @@
:disabled="single"
@click="handleUpdate"
v-hasPermi="['custom:wxDistribution:edit']"
>修改</el-button>
>修改</el-button
>
</el-col>
<el-col :span="1.5">
<el-button
@ -74,7 +108,8 @@
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['custom:wxDistribution:remove']"
>删除</el-button>
>删除</el-button
>
</el-col>
<el-col :span="1.5">
<el-button
@ -83,24 +118,42 @@
size="mini"
@click="handleExport"
v-hasPermi="['custom:wxDistribution:export']"
>导出</el-button>
>导出</el-button
>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
<right-toolbar
:showSearch.sync="showSearch"
@queryTable="getList"
></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="wxDistributionList" stripe @selection-change="handleSelectionChange">
<el-table
v-loading="loading"
:data="wxDistributionList"
stripe
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="销售姓名" align="center" prop="userName" />
<el-table-column label="微信昵称" align="center" prop="wxNickName" />
<el-table-column label="微信号" align="center" prop="wxAccount" />
<el-table-column label="进粉渠道" align="center" prop="account" />
<el-table-column label="销售组别" align="center" prop="saleGroup" />
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
<el-table-column
label="创建时间"
align="center"
prop="createTime"
width="180"
>
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
<span>{{ parseTime(scope.row.createTime, "{y}-{m}-{d}") }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<el-table-column
label="操作"
align="center"
class-name="small-padding fixed-width"
>
<template slot-scope="scope">
<el-button
size="mini"
@ -108,20 +161,22 @@
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['custom:wxDistribution:edit']"
>修改</el-button>
>修改</el-button
>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['custom:wxDistribution:remove']"
>删除</el-button>
>删除</el-button
>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@ -132,7 +187,13 @@
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="销售" prop="userId">
<el-select v-model="form.userId" placeholder="请选择销售" filterable clearable size="small">
<el-select
v-model="form.userId"
placeholder="请选择销售"
filterable
clearable
size="small"
>
<el-option
v-for="dict in preSaleIdOptions"
:key="dict.dictValue"
@ -142,7 +203,13 @@
</el-select>
</el-form-item>
<el-form-item label="销售组别" prop="saleGroupId">
<el-select v-model="form.saleGroupId" placeholder="请选择组别" filterable clearable size="small">
<el-select
v-model="form.saleGroupId"
placeholder="请选择组别"
filterable
clearable
size="small"
>
<el-option
v-for="dict in saleGroupOptions"
:key="dict.dictValue"
@ -152,7 +219,13 @@
</el-select>
</el-form-item>
<el-form-item label="进粉渠道" prop="accountId">
<el-select v-model="form.accountId" filterable placeholder="请选择渠道" clearable size="small">
<el-select
v-model="form.accountId"
filterable
placeholder="请选择渠道"
clearable
size="small"
>
<el-option
v-for="dict in accountIdOptions"
:key="dict.dictValue"
@ -162,7 +235,13 @@
</el-select>
</el-form-item>
<el-form-item label="微信号" prop="wechatAccount">
<el-select v-model="form.wechatAccount" filterable placeholder="请选择微信号" clearable size="small">
<el-select
v-model="form.wechatAccount"
filterable
placeholder="请选择微信号"
clearable
size="small"
>
<el-option
v-for="dict in wxAccountList"
:key="dict.id"
@ -181,10 +260,18 @@
</template>
<script>
import { listWxDistribution, getWxDistribution, delWxDistribution, addWxDistribution, updateWxDistribution, exportWxDistribution } from "@/api/custom/wxDistribution";
import {getOptions} from "@/api/custom/order";
import { listWxAccount } from "@/api/custom/wxAccount";
export default {
import {
listWxDistribution,
getWxDistribution,
delWxDistribution,
addWxDistribution,
updateWxDistribution,
exportWxDistribution,
} from "@/api/custom/wxDistribution";
import { getOptions } from "@/api/custom/order";
import { listWxAccount } from "@/api/custom/wxAccount";
import { mapState } from "vuex";
export default {
name: "WxDistribution",
data() {
return {
@ -220,36 +307,26 @@
//
rules: {
userId: [{ required: true, trigger: "blur", message: "请选择销售" }],
saleGroupId: [{ required: true, trigger: "blur", message: "请选择组别" }],
accountId: [{ required: true, trigger: "blur", message: "请选择进粉账号" }],
wechatAccount: [{ required: true, trigger: "blur", message: "请选择微信号" }]
saleGroupId: [
{ required: true, trigger: "blur", message: "请选择组别" },
],
accountId: [
{ required: true, trigger: "blur", message: "请选择进粉账号" },
],
wechatAccount: [
{ required: true, trigger: "blur", message: "请选择微信号" },
],
},
//
preSaleIdOptions:[],
//
accountIdOptions:[],
accountIdOptions: [],
//
saleGroupOptions:[],
saleGroupOptions: [],
//
wxAccountList:[]
wxAccountList: [],
};
},
created() {
this.getList();
getOptions().then((response) => {
const options = response.data.reduce((opts, cur) => {
if (!opts[cur.postCode]) {
opts[cur.postCode] = [];
}
opts[cur.postCode].push({
dictValue: cur.userId,
dictLabel: cur.userName,
remark: cur.remark,
});
return opts;
}, {});
this.preSaleIdOptions = options["pre_sale"] || [];
});
this.getDicts("fan_channel").then((response) => {
this.accountIdOptions = response.data;
});
@ -258,11 +335,17 @@
});
this.getListWxAccount();
},
computed: {
...mapState({
//
preSaleIdOptions: (state) => state.global.preSaleIdOptions.slice(1),
}),
},
methods: {
/** 查询微信分配管理列表 */
getList() {
this.loading = true;
listWxDistribution(this.queryParams).then(response => {
listWxDistribution(this.queryParams).then((response) => {
this.wxDistributionList = response.rows;
this.total = response.total;
this.loading = false;
@ -279,7 +362,7 @@
userId: null,
saleGroupId: null,
accountId: null,
wechatAccount: null
wechatAccount: null,
};
this.resetForm("form");
},
@ -295,9 +378,9 @@
},
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length!==1
this.multiple = !selection.length
this.ids = selection.map((item) => item.id);
this.single = selection.length !== 1;
this.multiple = !selection.length;
},
/** 新增按钮操作 */
handleAdd() {
@ -308,8 +391,8 @@
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids
getWxDistribution(id).then(response => {
const id = row.id || this.ids;
getWxDistribution(id).then((response) => {
this.form = response.data;
this.open = true;
this.title = "修改微信分配";
@ -317,10 +400,10 @@
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
this.$refs["form"].validate((valid) => {
if (valid) {
if (this.form.id != null) {
updateWxDistribution(this.form).then(response => {
updateWxDistribution(this.form).then((response) => {
if (response.code === 200) {
this.msgSuccess("修改成功");
this.open = false;
@ -328,7 +411,7 @@
}
});
} else {
addWxDistribution(this.form).then(response => {
addWxDistribution(this.form).then((response) => {
if (response.code === 200) {
this.msgSuccess("新增成功");
this.open = false;
@ -342,35 +425,45 @@
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$confirm('是否确认删除微信号为"' + row.wxNickName + '"的数据项?', "警告", {
this.$confirm(
'是否确认删除微信号为"' + row.wxNickName + '"的数据项?',
"警告",
{
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
type: "warning",
}
)
.then(function () {
return delWxDistribution(ids);
}).then(() => {
})
.then(() => {
this.getList();
this.msgSuccess("删除成功");
}).catch(function() {});
})
.catch(function () {});
},
/** 导出按钮操作 */
handleExport() {
const queryParams = this.queryParams;
this.$confirm('是否确认导出所有微信分配数据项?', "警告", {
this.$confirm("是否确认导出所有微信分配数据项?", "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
type: "warning",
})
.then(function () {
return exportWxDistribution(queryParams);
}).then(response => {
})
.then((response) => {
this.download(response.msg);
}).catch(function() {});
})
.catch(function () {});
},
getListWxAccount() {
listWxAccount(this.queryParams).then(response => {
listWxAccount(this.queryParams).then((response) => {
this.wxAccountList = response.rows;
});
}
}
};
},
},
};
</script>