clinical.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. <template>
  2. <div>
  3. <el-dialog
  4. center
  5. append-to-body
  6. title="与临床沟通记录统计"
  7. :visible.sync="dialogVisible"
  8. width="80%"
  9. top
  10. :close-on-click-modal="false"
  11. :close-on-press-escape="false"
  12. >
  13. <div class="date-wrap">
  14. <div class="date-label">沟通时间:</div>
  15. <el-date-picker
  16. v-model="monthValues"
  17. type="daterange"
  18. start-placeholder="开始日期"
  19. end-placeholder="结束日期"
  20. align="left"
  21. :picker-options="pickerOptions"
  22. value-format="yyyy-MM-dd"
  23. />
  24. <el-button type="primary" @click="searchData" style="margin-left: 20px"
  25. >查询</el-button
  26. >
  27. </div>
  28. <el-row class="custom-wrap">
  29. <el-col v-if="showEcharts.includes('echart3')" :span="12">
  30. <div class="chart-item"
  31. ><div id="echart3" style="width: 100%; height: 100%"></div></div
  32. ></el-col>
  33. <el-col v-if="showEcharts.includes('echart4')" :span="12">
  34. <div class="chart-item"
  35. ><div id="echart4" style="width: 100%; height: 100%"></div></div
  36. ></el-col>
  37. <el-col v-if="showEcharts.includes('echart5')" :span="12">
  38. <div class="chart-item"
  39. ><div id="echart5" style="width: 100%; height: 100%"></div></div
  40. ></el-col>
  41. <el-col v-if="showEcharts.includes('echart6')" :span="12">
  42. <div class="chart-item"
  43. ><div id="echart6" style="width: 100%; height: 100%"></div></div
  44. ></el-col>
  45. </el-row>
  46. <span slot="footer" class="dialog-footer">
  47. <el-button type="danger" @click="closeDialog">关闭</el-button>
  48. </span>
  49. </el-dialog>
  50. </div>
  51. </template>
  52. <script>
  53. import * as echarts from 'echarts'
  54. export default {
  55. props: {
  56. dialogVisible: {
  57. type: Boolean,
  58. default: false
  59. }
  60. },
  61. data() {
  62. return {
  63. pickerOptions: {
  64. shortcuts: [
  65. {
  66. text: '最近一周',
  67. onClick(picker) {
  68. const end = new Date()
  69. const start = new Date()
  70. start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
  71. picker.$emit('pick', [start, end])
  72. }
  73. },
  74. {
  75. text: '最近一个月',
  76. onClick(picker) {
  77. const end = new Date()
  78. const start = new Date()
  79. start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
  80. picker.$emit('pick', [start, end])
  81. }
  82. },
  83. {
  84. text: '最近三个月',
  85. onClick(picker) {
  86. const end = new Date()
  87. const start = new Date()
  88. start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
  89. picker.$emit('pick', [start, end])
  90. }
  91. }
  92. ]
  93. },
  94. monthValues: [],
  95. diDian: '',
  96. showEcharts:
  97. this.$store.getters?.setting?.clinical?.showEcharts ||
  98. 'echart3,echart4,echart5,echart6'
  99. }
  100. },
  101. watch: {},
  102. mounted() {
  103. const { first = '', second = '' } = this.$store.getters.level || {}
  104. this.diDian = second || first
  105. const today = new Date()
  106. const halfYearAgo = new Date()
  107. halfYearAgo.setMonth(halfYearAgo.getMonth() - 6)
  108. this.monthValues = [this.formatDate(halfYearAgo), this.formatDate(today)]
  109. this.$nextTick(() => {
  110. this.formatData3()
  111. this.getFangshi()
  112. this.getKeshi()
  113. this.getMonths()
  114. })
  115. },
  116. methods: {
  117. searchData() {
  118. this.formatData3()
  119. this.getFangshi()
  120. this.getKeshi()
  121. this.$message.success('查询成功')
  122. },
  123. // 格式化日期为 YYYY-MM-DD
  124. formatDate(date) {
  125. const year = date.getFullYear()
  126. const month = String(date.getMonth() + 1).padStart(2, '0')
  127. const day = String(date.getDate()).padStart(2, '0')
  128. return `${year}-${month}-${day}`
  129. },
  130. // changeDate(value) {
  131. // console.log('riqi ', value)
  132. // this.formatData3()
  133. // this.getFangshi()
  134. // this.getKeshi()
  135. // },
  136. // 关闭当前窗口
  137. closeDialog(needRefresh) {
  138. this.$emit('update:dialogVisible', false, needRefresh)
  139. },
  140. async formatData3() {
  141. const res = await this.$common.request('query', {
  142. key: 'hqlcgtlbgtztsj',
  143. params: [this.monthValues[0], this.monthValues[1], this.diDian]
  144. })
  145. const { data = [] } = res.variables
  146. var chartDom = document.getElementById('echart3')
  147. var myChart = echarts.init(chartDom)
  148. var option
  149. option = {
  150. title: {
  151. text: '沟通主题占比',
  152. textStyle: { fontSize: 16 },
  153. left: 'center'
  154. },
  155. tooltip: {
  156. trigger: 'item'
  157. },
  158. legend: {
  159. orient: 'vertical',
  160. left: 'left'
  161. },
  162. series: [
  163. {
  164. type: 'pie',
  165. radius: '50%',
  166. data,
  167. emphasis: {
  168. itemStyle: {
  169. shadowBlur: 10,
  170. shadowOffsetX: 0,
  171. shadowColor: 'rgba(0, 0, 0, 0.5)'
  172. }
  173. }
  174. }
  175. ]
  176. }
  177. option && myChart.setOption(option)
  178. },
  179. async getFangshi() {
  180. const res = await this.$common.request('query', {
  181. key: 'hqlcgtgtfssj',
  182. params: [this.monthValues[0], this.monthValues[1], this.diDian]
  183. })
  184. const { data = [] } = res.variables
  185. var chartDom = document.getElementById('echart4')
  186. var myChart = echarts.init(chartDom)
  187. var option
  188. option = {
  189. title: {
  190. text: '沟通方式占比',
  191. textStyle: { fontSize: 16 },
  192. left: 'center'
  193. },
  194. tooltip: {
  195. trigger: 'item'
  196. },
  197. legend: {
  198. orient: 'vertical',
  199. left: 'left'
  200. },
  201. series: [
  202. {
  203. type: 'pie',
  204. radius: '50%',
  205. data,
  206. emphasis: {
  207. itemStyle: {
  208. shadowBlur: 10,
  209. shadowOffsetX: 0,
  210. shadowColor: 'rgba(0, 0, 0, 0.5)'
  211. }
  212. }
  213. }
  214. ]
  215. }
  216. option && myChart.setOption(option)
  217. },
  218. async getKeshi() {
  219. const res = await this.$common.request('query', {
  220. key: 'hqlcgtlckssj',
  221. params: [this.monthValues[0], this.monthValues[1], this.diDian]
  222. })
  223. const { data = [] } = res.variables
  224. var chartDom = document.getElementById('echart5')
  225. var myChart = echarts.init(chartDom)
  226. var option
  227. option = {
  228. title: {
  229. text: '临床科室占比',
  230. textStyle: { fontSize: 16 },
  231. left: 'center'
  232. },
  233. tooltip: {
  234. trigger: 'item'
  235. },
  236. legend: {
  237. orient: 'vertical',
  238. left: 'left'
  239. },
  240. series: [
  241. {
  242. type: 'pie',
  243. radius: '50%',
  244. data,
  245. emphasis: {
  246. itemStyle: {
  247. shadowBlur: 10,
  248. shadowOffsetX: 0,
  249. shadowColor: 'rgba(0, 0, 0, 0.5)'
  250. }
  251. }
  252. }
  253. ]
  254. }
  255. option && myChart.setOption(option)
  256. },
  257. async getMonths() {
  258. const res = await this.$common.request('query', {
  259. key: 'hqlcgtlbj12ysj',
  260. params: [this.diDian]
  261. })
  262. const { data = [] } = res.variables
  263. let xAxis = []
  264. let yAxis = []
  265. data.forEach((item) => {
  266. xAxis.push(item.months)
  267. yAxis.push(item.data_count)
  268. })
  269. var chartDom = document.getElementById('echart6')
  270. var myChart = echarts.init(chartDom)
  271. var option
  272. option = {
  273. title: {
  274. text: '近12个月趋势',
  275. textStyle: { fontSize: 16 },
  276. left: 'center'
  277. },
  278. tooltip: {
  279. trigger: 'axis'
  280. },
  281. xAxis: {
  282. type: 'category',
  283. axisLabel: {
  284. interval: 0, // 强制显示所有标签
  285. rotate: 30
  286. },
  287. data: xAxis
  288. },
  289. yAxis: {
  290. type: 'value'
  291. },
  292. series: [
  293. {
  294. data: yAxis,
  295. type: 'line'
  296. }
  297. ]
  298. }
  299. option && myChart.setOption(option)
  300. }
  301. }
  302. }
  303. </script>
  304. <style scoped lang="scss">
  305. .date-wrap {
  306. padding: 20px;
  307. box-sizing: border-box;
  308. display: flex;
  309. align-items: center;
  310. justify-content: flex-start;
  311. color: #333;
  312. font-size: 16px;
  313. }
  314. .dialog-footer {
  315. display: flex;
  316. justify-content: center;
  317. }
  318. .custom-wrap {
  319. display: flex;
  320. flex-wrap: wrap;
  321. padding: 0 20px;
  322. box-sizing: border-box;
  323. .chart-item {
  324. width: 100%;
  325. height: 300px;
  326. margin: 20px 0;
  327. overflow: hidden;
  328. }
  329. }
  330. </style>