添加食谱计划发送状态开关

This commit is contained in:
huangdeliang 2021-03-30 16:44:50 +08:00
parent e613c44893
commit fa3698cf16
2 changed files with 31 additions and 3 deletions

View File

@ -221,7 +221,7 @@
<!-- 根据cusId查询食谱计划-->
<select id="selectPlanListByCusId" parameterType="Long" resultMap="SysRecipesPlanResult">
select id, out_id, start_date, end_date, start_num_day, end_num_day, recipes_id, review_status from sys_recipes_plan
<include refid="selectSysRecipesPlanVo"/>
where cus_id=#{cusId} and del_flag = 0 order by id asc
</select>
@ -241,7 +241,7 @@
<!-- 通过outId查询食谱计划简要-->
<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} and del_flag = 0 and review_status = 2
select id, start_date, end_date, start_num_day, end_num_day, recipes_id from sys_recipes_plan where out_id=#{outId} and del_flag = 0 and review_status = 2 and send_flag = 1
</select>
<resultMap type="SysRecipesDaily" id="SysRecipesResult">

View File

@ -75,6 +75,14 @@
{{ `${scope.row.startDate}${scope.row.endDate}` }}
</template>
</el-table-column>
<el-table-column label="发送" align="center">
<template slot-scope="scope">
<el-switch
v-model="!!scope.row.sendFlag"
@change="(val) => handleOnSendChange(val, scope.row)"
/>
</template>
</el-table-column>
<el-table-column label="操作" align="center" width="160">
<template slot-scope="scope">
<el-button
@ -201,7 +209,7 @@ export default {
window.location.origin.replace("manage", "sign") +
"/recipes/detail/" +
this.cusOutId;
// console.log(this.planList);
console.log(this.planList);
this.planLoading = false;
});
},
@ -314,6 +322,26 @@ export default {
// });
});
},
handleOnSendChange(val, data) {
console.log({ val, data });
const { id } = data;
if (data.reviewStatus === 2) {
updateRecipesPlan({
id,
sendFlag: val ? 1 : 0,
}).then((res) => {
if (res.code === 200) {
this.$message.success(res.msg);
const tarPlan = this.planList.find((obj) => obj.id === id);
if (tarPlan) {
tarPlan.sendFlag = val ? 1 : 0;
}
}
});
} else {
this.$message.error("未审核的食谱不能发送");
}
},
},
};
</script>