This commit is contained in:
xiezhijun 2021-03-25 17:27:01 +08:00
commit 4fece27960
18 changed files with 226 additions and 173 deletions

View File

@ -116,8 +116,8 @@ public class SysDishesController extends BaseController {
*/ */
@PreAuthorize("@ss.hasPermi('custom:dishes:remove')") @PreAuthorize("@ss.hasPermi('custom:dishes:remove')")
@Log(title = "菜品", businessType = BusinessType.DELETE) @Log(title = "菜品", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}") @DeleteMapping("/{id}")
public AjaxResult remove(@PathVariable Long[] ids) { public AjaxResult remove(@PathVariable Long id) {
return toAjax(sysDishesService.deleteSysDishesByIds(ids)); return toAjax(sysDishesService.deleteSysDishesById(id));
} }
} }

View File

@ -98,9 +98,9 @@ public class SysIngredientController extends BaseController
*/ */
@PreAuthorize("@ss.hasPermi('custom:ingredient:remove')") @PreAuthorize("@ss.hasPermi('custom:ingredient:remove')")
@Log(title = "食材", businessType = BusinessType.DELETE) @Log(title = "食材", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}") @DeleteMapping("/{id}")
public AjaxResult remove(@PathVariable Long[] ids) public AjaxResult remove(@PathVariable Long id)
{ {
return toAjax(sysIngredientService.deleteSysIngredientByIds(ids)); return toAjax(sysIngredientService.deleteSysIngredientById(id));
} }
} }

View File

