!60 修复通俗重量

Merge pull request !60 from 德仔/develop
This commit is contained in:
德仔
2021-02-09 10:27:08 +08:00
committed by Gitee
27 changed files with 1942 additions and 744 deletions

View File

@ -258,7 +258,7 @@
step="0.5"
:min="0.5"
/> -->
<el-select size="mini" v-model="scope.row.cusWei">
<el-select size="mini" v-model="scope.row.cusWeight">
<el-option
v-for="dict in cusWeightOptions"
:key="dict.dictValue"
@ -502,7 +502,7 @@ export default {
return this.selectDictLabel(this.cusUnitOptions, row.type);
},
cusWeightFormat(row, column) {
return this.selectDictLabel(this.cusWeightOptions, row.cusWei);
return this.selectDictLabel(this.cusWeightOptions, row.cusWeight);
},
// 地域字典翻译
reviewStatusFormat(row, column) {
@ -686,7 +686,7 @@ export default {
newTableData.push({
...tmpTableObj,
weight: 100,
cusWei: 1,
cusWeight: 1,
cusUnit: 1,
});
}

View File

@ -0,0 +1,89 @@
<template>
<div>
<div>
<h2>{{ this.data.name }}</h2>
<div class="msg-info" v-for="(info, idx) in basicInfo" :key="idx">
<text-info
v-for="con in info"
:title="con.title"
:key="con.title"
:value="data[con.value]"
extraclass="text-info-extra"
/>
</div>
</div>
</div>
</template>
<script>
import TextInfo from "./TextInfo.vue";
export default {
name: "BodySignView",
props: ["data"],
components: {
"text-info": TextInfo,
},
data() {
return {
basicInfo: [
[
{ title: "性别", value: "sex" },
{ title: "年龄", value: "age" },
],
[
{ title: "电话", value: "phone" },
{ title: "地域", value: "position" },
],
[
{ title: "身高", value: "tall" },
{ title: "体重", value: "weight" },
],
[
{ title: "工作职业", value: "vocation" },
{ title: "上夜班", value: "night" },
],
[
{ title: "熬夜失眠", value: "staylate" },
{ title: "运动情况", value: "walk" },
],
[
{ title: "浑身乏力", value: "weakness" },
{ title: "经常运动", value: "motion" },
],
[
{ title: "睡觉时间", value: "sleepTime" },
{ title: "起床时间", value: "getupTime" },
],
[
{ title: "饮食方式", value: "makeFoodType" },
{ title: "饮食特点", value: "makeFoodTaste" },
],
[{ title: "便秘", value: "constipation" }],
[{ title: "饮食备注", value: "remarks" }],
[{ title: "减脂反弹", value: "rebound" }],
[{ title: "意识到生活习惯是减脂关键", value: "crux" }],
[{ title: "减脂遇到的困难", value: "difficulty" }],
[
{ title: "湿气数据", value: "moistureDate" },
{ title: "气血数据", value: "bloodData" },
],
[{ title: "病史", value: "signStr" }],
[{ title: "忌口或过敏源", value: "dishesIngredientId" }],
[{ title: "方便沟通时间", value: "connectTime" }],
[{ title: "备注", value: "remark" }],
],
};
},
};
</script>
<style rel="stylesheet/scss" lang="scss">
.msg-info {
display: flex;
margin-bottom: 8px;
.text-info-extra {
margin-bottom: 2px;
}
}
</style>

View File

@ -0,0 +1,193 @@
<template>
<div>
<div>
<h2>{{ this.data.name }}</h2>
<div class="msg-info" v-for="(info, idx) in basicInfo" :key="idx">
<text-info
v-for="con in info"
:title="con.title"
:key="con.title"
:value="data[con.value]"
extraclass="text-info-extra"
/>
</div>
</div>
<el-collapse>
<el-collapse-item
v-for="item in healthyInvestigate"
:key="item.title"
:title="item.title"
:name="item.title"
>
<div v-for="con in item.content" :key="con.value">
<text-info
:title="con.title"
:value="data[con.value]"
extraclass="text-info-extra"
/>
</div>
</el-collapse-item>
</el-collapse>
</div>
</template>
<script>
import TextInfo from "./TextInfo.vue";
export default {
name: "HealthyView",
props: ["data"],
components: {
"text-info": TextInfo,
},
data() {
return {
basicInfo: [
[
{ title: "调理项目", value: "conditioningProject" },
{ title: "电话", value: "phone" },
],
[
{ title: "性别", value: "sex" },
{ title: "年龄", value: "age" },
],
[
{ title: "身高", value: "tall" },
{ title: "体重", value: "weight" },
],
[{ title: "地域", value: "position" }],
[{ title: "备注", value: "remark" }],
],
healthyInvestigate: [
{
title: "减脂经历评估",
content: [
{ title: "减脂经历", value: "experience" },
{ title: "减肥遇到的困难", value: "difficulty" },
{ title: "减脂是否反弹", value: "rebound" },
{ title: "是否意识到生活习惯是减脂关键", value: "crux" },
],
},
{
title: "食品安全评估",
content: [
{ title: "调味品种", value: "condiment" },
{ title: "烹调方式", value: "cookingStyle" },
{ title: "烹调频次", value: "cookingStyleRate" },
{ title: "洗菜方式", value: "washVegetablesStyle" },
],
},
{
title: "饮食结构评估",
content: [
{ title: "早餐习惯", value: "breakfastType" },
{ title: "早餐吃的食物", value: "breakfastFood" },
{ title: "午餐习惯", value: "lunchType" },
{ title: "晚餐习惯", value: "dinner" },
{ title: "正餐中素菜占比", value: "vegetableRate" },
{ title: "最常吃的肉类", value: "commonMeat" },
{ title: "晚餐时间", value: "dinnerTime" },
{ title: "每周吃夜宵次数", value: "supperNum" },
{ title: "夜宵通常吃的食物", value: "supperFood" },
{ title: "食物的冷热偏好", value: "dietHotAndCold" },
{ title: "食物的口味偏好", value: "dietFlavor" },
{ title: "平均每周吃生蔬菜几次", value: "vegetablesNum" },
{ title: "每周吃生蔬菜的频次类型", value: "vegetablesRateType" },
{ title: "平均每天吃水果次数", value: "fruitsNum" },
{ title: "吃水果的时间段", value: "fruitsTime" },
{ title: "平时吃水果的频次", value: "fruitsRate" },
{ title: "一餐吃几碗饭", value: "riceNum" },
{ title: "吃几成饱", value: "riceFull" },
{ title: "吃饭速度", value: "eatingSpeed" },
{ title: "饮食特点", value: "makeFoodType" },
{ title: "常吃的零食", value: "snacks" },
{ title: "有无服用营养保健品", value: "healthProductsFlag" },
{ title: "营养保健品品牌名", value: "healthProductsBrand" },
{ title: "营养保健品产品名", value: "healthProductsName" },
{ title: "服用营养保健品频次", value: "healthProductsWeekRate" },
{ title: "忌口过敏食物", value: "dishesIngredient" },
],
},
{
title: "生活习惯评估",
content: [
{ title: "每天的饮水量", value: "waterNum" },
{ title: "喜欢喝什么水", value: "waterType" },
{ title: "喝水习惯", value: "waterHabit" },
{ title: "常喝的饮品的每周频次", value: "drinksNum" },
{ title: "是否喝酒", value: "drinkWineFlag" },
{ title: "喝酒种类", value: "drinkWineClassify" },
{ title: "对应酒的量", value: "drinkWineAmount" },
{ title: "是否抽烟", value: "smokeFlag" },
{ title: "抽烟频次和烟龄", value: "smokeRate" },
{ title: "是否经常抽二手烟", value: "secondSmoke" },
{ title: "工作行业", value: "workIndustry" },
{ title: "工作性质", value: "workType" },
{ title: "排便次数", value: "defecationNum" },
{ title: "排便时间段", value: "defecationTime" },
{ title: "排便的形状", value: "defecationShape" },
{ title: "排便的气味", value: "defecationSmell" },
{ title: "排便的速度", value: "defecationSpeed" },
{ title: "排便的颜色", value: "defecationColor" },
],
},
{
title: "运动习惯评估",
content: [
{ title: "每周运动次数", value: "motionNum" },
{ title: "每次运动的时长", value: "motionDuration" },
{ title: "每天运动的时间", value: "motionTime" },
{ title: "运动", value: "motion" },
{ title: "运动场地", value: "motionField" },
],
},
{
title: "睡眠质量评估",
content: [
{ title: "睡觉时间", value: "sleepTime" },
{ title: "睡眠质量", value: "sleepQuality" },
{ title: "是否有辅助入睡药物", value: "sleepDrugFlag" },
{ title: "辅助睡眠类药物名称", value: "sleepDrug" },
{ title: "是否经常熬夜", value: "stayupLateFlag" },
{ title: "熬夜频次", value: "stayupLateWeekNum" },
],
},
{
title: "既往病史/用药史评估",
content: [
{ title: "病史体征", value: "physicalSigns" },
{ title: "湿气数据", value: "moistureDate" },
{ title: "气血数据", value: "bloodData" },
{ title: "家族疾病史", value: "familyIllnessHistory" },
{ title: "手术史", value: "operationHistory" },
{ title: "近期是否做过手术", value: "nearOperationFlag" },
{ title: "手术恢复情况", value: "recoveryeSituation" },
{ title: "是否长期服用药物", value: "longEatDrugFlag" },
{ title: "长期服用的药物", value: "longEatDrugClassify" },
{ title: "是否出现过过敏症状", value: "allergyFlag" },
{ title: "过敏症状", value: "allergySituation" },
{ title: "过敏源", value: "allergen" },
],
},
{
title: "体检报告",
content: [
{ title: "体检报告1", value: "medicalReport_one" },
{ title: "体检报告2", value: "medicalReport_two" },
{ title: "体检报告3", value: "medicalReport_three" },
],
},
],
};
},
};
</script>
<style rel="stylesheet/scss" lang="scss">
.msg-info {
display: flex;
margin-bottom: 8px;
.text-info-extra {
margin-bottom: 2px;
}
}
</style>

View File

@ -0,0 +1,52 @@
<template>
<div :class="classname">
<span class="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>
</div>
</template>
<script>
export default {
name: "TextInfo",
data() {
return {
classname: `text_info_wrapper ${this.extraclass || ""}`,
newLine: false,
};
},
computed: {
mValue: function () {
if (
this.value &&
typeof this.value === "string" &&
this.value.includes("</br>")
) {
this.newLine = true;
return this.value.split("</br>");
}
return this.value;
},
},
props: ["title", "value", "extraclass"],
};
</script>
<style rel="stylesheet/scss" lang="scss">
.text_info_wrapper {
display: flex;
margin-right: 24px;
min-width: 120px;
font-size: 14px;
.title {
color: #8c8c8c;
width: auto;
}
.value {
/* color: #696969; */
flex: 1;
}
}
</style>

View File

@ -0,0 +1,75 @@
<template>
<div class="app-container">
<div class="content">
<div class="left">left</div>
<div class="right">
<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"
);
import HealthyView from "./HealthyView";
import BodySignView from "./BodySignView";
export default {
name: "BuildRecipies",
data() {
return {};
},
mounted() {
//
console.log({
cusId: this.cusId,
recipesId: this.recipesId,
});
this.init({ cusId: this.cusId }).catch((err) => {
this.$message.error(err.message);
});
},
destroyed() {
this.clean();
},
created() {},
components: {
HealthyView,
BodySignView,
},
props: ["planId", "cusId", "recipesId"],
computed: {
...mapState({
healthyData: (state) => state.healthyData,
healthyDataType: (state) => state.healthyDataType,
}),
},
methods: {
...mapActions(["init"]),
...mapMutations(["clean"]),
},
};
</script>
<style rel="stylesheet/scss" lang="scss">
.content {
display: flex;
height: calc(100vh - 124px);
.left {
flex: 4;
border-right: 1px solid #e6ebf5;
height: 100%;
overflow: auto;
}
.right {
flex: 1;
height: 100%;
padding-left: 20px;
overflow: auto;
}
}
</style>

