diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/controller/FtCateringDaoController.java b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/controller/FtCateringDaoController.java index f23046c07..45eb82c28 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/controller/FtCateringDaoController.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/controller/FtCateringDaoController.java @@ -15,6 +15,7 @@ import com.ruoyi.system.fantang.service.IFtFoodDemandDaoService; import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import java.util.Arrays; @@ -76,40 +77,14 @@ public class FtCateringDaoController extends BaseController { @PreAuthorize("@ss.hasPermi('fantang:catering:add')") @Log(title = "配餐功能", businessType = BusinessType.INSERT) @PostMapping + @Transactional public AjaxResult add(@RequestBody FtCateringDao ftCateringDao) { - List 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); - // 如果属于加餐,新增一条病患配餐记录,否则修改 - if (type == 4) { - FtFoodDemandDao foodDemandDao = new FtFoodDemandDao(); - foodDemandDao.setPatientId(patientId); - foodDemandDao.setType(type); - foodDemandDao.setNutritionFoodId(ftCateringDao.getNumber()); - foodDemandDao.setCreateAt(new Date()); - foodDemandDao.setNutritionFoodFlag(0); - iFtFoodDemandDaoService.save(foodDemandDao); - } else { - QueryWrapper 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); - } - } + // 添加一个病人新增 4 条营养配餐记录 + List ftCateringList = iFtCateringDaoService.addNutritionCatering(ftCateringDao); + + // 更新病人报餐配置表 + iFtFoodDemandDaoService.updateDayFoodDemand(ftCateringList); return AjaxResult.success("新增成功"); } @@ -125,6 +100,7 @@ public class FtCateringDaoController extends BaseController { Long patientId = ftCateringDao.getPatientId(); Integer type = ftCateringDao.getType(); Long number = ftCateringDao.getNumber(); + Boolean flag = ftCateringDao.getFlag(); QueryWrapper wrapper = new QueryWrapper<>(); wrapper.eq("patient_id", patientId); @@ -132,6 +108,7 @@ public class FtCateringDaoController extends BaseController { FtFoodDemandDao foodDemandDao = iFtFoodDemandDaoService.getOne(wrapper); foodDemandDao.setNutritionFoodId(number); foodDemandDao.setUpdateAt(new Date()); + foodDemandDao.setNutritionFoodFlag(flag); iFtFoodDemandDaoService.updateById(foodDemandDao); return toAjax(iFtCateringDaoService.updateById(ftCateringDao) ? 1 : 0); @@ -144,6 +121,46 @@ public class FtCateringDaoController extends BaseController { @Log(title = "配餐功能", businessType = BusinessType.DELETE) @DeleteMapping("/{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 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; } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/controller/FtReportMealsDaoController.java b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/controller/FtReportMealsDaoController.java index 57cd886a8..e5803f479 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/controller/FtReportMealsDaoController.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/controller/FtReportMealsDaoController.java @@ -44,14 +44,11 @@ public class FtReportMealsDaoController extends BaseController { @GetMapping("/getLastSettlementDate/{patientId}") public AjaxResult getLastSettlementDate(@PathVariable("patientId") Long patientId) { - QueryWrapper wrapper = new QueryWrapper<>(); - wrapper.eq("patient_id", patientId); - wrapper.eq("settlement_flag", 1); - wrapper.orderByDesc("settlement_at"); - wrapper.last("limit 1"); - FtReportMealsDao ftReportMealsDao = iFtReportMealsDaoService.getOne(wrapper); - Date createAt = ftReportMealsDao.getCreateAt(); - Date settlementAt = ftReportMealsDao.getSettlementAt(); + // 获取最近一次已结算的报餐记录,如果首次结算则返回 + FtReportMealsDao reportMealsDao = iFtReportMealsDaoService.getLastReportMeals(patientId); + + Date createAt = reportMealsDao.getCreateAt(); + Date settlementAt = reportMealsDao.getSettlementAt(); ReportMealsDayEntity reportMealsDayEntity = new ReportMealsDayEntity(); if (settlementAt == null) { long betweenDays = DateUtil.between(createAt, new Date(), DateUnit.DAY); diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/domain/FtCateringDao.java b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/domain/FtCateringDao.java index 8079149c6..4dd8d668c 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/domain/FtCateringDao.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/domain/FtCateringDao.java @@ -1,5 +1,6 @@ package com.ruoyi.system.fantang.domain; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonFormat; @@ -12,6 +13,7 @@ import lombok.ToString; import lombok.experimental.Accessors; import java.util.Date; +import java.util.List; /** * 配餐功能对象 ft_catering @@ -41,6 +43,12 @@ public class FtCateringDao extends FtCateringVo { */ private Long patientId; + /** + * 病人 ids + */ + @TableField(exist = false) + private List patientIds; + /** * 正餐类型 */ diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/domain/FtFoodDemandDao.java b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/domain/FtFoodDemandDao.java index 832f53cd8..69f01de6b 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/domain/FtFoodDemandDao.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/domain/FtFoodDemandDao.java @@ -125,7 +125,7 @@ public class FtFoodDemandDao extends BasePatient implements Serializable { /** * 营养餐标志 **/ - private Integer nutritionFoodFlag; + private Boolean nutritionFoodFlag; /** * 营养餐名 diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/IFtCateringDaoService.java b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/IFtCateringDaoService.java index ea0d25782..f121ef18f 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/IFtCateringDaoService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/IFtCateringDaoService.java @@ -16,4 +16,10 @@ public interface IFtCateringDaoService extends IService { List listNewFormatter(FtCateringDao ftCateringDao); FtCateringDao getByIdNewFormatter(Long id); + + List addNutritionCatering(FtCateringDao ftCateringDao); + + Integer deleteByPatientId(Long[] ids); + + Integer cancelByPatientId(Long[] ids); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/IFtFoodDemandDaoService.java b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/IFtFoodDemandDaoService.java index 8bdd9e8a2..df3a5e41d 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/IFtFoodDemandDaoService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/IFtFoodDemandDaoService.java @@ -1,6 +1,7 @@ package com.ruoyi.system.fantang.service; 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.FtOrderDao; import com.ruoyi.system.fantang.domain.FtReportMealsDao; @@ -30,4 +31,8 @@ public interface IFtFoodDemandDaoService extends IService { List getStatisticsOfMonth(Date day); List getStatisticsFoodDemand(); + + Integer updateDayFoodDemand(List ftCateringList); + + Integer cancelNutritionByPatientId(Long[] ids); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/IFtReportMealsDaoService.java b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/IFtReportMealsDaoService.java index 994975b87..951a3c3cc 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/IFtReportMealsDaoService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/IFtReportMealsDaoService.java @@ -31,5 +31,7 @@ public interface IFtReportMealsDaoService extends IService { Integer settleMeals(Long settlementId, Long patientId, String lastBillingDate, String selectBillingDate); ReportMealsPriceEntity sumTotalPrice(Long patientId, Date lastBillingDate, Date selectBillingDate); + + FtReportMealsDao getLastReportMeals(Long patientId); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/impl/FtCateringDaoServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/impl/FtCateringDaoServiceImpl.java index d4062e160..cba6f9926 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/impl/FtCateringDaoServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/impl/FtCateringDaoServiceImpl.java @@ -1,11 +1,15 @@ 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.ruoyi.system.fantang.domain.FtCateringDao; import com.ruoyi.system.fantang.mapper.FtCateringDaoMapper; import com.ruoyi.system.fantang.service.IFtCateringDaoService; import org.springframework.stereotype.Service; +import java.util.ArrayList; +import java.util.Date; import java.util.List; /** @@ -26,4 +30,73 @@ public class FtCateringDaoServiceImpl extends ServiceImpl addNutritionCatering(FtCateringDao ftCateringDao) { + + List list = new ArrayList<>(); + + List types = ftCateringDao.getTypes(); + + List 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 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 wrapper = new UpdateWrapper<>(); + wrapper.eq("patient_id", id); + rows += this.baseMapper.update(ftCateringDao, wrapper); + } + + return rows; + } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/impl/FtFoodDemandDaoServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/impl/FtFoodDemandDaoServiceImpl.java index c0ea29bd5..50bea16cc 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/impl/FtFoodDemandDaoServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/impl/FtFoodDemandDaoServiceImpl.java @@ -1,7 +1,10 @@ package com.ruoyi.system.fantang.service.impl; 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.ruoyi.system.fantang.domain.FtCateringDao; import com.ruoyi.system.fantang.domain.FtFoodDemandDao; import com.ruoyi.system.fantang.domain.FtOrderDao; import com.ruoyi.system.fantang.domain.FtReportMealsDao; @@ -69,4 +72,44 @@ public class FtFoodDemandDaoServiceImpl extends ServiceImpl getStatisticsFoodDemand() { return this.baseMapper.getStatisticsFoodDemand(); } + + @Override + public Integer updateDayFoodDemand(List ftCateringList) { + + int rows = 0; + + Long patientId = ftCateringList.get(0).getPatientId(); + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("patient_id", patientId); + wrapper.orderByAsc("type"); + List 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 wrapper = new UpdateWrapper<>(); + wrapper.eq("patient_id", id); + rows += this.baseMapper.update(foodDemand, wrapper); + } + + return rows; + } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/impl/FtReportMealsDaoServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/impl/FtReportMealsDaoServiceImpl.java index b7a836a43..72e276d71 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/impl/FtReportMealsDaoServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/impl/FtReportMealsDaoServiceImpl.java @@ -1,5 +1,6 @@ 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.ruoyi.system.fantang.domain.FtReportMealsDao; 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.stereotype.Service; -import java.math.BigDecimal; import java.util.Date; import java.util.List; @@ -70,4 +70,31 @@ public class FtReportMealsDaoServiceImpl extends ServiceImpl 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 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; + } } diff --git a/ruoyi-ui/src/api/fantang/catering.js b/ruoyi-ui/src/api/fantang/catering.js index 95f685b09..814d68700 100644 --- a/ruoyi-ui/src/api/fantang/catering.js +++ b/ruoyi-ui/src/api/fantang/catering.js @@ -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) { 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) { return request({ @@ -50,4 +67,12 @@ export function exportCatering(query) { method: 'get', params: query }) -} \ No newline at end of file +} + +// 根据病人 id 查找 +export function getByPatient(id) { + return request({ + url: '/fantang/catering/getByPatient/' + id, + method: 'get' + }) +} diff --git a/ruoyi-ui/src/views/fantang/catering/index.vue b/ruoyi-ui/src/views/fantang/catering/index.vue index eb82ad4b2..81d701e71 100644 --- a/ruoyi-ui/src/views/fantang/catering/index.vue +++ b/ruoyi-ui/src/views/fantang/catering/index.vue @@ -101,7 +101,7 @@ icon="el-icon-delete" size="mini" :disabled="multiple" - @click="" + @click="handleCancel" v-hasPermi="['fantang:catering:remove']" >作废 @@ -134,7 +134,7 @@ icon="el-icon-delete" size="mini" :disabled="multiple" - @click="" + @click="handleCopyAndAdd" v-hasPermi="['fantang:catering:remove']" >拷贝并新增 @@ -188,15 +188,15 @@ - - - + + + - + @@ -300,15 +292,14 @@ - - - - - - - - - + + + + @@ -396,12 +387,118 @@ + + + + + + + + + + + + + + + + + + + + + {{ item.name }} + {{ item.bedId }} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -417,12 +514,26 @@ import { import {listDepart} from "@/api/fantang/depart"; import {getBedIdById, selectPatientByDepartId} from "@/api/fantang/patient"; import {listNutritionFood} from "@/api/fantang/nutritionFood"; +import {cancelCatering, copyAndAdd, getByPatient} from "../../../api/fantang/catering"; export default { name: "Catering", components: {}, data() { return { + frequencyOptions: [{ + value: 'qd', + label: 'qd' + }, { + value: 'bid', + label: 'bid' + }, { + value: 'tid', + label: 'tid' + }, { + value: 'qn', + label: 'qn' + }], // 配餐列表 numberOptions: [], // 用法列表 @@ -449,6 +560,7 @@ export default { loading: true, // 选中数组 ids: [], + names: [], // 非单个禁用 single: true, // 非多个禁用 @@ -465,6 +577,8 @@ export default { open: false, // 修改弹出层 modifyItem: false, + // 拷贝并新增弹出层 + copyItem: false, // 正餐类型字典 typeOptions: [], // 查询参数 @@ -479,8 +593,53 @@ export default { }, // 表单参数 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() { @@ -497,9 +656,25 @@ export default { }) }, 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 (rowIndex % 4 === 0) { return { @@ -537,7 +712,19 @@ export default { 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) { return { rowspan: 4, @@ -554,14 +741,20 @@ export default { // 响应营养配餐用餐安排多选列表 changeDinnerType(value) { - if (value.length === 1) + if (value.length === 1) { this.form.frequency = 'qd'; - else if (value.length === 2) + this.copyItemForm.frequency = 'qd'; + } else if (value.length === 2) { this.form.frequency = 'bid'; - else if (value.length === 3) + this.copyItemForm.frequency = 'bid'; + } else if (value.length === 3) { this.form.frequency = 'tid'; - else if (value.length === 4) + this.copyItemForm.frequency = 'tid'; + } else if (value.length === 4) { this.form.frequency = 'qn'; + this.copyItemForm.frequency = 'qn'; + } + }, // 响应科室信息切换 changeDepart(value) { @@ -571,12 +764,16 @@ export default { }, // 相应病人信息切换 changePatient(value) { - const _this = this; - getBedIdById(value).then(response => { - console.log("aaaaaaa", response); - _this.form.bedId = response.msg; - console.log(_this.form.bedId); - }) + setTimeout(() => { + getBedIdById(value).then(response => { + console.log("aaaaaaa", response); + console.log("value", value); + this.form.bedId = response.msg; + console.log('this.form.patientid', this.form.patientId) + }) + }, 200); + + console.log('this.form.patientid', this.form.patientId) }, /** 查询配餐功能列表 */ getList() { @@ -596,6 +793,7 @@ export default { cancel() { this.open = false; this.modifyItem = false; + this.copyItem = false; this.reset(); }, // 表单重置 @@ -616,6 +814,23 @@ export default { cateringDescribe: null }; 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() { @@ -629,7 +844,8 @@ export default { }, // 多选框选中数据 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.multiple = !selection.length }, @@ -650,6 +866,35 @@ export default { 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() { this.$refs["form"].validate(valid => { @@ -673,8 +918,9 @@ export default { }, /** 删除按钮操作 */ handleDelete(row) { - const ids = row.id || this.ids; - this.$confirm('是否确认删除配餐功能编号为"' + ids + '"的数据项?', "警告", { + const ids = row.patientId || this.ids; + console.log("ids-----", ids); + this.$confirm('是否确认删除 “' + this.names + '” 的营养配餐数据?', "警告", { confirmButtonText: "确定", cancelButtonText: "取消", type: "warning" @@ -685,6 +931,21 @@ export default { 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() { const queryParams = this.queryParams; diff --git a/ruoyi-ui/src/views/fantang/foodDemand/index.vue b/ruoyi-ui/src/views/fantang/foodDemand/index.vue index 1321778ed..347bcc275 100644 --- a/ruoyi-ui/src/views/fantang/foodDemand/index.vue +++ b/ruoyi-ui/src/views/fantang/foodDemand/index.vue @@ -82,7 +82,8 @@ - + @@ -95,8 +96,10 @@ - + +