HospitalWork.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654
  1. <template>
  2. <div class="doctorWork">
  3. <!-- 顶部筛选 -->
  4. <div class="screening">
  5. <div class="screening-title flex-vertical-center-l">
  6. <span></span>
  7. <div>筛选</div>
  8. </div>
  9. <div class="screening-form flex-vertical-center-l flex-wrap">
  10. <div class="screening-item flex-vertical-center-l">
  11. <span>年度:</span>
  12. <div class="input">
  13. <el-date-picker
  14. size="mini"
  15. @change="yearBlur"
  16. v-model="form.year"
  17. type="year"
  18. placeholder="选择年"
  19. :clearable="false"
  20. ></el-date-picker>
  21. </div>
  22. </div>
  23. <div class="screening-item flex-vertical-center-l">
  24. <span>月度:</span>
  25. <div class="input">
  26. <el-date-picker
  27. size="mini"
  28. v-model="form.month"
  29. format="MM"
  30. type="month"
  31. placeholder="选择月"
  32. ></el-date-picker>
  33. </div>
  34. </div>
  35. <div class="screening-item flex-vertical-center-l">
  36. <span>机构名称:</span>
  37. <div class="input">
  38. <el-select size="mini" v-model="form.medName" placeholder="请选择">
  39. <el-option
  40. :label="item.name"
  41. :value="item.pid"
  42. v-for="(item,index) in medSelectList"
  43. :key="index"
  44. ></el-option>
  45. </el-select>
  46. </div>
  47. </div>
  48. <div class="screening-item flex-vertical-center-l">
  49. <div class="input flex-vertical-center-l">
  50. <el-checkbox v-model="form.checked">是否包含下级</el-checkbox>
  51. </div>
  52. </div>
  53. <div class="screening-item flex-vertical-center-l" v-if="false">
  54. <div class="input">
  55. <el-select size="mini" v-model="form.depart" placeholder="请选择">
  56. <el-option label="全部科室" :value="1"></el-option>
  57. <el-option label="中医内科" :value="2"></el-option>
  58. <el-option label="康复科" :value="3"></el-option>
  59. </el-select>
  60. </div>
  61. </div>
  62. <el-button size="mini" type="primary" @click="search">搜索</el-button>
  63. <el-button size="mini" type="warning" @click="clearFilter">清空</el-button>
  64. </div>
  65. </div>
  66. <!-- 展示数据层 -->
  67. <div class="showData">
  68. <div class="flex-vertical-center-l">
  69. <div class="top-change flex-vertical-center-l">
  70. <div :class="isEcharts==0?'choosed':''" @click="topChange(0)">图表</div>
  71. <div :class="isEcharts==1?'choosed':''" @click="topChange(1)">列表</div>
  72. </div>
  73. <div class="flex-center bg-yellow" v-if="isEcharts==1" @click="exportDow">导出</div>
  74. </div>
  75. <!-- 展示两种数据 -->
  76. <div class="showEcharts" v-if="isEcharts==0">
  77. <div id="myChart" :style="{width: '100%'}" class="myCharts"></div>
  78. <div class="e-format">
  79. 格式:时间:数量
  80. <span style="margin-left:30px;"></span> X轴:时间 Y轴:单位(个)
  81. </div>
  82. </div>
  83. <!-- 列表展示 -->
  84. <div class="showList" v-if="isEcharts==1">
  85. <ul>
  86. <li class="flex-vertical-between" v-for="(item,index) in list" :key="index">
  87. <div class="title">{{form.year |formMatD}}-{{item.id}}</div>
  88. <div>
  89. 中医门诊量:
  90. <span>{{item.outpatientCount}}</span>
  91. </div>
  92. <div>
  93. 中医住院量:
  94. <span>{{item.hospitalCount}}</span>
  95. </div>
  96. <div>
  97. 饮片开方量:
  98. <span>{{item.slicesCount}}</span>
  99. </div>
  100. <div>
  101. 颗粒剂开方量:
  102. <span>{{item.particlesCount}}</span>
  103. </div>
  104. <div>
  105. 中药制剂开方量:
  106. <span>{{item.chinaMadeCount}}</span>
  107. </div>
  108. <div>
  109. 适宜技术处方开方量:
  110. <span>{{item.techCount}}</span>
  111. </div>
  112. </li>
  113. </ul>
  114. </div>
  115. </div>
  116. </div>
  117. </template>
  118. <script>
  119. import { mapState, mapGetters, mapActions, mapMutations } from "vuex";
  120. import { medicalInstitution } from "@/api/city.js";
  121. import { getHospitalWork, exportDow } from "@/api/dataAnalysis.js";
  122. export default {
  123. data() {
  124. return {
  125. // 筛选数据
  126. form: {
  127. medName: "",
  128. year: "",
  129. month: "",
  130. checked: false,
  131. depart: 1
  132. },
  133. isFinish: 1, // 上一段函数 是否完成
  134. // 医疗机构
  135. medSelectList: [],
  136. // 是否是图表
  137. isEcharts: 0, // 0 图表 1 列表
  138. list: [], // 列表
  139. xAxisData: [], // 图表 横向坐标
  140. chinaMadeCount: [], // 中药制剂开方数据
  141. chinaPreCount: [], // 中药处方
  142. hospitalCount: [], // 中医住院量
  143. outpatientCount: [], //中医门诊量
  144. particlesCount: [], // 颗粒剂开方量
  145. slicesCount: [], // 饮片开方量
  146. techCount: [] // 适宜技术处方
  147. };
  148. },
  149. created() {},
  150. mounted() {
  151. let date = new Date();
  152. this.form.year = date.getFullYear().toString();
  153. this.medicalInstitution();
  154. this.getHospitalWork();
  155. },
  156. filters: {
  157. formMatD(value) {
  158. let date = new Date(value);
  159. let year = date.getFullYear();
  160. let month = date.getMonth() + 1;
  161. return year;
  162. }
  163. },
  164. methods: {
  165. // 年份失去焦点
  166. yearBlur(e) {
  167. if (!e || e.length > 4 || e.length < 4) {
  168. let date = new Date();
  169. this.form.year = date.getFullYear().toString();
  170. }
  171. },
  172. // 顶部列表更改
  173. topChange(type) {
  174. this.isEcharts = type;
  175. if (type == 0) {
  176. setTimeout(() => {
  177. this.drawLine();
  178. // this.drawLine2()
  179. }, 200);
  180. }
  181. },
  182. // 绘制 图表
  183. drawLine() {
  184. // 基于准备好的dom,初始化echarts实例
  185. let myChart = this.$echarts.init(document.getElementById("myChart"));
  186. // 绘制图表
  187. myChart.setOption({
  188. grid: {
  189. left: "1%",
  190. right: "1%",
  191. bottom: "3%",
  192. containLabel: true
  193. },
  194. legend: {
  195. data: [
  196. "中医门诊量",
  197. "中医住院量",
  198. "中药处方开方量",
  199. "饮片开方量",
  200. "颗粒剂开方量",
  201. "中药制剂开方量",
  202. "适宜技术处方开方量"
  203. ]
  204. },
  205. color: [
  206. "#5FA0FA",
  207. "#FFB703",
  208. "#1bb2d8",
  209. "#FD2446",
  210. "#51CEC6",
  211. "#DAEDF6",
  212. "#FB925A"
  213. ],
  214. tooltip: {},
  215. xAxis: {
  216. type: "category",
  217. data: this.xAxisData,
  218. name: "时间",
  219. nameLocation: "end"
  220. },
  221. yAxis: {
  222. type: "value"
  223. // name: "单位(个)"
  224. },
  225. series: [
  226. {
  227. name: "中医门诊量",
  228. type: "bar",
  229. data: this.outpatientCount
  230. },
  231. {
  232. name: "中医住院量",
  233. type: "bar",
  234. data: this.hospitalCount
  235. },
  236. {
  237. name: "中药处方开方量",
  238. type: "bar",
  239. data: this.chinaPreCount
  240. },
  241. {
  242. name: "饮片开方量",
  243. type: "bar",
  244. // stack: "中药处方开方量",
  245. data: this.slicesCount
  246. },
  247. {
  248. name: "颗粒剂开方量",
  249. type: "bar",
  250. // stack: "中药处方开方量",
  251. data: this.particlesCount
  252. },
  253. {
  254. name: "中药制剂开方量",
  255. type: "bar",
  256. // stack: "中药处方开方量",
  257. data: this.chinaMadeCount
  258. },
  259. {
  260. name: "适宜技术处方开方量",
  261. type: "bar",
  262. data: this.techCount
  263. }
  264. ]
  265. });
  266. },
  267. // 绘制饼图
  268. drawLine2() {
  269. let text = this.forMatDate(1, this.form.month)
  270. ? "医生工作量分析-" +
  271. this.forMatDate(0, this.form.year) +
  272. "年" +
  273. this.forMatDate(1, this.form.month) +
  274. "月"
  275. : "医生工作量分析-" + this.forMatDate(0, this.form.year) + "年";
  276. // 基于准备好的dom,初始化echarts实例
  277. let myChart = this.$echarts.init(document.getElementById("myChart"));
  278. console.log(myChart, "chart");
  279. // 绘制图表
  280. myChart.setOption({
  281. title: {
  282. text: text,
  283. // top: '10%',
  284. left: "center"
  285. },
  286. tooltip: {
  287. trigger: "item"
  288. },
  289. legend: {
  290. orient: "vertical",
  291. left: "left"
  292. },
  293. series: [
  294. {
  295. name: "医生工作量分析",
  296. type: "pie",
  297. radius: "50%",
  298. data: [
  299. {
  300. name: "中医门诊量" + "-" + this.outpatientCount[0] + "个",
  301. value: this.outpatientCount[0]
  302. },
  303. {
  304. name: "中医住院量" + "-" + this.hospitalCount[0] + "个",
  305. value: this.hospitalCount[0]
  306. },
  307. {
  308. name: "中药处方开方量" + "-" + this.chinaPreCount[0] + "个",
  309. value: this.chinaPreCount[0]
  310. },
  311. {
  312. name: "饮片开方量" + "-" + this.slicesCount[0] + "个",
  313. // type: 'bar',
  314. stack: "中药处方开方量",
  315. value: this.slicesCount[0]
  316. },
  317. {
  318. name: "颗粒剂开方量" + "-" + this.particlesCount[0] + "个",
  319. // type: 'bar',
  320. stack: "中药处方开方量",
  321. value: this.particlesCount[0]
  322. },
  323. {
  324. name: "中药制剂开方量" + "-" + this.chinaMadeCount[0] + "个",
  325. // type: 'bar',
  326. stack: "中药处方开方量",
  327. value: this.chinaMadeCount[0]
  328. },
  329. {
  330. name: "适宜技术处方开方量" + "-" + this.techCount[0] + "个",
  331. // type: 'bar',
  332. value: this.techCount[0]
  333. }
  334. ],
  335. emphasis: {
  336. itemStyle: {
  337. shadowBlur: 10,
  338. shadowOffsetX: 0,
  339. shadowColor: "rgba(0, 0, 0, 0.5)"
  340. }
  341. }
  342. }
  343. ]
  344. });
  345. },
  346. search() {
  347. this.xAxisData = []; // 图表 横向坐标
  348. this.chinaMadeCount = []; // 中药制剂开方数据
  349. this.chinaPreCount = []; // 中药处方
  350. this.hospitalCount = []; // 中医住院量
  351. this.outpatientCount = []; //中医门诊量
  352. this.particlesCount = []; // 颗粒剂开方量
  353. this.slicesCount = []; // 饮片开方量
  354. this.techCount = []; // 适宜技术处方
  355. this.getHospitalWork();
  356. },
  357. clearFilter() {
  358. let date = new Date();
  359. this.form = {
  360. medName: "",
  361. year: date.getFullYear().toString(),
  362. month: "",
  363. checked: false,
  364. depart: 1
  365. };
  366. this.xAxisData = []; // 图表 横向坐标
  367. this.chinaMadeCount = []; // 中药制剂开方数据
  368. this.chinaPreCount = []; // 中药处方
  369. this.hospitalCount = []; // 中医住院量
  370. this.outpatientCount = []; //中医门诊量
  371. this.particlesCount = []; // 颗粒剂开方量
  372. this.slicesCount = []; // 饮片开方量
  373. this.techCount = []; // 适宜技术处方
  374. if (this.isFinish == 0) return;
  375. this.getHospitalWork();
  376. },
  377. // 处理选择器 时间数据
  378. forMatDate(type, data) {
  379. if (!data) return "";
  380. // type : 0 year 1 month
  381. let date = new Date(data);
  382. let year = date.getFullYear();
  383. let month = date.getMonth() + 1;
  384. if (type == 0) {
  385. return year;
  386. } else if (type == 1) {
  387. return month;
  388. }
  389. },
  390. // 获取医疗机构选择器
  391. async medicalInstitution() {
  392. let params = {
  393. organizationId: this.getuserinfo.organizationid
  394. };
  395. let res = await medicalInstitution(params);
  396. if (res.ResultCode == 0) {
  397. this.medSelectList = res.Data;
  398. }
  399. },
  400. // 获取工作量分析数据
  401. async getHospitalWork() {
  402. this.isFinish = 0; //
  403. let params = {
  404. month: this.forMatDate(1, this.form.month),
  405. stiId: this.form.medName,
  406. type: this.form.checked ? "0" : "1",
  407. year: this.forMatDate(0, this.form.year)
  408. };
  409. let res = await getHospitalWork(params);
  410. if (res.ResultCode == 0) {
  411. this.list = res.Data;
  412. if (!this.form.month) {
  413. for (let i = 1; i <= 12; i++) {
  414. let j = i < 10 ? "0" + i : i;
  415. let xAxis = this.forMatDate(0, this.form.year) + "-" + j + "月";
  416. this.xAxisData.push(xAxis);
  417. }
  418. } else {
  419. this.xAxisData = [
  420. this.forMatDate(0, this.form.year) +
  421. "-" +
  422. this.forMatDate(1, this.form.month) +
  423. "月"
  424. ];
  425. }
  426. res.Data.forEach((item, index) => {
  427. this.chinaMadeCount.push(item.chinaMadeCount);
  428. this.chinaPreCount.push(item.chinaPreCount);
  429. this.hospitalCount.push(item.hospitalCount);
  430. this.outpatientCount.push(item.outpatientCount);
  431. this.particlesCount.push(item.particlesCount);
  432. this.slicesCount.push(item.slicesCount);
  433. this.techCount.push(item.techCount);
  434. });
  435. // 数里列表数据
  436. this.list.filter((item, index) => {
  437. if (this.form.month) {
  438. return (item.id =
  439. this.forMatDate(1, this.form.month) < 10
  440. ? "0" + this.forMatDate(1, this.form.month)
  441. : this.forMatDate(1, this.form.month));
  442. } else {
  443. return (item.id = index + 1 < 10 ? "0" + (index + 1) : index + 1);
  444. }
  445. });
  446. let text = this.forMatDate(1, this.form.month)
  447. ? this.forMatDate(0, this.form.year) +
  448. "年" +
  449. this.forMatDate(1, this.form.month) +
  450. "月"
  451. : this.forMatDate(0, this.form.year) + "年";
  452. setTimeout(() => {
  453. this.isFinish = 1; //
  454. this.drawLine();
  455. // this.drawLine2()
  456. }, 200);
  457. }
  458. },
  459. // 表导出
  460. async exportDow() {
  461. let params = {
  462. month: this.forMatDate(1, this.form.month),
  463. stiId: this.form.medName,
  464. type: this.form.checked ? "0" : "1",
  465. year: this.forMatDate(0, this.form.year)
  466. };
  467. const loading = this.$loading({
  468. lock: true,
  469. text: "正在导出,请稍后",
  470. spinner: "el-icon-loading",
  471. background: "rgba(0, 0, 0, 0.7)"
  472. });
  473. let res = await exportDow(params).catch(err => {
  474. loading.close();
  475. });
  476. if (res.ResultCode == 0) {
  477. let path = process.env.VUE_APP_UPLOAD + "file/" + res.ResultInfo;
  478. const a = document.createElement("a"); // 创建a标签
  479. a.setAttribute("download", ""); // download属性
  480. a.setAttribute("href", path); // href链接
  481. a.click(); // 自执行点击事件
  482. a.remove();
  483. this.$message({
  484. type: "success",
  485. message: "导出成功",
  486. showClose: true
  487. });
  488. loading.close();
  489. }
  490. }
  491. },
  492. computed: {
  493. ...mapGetters(["getuserinfo"])
  494. }
  495. };
  496. </script>
  497. <style lang="scss" scoped>
  498. @import "../../style/common.scss";
  499. @import "../../style/base.scss";
  500. .showData {
  501. background: #fff;
  502. border-radius: 10px;
  503. margin-top: 5px;
  504. padding: 10px;
  505. height: 71vh;
  506. overflow: auto;
  507. .top-change {
  508. margin-bottom: 10px;
  509. width: 100px;
  510. height: 34px;
  511. border-radius: 8px;
  512. cursor: pointer;
  513. border: 1px solid #dcdfe6;
  514. font-size: 14px;
  515. div:first-child {
  516. border-radius: 8px 0 0 8px;
  517. }
  518. div:last-child {
  519. border-radius: 0 8px 8px 0;
  520. }
  521. div {
  522. height: 34px;
  523. width: 50px;
  524. box-sizing: border-box;
  525. line-height: 34px;
  526. text-align: center;
  527. }
  528. .choosed {
  529. background: #5386f6;
  530. color: #fff;
  531. }
  532. }
  533. .bg-yellow {
  534. border-radius: 8px;
  535. background: #ffae45;
  536. color: #fff;
  537. width: 74px;
  538. height: 34px;
  539. margin-bottom: 20px;
  540. cursor: pointer;
  541. margin-left: 20px;
  542. }
  543. .showEcharts {
  544. width: 100%;
  545. .myCharts {
  546. height: 340px;
  547. }
  548. }
  549. .showList {
  550. width: 100%;
  551. ul {
  552. li {
  553. padding: 15px;
  554. border-bottom: 1px solid #dcdfe6;
  555. }
  556. li:hover {
  557. background: #dcdfe6;
  558. cursor: default;
  559. }
  560. .title {
  561. font-weight: bold;
  562. color: #5386f6;
  563. width: 90px;
  564. }
  565. }
  566. }
  567. }
  568. </style>
  569. <style lang="scss" scoped>
  570. @media screen and (min-width: 1681px) and (max-width: 1920px) {
  571. .showData {
  572. height: 81vh;
  573. .showEcharts {
  574. width: 100%;
  575. .myCharts {
  576. height: 400px;
  577. }
  578. }
  579. }
  580. }
  581. @media screen and (min-width: 1601px) and (max-width: 1680px) {
  582. .showData {
  583. height: 80vh;
  584. .showEcharts {
  585. width: 100%;
  586. .myCharts {
  587. height: 400px;
  588. }
  589. }
  590. }
  591. }
  592. @media screen and (min-width: 1361px) and (max-width: 1600px) {
  593. .showData {
  594. height: 73vh;
  595. .showEcharts {
  596. width: 100%;
  597. .myCharts {
  598. height: 360px;
  599. }
  600. }
  601. }
  602. }
  603. @media screen and(min-width:1281px) and (max-width: 1360px) {
  604. .showData {
  605. height: 73vh;
  606. .showEcharts {
  607. width: 100%;
  608. .myCharts {
  609. height: 360px;
  610. }
  611. }
  612. }
  613. }
  614. </style>