index.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. <template>
  2. <div class="content-container">
  3. <el-row class="tool-bar">
  4. <div class="content-title">
  5. <span> {{ title }} </span>
  6. </div>
  7. <div class="select-search">
  8. <span class="search-label">部门:</span>
  9. <group-selector />
  10. </div>
  11. <div class="select-search">
  12. <span class="search-label">年度:</span>
  13. <el-select v-model="conditions.year" filterable placeholder="年份" style="width:120px">
  14. <el-option label="2022年" :value="2022" />
  15. <el-option label="2023年" :value="2023" />
  16. <el-option label="2024年" :value="2024" />
  17. <el-option label="2025年" :value="2025" />
  18. <el-option label="2026年" :value="2026" />
  19. <el-option label="2027年" :value="2027" />
  20. </el-select>
  21. </div>
  22. <div class="select-search">
  23. <span class="search-label">月份:</span>
  24. <el-select v-model="conditions.month" filterable placeholder="月份" style="width:120px" clearable>
  25. <el-option label="1月" :value="1" />
  26. <el-option label="2月" :value="2" />
  27. <el-option label="3月" :value="3" />
  28. <el-option label="4月" :value="4" />
  29. <el-option label="5月" :value="5" />
  30. <el-option label="6月" :value="6" />
  31. <el-option label="7月" :value="7" />
  32. <el-option label="8月" :value="8" />
  33. <el-option label="9月" :value="9" />
  34. <el-option label="10月" :value="10" />
  35. <el-option label="11月" :value="11" />
  36. <el-option label="12月" :value="12" />
  37. </el-select>
  38. </div>
  39. <div class="right" style="min-width:400px;flex: 1;">
  40. <el-input v-model="conditions.keywords" class="search-input m-right-15" size="mini" placeholder="请输入内容">
  41. <el-button slot="append" icon="el-icon-search" size="mini" @click="getData()" />
  42. </el-input>
  43. <el-button class="filter-item" type="primary" icon="el-icon-document" size="mini" @click="handleExport">导出</el-button>
  44. <el-button class="filter-item" style="margin-left: 10px;" type="primary" icon="el-icon-printer" size="mini" @click="handlePrint">打印</el-button>
  45. </div>
  46. </el-row>
  47. <el-row class="content-body">
  48. <vuescroll :ops="ops" style="height: calc(100vh - 250px)">
  49. <!--年度-->
  50. <el-table id="print_view" v-loading="listLoading" border :data="dataList">
  51. <el-table-column type="index" align="center" label="序号" width="80" />
  52. <el-table-column prop="year" header-align="center" align="center" width="300" label="部门">
  53. <template v-slot="{row}">
  54. <span> {{ row.groupName }} </span>
  55. </template>
  56. </el-table-column>
  57. <el-table-column prop="year" header-align="center" align="center" width="300" label="年月">
  58. <template v-slot="{row}">
  59. <span> {{ row.year }}年-{{ row.month }}月</span>
  60. </template>
  61. </el-table-column>
  62. <el-table-column prop="score" header-align="center" align="center" label="总评分">
  63. <template v-slot="{row}">
  64. <span> {{ row.score }} </span>
  65. </template>
  66. </el-table-column>
  67. <el-table-column prop="score" header-align="center" align="center" label="评价目标数目">
  68. <template v-slot="{row}">
  69. <span> {{ row.targetQty }} </span>
  70. </template>
  71. </el-table-column>
  72. <el-table-column prop="score" header-align="center" align="center" label="评价次数">
  73. <template v-slot="{row}">
  74. <span> {{ row.recordQty }} </span>
  75. </template>
  76. </el-table-column>
  77. </el-table>
  78. </vuescroll>
  79. </el-row>
  80. </div>
  81. </template>
  82. <script>
  83. import { mapGetters } from 'vuex'
  84. import GroupSelector from '@/components/GroupSelector'
  85. import vuescroll from 'vuescroll'
  86. import { groupMonthByList } from '@/api/hos/satisfyStatisApi'
  87. export default {
  88. name: 'MonthSatisIndex',
  89. components: { vuescroll, GroupSelector },
  90. mixins: [],
  91. props: {},
  92. data() {
  93. return {
  94. ops: {
  95. bar: {
  96. keepShow: false,
  97. background: 'rgba(144, 147, 153, 0.4)',
  98. onlyShowBarOnScroll: false
  99. }
  100. },
  101. title: '满意度-按年月统计',
  102. listLoading: false,
  103. dataList: [],
  104. conditions: {
  105. groupId: undefined,
  106. year: undefined,
  107. month: undefined,
  108. keywords: undefined
  109. }
  110. }
  111. },
  112. computed: {
  113. ...mapGetters([
  114. 'userData'
  115. ])
  116. },
  117. mounted() {
  118. this.getData()
  119. },
  120. methods: {
  121. getData() {
  122. this.listLoading = true
  123. groupMonthByList(this.conditions).then((resp) => {
  124. this.listLoading = false
  125. const { code, msg, data } = resp
  126. if (code === 200) {
  127. this.dataList = data
  128. this.showYearChart(data)
  129. } else {
  130. this.$message.error(msg)
  131. }
  132. }).catch((error) => {
  133. console.log(error)
  134. })
  135. },
  136. // 显示评分
  137. showYearChart(data) {
  138. var recordQty = []
  139. var score = []
  140. var year = []
  141. var targetQty = []
  142. for (let i = 0; i < data.length; i++) {
  143. recordQty.push(`${data[i].recordQty}`)
  144. score.push(`${data[i].score}`)
  145. year.push(`${data[i].year}`)
  146. targetQty.push(`${data[i].targetQty}`)
  147. }
  148. console.log({
  149. targetQty, recordQty, year, score
  150. })
  151. this.yearKeys = year
  152. this.scoreYearValues = score
  153. this.targetYearValues = targetQty
  154. this.recordYearValues = recordQty
  155. },
  156. // 导出评价记录
  157. handleExport() {
  158. if (this.recordList.length <= 0) {
  159. this.$message.info('数据为空')
  160. return
  161. }
  162. this.downloadLoading = true
  163. import('@/vendor/Export2Excel').then(excel => {
  164. const tHeader = ['科室', '年度', '评价次数', '得分']
  165. const filterVal = ['groupName', 'year', 'recordQty', 'score']
  166. const data = this.formatJson(filterVal, this.yearScoreList)
  167. excel.export_json_to_excel({
  168. header: tHeader,
  169. data,
  170. filename: '',
  171. autoWidth: true,
  172. bookType: 'xlsx'
  173. })
  174. this.downloadLoading = false
  175. })
  176. },
  177. handlePrint() {
  178. let iframe = document.getElementById('print-iframe')
  179. if (!iframe) {
  180. var el = document.querySelector('#print_view')
  181. iframe = document.createElement('IFRAME')
  182. var doc = null
  183. iframe.setAttribute('id', 'print-iframe')
  184. iframe.setAttribute('style', 'position:absolute;width:0px;height:0px;left:-500px;top:-500px;')
  185. document.body.appendChild(iframe)
  186. doc = iframe.contentWindow.document
  187. const styleHtml = 'table{color:#fff;background-color:#0C3444;-webkit-print-color-adjust: exact;}' +
  188. 'td,th{padding:10px;}' +
  189. 'th{background:#306379;-webkit-print-color-adjust: exact;}' +
  190. 'td{background:#0C3444;-webkit-print-color-adjust: exact; }'
  191. doc.write(`<html><head><style media="print">@media print {${styleHtml}}</style></head><body style="zoom: 60%;">${el.innerHTML}</body></html>`)
  192. doc.close()
  193. iframe.contentWindow.focus()
  194. }
  195. iframe.contentWindow.print()
  196. document.body.removeChild(iframe)
  197. // if (navigator.userAgent.indexOf('MSIE') > 0) {
  198. // document.body.removeChild(iframe)
  199. // }
  200. },
  201. formatJson(filterVal, jsonData) {
  202. return jsonData.map(v => filterVal.map(j => {
  203. return v[j]
  204. }))
  205. }
  206. }
  207. }
  208. </script>
  209. <style lang="scss" scoped>
  210. .content-container {
  211. padding: 10px;
  212. margin: 10px;
  213. overflow: hidden;
  214. background: #193142;
  215. height: calc(100vh - 85px);
  216. p {
  217. margin: 0;
  218. line-height: 2em;
  219. padding: 0;
  220. }
  221. .tool-bar {
  222. display: flex;
  223. align-items: center;
  224. overflow: unset;
  225. .list-group {
  226. font-size: 14px;
  227. color: #C1C6C8;
  228. // overflow: hidden;
  229. padding:0 20px;
  230. .list-item {
  231. float: left;
  232. margin-right: 20px;
  233. cursor: pointer;
  234. &.active {
  235. color: #FFFFFF;
  236. border-bottom: 3px solid #08A6DC;
  237. }
  238. }
  239. }
  240. .search-label {
  241. text-align: right;
  242. font-size: 12px;
  243. font-weight: 400;
  244. color: #FFFFFF;
  245. line-height: 1;
  246. span {
  247. font-size: 20px;
  248. font-weight: 400;
  249. color: #FFFFFF;
  250. }
  251. }
  252. }
  253. }
  254. .select-search{
  255. margin-left: 20px;
  256. display: flex;
  257. justify-content: flex-start;
  258. align-items: center;
  259. }
  260. </style>