|
@@ -1,62 +1,48 @@
|
|
|
<template>
|
|
|
<div class="nutrition-table">
|
|
|
<!-- 停嘱日期 (仅长期医嘱显示) -->
|
|
|
- <div v-if="type === 'long-term'" class="stop-date">
|
|
|
+ <div class="stop-date">
|
|
|
<span class="required">*</span>
|
|
|
<span class="label">停嘱日期</span>
|
|
|
- <el-date-picker v-model="stopDate" type="date" placeholder="请选择" format="YYYY-MM-DD" value-format="YYYY-MM-DD" />
|
|
|
- <span class="days">(使用天数:0天)</span>
|
|
|
+ <el-date-picker v-model="stopDate" type="date" placeholder="请选择" format="YYYY-MM-DD" value-format="YYYY-MM-DD" :clearable="false"
|
|
|
+ @change="handleStopDateChange" :disabled-date="disabledBeforeToday"/>
|
|
|
+ <span class="days">(使用天数:{{daysDifference}}天)</span>
|
|
|
</div>
|
|
|
|
|
|
<el-table :data="tableData" border>
|
|
|
<el-table-column type="index" label="组号" width="60" align="center" />
|
|
|
<el-table-column label="营养产品" min-width="300">
|
|
|
<template #default="{row}">
|
|
|
- <div class="product-group">
|
|
|
- <template v-if="!row.isNewRow">
|
|
|
+ <div class="product-group">
|
|
|
<div v-for="(product, index) in row.products" :key="index" class="product-row">
|
|
|
- <el-input v-model="product.value" placeholder="请输入" />
|
|
|
+ <el-select v-model="product.nutritionProductId" placeholder="请选择" @change="changeProductSelect">
|
|
|
+ <el-option v-for="pn in productNutritionList" :key="pn.id" :label="pn.productName"
|
|
|
+ :value="pn.id + '_' + row.sn + '_' + index"></el-option>
|
|
|
+ </el-select>
|
|
|
<div class="action-buttons">
|
|
|
<el-button class="icon-btn" @click="addProduct(row)">
|
|
|
- <el-icon><Plus /></el-icon>
|
|
|
+ <el-icon>
|
|
|
+ <Plus />
|
|
|
+ </el-icon>
|
|
|
</el-button>
|
|
|
<el-button class="icon-btn" @click="removeProduct(row, index)">
|
|
|
- <el-icon><Delete /></el-icon>
|
|
|
+ <el-icon>
|
|
|
+ <Delete />
|
|
|
+ </el-icon>
|
|
|
</el-button>
|
|
|
</div>
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- <template v-else>
|
|
|
- <div v-for="(product, index) in row.products" :key="index" class="product-row">
|
|
|
- <el-input v-model="product.value" placeholder="请选择" />
|
|
|
- <div class="action-buttons">
|
|
|
- <el-button class="icon-btn" @click="addProduct(row)">
|
|
|
- <el-icon><Plus /></el-icon>
|
|
|
- </el-button>
|
|
|
- <el-button class="icon-btn" @click="removeProduct(row, index)">
|
|
|
- <el-icon><Delete /></el-icon>
|
|
|
- </el-button>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </template>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column label="用量/次" width="150" align="center">
|
|
|
<template #default="{row}">
|
|
|
<div class="dosage-group">
|
|
|
- <template v-if="!row.isNewRow">
|
|
|
- <div v-for="(product, index) in row.products" :key="index" class="dosage-input">
|
|
|
- <el-input v-model="product.dosage" placeholder="请输入" class="input-center" />
|
|
|
- <span class="unit">g</span>
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- <template v-else>
|
|
|
- <div v-for="(product, index) in row.products" :key="index" class="dosage-input">
|
|
|
- <el-input v-model="product.dosage" placeholder="请输入" class="input-center" />
|
|
|
- <span class="unit">g</span>
|
|
|
- </div>
|
|
|
- </template>
|
|
|
+ <div v-for="(product, index) in row.products" :key="index" class="dosage-input">
|
|
|
+ <el-input v-model="product.dosePerTime" placeholder="请输入" class="input-center"
|
|
|
+ @input="dosePerTimeInput(product.dosePerTime,row.sn+'_'+index)"/>
|
|
|
+ <span class="unit">g</span>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
@@ -65,98 +51,138 @@
|
|
|
<div class="time-slots">
|
|
|
<div class="time-row">
|
|
|
<div class="time-group">
|
|
|
- <el-checkbox v-model="row.timeSlots[0].checked" />
|
|
|
- <el-time-select
|
|
|
- v-model="row.timeSlots[0].time"
|
|
|
- start="06:00"
|
|
|
- step="00:30"
|
|
|
- end="22:00"
|
|
|
- placeholder="选择时间"
|
|
|
- :disabled="!row.timeSlots[0].checked"
|
|
|
- />
|
|
|
+ <el-checkbox v-model="row.timeSlots[0].checked" @change="changeTimeSelection(row.timeSlots[0].checked,row.sn)"/>
|
|
|
+ <el-time-select v-model="row.timeSlots[0].time" start="00:00" step="00:30" end="23:30"
|
|
|
+ placeholder="选择时间" :disabled="!row.timeSlots[0].checked"
|
|
|
+ />
|
|
|
</div>
|
|
|
<div class="time-group">
|
|
|
- <el-checkbox v-model="row.timeSlots[1].checked" />
|
|
|
- <el-time-select
|
|
|
- v-model="row.timeSlots[1].time"
|
|
|
- start="06:00"
|
|
|
- step="00:30"
|
|
|
- end="22:00"
|
|
|
- placeholder="选择时间"
|
|
|
- :disabled="!row.timeSlots[1].checked"
|
|
|
- />
|
|
|
+ <el-checkbox v-model="row.timeSlots[1].checked" @change="changeTimeSelection(row.timeSlots[1].checked,row.sn)"/>
|
|
|
+ <el-time-select v-model="row.timeSlots[1].time" start="00:00" step="00:30" end="23:30"
|
|
|
+ placeholder="选择时间" :disabled="!row.timeSlots[1].checked"
|
|
|
+ />
|
|
|
</div>
|
|
|
<div class="time-group">
|
|
|
- <el-checkbox v-model="row.timeSlots[2].checked" />
|
|
|
- <el-time-select
|
|
|
- v-model="row.timeSlots[2].time"
|
|
|
- start="06:00"
|
|
|
- step="00:30"
|
|
|
- end="22:00"
|
|
|
- placeholder="选择时间"
|
|
|
- :disabled="!row.timeSlots[2].checked"
|
|
|
- />
|
|
|
+ <el-checkbox v-model="row.timeSlots[2].checked" @change="changeTimeSelection(row.timeSlots[2].checked,row.sn)"/>
|
|
|
+ <el-time-select v-model="row.timeSlots[2].time" start="00:00" step="00:30" end="23:30"
|
|
|
+ placeholder="选择时间" :disabled="!row.timeSlots[2].checked"
|
|
|
+ />
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="time-row">
|
|
|
<div class="time-group">
|
|
|
- <el-checkbox v-model="row.timeSlots[3].checked" />
|
|
|
- <el-time-select
|
|
|
- v-model="row.timeSlots[3].time"
|
|
|
- start="06:00"
|
|
|
- step="00:30"
|
|
|
- end="22:00"
|
|
|
- placeholder="选择时间"
|
|
|
- :disabled="!row.timeSlots[3].checked"
|
|
|
- />
|
|
|
+ <el-checkbox v-model="row.timeSlots[3].checked" @change="changeTimeSelection(row.timeSlots[3].checked,row.sn)"/>
|
|
|
+ <el-time-select v-model="row.timeSlots[3].time" start="00:00" step="00:30" end="23:30"
|
|
|
+ placeholder="选择时间" :disabled="!row.timeSlots[3].checked"
|
|
|
+ />
|
|
|
</div>
|
|
|
<div class="time-group">
|
|
|
- <el-checkbox v-model="row.timeSlots[4].checked" />
|
|
|
- <el-time-select
|
|
|
- v-model="row.timeSlots[4].time"
|
|
|
- start="06:00"
|
|
|
- step="00:30"
|
|
|
- end="22:00"
|
|
|
- placeholder="选择时间"
|
|
|
- :disabled="!row.timeSlots[4].checked"
|
|
|
- />
|
|
|
+ <el-checkbox v-model="row.timeSlots[4].checked" @change="changeTimeSelection(row.timeSlots[4].checked,row.sn)"/>
|
|
|
+ <el-time-select v-model="row.timeSlots[4].time" start="00:00" step="00:30" end="23:30"
|
|
|
+ placeholder="选择时间" :disabled="!row.timeSlots[4].checked"
|
|
|
+ />
|
|
|
</div>
|
|
|
<div class="time-group">
|
|
|
- <el-checkbox v-model="row.timeSlots[5].checked" />
|
|
|
- <el-time-select
|
|
|
- v-model="row.timeSlots[5].time"
|
|
|
- start="06:00"
|
|
|
- step="00:30"
|
|
|
- end="22:00"
|
|
|
- placeholder="选择时间"
|
|
|
- :disabled="!row.timeSlots[5].checked"
|
|
|
- />
|
|
|
+ <el-checkbox v-model="row.timeSlots[5].checked" @change="changeTimeSelection(row.timeSlots[5].checked,row.sn)"/>
|
|
|
+ <el-time-select v-model="row.timeSlots[5].time" start="00:00" step="00:30" end="23:30"
|
|
|
+ placeholder="选择时间" :disabled="!row.timeSlots[5].checked"
|
|
|
+ />
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column label="频次" width="120" align="center">
|
|
|
- <template #default>
|
|
|
- <span>一天3次</span>
|
|
|
+ <template #default="{row}">
|
|
|
+ <span>一天{{row.frequency}}次</span>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
+
|
|
|
+ <el-table-column label="首日" width="150" align="center">
|
|
|
+ <template #default="{row}">
|
|
|
+ <el-input v-model="row.firstDay" @input="firstDayInput(row.firstDay,row.sn)">
|
|
|
+ <template #append>次</template>
|
|
|
+ </el-input>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+
|
|
|
<el-table-column label="用量/日" width="150" align="center">
|
|
|
+ <template #default="{row}">
|
|
|
+ <div class="daily-dosage" v-for="(product, index) in row.products" :key="index">
|
|
|
+ <span>{{product.dosePerDay }}</span>
|
|
|
+ <span class="unit">{{ product.productSpecUnit }}</span>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+
|
|
|
+ <el-table-column label="规格" width="100" align="center">
|
|
|
+ <template #default="{row}">
|
|
|
+ <div class="daily-dosage" v-for="(product, index) in row.products" :key="index">
|
|
|
+ <span>{{product.specification }}</span>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+
|
|
|
+ <el-table-column label="用法" width="150" align="center">
|
|
|
+ <template #default="{row}">
|
|
|
+ <el-select v-model="row.usage" placeholder="请选择" @change="changeUsage(row.usage,row.sn)">
|
|
|
+ <el-option v-for="dict in default_usage" :key="dict.value" :label="dict.label"
|
|
|
+ :value="dict.value"></el-option>
|
|
|
+ </el-select>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+
|
|
|
+ <el-table-column label="制剂液量/次" width="170" align="center">
|
|
|
+ <template #default="{row}">
|
|
|
+ <el-input v-model="row.preparationVolumePerTime" @change="changePreparationVolumePerTime(row.preparationVolumePerTime,row.sn)">
|
|
|
+ <template #append>ml</template>
|
|
|
+ </el-input>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+
|
|
|
+ <el-table-column label="制剂浓度/次" width="100" align="center">
|
|
|
<template #default="{row}">
|
|
|
<div class="daily-dosage">
|
|
|
- <span>{{ row.dailyDosage }}</span>
|
|
|
- <span class="unit">袋</span>
|
|
|
+ <span>{{ row.preparationConcentrationPerTime }}</span>
|
|
|
+ <span class="unit">%</span>
|
|
|
</div>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column label="使用天数" width="120" align="center">
|
|
|
+
|
|
|
+ <el-table-column label="能量密度/次" width="200" align="center">
|
|
|
+ <template #default="{row}">
|
|
|
+ <el-input v-model="row.energyDensityPerTime" @change="changeEnergyDensityPerTime(row.energyDensityPerTime,row.sn)">
|
|
|
+ <template #append>kcal/ml</template>
|
|
|
+ </el-input>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+
|
|
|
+ <el-table-column label="处方备注" width="200" align="center">
|
|
|
<template #default="{row}">
|
|
|
- <div class="days">
|
|
|
- <span>{{ row.days }}</span>
|
|
|
- <span class="unit">天</span>
|
|
|
+ <template v-for="(product, index) in row.products" >
|
|
|
+ <el-input v-model="product.prescriptionRemark" :maxlength="100" :show-word-limit="true"
|
|
|
+ @change="changePrescriptionRemark(product.prescriptionRemark,row.sn)"/>
|
|
|
+ </template>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+
|
|
|
+ <el-table-column label="每日热量" width="100" align="center">
|
|
|
+ <template #default="{row}">
|
|
|
+ <div class="daily-dosage" v-for="(product, index) in row.products" :key="index">
|
|
|
+ <span>{{product.dailyCalories }}</span>
|
|
|
</div>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
+
|
|
|
+
|
|
|
+ <el-table-column label="金额" width="100" align="center">
|
|
|
+ <template #default="{row}">
|
|
|
+ <div class="daily-dosage" v-for="(product, index) in row.products" :key="index">
|
|
|
+ <span>{{product.amount }}</span>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+
|
|
|
<el-table-column label="操作" width="160" align="center" fixed="right">
|
|
|
<template #default="{$index}">
|
|
|
<div class="operation-cell">
|
|
@@ -168,7 +194,9 @@
|
|
|
</el-table>
|
|
|
<div class="table-footer">
|
|
|
<el-button type="primary" class="add-prescription-btn" @click="addNewRow">
|
|
|
- <el-icon><CirclePlus /></el-icon>
|
|
|
+ <el-icon>
|
|
|
+ <CirclePlus />
|
|
|
+ </el-icon>
|
|
|
开具多处方
|
|
|
</el-button>
|
|
|
</div>
|
|
@@ -178,65 +206,104 @@
|
|
|
<script setup lang="ts">
|
|
|
import {ref, defineProps} from 'vue';
|
|
|
import {Plus, Delete, CirclePlus} from '@element-plus/icons-vue';
|
|
|
+import { listEnteralNutrition, getEnteralNutrition, delEnteralNutrition, addEnteralNutrition, updateEnteralNutrition } from '@/api/patients/nutrition';
|
|
|
+import { EnteralNutritionVO, EnteralNutritionQuery, EnteralNutritionForm } from '@/api/patients/nutrition/types';
|
|
|
+import { listNutrition, listAllNutrition } from '@/api/warehouse/productNutrition/index';
|
|
|
+import { NutritionVO, NutritionQuery, NutritionForm } from '@/api/warehouse/productNutrition/types';
|
|
|
+
|
|
|
+const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
|
|
+const { default_usage } = toRefs < any > (proxy ?.useDict('default_usage'));
|
|
|
+
|
|
|
+let productNutritionList=ref<NutritionVO[]>([]);
|
|
|
+let tableId=ref<number>(0);
|
|
|
+
|
|
|
+const prop=defineProps({
|
|
|
+ prescriptionDate: {
|
|
|
+ type: String,
|
|
|
+ default: () => undefined
|
|
|
+ },
|
|
|
+});
|
|
|
|
|
|
-const props = defineProps<{
|
|
|
- type?: 'normal' | 'long-term';
|
|
|
-}>();
|
|
|
+const emit = defineEmits(['change']);
|
|
|
|
|
|
// 停嘱日期
|
|
|
const stopDate = ref('');
|
|
|
+const daysDifference = ref(0);
|
|
|
|
|
|
interface TimeSlot {
|
|
|
checked: boolean;
|
|
|
time: string;
|
|
|
}
|
|
|
|
|
|
-interface Product {
|
|
|
- value: string;
|
|
|
- dosage: string;
|
|
|
-}
|
|
|
-
|
|
|
-interface TableRow {
|
|
|
- products: Product[];
|
|
|
+interface TableRow extends EnteralNutritionForm {
|
|
|
+ products: EnteralNutritionForm[];
|
|
|
timeSlots: TimeSlot[];
|
|
|
- dailyDosage: number;
|
|
|
- days: number;
|
|
|
- isNewRow?: boolean;
|
|
|
+ sn: number;
|
|
|
+ tableId: number;
|
|
|
}
|
|
|
|
|
|
// 创建默认行数据的函数
|
|
|
-const createDefaultRow = (isNew: boolean = false): TableRow => ({
|
|
|
- products: isNew
|
|
|
- ? [{value: '', dosage: ''}]
|
|
|
- : [
|
|
|
- {value: '', dosage: ''},
|
|
|
- {value: '', dosage: ''},
|
|
|
- {value: '', dosage: ''}
|
|
|
- ],
|
|
|
+const createDefaultRow = (): TableRow => ({
|
|
|
+ products: [{specification:'',totalDose:'',dosePerDay:''}],
|
|
|
timeSlots: [
|
|
|
- {checked: false, time: '08:00'},
|
|
|
+ {checked: true, time: '08:00'},
|
|
|
{checked: false, time: '08:30'},
|
|
|
- {checked: false, time: '12:00'},
|
|
|
+ {checked: true, time: '12:00'},
|
|
|
{checked: false, time: '12:30'},
|
|
|
- {checked: false, time: '18:00'},
|
|
|
+ {checked: true, time: '18:00'},
|
|
|
{checked: false, time: '18:30'}
|
|
|
],
|
|
|
- dailyDosage: 2.0,
|
|
|
- days: 1,
|
|
|
- isNewRow: isNew
|
|
|
+ usageDays:0,
|
|
|
+ frequency:3,
|
|
|
+ firstDay:2,
|
|
|
+ sn:0,
|
|
|
+ tableId:tableId.value++,
|
|
|
});
|
|
|
|
|
|
// 示例数据
|
|
|
-const tableData = ref<TableRow[]>([createDefaultRow(), createDefaultRow()]);
|
|
|
+const tableData = ref<TableRow[]>([createDefaultRow()]);
|
|
|
+
|
|
|
+
|
|
|
+const changeProductSelect = async (id: string) => {
|
|
|
+ let arr=id.split('_');
|
|
|
+ for (let item of productNutritionList.value) {
|
|
|
+ if (item.id.toString() != arr[0]) {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+ let row = tableData.value[Number(arr[1])];
|
|
|
+ let pt = row.products[Number(arr[2])];
|
|
|
+ pt.specification=item.productSpec;
|
|
|
+ pt.dosePerTime=null;
|
|
|
+ pt.dailyCalories=null;
|
|
|
+ pt.productSpecUnit=item.productSpecUnit;
|
|
|
+ pt.amount=null;
|
|
|
+ row.usage=item.defaultUsage;
|
|
|
+ pt.totalDose='0' ;
|
|
|
+ pt.dosePerDay='0';
|
|
|
+ pt.firstDay=Math.ceil(row.frequency/2.0);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ emit('change',JSON.stringify(tableData.value))
|
|
|
+};
|
|
|
+
|
|
|
+const getProductNutritionList = async () => {
|
|
|
+ const res = await listAllNutrition();
|
|
|
+ productNutritionList.value = res.rows;
|
|
|
+}
|
|
|
|
|
|
// 新增行
|
|
|
const addNewRow = () => {
|
|
|
- tableData.value.push(createDefaultRow(true));
|
|
|
+ let row: TableRow = createDefaultRow();
|
|
|
+ row.sn = tableData.value.length ;
|
|
|
+ tableData.value.push(row);
|
|
|
+ emit('change',JSON.stringify(tableData.value))
|
|
|
};
|
|
|
|
|
|
// 新增产品输入框
|
|
|
const addProduct = (row: TableRow) => {
|
|
|
- row.products.push({value: '', dosage: ''});
|
|
|
+ row.products.push({});
|
|
|
};
|
|
|
|
|
|
// 删除产品输入框
|
|
@@ -247,35 +314,213 @@ const removeProduct = (row: TableRow, index: number) => {
|
|
|
if (rowIndex !== -1) {
|
|
|
tableData.value.splice(rowIndex, 1);
|
|
|
}
|
|
|
+ emit('change',JSON.stringify(tableData.value))
|
|
|
} else {
|
|
|
// 否则只删除当前输入框
|
|
|
row.products.splice(index, 1);
|
|
|
}
|
|
|
};
|
|
|
-
|
|
|
-// 选择产品
|
|
|
-const selectProduct = (row: TableRow, index: number) => {
|
|
|
- // TODO: 实现产品选择逻辑
|
|
|
- console.log('选择产品', row, index);
|
|
|
-};
|
|
|
-
|
|
|
-// 删除产品
|
|
|
-const deleteProduct = (row: TableRow, index: number) => {
|
|
|
- // TODO: 实现产品删除逻辑
|
|
|
- console.log('删除产品', row, index);
|
|
|
-};
|
|
|
+
|
|
|
|
|
|
// 复制行
|
|
|
const copyRow = (index: number) => {
|
|
|
const newRow = JSON.parse(JSON.stringify(tableData.value[index]));
|
|
|
+ newRow.tableId = tableId.value++
|
|
|
tableData.value.splice(index + 1, 0, newRow);
|
|
|
+ tableData.value.forEach((item, index) => {
|
|
|
+ item.sn = index;
|
|
|
+ item.products.forEach((ch, idx) => {
|
|
|
+ if(ch.nutritionProductId){
|
|
|
+ let arr = ch.nutritionProductId.split('_');
|
|
|
+ ch.nutritionProductId = arr[0] + '_' + index + '_' + idx;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ emit('change', JSON.stringify(tableData.value))
|
|
|
};
|
|
|
|
|
|
// 删除行
|
|
|
-const deleteRow = (index: number) => {
|
|
|
- if (tableData.value.length === 1) return;
|
|
|
+const deleteRow = (index: number) => {
|
|
|
tableData.value.splice(index, 1);
|
|
|
+
|
|
|
+ tableData.value.forEach((item, index) => {
|
|
|
+ item.sn = index;
|
|
|
+ });
|
|
|
+
|
|
|
+ emit('change',JSON.stringify(tableData.value))
|
|
|
+};
|
|
|
+
|
|
|
+
|
|
|
+const changeUsageDays = (value: string, sn:string) => {
|
|
|
+ changeTimeSelection(null,sn);
|
|
|
+}
|
|
|
+
|
|
|
+const changeUsage = (value: string, sn:string) => {
|
|
|
+ changeTimeSelection(null,sn);
|
|
|
+}
|
|
|
+
|
|
|
+const changePreparationVolumePerTime = (value: string, sn:string) => {
|
|
|
+ changeTimeSelection(null,sn);
|
|
|
+}
|
|
|
+
|
|
|
+const changeEnergyDensityPerTime = (value: string, sn:string) => {
|
|
|
+ changeTimeSelection(null,sn);
|
|
|
+}
|
|
|
+
|
|
|
+const changePrescriptionRemark = (value: string, sn:string) => {
|
|
|
+ changeTimeSelection(null,sn);
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+const firstDayInput = (value: string, sn:string) => {
|
|
|
+ changeTimeSelection(null,sn);
|
|
|
+}
|
|
|
+
|
|
|
+const changeTimeSelection = (value: string, sn:string) => {
|
|
|
+ let row = tableData.value[sn];
|
|
|
+ let frequency=0;
|
|
|
+ row.timeSlots.forEach(item=>{
|
|
|
+ if(item.checked){
|
|
|
+ frequency++;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ row.frequency=frequency;
|
|
|
+ if(value!=null){
|
|
|
+ row.firstDay=Math.ceil(row.frequency/2.0);
|
|
|
+ }
|
|
|
+
|
|
|
+ row.products.forEach(pt => {
|
|
|
+ if (!pt.dosePerTime || pt.dosePerTime.trim().length == 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ let arr=pt.nutritionProductId.split('_');
|
|
|
+
|
|
|
+ for (let item of productNutritionList.value) {
|
|
|
+ if (item.id.toString() != arr[0]) {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ let val=item.calorie*row.frequency*Number(pt.dosePerTime)/100.0
|
|
|
+ pt.dailyCalories=val.toFixed(4);
|
|
|
+
|
|
|
+ let firstDay=Number(row.firstDay.toString());
|
|
|
+ val=(row.frequency*(daysDifference.value-1)+firstDay)*item.configSalePrice*Number(pt.dosePerTime);
|
|
|
+ val=Math.max(0,val);
|
|
|
+ pt.amount=Math.round(val*100)/100;
|
|
|
+
|
|
|
+ val=(row.frequency*(daysDifference.value-1)+firstDay)*Number(pt.dosePerTime);
|
|
|
+ val=Math.max(0,val);
|
|
|
+ pt.totalDose=val.toFixed(4) ;
|
|
|
+
|
|
|
+ val=row.frequency*Number(pt.dosePerTime)
|
|
|
+ pt.dosePerDay=val.toFixed(4) ;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ emit('change',JSON.stringify(tableData.value));
|
|
|
+};
|
|
|
+
|
|
|
+const dosePerTimeInput = (value: string, str:string) => {
|
|
|
+ let arr=str.split('_');
|
|
|
+ let row = tableData.value[Number(arr[0])];
|
|
|
+ let pt = row.products[Number(arr[1])];
|
|
|
+ if(!pt.dosePerTime||pt.dosePerTime.trim().length==0){
|
|
|
+ pt.dailyCalories=null;
|
|
|
+ pt.amount=null;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ arr=pt.nutritionProductId.split('_');
|
|
|
+ for (let item of productNutritionList.value) {
|
|
|
+ if (item.id.toString() != arr[0]) {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ let val=item.calorie*row.frequency*Number(pt.dosePerTime)/100.0
|
|
|
+ pt.dailyCalories=val.toFixed(4);
|
|
|
+
|
|
|
+ let firstDay=Number(row.firstDay.toString());
|
|
|
+ val=(row.frequency*(daysDifference.value-1)+firstDay)*item.configSalePrice*Number(pt.dosePerTime);
|
|
|
+ val=Math.max(0,val);
|
|
|
+ pt.amount=Math.round(val*100)/100;
|
|
|
+
|
|
|
+ val=(row.frequency*(daysDifference.value-1)+firstDay)*Number(pt.dosePerTime);
|
|
|
+ val=Math.max(0,val);
|
|
|
+ pt.totalDose=val.toFixed(4) ;
|
|
|
+
|
|
|
+ val=row.frequency*Number(pt.dosePerTime)
|
|
|
+ pt.dosePerDay=val.toFixed(4) ;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ emit('change',JSON.stringify(tableData.value))
|
|
|
};
|
|
|
+
|
|
|
+// 禁用今天之前的日期
|
|
|
+const disabledBeforeToday = (date) => {
|
|
|
+ const start = new Date(prop.prescriptionDate);
|
|
|
+ const today = new Date();
|
|
|
+ // 设置时间为今天凌晨,确保比较的是日期而非具体时间
|
|
|
+ today.setHours(0, 0, 0, 0)
|
|
|
+ today.setDate(start.getDate() + 1);
|
|
|
+ return date < today
|
|
|
+}
|
|
|
+
|
|
|
+watch(
|
|
|
+ () => prop.prescriptionDate,
|
|
|
+ async (val: string) => {
|
|
|
+ if (!val || val.trim().length == 0||!stopDate.value||stopDate.value.trim().length == 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ const end = new Date(stopDate.value);
|
|
|
+ const start = new Date(prop.prescriptionDate);
|
|
|
+ if(start>=end){
|
|
|
+ stopDate.value='';
|
|
|
+ }else{
|
|
|
+ handleStopDateChange(stopDate.value);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ { deep: true, immediate: true }
|
|
|
+);
|
|
|
+
|
|
|
+const handleStopDateChange = (dateVal: any) => {
|
|
|
+ // 定义两个日期
|
|
|
+ const end = new Date(dateVal);
|
|
|
+ const start = new Date(prop.prescriptionDate);
|
|
|
+
|
|
|
+ // 计算时间差(毫秒)
|
|
|
+ const timeDifference = end.getTime() - start.getTime();
|
|
|
+
|
|
|
+ // 将毫秒差转换为天数差
|
|
|
+ daysDifference.value = timeDifference / (1000 * 60 * 60 * 24) + 1;
|
|
|
+ if (daysDifference.value <= 0) {
|
|
|
+ daysDifference.value = 0;
|
|
|
+ stopDate.value = '';
|
|
|
+ }
|
|
|
+
|
|
|
+ tableData.value.forEach(item=>{
|
|
|
+ item.stopDate=stopDate.value;
|
|
|
+ item.prescriptionDate=prop.prescriptionDate;
|
|
|
+ item.usageDays=daysDifference.value;
|
|
|
+ });
|
|
|
+
|
|
|
+ emit('change',JSON.stringify(tableData.value));
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+onMounted(() => {
|
|
|
+ getProductNutritionList();
|
|
|
+ tableData.value.forEach(item=>{
|
|
|
+ item.stopDate=stopDate.value;
|
|
|
+ item.prescriptionDate=prop.prescriptionDate;
|
|
|
+ item.usageDays=daysDifference.value;
|
|
|
+ });
|
|
|
+});
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|