PrintInfusionCard.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703
  1. <template>
  2. <page-layer>
  3. <template #header>
  4. <el-select v-model="queryParams.wardCode" style="width: 88px" @change="handleWardChange">
  5. <el-option v-for="item in userWards" :value="item.value" :label="item.label"></el-option>
  6. </el-select>
  7. <span class="ml12">
  8. 执行日期:<el-date-picker v-model="queryParams.executeDate" :clearable="false" style="width: 102px"
  9. @change="datePickChange"></el-date-picker>
  10. </span>
  11. <span class="ml12">床位范围:
  12. <el-select v-model="queryParams.bedNoStart" style="width: 70px" value-key="bedNo"
  13. @change="handleStartBedChange">
  14. <el-option v-for="item in patientBedList" :key="item.bedNo" :value="item">
  15. {{ item.bedNoLabel }}
  16. <el-divider direction="vertical"></el-divider>
  17. <span class="green-text">{{ item.patNo }}</span>
  18. <el-divider direction="vertical"></el-divider>
  19. <span class="blue-text">{{ item.patName }}</span>
  20. </el-option>
  21. </el-select>
  22. <span style="margin: 0 4px; font-size: 11px">至</span>
  23. <el-select v-model="queryParams.bedNoEnd" style="width: 70px" value-key="bedNo" @change="handleEndBedChange">
  24. <el-option v-for="item in patientBedList" :key="item.bedNo" :value="item"
  25. :disabled="item.sortNo < queryParams.sortNoStart">
  26. {{ item.bedNoLabel }}
  27. <el-divider direction="vertical"></el-divider>
  28. <span :class="item.sortNo < queryParams.sortNoStart ? 'is-disabled' : 'green-text'">{{ item.patNo }}</span>
  29. <el-divider direction="vertical"></el-divider>
  30. <span :class="item.sortNo < queryParams.sortNoStart ? 'is-disabled' : 'blue-text'">{{ item.patName }}</span>
  31. </el-option>
  32. </el-select>
  33. </span>
  34. <span class="ml12">
  35. 频率:
  36. <el-select v-model="queryParams.frequency" style="width: 60px">
  37. <el-option value="ALL" label="全部"></el-option>
  38. <el-option value="ALWAYS" label="长期"></el-option>
  39. <el-option value="ONCE" label="临时"></el-option>
  40. </el-select>
  41. </span>
  42. <span class="ml12">
  43. 打印范围:
  44. <el-select v-model="queryParams.printRange" style="width: 76px">
  45. <el-option value="ALL" label="全部"></el-option>
  46. <el-option value="UNPRINTED" label="新增"></el-option>
  47. <el-option value="PRINTED" label="已打印"></el-option>
  48. </el-select>
  49. </span>
  50. <span class="ml12">
  51. 类型:
  52. <el-select v-model="queryParams.cardType" @change="handleTypeChange" style="width: 76px">
  53. <el-option value="INFUSION_CARD" label="输液卡"></el-option>
  54. <el-option value="BOTTLE_CARD" label="瓶贴"></el-option>
  55. </el-select>
  56. </span>
  57. <!-- <span class="ml12" v-if="queryParams.cardType === 'BOTTLE_CARD'">
  58. 瓶贴类型:
  59. <el-select v-model="queryParams.bottleCardType" style="width: 76px">
  60. <el-option :value="2" label="输液"></el-option>
  61. <el-option :value="7" label="注射"></el-option>
  62. <el-option value="BOTTLE_CARD" label="雾化"></el-option>
  63. </el-select>
  64. </span> -->
  65. <el-divider direction="vertical"></el-divider>
  66. <el-button type="primary" icon="Search" @click="executeQuery">检索</el-button>
  67. <el-button type="primary" icon="Printer" @click="execPrint">打印</el-button>
  68. </template>
  69. <template #main>
  70. <div style="display: flex; flex-wrap: wrap" id="infusion_list">
  71. <div v-if="queryParams.cardType === 'INFUSION_CARD'">
  72. <div v-for="(item, index) in patientInfusionInfos" :id="item.patInfo.patNo">
  73. <div class="crad-area"
  74. style="width: 90%; margin: 8px 12px; padding: 4px; border: 1px solid red ;display: flex;justify-content: center; align-items: center;">
  75. <infusion-card :drug-groups="item.drugGroups" :pat-info="item.patInfo" :yz-date="queryParams.executeDate"
  76. :print-date="printDate">
  77. </infusion-card>
  78. </div>
  79. </div>
  80. </div>
  81. <div v-else id="print-test">
  82. <div v-for="(item, index) in patientInfusionInfos" :id="item.patInfo.patNo + '-' + index"
  83. style="width: 230px;display: inline-block;margin-right: 20px">
  84. <bottle-card :drugs="item.bottleCardDrugs" :pat-info="item.patInfo" :yz-date="queryParams.executeDate"
  85. :bottle-group="item.bottleGroup" style="margin-bottom: 10px;">
  86. </bottle-card>
  87. </div>
  88. </div>
  89. <div class="print-hiden-area" style="margin: 0px 12px">
  90. <div v-for="(item, index) in printPatientBottleInfos" :id="item.patInfo.patNo + '-' + index + '_print'"
  91. style="width: 230px;display: inline-block;margin-right: 20px">
  92. <bottle-card :drugs="item.bottleCardDrugs" :pat-info="item.patInfo" :yz-date="queryParams.executeDate"
  93. :bottle-group="item.bottleGroup" style="margin-bottom: 10px;">
  94. </bottle-card>
  95. </div>
  96. </div>
  97. </div>
  98. </template>
  99. </page-layer>
  100. </template>
  101. <script setup>
  102. import PageLayer from "@/layout/PageLayer.vue";
  103. import { formatDate, getDatetime, getDate } from "@/utils/date";
  104. import {
  105. getPatientBeds,
  106. queryInfusionCardOrBottleCard,
  107. updatePrintStatus
  108. } from '@/api/inpatient/nurse-module/print-infusion-card'
  109. import InfusionCard from "@/components/inpatient/nurse-module/InfusionCard.vue";
  110. import { ElMessage } from "element-plus";
  111. import { getLodop, initLodop } from "@/utils/c-lodop";
  112. import BottleCard from "@/components/inpatient/nurse-module/BottleCard.vue";
  113. import { getWardsApi } from "@/api/login";
  114. const userWards = ref([])
  115. const patientBedList = ref([])
  116. const printDate = ref(null)
  117. const handleWardChange = (wardCode) => {
  118. getPatientBeds(wardCode).then(res => {
  119. patientBedList.value = res
  120. if (res.length > 0) {
  121. queryParams.bedNoStart = res[0].bedNoLabel
  122. queryParams.sortNoStart = res[0].sortNo
  123. queryParams.bedNoEnd = res[res.length - 1].bedNoLabel
  124. queryParams.sortNoEnd = res[res.length - 1].sortNo
  125. } else {
  126. queryParams.bedNoStart = null
  127. queryParams.sortNoStart = null
  128. queryParams.bedNoEnd = null
  129. queryParams.sortNoEnd = null
  130. }
  131. })
  132. }
  133. const queryParams = reactive({
  134. executeDate: getDate(),
  135. wardCode: null,
  136. bedNoStart: null,
  137. bedNoEnd: null,
  138. sortNoStart: null,
  139. sortNoEnd: null,
  140. frequency: 'ALWAYS',
  141. printRange: 'UNPRINTED',
  142. cardType: 'INFUSION_CARD',
  143. bedNos: []
  144. })
  145. const patientInfusionInfos = ref([])
  146. const printPatientBottleInfos = ref([])
  147. const handleStartBedChange = (bed) => {
  148. queryParams.bedNoStart = bed.bedNoLabel
  149. queryParams.sortNoStart = bed.sortNo
  150. }
  151. const handleEndBedChange = (bed) => {
  152. queryParams.bedNoEnd = bed.bedNoLabel
  153. queryParams.sortNoEnd = bed.sortNo
  154. }
  155. const handleTypeChange = (val) => {
  156. // console.log("val",val)
  157. patientInfusionInfos.value = []
  158. queryParams.bottleCardType = val == "INFUSION_CARD" ? "" : 2
  159. // console.log("queryParams",queryParams)
  160. }
  161. const datePickChange = () => {
  162. patientInfusionInfos.value = []
  163. queryParams.executeDate = formatDate(queryParams.executeDate)
  164. console.log("patientInfusionInfos", patientInfusionInfos.value)
  165. }
  166. const executeQuery = () => {
  167. patientInfusionInfos.value = []
  168. queryParams.executeDate = formatDate(queryParams.executeDate)
  169. queryParams.bedNos = []
  170. patientBedList.value.forEach(bed => {
  171. if (bed.sortNo >= queryParams.sortNoStart && bed.sortNo <= queryParams.sortNoEnd) {
  172. queryParams.bedNos.push(bed.bedNo)
  173. }
  174. })
  175. queryInfusionCardOrBottleCard(queryParams).then(res => {
  176. nextTick(() => {
  177. patientInfusionInfos.value = res
  178. if (queryParams.cardType !== 'INFUSION_CARD' && patientInfusionInfos.value.length > 0) {
  179. //瓶贴分配药品组号
  180. patientInfusionInfos.value.forEach(item => {
  181. let group = patientInfusionInfos.value.filter(citem => citem.patInfo.patNo === item.patInfo.patNo)
  182. group.forEach((v, vindex) => {
  183. let target = patientInfusionInfos.value.find(citem => citem.bottleCardDrugs[0].actOrderNo === v.bottleCardDrugs[0].actOrderNo)
  184. target.bottleGroup = vindex + 1 + "/" + group.length
  185. // console.log("target",target)
  186. })
  187. // console.log("group",group)
  188. // console.log("index")
  189. })
  190. // console.log("patientInfusionInfo s",patientInfusionInfos.value)
  191. }
  192. // for (let i = 0; i < 2; i++) {
  193. // patientInfusionInfos.value = [...patientInfusionInfos.value, ...res]
  194. // }
  195. // printPatientBottleInfos.value = res
  196. printDate.value = getDatetime()
  197. })
  198. }).catch(() => {
  199. patientInfusionInfos.value = []
  200. })
  201. }
  202. const frequencyOptions = [
  203. {
  204. //每天两次
  205. arr: ['Bid', 'Q12H', 'Q12H/单日', 'Q12H/双日', 'bod'
  206. ],
  207. add: 1
  208. },
  209. {
  210. //每天三次
  211. arr: ['Tid', 'Tod'],
  212. add: 2
  213. },
  214. {
  215. //每天四次
  216. arr: ['Qid'],
  217. add: 3
  218. },
  219. ]
  220. const handlePrintByFrequency = () => {
  221. let result = [...printPatientBottleInfos.value]
  222. printPatientBottleInfos.value.forEach(item => {
  223. let frequency = item.bottleCardDrugs[0].frequCode
  224. let add = 0;
  225. for (let i = 0; i < frequencyOptions.length; i++) {
  226. if (frequencyOptions[i].arr.includes(frequency)) {
  227. add = frequencyOptions[i].add
  228. break;
  229. }
  230. }
  231. if (add > 0) {
  232. let index = result.findIndex(citem => citem.bottleCardDrugs[0].actOrderNo === item.bottleCardDrugs[0].actOrderNo);
  233. for (let i = 0; i < add; i++) {
  234. let target = { ...item }
  235. target.patInfo.patNo = target.patInfo.patNo + '_' + i
  236. result.splice(index, 0, target);
  237. }
  238. }
  239. })
  240. return result
  241. }
  242. const execPrint = () => {
  243. const type = queryParams.cardType === 'INFUSION_CARD' ? '输液卡' : '瓶贴卡'
  244. if (patientInfusionInfos.value.length === 0) {
  245. ElMessage({
  246. message: `请先检索${type}。`,
  247. type: 'warning',
  248. duration: 2500,
  249. showClose: true
  250. })
  251. return
  252. }
  253. let LODOP = getLodop();
  254. if (queryParams.cardType == 'INFUSION_CARD') {
  255. let prntContent = document.getElementById("infusion_list").innerHTML
  256. // console.log("prntContent",prntContent)
  257. let printHTML = ""
  258. const printStyle = `<style>td{border: 1px solid black;
  259. font-size: 12px;padding: 2px;}</style>`
  260. if (patientInfusionInfos.value.length == 1) {
  261. let id = queryParams.cardType === 'INFUSION_CARD'
  262. ? patientInfusionInfos.value[0].patInfo.patNo : patientInfusionInfos.value[0].patInfo.patNo + '-' + i
  263. printHTML = document.getElementById(id).innerHTML
  264. LODOP.PRINT_INIT('infusionCard')
  265. LODOP.SET_PRINT_PAGESIZE(1, '210mm', '297mm', '')
  266. LODOP.ADD_PRINT_HTML('0mm', '0mm', '210mm', '297mm', printStyle + '<body style:"display: flex;justify-content: center;align-items: center;">' + printHTML + '</body>')
  267. LODOP.SET_PRINT_STYLE('ItemType', 3)
  268. LODOP.PREVIEW();
  269. } else {
  270. LODOP.PRINT_INIT('infusionCard')
  271. LODOP.SET_PRINT_PAGESIZE(1, '210mm', '297mm', '')
  272. let PAGE_MAX_HEIGHT = 1050
  273. let pageHeightNow = 0
  274. let currentPageHTML = '';
  275. for (let i = 0; i < patientInfusionInfos.value.length; i++) {
  276. let info = patientInfusionInfos.value[i]
  277. let printTarget = document.getElementById(info.patInfo.patNo)
  278. console.log('printTarget', printTarget)
  279. if (pageHeightNow + printTarget.offsetHeight > PAGE_MAX_HEIGHT) {
  280. LODOP.ADD_PRINT_HTML('0mm', '0mm', '210mm', '297mm', printStyle + currentPageHTML);
  281. LODOP.NewPage(); // 开启新页
  282. // 新页初始化:当前行作为新页的第一行
  283. currentPageHTML = printTarget.innerHTML;
  284. pageHeightNow = printTarget.offsetHeight;
  285. } else {
  286. pageHeightNow += printTarget.offsetHeight
  287. currentPageHTML += printTarget.innerHTML
  288. }
  289. // let info = patientInfusionInfos.value[i]
  290. // let id = queryParams.cardType === 'INFUSION_CARD'
  291. // ? info.patInfo.patNo : info.patInfo.patNo + '-' + i
  292. // let printCount = queryParams.cardType === 'INFUSION_CARD'
  293. // ? 3 : 6
  294. // // console.log("printCount",printCount)
  295. // if (i !== 0 && ((i + 1) % printCount == 0 || i == patientInfusionInfos.value.length - 1)) {
  296. // // console.log("printIndex",i)
  297. // printHTML = document.getElementById(id).innerHTML + printHTML
  298. // let printFinal = printStyle + '<body><div style:"width:600px;display: flex;justify-content: center;align-items: center;flex-wrap: wrap;">' + printHTML + '</div></body>';
  299. // console.log("printFinal", printFinal)
  300. // // LODOP.ADD_PRINT_HTML('0mm', '0mm', '210mm', '297mm',printStyle + '<body style:"width:800px;display: flex;justify-content: center;align-items: center;flex-wrap: wrap;">' + printHTML + '</body>' )
  301. // LODOP.ADD_PRINT_HTML('0mm', '0mm', '210mm', '297mm', printFinal)
  302. // LODOP.SET_PRINT_STYLE('ItemType', 3)
  303. // LODOP.PREVIEW();
  304. // // LODOP.PRINT()
  305. // printHTML = ""
  306. // } else {
  307. // printHTML += document.getElementById(id).innerHTML
  308. // }
  309. }
  310. LODOP.ADD_PRINT_HTML('0mm', '0mm', '210mm', '297mm', printStyle + currentPageHTML);
  311. LODOP.PREVIEW()
  312. }
  313. updatePrintState()
  314. } else {
  315. printPatientBottleInfos.value = [...patientInfusionInfos.value]
  316. printPatientBottleInfos.value = handlePrintByFrequency()
  317. // console.log("patientInfusionInfos",patientInfusionInfos.value)
  318. // console.log("printPatientBottleInfos",printPatientBottleInfos.value)
  319. nextTick(() => {
  320. // LODOP.PRINT_INIT('infusionCard');
  321. // LODOP.SET_PRINT_PAGESIZE(1, '210mm', '297mm', '');
  322. // /* 一行3个,预留间距 */
  323. // const printStyle = `<style>
  324. // .card-container { display: inline; }
  325. // td { border: 1px solid black; font-size: 12px; padding: 2px; }
  326. // </style>`;
  327. // const PAGE_MAX_HEIGHT = 1100; // 页面最大高度阈值(px)
  328. // let currentPageHTML = printStyle; // 当前页内容
  329. // let currentPageTotalHeight = 0; // 当前页累计高度(px)
  330. // let currentRowElements = []; // 当前行的元素
  331. // let currentRowMaxHeight = 0; // 当前行最高元素高度(px)
  332. // printPatientBottleInfos.value.forEach((item, index) => {
  333. // const printTarget = document.getElementById(`${item.patInfo.patNo}-${index}_print`);
  334. // if (!printTarget) return;
  335. // // 获取当前元素高度(px)
  336. // const itemHeight = printTarget.offsetHeight;
  337. // // 1. 处理当前行:添加元素并更新行最高高度
  338. // currentRowElements.push(printTarget);
  339. // currentRowMaxHeight = Math.max(currentRowMaxHeight, itemHeight);
  340. // // 2. 当行内元素满3个时,计算行高并判断是否分页
  341. // if (currentRowElements.length === 3) {
  342. // // 计算当前行加入后,页面的总高度
  343. // const totalHeightAfterAdd = currentPageTotalHeight + currentRowMaxHeight;
  344. // // 3. 判断是否需要分页
  345. // if (totalHeightAfterAdd > PAGE_MAX_HEIGHT) {
  346. // // 先打印当前页已有的内容
  347. // LODOP.ADD_PRINT_HTML('0mm', '0mm', '210mm', '297mm', currentPageHTML);
  348. // LODOP.NewPage(); // 开启新页
  349. // // 新页初始化:当前行作为新页的第一行
  350. // currentPageHTML = printStyle;
  351. // currentPageTotalHeight = currentRowMaxHeight;
  352. // } else {
  353. // // 不需要分页,累加当前行高度
  354. // currentPageTotalHeight = totalHeightAfterAdd;
  355. // }
  356. // // 4. 将当前行的3个元素添加到页面HTML
  357. // currentRowElements.forEach(el => {
  358. // currentPageHTML += `<div class="card-container">${el.outerHTML}</div>`;
  359. // });
  360. // // 5. 重置行状态,准备下一行
  361. // currentRowElements = [];
  362. // currentRowMaxHeight = 0;
  363. // }
  364. // });
  365. // // 6. 处理最后一行未填满3个元素的情况
  366. // if (currentRowElements.length > 0) {
  367. // // 计算剩余行加入后的总高度
  368. // const totalHeightAfterAdd = currentPageTotalHeight + currentRowMaxHeight;
  369. // // 如果超出页面高度,单独分页
  370. // if (totalHeightAfterAdd > PAGE_MAX_HEIGHT) {
  371. // LODOP.ADD_PRINT_HTML('0mm', '0mm', '210mm', '297mm', currentPageHTML);
  372. // LODOP.NewPage();
  373. // currentPageHTML = printStyle;
  374. // currentPageTotalHeight = currentRowMaxHeight;
  375. // } else {
  376. // currentPageTotalHeight = totalHeightAfterAdd;
  377. // }
  378. // // 添加剩余元素到页面
  379. // currentRowElements.forEach(el => {
  380. // currentPageHTML += `<div class="card-container">${el.outerHTML}</div>`;
  381. // });
  382. // }
  383. // // 7. 添加最后一页内容
  384. // if (currentPageHTML) {
  385. // LODOP.ADD_PRINT_HTML('0mm', '0mm', '210mm', '297mm', currentPageHTML);
  386. // }
  387. // LODOP.PREVIEW();
  388. LODOP.PRINT_INIT('infusionCard');
  389. LODOP.SET_PRINT_PAGESIZE(1, '210mm', '297mm', '');
  390. /* 一行3个,使用float布局确保兼容性 */
  391. const printStyle = `<style>
  392. .card-row { overflow: hidden; margin-bottom: 10px; } /* 清除浮动并添加行间距 */
  393. .card-container {
  394. float: left;
  395. width: 31.5%;
  396. box-sizing: border-box;
  397. padding: 0 5px; /* 预留间距 */
  398. }
  399. td { border: 1px solid black; font-size: 12px; padding: 2px; }
  400. /* 最后一个元素清除右侧内边距 */
  401. .card-container:nth-child(3n) { padding-right: 0; }
  402. /* 第一个元素清除左侧内边距 */
  403. .card-container:nth-child(3n+1) { padding-left: 0; }
  404. </style>`;
  405. const PAGE_MAX_HEIGHT = 840; // 页面最大高度阈值(px)
  406. let currentPageHTML = printStyle; // 当前页内容
  407. let currentPageTotalHeight = 0; // 当前页累计高度(px)
  408. let currentRowHTML = ''; // 当前行的HTML内容
  409. let currentRowElements = []; // 当前行的元素
  410. let currentRowMaxHeight = 0; // 当前行最高元素高度(px)
  411. printPatientBottleInfos.value.forEach((item, index) => {
  412. const printTarget = document.getElementById(`${item.patInfo.patNo}-${index}_print`);
  413. if (!printTarget) return;
  414. // 获取当前元素高度(px)
  415. const itemHeight = printTarget.offsetHeight;
  416. // 1. 处理当前行:添加元素并更新行最高高度
  417. currentRowElements.push(printTarget);
  418. currentRowMaxHeight = Math.max(currentRowMaxHeight, itemHeight);
  419. currentRowHTML += `<div class="card-container">${printTarget.outerHTML}</div>`;
  420. // 2. 当行内元素满3个时,计算行高并判断是否分页
  421. if (currentRowElements.length === 3) {
  422. // 包装当前行为一个带清除浮动的容器
  423. const rowWithClearfix = `<div class="card-row">${currentRowHTML}</div>`;
  424. // 计算当前行加入后,页面的总高度
  425. const totalHeightAfterAdd = currentPageTotalHeight + currentRowMaxHeight;
  426. // 3. 判断是否需要分页
  427. if (totalHeightAfterAdd > PAGE_MAX_HEIGHT) {
  428. // 先打印当前页已有的内容
  429. LODOP.ADD_PRINT_HTML('0mm', '0mm', '210mm', '297mm', currentPageHTML);
  430. LODOP.NewPage(); // 开启新页
  431. // 新页初始化:当前行作为新页的第一行
  432. currentPageHTML = printStyle + rowWithClearfix;
  433. currentPageTotalHeight = currentRowMaxHeight;
  434. } else {
  435. // 不需要分页,累加当前行高度并添加到页面
  436. currentPageHTML += rowWithClearfix;
  437. currentPageTotalHeight = totalHeightAfterAdd;
  438. }
  439. // 5. 重置行状态,准备下一行
  440. currentRowElements = [];
  441. currentRowMaxHeight = 0;
  442. currentRowHTML = '';
  443. }
  444. });
  445. // 6. 处理最后一行未填满3个元素的情况
  446. if (currentRowElements.length > 0) {
  447. // 包装当前行为一个带清除浮动的容器
  448. const rowWithClearfix = `<div class="card-row">${currentRowHTML}</div>`;
  449. // 计算剩余行加入后的总高度
  450. const totalHeightAfterAdd = currentPageTotalHeight + currentRowMaxHeight;
  451. // 如果超出页面高度,单独分页
  452. if (totalHeightAfterAdd > PAGE_MAX_HEIGHT) {
  453. LODOP.ADD_PRINT_HTML('0mm', '0mm', '210mm', '297mm', currentPageHTML);
  454. LODOP.NewPage();
  455. currentPageHTML = printStyle + rowWithClearfix;
  456. currentPageTotalHeight = currentRowMaxHeight;
  457. } else {
  458. currentPageHTML += rowWithClearfix;
  459. currentPageTotalHeight = totalHeightAfterAdd;
  460. }
  461. }
  462. // 7. 添加最后一页内容
  463. if (currentPageHTML) {
  464. LODOP.ADD_PRINT_HTML('0mm', '0mm', '210mm', '297mm', currentPageHTML);
  465. }
  466. LODOP.PREVIEW();
  467. printPatientBottleInfos.value = []
  468. // LODOP.PRINT_INIT('infusionCard')
  469. // LODOP.SET_PRINT_PAGESIZE(1, '210mm', '297mm', '')
  470. // let printHTML = "";
  471. // let pageHeightNow = 0;
  472. // let pageHeighInRow = 0;
  473. // let rowCount = 0;
  474. // let isWarp = false;
  475. // let isRowHeightNew = true
  476. // const printStyle = `<style>td{border: 1px solid black;
  477. // font-size: 12px;padding: 2px;}</style>`
  478. // patientInfusionInfos.value.forEach((item, index) => {
  479. // let printTarget = document.getElementById(item.patInfo.patNo + '-' + index);
  480. // console.log("printTarget", printTarget.offsetHeight)
  481. // if (printTarget.offsetHeight > pageHeighInRow) {
  482. // pageHeighInRow = printTarget.offsetHeight;
  483. // isRowHeightNew = true;
  484. // }
  485. // // console.log("pageHeighInRow", pageHeighInRow)
  486. // // console.log("pageHeightNow", pageHeightNow)
  487. // // console.log("HeightAll", pageHeighInRow + pageHeightNow)
  488. // if (isWarp) {
  489. // isWarp = false
  490. // // if(isRowHeightNew)
  491. // if (isRowHeightNew && pageHeighInRow + pageHeightNow > 900) {
  492. // // console.log("11")
  493. // // 此时超出一页
  494. // // LODOP.PRINT()
  495. // rowCount = 0
  496. // LODOP.ADD_PRINT_HTML('0mm', '0mm', '210mm', '297mm', printStyle + printHTML)
  497. // LODOP.NewPage(); // 关键:开启新页
  498. // printHTML = printTarget.outerHTML;
  499. // pageHeightNow = pageHeighInRow;
  500. // // isWarp = true
  501. // rowCount = 1; // 重置行计数
  502. // } else {
  503. // // console.log("2")
  504. // // pageHeightNow = pageHeighInRow + pageHeightNow;
  505. // printHTML += printTarget.outerHTML;
  506. // }
  507. // } else {
  508. // rowCount++;
  509. // isRowHeightNew = false
  510. // if (rowCount == 3) {
  511. // // 换行
  512. // isWarp = true;
  513. // rowCount = 0;
  514. // isRowHeightNew = true;
  515. // pageHeightNow = pageHeighInRow + pageHeightNow;
  516. // console.log('pageHeightNow',pageHeightNow)
  517. // }
  518. // printHTML += printTarget.outerHTML;
  519. // }
  520. // });
  521. // if (printHTML) {
  522. // LODOP.ADD_PRINT_HTML('0mm', '0mm', '210mm', '297mm', printStyle + printHTML);
  523. // }
  524. // let prntContent1 = document.getElementById("print-test").innerHTML
  525. // let flexStyles = getStyleText('.print-bottle-card-area');
  526. // // const printStyle = `<style>${flexStyles}td{border: 1px solid black;
  527. // // font-size: 12px;padding: 2px;}</style>`
  528. // // let printFinal = printStyle + prntContent1
  529. // // console.log("prntContent1", prntContent1)
  530. // // LODOP.ADD_PRINT_HTML('0mm', '0mm', '210mm', '297mm', printFinal)
  531. // // LODOP.SET_PRINT_STYLE('ItemType', 3)
  532. // LODOP.PREVIEW();
  533. updatePrintState()
  534. });
  535. }
  536. }
  537. function updatePrintState() {
  538. const params = {
  539. cardType: queryParams.cardType,
  540. orderNos: []
  541. }
  542. patientInfusionInfos.value.forEach(info => {
  543. if (params.cardType === 'INFUSION_CARD') {
  544. info.drugGroups.forEach(group => {
  545. params.orderNos.push(group.mainDrug.actOrderNo)
  546. })
  547. } else {
  548. info.bottleCardDrugs.forEach(group => {
  549. params.orderNos.push(group.actOrderNo)
  550. })
  551. }
  552. })
  553. nextTick(() => {
  554. updatePrintStatus(params).then(res => {
  555. console.log(res)
  556. })
  557. })
  558. }
  559. function getStyleText(selector) {
  560. var sheets = document.styleSheets;
  561. var styleText = '';
  562. for (var i = 0; i < sheets.length; i++) {
  563. try {
  564. var rules = sheets[i].cssRules || sheets[i].rules;
  565. if (rules) {
  566. for (var j = 0; j < rules.length; j++) {
  567. if (rules[j].selectorText && rules[j].selectorText.includes(selector)) {
  568. styleText += rules[j].cssText + '\n';
  569. }
  570. }
  571. }
  572. } catch (e) { /* 可能跨域安全错误 */ }
  573. }
  574. return styleText;
  575. }
  576. // J,S,JS,SJ
  577. // -- 小输液卡
  578. // -- 已打印:print_comment like '%S%'
  579. // -- 未打印:isnull(print_comment,'') not like '%S%'
  580. //
  581. // -- 已打印:print_comment like '%J%'
  582. // -- 未打印:isnull(print_comment,'') not like '%J%'
  583. onMounted(() => {
  584. initLodop()
  585. getWardsApi().then(res => {
  586. userWards.value = res
  587. if (!queryParams.wardCode) {
  588. queryParams.wardCode = userWards.value[0].value
  589. }
  590. handleWardChange(queryParams.wardCode)
  591. })
  592. })
  593. </script>
  594. <style scoped>
  595. .ml12 {
  596. margin-left: 12px;
  597. }
  598. .green-text {
  599. color: green;
  600. }
  601. .blue-text {
  602. color: #1146f3
  603. }
  604. .is-disabled {
  605. color: #a8abb2;
  606. }
  607. .crad-area {
  608. width: 100%;
  609. display: flex;
  610. justify-content: center;
  611. align-items: center;
  612. }
  613. .print-bottle-card-area {
  614. width: 730px;
  615. display: flex;
  616. justify-content: space-between;
  617. align-items: center;
  618. flex-wrap: wrap;
  619. /* float: left; */
  620. padding: 15px 5px;
  621. }
  622. .print-hiden-area {
  623. /* display: none; */
  624. }
  625. @media print {
  626. .your-flex-container {
  627. display: flex !important;
  628. flex-direction: row !important;
  629. /* 其他必要flex属性 */
  630. }
  631. .flex-item {
  632. flex: 1 !important;
  633. }
  634. .print-bottle-card-area {
  635. width: 700px;
  636. display: flex;
  637. justify-content: center;
  638. /* align-items: center; */
  639. flex-wrap: wrap;
  640. }
  641. }
  642. </style>