weightDetails.vue 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  1. <template>
  2. <div class="main-contain">
  3. <div class="position">
  4. <bread-crumb :crumbs="crumbs"></bread-crumb>
  5. <el-button type="primary" @click="$router.back(-1)">返回</el-button>
  6. </div>
  7. <div class="app-container">
  8. <div class="page_weightDetails">
  9. <div class="cell clearfix" style="margin:0">
  10. <el-form :inline="true" :model="listQuery">
  11. <el-form-item label>
  12. <el-autocomplete
  13. class="checkSearch"
  14. popper-class="my-autocomplete"
  15. v-model="search_value"
  16. :fetch-suggestions="querySearchAsync"
  17. :trigger-on-focus="false"
  18. placeholder="请输入病人名字"
  19. @select="handleSelect"
  20. style="width:160px"
  21. >
  22. <i class="el-icon-search el-input__icon" slot="suffix"></i>
  23. <template slot-scope="{ item }">
  24. <div class="name">{{ item.name }}</div>
  25. </template>
  26. </el-autocomplete>
  27. </el-form-item>
  28. </el-form>
  29. <label class="title" style="text-align:left">
  30. <span class="name">体重类型</span> :
  31. </label>
  32. <el-select v-model="query.statistics_type" placeholder="请选择" style="width:110px;margin-right:10px" @change="changeProject">
  33. <el-option
  34. v-for="item in options"
  35. :key="item.value"
  36. :label="item.name"
  37. :value="item.value"
  38. ></el-option>
  39. </el-select>
  40. <label class="title">
  41. <span class="name">日期查询</span> :
  42. </label>
  43. <el-date-picker
  44. v-model="query.start_time"
  45. prefix-icon="el-icon-date"
  46. @change="changeTime"
  47. :editable="false"
  48. style="width: 150px;"
  49. type="date"
  50. :picker-options="pickerOptions"
  51. placeholder="选择日期时间"
  52. align="right"
  53. format="yyyy-MM-dd"
  54. value-format="yyyy-MM-dd"
  55. ></el-date-picker>
  56. <span class>-</span>
  57. <el-date-picker
  58. v-model="query.end_time"
  59. prefix-icon="el-icon-date"
  60. @change="changeEndTime"
  61. :editable="false"
  62. :picker-options="pickerOptions"
  63. style="width: 150px;"
  64. type="date"
  65. placeholder="选择日期时间"
  66. align="right"
  67. format="yyyy-MM-dd"
  68. value-format="yyyy-MM-dd"
  69. ></el-date-picker>
  70. </div>
  71. <el-container>
  72. <div style="width:160px">
  73. <div class="tableTitle">患者列表</div>
  74. <el-table ref="table" :data="patientsData" border style="width: 100%;" height="500" :row-style="{ color: '#303133' }"
  75. :header-cell-style="{backgroundColor: 'rgb(245, 247, 250)',color: '#606266'}"
  76. highlight-current-row
  77. @current-change="handleChange">
  78. <el-table-column prop="dialysis_no" label="透析号" width="70">
  79. <template slot-scope="scope">{{scope.row.dialysis_no}}</template>
  80. </el-table-column>
  81. <el-table-column prop="name" label="姓名" width="90">
  82. <template slot-scope="scope">{{ scope.row.name }}</template>
  83. </el-table-column>
  84. </el-table>
  85. </div>
  86. <div class="containerRight" style="flex:1;overflow: hidden">
  87. <div class="tableTitle">指标趋势</div>
  88. <div>
  89. <line-chart :options="chart"></line-chart>
  90. </div>
  91. <div class="tableTitle">统计表</div>
  92. <div>
  93. <el-table :data="tableData" style="width: 100%" border :row-style="{ color: '#303133' }" :header-cell-style="{backgroundColor: 'rgb(245, 247, 250)',color: '#606266'}">
  94. <el-table-column fixed label="日期" align="center">
  95. <template slot-scope="scope">
  96. {{scope.row.assessment_date | parseTime("{y}-{m}-{d}") }}
  97. </template>
  98. </el-table-column>
  99. <el-table-column label="姓名" align="center">
  100. <template slot-scope="scope">
  101. {{scope.row.patient.name}}
  102. </template>
  103. </el-table-column>
  104. <el-table-column label="干体重" align="center">
  105. <template slot-scope="scope">
  106. {{scope.row.dry_weight?scope.row.dry_weight:''}}
  107. <!--{{// scope.row.patient.lapseto == 1 ? '留治':'转出'}}-->
  108. </template>
  109. </el-table-column>
  110. <el-table-column label="前次透后体重" align="center">
  111. <template slot-scope="scope">
  112. {{scope.row.last_after_weight?scope.row.last_after_weight:''}}
  113. <!--<div v-if="scope.row.before.systolic_blood_pressure">{{scope.row.before.systolic_blood_pressure}} / {{scope.row.before.diastolic_blood_pressure}}</div>-->
  114. </template>
  115. </el-table-column>
  116. <el-table-column label="透前体重" align="center">
  117. <template slot-scope="scope">
  118. {{scope.row.weight_before?scope.row.weight_before:''}}
  119. <!--<div v-if="scope.row.min_monitor.systolic_blood_pressure">{{ scope.row.min_monitor.systolic_blood_pressure}} /{{ scope.row.min_monitor.diastolic_blood_pressure}}</div>-->
  120. </template>
  121. </el-table-column>
  122. <el-table-column label="透后体重" align="center">
  123. <template slot-scope="scope">
  124. <!--<div v-if="scope.row.max_monitor.systolic_blood_pressure">{{ scope.row.max_monitor.systolic_blood_pressure}} /{{ scope.row.max_monitor.diastolic_blood_pressure}}</div>-->
  125. {{scope.row.after.weight_after?scope.row.after.weight_after:''}}
  126. </template>
  127. </el-table-column>
  128. <el-table-column label="体重增加" align="center">
  129. <template slot-scope="scope">
  130. <div v-if="scope.row.weight_before && scope.row.last_after_weight">{{(scope.row.weight_before - scope.row.last_after_weight).toFixed(1)}}</div>
  131. <!--{{scope.row.weight_before - scope.row.last_after_weight}}-->
  132. <!--<div v-if="scope.row.after.systolic_blood_pressure"> {{ scope.row.after.systolic_blood_pressure}} /{{scope.row.after.diastolic_blood_pressure}}</div>-->
  133. </template>
  134. </el-table-column>
  135. </el-table>
  136. <el-pagination
  137. align="right"
  138. @size-change="handleSizeChange"
  139. @current-change="handleCurrentChange"
  140. :current-page="query.page"
  141. :page-sizes="[10, 20, 50, 100]"
  142. :page-size="10"
  143. background
  144. style="margin-top:20px;"
  145. layout="total, sizes, prev, pager, next, jumper"
  146. :total="total"
  147. ></el-pagination>
  148. </div>
  149. </div>
  150. </el-container>
  151. </div>
  152. </div>
  153. </div>
  154. </template>
  155. <script>
  156. import echarts from "echarts";
  157. import BreadCrumb from "@/xt_pages/components/bread-crumb";
  158. import LineChart from "../../qcd/components/LineChart";
  159. import { getCurrentOrgPatients } from "@/api/common/common";
  160. import {GetDialysisPatientWeightChartData,GetDialysisWeightTableData} from "@/api/common/statistics"
  161. import { PostSearch } from '@/api/patient'
  162. import { uParseTime } from "@/utils/tools";
  163. export default {
  164. components: {
  165. LineChart,
  166. BreadCrumb
  167. },
  168. data() {
  169. return {
  170. pickerOptions: {
  171. disabledDate(time) {
  172. let threeMonths = new Date(new Date().setFullYear(new Date().getFullYear()-1)).getTime() - 24 * 3600 * 1000;
  173. return time.getTime() > Date.now() || time.getTime() < threeMonths;;
  174. }
  175. },
  176. patientsData:[],
  177. tableData: [],
  178. loading: false,
  179. search_value: '',
  180. total: 0,
  181. patient_name:'',
  182. query: {
  183. patient_id: '',
  184. statistics_type: 1,
  185. start_time: '',
  186. end_time: '',
  187. limit: 10,
  188. page: 1
  189. },
  190. options: [
  191. { value: 1, name: '干体重' },
  192. { value: 2, name: '透前体重' },
  193. { value: 3, name: '体重增加' },
  194. { value: 4, name: '透后体重' },
  195. ],
  196. crumbs: [
  197. { path: false, name: "质控管理" },
  198. { path: false, name: "患者血压详情" }
  199. ],
  200. chart: {
  201. title: {
  202. text: "ECharts 入门示例"
  203. },
  204. tooltip: {},
  205. legend: {
  206. data: [],
  207. left: 0
  208. },
  209. xAxis: {
  210. data: []
  211. },
  212. yAxis: {
  213. axisLabel: {
  214. formatter: "{value} %"
  215. },
  216. show: false
  217. },
  218. series: [
  219. {
  220. name: "",
  221. type: "line",
  222. data: [
  223. ],
  224. barWidth: 30,
  225. label: {
  226. normal: {
  227. show: true,
  228. position: "top",
  229. formatter: "{c}"
  230. }
  231. },
  232. //配置样式
  233. itemStyle: {
  234. normal: {
  235. color: "#5b98ff", //折点颜色
  236. lineStyle: {
  237. color: "#5b98ff" //折线颜色
  238. }
  239. }
  240. }
  241. },
  242. ],
  243. dataZoom: [
  244. {
  245. // Y轴固定,让内容滚动
  246. type: 'slider',
  247. show: false,
  248. xAxisIndex: [0],
  249. start: 1,
  250. end: 20, // 设置X轴刻度之间的间隔(根据数据量来调整)
  251. zoomLock: true // 锁定区域禁止缩放(鼠标滚动会缩放,所以禁止)
  252. },
  253. {
  254. type: 'inside',
  255. xAxisIndex: [0],
  256. start: 1,
  257. end: 20,
  258. zoomLock: true // 锁定区域禁止缩放
  259. }
  260. ]
  261. },
  262. };
  263. },
  264. methods: {
  265. chooseMonth(month) {
  266. this.monthType = month;
  267. },
  268. clickQuality(index) {
  269. this.quality = index;
  270. }, changeProject(val){
  271. this.query.statistics_type = val
  272. this.query.page = 1
  273. this.GetDialysisPatientWeightChartData(this.query)
  274. },
  275. handleChange(val){
  276. this.patient_name = val.name
  277. this.query.patient_id = val.id
  278. this.query.page = 1
  279. this.GetDialysisWeightTableData(this.query)
  280. this.GetDialysisPatientWeightChartData(this.query)
  281. },
  282. handleSizeChange(limit) {
  283. this.query.limit = limit;
  284. this.GetDialysisWeightTableData(this.query)
  285. },
  286. handleCurrentChange(page) {
  287. this.query.page = page;
  288. this.GetDialysisWeightTableData(this.query)
  289. },
  290. changeTime(val) {
  291. var time = this.getTimestamp(val) - this.getTimestamp(this.query.end_time);
  292. if (time > 0) {
  293. this.$message.error("结束时间不能小于开始时间");
  294. this.query.start_time = "";
  295. } else {
  296. // this.getDialysisList()
  297. this.query.page = 1;
  298. this.GetDialysisPatientWeightChartData(this.query)
  299. this.GetDialysisWeightTableData(this.query)
  300. }
  301. },
  302. changeEndTime(val) {
  303. var time =
  304. this.getTimestamp(val) - this.getTimestamp(this.query.start_time);
  305. if (time < 0) {
  306. this.$message.error("结束时间不能小于开始时间");
  307. this.query.end_time = "";
  308. } else {
  309. this.query.page = 1;
  310. this.GetDialysisPatientWeightChartData(this.query)
  311. this.GetDialysisWeightTableData(this.query)
  312. }
  313. },
  314. getTimestamp(time) {
  315. // 把时间日期转成时间戳
  316. return new Date(time).getTime() / 1000;
  317. },GetDialysisWeightTableData(params) {
  318. this.loading = true
  319. GetDialysisWeightTableData(params)
  320. .then(rs => {
  321. var resp = rs.data
  322. if (resp.state == 1) {
  323. this.loading = false
  324. this.tableData = []
  325. for (let i = 0; i < resp.data.data.length; i++) {
  326. this.tableData.push(resp.data.data[i])
  327. }
  328. this.total = resp.data.total
  329. } else {
  330. this.loading = false
  331. }
  332. })
  333. .catch(error => {
  334. })
  335. },
  336. GetDialysisPatientWeightChartData(params) {
  337. this.chart.xAxis.data = []
  338. this.chart.series[0].data = []
  339. GetDialysisPatientWeightChartData(params)
  340. .then(rs => {
  341. var resp = rs.data
  342. if (resp.state == 1) {
  343. for (let i = 0; i < resp.data.data.length; i++) {
  344. this.chart.xAxis.data.push(resp.data.data[i].date)
  345. this.chart.series[0].data.push(parseFloat(resp.data.data[i].value).toFixed(1))
  346. }
  347. this.getArrLength(this.chart.xAxis.data)
  348. } else {
  349. }
  350. })
  351. .catch(error => {
  352. })
  353. },
  354. handleSelect(val) {
  355. this.query.patient_id = val.id
  356. this.query.page = 1
  357. this.patient_name = val.name
  358. // this.GetDialysisPatientWeightChartData(this.query)
  359. // this.GetDialysisWeightTableData(this.query)
  360. for (let i = 0;i < this.patientsData.length; i++){
  361. if (this.patientsData[i].id == val.id){
  362. this.$refs.table.setCurrentRow(this.patientsData[i])
  363. }
  364. }
  365. },
  366. querySearchAsync(keyword, cb) {
  367. let key = ''
  368. if (keyword != undefined) {
  369. key = keyword
  370. }
  371. let searchArray = []
  372. PostSearch(key).then(response => {
  373. if (response.data.state == 1) {
  374. searchArray = response.data.data.patient
  375. cb(searchArray)
  376. } else {
  377. cb([])
  378. }
  379. })
  380. }, getCurrentOrgPatients(){
  381. getCurrentOrgPatients().then(response=>{
  382. if(response.data.state == 1){
  383. var patients = response.data.data.patients
  384. this.patientsData = patients
  385. for (let i = 0;i < this.patientsData.length; i++){
  386. if (this.patientsData[i].id == this.query.patient_id){
  387. this.patient_name = this.patientsData[i].name
  388. this.$refs.table.setCurrentRow(this.patientsData[i])
  389. }
  390. }
  391. }
  392. })
  393. },
  394. getArrLength(result){
  395. if(result.length > 10){
  396. var dataZoom_end = (10/result.length)*100;
  397. this.chart.dataZoom[0].end = dataZoom_end
  398. }else{
  399. var dataZoom_end = 100;
  400. this.chart.dataZoom[0].end = dataZoom_end
  401. }
  402. }
  403. },created() {
  404. var date = new Date()
  405. var year = date.getFullYear() //获取完整的年份(4位)
  406. var month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1).toString() : date.getMonth() + 1 //获取当前月份(0-11,0代表1月)
  407. var day = date.getDate() < 10 ? '0' + date.getDate().toString() : date.getDate() //获取当前日(1-31)
  408. var last_month = date.getMonth() < 10 ? '0' + date.getMonth().toString() : date.getMonth() //获取当前月份(0-11,0代表1月)
  409. this.query.patient_id = this.$route.query.id
  410. this.query.end_time = year + '-' + month + '-' + day
  411. this.query.start_time = year + '-' + last_month + '-' + day
  412. this.query.statistics_type = 1
  413. this.GetDialysisPatientWeightChartData(this.query)
  414. this.GetDialysisWeightTableData(this.query)
  415. this.getCurrentOrgPatients()
  416. }
  417. };
  418. </script>
  419. <style lang="scss" scoped>
  420. .containerRight {
  421. padding-left: 10px;
  422. }
  423. .tableTitle {
  424. font-size: 16px;
  425. color: #000;
  426. font-weight: bold;
  427. margin-bottom: 10px;
  428. margin-top: 8px;
  429. }
  430. </style>
  431. <style lang="scss">
  432. .page_weightDetails {
  433. .cell {
  434. text-align: center;
  435. }
  436. .el-form-item {
  437. margin-bottom: 0;
  438. }
  439. ::-webkit-scrollbar{
  440. height: 15px !important;
  441. }
  442. }
  443. </style>