blood_table.vue 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  1. <template>
  2. <div class="main-contain">
  3. <div class="position">
  4. <div>
  5. <span>
  6. <el-button @click="return_click" type="text" icon="el-icon-arrow-left">返回</el-button>
  7. </span>&nbsp;&nbsp;
  8. <span>患者血压详情</span>
  9. </div>
  10. </div>
  11. <div class="app-container">
  12. <div class="page_patientControlAnalysis">
  13. <div style="display: flex;margin-bottom: 20px;">
  14. <div style="flex: 3;display: flex;flex-wrap:wrap">
  15. <div>
  16. 日期:
  17. <el-select v-model="date_value" @change="datachange" placeholder="请选择" style="width: 100px;">
  18. <el-option
  19. v-for="item in date_options"
  20. :key="item.value"
  21. :label="item.label"
  22. :value="item.value">
  23. </el-option>
  24. </el-select>
  25. </div>
  26. <div style="margin:0 10px;">
  27. <el-date-picker
  28. v-model="start_date"
  29. type="date"
  30. value-format="yyyy-MM-dd"
  31. placeholder="选择日期"
  32. style="width: 150px;">
  33. </el-date-picker>
  34. <span>-</span>
  35. <el-date-picker
  36. v-model="end_date"
  37. type="date"
  38. value-format="yyyy-MM-dd"
  39. placeholder="选择日期"
  40. style="width: 150px;">
  41. </el-date-picker>
  42. </div>
  43. <div>
  44. 状态:
  45. <el-select v-model="status_value" placeholder="请选择" style="width: 100px;">
  46. <el-option :key="0" label="不限" :value="0"></el-option>
  47. <el-option
  48. v-for="item in status_options"
  49. :key="item.value"
  50. :label="item.label"
  51. :value="item.value">
  52. </el-option>
  53. </el-select>
  54. </div>
  55. <div>
  56. 统计类型:
  57. <el-select v-model="blood_value" placeholder="请选择" style="width: 100px;">
  58. <el-option :key="0" label="不限" :value="0"></el-option>
  59. <el-option
  60. v-for="item in blood_options"
  61. :key="item.value"
  62. :label="item.label"
  63. :value="item.value">
  64. </el-option>
  65. </el-select>
  66. </div>
  67. </div>
  68. <div style="flex: 1;">
  69. <div>
  70. <el-button type="primary" @click="deil_click">查询</el-button>
  71. <el-button type="primary" @click="exportExcel">导出</el-button>
  72. </div>
  73. </div>
  74. </div>
  75. <el-table :data="tableData" border style="width: 100%"
  76. :header-cell-style="{textAlign: 'center'}"
  77. :cell-style="{ textAlign: 'center' }"
  78. height="380">
  79. <el-table-column
  80. prop="index"
  81. label="序号"
  82. width="50">
  83. </el-table-column>
  84. <el-table-column
  85. prop="dialysis_no"
  86. label="透析号"
  87. width="70">
  88. </el-table-column>
  89. <el-table-column
  90. prop="patient_name"
  91. label="患者姓名"
  92. width="80">
  93. </el-table-column>
  94. <el-table-column
  95. prop="gender"
  96. label="性别"
  97. width="50">
  98. </el-table-column>
  99. <el-table-column
  100. prop="age"
  101. label="年龄"
  102. width="50">
  103. </el-table-column>
  104. <el-table-column
  105. prop="dialysis_date"
  106. label="透析日期"
  107. width="100">
  108. </el-table-column>
  109. <el-table-column
  110. prop="dryweight"
  111. label="干体重"
  112. width="70">
  113. </el-table-column>
  114. <el-table-column
  115. prop="UltrafiltrationVol"
  116. label="超滤总量(L)"
  117. width="90">
  118. </el-table-column>
  119. <el-table-column
  120. prop="actual_ultrafiltration"
  121. label="实际超滤量(ml)"
  122. width="100">
  123. </el-table-column>
  124. <el-table-column
  125. prop="ultrafiltration_rate"
  126. label="超滤率"
  127. width="70">
  128. </el-table-column>
  129. <el-table-column
  130. prop="preDialysisBP"
  131. label="透前血压"
  132. width="90">
  133. </el-table-column>
  134. <el-table-column
  135. prop="monitoringbp"
  136. label="监测记录血压">
  137. </el-table-column>
  138. <el-table-column
  139. prop="PostDialysisBP"
  140. label="透后血压"
  141. width="90">
  142. </el-table-column>
  143. </el-table>
  144. <div style="text-align: right;margin-top: 10px;">
  145. <el-pagination
  146. @size-change="handleSizeChange"
  147. @current-change="handleCurrentChange"
  148. :current-page="currentPage"
  149. :page-sizes="[50,100, 200, 300, 400]"
  150. :page-size="limit"
  151. layout="total, sizes, prev, pager, next, jumper"
  152. :total="total">
  153. </el-pagination>
  154. </div>
  155. </div>
  156. </div>
  157. <!-- 弹窗 -->
  158. </div>
  159. </template>
  160. <script>
  161. import * as echarts from 'echarts';
  162. import XLSX from 'xlsx';
  163. import { uParseTime } from "@/utils/tools";
  164. import {Getbpdetail} from '../../../../api/qcd'
  165. import { forEach } from 'jszip';
  166. import html2canvas from "html2canvas"
  167. export default {
  168. components:{
  169. },
  170. data(){
  171. return{
  172. date_value:4,
  173. start_date:'',
  174. end_date:this.getTime(new Date()),
  175. mode:'',
  176. date_mode:'',
  177. source:'',
  178. dialyze_value:0,
  179. dialyze_dialog:false,
  180. currentPage:1,
  181. limit:50,
  182. total:0,
  183. tableData:[],
  184. status_value:1,
  185. blood_value:0,
  186. status_options:[{value:1,label:'达标'},{value:2,label:'不达标'}],
  187. date_options:[{value:1,label:'最近七天'},{value:2,label:'本周'},{value:3,label:'上周'},{value:4,label:'本月'},
  188. {value:5,label:'上月'},{value:6,label:'本年'},{value:7,label:'上一年'}
  189. ],
  190. blood_options:[{value:1,label:'透前血压'},{value:2,label:'透后血压'}],
  191. date_mode_options:[{value:1,label:'按周'},{value:2,label:'按天'},{value:3,label:'按月'},{value:4,label:'按年'}],
  192. source_options:[{value:1,label:'以开始透析为准'},{value:2,label:'以排班为准'}],
  193. input:'',
  194. }
  195. },
  196. methods:{
  197. // 返回
  198. return_click(){
  199. this.$router.push('/Dialysisanalysis/qualitycontrol/weightblood')
  200. },
  201. // 导出excel
  202. exportExcel(){
  203. let tableData = [
  204. ['序号', '透析号', '患者姓名','性别','年龄', '透析日期','干体重', '超滤总量','实际超滤量','超滤率','透前血压','监测记录血压','透后血压']//导出表头
  205. ]
  206. this.tableData.forEach((item,index) =>{
  207. let rowdata=[]
  208. rowdata=[
  209. item.index,
  210. item.dialysis_no,
  211. item.patient_name,
  212. item.gender,
  213. item.age,
  214. item.dialysis_date,
  215. item.dryweight,
  216. item.UltrafiltrationVol,
  217. item.actual_ultrafiltration,
  218. item.ultrafiltration_rate,
  219. item.preDialysisBP,
  220. item.monitoringbp,
  221. item.PostDialysisBP,
  222. ]
  223. tableData.push(rowdata)
  224. })
  225. let workSheet = XLSX.utils.aoa_to_sheet(tableData);
  226. let bookNew = XLSX.utils.book_new();
  227. XLSX.utils.book_append_sheet(bookNew, workSheet, '患者血压详情') // 工作簿名称
  228. let name = '患者血压详情'+ '.xlsx'
  229. XLSX.writeFile(bookNew, name) // 保存的文件名
  230. },
  231. // 详情查询
  232. deil_click(){
  233. this.currentPage =1
  234. this.Getdialyzerdetail(this.status_value)
  235. },
  236. // 选择日期
  237. datachange(eve){
  238. if(eve ==1){
  239. this.start_date = this.getPreviousDate(7)
  240. this.end_date = this.getTime(new Date())
  241. }else if(eve==2){
  242. this.start_date = this.getFirstDayOfWeek(new Date())
  243. this.end_date = this.getTime(new Date())
  244. console.log('this.start_date', this.start_date);
  245. }else if(eve ==3){
  246. var date=new Date()
  247. date.setDate(date.getDate()-7 - date.getDay() + 1);
  248. var m =''
  249. var d = ''
  250. if(date.getMonth() + 1<10){
  251. m = '0'+(date.getMonth() + 1)
  252. }else{
  253. m = date.getMonth() + 1
  254. }
  255. if(date.getDate()<10){
  256. d = '0'+date.getDate()
  257. }else{
  258. d = date.getDate()
  259. }
  260. // this.start_date = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate() ;
  261. this.start_date = date.getFullYear() + "-" + m + "-" + d ;
  262. date.setDate(date.getDate() +6);
  263. var mm = ''
  264. var dd = ''
  265. if(date.getMonth() + 1<10){
  266. mm = '0'+(date.getMonth() + 1)
  267. }else{
  268. mm = date.getMonth() + 1
  269. }
  270. if(date.getDate()<10){
  271. dd = '0'+date.getDate()
  272. }else{
  273. dd = date.getDate()
  274. }
  275. // if(date.getMonth() + 1<10)
  276. // this.end_date = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate();
  277. this.end_date = date.getFullYear() + "-" + mm + "-" + dd ;
  278. console.log('this.end_date',this.end_date);
  279. }else if(eve ==4){
  280. this.start_date = this.getFirstDayOfMonth(new Date())
  281. this.end_date = this.getTime(new Date())
  282. }else if(eve ==5){
  283. this.getLastMonthFirstDay()
  284. this.getLastMonthLastDay()
  285. }else if(eve == 6){
  286. this.start_date = this.getFirstDayOfYear(new Date())
  287. this.end_date = this.getTime(new Date())
  288. }else if(eve == 7){
  289. this.getLastYearFirstDay()
  290. this.getLastYearLastDay()
  291. }
  292. console.log('eve',eve);
  293. },
  294. // 详情数据源
  295. Getdialyzerdetail(value){
  296. const params={
  297. status_type:value,
  298. statistics_type:this.blood_value,
  299. start_time:this.start_date,
  300. end_time:this.end_date,
  301. page:this.currentPage,
  302. limit:this.limit,
  303. }
  304. Getbpdetail(params).then(response =>{
  305. if(response.data.state == 1){
  306. const list = response.data.data.list
  307. const table=[]
  308. if(list.length > 0){
  309. list.forEach((item,index)=>{
  310. const obj ={
  311. index:index+1,
  312. dialysis_no:item.dialysis_no,
  313. patient_name:item.patient_name,
  314. gender:this.getgender(item.gender),
  315. age:item.age,
  316. dialysis_date:this.getTime(item.assessment_date),
  317. dryweight:item.dry_weight,
  318. UltrafiltrationVol:item.ultrafiltration_vol/1000,
  319. actual_ultrafiltration:item.actual_ultrafiltration,
  320. ultrafiltration_rate:item.ultrafiltration_rate,
  321. preDialysisBP:item.pre_dialysis_bp,
  322. monitoringbp:item.monitoring_bp,
  323. PostDialysisBP:item.post_dialysis_bp,
  324. }
  325. table.push(obj)
  326. })
  327. this.tableData = table
  328. this.total = response.data.data.total
  329. }
  330. }
  331. console.log('77777血压表格',response);
  332. })
  333. },
  334. // 首先定义一个getPreviousDate函数,方便调用
  335. getPreviousDate(numOfDays) {
  336. var date = new Date();
  337. date.setDate(date.getDate() - numOfDays);
  338. var year = date.getFullYear();
  339. if(date.getMonth() + 1<10){
  340. var month = '0'+(date.getMonth() + 1);
  341. }else{
  342. var month = date.getMonth() + 1;
  343. }
  344. if(date.getDate()<10){
  345. var day = '0'+date.getDate();
  346. }else{
  347. var day = date.getDate();
  348. }
  349. return year + "-" + month + "-" + day;
  350. },
  351. // 本周
  352. getFirstDayOfWeek(date){
  353. var weekday = date.getDay()
  354. date.setDate(date.getDate()-weekday+1);//往前算(weekday-1)天,年份、月份会自动变化
  355. return this.timeFormat(date);
  356. },
  357. // 本月
  358. getFirstDayOfMonth (date) {
  359. date.setDate(1);
  360. return this.timeFormat(date);
  361. },
  362. //上个月第一天
  363. getLastMonthFirstDay() {
  364. var date = new Date();
  365. date.setDate(0);
  366. var y = date.getFullYear(); //获取年份
  367. var m = date.getMonth() + 1; //获取月份
  368. m = m < 10 ? "0" + m : m;
  369. this.start_date = [y, m, '01'].join("-")
  370. // return [y, m, '01'].join("-");
  371. },
  372. // 上个月最后一天
  373. getLastMonthLastDay() {
  374. var date = new Date();
  375. date.setDate(0);
  376. var y = date.getFullYear(); //获取年份
  377. var m = date.getMonth() + 1; //获取月份
  378. var d = new Date(y, m, 0).getDate(); //获取当月最后一日
  379. m = m < 10 ? "0" + m : m; //月份补 0
  380. d = d < 10 ? "0" + d : d; //日数补 0
  381. this.end_date = [y, m, d].join("-")
  382. // return [y, m, d].join("-");
  383. },
  384. // 本年
  385. getFirstDayOfYear (date) {
  386. date.setDate(1);
  387. date.setMonth(0);
  388. return this.timeFormat(date);
  389. },
  390. // 上一年第一天
  391. getLastYearFirstDay() {
  392. let date = new Date();
  393. const year= date.setFullYear(date.getFullYear() - 1); // 设置年份为前一年
  394. const start_month= date.setMonth(0); // 设置月份为1月(注意月份是从0开始的)
  395. const start_day = date.setDate(1); // 设置日期为1日
  396. // const last_month = date.setMonth(11); // 设置月份为12月
  397. // const last_day = date.setDate(0); // 设置日期为0,这将自动设置为该月的最后一天
  398. // this.start_date = year+ "-" +start_month+ "-" +start_day
  399. this.start_date = this.getTime(start_day)
  400. // return this.start_date
  401. },
  402. // 上一年最后一天
  403. getLastYearLastDay() {
  404. let date = new Date();
  405. const year= date.setFullYear(date.getFullYear() - 1); // 设置年份为前一年
  406. const last_month = date.setMonth(12); // 设置月份为12月
  407. const last_day = date.setDate(0);// 设置日期为0,这将自动设置为该月的最后一天
  408. // this.end_date = year+ "-" +last_month+ "-" +last_day
  409. this.end_date = this.getTime(last_day)
  410. console.log('this.end_date',this.end_date);
  411. // return this.end_date;
  412. },
  413. // 日期格式化
  414. timeFormat(date) {
  415. if (!date || typeof(date) === "string") {
  416. this.error("参数异常,请检查...");
  417. }
  418. var y = date.getFullYear(); //年
  419. if(date.getMonth() + 1<10){
  420. var m ='0'+(date.getMonth() + 1); //月
  421. }else{
  422. var m =date.getMonth() + 1; //月
  423. }
  424. if(date.getDate()<10){
  425. var d ='0'+date.getDate(); //日
  426. }else{
  427. var d = date.getDate(); //日
  428. }
  429. // var d = date.getDate(); //日
  430. return y + "-" + m + "-" + d;
  431. },
  432. handleCurrentChange(val){
  433. this.currentPage = val
  434. this.Getdialyzerdetail(this.status_value)
  435. },
  436. handleSizeChange(val){
  437. this.limit = val
  438. this.Getdialyzerdetail(this.status_value)
  439. },
  440. // 性别
  441. getgender(ids){
  442. if(ids ==1){
  443. return "男"
  444. }else{
  445. return "女"
  446. }
  447. },
  448. // getVol(value){
  449. // if(value >1000){
  450. // }
  451. // },
  452. // 转换时间
  453. getTime(val) {
  454. if(val < 0){
  455. return ""
  456. }
  457. if(val == ""){
  458. return ""
  459. }else {
  460. return uParseTime(val, '{y}-{m}-{d}')
  461. }
  462. },
  463. dataURLtoBlob(dataURL) {
  464. const arr = dataURL.split(',');
  465. const mime = arr[0].match(/:(.*?);/)[1];
  466. const bstr = atob(arr[1]);
  467. let n = bstr.length;
  468. const u8arr = new Uint8Array(n);
  469. while (n--) {
  470. u8arr[n] = bstr.charCodeAt(n);
  471. }
  472. return new Blob([u8arr], { type: mime });
  473. },
  474. },
  475. mounted(){
  476. },
  477. created(){
  478. this.start_date = this.getFirstDayOfMonth(new Date())
  479. this.Getdialyzerdetail(this.status_value)
  480. },
  481. }
  482. </script>