patientPrint.vue 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <template>
  2. <el-dialog
  3. title="打印"
  4. :visible.sync="visibility"
  5. :close-on-click-modal="isClose"
  6. :close-on-press-escape="isClose"
  7. >
  8. <el-button type="primary" @click="print" class="print_style"
  9. >打印</el-button
  10. >
  11. <div id="dialysis-print-box-1" class="dialysis-print-box-1">
  12. <div class="list_title">
  13. <div>患者名称:</div>
  14. <div>数据来源:</div>
  15. <div>发药状态:</div>
  16. <div>领药时间:</div>
  17. </div>
  18. <el-table
  19. style="width: 940px; margin: 0 auto"
  20. :data="tableData"
  21. border
  22. max-height="450"
  23. :header-cell-style="{ backgroundColor: 'rgb(245, 247, 250)' }"
  24. >
  25. <el-table-column type="index" prop="index" label="序号" width="60">
  26. </el-table-column>
  27. <el-table-column prop="name" label="名称" width="160">
  28. </el-table-column>
  29. <el-table-column prop="SingleDosage" label="单次用量" width="120">
  30. </el-table-column>
  31. <el-table-column prop="use" label="用法" width="120"> </el-table-column>
  32. <el-table-column prop="frequency" label="频率" width="120">
  33. </el-table-column>
  34. <el-table-column prop="day" label="天数" width="120"> </el-table-column>
  35. <el-table-column prop="amount" label="总量" width="120">
  36. </el-table-column>
  37. <el-table-column prop="tips" label="备注" width="120">
  38. </el-table-column>
  39. </el-table>
  40. </div>
  41. </el-dialog>
  42. </template>
  43. <script>
  44. import Vue from "vue";
  45. import print from "print-js";
  46. import printutils from "./print.js";
  47. export default {
  48. data() {
  49. return {
  50. visibility: false,
  51. tableData: [{}],
  52. isClose:false,
  53. org_name:"",
  54. };
  55. },
  56. props: {
  57. propForm: {
  58. type: Object,
  59. },
  60. },
  61. methods: {
  62. // isClose() {
  63. // this.visibility = false;
  64. // },
  65. hide: function () {
  66. this.visibility = false;
  67. for (let i = 0; i < this.propForm.goods.length; i++) {
  68. for (let key in this.propForm.goods[i]) {
  69. if (key != "index") {
  70. this.propForm.goods[i][key].isSelected = false;
  71. }
  72. }
  73. }
  74. },
  75. show: function () {
  76. this.visibility = true;
  77. },
  78. comfirm: function (formName) {
  79. this.goodInfo = [];
  80. this.goodInfoTableData = [];
  81. this.$emit("dialog-comfirm", this.getValue());
  82. this.$refs.multipleTable.clearSelection();
  83. this.$refs.table.setCurrentRow(null);
  84. },
  85. getValue() {},
  86. // 打印
  87. print() {
  88. Vue.prototype.printJson = printutils.printJson;
  89. // const style =
  90. // '@media print {.list_title{ width: 940px;border-bottom: 1px solid;display: flex;margin: 30px auto}}';
  91. // printJS({
  92. // printable: "dialysis-print-box-1",
  93. // type: "html",
  94. // style: style,
  95. // scanStyles: false,
  96. // });
  97. this.printJson({
  98. title: `<div style="width:100%;text-align:center;font-size:16px;font-weight:bold;">${this.org_name}医院 发药单</div>
  99. <div style="width: 940px;border-bottom: 1px solid;display: flex;margin: 30px auto;">
  100. <div style="width: 310px;padding: 10px 0;">患者名称:${1}</div>
  101. <div style="width: 310px;padding: 10px 0;">数据来源:${1}</div>
  102. <div style="width: 310px;padding: 10px 0;">发药状态:${1}</div>
  103. </div>`, // 打印出来的标题
  104. data: this.tableData, // 需要打印的数据
  105. serial: true, // 是否需要打印序列号
  106. fields: [
  107. // 需要打印的字段
  108. "name",
  109. "SingleDosage",
  110. "use",
  111. "frequency",
  112. "day",
  113. "amount",
  114. "from",
  115. "tips",
  116. ],
  117. properties: [
  118. // 需要打印的字段对应的表头名
  119. {
  120. field: "name",
  121. displayName: "姓名",
  122. },
  123. {
  124. field: "SingleDosage",
  125. displayName: "单词用量",
  126. },
  127. {
  128. field: "use",
  129. displayName: "用法",
  130. },
  131. {
  132. field: "frequency",
  133. displayName: "频率",
  134. },
  135. {
  136. field: "day",
  137. displayName: "天数",
  138. },
  139. {
  140. field: "amount",
  141. displayName: "总量",
  142. },
  143. {
  144. field: "from",
  145. displayName: "数据来源",
  146. },
  147. {
  148. field: "tips",
  149. displayName: "备注",
  150. },
  151. ],
  152. });
  153. },
  154. },
  155. };
  156. </script>
  157. <style lang="scss" scoped>
  158. /deep/ .el-dialog{
  159. width: 60%;
  160. }
  161. .print_style {
  162. position: absolute;
  163. right: 65px;
  164. top: 50px;
  165. }
  166. .list_title {
  167. width: 940px;
  168. border-bottom: 1px solid;
  169. display: flex;
  170. margin: 30px auto;
  171. div {
  172. width: 230px;
  173. padding: 10px 0;
  174. }
  175. }
  176. </style>