@ -11,6 +11,10 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@RestController @RestController
@RequestMapping("/wap") @RequestMapping("/wap")
public class SysWapController extends BaseController { public class SysWapController extends BaseController {
@ -69,11 +73,17 @@ public class SysWapController extends BaseController {
/** /**
* 获取完整食谱 * 获取完整食谱
*
* @param id * @param id
* @return * @return
*/ */
@GetMapping(value = "recipes/{id}") @GetMapping(value = "/recipes/{id}")
public AjaxResult recipesDetail(@PathVariable Long id) { public AjaxResult recipesDetail(@PathVariable Long id) {
return AjaxResult.success(iSysRecipesService.selectSysRecipesByRecipesId(id)); return AjaxResult.success(iSysRecipesService.selectSysRecipesByRecipesId(id));
} }
// @GetMapping(value = "/qrcode")
// public void qrcodeRediredt(String group, HttpServletRequest request, HttpServletResponse response) throws IOException {
// response.sendRedirect("https://weibo.com/u/1913360251");
// }
} }

View File

@ -61,7 +61,7 @@ public interface SysIngredientMapper {
* @param ids 需要删除的数据ID * @param ids 需要删除的数据ID
* @return 结果 * @return 结果
*/ */
int deleteSysIngredientByIds(Long[] ids); // int deleteSysIngredientByIds(Long[] ids);
int batchIngredientRec(List<SysIngredientRec> ingredientRecList); int batchIngredientRec(List<SysIngredientRec> ingredientRecList);
@ -71,9 +71,9 @@ public interface SysIngredientMapper {
int deleteIngredientNotRecByIngredientId(Long notRecId); int deleteIngredientNotRecByIngredientId(Long notRecId);
int deleteIngredientRecByIngredientIds(Long[] id); // int deleteIngredientRecByIngredientIds(Long[] id);
int deleteIngredientNotRecByIngredientIds(Long[] id); // int deleteIngredientNotRecByIngredientIds(Long[] id);
/** /**
* 根据食材名称查询食材信息 * 根据食材名称查询食材信息

View File

@ -53,7 +53,7 @@ public interface ISysDishesService
* @param ids 需要删除的菜品ID * @param ids 需要删除的菜品ID
* @return 结果 * @return 结果
*/ */
public int deleteSysDishesByIds(Long[] ids); // public int deleteSysDishesByIds(Long[] ids);
/** /**
* 删除菜品信息 * 删除菜品信息

View File

@ -49,7 +49,7 @@ public interface ISysIngredientService
* @param ids 需要删除的食材ID * @param ids 需要删除的食材ID
* @return 结果 * @return 结果
*/ */
public int deleteSysIngredientByIds(Long[] ids); // public int deleteSysIngredientByIds(Long[] ids);
/** /**
* 删除食材信息 * 删除食材信息

View File

@ -107,11 +107,11 @@ public class SysDishesServiceImpl implements ISysDishesService {
* @param ids 需要删除的菜品ID * @param ids 需要删除的菜品ID
* @return 结果 * @return 结果
*/ */
@Override // @Override
public int deleteSysDishesByIds(Long[] ids) { // public int deleteSysDishesByIds(Long[] ids) {
sysDishesMapper.deleteIngredientByIds(ids); // sysDishesMapper.deleteIngredientByIds(ids);
return sysDishesMapper.deleteSysDishesByIds(ids); // return sysDishesMapper.deleteSysDishesByIds(ids);
} // }
/** /**
* 删除菜品信息 * 删除菜品信息
@ -121,7 +121,7 @@ public class SysDishesServiceImpl implements ISysDishesService {
*/ */
@Override @Override
public int deleteSysDishesById(Long id) { public int deleteSysDishesById(Long id) {
sysDishesMapper.deleteIngredientById(id); // sysDishesMapper.deleteIngredientById(id);
return sysDishesMapper.deleteSysDishesById(id); return sysDishesMapper.deleteSysDishesById(id);
} }

View File

@ -169,18 +169,18 @@ public class SysIngredientServiceImpl implements ISysIngredientService {
return sysIngredientMapper.updateSysIngredient(sysIngredient); return sysIngredientMapper.updateSysIngredient(sysIngredient);
} }
/** // /**
* 批量删除食材 // * 批量删除食材
* // *
* @param ids 需要删除的食材ID // * @param ids 需要删除的食材ID
* @return 结果 // * @return 结果
*/ // */
@Override // @Override
public int deleteSysIngredientByIds(Long[] ids) { // public int deleteSysIngredientByIds(Long[] ids) {
sysIngredientMapper.deleteIngredientRecByIngredientIds(ids); // sysIngredientMapper.deleteIngredientRecByIngredientIds(ids);
sysIngredientMapper.deleteIngredientNotRecByIngredientIds(ids); // sysIngredientMapper.deleteIngredientNotRecByIngredientIds(ids);
return sysIngredientMapper.deleteSysIngredientByIds(ids); // return sysIngredientMapper.deleteSysIngredientByIds(ids);
} // }
/** /**
* 删除食材信息 * 删除食材信息
@ -190,8 +190,8 @@ public class SysIngredientServiceImpl implements ISysIngredientService {
*/ */
@Override @Override
public int deleteSysIngredientById(Long id) { public int deleteSysIngredientById(Long id) {
sysIngredientMapper.deleteIngredientRecByIngredientId(id); // sysIngredientMapper.deleteIngredientRecByIngredientId(id);
sysIngredientMapper.deleteIngredientNotRecByIngredientId(id); // sysIngredientMapper.deleteIngredientNotRecByIngredientId(id);
return sysIngredientMapper.deleteSysIngredientById(id); return sysIngredientMapper.deleteSysIngredientById(id);
} }

View File

@ -5,37 +5,37 @@
<mapper namespace="com.stdiet.custom.mapper.SysDishesMapper"> <mapper namespace="com.stdiet.custom.mapper.SysDishesMapper">
<resultMap type="SysDishes" id="SysDishesResult"> <resultMap type="SysDishes" id="SysDishesResult">
<result property="id" column="id" /> <result property="id" column="id"/>
<result property="name" column="name" /> <result property="name" column="name"/>
<result property="bigClass" column="big_class" /> <result property="bigClass" column="big_class"/>
<result property="smallClass" column="small_class" /> <result property="smallClass" column="small_class"/>
<result property="type" column="type" /> <result property="type" column="type"/>
<result property="isMain" column="is_main" /> <result property="isMain" column="is_main"/>
<result property="methods" column="methods" /> <result property="methods" column="methods"/>
<result property="reviewStatus" column="review_status" /> <result property="reviewStatus" column="review_status"/>
<result property="createBy" column="create_by" /> <result property="createBy" column="create_by"/>
<result property="createTime" column="create_time" /> <result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by" /> <result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time" /> <result property="updateTime" column="update_time"/>
<!-- 非持久化字段 --> <!-- 非持久化字段 -->
<result property="bigClassName" column="bigClassName" /> <result property="bigClassName" column="bigClassName"/>
<result property="smallClassName" column="smallClassName" /> <result property="smallClassName" column="smallClassName"/>
</resultMap> </resultMap>
<resultMap type="SysDishesIngredient" id="SysDishesIngredientResult"> <resultMap type="SysDishesIngredient" id="SysDishesIngredientResult">
<result property="id" column="id" /> <result property="id" column="id"/>
<result property="name" column="name" /> <result property="name" column="name"/>
<result property="type" column="type" /> <result property="type" column="type"/>
<result property="proteinRatio" column="protein_ratio" /> <result property="proteinRatio" column="protein_ratio"/>
<result property="fatRatio" column="fat_ratio" /> <result property="fatRatio" column="fat_ratio"/>
<result property="carbonRatio" column="carbon_ratio" /> <result property="carbonRatio" column="carbon_ratio"/>
<result property="area" column="area" /> <result property="area" column="area"/>
<result property="rec" column="rec" /> <result property="rec" column="rec"/>
<result property="notRec" column="not_rec" /> <result property="notRec" column="not_rec"/>
<result property="cusWeight" column="cus_weight" /> <result property="cusWeight" column="cus_weight"/>
<result property="cusUnit" column="cus_unit" /> <result property="cusUnit" column="cus_unit"/>
<result property="weight" column="weight" /> <result property="weight" column="weight"/>
</resultMap> </resultMap>
<sql id="selectSysDishesVo"> <sql id="selectSysDishesVo">
@ -45,12 +45,13 @@
<select id="selectSysDishesList" parameterType="SysDishes" resultMap="SysDishesResult"> <select id="selectSysDishesList" parameterType="SysDishes" resultMap="SysDishesResult">
<include refid="selectSysDishesVo"/> <include refid="selectSysDishesVo"/>
<where> <where>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if> <if test="name != null and name != ''">and name like concat('%', #{name}, '%')</if>
<if test="type != null and type != ''"> and FIND_IN_SET(#{type}, type)</if> <if test="type != null and type != ''">and FIND_IN_SET(#{type}, type)</if>
<if test="bigClass != null"> and big_class = #{bigClass}</if> <if test="bigClass != null">and big_class = #{bigClass}</if>
<if test="smallClass != null"> and small_class = #{smallClass}</if> <if test="smallClass != null">and small_class = #{smallClass}</if>
<if test="reviewStatus != null and type != ''"> and review_status = #{reviewStatus}</if> <if test="reviewStatus != null and type != ''">and review_status = #{reviewStatus}</if>
<if test="isMain != null and type != ''"> and is_main = #{isMain}</if> <if test="isMain != null and type != ''">and is_main = #{isMain}</if>
<if test="true">and del_flag=0</if>
</where> </where>
order by id desc order by id desc
</select> </select>
@ -82,7 +83,7 @@
</sql> </sql>
<select id="selectSysIngreditentsById" parameterType="Long" resultMap="SysDishesIngredientResult"> <select id="selectSysIngreditentsById" parameterType="Long" resultMap="SysDishesIngredientResult">
<include refid="selectSysIngreditentsByIdVo" > <include refid="selectSysIngreditentsByIdVo">
<property name="id" value="#{id}"/> <property name="id" value="#{id}"/>
</include> </include>
</select> </select>
@ -140,16 +141,16 @@
where id = #{id} where id = #{id}
</update> </update>
<delete id="deleteSysDishesById" parameterType="Long"> <update id="deleteSysDishesById" parameterType="Long">
delete from sys_dishes where id = #{id} update sys_dishes set del_flag=1 where id = #{id}
</delete> </update>
<delete id="deleteSysDishesByIds" parameterType="String"> <!-- <delete id="deleteSysDishesByIds" parameterType="String">-->
delete from sys_dishes where id in <!-- delete from sys_dishes where id in-->
<foreach item="id" collection="array" open="(" separator="," close=")"> <!-- <foreach item="id" collection="array" open="(" separator="," close=")">-->
#{id} <!-- #{id}-->
</foreach> <!-- </foreach>-->
</delete> <!-- </delete>-->
<delete id="deleteIngredientById" parameterType="Long"> <delete id="deleteIngredientById" parameterType="Long">
delete from sys_dishes_ingredient where dishes_id = #{id} delete from sys_dishes_ingredient where dishes_id = #{id}
@ -163,7 +164,8 @@
</delete> </delete>
<insert id="bashInsertDishesIngredent"> <insert id="bashInsertDishesIngredent">
insert into sys_dishes_ingredient(dishes_id, ingredient_id, ingredient_weight, cus_unit, cus_weight, remark) values insert into sys_dishes_ingredient(dishes_id, ingredient_id, ingredient_weight, cus_unit, cus_weight, remark)
values
<foreach collection="list" separator="," item="item" index="index"> <foreach collection="list" separator="," item="item" index="index">
(#{item.dishesId}, #{item.ingredientId}, #{item.weight}, #{item.cusUnit}, #{item.cusWeight}, #{item.remark}) (#{item.dishesId}, #{item.ingredientId}, #{item.weight}, #{item.cusUnit}, #{item.cusWeight}, #{item.remark})
</foreach> </foreach>

View File

@ -103,6 +103,7 @@
<if test="type != null and type != ''">and type = #{type}</if> <if test="type != null and type != ''">and type = #{type}</if>
<if test="area != null and area != ''">and area = #{area}</if> <if test="area != null and area != ''">and area = #{area}</if>
<if test="reviewStatus != null and reviewStatus != ''">and review_status = #{reviewStatus}</if> <if test="reviewStatus != null and reviewStatus != ''">and review_status = #{reviewStatus}</if>
<if test="true">and del_flag=0</if>
</where> </where>
</select> </select>
@ -167,19 +168,19 @@
delete from sys_ingredient_not_rec where ingredient_id=#{ingredientId} delete from sys_ingredient_not_rec where ingredient_id=#{ingredientId}
</delete> </delete>
<delete id="deleteIngredientRecByIngredientIds" parameterType="Long"> <!-- <delete id="deleteIngredientRecByIngredientIds" parameterType="Long">-->
delete from sys_ingredient_rec where ingredient_id in <!-- delete from sys_ingredient_rec where ingredient_id in-->
<foreach item="id" collection="array" open="(" separator="," close=")"> <!-- <foreach item="id" collection="array" open="(" separator="," close=")">-->
#{id} <!-- #{id}-->
</foreach> <!-- </foreach>-->
</delete> <!-- </delete>-->
<delete id="deleteIngredientNotRecByIngredientIds" parameterType="String"> <!-- <delete id="deleteIngredientNotRecByIngredientIds" parameterType="String">-->
delete from sys_ingredient_not_rec where ingredient_id in <!-- delete from sys_ingredient_not_rec where ingredient_id in-->
<foreach item="id" collection="array" open="(" separator="," close=")"> <!-- <foreach item="id" collection="array" open="(" separator="," close=")">-->
#{id} <!-- #{id}-->
</foreach> <!-- </foreach>-->
</delete> <!-- </delete>-->
<update id="updateSysIngredient" parameterType="SysIngredient"> <update id="updateSysIngredient" parameterType="SysIngredient">
update sys_ingredient update sys_ingredient
@ -201,16 +202,9 @@
where id = #{id} where id = #{id}
</update> </update>
<delete id="deleteSysIngredientById" parameterType="Long"> <update id="deleteSysIngredientById" parameterType="Long">
delete from sys_ingredient where id = #{id} update sys_ingredient set del_flag=1 where id = #{id}
</delete> </update>
<delete id="deleteSysIngredientByIds" parameterType="String">
delete from sys_ingredient where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<!-- 根据食材名称查询食材 --> <!-- 根据食材名称查询食材 -->
<select id="selectSysIngredientByName" parameterType="String" resultMap="SysIngredientResult"> <select id="selectSysIngredientByName" parameterType="String" resultMap="SysIngredientResult">

View File

@ -568,13 +568,15 @@ export default {
detailHealthy.secondSmoke = detailHealthy.secondSmoke == 1 ? "是" : "否"; detailHealthy.secondSmoke = detailHealthy.secondSmoke == 1 ? "是" : "否";
let smokeRateString = ""; let smokeRateString = "";
if (detailHealthy.smokeRate != null) { if (detailHealthy.smokeRate != null) {
detailHealthy.smokeRate.split(",").forEach(function (item, index) { (detailHealthy.smokeRate || "")
smokeRateString += .split(",")
(smokeRateString != "" ? "" : "") + .forEach(function (item, index) {
healthyData["smokeRateArray"][index] + smokeRateString +=
item + (smokeRateString != "" ? "" : "") +
healthyData["smokeRateUnitArray"][index]; healthyData["smokeRateArray"][index] +
}); item +
healthyData["smokeRateUnitArray"][index];
});
} }
detailHealthy.smokeRate = smokeRateString; detailHealthy.smokeRate = smokeRateString;
detailHealthy.defecationNum = detailHealthy.defecationNum + "次/天"; detailHealthy.defecationNum = detailHealthy.defecationNum + "次/天";
@ -686,7 +688,7 @@ export default {
? medicalReportNameArray[2] ? medicalReportNameArray[2]
: "体检报告3" : "体检报告3"
: ""; : "";
detailHealthy.moistureDate = detailHealthy.moistureDate detailHealthy.moistureDate = (detailHealthy.moistureDate || "")
.split(",") .split(",")
.reduce((arr, cur) => { .reduce((arr, cur) => {
const tarData = healthyData.moistureDateArray.find( const tarData = healthyData.moistureDateArray.find(
@ -697,7 +699,7 @@ export default {
} }
return arr; return arr;
}, []); }, []);
detailHealthy.bloodData = detailHealthy.bloodData detailHealthy.bloodData = (detailHealthy.bloodData || "")
.split(",") .split(",")
.reduce((arr, cur) => { .reduce((arr, cur) => {
const tarData = healthyData.bloodDataArray.find( const tarData = healthyData.bloodDataArray.find(

View File

@ -437,6 +437,8 @@ const actions = {
const result = await updateDishesDetailApi(params); const result = await updateDishesDetailApi(params);
if (result.code === 200) { if (result.code === 200) {
commit("updateRecipesDishesDetail", payload); commit("updateRecipesDishesDetail", payload);
} else {
return new Promise((res, rej) => rej(result.msg));
} }
} }
} else { } else {

View File

@ -374,14 +374,13 @@ export default {
}, },
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
const ids = row.id || this.ids; this.$confirm('是否确认删除菜品「' + row.name + '」的数据项?', "警告", {
this.$confirm('是否确认删除菜品编号为"' + ids + '"的数据项?', "警告", {
confirmButtonText: "确定", confirmButtonText: "确定",
cancelButtonText: "取消", cancelButtonText: "取消",
type: "warning", type: "warning",
}) })
.then(function () { .then(function () {
return delDishes(ids); return delDishes(row.id);
}) })
.then(() => { .then(() => {
this.getList(); this.getList();

View File

@ -664,14 +664,13 @@ export default {
}, },
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
const ids = row.id || this.ids; this.$confirm("是否确认删除食材「" + row.name + "」的数据项?", "警告", {
this.$confirm('是否确认删除食材编号为"' + ids + '"的数据项?', "警告", {
confirmButtonText: "确定", confirmButtonText: "确定",
cancelButtonText: "取消", cancelButtonText: "取消",
type: "warning", type: "warning",
}) })
.then(function () { .then(function () {
return delIngredient(ids); return delIngredient(row.id);
}) })
.then(() => { .then(() => {
this.getList(); this.getList();

View File

@ -68,11 +68,6 @@ export default {
]), ]),
...mapGetters(["analyseData"]), ...mapGetters(["analyseData"]),
}, },
watch: {
healthyData(val) {
console.log({ val });
},
},
methods: { methods: {
handleOnTabClick(tab) { handleOnTabClick(tab) {
this.activeName = tab.name; this.activeName = tab.name;

View File

@ -504,6 +504,8 @@ export default {
igdId: data.igdId, igdId: data.igdId,
weight, weight,
actionType: "weight", actionType: "weight",
}).catch((err) => {
this.$message.error(err);
}); });
}, },
handleOnCustomUnitChange(data, { cusWeight, cusUnit }) { handleOnCustomUnitChange(data, { cusWeight, cusUnit }) {
@ -517,6 +519,8 @@ export default {
cusWeight, cusWeight,
cusUnit, cusUnit,
actionType: "unit", actionType: "unit",
}).catch((err) => {
this.$message.error(err);
}); });
}, },
handleOnDishesConfirm({ type, data }) { handleOnDishesConfirm({ type, data }) {
@ -547,6 +551,8 @@ export default {
id, id,
type, type,
actionType: "menuType", actionType: "menuType",
}).catch((err) => {
this.$message.error(err);
}); });
}, },
handleOnMenuTypeClick(data) { handleOnMenuTypeClick(data) {
@ -560,6 +566,8 @@ export default {
id, id,
igdId, igdId,
actionType: "delIgd", actionType: "delIgd",
}).catch((err) => {
this.$message.error(err);
}); });
}, },
handleOnEditRemark(data) { handleOnEditRemark(data) {
@ -573,6 +581,8 @@ export default {
id, id,
remark, remark,
actionType: "remark", actionType: "remark",
}).catch((err) => {
this.$message.error(err);
}); });
}, },
...mapActions([ ...mapActions([

View File

@ -3,7 +3,16 @@
<!-- 营养分析 --> <!-- 营养分析 -->
<!-- <NutriComputeCom :date="date" :value="value" /> --> <!-- <NutriComputeCom :date="date" :value="value" /> -->
<div class="top"> <div class="top">
<img :src="logo" style="width: auto; height: 32px" alt="logo" /> <img
class="logo"
:src="logo"
style="width: auto; height: 32px"
alt="logo"
/>
<em
class="el-icon-shopping-cart-full icon_style shopping_cart"
@click="handleOnShoppingPlanClick"
/>
</div> </div>
<!-- 食谱详细 --> <!-- 食谱详细 -->
<el-card v-for="obj in menus" :key="obj.type" style="margin-top: 12px"> <el-card v-for="obj in menus" :key="obj.type" style="margin-top: 12px">
@ -34,6 +43,8 @@
</el-card> </el-card>
<!-- 复杂菜品展示 --> <!-- 复杂菜品展示 -->
<DishesDetailDialog ref="detailDialogRef" /> <DishesDetailDialog ref="detailDialogRef" />
<!-- 当天采购计划 -->
<TodayShoppingPlanDrawer ref="shoppingPlanRef" />
</div> </div>
</template> </template>
<script> <script>
@ -46,12 +57,14 @@ const {
} = createNamespacedHelpers("recipesShow"); } = createNamespacedHelpers("recipesShow");
// import NutriComputeCom from "./NutriComputeCom"; // import NutriComputeCom from "./NutriComputeCom";
import DishesDetailDialog from "./DishesDetailDialog"; import DishesDetailDialog from "./DishesDetailDialog";
import TodayShoppingPlanDrawer from "../PlanDrawer/ShoppingPlanDrawer";
export default { export default {
name: "menuDetail", name: "menuDetail",
props: ["value", "date"], props: ["value", "date"],
components: { components: {
// NutriComputeCom, // NutriComputeCom,
DishesDetailDialog, DishesDetailDialog,
TodayShoppingPlanDrawer,
}, },
data() { data() {
return { return {
@ -99,6 +112,17 @@ export default {
handleOnDetailClick(data) { handleOnDetailClick(data) {
this.$refs["detailDialogRef"].showDialog(data); this.$refs["detailDialogRef"].showDialog(data);
}, },
handleOnShoppingPlanClick() {
this.$refs["shoppingPlanRef"].showDrawer({
num: -1,
data: [
{
dishes: this.value,
},
],
label: this.date,
});
},
}, },
}; };
</script> </script>
@ -106,8 +130,27 @@ export default {
.menu_detail_wrapper { .menu_detail_wrapper {
padding: 0 12px 12px 12px; padding: 0 12px 12px 12px;
.top { .top {
text-align: center; height: 50px;
padding: 10px 14px; position: relative;
.logo {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.shopping_cart {
position: absolute;
right: 5px;
top: 10px;
display: flex;
align-items: center;
&::after {
margin-left: 2px;
content: "采购";
font-size: 12px;
}
}
} }
.header_style { .header_style {

View File

@ -74,17 +74,19 @@ export default {
}; };
}, },
methods: { methods: {
showDrawer(data) { showDrawer(obj) {
// console.log(data); const { recipesId, num, label, data } = obj;
const { recipesId, num, label } = data; console.log(obj);
this.label = label; this.label = label;
// num < 0 // num < 0
this.title = `${ this.title = `${
num === 3 ? "前3" : num === 4 ? "后4" : Math.abs(num) num === 3 ? "前3" : num === 4 ? "后4" : Math.abs(num)
}天采购计划`; }天采购计划`;
this.visible = true; this.visible = true;
if (this.recipes[recipesId]) { if (data) {
this.processShoppingCart(num, recipesId); this.processShoppingCart(num, data);
} else if (this.recipes[recipesId]) {
this.processShoppingCart(num, this.recipes[recipesId]);
} else { } else {
this.loading = true; this.loading = true;
this.fetchFullRecipes({ this.fetchFullRecipes({
@ -92,61 +94,56 @@ export default {
}).then(() => { }).then(() => {
this.loading = false; this.loading = false;
setTimeout(() => { setTimeout(() => {
this.processShoppingCart(num, recipesId); this.processShoppingCart(num, this.recipes[recipesId]);
}, 0); }, 0);
}); });
} }
}, },
processShoppingCart(num, recipesId) { processShoppingCart(num, data = []) {
this.shoppingCart = (this.recipes[recipesId] || []).reduce( this.shoppingCart = data.reduce((obj, cur, idx) => {
(obj, cur, idx) => { if (
if ( num < 0 || //
num < 0 || // num === 7 ||
num === 7 || (num === 3 && num > idx) ||
(num === 3 && num > idx) || (num === 4 && idx > 2)
(num === 4 && idx > 2) ) {
) { cur.dishes.forEach((dObj) => {
cur.dishes.forEach((dObj) => { dObj.igdList.forEach((iObj) => {
dObj.igdList.forEach((iObj) => { const tarTypeName = this.idgTypeDict[iObj.type];
const tarTypeName = this.idgTypeDict[iObj.type]; const tarObj = obj[tarTypeName];
const tarObj = obj[tarTypeName]; if (tarObj) {
if (tarObj) { const tarIObj = tarObj.find((zObj) => zObj.name === iObj.name);
const tarIObj = tarObj.find( if (tarIObj) {
(zObj) => zObj.name === iObj.name tarIObj.weight += this.igdUnitDict[iObj.name]
); ? iObj.cusWeight
if (tarIObj) { : iObj.weight;
tarIObj.weight += this.igdUnitDict[iObj.name]
? iObj.cusWeight
: iObj.weight;
} else {
tarObj.push({
type: iObj.type,
name: iObj.name,
weight: this.igdUnitDict[iObj.name]
? iObj.cusWeight
: iObj.weight,
unit: this.igdUnitDict[iObj.name] || "g",
});
}
} else { } else {
obj[tarTypeName] = [ tarObj.push({
{ type: iObj.type,
type: iObj.type, name: iObj.name,
name: iObj.name, weight: this.igdUnitDict[iObj.name]
weight: this.igdUnitDict[iObj.name] ? iObj.cusWeight
? iObj.cusWeight : iObj.weight,
: iObj.weight, unit: this.igdUnitDict[iObj.name] || "g",
unit: this.igdUnitDict[iObj.name] || "g", });
},
];
} }
}); } else {
obj[tarTypeName] = [
{
type: iObj.type,
name: iObj.name,
weight: this.igdUnitDict[iObj.name]
? iObj.cusWeight
: iObj.weight,
unit: this.igdUnitDict[iObj.name] || "g",
},
];
}
}); });
} });
return obj; }
}, return obj;
{} }, {});
);
// console.log(this.shoppingCart); // console.log(this.shoppingCart);
}, },
handleOnBackClick() { handleOnBackClick() {