生成食谱接口对接
This commit is contained in:
@ -4,8 +4,12 @@
|
||||
:style="`height: ${collapse ? 30 : 200}px`"
|
||||
>
|
||||
<div class="header">
|
||||
<el-button size="mini" type="primary" @click="handleOnSave"
|
||||
>保存</el-button
|
||||
<el-button
|
||||
v-if="!recipesId"
|
||||
size="mini"
|
||||
type="primary"
|
||||
@click="handleOnSave"
|
||||
>生成食谱</el-button
|
||||
>
|
||||
<el-button size="mini" type="text" @click="handleCollapseClick">{{
|
||||
`${collapse ? "展开分析" : "收起分析"}`
|
||||
@ -21,7 +25,12 @@
|
||||
height="170px"
|
||||
width="500px"
|
||||
/>
|
||||
<PieChart v-else :data="data" height="170px" width="500px" />
|
||||
<PieChart
|
||||
v-if="data.length === 1"
|
||||
:data="data"
|
||||
height="170px"
|
||||
width="500px"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@ -29,7 +38,7 @@
|
||||
import BarChart from "./BarChart";
|
||||
import PieChart from "./PieChart";
|
||||
import { createNamespacedHelpers } from "vuex";
|
||||
const { mapActions } = createNamespacedHelpers("recipes");
|
||||
const { mapActions, mapState } = createNamespacedHelpers("recipes");
|
||||
export default {
|
||||
name: "RecipesAspectCom",
|
||||
components: {
|
||||
@ -43,7 +52,9 @@ export default {
|
||||
// console.log(this.data);
|
||||
},
|
||||
props: ["collapse", "data"],
|
||||
computed: {},
|
||||
computed: {
|
||||
...mapState(["recipesId"]),
|
||||
},
|
||||
methods: {
|
||||
handleCollapseClick() {
|
||||
this.$emit("update:collapse", !this.collapse);
|
||||
|
@ -70,8 +70,8 @@ export default {
|
||||
name: "",
|
||||
type: "",
|
||||
igdList: [],
|
||||
recTags:[],
|
||||
notRecTags: []
|
||||
recTags: [],
|
||||
notRecTags: [],
|
||||
},
|
||||
};
|
||||
},
|
||||
@ -123,8 +123,27 @@ export default {
|
||||
handleOnConfirmClick() {
|
||||
this.visible = false;
|
||||
this.active = 0;
|
||||
this.$emit("onConfirm", this.selDishes);
|
||||
// console.log(this.selDishes);
|
||||
|
||||
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);
|
||||
},
|
||||
},
|
||||
};
|
||||
|
@ -161,7 +161,7 @@ export default {
|
||||
const mData = this.data.dishes
|
||||
.sort((a, b) => a.type - b.type)
|
||||
.reduce((arr, cur, idx) => {
|
||||
if (cur.id > 0 && cur.type !== "0") {
|
||||
if (cur.dishesId > 0 && cur.type !== "0") {
|
||||
cur.igdList.forEach((igd) => {
|
||||
let lastTypeHit = false,
|
||||
lastNameHit = false;
|
||||
@ -194,6 +194,8 @@ export default {
|
||||
|
||||
arr.push({
|
||||
id: cur.id,
|
||||
dishesId: cur.dishesId,
|
||||
menuId: cur.menuId,
|
||||
name: cur.name,
|
||||
type: cur.type,
|
||||
isMain: cur.isMain,
|
||||
@ -272,21 +274,22 @@ export default {
|
||||
},
|
||||
handleOnDelete(data) {
|
||||
// console.log(data);
|
||||
this.deleteDishes({ num: this.num - 1, dishesId: data.id });
|
||||
this.deleteDishes({ num: this.num - 1, id: data.id });
|
||||
},
|
||||
handleOnWeightChange(data, weight) {
|
||||
// console.log({ data, weight });
|
||||
console.log({ data, weight });
|
||||
this.updateDishes({
|
||||
num: this.num - 1,
|
||||
dishesId: data.id,
|
||||
dishesId: data.dishesId,
|
||||
igdId: data.igdId,
|
||||
weight,
|
||||
});
|
||||
},
|
||||
handleOnCustomUnitChange(data, { cusWeight, cusUnit }) {
|
||||
console.log({ data, cusWeight, cusUnit });
|
||||
this.updateDishes({
|
||||
num: this.num - 1,
|
||||
dishesId: data.id,
|
||||
dishesId: data.dishesId,
|
||||
igdId: data.igdId,
|
||||
cusWeight,
|
||||
cusUnit,
|
||||
|
@ -24,6 +24,11 @@ export default {
|
||||
RecipesCom,
|
||||
RecipesAspectCom,
|
||||
},
|
||||
computed: {
|
||||
mCollapse() {
|
||||
return analyseData.length ? this.collapse : false;
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
collapse: false,
|
||||
|
22
stdiet-ui/src/views/custom/recipesBuild/RecommondView.vue
Normal file
22
stdiet-ui/src/views/custom/recipesBuild/RecommondView.vue
Normal 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>
|
@ -1,13 +1,15 @@
|
||||
<template>
|
||||
<div class="recipes_build_wrapper">
|
||||
<div class="left">
|
||||
<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>
|
||||
@ -25,6 +27,7 @@ const {
|
||||
import HealthyView from "./HealthyView";
|
||||
import BodySignView from "./BodySignView";
|
||||
import RecipesView from "./RecipesView/index";
|
||||
import RecommondView from "./RecommondView";
|
||||
|
||||
export default {
|
||||
name: "BuildRecipies",
|
||||
@ -32,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);
|
||||
});
|
||||
},
|
||||
@ -49,10 +55,17 @@ export default {
|
||||
HealthyView,
|
||||
BodySignView,
|
||||
RecipesView,
|
||||
RecommondView,
|
||||
},
|
||||
props: ["planId", "cusId", "recipesId"],
|
||||
// props: ["cusId", "planId", "recipesId", "startDate", "endDate"],
|
||||
computed: {
|
||||
...mapState(["healthyData", "healthyDataType", "recipesData"]),
|
||||
...mapState([
|
||||
"healthyData",
|
||||
"healthyDataType",
|
||||
"recipesData",
|
||||
"recipesDataLoading",
|
||||
"healthDataLoading",
|
||||
]),
|
||||
...mapGetters(["analyseData"]),
|
||||
},
|
||||
methods: {
|
||||
|
Reference in New Issue
Block a user