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

gather.vue 18KB

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