Browse Source

导出打印记录

huangxw 1 week ago
parent
commit
e8e2f709b9
1 changed files with 39 additions and 23 deletions
  1. 39 23
      src/plant/export-print/models/export-print-confirm.vue

+ 39 - 23
src/plant/export-print/models/export-print-confirm.vue

@@ -3,15 +3,24 @@
         <up-form class="p-rtv bg-#fff" labelPosition="top" :model="form" errorType="toast" :rules="rules" labelWidth="auto" ref="upFormUpRef">
             <view class="f-s-24 c-#999">导出追溯码仅支持导出追溯码地址用于喷印或排版好追溯码PDF文件直接打印。如有疑问,请。如有疑问,请<span class="c-primary">点击此处联系客服</span>。</view>
             <slot name="fileType"></slot>
-            <ut-action-sheet v-model="form.extraInfo.fileType" :tabs="pt_code_export_type" @change="changeExtraFileType" mode="custom" title="请选择导出类型">
+            <template v-if="opts.id">
                 <up-form-item borderBottom label="导出类型" required prop="extraInfo.fileType">
                     <view v-if="form.extraInfo?.fileType" class="f-s-30 c-333 f-w-5 flex1">{{ selectDictLabel(pt_code_export_type, form.extraInfo.fileType) }}</view>
                     <view v-else class="f-s-30 c-ccc f-w-4 flex1">请选择导出类型</view>
-                    <template #right>
-                        <up-icon size="22rpx" color="#37A954" name="arrow-down-fill"></up-icon>
-                    </template>
                 </up-form-item>
-            </ut-action-sheet>
+            </template>
+            <template v-else>
+                <ut-action-sheet v-model="form.extraInfo.fileType" :tabs="pt_code_export_type" @change="changeExtraFileType" mode="custom" title="请选择导出类型">
+                    <up-form-item borderBottom label="导出类型" required prop="extraInfo.fileType">
+                        <view v-if="form.extraInfo?.fileType" class="f-s-30 c-333 f-w-5 flex1">{{ selectDictLabel(pt_code_export_type, form.extraInfo.fileType) }}</view>
+                        <view v-else class="f-s-30 c-ccc f-w-4 flex1">请选择导出类型</view>
+                        <template #right>
+                            <up-icon size="22rpx" color="#37A954" name="arrow-down-fill"></up-icon>
+                        </template>
+                    </up-form-item>
+                </ut-action-sheet>
+            </template>
+
             <template v-if="form.extraInfo.fileType == '2'">
                 <slot name="logos"></slot>
                 <up-form-item borderBottom prop="extraInfo.logos">
@@ -62,12 +71,22 @@
                 <!-- 导出数量 -->
 
                 <slot name="printCount"></slot>
-                <up-form-item :label="`导出数量`" prop="printCount" required borderBottom>
-                    <up-input v-model="form.printCount" placeholder="请输入导出数量" border="none" clearable></up-input>
-                    <template #right>
-                        <span class="f-s-30 f-w-5 c-#333">{{ opts?.unit || form?.unit || 'kg' }}</span>
-                    </template>
-                </up-form-item>
+                <template v-if="opts.id">
+                    <up-form-item :label="`导出数量`" prop="printCount" required borderBottom>
+                        <up-input v-model="form.printCount" readonly placeholder="请输入导出数量" border="none" clearable></up-input>
+                        <template #right>
+                            <span class="f-s-30 f-w-5 c-#333">{{ opts?.unit || form?.unit || 'kg' }}</span>
+                        </template>
+                    </up-form-item>
+                </template>
+                <template v-else>
+                    <up-form-item :label="`导出数量`" prop="printCount" required borderBottom>
+                        <up-input v-model="form.printCount" placeholder="请输入导出数量" border="none" clearable></up-input>
+                        <template #right>
+                            <span class="f-s-30 f-w-5 c-#333">{{ opts?.unit || form?.unit || 'kg' }}</span>
+                        </template>
+                    </up-form-item>
+                </template>
                 <!-- 邮箱 -->
                 <slot name="email"></slot>
                 <up-form-item borderBottom required label="邮箱" prop="extraInfo.email">
@@ -136,7 +155,7 @@ const emit = defineEmits(['next', 'prev', 'formdata']);
 const form = ref<any>({
     printCount: props.opts?.printedCount,
     extraInfo: {
-        fileType: '2',
+        fileType: '1',
         fileFormat: '1',
         logos: [], // 导出logo
         // 只有禁用的默认有值,
@@ -236,18 +255,15 @@ const submitForm = async () => {
     uni.showLoading({
         title: '正在导出...',
     });
-    const  payload = {
+    const payload = {
         ...props.opts,
         ...form.value,
-        printType: '2',
-        printCount: form.value.extraInfo.fileType == '1' ? props.opts.printedCount : form.value.printCount,
-    }
-    const res = await useClientRequest.post('/plt-api/app/printLog/printNext', payload)
+    };
+    const res = props.opts?.id ? await useClientRequest.get(`/plt-api/app/printLog/update/${props.opts.id}`, payload?.extraInfo) : await useClientRequest.post('/plt-api/app/printLog/printNext', payload);
     if (!res || res.code !== 200) return;
     uni.$emit('refreshPackTaskList');
     uni.$emit('refreshPackTaskDetail');
-    await useClientRequest.get(`/plt-api/app/printLog/export/${res.data?.id}`)
-
+    await useClientRequest.get(`/plt-api/app/printLog/export/${res.data?.id || props.opts?.id}`);
     uni.hideLoading();
     uni.showToast({
         title: '导出成功',
@@ -266,16 +282,16 @@ const prevSteps = () => {
 };
 // getFormInfo
 const getFormInfo = async () => {
-   if (!props.opts.id) return
-   const res = await useClientRequest.get(`/plt-api/app/printLog/${props.opts.id}`);
+    if (!props.opts.id) return;
+    const res = await useClientRequest.get(`/plt-api/app/printLog/${props.opts.id}`);
     if (res && res.code === 200) {
         form.value = {
             ...form.value,
             ...res.data,
-        }
+        };
     }
 };
 onMounted(() => {
-   getFormInfo();
+    getFormInfo();
 });
 </script>