patientPrint.vue 5.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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>患者名称:{{name}}</div>
  14. <div>发药状态:{{state}}</div>
  15. </div>
  16. <el-table
  17. style="width: 940px; margin: 0 auto"
  18. :data="tableData"
  19. border
  20. max-height="450"
  21. :header-cell-style="{ backgroundColor: 'rgb(245, 247, 250)' }"
  22. >
  23. <el-table-column type="index" prop="index" label="序号" width="60">
  24. </el-table-column>
  25. <el-table-column prop="name" label="名称" width="160">
  26. <template slot-scope="scope" >
  27. <span>{{scope.row.Name ? scope.row.Name : ""}}</span>
  28. </template>
  29. </el-table-column>
  30. <el-table-column prop="SingleDosage" label="单次用量" width="120">
  31. <template slot-scope="scope" >
  32. <span>{{scope.row.SingleDosage ? scope.row.SingleDosage : ""}}</span>
  33. </template>
  34. </el-table-column>
  35. <el-table-column prop="use" label="用法" width="120">
  36. <template slot-scope="scope" >
  37. <span>{{scope.row.Usage ? scope.row.Usage : ""}}</span>
  38. </template>
  39. </el-table-column>
  40. <el-table-column prop="frequency" label="频率" width="120">
  41. <template slot-scope="scope" >
  42. <span>{{scope.row.Frequency ? scope.row.Frequency : ""}}</span>
  43. </template>
  44. </el-table-column>
  45. <el-table-column prop="day" label="天数" width="120">
  46. <template slot-scope="scope" >
  47. <span>{{scope.row.Days ? scope.row.Days : ""}}</span>
  48. </template>
  49. </el-table-column>
  50. <el-table-column prop="amount" label="总量" width="120">
  51. <template slot-scope="scope" >
  52. <span>{{scope.row.Total ? scope.row.Total : ""}}</span>
  53. </template>
  54. </el-table-column>
  55. <el-table-column prop="tips" label="数据来源" width="120">
  56. <template slot-scope="scope" >
  57. <span>{{scope.row.DataSources ? scope.row.DataSources : ""}}</span>
  58. </template>
  59. </el-table-column>
  60. <el-table-column prop="tips" label="备注" width="120">
  61. <template slot-scope="scope" >
  62. <span>{{scope.row.Remarks ? scope.row.Remarks : ""}}</span>
  63. </template>
  64. </el-table-column>
  65. </el-table>
  66. </div>
  67. </el-dialog>
  68. </template>
  69. <script>
  70. import Vue from "vue";
  71. import print from "print-js";
  72. import printutils from "./print.js";
  73. export default {
  74. data() {
  75. return {
  76. visibility: false,
  77. tableData: [],
  78. isClose:false,
  79. name:"",
  80. state:null,
  81. };
  82. },
  83. props: {
  84. propForm: {
  85. type: Object,
  86. },
  87. },
  88. methods: {
  89. // isClose() {
  90. // this.visibility = false;
  91. // },
  92. hide: function () {
  93. this.visibility = false;
  94. for (let i = 0; i < this.propForm.goods.length; i++) {
  95. for (let key in this.propForm.goods[i]) {
  96. if (key != "index") {
  97. this.propForm.goods[i][key].isSelected = false;
  98. }
  99. }
  100. }
  101. },
  102. show: function (val,data,state) {
  103. this.visibility = true;
  104. console.log("val",val)
  105. this.tableData = val
  106. this.name = data.Name
  107. if (state == 1){
  108. this.state = "待发药"
  109. }
  110. if (state == 2){
  111. this.state = "已发药"
  112. }
  113. },
  114. comfirm: function (formName) {
  115. this.goodInfo = [];
  116. this.goodInfoTableData = [];
  117. this.$emit("dialog-comfirm", this.getValue());
  118. this.$refs.multipleTable.clearSelection();
  119. this.$refs.table.setCurrentRow(null);
  120. },
  121. getValue() {},
  122. // 打印
  123. print() {
  124. Vue.prototype.printJson = printutils.printJson;
  125. // const style =
  126. // '@media print {.list_title{ width: 940px;border-bottom: 1px solid;display: flex;margin: 30px auto}}';
  127. // printJS({
  128. // printable: "dialysis-print-box-1",
  129. // type: "html",
  130. // style: style,
  131. // scanStyles: false,
  132. // });
  133. this.printJson({
  134. title: `<div style="width: 940px;border-bottom: 1px solid;display: flex;margin: 30px auto;">
  135. <div style="width: 230px;padding: 10px 0;">患者名称:${this.name}</div>
  136. <div style="width: 230px;padding: 10px 0;">发药状态:${this.state}</div>
  137. </div>`, // 打印出来的标题
  138. data: this.tableData, // 需要打印的数据
  139. serial: true, // 是否需要打印序列号
  140. fields: [
  141. // 需要打印的字段
  142. "Name",
  143. "SingleDosage",
  144. "Usage",
  145. "Frequency",
  146. "Days",
  147. "Total",
  148. "DataSources",
  149. "Remarks",
  150. ],
  151. properties: [
  152. // 需要打印的字段对应的表头名
  153. {
  154. field: "Name",
  155. displayName: "姓名",
  156. },
  157. {
  158. field: "SingleDosage",
  159. displayName: "单次用量",
  160. },
  161. {
  162. field: "Usage",
  163. displayName: "用法",
  164. },
  165. {
  166. field: "Frequency",
  167. displayName: "频率",
  168. },
  169. {
  170. field: "Days",
  171. displayName: "天数",
  172. },
  173. {
  174. field: "Total",
  175. displayName: "总量",
  176. },
  177. {
  178. field: "DataSources",
  179. displayName: "数据来源",
  180. },
  181. {
  182. field: "Remarks",
  183. displayName: "备注",
  184. },
  185. ],
  186. });
  187. },
  188. },
  189. };
  190. </script>
  191. <style lang="scss" scoped>
  192. .print_style {
  193. position: absolute;
  194. right: 10px;
  195. top: 42px;
  196. }
  197. .list_title {
  198. width: 940px;
  199. border-bottom: 1px solid;
  200. display: flex;
  201. margin: 30px auto;
  202. div {
  203. width: 230px;
  204. padding: 10px 0;
  205. }
  206. }
  207. </style>