|
@@ -38,15 +38,15 @@
|
|
<el-button type="primary" icon="Plus" @click="handleAdd" v-hasPermi="['system:recipe:add']">新增食谱</el-button>
|
|
<el-button type="primary" icon="Plus" @click="handleAdd" v-hasPermi="['system:recipe:add']">新增食谱</el-button>
|
|
</el-col>
|
|
</el-col>
|
|
<el-col :span="1.5">
|
|
<el-col :span="1.5">
|
|
- <el-button @click="handleNew()" v-hasPermi="['system:recipe:remove']">食谱分类</el-button>
|
|
|
|
|
|
+ <el-button @click="handleNew()" >食谱分类</el-button>
|
|
</el-col>
|
|
</el-col>
|
|
|
|
|
|
<el-col :span="1.5">
|
|
<el-col :span="1.5">
|
|
- <el-button type="primary" :disabled="multiple" @click="handleDelete()" v-hasPermi="['system:recipe:remove']">批量智能推荐</el-button>
|
|
|
|
|
|
+ <el-button type="primary" :disabled="recommend" @click="handleRecommend()">批量智能推荐</el-button>
|
|
</el-col>
|
|
</el-col>
|
|
|
|
|
|
<el-col :span="1.5">
|
|
<el-col :span="1.5">
|
|
- <el-button type="primary" :disabled="multiple" @click="handleDelete()" v-hasPermi="['system:recipe:remove']">批量取消智能推荐</el-button>
|
|
|
|
|
|
+ <el-button type="primary" :disabled="cancleRecommend" @click="handleCancleRecommend()">批量取消智能推荐</el-button>
|
|
</el-col>
|
|
</el-col>
|
|
|
|
|
|
<el-col :span="1.5">
|
|
<el-col :span="1.5">
|
|
@@ -62,31 +62,28 @@
|
|
</el-row>
|
|
</el-row>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
- <el-table v-loading="loading" border :data="recipeList" @selection-change="handleSelectionChange">
|
|
|
|
|
|
+ <el-table v-loading="loading" border :data="recipeList" @selection-change="handleSelectionChange" ref="tableRef">
|
|
<el-table-column type="selection" width="55" align="center" />
|
|
<el-table-column type="selection" width="55" align="center" />
|
|
- <el-table-column label="食谱编码" align="center" prop="recipeId"/>
|
|
|
|
- <el-table-column label="膳食类型" align="center" prop="recipeId"/>
|
|
|
|
- <el-table-column label="食谱分类" align="center" prop="categoryId" />
|
|
|
|
- <el-table-column label="食谱名称" align="center" prop="name" />
|
|
|
|
- <el-table-column label="食谱价格" align="center" prop="price" />
|
|
|
|
- <el-table-column label="智能推荐" align="center" prop="smartRecommend" />
|
|
|
|
- <!-- <el-table-column label="基本膳食" align="center" prop="baseDiet" />
|
|
|
|
- <el-table-column label="餐次" align="center" prop="mealTime" />
|
|
|
|
- <el-table-column label="适用疾病" align="center" prop="suitableDisease" />
|
|
|
|
- <el-table-column label="忌食病症" align="center" prop="avoidDisease" />
|
|
|
|
- <el-table-column label="适用科室" align="center" prop="suitableDept" />
|
|
|
|
- <el-table-column label="制作方式" align="center" prop="cookingMethod" />
|
|
|
|
- <el-table-column label="状态" align="center" prop="status" /> -->
|
|
|
|
- <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
|
|
|
|
|
+ <el-table-column label="食谱编码" align="center" prop="recipeId" width="200px"/>
|
|
|
|
+ <el-table-column label="膳食类型" align="left" prop="baseDietName" width="150px"/>
|
|
|
|
+ <el-table-column label="食谱分类" align="left" prop="categoryName" width="150px"/>
|
|
|
|
+ <el-table-column label="食谱名称" align="left" prop="name" />
|
|
|
|
+ <el-table-column label="食谱价格" align="left" prop="price" width="150px"/>
|
|
|
|
+ <el-table-column label="智能推荐" align="left" prop="smartRecommend" width="150px">
|
|
|
|
+ <template #default="scope">
|
|
|
|
+ <el-switch v-model="scope.row.smartRecommend" active-value="0" inactive-value="1" @change="handleStatusChange(scope.row)"></el-switch>
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="230px">
|
|
<template #default="scope">
|
|
<template #default="scope">
|
|
<el-tooltip content="详情" placement="top">
|
|
<el-tooltip content="详情" placement="top">
|
|
- <el-button link type="primary" icon="View" @click="handleUpdate(false,scope.row)" v-hasPermi="['system:recipe:edit']">详情</el-button>
|
|
|
|
|
|
+ <el-button link type="primary" icon="View" @click="handleUpdate(true,scope.row)" v-hasPermi="['system:recipe:edit']">详情</el-button>
|
|
</el-tooltip>
|
|
</el-tooltip>
|
|
<el-tooltip content="编辑" placement="top">
|
|
<el-tooltip content="编辑" placement="top">
|
|
<el-button link type="primary" icon="Edit" @click="handleUpdate(false,scope.row)" v-hasPermi="['system:recipe:edit']">编辑</el-button>
|
|
<el-button link type="primary" icon="Edit" @click="handleUpdate(false,scope.row)" v-hasPermi="['system:recipe:edit']">编辑</el-button>
|
|
</el-tooltip>
|
|
</el-tooltip>
|
|
<el-tooltip content="删除" placement="top">
|
|
<el-tooltip content="删除" placement="top">
|
|
- <el-button link type="primary" icon="Delete" @click="handleDelete(true,scope.row)" v-hasPermi="['system:recipe:remove']">删除</el-button>
|
|
|
|
|
|
+ <el-button link type="danger" icon="Delete" @click="handleDelete( scope.row)" v-hasPermi="['system:recipe:remove']">删除</el-button>
|
|
</el-tooltip>
|
|
</el-tooltip>
|
|
</template>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table-column>
|
|
@@ -121,33 +118,40 @@
|
|
</el-table-column>
|
|
</el-table-column>
|
|
</el-table>
|
|
</el-table>
|
|
</el-dialog>
|
|
</el-dialog>
|
|
- </div>
|
|
|
|
|
|
+ </div>
|
|
|
|
+
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup name="Recipe" lang="ts">
|
|
<script setup name="Recipe" lang="ts">
|
|
import { listRecipeCategory, getRecipeCategory, delRecipeCategory, addRecipeCategory, updateRecipeCategory } from '@/api/system/recipeCategory';
|
|
import { listRecipeCategory, getRecipeCategory, delRecipeCategory, addRecipeCategory, updateRecipeCategory } from '@/api/system/recipeCategory';
|
|
import { RecipeCategoryVO, RecipeCategoryQuery, RecipeCategoryForm } from '@/api/system/recipeCategory/types';
|
|
import { RecipeCategoryVO, RecipeCategoryQuery, RecipeCategoryForm } from '@/api/system/recipeCategory/types';
|
|
-import { listRecipe, getRecipe, delRecipe, addRecipe, updateRecipe } from '@/api/system/recipe';
|
|
|
|
|
|
+import { listRecipe, getRecipe, delRecipe, addRecipe, updateRecipe,changeRecipeStatus } from '@/api/system/recipe';
|
|
import { RecipeVO, RecipeQuery, RecipeForm } from '@/api/system/recipe/types';
|
|
import { RecipeVO, RecipeQuery, RecipeForm } from '@/api/system/recipe/types';
|
|
|
|
+import { title } from 'process';
|
|
|
|
|
|
|
|
|
|
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
|
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
|
-const { intelligent_recommendation,meal_times,dietary_types } = toRefs<any>(proxy?.useDict('intelligent_recommendation','meal_times','dietary_types'));
|
|
|
|
-
|
|
|
|
|
|
+const { intelligent_recommendation, dietary_types } = toRefs<any>(proxy?.useDict('intelligent_recommendation', 'dietary_types'));
|
|
|
|
+
|
|
|
|
+const cancleRecommend = ref(true);
|
|
|
|
+const recommend = ref(true);
|
|
const router = useRouter();
|
|
const router = useRouter();
|
|
const recipeList = ref<RecipeVO[]>([]);
|
|
const recipeList = ref<RecipeVO[]>([]);
|
|
const buttonLoading = ref(false);
|
|
const buttonLoading = ref(false);
|
|
const loading = ref(true);
|
|
const loading = ref(true);
|
|
const showSearch = ref(true);
|
|
const showSearch = ref(true);
|
|
const ids = ref<Array<string | number>>([]);
|
|
const ids = ref<Array<string | number>>([]);
|
|
|
|
+const idRows = ref<Array<RecipeVO>>([]);
|
|
|
|
+const idForNames = ref<string>([]);
|
|
const single = ref(true);
|
|
const single = ref(true);
|
|
const multiple = ref(true);
|
|
const multiple = ref(true);
|
|
const total = ref(0);
|
|
const total = ref(0);
|
|
const recipeCategoryList = ref<RecipeCategoryVO[]>([]);
|
|
const recipeCategoryList = ref<RecipeCategoryVO[]>([]);
|
|
-
|
|
|
|
const queryFormRef = ref<ElFormInstance>();
|
|
const queryFormRef = ref<ElFormInstance>();
|
|
-const recipeFormRef = ref<ElFormInstance>();
|
|
|
|
|
|
+const tableRef = ref<ElTableInstance>();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
const dialog = reactive<DialogOption>({
|
|
const dialog = reactive<DialogOption>({
|
|
visible: false,
|
|
visible: false,
|
|
@@ -218,18 +222,7 @@ const getList = async () => {
|
|
total.value = res.total;
|
|
total.value = res.total;
|
|
loading.value = false;
|
|
loading.value = false;
|
|
}
|
|
}
|
|
-
|
|
|
|
-/** 取消按钮 */
|
|
|
|
-const cancel = () => {
|
|
|
|
- reset();
|
|
|
|
- dialog.visible = false;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-/** 表单重置 */
|
|
|
|
-const reset = () => {
|
|
|
|
- form.value = {...initFormData};
|
|
|
|
- recipeFormRef.value?.resetFields();
|
|
|
|
-}
|
|
|
|
|
|
+
|
|
|
|
|
|
/** 搜索按钮操作 */
|
|
/** 搜索按钮操作 */
|
|
const handleQuery = () => {
|
|
const handleQuery = () => {
|
|
@@ -246,24 +239,31 @@ const resetQuery = () => {
|
|
/** 多选框选中数据 */
|
|
/** 多选框选中数据 */
|
|
const handleSelectionChange = (selection: RecipeVO[]) => {
|
|
const handleSelectionChange = (selection: RecipeVO[]) => {
|
|
ids.value = selection.map(item => item.recipeId);
|
|
ids.value = selection.map(item => item.recipeId);
|
|
- single.value = selection.length != 1;
|
|
|
|
|
|
+ idRows.value=selection;
|
|
|
|
+ idForNames.value= selection.map(item => item.name).join(',');
|
|
|
|
+ // single.value = selection.length != 1;
|
|
multiple.value = !selection.length;
|
|
multiple.value = !selection.length;
|
|
|
|
+ if(selection&&selection.length==0){
|
|
|
|
+ recommend.value=true;
|
|
|
|
+ cancleRecommend.value=true;
|
|
|
|
+ }else{
|
|
|
|
+ recommend.value=selection.filter((value: RecipeVO, index: number, array: RecipeVO[])=>{
|
|
|
|
+ return value.smartRecommend=='1';
|
|
|
|
+ }).length!=selection.length;
|
|
|
|
+
|
|
|
|
+ cancleRecommend.value=selection.filter((value: RecipeVO, index: number, array: RecipeVO[])=>{
|
|
|
|
+ return value.smartRecommend=='0';
|
|
|
|
+ }).length!=selection.length;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
/** 新增按钮操作 */
|
|
/** 新增按钮操作 */
|
|
const handleAdd = () => {
|
|
const handleAdd = () => {
|
|
- // reset();
|
|
|
|
- // dialog.visible = true;
|
|
|
|
- // dialog.title = "添加食谱管理";
|
|
|
|
-
|
|
|
|
router.push('/food/recipe-page/0');
|
|
router.push('/food/recipe-page/0');
|
|
}
|
|
}
|
|
|
|
|
|
/** 修改按钮操作 */
|
|
/** 修改按钮操作 */
|
|
const handleNew = async ( ) => {
|
|
const handleNew = async ( ) => {
|
|
- reset();
|
|
|
|
- // const res = await getRecipe(_recipeId);
|
|
|
|
- // Object.assign(form.value, res.data);
|
|
|
|
dialog.visible = true;
|
|
dialog.visible = true;
|
|
dialog.title = "食谱分类管理";
|
|
dialog.title = "食谱分类管理";
|
|
await getRecipeCategoryList();
|
|
await getRecipeCategoryList();
|
|
@@ -271,11 +271,6 @@ const handleNew = async ( ) => {
|
|
|
|
|
|
/** 修改按钮操作 */
|
|
/** 修改按钮操作 */
|
|
const handleUpdate = async (disabled:boolean,row?: RecipeVO) => {
|
|
const handleUpdate = async (disabled:boolean,row?: RecipeVO) => {
|
|
- // reset();
|
|
|
|
- // const res = await getRecipe(_recipeId);
|
|
|
|
- // Object.assign(form.value, res.data);
|
|
|
|
- // dialog.visible = true;
|
|
|
|
- // dialog.title = "修改食谱管理";
|
|
|
|
const _recipeId = row?.recipeId || ids.value[0]
|
|
const _recipeId = row?.recipeId || ids.value[0]
|
|
if(disabled){
|
|
if(disabled){
|
|
router.push('/food/recipe-view/'+_recipeId);
|
|
router.push('/food/recipe-view/'+_recipeId);
|
|
@@ -284,22 +279,7 @@ const handleUpdate = async (disabled:boolean,row?: RecipeVO) => {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-/** 提交按钮 */
|
|
|
|
-const submitForm = () => {
|
|
|
|
- recipeFormRef.value?.validate(async (valid: boolean) => {
|
|
|
|
- if (valid) {
|
|
|
|
- buttonLoading.value = true;
|
|
|
|
- if (form.value.recipeId) {
|
|
|
|
- await updateRecipe(form.value).finally(() => buttonLoading.value = false);
|
|
|
|
- } else {
|
|
|
|
- await addRecipe(form.value).finally(() => buttonLoading.value = false);
|
|
|
|
- }
|
|
|
|
- proxy?.$modal.msgSuccess("操作成功");
|
|
|
|
- dialog.visible = false;
|
|
|
|
- await getList();
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
-}
|
|
|
|
|
|
+
|
|
|
|
|
|
/** 查询食谱管理列表 */
|
|
/** 查询食谱管理列表 */
|
|
const getRecipeCategoryList = async () => {
|
|
const getRecipeCategoryList = async () => {
|
|
@@ -349,18 +329,57 @@ const handleRecipeCategoryDelete = async (row?: RecipeCategoryVO) => {
|
|
/** 删除按钮操作 */
|
|
/** 删除按钮操作 */
|
|
const handleDelete = async (row?: RecipeVO) => {
|
|
const handleDelete = async (row?: RecipeVO) => {
|
|
const _recipeIds = row?.recipeId || ids.value;
|
|
const _recipeIds = row?.recipeId || ids.value;
|
|
- await proxy?.$modal.confirm('是否确认删除食谱管理编号为"' + _recipeIds + '"的数据项?').finally(() => loading.value = false);
|
|
|
|
|
|
+ const _recipeNames = row?.name || idForNames.value;
|
|
|
|
+ await proxy?.$modal.confirm('是否确认删除食谱名称为"' + _recipeNames + '"的数据项?').finally(() => loading.value = false);
|
|
await delRecipe(_recipeIds);
|
|
await delRecipe(_recipeIds);
|
|
proxy?.$modal.msgSuccess("删除成功");
|
|
proxy?.$modal.msgSuccess("删除成功");
|
|
await getList();
|
|
await getList();
|
|
}
|
|
}
|
|
|
|
|
|
-/** 导出按钮操作 */
|
|
|
|
-const handleExport = () => {
|
|
|
|
- proxy?.download('system/recipe/export', {
|
|
|
|
- ...queryParams.value
|
|
|
|
- }, `recipe_${new Date().getTime()}.xlsx`)
|
|
|
|
-}
|
|
|
|
|
|
+
|
|
|
|
+const handleStatusChange = async (row: RecipeVO) => {
|
|
|
|
+ const text = row.smartRecommend === '0' ? '启用' : '停用';
|
|
|
|
+ try {
|
|
|
|
+ await proxy?.$modal.confirm('确认要"' + text + '""' + row.name + '"食谱吗?');
|
|
|
|
+ await changeRecipeStatus(row.recipeId, row.smartRecommend);
|
|
|
|
+ proxy?.$modal.msgSuccess(text + '成功');
|
|
|
|
+ } catch {
|
|
|
|
+ row.smartRecommend = row.smartRecommend === '0' ? '1' : '0';
|
|
|
|
+ }
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+const handleRecommend = async ( ) => {
|
|
|
|
+ const _recipeIds = ids.value.join(",");
|
|
|
|
+ const _recipeNames = idForNames.value;
|
|
|
|
+ const text = '启用' ;
|
|
|
|
+ try {
|
|
|
|
+ await proxy?.$modal.confirm('确认要"' + text + '""' + _recipeNames + '"食谱吗?');
|
|
|
|
+ await changeRecipeStatus(_recipeIds, '0');
|
|
|
|
+ idRows.value.forEach(item=>{
|
|
|
|
+ item.smartRecommend='0';
|
|
|
|
+ tableRef.value?.clearSelection();
|
|
|
|
+ })
|
|
|
|
+ proxy?.$modal.msgSuccess(text + '成功');
|
|
|
|
+ } catch {
|
|
|
|
+ }
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+const handleCancleRecommend = async ( ) => {
|
|
|
|
+ const _recipeIds = ids.value.join(",");
|
|
|
|
+ const _recipeNames = idForNames.value;
|
|
|
|
+ const text = '停用' ;
|
|
|
|
+ try {
|
|
|
|
+ await proxy?.$modal.confirm('确认要"' + text + '""' + _recipeNames + '"食谱吗?');
|
|
|
|
+ await changeRecipeStatus(_recipeIds, '1');
|
|
|
|
+ idRows.value.forEach(item=>{
|
|
|
|
+ item.smartRecommend='1';
|
|
|
|
+ tableRef.value?.clearSelection();
|
|
|
|
+ })
|
|
|
|
+ proxy?.$modal.msgSuccess(text + '成功');
|
|
|
|
+ } catch {
|
|
|
|
+ }
|
|
|
|
+};
|
|
|
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
getList();
|
|
getList();
|