View File

@ -1,6 +1,11 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch">
<el-form
:model="queryParams"
ref="queryForm"
:inline="true"
v-show="showSearch"
>
<el-form-item label="客户信息" prop="customer">
<el-input
v-model="queryParams.customer"
@ -9,17 +14,27 @@
size="small"
/>
</el-form-item>
<el-form-item label="食谱开始日期范围" prop="planStartDateScope" label-width="130px">
<el-form-item
label="食谱开始日期范围"
prop="planStartDateScope"
label-width="130px"
>
<el-date-picker
v-model="planStartDateScope"
type="daterange"
range-separator=""
start-placeholder="开始日期"
end-placeholder="结束日期">
end-placeholder="结束日期"
>
</el-date-picker>
</el-form-item>
<el-form-item label="营养师" prop="nutritionistId">
<el-select v-model="queryParams.nutritionistId" placeholder="请选择营养师" clearable size="small">
<el-select
v-model="queryParams.nutritionistId"
placeholder="请选择营养师"
clearable
size="small"
>
<el-option
v-for="dict in nutritionistIdOptions"
:key="dict.dictValue"
@ -29,7 +44,12 @@
</el-select>
</el-form-item>
<el-form-item label="营养师助理" prop="nutritionistAssisId">
<el-select v-model="queryParams.nutritionistAssisId" placeholder="请选择营养师助理" clearable size="small">
<el-select
v-model="queryParams.nutritionistAssisId"
placeholder="请选择营养师助理"
clearable
size="small"
>
<el-option
v-for="dict in nutriAssisIdOptions"
:key="dict.dictValue"
@ -39,14 +59,25 @@
</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>
<div><span style="color:#E6A23C;font-family:PingFang SC">
注意事项
<br/>12021年1月开始的订单才会自动生成食谱计划</span></div>
<el-row :gutter="10" class="mb8" style="margin-top:10px;">
<div>
<span style="color: #e6a23c; font-family: PingFang SC">
注意事项
<br />12021年1月开始的订单才会自动生成食谱计划</span
>
</div>
<el-row :gutter="10" class="mb8" style="margin-top: 10px">
<el-col :span="1.5">
<el-button
type="success"
@ -55,7 +86,7 @@
:disabled="single"
@click="handleUpdate"
v-hasPermi="['recipes:recipesPlan:edit']"
>修改
>修改
</el-button>
</el-col>
<el-col :span="1.5">
@ -65,39 +96,68 @@
size="mini"
@click="handleExport"
v-hasPermi="['recipes:recipesPlan:export']"
>导出
>导出
</el-button>
</el-col>
<!--<div><span style="margin-left:10px;font-size:16px;color:#E6A23C;font-family:PingFang SC">备注2021年1月开始的订单才会自动生成食谱计划</span></div>-->
<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="recipesPlanList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center"/>
<el-table-column label="客户姓名" align="center" prop="customer"/>
<el-table-column label="客户手机号" align="center" prop="hidePhone" width="180"/>
<el-table-column label="食谱日期范围" align="center" prop="scopeDate" width="200"/>
<el-table-column label="营养师" align="center" prop="nutritionist"/>
<el-table-column label="营养师助理" align="center" prop="nutritionistAssis" width="180"/>
<el-table
v-loading="loading"
:data="recipesPlanList"
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="客户姓名" align="center" prop="customer" />
<el-table-column
label="客户手机号"
align="center"
prop="hidePhone"
width="180"
/>
<el-table-column
label="食谱日期范围"
align="center"
prop="scopeDate"
width="200"
/>
<el-table-column label="营养师" align="center" prop="nutritionist" />
<el-table-column
label="营养师助理"
align="center"
prop="nutritionistAssis"
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 :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">
<el-table-column
label="食谱发送时间"
align="center"
prop="sendTime"
width="180"
>
<template slot-scope="scope">
<span>{{ parseTime(scope.row.sendTime, '{y}-{m}-{d}') }}</span>
<span>{{ parseTime(scope.row.sendTime, "{y}-{m}-{d}") }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="300">
<el-table-column
label="操作"
align="center"
class-name="small-padding fixed-width"
width="300"
>
<template slot-scope="scope">
<el-button
size="mini"
@ -105,14 +165,17 @@
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['recipes:recipesPlan:edit']"
>修改
>修改
</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="allRecipesPlanQueryParam.orderId = scope.row.orderId; getAllPlanByOrderId()"
>查看完整计划
@click="
allRecipesPlanQueryParam.orderId = scope.row.orderId;
getAllPlanByOrderId();
"
>查看完整计划
</el-button>
<el-button
size="mini"
@ -120,7 +183,7 @@
icon="el-icon-edit"
@click="getOrderDetail(scope.row)"
v-hasPermi="['custom:order:query']"
>查看订单
>查看订单
</el-button>
<el-button
size="mini"
@ -128,21 +191,21 @@
icon="el-icon-edit"
@click="getCustomerSign(scope.row)"
v-hasPermi="['custom:customer:query']"
>查看体征
>查看体征
</el-button>
<!--<el-button
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['recipes:recipesPlan:remove']"
>删除</el-button>-->
icon="el-icon-edit"
@click="handleBuild(scope.row)"
>{{ `${scope.row.recipes_id ? "编辑" : "制作"}食谱` }}</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"
@ -152,10 +215,14 @@
<!-- 添加或修改食谱计划对话框 -->
<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-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-option label="否" :value="parseInt('0')" />
<el-option label="是" :value="parseInt('1')" />
</el-select>
</el-form-item>
</el-form>
@ -166,47 +233,73 @@
</el-dialog>
<!-- 查看完整计划 -->
<el-dialog title="食谱计划表" v-if="allRecipesPlanOpen" :visible.sync="allRecipesPlanOpen" width="800px" append-to-body>
<el-form :model="allRecipesPlanQueryParam" ref="allPlanQueryFrom" :inline="true">
<el-dialog
title="食谱计划表"
v-if="allRecipesPlanOpen"
: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
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-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="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="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 :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">
<el-table-column
label="食谱发送时间"
align="center"
prop="sendTime"
width="180"
>
<template slot-scope="scope">
<span>{{ parseTime(scope.row.sendTime, '{y}-{m}-{d}') }}</span>
<span>{{ parseTime(scope.row.sendTime, "{y}-{m}-{d}") }}</span>
</template>
</el-table-column>
</el-table>
<pagination
v-show="allRecipesPlanTotal>0"
v-show="allRecipesPlanTotal > 0"
:total="allRecipesPlanTotal"
:page.sync="allRecipesPlanQueryParam.pageNum"
:limit.sync="allRecipesPlanQueryParam.pageSize"
@ -218,266 +311,316 @@
</el-dialog>
<!-- 查看订单 -->
<order-dialog ref="orderDialog"/>
<order-dialog ref="orderDialog" />
<!-- 查看体征 -->
<body_sign_dialog ref="bodySignDialog"/>
<body_sign_dialog ref="bodySignDialog" />
</div>
</template>
<script>
import {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 store from "@/store";
import {
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 store from "@/store";
const nextDate = dayjs().add(1, 'day').format("YYYY-MM-DD");
const weekDate = dayjs().add(6, 'day').format("YYYY-MM-DD");
const userId = store.getters && store.getters.userId;
export default {
name: "recipesPlan",
data() {
return {
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 食谱计划表格数据
recipesPlanList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
orderDialog: undefined,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
customer: null,
startDate: null,
endDate: null,
nutritionistId: null,
nutritionistAssisId: null
},
// 表单参数
form: {},
// 表单校验
rules: {},
//食谱开始时间范围
planStartDateScope: [nextDate, nextDate],
//订单对于所有计划安排数据
allRecipesPlanList: [],
//订单弹窗状态
allRecipesPlanOpen: false,
//订单弹窗中查询参数
allRecipesPlanQueryParam: {
pageNum: 1,
pageSize: 10,
orderId: null,
sendFlag: 0
},
//订单弹窗中列表数据的总条数
allRecipesPlanTotal: 0,
//营养师
nutritionistIdOptions: [],
//营养师助理
nutriAssisIdOptions: [],
const nextDate = dayjs().add(1, "day").format("YYYY-MM-DD");
const weekDate = dayjs().add(6, "day").format("YYYY-MM-DD");
const userId = store.getters && store.getters.userId;
export default {
name: "recipesPlan",
data() {
return {
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 食谱计划表格数据
recipesPlanList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
orderDialog: undefined,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
customer: null,
startDate: null,
endDate: null,
nutritionistId: null,
nutritionistAssisId: null,
},
// 表单参数
form: {},
// 表单校验
rules: {},
//食谱开始时间范围
planStartDateScope: [nextDate, nextDate],
//订单对于所有计划安排数据
allRecipesPlanList: [],
//订单弹窗状态
allRecipesPlanOpen: false,
//订单弹窗中查询参数
allRecipesPlanQueryParam: {
pageNum: 1,
pageSize: 10,
orderId: null,
sendFlag: 0,
},
//订单弹窗中列表数据的总条数
allRecipesPlanTotal: 0,
//营养师
nutritionistIdOptions: [],
//营养师助理
nutriAssisIdOptions: [],
};
},
components: {
"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) {
this.queryParams.nutritionistId = userId;
}
if (defaultNutriAssisId) {
this.queryParams.nutritionistAssisId = userId;
}
this.getList();
});
},
methods: {
/** 查询食谱计划列表 */
getList() {
this.loading = true;
if (
this.planStartDateScope != null &&
this.planStartDateScope.length > 0
) {
this.queryParams.startDate = dayjs(this.planStartDateScope[0]).format(
"YYYY-MM-DD"
);
this.queryParams.endDate = dayjs(this.planStartDateScope[1]).format(
"YYYY-MM-DD"
);
} else {
this.queryParams.startDate = null;
this.queryParams.endDate = null;
}
listRecipesPlan(this.queryParams).then((response) => {
this.recipesPlanList = response.rows;
this.recipesPlanList.forEach(function (item, index) {
item.scopeDate =
dayjs(item.startDate).format("YYYY-MM-DD") +
" 到 " +
dayjs(item.endDate).format("YYYY-MM-DD");
});
this.total = response.total;
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.allRecipesPlanTotal = response.total;
});
},
getOrderDetail(row) {
this.$refs.orderDialog.showDialog(row.orderId);
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
id: null,
orderId: null,
startDate: null,
endDate: null,
recipesId: null,
sendFlag: null,
sendTime: null,
createTime: null,
createBy: null,
updateTime: null,
updateBy: null,
delFlag: null,
};
this.resetForm("form");
},
components: {
"order-dialog": OrderDetail,
"body_sign_dialog": BodySignDetail
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
created() {
getOptions().then(response => {
const options = response.data.reduce((opts, cur) => {
if (!opts[cur.postCode]) {
opts[cur.postCode] = [{dictValue: null, dictLabel: '全部', remark: null}];
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.planStartDateScope = [nextDate, nextDate];
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();
}
});
}
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) {
this.queryParams.nutritionistId = userId;
}
if (defaultNutriAssisId) {
this.queryParams.nutritionistAssisId = userId;
}
this.getList();
});
},
/** 导出按钮操作 */
handleExport() {
const queryParams = this.queryParams;
this.$confirm("是否确认导出所有食谱计划数据项?", "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
},
methods: {
/** 查询食谱计划列表 */
getList() {
this.loading = true;
if (this.planStartDateScope != null && this.planStartDateScope.length > 0) {
this.queryParams.startDate = dayjs(this.planStartDateScope[0]).format('YYYY-MM-DD');
this.queryParams.endDate = dayjs(this.planStartDateScope[1]).format('YYYY-MM-DD');
} else {
this.queryParams.startDate = null;
this.queryParams.endDate = null;
}
listRecipesPlan(this.queryParams).then(response => {
this.recipesPlanList = response.rows;
this.recipesPlanList.forEach(function (item, index) {
item.scopeDate = dayjs(item.startDate).format("YYYY-MM-DD") + " 到 " + dayjs(item.endDate).format("YYYY-MM-DD")
});
this.total = response.total;
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.allRecipesPlanTotal = response.total;
});
},
getOrderDetail(row) {
this.$refs.orderDialog.showDialog(row.orderId);
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
id: null,
orderId: null,
startDate: null,
endDate: null,
recipesId: null,
sendFlag: null,
sendTime: null,
createTime: null,
createBy: null,
updateTime: null,
updateBy: null,
delFlag: null
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.planStartDateScope = [nextDate, nextDate];
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() {
const queryParams = this.queryParams;
this.$confirm('是否确认导出所有食谱计划数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function () {
.then(function () {
return exportRecipesPlan(queryParams);
}).then(response => {
})
.then((response) => {
this.download(response.msg);
}).catch(function () {
});
},
getTagType(row) {
if (row.sendFlag == 1) {
return "success";
}
return "danger";
/* if(dayjs(row.startDate+"").diff(dayjs(),'day') <= 1){
})
.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) {
//第三第四列的背景色就改变了2和3都是列数的下标
return "background:#f3f6fc;font-weight:bold";
},
// 自定义列背景色
columnStyle({ row, column, rowIndex, columnIndex }) {
if (
columnIndex == 0 ||
columnIndex == 2 ||
columnIndex == 4 ||
columnIndex == 6
) {
//第三第四列的背景色就改变了2和3都是列数的下标
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 "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
};
}
return {
rowspan: 0,
colspan: 0,
};
}
}
}
};
},
handleBuild(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 += '/61';
// this.$router.push({
// name: "build",
// params,
// });
this.$router.push(path);
},
},
};
</script>