CheckPersonal.vue 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458
  1. <template>
  2. <div class="page_checkPersonal">
  3. <div class="cell clearfix">
  4. <el-form :inline="true" :model="listQuery">
  5. <el-form-item label>
  6. <!-- <el-input v-model.trim="listQuery.search" placeholder="姓名/透析号" style="width:150px"></el-input>
  7. <el-button type="primary" @click="onSearch" icon="el-icon-search">搜索</el-button> -->
  8. <el-autocomplete
  9. class="checkSearch"
  10. popper-class="my-autocomplete"
  11. v-model.trim="listQuery.search"
  12. :fetch-suggestions="querySearchAsync"
  13. :trigger-on-focus="false"
  14. placeholder="输入病人透析号/姓名"
  15. @select="handleSelect"
  16. >
  17. <i class="el-icon-search el-input__icon" slot="suffix"></i>
  18. <template slot-scope="{ item }">
  19. <div class="name">{{ item.name }}</div>
  20. </template>
  21. </el-autocomplete>
  22. </el-form-item>
  23. </el-form>
  24. <label class="title">
  25. <span class="name">日期查询</span> :
  26. </label>
  27. <el-date-picker
  28. v-model="listQuery.start_time"
  29. prefix-icon="el-icon-date"
  30. @change="changeTime"
  31. :editable="false"
  32. style="width: 196px;"
  33. type="date"
  34. placeholder="选择日期时间"
  35. align="right"
  36. format="yyyy-MM-dd"
  37. value-format="yyyy-MM-dd"
  38. :picker-options="pickerOptions"
  39. ></el-date-picker>
  40. <span class>-</span>
  41. <el-date-picker
  42. v-model="listQuery.end_time"
  43. prefix-icon="el-icon-date"
  44. @change="changeEndTime"
  45. :editable="false"
  46. style="width: 196px;"
  47. type="date"
  48. placeholder="选择日期时间"
  49. align="right"
  50. format="yyyy-MM-dd"
  51. value-format="yyyy-MM-dd"
  52. :picker-options="pickerOptions"
  53. ></el-date-picker>
  54. </div>
  55. <el-container>
  56. <div style="width:150px">
  57. <div class="tableTitle">患者列表</div>
  58. <el-table :data="patientsData" border style="width: 100%;"
  59. height="500" :row-style="{ color: '#303133' }"
  60. :header-cell-style="{backgroundColor: 'rgb(245, 247, 250)',color: '#606266'}"
  61. highlight-current-row
  62. @current-change="handleChange"
  63. >
  64. <el-table-column prop="dialysis_no" label="透析号" width="80">
  65. <template slot-scope="scope">{{scope.row.dialysis_no}}</template>
  66. </el-table-column>
  67. <el-table-column prop="name" label="姓名" width="80">
  68. <template slot-scope="scope">{{ scope.row.name }}</template>
  69. </el-table-column>
  70. </el-table>
  71. </div>
  72. <div style="padding-left:10px;flex:1">
  73. <div class="tableTitle">统计图</div>
  74. <div>
  75. <line-chart :options="chart"></line-chart>
  76. </div>
  77. </div>
  78. </el-container>
  79. </div>
  80. </template>
  81. <script>
  82. import { PostSearch} from '@/api/patient'
  83. import echarts from "echarts";
  84. import LineChart from "../../components/LineChart";
  85. import { getCurrentOrgPatients,getInspectionTotalCount,getInspectionDetailById,getSearchPatientInfo } from "@/api/common/common";
  86. export default {
  87. components: {
  88. LineChart
  89. },
  90. data() {
  91. return {
  92. listQuery: {
  93. start_time: "",
  94. end_time: "",
  95. page: 1,
  96. limit: 10
  97. },
  98. value: "请选项",
  99. patientsData:[],
  100. tableData:[],
  101. chart: {
  102. tooltip: {},
  103. // legend: {
  104. // data: ["次数"],
  105. // left: 0
  106. // },
  107. xAxis: {
  108. data: []
  109. },
  110. yAxis: {
  111. axisLabel: {
  112. formatter: "{value} %"
  113. },
  114. show: false
  115. },
  116. series: [
  117. {
  118. name: "次数",
  119. type: "bar",
  120. data: [],
  121. barWidth: 30,
  122. label: {
  123. normal: {
  124. show: true,
  125. position: "top",
  126. formatter: (params) => {
  127. if(this.obj.length > 0){
  128. let str = ''
  129. str = params.data +'次' + '\n(参考值'+ this.obj[params.dataIndex] +'次)'
  130. return str
  131. }else{
  132. let str = ''
  133. str = params.data+'次'
  134. return str
  135. }
  136. }
  137. }
  138. },
  139. //配置样式
  140. itemStyle: {
  141. //通常情况下:
  142. //每个柱子的颜色即为colorList数组里的每一项,如果柱子数目多于colorList的长度,则柱子颜色循环使用该数组
  143. normal: {
  144. color: function(params) {
  145. //我这边就两个柱子,大体就两个柱子颜色渐变,所以数组只有两个值,多个颜色就多个值
  146. var colorList = [
  147. ["#A9E0F3", "#9FBDFC"],
  148. ["#A9E0F3", "#9FBDFC"],
  149. ["#A9E0F3", "#9FBDFC"],
  150. ["#FFD7C0", "#FF9994"],
  151. ["#FFD7C0", "#FF9994"],
  152. ["#FFD7C0", "#FF9994"],
  153. ["#D7C3FD", "#B3A8F7"],
  154. ["#D7C3FD", "#B3A8F7"],
  155. ["#D7C3FD", "#B3A8F7"]
  156. ];
  157. var index = params.dataIndex;
  158. if (params.dataIndex >= colorList.length) {
  159. index = params.dataIndex % colorList.length;
  160. }
  161. return new echarts.graphic.LinearGradient(0, 0, 0, 1, [
  162. { offset: 0, color: colorList[index][0] },
  163. // { offset: 0.5, color: colorList[index][1] },
  164. { offset: 1, color: colorList[index][1] }
  165. ]);
  166. },
  167. barBorderRadius: [5, 5, 0, 0] //柱状角成椭圆形
  168. },
  169. //鼠标悬停时:
  170. emphasis: {
  171. shadowBlur: 10,
  172. shadowOffsetX: 0,
  173. shadowColor: "rgba(0, 0, 0, 0.5)"
  174. }
  175. }
  176. }
  177. ]
  178. },
  179. pickerOptions: {
  180. disabledDate(time) {
  181. let threeMonths = new Date(new Date().setFullYear(new Date().getFullYear()-1)).getTime() - 24 * 3600 * 1000;
  182. return time.getTime() > Date.now() || time.getTime() < threeMonths;;
  183. }
  184. },
  185. modesData: {
  186. xAxis: [],
  187. series: []
  188. },
  189. obj:[],
  190. patient_id:0,
  191. };
  192. },
  193. methods: {
  194. changeTime() {
  195. var time = this.getTimestamp(val) - this.getTimestamp(this.listQuery.end_time);
  196. if (time > 0) {
  197. this.$message.error("结束时间不能小于开始时间");
  198. this.listQuery.start_time = "";
  199. } else {
  200. }
  201. },
  202. changeEndTime(val) {
  203. var time =
  204. this.getTimestamp(val) - this.getTimestamp(this.listQuery.start_time);
  205. if (time < 0) {
  206. this.$message.error("结束时间不能小于开始时间");
  207. this.listQuery.end_time = "";
  208. } else {
  209. }
  210. },
  211. getTimestamp(time) {
  212. // 把时间日期转成时间戳
  213. return new Date(time).getTime() / 1000;
  214. },
  215. getCurrentOrgPatients(){
  216. getCurrentOrgPatients().then(response=>{
  217. var patients = response.data.data.patients
  218. this.patientsData = patients
  219. })
  220. },
  221. getInspectionTotalCount(){
  222. this.modesData.series = []
  223. this.modesData.xAxis = []
  224. getInspectionTotalCount(this.listQuery.start_time,this.listQuery.end_time).then(response=>{
  225. if(response.data.state === 1){
  226. var Inspection = response.data.data.Inspection
  227. this.tableData = Inspection
  228. var counts = response.data.data.counts
  229. var arr = []
  230. for(let i=0;i<Inspection.length;i++){
  231. for(let j=0;j<counts.length;j++){
  232. if(Inspection[i].inspection_major == counts[j].ProjectId){
  233. arr.push(counts[j])
  234. }
  235. }
  236. }
  237. var arrtwo = this.arrayDate(counts,this.normData)
  238. var hash = {};
  239. var i = 0;
  240. var res = [];
  241. arr.forEach(function(item) {
  242. var ProjectName = item.ProjectName;
  243. hash[ProjectName] ? res[hash[ProjectName] - 1].Count.push(item.Count) : hash[ProjectName] = ++i && res.push({
  244. Count: [item.Count],
  245. ProjectName: ProjectName,
  246. ProjectId: item.ProjectId,
  247. Sort:item.Sort,
  248. })
  249. });
  250. res.map(item => {
  251. item.Count = eval(item.Count.join('+'))
  252. })
  253. let arr1 = []
  254. this.tableData.map(it => {
  255. arr1.push(it.project_name)
  256. })
  257. arr1.forEach((item,index)=>{
  258. if(!(res[index] && item ==res[index].ProjectName)){
  259. res.splice(index,0,{Count:0, ProjectName: item, Sort: index+1})
  260. }
  261.             })
  262. res.map(item => {
  263. this.modesData.series.push(parseInt(item.Count));
  264. })
  265. console.log("this=====",this.tableData)
  266. for (const key in this.tableData) {
  267. this.modesData.xAxis.push(this.tableData[key].project_name);
  268. let time = new Date(this.listQuery.end_time) - new Date(this.listQuery.start_time)
  269. let day = parseInt(time / (1000 * 60 * 60 * 24))
  270. this.obj.push(Math.round(day / this.tableData[key].inspection_frequency))
  271. }
  272. this.chart.series[0].data = this.modesData.series
  273. this.chart.xAxis.data = this.modesData.xAxis
  274. }
  275. })
  276. },
  277. //获取单个病人数据
  278. handleChange(val){
  279. this.modesData.series = []
  280. this.modesData.xAxis = []
  281. getInspectionDetailById(val.id,this.listQuery.start_time,this.listQuery.end_time).then(response=>{
  282. if(response.data.state === 1){
  283. var patientdetail = response.data.data.patientdetail
  284. console.log("patientdetail",patientdetail)
  285. var arr=[]
  286. for(let i=0;i<this.tableData.length;i++){
  287. for(let j=0;j<patientdetail.length;j++){
  288. if(this.tableData[i].inspection_major == patientdetail[j].ProjectId){
  289. arr.push(patientdetail[j])
  290. }
  291. }
  292. }
  293. let time = new Date(this.listQuery.end_time) - new Date(this.listQuery.start_time)
  294. let day = parseInt(time / (1000 * 60 * 60 * 24))
  295. console.log("arr",arr)
  296. console.log("tabledata",this.tableData)
  297. for (const key in this.tableData) {
  298. this.modesData.xAxis.push(this.tableData[key].project_name);
  299. if (key in arr) {
  300. this.modesData.series.push(parseInt(arr[key].Count));
  301. this.obj.push(Math.round(day / arr[key].InspectionFrequency))
  302. // batotal += parseInt(res[key].Count);
  303. } else {
  304. this.modesData.series.push(0);
  305. this.obj.push(0)
  306. }
  307. }
  308. this.chart.series[0].data = this.modesData.series
  309. this.chart.xAxis.data = this.modesData.xAxis
  310. }
  311. })
  312. },
  313. //搜索功能
  314. onSearch(){
  315. this.modesData.series = []
  316. this.modesData.xAxis = []
  317. getSearchPatientInfo(this.patient_id,this.listQuery.start_time,this.listQuery.end_time).then(response=>{
  318. if(response.data.state === 1){
  319. var PatientsInfo = response.data.data.PatientsInfo
  320. console.log("patientsInfo",PatientsInfo)
  321. var arr = []
  322. for(let i=0;i<this.tableData.length;i++){
  323. for(let j=0;j<PatientsInfo.length;j++){
  324. if(this.tableData[i].inspection_major == PatientsInfo[j].ProjectId){
  325. arr.push(PatientsInfo[j])
  326. }
  327. }
  328. }
  329. let time = new Date(this.listQuery.end_time) - new Date(this.listQuery.start_time)
  330. let day = parseInt(time / (1000 * 60 * 60 * 24))
  331. for (const key in this.tableData) {
  332. this.modesData.xAxis.push(this.tableData[key].project_name);
  333. if (key in arr) {
  334. this.modesData.series.push(parseInt(arr[key].Count));
  335. this.obj.push(Math.round(day / arr[key].InspectionFrequency))
  336. // batotal += parseInt(res[key].Count);
  337. } else {
  338. this.modesData.series.push(0);
  339. this.obj.push(0)
  340. }
  341. }
  342. this.chart.series[0].data = this.modesData.series
  343. this.chart.xAxis.data = this.modesData.xAxis
  344. }
  345. })
  346. },
  347. arrayDate(array1,array2){
  348. var array1 = array1;
  349. var array2 = this.tableData;
  350. var result = [];
  351. for(var i = 0; i < array2.length; i++){
  352. var obj = array2[i];
  353. var num = obj.inspection_major; //staff_id 就是要对比的key
  354. var isExist = false;
  355. for(var j = 0; j < array1.length; j++){
  356. var aj = array1[j];
  357. var n = aj.ProjectId;
  358. if(n == num){
  359. isExist = true;
  360. break;
  361. }
  362. }
  363. if(!isExist){
  364. result.push(obj);
  365. }
  366. }
  367. return result;
  368. },
  369. querySearchAsync(keyword, cb) {
  370. let key = ''
  371. if (keyword != undefined) {
  372. key = keyword
  373. }
  374. let searchArray = []
  375. PostSearch(key).then(response => {
  376. if (response.data.state == 1) {
  377. searchArray = response.data.data.patient
  378. console.log("searchArray",searchArray)
  379. cb(searchArray)
  380. } else {
  381. cb([])
  382. }
  383. })
  384. },
  385. handleSelect(val) {
  386. console.log("val",val)
  387. this.listQuery.search = val.name
  388. this.patient_id = val.id
  389. this.onSearch()
  390. },
  391. },
  392. created(){
  393. var nowDate = new Date();
  394. var nowYear = nowDate.getFullYear();
  395. var nowMonth = nowDate.getMonth() + 1;
  396. var nowDay = nowDate.getDate();
  397. this.listQuery.end_time =
  398. nowYear +
  399. "-" +
  400. (nowMonth < 10 ? "0" + nowMonth : nowMonth) +
  401. "-" +
  402. (nowDay < 10 ? "0" + nowDay : nowDay);
  403. nowDate.setMonth(nowDate.getMonth() - 3);
  404. nowYear = nowDate.getFullYear();
  405. nowMonth = nowDate.getMonth() + 1;
  406. nowDay = nowDate.getDate();
  407. this.listQuery.start_time =
  408. nowYear +
  409. "-" +
  410. (nowMonth < 10 ? "0" + nowMonth : nowMonth) +
  411. "-" +
  412. (nowDay < 10 ? "0" + nowDay : nowDay);
  413. //获取该机构下的所有患者
  414. this.getCurrentOrgPatients()
  415. //获取检验检查项目
  416. this.getInspectionTotalCount()
  417. }
  418. };
  419. </script>
  420. <style lang="scss" scoped>
  421. .tableTitle {
  422. font-size: 16px;
  423. color: #000;
  424. font-weight: bold;
  425. margin-bottom: 10px;
  426. }
  427. </style>
  428. <style lang="scss">
  429. .page_checkPersonal {
  430. .cell {
  431. text-align: center;
  432. }
  433. }
  434. </style>