StepDecoction.vue 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <script setup lang="ts">
  2. import { showSuccessToast } from 'vant';
  3. import { useForm, useWatcher } from 'alova/client';
  4. import { getDecoctionDataMethod, setDecoctionDataMethod } from '@/api/pda.api.ts';
  5. import { type DecoctionModel, fromDecoctionModel } from '@/model/step.model.ts';
  6. import { useStepStore } from '@/stores';
  7. import type { ScanData } from '@/core/hook/useScan.ts';
  8. const emits = defineEmits<{ back: [delta?: number] }>();
  9. const storeStore = useStepStore();
  10. const { dataset } = storeToRefs(storeStore);
  11. const {
  12. loading: submitting,
  13. form: model,
  14. send,
  15. } = useForm(setDecoctionDataMethod, { immediate: false, initialForm: fromDecoctionModel() }).onSuccess(() => {
  16. showSuccessToast(`操作成功`);
  17. emits('back');
  18. });
  19. const { data, loading } = useWatcher(() => getDecoctionDataMethod(dataset.value!.id), [dataset], { immediate: true, initialData: {} })
  20. .onSuccess(({ data }) => {
  21. for (const [key, value] of Object.entries(data)) model.value[key as keyof DecoctionModel] = value;
  22. })
  23. .onError(({ error: message }) => {
  24. showDialog({ title: '温馨提示', message, closeOnClickOverlay: true }).then(() => emits('back'));
  25. });
  26. defineExpose({
  27. scan(data: ScanData) {
  28. model.value.deviceCode = data?.code ?? '';
  29. },
  30. });
  31. </script>
  32. <template>
  33. <van-toast :show="loading" type="loading" forbid-click />
  34. <van-cell title="煎药方案" :value="data.schemeName" />
  35. <van-cell title="压力模式" :value="data.pressurePattern" />
  36. <van-cell title="剂型" :value="data.dosageForm" />
  37. <van-cell title="煎煮时间" :value="data.decoctTime ? `${data.decoctTime} min` : ''" />
  38. <van-cell title="先煎时间" :value="data.preDecoctTime ? `${data.preDecoctTime} min` : ''" />
  39. <van-cell title="一煎时间" :value="data.firstDecoctTime ? `${data.firstDecoctTime} min` : ''" />
  40. <van-cell title="二煎时间" :value="data.secondDecoctTime ? `${data.secondDecoctTime} min` : ''" />
  41. <van-cell title="后下时间" :value="data.backDownTime ? `${data.backDownTime} min` : ''" />
  42. <van-field class="suffix" v-model="model.startConcentrationDose" :readonly="submitting" type="digit" label="开始浓缩药量" placeholder="请输入开始浓缩药量">
  43. <template #extra>
  44. <div v-if="model.startConcentrationDose">ml</div>
  45. </template>
  46. </van-field>
  47. <van-field class="suffix" v-model="model.endConcentrationDose" :readonly="submitting" type="digit" label="结束浓缩药量" placeholder="请输入结束浓缩药量">
  48. <template #extra>
  49. <div v-if="model.endConcentrationDose">ml</div>
  50. </template>
  51. </van-field>
  52. <slot name="scanner" title="扫描设备" :disabled="submitting"></slot>
  53. <slot name="uploader" :disabled="submitting"></slot>
  54. <van-field v-model="model.decoctNote" :readonly="submitting" rows="2" autosize label="煎煮备注" type="textarea" placeholder="请输入备注内容" />
  55. <slot name="submit" title="煎煮节点上传" :submitting="submitting" :submit="send"></slot>
  56. </template>
  57. <style scoped lang="scss">
  58. .van-field.suffix {
  59. :deep(.van-field__value) {
  60. flex: none;
  61. //width: min-content;
  62. //min-width: 120px;
  63. max-width: 170px;
  64. input {
  65. text-align: center;
  66. }
  67. }
  68. }
  69. </style>