浏览代码

生成PDF提交

yjwang 1 周之前
父节点
当前提交
f8f03a3bb9

+ 11 - 1
src/api/hisStore/storePrescription.js

@@ -66,4 +66,14 @@ export function getChatMessages(preId) {
     url: '/store/prescription/chatDetail/' + preId,
     method: 'get'
   })
-}
+}
+
+// 新增处方订单
+export function downloadMedicalPdf(data) {
+  return request({
+    url: '/store/prescription/downloadMedicalPdf',
+    method: 'post',
+    responseType: 'blob',
+    data: data
+  })
+}

+ 76 - 4
src/views/hisStore/storePrescription/index.vue

@@ -56,6 +56,20 @@
       </el-form-item>
     </el-form>
 
+    <el-row :gutter="10" class="mb8">
+      <el-col :span="1.5">
+        <el-button
+          type="warning"
+          plain
+          icon="el-icon-download"
+          size="mini"
+          @click="downloadPdf"
+          :disabled="multiple"
+        >批量生成PDF</el-button>
+      </el-col>
+      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
+    </el-row>
+
     <!-- <el-row :gutter="10" class="mb8">
       <el-col :span="1.5">
         <el-button
@@ -158,7 +172,7 @@
         </template>
       </el-table-column>
     </el-table>
-    
+
     <pagination
       v-show="total>0"
       :total="total"
@@ -275,7 +289,8 @@
 </template>
 
 <script>
-import { listPrescription, getPrescription, delPrescription, addPrescription, updatePrescription, exportPrescription } from "@/api/hisStore/storePrescription";
+import { listPrescription, getPrescription, delPrescription, addPrescription, updatePrescription, exportPrescription,downloadMedicalPdf } from "@/api/hisStore/storePrescription";
+import { getToken } from '@/utils/auth'
 
 export default {
   name: "StorePrescription",
@@ -372,7 +387,7 @@ export default {
         this.queryParams.beginTime = null;
         this.queryParams.endTime = null;
       }
-      
+
       listPrescription(this.queryParams).then(response => {
           this.prescriptionList = response.rows;
           this.total = response.total;
@@ -482,7 +497,64 @@ export default {
         this.download(response.msg);
         this.exportLoading = false;
       }).catch(() => {});
+    },
+    downloadPdf() {
+      this.$alert('是否确定批量生成PDF文件', '生成PDF', {
+        confirmButtonText: '确定',
+        callback: action => {
+          if (this.ids.length > 3) {
+            return this.$message.warning('生成处方信息不能大于3条!');
+          }
+          if (this.ids.length === 0) {
+            return this.$message.warning('请选择需要生成的记录!');
+          }
+
+          const xhr = new XMLHttpRequest();
+          const url = process.env.VUE_APP_BASE_API + '/store/prescription/downloadMedicalPdf';
+          xhr.open('POST', url, true);
+          xhr.setRequestHeader('Authorization', 'Bearer ' + getToken()); // 携带Token
+          xhr.setRequestHeader('Content-Type', 'application/json'); // 声明JSON格式
+          xhr.responseType = 'arraybuffer';
+          xhr.onload = function() {
+            if (xhr.status === 200) {
+              // 6. 解析文件名(从响应头获取)
+              const contentDisposition = xhr.getResponseHeader('content-disposition');
+              let fileName = '医疗记录.pdf';
+              if (contentDisposition) {
+                const match = contentDisposition.match(/filename="?([^";]+)"?/);
+                if (match && match[1]) {
+                  fileName = decodeURIComponent(match[1]);
+                }
+              }
+
+              // 7. 将二进制数据转为Blob并下载
+              const blob = new Blob([xhr.response], { type: 'application/pdf' });
+              const url = window.URL.createObjectURL(blob);
+              const aLink = document.createElement('a');
+              aLink.href = url;
+              aLink.download = fileName;
+              document.body.appendChild(aLink);
+              aLink.click();
+              setTimeout(() => {
+                window.URL.revokeObjectURL(url);
+                document.body.removeChild(aLink);
+              }, 500);
+
+              this.$message.success('PDF下载成功!');
+            } else {
+              // 处理错误状态
+              this.$message.error(`下载失败,状态码:${xhr.status}`);
+            }
+          }.bind(this); // 绑定this上下文,确保能调用this.$message
+
+          // 9. 监听网络错误
+          xhr.onerror = function() {
+            this.$message.error('网络错误,下载失败');
+          }.bind(this);
+          xhr.send(JSON.stringify({ ids: this.ids }));
+        }
+      });
     }
   }
 };
-</script>
+</script>

+ 6 - 6
src/views/user/complaint/index.vue

@@ -71,6 +71,7 @@
           <dict-tag :options="typeOptions" :value="scope.row.type"/>
         </template>
       </el-table-column>
+      <el-table-column label="店铺名称" align="center" prop="storeName" />
       <el-table-column label="投诉时间" align="center" prop="createTime" />
       <el-table-column
         label="平台消息是否处理"
@@ -135,8 +136,11 @@
       <!-- 修改tab-click事件处理器名称 -->
       <el-tabs v-model="activeTab" type="card" @tab-click="handleClick">
         <!-- 投诉详情标签页 -->
-        <el-tab-pane :label="complaintType === 1?'咨询详情':'投诉详情'" name="complaint">
+        <el-tab-pane :label="complaintType === 1?'咨询详情':'投诉/举报详情'" name="complaint">
           <el-form ref="form" :model="form" :rules="rules" label-width="80px">
+            <el-form-item label="店铺名称" prop="name" v-if="complaintType === 1 || complaintType === 2">
+              <el-input v-model="form.storeName" :disabled="true" />
+            </el-form-item>
             <el-form-item label="投诉内容" prop="name">
               <el-input v-model="form.name" :disabled="true" />
             </el-form-item>
@@ -598,7 +602,7 @@ export default {
         this.replyForm.complaintId = complaintId;
         this.replyQueryParams.complaintId = complaintId;
         this.open = true;
-        this.title = "投诉详情";
+        this.title = complaintType === 1?"咨询详情":complaintType === 2?"投诉/举报详情":"其它详情";
         // 加载回复列表
         this.getReplyList();
       });
@@ -792,10 +796,6 @@ export default {
           this.getList();
         })
       }).catch(() => {
-        this.$message({
-          type: 'info',
-          message: '已取消删除'
-        });
       });
     }
   }