todo:营养餐

This commit is contained in:
ryoeiken 2021-01-15 15:40:33 +08:00
parent a8a1b53794
commit c6f2967e70
13 changed files with 607 additions and 87 deletions

View File

@ -15,6 +15,7 @@ import com.ruoyi.system.fantang.service.IFtFoodDemandDaoService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.Arrays; import java.util.Arrays;
@ -76,40 +77,14 @@ public class FtCateringDaoController extends BaseController {
@PreAuthorize("@ss.hasPermi('fantang:catering:add')") @PreAuthorize("@ss.hasPermi('fantang:catering:add')")
@Log(title = "配餐功能", businessType = BusinessType.INSERT) @Log(title = "配餐功能", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
@Transactional
public AjaxResult add(@RequestBody FtCateringDao ftCateringDao) { public AjaxResult add(@RequestBody FtCateringDao ftCateringDao) {
List<Integer> types = ftCateringDao.getTypes();
for (Integer type : types) {
Long patientId = ftCateringDao.getPatientId();
FtCateringDao ftCatering = new FtCateringDao();
ftCatering.setPatientId(patientId);
ftCatering.setNumber(ftCateringDao.getNumber());
ftCatering.setFrequency(ftCateringDao.getFrequency());
ftCatering.setCateringUsage(ftCateringDao.getCateringUsage());
ftCatering.setFlag(true);
ftCatering.setCreateAt(new Date());
ftCatering.setType(type);
iFtCateringDaoService.save(ftCatering);
// 如果属于加餐新增一条病患配餐记录否则修改 // 添加一个病人新增 4 条营养配餐记录
if (type == 4) { List<FtCateringDao> ftCateringList = iFtCateringDaoService.addNutritionCatering(ftCateringDao);
FtFoodDemandDao foodDemandDao = new FtFoodDemandDao();
foodDemandDao.setPatientId(patientId); // 更新病人报餐配置表
foodDemandDao.setType(type); iFtFoodDemandDaoService.updateDayFoodDemand(ftCateringList);
foodDemandDao.setNutritionFoodId(ftCateringDao.getNumber());
foodDemandDao.setCreateAt(new Date());
foodDemandDao.setNutritionFoodFlag(0);
iFtFoodDemandDaoService.save(foodDemandDao);
} else {
QueryWrapper<FtFoodDemandDao> wrapper = new QueryWrapper<>();
wrapper.eq("patient_id", patientId);
wrapper.eq("type", type);
FtFoodDemandDao foodDemandDao = iFtFoodDemandDaoService.getOne(wrapper);
foodDemandDao.setNutritionFoodId(ftCateringDao.getNumber());
foodDemandDao.setUpdateAt(new Date());
foodDemandDao.setNutritionFoodFlag(0);
iFtFoodDemandDaoService.updateById(foodDemandDao);
}
}
return AjaxResult.success("新增成功"); return AjaxResult.success("新增成功");
} }
@ -125,6 +100,7 @@ public class FtCateringDaoController extends BaseController {
Long patientId = ftCateringDao.getPatientId(); Long patientId = ftCateringDao.getPatientId();
Integer type = ftCateringDao.getType(); Integer type = ftCateringDao.getType();
Long number = ftCateringDao.getNumber(); Long number = ftCateringDao.getNumber();
Boolean flag = ftCateringDao.getFlag();
QueryWrapper<FtFoodDemandDao> wrapper = new QueryWrapper<>(); QueryWrapper<FtFoodDemandDao> wrapper = new QueryWrapper<>();
wrapper.eq("patient_id", patientId); wrapper.eq("patient_id", patientId);
@ -132,6 +108,7 @@ public class FtCateringDaoController extends BaseController {
FtFoodDemandDao foodDemandDao = iFtFoodDemandDaoService.getOne(wrapper); FtFoodDemandDao foodDemandDao = iFtFoodDemandDaoService.getOne(wrapper);
foodDemandDao.setNutritionFoodId(number); foodDemandDao.setNutritionFoodId(number);
foodDemandDao.setUpdateAt(new Date()); foodDemandDao.setUpdateAt(new Date());
foodDemandDao.setNutritionFoodFlag(flag);
iFtFoodDemandDaoService.updateById(foodDemandDao); iFtFoodDemandDaoService.updateById(foodDemandDao);
return toAjax(iFtCateringDaoService.updateById(ftCateringDao) ? 1 : 0); return toAjax(iFtCateringDaoService.updateById(ftCateringDao) ? 1 : 0);
@ -144,6 +121,46 @@ public class FtCateringDaoController extends BaseController {
@Log(title = "配餐功能", businessType = BusinessType.DELETE) @Log(title = "配餐功能", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}") @DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) { public AjaxResult remove(@PathVariable Long[] ids) {
return toAjax(iFtCateringDaoService.removeByIds(Arrays.asList(ids)) ? 1 : 0); return AjaxResult.success(iFtCateringDaoService.deleteByPatientId(ids));
}
/**
* 作废营养配餐数据
*/
@PutMapping("/cancel/{ids}")
@Transactional
public AjaxResult cancel(@PathVariable Long[] ids) {
System.out.println(Arrays.toString(ids));
// 根据病人 id 修改营养配餐启用标志
iFtCateringDaoService.cancelByPatientId(ids);
// 根据病人 id 修改报餐配置表营养餐启用标志
iFtFoodDemandDaoService.cancelNutritionByPatientId(ids);
return AjaxResult.success("已作废");
}
/**
* 根据病人 id 查找营养配餐数据
*/
@GetMapping("/getByPatient/{patientId}")
public AjaxResult getByPatient(@PathVariable Long patientId) {
QueryWrapper<FtCateringDao> wrapper = new QueryWrapper<>();
wrapper.eq("patient_id", patientId);
wrapper.eq("type", 1);
return AjaxResult.success(iFtCateringDaoService.getOne(wrapper));
}
/**
* 拷贝并新增
*/
@PostMapping("/copyAndAdd")
public AjaxResult copyAndAdd(@RequestBody FtCateringDao ftCateringDao) {
System.out.println(ftCateringDao);
return null;
} }
} }

View File

@ -44,14 +44,11 @@ public class FtReportMealsDaoController extends BaseController {
@GetMapping("/getLastSettlementDate/{patientId}") @GetMapping("/getLastSettlementDate/{patientId}")
public AjaxResult getLastSettlementDate(@PathVariable("patientId") Long patientId) { public AjaxResult getLastSettlementDate(@PathVariable("patientId") Long patientId) {
QueryWrapper<FtReportMealsDao> wrapper = new QueryWrapper<>(); // 获取最近一次已结算的报餐记录如果首次结算则返回
wrapper.eq("patient_id", patientId); FtReportMealsDao reportMealsDao = iFtReportMealsDaoService.getLastReportMeals(patientId);
wrapper.eq("settlement_flag", 1);
wrapper.orderByDesc("settlement_at"); Date createAt = reportMealsDao.getCreateAt();
wrapper.last("limit 1"); Date settlementAt = reportMealsDao.getSettlementAt();
FtReportMealsDao ftReportMealsDao = iFtReportMealsDaoService.getOne(wrapper);
Date createAt = ftReportMealsDao.getCreateAt();
Date settlementAt = ftReportMealsDao.getSettlementAt();
ReportMealsDayEntity reportMealsDayEntity = new ReportMealsDayEntity(); ReportMealsDayEntity reportMealsDayEntity = new ReportMealsDayEntity();
if (settlementAt == null) { if (settlementAt == null) {
long betweenDays = DateUtil.between(createAt, new Date(), DateUnit.DAY); long betweenDays = DateUtil.between(createAt, new Date(), DateUnit.DAY);

View File

@ -1,5 +1,6 @@
package com.ruoyi.system.fantang.domain; package com.ruoyi.system.fantang.domain;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
@ -12,6 +13,7 @@ import lombok.ToString;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import java.util.Date; import java.util.Date;
import java.util.List;
/** /**
* 配餐功能对象 ft_catering * 配餐功能对象 ft_catering
@ -41,6 +43,12 @@ public class FtCateringDao extends FtCateringVo {
*/ */
private Long patientId; private Long patientId;
/**
* 病人 ids
*/
@TableField(exist = false)
private List<Long> patientIds;
/** /**
* 正餐类型 * 正餐类型
*/ */

View File

@ -125,7 +125,7 @@ public class FtFoodDemandDao extends BasePatient implements Serializable {
/** /**
* 营养餐标志 * 营养餐标志
**/ **/
private Integer nutritionFoodFlag; private Boolean nutritionFoodFlag;
/** /**
* 营养餐名 * 营养餐名

View File

@ -16,4 +16,10 @@ public interface IFtCateringDaoService extends IService<FtCateringDao> {
List<FtCateringDao> listNewFormatter(FtCateringDao ftCateringDao); List<FtCateringDao> listNewFormatter(FtCateringDao ftCateringDao);
FtCateringDao getByIdNewFormatter(Long id); FtCateringDao getByIdNewFormatter(Long id);
List<FtCateringDao> addNutritionCatering(FtCateringDao ftCateringDao);
Integer deleteByPatientId(Long[] ids);
Integer cancelByPatientId(Long[] ids);
} }

View File

@ -1,6 +1,7 @@
package com.ruoyi.system.fantang.service; package com.ruoyi.system.fantang.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.system.fantang.domain.FtCateringDao;
import com.ruoyi.system.fantang.domain.FtFoodDemandDao; import com.ruoyi.system.fantang.domain.FtFoodDemandDao;
import com.ruoyi.system.fantang.domain.FtOrderDao; import com.ruoyi.system.fantang.domain.FtOrderDao;
import com.ruoyi.system.fantang.domain.FtReportMealsDao; import com.ruoyi.system.fantang.domain.FtReportMealsDao;
@ -30,4 +31,8 @@ public interface IFtFoodDemandDaoService extends IService<FtFoodDemandDao> {
List<FtOrderDao> getStatisticsOfMonth(Date day); List<FtOrderDao> getStatisticsOfMonth(Date day);
List<FtReportMealsDao> getStatisticsFoodDemand(); List<FtReportMealsDao> getStatisticsFoodDemand();
Integer updateDayFoodDemand(List<FtCateringDao> ftCateringList);
Integer cancelNutritionByPatientId(Long[] ids);
} }

View File

@ -31,5 +31,7 @@ public interface IFtReportMealsDaoService extends IService<FtReportMealsDao> {
Integer settleMeals(Long settlementId, Long patientId, String lastBillingDate, String selectBillingDate); Integer settleMeals(Long settlementId, Long patientId, String lastBillingDate, String selectBillingDate);
ReportMealsPriceEntity sumTotalPrice(Long patientId, Date lastBillingDate, Date selectBillingDate); ReportMealsPriceEntity sumTotalPrice(Long patientId, Date lastBillingDate, Date selectBillingDate);
FtReportMealsDao getLastReportMeals(Long patientId);
} }

View File

@ -1,11 +1,15 @@
package com.ruoyi.system.fantang.service.impl; package com.ruoyi.system.fantang.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.system.fantang.domain.FtCateringDao; import com.ruoyi.system.fantang.domain.FtCateringDao;
import com.ruoyi.system.fantang.mapper.FtCateringDaoMapper; import com.ruoyi.system.fantang.mapper.FtCateringDaoMapper;
import com.ruoyi.system.fantang.service.IFtCateringDaoService; import com.ruoyi.system.fantang.service.IFtCateringDaoService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
@ -26,4 +30,73 @@ public class FtCateringDaoServiceImpl extends ServiceImpl<FtCateringDaoMapper, F
public FtCateringDao getByIdNewFormatter(Long id) { public FtCateringDao getByIdNewFormatter(Long id) {
return this.baseMapper.getByIdNewFormatter(id); return this.baseMapper.getByIdNewFormatter(id);
} }
@Override
public List<FtCateringDao> addNutritionCatering(FtCateringDao ftCateringDao) {
List<FtCateringDao> list = new ArrayList<>();
List<Integer> types = ftCateringDao.getTypes();
List<Long> patientIds = ftCateringDao.getPatientIds();
for (Long patientId : patientIds) {
for (int i = 1; i < 5; i++) {
FtCateringDao cateringDao = new FtCateringDao();
cateringDao.setPatientId(patientId);
cateringDao.setNumber(ftCateringDao.getNumber());
cateringDao.setFrequency(ftCateringDao.getFrequency());
cateringDao.setCateringUsage(ftCateringDao.getCateringUsage());
cateringDao.setCreateAt(new Date());
cateringDao.setType(i);
for (Integer type : types) {
if (i == type) {
cateringDao.setFlag(true);
break;
} else {
cateringDao.setFlag(false);
}
}
this.baseMapper.insert(cateringDao);
list.add(cateringDao);
}
}
return list;
}
@Override
public Integer deleteByPatientId(Long[] ids) {
int rows = 0;
for (Long id : ids) {
QueryWrapper<FtCateringDao> wrapper = new QueryWrapper<>();
wrapper.eq("patient_id", id);
rows += this.baseMapper.delete(wrapper);
}
return rows;
}
@Override
public Integer cancelByPatientId(Long[] ids) {
int rows = 0;
FtCateringDao ftCateringDao = new FtCateringDao();
ftCateringDao.setFlag(false);
ftCateringDao.setUpdateAt(new Date());
for (Long id : ids) {
UpdateWrapper<FtCateringDao> wrapper = new UpdateWrapper<>();
wrapper.eq("patient_id", id);
rows += this.baseMapper.update(ftCateringDao, wrapper);
}
return rows;
}
} }

View File

@ -1,7 +1,10 @@
package com.ruoyi.system.fantang.service.impl; package com.ruoyi.system.fantang.service.impl;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.system.fantang.domain.FtCateringDao;
import com.ruoyi.system.fantang.domain.FtFoodDemandDao; import com.ruoyi.system.fantang.domain.FtFoodDemandDao;
import com.ruoyi.system.fantang.domain.FtOrderDao; import com.ruoyi.system.fantang.domain.FtOrderDao;
import com.ruoyi.system.fantang.domain.FtReportMealsDao; import com.ruoyi.system.fantang.domain.FtReportMealsDao;
@ -69,4 +72,44 @@ public class FtFoodDemandDaoServiceImpl extends ServiceImpl<FtFoodDemandDaoMappe
public List<FtReportMealsDao> getStatisticsFoodDemand() { public List<FtReportMealsDao> getStatisticsFoodDemand() {
return this.baseMapper.getStatisticsFoodDemand(); return this.baseMapper.getStatisticsFoodDemand();
} }
@Override
public Integer updateDayFoodDemand(List<FtCateringDao> ftCateringList) {
int rows = 0;
Long patientId = ftCateringList.get(0).getPatientId();
QueryWrapper<FtFoodDemandDao> wrapper = new QueryWrapper<>();
wrapper.eq("patient_id", patientId);
wrapper.orderByAsc("type");
List<FtFoodDemandDao> foodDemandList = this.baseMapper.selectList(wrapper);
for (int i = 0; i < 4; i++) {
FtFoodDemandDao foodDemand = foodDemandList.get(i);
foodDemand.setNutritionFoodId(ftCateringList.get(i).getNumber());
foodDemand.setNutritionFoodFlag(ftCateringList.get(i).getFlag());
foodDemand.setUpdateAt(new Date());
rows += this.baseMapper.updateById(foodDemand);
}
return rows;
}
@Override
public Integer cancelNutritionByPatientId(Long[] ids) {
int rows = 0;
FtFoodDemandDao foodDemand = new FtFoodDemandDao();
foodDemand.setNutritionFoodFlag(false);
foodDemand.setUpdateAt(new Date());
for (Long id : ids) {
UpdateWrapper<FtFoodDemandDao> wrapper = new UpdateWrapper<>();
wrapper.eq("patient_id", id);
rows += this.baseMapper.update(foodDemand, wrapper);
}
return rows;
}
} }

View File

@ -1,5 +1,6 @@
package com.ruoyi.system.fantang.service.impl; package com.ruoyi.system.fantang.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.system.fantang.domain.FtReportMealsDao; import com.ruoyi.system.fantang.domain.FtReportMealsDao;
import com.ruoyi.system.fantang.entity.ReportMealsDayEntity; import com.ruoyi.system.fantang.entity.ReportMealsDayEntity;
@ -11,7 +12,6 @@ import com.ruoyi.system.fantang.vo.FtReportMealVo;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -70,4 +70,31 @@ public class FtReportMealsDaoServiceImpl extends ServiceImpl<FtReportMealsDaoMap
public ReportMealsPriceEntity sumTotalPrice(Long patientId, Date lastBillingDate, Date selectBillingDate) { public ReportMealsPriceEntity sumTotalPrice(Long patientId, Date lastBillingDate, Date selectBillingDate) {
return this.baseMapper.sumTotalPrice(patientId, lastBillingDate, selectBillingDate); return this.baseMapper.sumTotalPrice(patientId, lastBillingDate, selectBillingDate);
} }
@Override
public FtReportMealsDao getLastReportMeals(Long patientId) {
// 获取最近一条已结算的报餐记录
QueryWrapper<FtReportMealsDao> flag1Wrapper = new QueryWrapper<>();
flag1Wrapper.eq("patient_id", patientId);
flag1Wrapper.eq("settlement_flag", 1);
flag1Wrapper.orderByDesc("settlement_at");
flag1Wrapper.last("limit 1");
FtReportMealsDao flag1ReportMealsDao = this.baseMapper.selectOne(flag1Wrapper);
// 如果是首次结算
if (flag1ReportMealsDao == null) {
// 获取最近一条报餐
QueryWrapper<FtReportMealsDao> flag0Wrapper = new QueryWrapper<>();
flag0Wrapper.eq("patient_id", patientId);
flag0Wrapper.eq("settlement_flag", 1);
flag0Wrapper.orderByDesc("settlement_at");
flag0Wrapper.last("limit 0");
return this.baseMapper.selectOne(flag0Wrapper);
}
return flag1ReportMealsDao;
}
} }

View File

@ -26,6 +26,15 @@ export function addCatering(data) {
}) })
} }
// 拷贝并新增配餐功能
export function copyAndAdd(data) {
return request({
url: '/fantang/catering/copyAndAdd',
method: 'post',
data: data
})
}
// 修改配餐功能 // 修改配餐功能
export function updateCatering(data) { export function updateCatering(data) {
return request({ return request({
@ -43,6 +52,14 @@ export function delCatering(id) {
}) })
} }
// 作废
export function cancelCatering(id) {
return request({
url: '/fantang/catering/cancel/' + id,
method: 'put'
})
}
// 导出配餐功能 // 导出配餐功能
export function exportCatering(query) { export function exportCatering(query) {
return request({ return request({
@ -50,4 +67,12 @@ export function exportCatering(query) {
method: 'get', method: 'get',
params: query params: query
}) })
} }
// 根据病人 id 查找
export function getByPatient(id) {
return request({
url: '/fantang/catering/getByPatient/' + id,
method: 'get'
})
}

View File

@ -101,7 +101,7 @@
icon="el-icon-delete" icon="el-icon-delete"
size="mini" size="mini"
:disabled="multiple" :disabled="multiple"
@click="" @click="handleCancel"
v-hasPermi="['fantang:catering:remove']" v-hasPermi="['fantang:catering:remove']"
>作废 >作废
</el-button> </el-button>
@ -134,7 +134,7 @@
icon="el-icon-delete" icon="el-icon-delete"
size="mini" size="mini"
:disabled="multiple" :disabled="multiple"
@click="" @click="handleCopyAndAdd"
v-hasPermi="['fantang:catering:remove']" v-hasPermi="['fantang:catering:remove']"
>拷贝并新增 >拷贝并新增
</el-button> </el-button>
@ -188,15 +188,15 @@
<el-table-column label="配餐频次" align="center" prop="frequency"/> <el-table-column label="配餐频次" align="center" prop="frequency"/>
<el-table-column label="正餐类型" align="center" prop="type" :formatter="typeFormat"/> <el-table-column label="正餐类型" align="center" prop="type" :formatter="typeFormat"/>
<el-table-column label="营养配餐" align="center" prop="foodName"/> <el-table-column label="营养配餐" align="center" prop="foodName"/>
<el-table-column label="用法" align="center" prop="cateringUsage"/> <el-table-column label="用法" align="center" prop="cateringUsage" :formatter="cateringUsageFormat"/>
<el-table-column label="描述" align="center" prop="cateringDescribe"/> <!-- <el-table-column label="描述" align="center" prop="cateringDescribe"/>-->
<el-table-column label="启用标" align="center" prop="flag"/> <el-table-column label="启用标" align="center" prop="flag" :formatter="formatFlag"/>
<el-table-column label="创建时间" align="center" prop="createAt" width="180"> <el-table-column label="创建时间" align="center" prop="createAt" width="180">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ parseTime(scope.row.createAt, '{y}-{m}-{d}') }}</span> <span>{{ parseTime(scope.row.createAt, '{y}-{m}-{d}') }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="更新人" align="center" prop="updateBy"/> <!-- <el-table-column label="更新人" align="center" prop="updateBy"/>-->
<el-table-column label="操作" align="center" class-name="small-padding fixed-width"> <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button
@ -207,14 +207,6 @@
v-hasPermi="['fantang:catering:edit']" v-hasPermi="['fantang:catering:edit']"
>修改 >修改
</el-button> </el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['fantang:catering:remove']"
>删除
</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -300,15 +292,14 @@
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="配餐频次" prop="frequency"> <el-form-item label="配餐频次" prop="frequency">
<!-- <el-select v-model="form.frequency" placeholder="频次" :disabled="true">--> <el-select v-model="form.frequency" placeholder="请选择频次">
<!-- <el-option--> <el-option
<!-- v-for="item in frequencyOptions"--> v-for="item in frequencyOptions"
<!-- :key="item.label"--> :key="item.value"
<!-- :label="item.label"--> :label="item.label"
<!-- :value="item.label"--> :value="item.value">
<!-- ></el-option>--> </el-option>
<!-- </el-select>--> </el-select>
<el-input v-model="form.frequency" placeholder="频次"/>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
@ -396,12 +387,118 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row>
<el-col>
<el-form-item label="启用标志">
<el-switch
v-model="form.flag"
active-color="#13ce66"
inactive-color="#ff4949"
active-text="启用"
inactive-text="关闭">
</el-switch>
</el-form-item>
</el-col>
</el-row>
</el-form> </el-form>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button> <el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button> <el-button @click="cancel"> </el-button>
</div> </div>
</el-dialog> </el-dialog>
<!-- 拷贝并新增对话框 -->
<el-dialog :title="title" :visible.sync="copyItem" width="600px" append-to-body>
<el-form ref="copyItemForm" :model="copyItemForm" :rules="copyItemFormRules" label-width="80px">
<el-form-item label="科室" prop="departId">
<el-select v-model="copyItemForm.departId"
placeholder="请选择科室"
@change="changeDepart">
<el-option
v-for="item in departOptions"
:key="item.departName"
:label="item.departName"
:value="item.departId"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="病人" prop="patientIds">
<el-select v-model="copyItemForm.patientIds" placeholder="请选择病人" multiple>
<el-option
v-for="item in patientOptions"
:key="item.name"
:label="item.name"
:value="item.patientId"
>
<span style="float: left">{{ item.name }}</span>
<span style="float: right; color: #8492a6; font-size: 13px; margin-right:16px">{{ item.bedId }}</span>
</el-option>
</el-select>
</el-form-item>
<!-- <el-form-item label="床号" prop="bedId">-->
<!-- <el-input v-model="form.bedId" placeholder="床号" :disabled="true"/>-->
<!-- </el-form-item>-->
<el-row :gutter="10">
<el-col :span="12">
<el-form-item label="配餐号" prop="number">
<el-select v-model="copyItemForm.number" placeholder="请选择配餐号">
<el-option
v-for="item in numberOptions"
:key="item.name"
:label="item.name"
:value="item.id"
></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="用法" prop="cateringUsage">
<el-select v-model="copyItemForm.cateringUsage" placeholder="请选择用法">
<el-option
v-for="item in cateringUsageOptions"
:key="item.label"
:label="item.label"
:value="item.value"
></el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="10">
<el-col :span="12">
<el-form-item label="正餐类型" prop="types">
<el-select v-model="copyItemForm.types"
multiple
@change="changeDinnerType"
placeholder="请选择正餐类型">
<el-option
v-for="dict in typeOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="parseInt(dict.dictValue)"
></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="配餐频次" prop="frequency">
<el-select v-model="copyItemForm.frequency" placeholder="请选择频次">
<el-option
v-for="item in frequencyOptions"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitCopyForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div> </div>
</template> </template>
@ -417,12 +514,26 @@ import {
import {listDepart} from "@/api/fantang/depart"; import {listDepart} from "@/api/fantang/depart";
import {getBedIdById, selectPatientByDepartId} from "@/api/fantang/patient"; import {getBedIdById, selectPatientByDepartId} from "@/api/fantang/patient";
import {listNutritionFood} from "@/api/fantang/nutritionFood"; import {listNutritionFood} from "@/api/fantang/nutritionFood";
import {cancelCatering, copyAndAdd, getByPatient} from "../../../api/fantang/catering";
export default { export default {
name: "Catering", name: "Catering",
components: {}, components: {},
data() { data() {
return { return {
frequencyOptions: [{
value: 'qd',
label: 'qd'
}, {
value: 'bid',
label: 'bid'
}, {
value: 'tid',
label: 'tid'
}, {
value: 'qn',
label: 'qn'
}],
// //
numberOptions: [], numberOptions: [],
// //
@ -449,6 +560,7 @@ export default {
loading: true, loading: true,
// //
ids: [], ids: [],
names: [],
// //
single: true, single: true,
// //
@ -465,6 +577,8 @@ export default {
open: false, open: false,
// //
modifyItem: false, modifyItem: false,
//
copyItem: false,
// //
typeOptions: [], typeOptions: [],
// //
@ -479,8 +593,53 @@ export default {
}, },
// //
form: {}, form: {},
//
copyItemForm: {},
//
copyItemFormRules: {
departId: [
{required: true, message: "部门不能为空", trigger: "blur"}
],
patientIds: [
{required: true, message: "病人不能为空", trigger: "blur"}
],
types: [
{required: true, message: "正餐类型不能为空", trigger: "blur"}
],
cateringUsage: [
{required: true, message: "用法不能为空", trigger: "blur"}
],
frequency: [
{required: true, message: "频次不能为空", trigger: "blur"}
],
number: [
{required: true, message: "配餐号不能为空", trigger: "blur"}
],
},
// //
rules: {} rules: {
departId: [
{required: true, message: "部门不能为空", trigger: "blur"}
],
patientId: [
{required: true, message: "姓名不能为空", trigger: "blur"}
],
bedId: [
{required: true, message: "床号不能为空", trigger: "blur"}
],
types: [
{required: true, message: "正餐类型不能为空", trigger: "blur"}
],
cateringUsage: [
{required: true, message: "用法不能为空", trigger: "blur"}
],
frequency: [
{required: true, message: "频次不能为空", trigger: "blur"}
],
number: [
{required: true, message: "配餐号不能为空", trigger: "blur"}
],
}
}; };
}, },
created() { created() {
@ -497,9 +656,25 @@ export default {
}) })
}, },
methods: { methods: {
cateringUsageFormat(row) {
if (row.cateringUsage === 1 || row.cateringUsage === '1') {
return "鼻饲";
} else if (row.cateringUsage === 2 || row.cateringUsage === '2') {
return "口服";
} else {
return " ";
}
},
formatFlag(row) {
if (row.flag === true) {
return "启用";
} else if (row.flag === false) {
return "禁用";
}
},
// //
objectSpanMethod({row, column, rowIndex, columnIndex}) { objectSpanMethod({rowIndex, columnIndex}) {
if (columnIndex === 1) { if (columnIndex === 1) {
if (rowIndex % 4 === 0) { if (rowIndex % 4 === 0) {
return { return {
@ -537,7 +712,19 @@ export default {
colspan: 0 colspan: 0
}; };
} }
}else if (columnIndex === 4) { } else if (columnIndex === 4) {
if (rowIndex % 4 === 0) {
return {
rowspan: 4,
colspan: 1
};
} else {
return {
rowspan: 0,
colspan: 0
};
}
} else if (columnIndex === 0) {
if (rowIndex % 4 === 0) { if (rowIndex % 4 === 0) {
return { return {
rowspan: 4, rowspan: 4,
@ -554,14 +741,20 @@ export default {
// //
changeDinnerType(value) { changeDinnerType(value) {
if (value.length === 1) if (value.length === 1) {
this.form.frequency = 'qd'; this.form.frequency = 'qd';
else if (value.length === 2) this.copyItemForm.frequency = 'qd';
} else if (value.length === 2) {
this.form.frequency = 'bid'; this.form.frequency = 'bid';
else if (value.length === 3) this.copyItemForm.frequency = 'bid';
} else if (value.length === 3) {
this.form.frequency = 'tid'; this.form.frequency = 'tid';
else if (value.length === 4) this.copyItemForm.frequency = 'tid';
} else if (value.length === 4) {
this.form.frequency = 'qn'; this.form.frequency = 'qn';
this.copyItemForm.frequency = 'qn';
}
}, },
// //
changeDepart(value) { changeDepart(value) {
@ -571,12 +764,16 @@ export default {
}, },
// //
changePatient(value) { changePatient(value) {
const _this = this; setTimeout(() => {
getBedIdById(value).then(response => { getBedIdById(value).then(response => {
console.log("aaaaaaa", response); console.log("aaaaaaa", response);
_this.form.bedId = response.msg; console.log("value", value);
console.log(_this.form.bedId); this.form.bedId = response.msg;
}) console.log('this.form.patientid', this.form.patientId)
})
}, 200);
console.log('this.form.patientid', this.form.patientId)
}, },
/** 查询配餐功能列表 */ /** 查询配餐功能列表 */
getList() { getList() {
@ -596,6 +793,7 @@ export default {
cancel() { cancel() {
this.open = false; this.open = false;
this.modifyItem = false; this.modifyItem = false;
this.copyItem = false;
this.reset(); this.reset();
}, },
// //
@ -616,6 +814,23 @@ export default {
cateringDescribe: null cateringDescribe: null
}; };
this.resetForm("form"); this.resetForm("form");
this.copyItemForm = {
id: null,
patientId: null,
type: null,
number: null,
frequency: null,
cateringUsage: null,
isReplace: null,
flag: null,
updateAt: null,
updateBy: null,
createAt: null,
createBy: null,
cateringDescribe: null
};
this.resetForm("copyItemForm");
}, },
/** 搜索按钮操作 */ /** 搜索按钮操作 */
handleQuery() { handleQuery() {
@ -629,7 +844,8 @@ export default {
}, },
// //
handleSelectionChange(selection) { handleSelectionChange(selection) {
this.ids = selection.map(item => item.id) this.ids = selection.map(item => item.patientId)
this.names = selection.map(item => item.name);
this.single = selection.length !== 1 this.single = selection.length !== 1
this.multiple = !selection.length this.multiple = !selection.length
}, },
@ -650,6 +866,35 @@ export default {
this.title = "修改配餐"; this.title = "修改配餐";
}); });
}, },
//
handleCopyAndAdd(row) {
this.reset();
const id = row.id || this.ids;
if (this.ids.length > 1) {
this.msgError("只能选择一条记录进行拷贝并新增")
} else {
getByPatient(id).then(response => {
console.log(response.data)
this.copyItemForm.cateringUsage = response.data.cateringUsage;
this.copyItemForm.frequency = response.data.frequency;
this.copyItemForm.number = response.data.number;
this.copyItem = true;
})
}
},
/** 拷贝并新增提交按钮 */
submitCopyForm() {
this.$refs["copyItemForm"].validate(valid => {
if (valid) {
console.log(this.copyItemForm);
copyAndAdd(this.copyItemForm).then(response => {
this.msgSuccess("新增成功");
this.copyItem = false;
this.getList();
})
}
})
},
/** 提交按钮 */ /** 提交按钮 */
submitForm() { submitForm() {
this.$refs["form"].validate(valid => { this.$refs["form"].validate(valid => {
@ -673,8 +918,9 @@ export default {
}, },
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
const ids = row.id || this.ids; const ids = row.patientId || this.ids;
this.$confirm('是否确认删除配餐功能编号为"' + ids + '"的数据项?', "警告", { console.log("ids-----", ids);
this.$confirm('是否确认删除 “' + this.names + '” 的营养配餐数据?', "警告", {
confirmButtonText: "确定", confirmButtonText: "确定",
cancelButtonText: "取消", cancelButtonText: "取消",
type: "warning" type: "warning"
@ -685,6 +931,21 @@ export default {
this.msgSuccess("删除成功"); this.msgSuccess("删除成功");
}) })
}, },
//
handleCancel(row) {
const ids = row.patientId || this.ids;
console.log("ids-----", ids);
this.$confirm('是否作废 “' + this.names + '” 的营养配餐数据?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function () {
return cancelCatering(ids);
}).then(() => {
this.getList();
this.msgSuccess("已作废");
})
},
/** 导出按钮操作 */ /** 导出按钮操作 */
handleExport() { handleExport() {
const queryParams = this.queryParams; const queryParams = this.queryParams;

View File

@ -82,7 +82,8 @@
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row> </el-row>
<el-table v-loading="loading" :data="foodDemandList" @selection-change="handleSelectionChange" border> <el-table v-loading="loading" :data="foodDemandList" @selection-change="handleSelectionChange"
:span-method="objectSpanMethod" border>
<!-- <el-table-column type="selection" width="55" align="center"/>--> <!-- <el-table-column type="selection" width="55" align="center"/>-->
<el-table-column label="id" align="center" prop="id" v-if="false"/> <el-table-column label="id" align="center" prop="id" v-if="false"/>
<!-- <el-table-column label="住院号" align="center" prop="hospitalId"/>--> <!-- <el-table-column label="住院号" align="center" prop="hospitalId"/>-->
@ -95,8 +96,10 @@
<el-table-column label="加肉" align="center" prop="meat" width="80px" :formatter="formatMeat"/> <el-table-column label="加肉" align="center" prop="meat" width="80px" :formatter="formatMeat"/>
<el-table-column label="加饭" align="center" prop="rice" width="80px" :formatter="formatRice"/> <el-table-column label="加饭" align="center" prop="rice" width="80px" :formatter="formatRice"/>
<el-table-column label="加蛋" align="center" prop="egg" width="80px"/> <el-table-column label="加蛋" align="center" prop="egg" width="80px"/>
<el-table-column label="营养配餐" align="center" prop="nutritionFood" width="120px"/>
<el-table-column label="启用状态" align="center" prop="flag" width="80px" :formatter="formatFlag"/> <el-table-column label="启用状态" align="center" prop="flag" width="80px" :formatter="formatFlag"/>
<el-table-column label="营养配餐" align="center" prop="nutritionFood" width="130px"/>
<el-table-column label="营养配餐启用状态" align="center" prop="nutritionFoodFlag" width="130px"
:formatter="formatNutritionFoodFlag"/>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width"> <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button
@ -116,6 +119,7 @@
:total="total" :total="total"
:page.sync="queryParams.pageNum" :page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize" :limit.sync="queryParams.pageSize"
:page-sizes="[12, 24]"
@pagination="getList" @pagination="getList"
/> />
@ -237,7 +241,7 @@ export default {
// //
queryParams: { queryParams: {
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 12,
flag: null, flag: null,
name: null, name: null,
bedId: null, bedId: null,
@ -275,6 +279,48 @@ export default {
}); });
}, },
methods: { methods: {
//
objectSpanMethod({rowIndex, columnIndex}) {
if (columnIndex === 1) {
if (rowIndex % 4 === 0) {
return {
rowspan: 4,
colspan: 1
};
} else {
return {
rowspan: 0,
colspan: 0
};
}
} else if (columnIndex === 2) {
if (rowIndex % 4 === 0) {
return {
rowspan: 4,
colspan: 1
};
} else {
return {
rowspan: 0,
colspan: 0
};
}
} else if (columnIndex === 0) {
if (rowIndex % 4 === 0) {
return {
rowspan: 4,
colspan: 1
};
} else {
return {
rowspan: 0,
colspan: 0
};
}
}
},
formatFlag(row) { formatFlag(row) {
if (row.flag === true) { if (row.flag === true) {
return "启用"; return "启用";
@ -284,6 +330,15 @@ export default {
return ""; return "";
} }
}, },
formatNutritionFoodFlag(row) {
if (row.nutritionFoodFlag === true) {
return "启用";
} else if (row.nutritionFoodFlag === false) {
return "禁用";
} else {
return " ";
}
},
// //
formatFoods(row) { formatFoods(row) {
const _this = this; const _this = this;
@ -368,7 +423,8 @@ export default {
rice: null, rice: null,
egg: null, egg: null,
orderInfo: null, orderInfo: null,
flag: null flag: null,
nutritionFoodFlag: null,
}; };
this.resetForm("form"); this.resetForm("form");
}, },