串联功能

This commit is contained in:
huangdeliang 2021-02-27 16:57:45 +08:00
parent df485e55d0
commit 1d7b7cd259
16 changed files with 388 additions and 451 deletions

View File

@ -57,6 +57,12 @@ public class SysRecipesPlanController extends BaseController
return getDataTable(list); return getDataTable(list);
} }
@PreAuthorize("@ss.hasPermi('recipes:recipesPlan:list')")
@GetMapping(value = "/list/{cusId}")
public AjaxResult getAllPlanByCusId(@PathVariable Long cusId) {
return AjaxResult.success(sysRecipesPlanService.selectPlanListByCusId(cusId));
}
/** /**
* 获取食谱计划详细信息 * 获取食谱计划详细信息
*/ */

View File

@ -34,16 +34,31 @@ public class SysWapController extends BaseController {
return AjaxResult.success(iSysWapServices.getRecipesPlanListInfo(outId)); return AjaxResult.success(iSysWapServices.getRecipesPlanListInfo(outId));
} }
/**
* 获取用户信息
* @param outId
* @return
*/
@GetMapping(value = "/healthyInfo/{outId}") @GetMapping(value = "/healthyInfo/{outId}")
public AjaxResult healthy(@PathVariable String outId) { public AjaxResult healthy(@PathVariable String outId) {
return AjaxResult.success(iSysWapServices.getHealthyDataByOutId(outId)); return AjaxResult.success(iSysWapServices.getHealthyDataByOutId(outId));
} }
/**
* 获取某天食谱菜品
* @param id
* @return
*/
@GetMapping(value = "/recipes/menu/{id}") @GetMapping(value = "/recipes/menu/{id}")
public AjaxResult dayilyMenu(@PathVariable Long id) { public AjaxResult dayilyMenu(@PathVariable Long id) {
return AjaxResult.success(iSysRecipesService.selectDishesByMenuId(id)); return AjaxResult.success(iSysRecipesService.selectDishesByMenuId(id));
} }
/**
* 系统字典
* @param dictType
* @return
*/
@GetMapping(value = "/dict/{dictType}") @GetMapping(value = "/dict/{dictType}")
public AjaxResult sysDict(@PathVariable String dictType) { public AjaxResult sysDict(@PathVariable String dictType) {
return AjaxResult.success(iSysDictTypeService.selectDictDataByType(dictType)); return AjaxResult.success(iSysDictTypeService.selectDictDataByType(dictType));

View File

@ -28,6 +28,11 @@ public class SysRecipesPlan {
private Long cusId; private Long cusId;
/**
* 对外的用户id
*/
private String outId;
//客户ID //客户ID
// private Long customerId; // private Long customerId;

View File

@ -88,9 +88,9 @@ public interface SysRecipesPlanMapper
*/ */
List<SysRecipesPlan> selectPlanListByOrderId(SysRecipesPlan sysRecipesPlan); List<SysRecipesPlan> selectPlanListByOrderId(SysRecipesPlan sysRecipesPlan);
List<SysRecipesPlan> selectPlanListByOutId(String outId);
Long getCusIdByOutId(String outId); Long getCusIdByOutId(String outId);
List<SysRecipesPlanListInfo> selectRecipesPlanListInfo(String outId); List<SysRecipesPlanListInfo> selectRecipesPlanListInfo(String outId);
List<SysRecipesPlan> selectPlanListByCusId(Long cusId);
} }

View File

@ -91,10 +91,26 @@ public interface ISysRecipesPlanService
*/ */
List<SysRecipesPlan> selectPlanListByOrderId(SysRecipesPlan sysRecipesPlan); List<SysRecipesPlan> selectPlanListByOrderId(SysRecipesPlan sysRecipesPlan);
List<SysRecipesPlan> selectPlanListByOutId(String outId);
/**
* 通过outId查询cusId
* @param outId
* @return
*/
Long getCusIdByOutId(String outId); Long getCusIdByOutId(String outId);
/**
* 通过outId查询食谱计划简要
* @param outId
* @return
*/
List<SysRecipesPlanListInfo> selectRecipesPlanListInfo(String outId); List<SysRecipesPlanListInfo> selectRecipesPlanListInfo(String outId);
/**
* 通过客户id查询食谱计划
* @param cusId
* @return
*/
List<SysRecipesPlan> selectPlanListByCusId(Long cusId);
} }

View File

@ -293,11 +293,6 @@ public class SysRecipesPlanServiceImpl implements ISysRecipesPlanService {
return sysRecipesPlanMapper.selectPlanListByOrderId(sysRecipesPlan); return sysRecipesPlanMapper.selectPlanListByOrderId(sysRecipesPlan);
} }
@Override
public List<SysRecipesPlan> selectPlanListByOutId(String outId) {
return sysRecipesPlanMapper.selectPlanListByOutId(outId);
}
@Override @Override
public Long getCusIdByOutId(String outId) { public Long getCusIdByOutId(String outId) {
return sysRecipesPlanMapper.getCusIdByOutId(outId); return sysRecipesPlanMapper.getCusIdByOutId(outId);
@ -308,4 +303,9 @@ public class SysRecipesPlanServiceImpl implements ISysRecipesPlanService {
return sysRecipesPlanMapper.selectRecipesPlanListInfo(outId); return sysRecipesPlanMapper.selectRecipesPlanListInfo(outId);
} }
@Override
public List<SysRecipesPlan> selectPlanListByCusId(Long cusId) {
return sysRecipesPlanMapper.selectPlanListByCusId(cusId);
}
} }

View File

@ -54,6 +54,7 @@ public class SysRecipesServiceImpl implements ISysRecipesService {
SysRecipesPlan sysRecipesPlan = new SysRecipesPlan(); SysRecipesPlan sysRecipesPlan = new SysRecipesPlan();
sysRecipesPlan.setId(sysRecipes.getPlanId()); sysRecipesPlan.setId(sysRecipes.getPlanId());
sysRecipesPlan.setRecipesId(sysRecipes.getId()); sysRecipesPlan.setRecipesId(sysRecipes.getId());
sysRecipesPlan.setReviewStatus(1);
sysRecipesPlanMapper.updateSysRecipesPlan(sysRecipesPlan); sysRecipesPlanMapper.updateSysRecipesPlan(sysRecipesPlan);
} }

