Elizabeth's proactive approach involves introducing urinal toilet attachment , an ingenious concept that optimizes space and functionality.

detail.vue 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557
  1. <template>
  2. <!-- <div class="main-contain outpatientChargesManagement">
  3. <div class="position">
  4. <bread-crumb :crumbs='crumbs'></bread-crumb>
  5. </div> -->
  6. <div>
  7. <div style="display: flex;justify-content: space-between;margin-bottom:10px;">
  8. <div>
  9. <!--<el-button size="small" style="margin-left:10px;" class="filter-item" type="primary"-->
  10. <!--@click="Action">-->
  11. <!--导出-->
  12. <!--</el-button>-->
  13. <el-input size="small" style="width:150px;" v-model="keywords" @input="searchAction"
  14. @keyup.enter.native='searchAction'
  15. placeholder="请输入患者姓名"
  16. class="filter-item"/>
  17. <el-select size="small" v-model="item_type" placeholder="请选择"
  18. style="width:150px;margin-left:10px;" @change="changeItem">
  19. <el-option
  20. label="全部"
  21. value="0">
  22. </el-option>
  23. <el-option
  24. v-for="item,index in items"
  25. :key="index"
  26. :label="item.name"
  27. :value="item.id">
  28. </el-option>
  29. </el-select>
  30. <el-date-picker
  31. v-model="chargeDate"
  32. type="daterange"
  33. value-format="yyyy-MM-dd"
  34. range-separator="至"
  35. start-placeholder="开始日期"
  36. @change="changeDate"
  37. end-placeholder="结束日期">
  38. </el-date-picker>
  39. <!--<el-radio v-model="radio" label="1">明细</el-radio>-->
  40. <!--<el-radio v-model="radio" label="2">汇总</el-radio>-->
  41. </div>
  42. <div>
  43. <!-- <el-popover
  44. placement="bottom"
  45. width="210"
  46. trigger="click">
  47. <el-button size="small" ref="button_two" @click="open(1)">打印清单</el-button>
  48. <el-button size="small" ref="button_six" @click="open(2)">打印汇总</el-button>
  49. <el-button slot="reference" style="margin:0 10px;" type="primary" size="small">打印</el-button>
  50. </el-popover> -->
  51. <el-button size="small" type="primary" @click="export_detail">报表下载</el-button>
  52. </div>
  53. </div>
  54. <el-table :data="tableData" border :row-style="{ color: '#303133' }" ref="table"
  55. :header-cell-style="{backgroundColor: 'rgb(245, 247, 250)',color: '#606266'}"
  56. :span-method="merge"
  57. show-summary
  58. :summary-method="getTotal"
  59. max-height="600"
  60. v-loading="detail_loading"
  61. highlight-current-row>
  62. <el-table-column align="center" prop="name" label="患者名字">
  63. <template slot-scope="scope">{{ scope.row.name }}</template>
  64. </el-table-column>
  65. <!--<el-table-column align="center" prop="name" label="患者类型">-->
  66. <!--<template slot-scope="scope"></template>-->
  67. <!--</el-table-column>-->
  68. <el-table-column align="center" prop="name" label="项目名称">
  69. <template slot-scope="scope">{{scope.row.item_name}}</template>
  70. </el-table-column>
  71. <el-table-column align="center" prop="name" label="数量">
  72. <template slot-scope="scope">{{scope.row.count}}</template>
  73. </el-table-column>
  74. <el-table-column align="center" prop="name" label="单价">
  75. <template slot-scope="scope">{{scope.row.price.toFixed(2)}}</template>
  76. </el-table-column>
  77. <el-table-column align="center" prop="name" label="费用">
  78. <template slot-scope="scope">
  79. <div>{{(scope.row.price.toFixed(2)*scope.row.count).toFixed(2)}}</div>
  80. </template>
  81. </el-table-column>
  82. <el-table-column align="center" prop="total" label="费用总额">
  83. <template slot-scope="scope">
  84. <div>{{scope.row.total.toFixed(2)}}</div>
  85. </template>
  86. </el-table-column>
  87. </el-table>
  88. </div>
  89. <!-- </div> -->
  90. </template>
  91. <script>
  92. import BreadCrumb from '@/xt_pages/components/bread-crumb'
  93. import { GetSummaryDetail } from '@/api/his/his'
  94. import { uParseTime } from '@/utils/tools'
  95. // import NewStatementPrint from './newStatementPrint'
  96. const moment = require('moment')
  97. export default {
  98. components: {
  99. BreadCrumb
  100. },
  101. data() {
  102. return {
  103. detail_loading:false,
  104. tempArr: [],
  105. pos:0,
  106. sameRowArr: [],
  107. keywords: '',
  108. tableData: [],
  109. chargeDate: [moment(new Date()).add('year', 0).format('YYYY-MM-DD'), moment(new Date()).add('year', 0).format('YYYY-MM-DD')],
  110. item_type: '0',
  111. items: [
  112. { id: 1, name: '药品' },
  113. { id: 2, name: '项目' },
  114. { id: 3, name: '耗材' },
  115. ]
  116. }
  117. },
  118. methods: {
  119. objectSpanMethod({ row, column, rowIndex, columnIndex }) {
  120. if (columnIndex === 0) {
  121. if (rowIndex % 2 === 0) {
  122. return {
  123. rowspan: 2,
  124. colspan: 1
  125. }
  126. } else {
  127. return {
  128. rowspan: 0,
  129. colspan: 0
  130. }
  131. }
  132. }
  133. },
  134. unique(arr) {
  135. const res = new Map()
  136. return arr.filter((arr) => !res.has(arr.id) && res.set(arr.id, 1))
  137. },
  138. changeDate() {
  139. this.getSummaryDetailList()
  140. },
  141. changeItem() {
  142. this.getSummaryDetailList()
  143. },
  144. searchAction() {
  145. this.item_type = '0'
  146. this.getSummaryDetailList()
  147. },
  148. getSummaryDetailList() {
  149. this.detail_loading = true
  150. let start_time = this.chargeDate[0]
  151. let end_time = this.chargeDate[1]
  152. let params = {
  153. start_time: start_time,
  154. end_time: end_time,
  155. type: this.item_type,
  156. keyword: this.keywords
  157. }
  158. GetSummaryDetail(params).then(response => {
  159. if (response.data.state == 0) {
  160. this.detail_loading = false
  161. this.$message.error(response.data.msg)
  162. return false
  163. } else {
  164. this.detail_loading = false
  165. this.tableData = []
  166. let tempPatients = []
  167. let tempPatientsTwo = []
  168. let tempData = response.data.data.patients
  169. let data = response.data.data.patients
  170. let orders = this.unique(tempData)
  171. for (let i = 0; i < orders.length; i++) {
  172. let obj = {
  173. patient_id: orders[i].id,
  174. name: orders[i].name,
  175. orders: []
  176. }
  177. for (let b = 0; b < data.length; b++) {
  178. if (orders[i].id == data[b].id) {
  179. obj.orders = obj.orders.concat(data[b].orders)
  180. }
  181. }
  182. tempPatients.push(obj)
  183. }
  184. for (let i = 0; i < tempPatients.length; i++) {
  185. let obj = {
  186. patient_id: tempPatients[i].patient_id,
  187. name: tempPatients[i].name,
  188. order_info: []
  189. }
  190. let orders = tempPatients[i].orders
  191. for (let b = 0; b < orders.length; b++) {
  192. for (let c = 0; c < orders[b].order_info.length; c++) {
  193. let newObj = {}
  194. newObj['count'] = orders[b].order_info[c].cnt
  195. newObj['price'] = orders[b].order_info[c].pric
  196. if (orders[b].order_info[c].advice_id > 0 && orders[b].order_info[c].project_id == 0) {
  197. newObj['type'] = 1
  198. // newObj['item_name'] = orders[b].order_info[c].advice.advice_name
  199. newObj['item_id'] = orders[b].order_info[c].advice.drug_id
  200. if(orders[b].order_info[c].advice.drug.min_unit != orders[b].order_info[c].advice.drug.dose_unit) {
  201. newObj['item_name'] = orders[b].order_info[c].advice.advice_name + "( " + orders[b].order_info[c].advice.drug.dose + orders[b].order_info[c].advice.drug.dose_unit + "*" + orders[b].order_info[c].advice.drug.min_number + orders[b].order_info[c].advice.drug.min_unit + "/" + orders[b].order_info[c].advice.drug.max_unit + " )"
  202. }else{
  203. newObj['item_name'] = ""
  204. }
  205. }
  206. if (orders[b].order_info[c].advice_id == 0 && orders[b].order_info[c].project_id > 0) {
  207. newObj['type'] = 2
  208. newObj['item_id'] = orders[b].order_info[c].project.project_id
  209. if (orders[b].order_info[c].project.type == 2) {
  210. newObj['item_name'] = orders[b].order_info[c].project.project.project_name
  211. } else if (orders[b].order_info[c].project.type == 3) {
  212. newObj['item_name'] = orders[b].order_info[c].project.good_info.good_name + "( "+ orders[b].order_info[c].project.good_info.specification_name+" )"
  213. }
  214. }
  215. obj.order_info.push(newObj)
  216. }
  217. }
  218. tempPatientsTwo.push(obj)
  219. }
  220. for (let d = 0; d < tempPatientsTwo.length; d++) {
  221. tempPatientsTwo[d]['new_order_info'] = []
  222. let project = []
  223. let advice = []
  224. for (let b = 0; b < tempPatientsTwo[d].order_info.length; b++) {
  225. if (tempPatientsTwo[d].order_info[b].type == 1) {
  226. advice.push(tempPatientsTwo[d].order_info[b])
  227. } else {
  228. project.push(tempPatientsTwo[d].order_info[b])
  229. }
  230. }
  231. project = this.uniqueProjectAndAdvice(project)
  232. advice = this.uniqueProjectAndAdvice(advice)
  233. for (let i = 0; i < project.length; i++) {
  234. let obj = {}
  235. let count = 0
  236. for (let a = 0; a < tempPatientsTwo[d].order_info.length; a++) {
  237. if (project[i].item_id == tempPatientsTwo[d].order_info[a].item_id && project[i].price == tempPatientsTwo[d].order_info[a].price) {
  238. count = count + tempPatientsTwo[d].order_info[a].count
  239. }
  240. }
  241. obj['price'] = project[i].price
  242. obj['type'] = project[i].type
  243. obj['item_name'] = project[i].item_name
  244. obj['item_id'] = project[i].item_id
  245. obj['name'] = tempPatientsTwo[d].name
  246. obj['patient_id'] = tempPatientsTwo[d].patient_id
  247. obj['count'] = count
  248. tempPatientsTwo[d].new_order_info.push(obj)
  249. }
  250. for (let i = 0; i < advice.length; i++) {
  251. let obj = {}
  252. let count = 0
  253. for (let a = 0; a < tempPatientsTwo[d].order_info.length; a++) {
  254. if (advice[i].item_id == tempPatientsTwo[d].order_info[a].item_id && advice[i].price == tempPatientsTwo[d].order_info[a].price) {
  255. count = count + tempPatientsTwo[d].order_info[a].count
  256. }
  257. }
  258. obj['price'] = advice[i].price
  259. obj['type'] = advice[i].type
  260. obj['item_name'] = advice[i].item_name
  261. obj['item_id'] = advice[i].item_id
  262. obj['name'] = tempPatientsTwo[d].name
  263. obj['patient_id'] = tempPatientsTwo[d].patient_id
  264. obj['count'] = count
  265. tempPatientsTwo[d].new_order_info.push(obj)
  266. }
  267. }
  268. for (let i = 0; i < tempPatientsTwo.length; i++) {
  269. let total = 0
  270. for (let b = 0; b < tempPatientsTwo[i].new_order_info.length; b++) {
  271. let new_name = tempPatientsTwo[i].new_order_info[b].item_name
  272. new_name=new_name.replace("( ","");
  273. new_name=new_name.replace(" )","");
  274. if (new_name.length != 0) {
  275. total = parseFloat(total) + parseFloat((parseFloat(tempPatientsTwo[i].new_order_info[b].count.toString()) * parseFloat(tempPatientsTwo[i].new_order_info[b].price.toString().toString())).toFixed(2))
  276. }
  277. }
  278. tempPatientsTwo[i]['total'] = total
  279. }
  280. console.log('tempPatientsTwo',tempPatientsTwo)
  281. for (let i = 0; i < tempPatientsTwo.length; i++) {
  282. // console.log(111,tempPatientsTwo[i].total)
  283. if(tempPatientsTwo[i].new_order_info.length > 0){
  284. for (let b = 0; b < tempPatientsTwo[i].new_order_info.length; b++) {
  285. let new_name = tempPatientsTwo[i].new_order_info[b].item_name
  286. new_name=new_name.replace("( ","");
  287. new_name=new_name.replace(" )","");
  288. if (new_name.length != 0) {
  289. let obj = {
  290. name: tempPatientsTwo[i].name,
  291. patient_id: tempPatientsTwo[i].patient_id,
  292. price: tempPatientsTwo[i].new_order_info[b].price,
  293. type: tempPatientsTwo[i].new_order_info[b].type,
  294. item_name: tempPatientsTwo[i].new_order_info[b].item_name,
  295. item_id: tempPatientsTwo[i].new_order_info[b].item_id,
  296. count: tempPatientsTwo[i].new_order_info[b].count,
  297. }
  298. // if(b == 0){
  299. obj['total'] = tempPatientsTwo[i].total
  300. // }else{
  301. // obj['total'] = 0
  302. // }
  303. this.tableData.push(obj)
  304. }
  305. }
  306. }
  307. }
  308. this.handleSpanTempArr()
  309. // this.tableData = tempPatientsTwo
  310. // console.log(tempPatientsTwo.length)
  311. //
  312. }
  313. //
  314. // console.log('去重前')
  315. // console.log(advice)
  316. // console.log(project)
  317. // //
  318. // //
  319. // //
  320. // console.log('去重后')
  321. //
  322. // console.log(advice.length)
  323. // console.log(project.length)
  324. //
  325. // for (let i = 0; i < project.length; i++) {
  326. // let obj = {}
  327. // let count = 0
  328. // for (let a = 0; a < tempPatientsTwo.length; a++) {
  329. // if (project[i].patient_id == tempPatientsTwo[a].patient_id && project[i].item_id == tempPatientsTwo[a].item_id && project[i].price == tempPatientsTwo[a].price) {
  330. // count = count + tempPatientsTwo[a].count
  331. // obj['count'] = count
  332. //
  333. // }
  334. // obj['price'] = project[i].price
  335. // obj['type'] = project[i].type
  336. // obj['item_name'] = project[i].item_name
  337. // obj['item_id'] = project[i].item_id
  338. // obj['name'] = project[i].name
  339. // obj['patient_id'] = project[i].patient_id
  340. // obj['count'] = count
  341. // this.tableData.push(obj)
  342. // }
  343. // }
  344. //
  345. //
  346. // for (let i = 0; i < advice.length; i++) {
  347. // let obj = {}
  348. // let count = 0
  349. // for (let a = 0; a < tempPatientsTwo.length; a++) {
  350. // if (advice[i].patient_id == tempPatientsTwo[a].patient_id && advice[i].item_id == tempPatientsTwo[a].item_id && advice[i].price == tempPatientsTwo[a].price) {
  351. // count = count + tempPatientsTwo[a].count
  352. // obj['count'] = count
  353. //
  354. // }
  355. // obj['price'] = advice[i].price
  356. // obj['type'] = advice[i].type
  357. // obj['item_name'] = advice[i].item_name
  358. // obj['item_id'] = advice[i].item_id
  359. // obj['name'] = advice[i].name
  360. // obj['patient_id'] = advice[i].patient_id
  361. // this.tableData.push(obj)
  362. // }
  363. // }
  364. // console.log(this.tableData.length)
  365. // this.tableData = this.sort(this.tableData)
  366. })
  367. }, uniqueProjectAndAdvice(array) {
  368. // res用来存储结果
  369. var res = []
  370. for (var i = 0, arrayLen = array.length; i < arrayLen; i++) {
  371. for (var j = 0, resLen = res.length; j < resLen; j++) {
  372. if (array[i].item_id === res[j].item_id && array[i].price === res[j].price) {
  373. break
  374. }
  375. }
  376. // 如果array[i]是唯一的,那么执行完循环,j等于resLen
  377. if (j === resLen) {
  378. res.push(array[i])
  379. }
  380. }
  381. return res
  382. }, sort(arr) {
  383. for (var i = 0; i < arr.length - 1; i++) {
  384. for (var j = 0; j < arr.length - i - 1; j++) {
  385. if (arr[j].patient_id > arr[j + 1].patient_id) {// 相邻元素两两对比
  386. var hand = arr[j]
  387. arr[j] = arr[j + 1]
  388. arr[j + 1] = hand
  389. }
  390. }
  391. }
  392. return arr
  393. }, handleSpanTempArr() {
  394. this.tempArr = []
  395. for (let i = 0; i < this.tableData.length; i++) {
  396. if (i === 0) {
  397. this.tempArr.push(1)
  398. this.pos = 0
  399. } else {
  400. // 判断当前元素与上一个元素是否相同
  401. if (this.tableData[i].patient_id === this.tableData[i - 1].patient_id) {
  402. this.tempArr[this.pos] += 1
  403. this.tempArr.push(0)
  404. } else {
  405. this.tempArr.push(1)
  406. this.pos = i
  407. }
  408. }
  409. }
  410. let sameRowArr = [], sIdx = 0
  411. this.tableData.forEach((item, index) => {
  412. item.index = index
  413. if (index === 0) {
  414. sameRowArr.push([index])
  415. } else {
  416. if (item.patient_id === this.tableData[index - 1].patient_id) {
  417. sameRowArr[sIdx].push(index)
  418. } else {
  419. sIdx = sIdx + 1
  420. sameRowArr.push([index])
  421. }
  422. }
  423. })
  424. this.sameRowArr = sameRowArr
  425. }, merge({ row, column, rowIndex, columnIndex }) {
  426. if (columnIndex === 0 || columnIndex === 5) {
  427. const _row = this.tempArr[rowIndex]
  428. const _col = _row > 0 ? 1 : 0
  429. return {
  430. rowspan: _row,
  431. colspan: _col
  432. }
  433. }
  434. }, export_detail() {
  435. let list = []
  436. for (let i = 0; i < this.tableData.length; i++) {
  437. let order = this.tableData[i]
  438. let name = order.name
  439. let item_name = order.item_name
  440. let count = order.count
  441. let price = order.price.toFixed(2)
  442. let pay_sumamt = (order.price.toFixed(2)*order.count).toFixed(2)
  443. let total = order.total.toFixed(2)
  444. let obj = {
  445. '患者姓名': name,
  446. '项目名称': item_name,
  447. '数量': count,
  448. '单价': price,
  449. '费用': pay_sumamt,
  450. '费用总额':total,
  451. }
  452. list.push(obj)
  453. }
  454. import('@/vendor/Export2Excel').then(excel => {
  455. const tHeader = [ '患者姓名', '项目名称', '数量', '单价', '费用', '费用总额']
  456. const filterVal = [ '患者姓名', '项目名称', '数量', '单价', '费用', '费用总额']
  457. const data = this.formatJson(filterVal, list)
  458. excel.export_json_to_excel1({
  459. header: tHeader,
  460. data,
  461. filename: '明细',
  462. ref:this.$refs['table'].$el
  463. })
  464. })
  465. }, formatJson(filterVal, jsonData) {
  466. return jsonData.map(v => filterVal.map(j => v[j]))
  467. }, getTotal(param) {
  468. const { columns, data } = param
  469. const sums = []
  470. columns.forEach((column, index) => {
  471. if (index === 0) {
  472. sums[index] = '合计'
  473. return
  474. }
  475. console.log(data)
  476. const values = data.map(item => Number(item[column.property]))
  477. if (column.property === 'total') {
  478. // sums[index] = values.reduce((prev, curr) => {
  479. // const value = Number(curr)
  480. // if (!isNaN(value)) {
  481. // return prev + curr
  482. // } else {
  483. // return prev
  484. // }
  485. // }, 0)
  486. // sums[index] = sums[index].toFixed(2)
  487. let num = 0
  488. data.map(item => {
  489. num += item.price.toFixed(2)*item.count
  490. })
  491. sums[index] = num.toFixed(2)
  492. } else {
  493. sums[index] = ''
  494. }
  495. })
  496. return sums
  497. },
  498. },
  499. created() {
  500. this.getSummaryDetailList()
  501. }
  502. }
  503. </script>