|
@@ -1,109 +0,0 @@
|
|
-<script setup lang="ts">
|
|
|
|
-import { useForm } from 'alova/client';
|
|
|
|
-import { setDataMethod } from '@/api/pda.api.ts';
|
|
|
|
-import { uploadMethod } from '@/api/file.api.ts';
|
|
|
|
-import type { ToRef } from 'vue';
|
|
|
|
-import { showSuccessToast, type UploaderAfterRead, type UploaderFileListItem } from 'vant';
|
|
|
|
-import { useAccountStore, useStepStore } from '@/stores';
|
|
|
|
-// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
|
|
-// @ts-expect-error
|
|
|
|
-import Big from 'big.js';
|
|
|
|
-
|
|
|
|
-const { title } = defineProps<{ title: string }>();
|
|
|
|
-const emits = defineEmits<{ back: [delta?: number] }>();
|
|
|
|
-const route = useRoute();
|
|
|
|
-const mode = toRef(route.params, 'mode') as ToRef<'deploy' | 'deploy-recheck'>;
|
|
|
|
-
|
|
|
|
-const storeStore = useStepStore();
|
|
|
|
-const accountStore = useAccountStore();
|
|
|
|
-
|
|
|
|
-const files = ref<UploaderFileListItem[]>([]);
|
|
|
|
-const {
|
|
|
|
- loading: submitting,
|
|
|
|
- form: model,
|
|
|
|
- send: submit,
|
|
|
|
-} = useForm(
|
|
|
|
- (model) => {
|
|
|
|
- const data = Object.assign(
|
|
|
|
- {
|
|
|
|
- urls: files.value.filter((file) => file.status === 'done').map((file) => file.url),
|
|
|
|
- coreId: storeStore.dataset?.id,
|
|
|
|
- preNo: storeStore.dataset?.no,
|
|
|
|
- userId: accountStore.account?.id,
|
|
|
|
- },
|
|
|
|
- model,
|
|
|
|
- );
|
|
|
|
- switch (mode.value) {
|
|
|
|
- case 'deploy':
|
|
|
|
- Reflect.deleteProperty(data, 'weight');
|
|
|
|
- return setDataMethod('/file/saveCoreFile', data);
|
|
|
|
- case 'deploy-recheck':
|
|
|
|
- return setDataMethod('/prescription/prescriptionCore/reviewPrescription', data);
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- initialForm: {
|
|
|
|
- comments: '',
|
|
|
|
- weight: '',
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
-).onSuccess(() => {
|
|
|
|
- showSuccessToast(`操作成功`);
|
|
|
|
- emits('back', -1);
|
|
|
|
-});
|
|
|
|
-
|
|
|
|
-const afterRead: UploaderAfterRead = async (listItem) => {
|
|
|
|
- if (listItem && !Array.isArray(listItem)) listItem = [listItem];
|
|
|
|
- for (const item of listItem) {
|
|
|
|
- if (!item?.file) continue;
|
|
|
|
- item.status = 'uploading';
|
|
|
|
- item.message = '上传中...';
|
|
|
|
- try {
|
|
|
|
- item.url = await uploadMethod(item.file!);
|
|
|
|
- item.status = 'done';
|
|
|
|
- } catch (e) {
|
|
|
|
- console.error('上传文件-->失败', e);
|
|
|
|
- item.status = 'failed';
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-};
|
|
|
|
-
|
|
|
|
-const remarkLabel = computed(() => title.replace('管理', '备注'));
|
|
|
|
-const buttonText = computed(() => title.replace('管理', '节点上传'));
|
|
|
|
-
|
|
|
|
-const update = () => {
|
|
|
|
- if (mode.value === 'deploy-recheck') {
|
|
|
|
- const {
|
|
|
|
- medicines,
|
|
|
|
- prescription: { count },
|
|
|
|
- } = storeStore.dataset!;
|
|
|
|
- const weight = medicines.reduce((total, medicine) => total.plus(Big(medicine.dosage || 0)), Big(0));
|
|
|
|
- model.value.weight = weight.times(Big(count)).toString();
|
|
|
|
- }
|
|
|
|
-};
|
|
|
|
-onBeforeMount(() => update());
|
|
|
|
-onBeforeRouteUpdate(() => update());
|
|
|
|
-</script>
|
|
|
|
-
|
|
|
|
-<template>
|
|
|
|
- <div>
|
|
|
|
- <van-cell-group>
|
|
|
|
- <van-form required="auto">
|
|
|
|
- <template v-if="mode === 'deploy-recheck'">
|
|
|
|
- <van-field v-model="model.weight" type="number" label="复核重量" placeholder="请输入重量" />
|
|
|
|
- </template>
|
|
|
|
- <van-field label="拍照上传">
|
|
|
|
- <template #input>
|
|
|
|
- <van-uploader v-model="files" :after-read="afterRead" />
|
|
|
|
- </template>
|
|
|
|
- </van-field>
|
|
|
|
- <van-field v-model="model.comments" rows="2" autosize :label="remarkLabel" type="textarea" placeholder="请输入备注" />
|
|
|
|
- <div class="my-4 px-4">
|
|
|
|
- <van-button type="primary" block :loading="submitting" @click="submit()">{{ buttonText }} </van-button>
|
|
|
|
- </div>
|
|
|
|
- </van-form>
|
|
|
|
- </van-cell-group>
|
|
|
|
- </div>
|
|
|
|
-</template>
|
|
|
|
-
|
|
|
|
-<style scoped lang="scss"></style>
|
|
|