View File

@ -5,52 +5,53 @@
<mapper namespace="com.stdiet.custom.mapper.SysRecipesPlanMapper"> <mapper namespace="com.stdiet.custom.mapper.SysRecipesPlanMapper">
<resultMap type="SysRecipesPlan" id="SysRecipesPlanResult"> <resultMap type="SysRecipesPlan" id="SysRecipesPlanResult">
<result property="id" column="id" /> <result property="id" column="id"/>
<result property="orderId" column="order_id" /> <result property="orderId" column="order_id"/>
<result property="startDate" column="start_date" /> <result property="startDate" column="start_date"/>
<result property="endDate" column="end_date" /> <result property="endDate" column="end_date"/>
<result property="startNumDay" column="start_num_day" /> <result property="startNumDay" column="start_num_day"/>
<result property="endNumDay" column="end_num_day" /> <result property="endNumDay" column="end_num_day"/>
<result property="recipesId" column="recipes_id" /> <result property="recipesId" column="recipes_id"/>
<result property="sendFlag" column="send_flag" /> <result property="sendFlag" column="send_flag"/>
<result property="sendTime" column="send_time" /> <result property="sendTime" column="send_time"/>
<result property="createTime" column="create_time" /> <result property="createTime" column="create_time"/>
<result property="createBy" column="create_by" /> <result property="createBy" column="create_by"/>
<result property="updateTime" column="update_time" /> <result property="updateTime" column="update_time"/>
<result property="updateBy" column="update_by" /> <result property="updateBy" column="update_by"/>
<result property="delFlag" column="del_flag" /> <result property="delFlag" column="del_flag"/>
<result property="cusId" column="cus_id" /> <result property="cusId" column="cus_id"/>
<result property="outId" column="out_id"/>
<!-- 非持久化字段 --> <!-- 非持久化字段 -->
<!-- <result property="customerId" column="cus_id"></result>&lt;!&ndash; 客户ID &ndash;&gt;--> <!-- <result property="customerId" column="cus_id"></result>&lt;!&ndash; 客户ID &ndash;&gt;-->
<result property="customer" column="customer" /><!-- 客户姓名 --> <result property="customer" column="customer"/><!-- 客户姓名 -->
<result property="phone" column="phone" /> <result property="phone" column="phone"/>
<result property="reviewStatus" column="review_status" /> <result property="reviewStatus" column="review_status"/>
<result property="orderStartDate" column="order_start_date" /> <result property="orderStartDate" column="order_start_date"/>
<result property="orderEndDate" column="order_end_date" /> <result property="orderEndDate" column="order_end_date"/>
<result property="nutritionistId" column="nutritionist_id" /> <result property="nutritionistId" column="nutritionist_id"/>
<result property="nutritionist" column="nutritionist" /> <result property="nutritionist" column="nutritionist"/>
<result property="nutritionistAssisId" column="nutritionist_assis_id" /> <result property="nutritionistAssisId" column="nutritionist_assis_id"/>
<result property="nutritionistAssis" column="nutritionist_assis" /> <result property="nutritionistAssis" column="nutritionist_assis"/>
</resultMap> </resultMap>
<sql id="selectSysRecipesPlanVo"> <sql id="selectSysRecipesPlanVo">
select id, order_id, cus_id, start_date, end_date, start_num_day, end_num_day, recipes_id, send_flag, send_time, create_time, create_by, update_time, update_by, del_flag, review_status from sys_recipes_plan select id, order_id, cus_id, start_date, end_date, start_num_day, end_num_day, recipes_id, send_flag, send_time, create_time, create_by, update_time, update_by, del_flag, review_status from sys_recipes_plan
</sql> </sql>
<select id="selectSysRecipesPlanList" parameterType="SysRecipesPlan" resultMap="SysRecipesPlanResult"> <select id="selectSysRecipesPlanList" parameterType="SysRecipesPlan" resultMap="SysRecipesPlanResult">
<include refid="selectSysRecipesPlanVo"/> where del_flag = 0 <include refid="selectSysRecipesPlanVo"/>
<if test="orderId != null "> and order_id = #{orderId}</if> where del_flag = 0
<if test="cusId != null "> and cus_id = #{cusId}</if> <if test="orderId != null ">and order_id = #{orderId}</if>
<if test="startDate != null "> and start_date = #{startDate}</if> <if test="cusId != null ">and cus_id = #{cusId}</if>
<if test="endDate != null "> and end_date = #{endDate}</if> <if test="startDate != null ">and start_date = #{startDate}</if>
<if test="startNumDay != null "> and start_num_day = #{startNumDay}</if> <if test="endDate != null ">and end_date = #{endDate}</if>
<if test="endNumDay != null "> and end_num_day = #{endNumDay}</if> <if test="startNumDay != null ">and start_num_day = #{startNumDay}</if>
<if test="recipesId != null "> and recipes_id = #{recipesId}</if> <if test="endNumDay != null ">and end_num_day = #{endNumDay}</if>
<if test="sendFlag != null "> and send_flag = #{sendFlag}</if> <if test="recipesId != null ">and recipes_id = #{recipesId}</if>
<if test="sendTime != null "> and send_time = #{sendTime}</if> <if test="sendFlag != null ">and send_flag = #{sendFlag}</if>
<if test="reviewStatus != null "> and review_status = #{reviewStatus}</if> <if test="sendTime != null ">and send_time = #{sendTime}</if>
<if test="reviewStatus != null ">and review_status = #{reviewStatus}</if>
</select> </select>
<select id="selectSysRecipesPlanById" parameterType="Long" resultMap="SysRecipesPlanResult"> <select id="selectSysRecipesPlanById" parameterType="Long" resultMap="SysRecipesPlanResult">
@ -134,9 +135,10 @@
INSERT INTO sys_recipes_plan INSERT INTO sys_recipes_plan
(order_id, cus_id, start_date, end_date, start_num_day, end_num_day, send_flag, send_time, recipes_id) (order_id, cus_id, start_date, end_date, start_num_day, end_num_day, send_flag, send_time, recipes_id)
VALUES VALUES
<foreach collection ="list" item="plan" separator =","> <foreach collection="list" item="plan" separator=",">
(#{plan.orderId}, #{plan.cusId}, #{plan.startDate}, #{plan.endDate}, #{plan.startNumDay}, #{plan.endNumDay}, #{plan.sendFlag}, #{plan.sendTime}, #{plan.recipesId}) (#{plan.orderId}, #{plan.cusId}, #{plan.startDate}, #{plan.endDate}, #{plan.startNumDay}, #{plan.endNumDay},
</foreach > #{plan.sendFlag}, #{plan.sendTime}, #{plan.recipesId})
</foreach>
</insert> </insert>
<!-- 根据订单ID删除对应食谱计划 --> <!-- 根据订单ID删除对应食谱计划 -->
@ -151,19 +153,26 @@
<select id="selectPlanListByCondition" parameterType="SysRecipesPlan" resultMap="SysRecipesPlanResult"> <select id="selectPlanListByCondition" parameterType="SysRecipesPlan" resultMap="SysRecipesPlanResult">
SELECT srp.id,srp.order_id,srp.recipes_id,srp.start_num_day,srp.end_num_day,srp.cus_id,sc.phone, SELECT srp.id,srp.order_id,srp.recipes_id,srp.start_num_day,srp.end_num_day,srp.cus_id,sc.phone,
su_nutritionist.nick_name nutritionist,su_nutritionist_assis.nick_name AS nutritionist_assis, su_nutritionist.nick_name nutritionist,su_nutritionist_assis.nick_name AS nutritionist_assis,
srp.start_date,srp.end_date,srp.send_flag,srp.send_time, sc.name as customer srp.start_date,srp.end_date,srp.send_flag,srp.send_time, sc.name as customer, srp.review_status
FROM sys_recipes_plan srp FROM sys_recipes_plan srp
LEFT JOIN sys_order sr ON sr.order_id = srp.order_id LEFT JOIN sys_order sr ON sr.order_id = srp.order_id
LEFT JOIN sys_customer sc ON sc.id = srp.cus_id LEFT JOIN sys_customer sc ON sc.id = srp.cus_id
LEFT JOIN sys_user su_nutritionist ON su_nutritionist.user_id = sr.nutritionist_id AND su_nutritionist.del_flag = 0 LEFT JOIN sys_user su_nutritionist ON su_nutritionist.user_id = sr.nutritionist_id AND su_nutritionist.del_flag
LEFT JOIN sys_user su_nutritionist_assis ON su_nutritionist_assis.user_id = sr.nutri_assis_id AND su_nutritionist_assis.del_flag = 0 = 0
LEFT JOIN sys_user su_nutritionist_assis ON su_nutritionist_assis.user_id = sr.nutri_assis_id AND
su_nutritionist_assis.del_flag = 0
WHERE srp.del_flag = 0 and sr.del_flag = 0 WHERE srp.del_flag = 0 and sr.del_flag = 0
<if test="orderId != null">AND srp.order_id = #{orderId}</if> <if test="orderId != null">AND srp.order_id = #{orderId}</if>
<if test="sendFlag != null">AND srp.send_flag = #{sendFlag}</if> <if test="sendFlag != null">AND srp.send_flag = #{sendFlag}</if>
<if test="customer != null and customer != ''">AND (sc.name like concat('%',#{customer},'%') OR sc.phone like concat('%',#{customer},'%'))</if> <if test="customer != null and customer != ''">AND (sc.name like concat('%',#{customer},'%') OR sc.phone like
concat('%',#{customer},'%'))
</if>
<if test="nutritionistId != null">AND su_nutritionist.user_id = #{nutritionistId}</if> <if test="nutritionistId != null">AND su_nutritionist.user_id = #{nutritionistId}</if>
<if test="nutritionistAssisId != null">AND su_nutritionist_assis.user_id = #{nutritionistAssisId}</if> <if test="nutritionistAssisId != null">AND su_nutritionist_assis.user_id = #{nutritionistAssisId}</if>
<if test="startDate != null and endDate != null ">AND srp.start_date BETWEEN date_format(#{startDate},'%y%m%d') AND date_format(#{endDate},'%y%m%d') </if> <if test="reviewStatus != null">AND srp.review_status = #{reviewStatus}</if>
<if test="startDate != null and endDate != null ">AND srp.start_date BETWEEN date_format(#{startDate},'%y%m%d')
AND date_format(#{endDate},'%y%m%d')
</if>
ORDER BY srp.order_id DESC,srp.id ASC ORDER BY srp.order_id DESC,srp.id ASC
</select> </select>
<!-- 食谱计划、订单表联查 --> <!-- 食谱计划、订单表联查 -->
@ -194,9 +203,9 @@
ORDER BY srp.id ASC ORDER BY srp.id ASC
</select> </select>
<!-- 根据outId查询食谱计划--> <!-- 根据cusId查询食谱计划-->
<select id="selectPlanListByOutId" parameterType="String" resultMap="SysRecipesPlanResult"> <select id="selectPlanListByCusId" parameterType="Long" resultMap="SysRecipesPlanResult">
select cus_id, recipes_id, start_num_day, end_num_day from sys_recipes_plan where out_id=#{outId} order by create_time desc select id, out_id, start_date, end_date, start_num_day, end_num_day, recipes_id, review_status from sys_recipes_plan where cus_id=#{cusId} order by create_time desc
</select> </select>
<select id="getCusIdByOutId" parameterType="String" resultType="Long"> <select id="getCusIdByOutId" parameterType="String" resultType="Long">
@ -204,14 +213,15 @@
</select> </select>
<resultMap id="SysRecipesPlanListInfoResult" type="SysRecipesPlanListInfo"> <resultMap id="SysRecipesPlanListInfoResult" type="SysRecipesPlanListInfo">
<result property="id" column="id" /> <result property="id" column="id"/>
<result property="startDate" column="start_date" /> <result property="startDate" column="start_date"/>
<result property="endDate" column="end_date" /> <result property="endDate" column="end_date"/>
<result property="startNumDay" column="start_num_day" /> <result property="startNumDay" column="start_num_day"/>
<result property="endNumDay" column="end_num_day" /> <result property="endNumDay" column="end_num_day"/>
<association property="menus" column="recipes_id" select="selectMenuIds"/> <association property="menus" column="recipes_id" select="selectMenuIds"/>
</resultMap> </resultMap>
<!-- 通过outId查询食谱计划简要-->
<select id="selectRecipesPlanListInfo" resultMap="SysRecipesPlanListInfoResult"> <select id="selectRecipesPlanListInfo" resultMap="SysRecipesPlanListInfoResult">
select id, start_date, end_date, start_num_day, end_num_day, recipes_id from sys_recipes_plan where out_id=#{outId} select id, start_date, end_date, start_num_day, end_num_day, recipes_id from sys_recipes_plan where out_id=#{outId}
</select> </select>

View File

@ -1,36 +1,43 @@
import request from '@/utils/request' import request from "@/utils/request";
// 查询食谱计划列表 // 查询食谱计划列表
export function listRecipesPlan(query) { export function listRecipesPlan(query) {
return request({ return request({
url: '/recipes/recipesPlan/list', url: "/recipes/recipesPlan/list",
method: 'get', method: "get",
params: query params: query
}) });
} }
// 查询食谱计划详细 // 查询食谱计划详细
export function getRecipesPlan(id) { export function getRecipesPlan(id) {
return request({ return request({
url: '/recipes/recipesPlan/' + id, url: "/recipes/recipesPlan/" + id,
method: 'get' method: "get"
}) });
} }
// 修改食谱计划 // 修改食谱计划
export function updateRecipesPlan(data) { export function updateRecipesPlan(data) {
return request({ return request({
url: '/recipes/recipesPlan', url: "/recipes/recipesPlan",
method: 'put', method: "put",
data: data data: data
}) });
} }
// 导出食谱计划 // 导出食谱计划
export function exportRecipesPlan(query) { export function exportRecipesPlan(query) {
return request({ return request({
url: '/recipes/recipesPlan/export', url: "/recipes/recipesPlan/export",
method: 'get', method: "get",
params: query params: query
}) });
}
export function listRecipesPlanByCusId(id) {
return request({
url: "/recipes/recipesPlan/list/" + id,
method: "get"
});
} }

View File

@ -6,19 +6,60 @@
@closed="handleOnClosed" @closed="handleOnClosed"
size="40%" size="40%"
> >
<div class="app-container"> <div class="app-container recipes_plan_drawer_wrapper">
<el-row :gutter="10" class="mb8"> <el-row :gutter="10" class="mb8">
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
v-if="cusOutId"
type="primary" type="primary"
icon="el-icon-plus" icon="el-icon-share"
size="mini" size="mini"
@click="handleInnerOpen" class="copyBtn"
:data-clipboard-text="copyValue"
@click="handleOnRecipesLinkClick"
>客户食谱链接
</el-button>
<el-button icon="el-icon-view" size="mini" @click="handleInnerOpen"
>查看暂停记录 >查看暂停记录
</el-button> </el-button>
</el-col> </el-col>
</el-row> </el-row>
<el-table :data="planList" v-loading="planLoading" height="90%">
<el-table-column label="审核状态" align="center" width="80">
<template slot-scope="scope">
<el-tag :type="scope.row.reviewStatus ? 'success' : 'danger'">{{
`${scope.row.reviewStatus ? "已审核" : "未审核"}`
}}</el-tag>
</template>
</el-table-column>
<el-table-column label="计划" align="center">
<template slot-scope="scope">
{{ `${scope.row.startNumDay}${scope.row.endNumDay}` }}
</template>
</el-table-column>
<el-table-column label="日期" align="center">
<template slot-scope="scope">
{{ `${scope.row.startDate}${scope.row.endDate}` }}
</template>
</el-table-column>
<el-table-column label="操作" align="center" width="120">
<template slot-scope="scope">
<el-button
type="text"
:icon="
scope.row.recipesId ? 'el-icon-edit' : 'el-icon-edit-outline'
"
@click="handleOnRecipesEditClick(scope.row)"
>
{{ `${scope.row.recipesId ? "编辑" : "制作"}` }}
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 暂停记录抽屉 -->
<el-drawer <el-drawer
:title="innerTitle" :title="innerTitle"
:append-to-body="true" :append-to-body="true"
@ -34,7 +75,7 @@
icon="el-icon-plus" icon="el-icon-plus"
size="mini" size="mini"
@click="handleInnerOpen" @click="handleInnerOpen"
>查看暂停记录 >增加暂停记录
</el-button> </el-button>
</el-col> </el-col>
</el-row> </el-row>
@ -44,6 +85,8 @@
</el-drawer> </el-drawer>
</template> </template>
<script> <script>
import Clipboard from "clipboard";
import { listRecipesPlanByCusId } from "@/api/custom/recipesPlan";
export default { export default {
name: "RecipesPlanDrawer", name: "RecipesPlanDrawer",
data() { data() {
@ -52,25 +95,59 @@ export default {
innerVisible: false, innerVisible: false,
title: "", title: "",
innerTitle: "", innerTitle: "",
cusOutId: "",
copyValue: "",
planLoading: false,
planList: [],
}; };
}, },
methods: { methods: {
showDrawer(data) { showDrawer(data) {
// console.log(data);
this.data = data; this.data = data;
if (!this.data) { if (!this.data) {
return; return;
} }
this.visible = true; this.visible = true;
this.title = `${this.data.name}」食谱计划`; this.title = `${this.data.name}」食谱计划`;
this.planLoading = true;
listRecipesPlanByCusId(data.id).then((response) => {
this.planList = response.data;
this.cusOutId = response.data.reduce((str, cur) => {
if (!str && cur.recipesId) {
str = cur.outId;
}
return str;
}, "");
console.log(this.planList);
this.planLoading = false;
});
}, },
handleOnClosed() { handleOnClosed() {
this.data = undefined; this.data = undefined;
this.cusOutId = "";
}, },
handleInnerOpen() { handleInnerOpen() {
this.innerVisible = true; this.innerVisible = true;
this.innerTitle = `${this.data.name}」暂停记录`; this.innerTitle = `${this.data.name}」暂停记录`;
}, },
handleOnRecipesLinkClick() {
this.copyValue =
window.location.origin.replace("manage", "sign") +
"/recipes/detail/" +
this.cusOutId;
new Clipboard(".copyBtn");
this.$message({
message: "拷贝成功",
type: "success",
});
},
handleOnInnerClosed() {}, handleOnInnerClosed() {},
handleOnRecipesEditClick(data) {
// console.log(data);
const { id, name } = this.data;
window.open("/recipes/build/" + name + "/" + id, "_blank");
},
}, },
}; };
</script> </script>
@ -78,4 +155,8 @@ export default {
/deep/ :focus { /deep/ :focus {
outline: 0; outline: 0;
} }
.recipes_plan_drawer_wrapper {
height: calc(100vh - 77px);
}
</style> </style>

View File

@ -140,9 +140,10 @@ export const constantRoutes = [
] ]
}, },
{ {
path: "/recipes/build", path: "/recipes/build/:name/:planId",
component: resolve => require(["@/views/custom/recipesBuild"], resolve), component: resolve => require(["@/views/custom/recipesBuild"], resolve),
name: "RecipiesBuild", name: "RecipiesBuild",
props: true,
meta: { title: "食谱制作" }, meta: { title: "食谱制作" },
hidden: true hidden: true
}, },

View File

@ -7,6 +7,7 @@ import {
deleteDishesApi, deleteDishesApi,
addRecipesApi addRecipesApi
} from "@/api/custom/recipes"; } from "@/api/custom/recipes";
import { getRecipesPlan, updateRecipesPlan } from "@/api/custom/recipesPlan";
import { getDicts } from "@/api/system/dict/data"; import { getDicts } from "@/api/system/dict/data";
const oriState = { const oriState = {
@ -23,7 +24,8 @@ const oriState = {
typeOptions: [], typeOptions: [],
currentDay: -1, currentDay: -1,
startNum: 0, startNum: 0,
endNum: 0 endNum: 0,
reviewStatus: 0
}; };
const mutations = { const mutations = {
@ -72,11 +74,24 @@ const mutations = {
const actions = { const actions = {
async init({ commit, dispatch }, payload) { async init({ commit, dispatch }, payload) {
return new Promise((res, rej) => {
// console.log(payload); // console.log(payload);
// const planResponse = await getRecipesPlan(payload.planId);
commit("updateStateData", payload); const {
// startNumDay,
endNumDay,
recipesId,
cusId,
reviewStatus
} = planResponse.data;
commit("updateStateData", {
cusId,
recipesId,
reviewStatus,
planId: payload.planId,
startNum: startNumDay,
endNum: endNumDay
});
getDicts("cus_cus_unit").then(response => { getDicts("cus_cus_unit").then(response => {
commit("updateStateData", { cusUnitOptions: response.data }); commit("updateStateData", { cusUnitOptions: response.data });
}); });
@ -87,17 +102,27 @@ const actions = {
commit("updateStateData", { typeOptions: response.data }); commit("updateStateData", { typeOptions: response.data });
}); });
return new Promise((res, rej) => {
// 健康数据 // 健康数据
if (payload.cusId) { if (cusId) {
dispatch("getHealthyData", payload).catch(err => rej(err)); dispatch("getHealthyData", { cusId }).catch(err => rej(err));
} }
// 食谱数据 // 食谱数据
if (payload.recipesId) { if (recipesId) {
dispatch("getRecipesInfo", payload).catch(err => rej(err)); dispatch("getRecipesInfo", { recipesId }).catch(err => rej(err));
} }
}); });
}, },
async updateReviewStatus({ commit, state }, payload) {
const response = await updateRecipesPlan({
id: state.planId,
reviewStatus: payload.reviewStatus
});
if (response.code === 200) {
commit("updateStateData", payload);
}
},
async getHealthyData({ commit }, payload) { async getHealthyData({ commit }, payload) {
commit("updateStateData", { healthDataLoading: true }); commit("updateStateData", { healthDataLoading: true });
const healthyDataResult = await getCustomerPhysicalSignsByCusId( const healthyDataResult = await getCustomerPhysicalSignsByCusId(
@ -127,16 +152,14 @@ const actions = {
const recipesDataResult = await getRecipesApi(payload.recipesId); const recipesDataResult = await getRecipesApi(payload.recipesId);
let recipesData = []; let recipesData = [];
if (recipesDataResult.code === 200) { if (recipesDataResult.code === 200) {
const { endNum, startNum } = state; const { endNum, startNum, recipesId } = state;
let length = null; // 计算
if (endNum && startNum) { let length = endNum - startNum;
length = endNum - startNum;
}
recipesData = recipesDataResult.data.reduce((outArr, dayData, idx) => { recipesData = recipesDataResult.data.reduce((outArr, dayData, idx) => {
if (!length || (length && length >= idx)) { if (!recipesId || length >= idx) {
outArr.push({ outArr.push({
id: dayData.id, id: dayData.id,
numDay: startNum ? startNum + idx : dayData.numDay, numDay: !recipesId ? startNum + idx : dayData.numDay,
dishes: dayData.dishes.reduce((arr, cur) => { dishes: dayData.dishes.reduce((arr, cur) => {
if ( if (
cur.dishesId > -1 && cur.dishesId > -1 &&

View File

@ -29,7 +29,6 @@ service.interceptors.request.use(config => {
service.interceptors.response.use(res => { service.interceptors.response.use(res => {
// 未设置状态码则默认成功状态 // 未设置状态码则默认成功状态
const code = res.data.code || 200; const code = res.data.code || 200;
console.log(res)
// 获取错误信息 // 获取错误信息
const msg = errorCode[code] || res.data.msg || errorCode['default'] const msg = errorCode[code] || res.data.msg || errorCode['default']
if (code === 401) { if (code === 401) {

View File

@ -4,6 +4,31 @@
:style="`height: ${collapse ? 30 : 200}px`" :style="`height: ${collapse ? 30 : 200}px`"
> >
<div class="header"> <div class="header">
<el-popover
placement="bottom"
trigger="click"
title="修改审核状态"
style="margin-right: 12px"
v-hasPermi="['recipes:recipesPlan:review']"
>
<div>
<el-button size="mini" type="success" @click="hanldeOnReveiwChange(2)"
>审核通过</el-button
>
<el-button size="mini" type="danger" @click="hanldeOnReveiwChange(1)"
>未审核通过</el-button
>
</div>
<el-button
slot="reference"
size="mini"
v-if="reviewStatus"
@click="handleReview"
:type="reviewStatus === 1 ? 'danger' : 'success'"
>
{{ reviewStatus === 1 ? "未审核" : "已审核" }}
</el-button>
</el-popover>
<el-button <el-button
v-if="!recipesId" v-if="!recipesId"
size="mini" size="mini"
@ -11,9 +36,15 @@
@click="handleOnSave" @click="handleOnSave"
>生成食谱</el-button >生成食谱</el-button
> >
<el-button size="mini" type="text" @click="handleCollapseClick">{{ <el-button size="mini" type="text" @click="handleCollapseClick">
`${collapse ? "展开分析" : "收起分析"}` {{ `${collapse ? "展开" : "收起"}` }}
}}</el-button> <em
class="el-icon-arrow-down arrow_icon"
:style="
collapse ? 'transform: rotate(-180deg);' : 'transform: unset;'
"
/>
</el-button>
</div> </div>
<div <div
class="content" class="content"
@ -53,7 +84,7 @@ export default {
}, },
props: ["collapse", "data"], props: ["collapse", "data"],
computed: { computed: {
...mapState(["recipesId"]), ...mapState(["recipesId", "reviewStatus"]),
}, },
methods: { methods: {
handleCollapseClick() { handleCollapseClick() {
@ -67,7 +98,10 @@ export default {
}, },
}); });
}, },
...mapActions(["saveRecipes"]), hanldeOnReveiwChange(reviewStatus) {
this.updateReviewStatus({ reviewStatus });
},
...mapActions(["saveRecipes", "updateReviewStatus"]),
}, },
}; };
</script> </script>
@ -79,6 +113,11 @@ export default {
.header { .header {
text-align: right; text-align: right;
height: 30px; height: 30px;
.arrow_icon {
transition: all 0.3s;
transform-origin: center center;
}
} }
.content { .content {

View File

@ -1,5 +1,5 @@
<template> <template>
<div class="recipes_build_wrapper" v-title :data-title="$route.query.name"> <div class="recipes_build_wrapper" v-title :data-title="name">
<div class="left" v-loading="recipesDataLoading"> <div class="left" v-loading="recipesDataLoading">
<RecipesView <RecipesView
v-if="!!recipesData.length" v-if="!!recipesData.length"
@ -35,14 +35,8 @@ export default {
return {}; return {};
}, },
mounted() { mounted() {
const { cusId, planId, startNum, endNum, recipesId } = this.$route.query;
this.init({ this.init({
cusId, planId: this.planId,
planId,
startNum: parseInt(startNum),
endNum: parseInt(endNum),
recipesId,
}).catch((err) => { }).catch((err) => {
this.$message.error(err.message); this.$message.error(err.message);
}); });
@ -57,7 +51,7 @@ export default {
RecipesView, RecipesView,
RecommondView, RecommondView,
}, },
// props: ["cusId", "planId", "recipesId", "startDate", "endDate"], props: ["name", "planId"],
computed: { computed: {
...mapState([ ...mapState([
"healthyData", "healthyData",

View File

@ -14,11 +14,7 @@
size="small" size="small"
/> />
</el-form-item> </el-form-item>
<el-form-item <el-form-item label="日期" prop="planStartDateScope">
label="食谱开始日期范围"
prop="planStartDateScope"
label-width="130px"
>
<el-date-picker <el-date-picker
v-model="planStartDateScope" v-model="planStartDateScope"
type="daterange" type="daterange"
@ -58,6 +54,21 @@
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="审核状态" prop="reviewStatus">
<el-select
v-model="queryParams.reviewStatus"
placeholder="请选审核状态"
clearable
size="small"
>
<el-option
v-for="dict in reviewStatusOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="dict.dictValue"
/>
</el-select>
</el-form-item>
<el-form-item> <el-form-item>
<el-button <el-button
type="cyan" type="cyan"
@ -78,17 +89,6 @@
> >
</div> </div>
<el-row :gutter="10" class="mb8" style="margin-top: 10px"> <el-row :gutter="10" class="mb8" style="margin-top: 10px">
<el-col :span="1.5">
<el-button
type="success"
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['recipes:recipesPlan:edit']"
>修改
</el-button>
</el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
type="warning" type="warning"
@ -99,19 +99,35 @@
>导出 >导出
</el-button> </el-button>
</el-col> </el-col>
<!--<div><span style="margin-left:10px;font-size:16px;color:#E6A23C;font-family:PingFang SC">备注2021年1月开始的订单才会自动生成食谱计划</span></div>-->
<right-toolbar <right-toolbar
:showSearch.sync="showSearch" :showSearch.sync="showSearch"
@queryTable="getList" @queryTable="getList"
></right-toolbar> ></right-toolbar>
</el-row> </el-row>
<el-table <el-table v-loading="loading" :data="recipesPlanList">
v-loading="loading" <el-table-column label="审核状态" align="center" width="100">
:data="recipesPlanList" <template slot-scope="scope">
@selection-change="handleSelectionChange" <el-tag
:type="
!scope.row.reviewStatus
? 'info'
: scope.row.reviewStatus === 1
? 'danger'
: 'success'
"
>{{
`${
!scope.row.reviewStatus
? "未制作"
: scope.row.reviewStatus == 1
? "未审核"
: "已审核"
}`
}}</el-tag
> >
<!-- <el-table-column type="selection" width="55" align="center" /> --> </template>
</el-table-column>
<el-table-column label="客户姓名" align="center" prop="customer" /> <el-table-column label="客户姓名" align="center" prop="customer" />
<el-table-column <el-table-column
label="客户手机号" label="客户手机号"
@ -120,15 +136,15 @@
width="180" width="180"
/> />
<el-table-column <el-table-column
label="食谱日期范围" label="计划"
align="center" align="center"
prop="scopeDate" prop="scopeDay"
width="200" width="200"
/> />
<el-table-column <el-table-column
label="食谱天数范围" label="日期"
align="center" align="center"
prop="scopeDay" prop="scopeDate"
width="200" width="200"
/> />
<el-table-column label="营养师" align="center" prop="nutritionist" /> <el-table-column label="营养师" align="center" prop="nutritionist" />
@ -138,26 +154,6 @@
prop="nutritionistAssis" prop="nutritionistAssis"
width="180" width="180"
/> />
<el-table-column label="是否发送" align="center" prop="sendFlag">
<!--<template slot-scope="scope">
<span>{{ scope.row.sendFlag == 1 ? "已发送" : "未发送"}}</span>
</template>(.sendFlag == 1) ? 'success' : 'warning'-->
<template slot-scope="scope">
<el-tag :type="getTagType(scope.row)" disable-transitions>
{{ scope.row.sendFlag == 1 ? "已发送" : "未发送" }}
</el-tag>
</template>
</el-table-column>
<el-table-column
label="食谱发送时间"
align="center"
prop="sendTime"
width="180"
>
<template slot-scope="scope">
<span>{{ parseTime(scope.row.sendTime, "{y}-{m}-{d}") }}</span>
</template>
</el-table-column>
<el-table-column <el-table-column
label="操作" label="操作"
align="center" align="center"
@ -168,45 +164,12 @@
<el-button <el-button
size="mini" size="mini"
type="text" type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['recipes:recipesPlan:edit']" v-hasPermi="['recipes:recipesPlan:edit']"
>修改
</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-view"
@click="
allRecipesPlanQueryParam.orderId = scope.row.orderId;
getAllPlanByOrderId();
"
>查看完整计划
</el-button>
<!-- <el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="getOrderDetail(scope.row)"
v-hasPermi="['custom:order:query']"
>查看订单
</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="getCustomerSign(scope.row)"
v-hasPermi="['custom:customer:query']"
>查看体征
</el-button> -->
<el-button
size="mini"
type="text"
:icon="`${ :icon="`${
scope.row.recipesId ? 'el-icon-edit' : 'el-icon-edit-outline' scope.row.recipesId ? 'el-icon-edit' : 'el-icon-edit-outline'
}`" }`"
@click="handleBuild(scope.row)" @click="handleBuild(scope.row)"
>{{ `${scope.row.recipesId ? "编辑" : "制作"}食谱` }}</el-button >{{ `${scope.row.recipesId ? "编辑" : "制作"}` }}</el-button
> >
</template> </template>
</el-table-column> </el-table-column>
@ -219,121 +182,11 @@
:limit.sync="queryParams.pageSize" :limit.sync="queryParams.pageSize"
@pagination="getList" @pagination="getList"
/> />
<!-- 添加或修改食谱计划对话框 -->
<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="sendFlag"
label-width="120px"
>
<el-select v-model="form.sendFlag" placeholder="请选择">
<el-option label="否" :value="parseInt('0')" />
<el-option label="是" :value="parseInt('1')" />
</el-select>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
<!-- 查看完整计划 -->
<el-dialog
:title="allRecipesPlanTitle"
:visible.sync="allRecipesPlanOpen"
width="800px"
append-to-body
>
<el-form
:model="allRecipesPlanQueryParam"
ref="allPlanQueryFrom"
:inline="true"
>
<el-form-item label="发送状态" prop="sendFlag">
<el-select
v-model="allRecipesPlanQueryParam.sendFlag"
placeholder="请选择"
>
<el-option label="全部" :value="null" />
<el-option label="未发送" :value="parseInt('0')" />
<el-option label="已发送" :value="parseInt('1')" />
</el-select>
</el-form-item>
<el-form-item>
<el-button
type="cyan"
icon="el-icon-search"
size="mini"
@click="getAllPlanByOrderId()"
>搜索</el-button
>
</el-form-item>
</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="nutritionist" />
<el-table-column label="营养师助理名称" align="center" prop="nutritionistAssis" />-->
<el-table-column
label="食谱时间范围"
align="center"
prop="scopeDate"
width="250"
/>
<el-table-column label="食谱是否发送" align="center" prop="sendFlag">
<!--<template slot-scope="scope">
<span>{{ scope.row.sendFlag == 1 ? "已发送" : "未发送"}}</span>
</template>(.sendFlag == 1) ? 'success' : 'warning'-->
<template slot-scope="scope">
<el-tag :type="getTagType(scope.row)" disable-transitions>
{{ scope.row.sendFlag == 1 ? "已发送" : "未发送" }}
</el-tag>
</template>
</el-table-column>
<el-table-column
label="食谱发送时间"
align="center"
prop="sendTime"
width="180"
>
<template slot-scope="scope">
<span>{{ parseTime(scope.row.sendTime, "{y}-{m}-{d}") }}</span>
</template>
</el-table-column>
</el-table>
<pagination
v-show="allRecipesPlanTotal > 0"
:total="allRecipesPlanTotal"
:page.sync="allRecipesPlanQueryParam.pageNum"
:limit.sync="allRecipesPlanQueryParam.pageSize"
@pagination="getAllPlanByOrderId"
/>
<!--<div slot="footer" class="dialog-footer">
<el-button @click="allRecipesPlanOpen = false"> </el-button>
</div>-->
</el-dialog>
<!-- 查看订单 -->
<!-- <order-dialog ref="orderDialog" /> -->
<!-- 查看体征 -->
<!-- <body_sign_dialog ref="bodySignDialog" /> -->
</div> </div>
</template> </template>
<script> <script>
import { import { exportRecipesPlan, listRecipesPlan } from "@/api/custom/recipesPlan";
exportRecipesPlan,
getRecipesPlan,
listRecipesPlan,
updateRecipesPlan,
} from "@/api/custom/recipesPlan";
import { getOptions } from "@/api/custom/order";
// import OrderDetail from "@/components/OrderDetail";
// import BodySignDetail from "@/components/BodySignDetail";
import dayjs from "dayjs"; import dayjs from "dayjs";
import store from "@/store"; import store from "@/store";
import { mapState } from "vuex"; import { mapState } from "vuex";
@ -359,11 +212,12 @@ export default {
total: 0, total: 0,
// //
recipesPlanList: [], recipesPlanList: [],
//
title: "",
//
open: false,
orderDialog: undefined, orderDialog: undefined,
reviewStatusOptions: [
{ dictValue: 0, dictLabel: "未制作" },
{ dictValue: 1, dictLabel: "未审核" },
{ dictValue: 2, dictLabel: "已审核" },
],
// //
queryParams: { queryParams: {
pageNum: 1, pageNum: 1,
@ -373,6 +227,7 @@ export default {
endDate: null, endDate: null,
nutritionistId: null, nutritionistId: null,
nutritionistAssisId: null, nutritionistAssisId: null,
reviewStatus: null,
}, },
// //
form: {}, form: {},
@ -461,33 +316,8 @@ export default {
this.loading = false; this.loading = false;
}); });
}, },
/** 查询客户体征 */
getCustomerSign(row) {
this.$refs.bodySignDialog.showDialog(row.phone);
},
getAllPlanByOrderId() {
if (this.allRecipesPlanQueryParam.sendFlag === "") {
this.allRecipesPlanQueryParam.sendFlag = null;
}
listRecipesPlan(this.allRecipesPlanQueryParam).then((response) => {
this.allRecipesPlanList = response.rows;
this.allRecipesPlanList.forEach(function (item, index) {
item.scopeDate =
dayjs(item.startDate).format("YYYY-MM-DD") +
" 到 " +
dayjs(item.endDate).format("YYYY-MM-DD");
});
this.allRecipesPlanOpen = true;
this.allRecipesPlanTitle = `${this.allRecipesPlanList[0].customer}」食谱计划表`;
this.allRecipesPlanTotal = response.total;
});
},
getOrderDetail(row) {
this.$refs.orderDialog.showDialog(row.orderId);
},
// //
cancel() { cancel() {
this.open = false;
this.reset(); this.reset();
}, },
// //
@ -519,39 +349,6 @@ export default {
this.planStartDateScope = [nextDate, nextDate]; this.planStartDateScope = [nextDate, nextDate];
this.handleQuery(); this.handleQuery();
}, },
//
handleSelectionChange(selection) {
this.ids = selection.map((item) => item.id);
this.single = selection.length !== 1;
this.multiple = !selection.length;
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids;
getRecipesPlan(id).then((response) => {
this.form.id = response.data.id;
this.form.sendFlag = response.data.sendFlag;
this.open = true;
this.title = "修改食谱计划";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate((valid) => {
if (valid) {
if (this.form.id != null) {
updateRecipesPlan(this.form).then((response) => {
if (response.code === 200) {
this.msgSuccess("修改成功");
this.open = false;
this.getList();
}
});
}
}
});
},
/** 导出按钮操作 */ /** 导出按钮操作 */
handleExport() { handleExport() {
const queryParams = this.queryParams; const queryParams = this.queryParams;
@ -568,67 +365,10 @@ export default {
}) })
.catch(function () {}); .catch(function () {});
}, },
getTagType(row) {
if (row.sendFlag == 1) {
return "success";
}
return "danger";
/* if(dayjs(row.startDate+"").diff(dayjs(),'day') <= 1){
return "danger";
}
return '';*/
},
//
columnStyle({ row, column, rowIndex, columnIndex }) {
if (
columnIndex == 0 ||
columnIndex == 2 ||
columnIndex == 4 ||
columnIndex == 6
) {
//23
return "background:#f3f6fc;font-weight:bold";
} else {
return "background:#ffffff;";
}
},
//
objectSpanMethod({ row, column, rowIndex, columnIndex }) {
if (columnIndex === 0) {
if (rowIndex % 4 === 0) {
return {
rowspan: 4,
colspan: 1,
};
} else {
return {
rowspan: 0,
colspan: 0,
};
}
}
},
handleBuild(data) { handleBuild(data) {
// console.log(data); // console.log(data);
const { id, cusId, recipesId, customer, startNumDay, endNumDay } = data; const { id, customer } = data;
window.open("/recipes/build/" + customer + "/" + id, "_blank");
const queryParam = {
planId: id,
cusId,
name: customer,
};
if (recipesId) {
queryParam.recipesId = recipesId;
} else {
queryParam.startNum = startNumDay;
queryParam.endNum = endNumDay;
}
const routeUrl = this.$router.resolve({
path: "/recipes/build",
query: queryParam,
});
window.open(routeUrl.href, "_blank");
// this.$router.push({ path: "/recipes/build", query: queryParam });
}, },
}, },
}; };