TableBox.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <template>
  2. <div class="app-container">
  3. <div class="btn-box">
  4. <el-upload
  5. class="upload-btn"
  6. :multiple="false"
  7. :limit="1"
  8. :show-file-list="false"
  9. action="#"
  10. :before-upload="beforeUpload"
  11. >
  12. <el-button type="primary" size="small" icon="el-icon-upload">导入</el-button>
  13. </el-upload>
  14. <el-button type="primary" icon="el-icon-download" @click="onExport">导出</el-button>
  15. <el-button type="primary" plain icon="el-icon-download" @click="onTemplateExport">模板导出</el-button>
  16. </div>
  17. <el-table
  18. v-loading="loading"
  19. :data="data"
  20. style="width: 100%"
  21. >
  22. <el-table-column
  23. v-if="codes.includes('FLAG')"
  24. prop="FLAG"
  25. label="序号"
  26. width="200"
  27. show-overflow-tooltip
  28. align="center"
  29. fixed="left"
  30. />
  31. <el-table-column
  32. v-if="codes.includes('KSMC')"
  33. prop="KSMC"
  34. label="科室"
  35. width="200"
  36. show-overflow-tooltip
  37. />
  38. <el-table-column
  39. v-if="codes.includes('JBMC')"
  40. prop="JBMC"
  41. label="疾病名称"
  42. width="200"
  43. show-overflow-tooltip
  44. />
  45. <el-table-column
  46. v-if="codes.includes('BM')"
  47. prop="BM"
  48. label="疾病别名"
  49. width="200"
  50. show-overflow-tooltip
  51. />
  52. <el-table-column
  53. v-if="codes.includes('JBBM')"
  54. prop="JBBM"
  55. label="疾病编码"
  56. width="200"
  57. show-overflow-tooltip
  58. />
  59. <el-table-column
  60. v-if="codes.includes('JBZD')"
  61. prop="JBZD"
  62. label="鉴别诊断"
  63. width="200"
  64. show-overflow-tooltip
  65. />
  66. <el-table-column
  67. v-if="codes.includes('ZZ')"
  68. prop="ZZ"
  69. label="症状"
  70. width="200"
  71. show-overflow-tooltip
  72. />
  73. <el-table-column
  74. v-if="codes.includes('TZ')"
  75. prop="TZ"
  76. label="体征"
  77. width="200"
  78. show-overflow-tooltip
  79. />
  80. <el-table-column
  81. v-if="codes.includes('YP')"
  82. prop="YP"
  83. label="药品"
  84. width="200"
  85. show-overflow-tooltip
  86. />
  87. <el-table-column
  88. v-if="codes.includes('ZL')"
  89. prop="ZL"
  90. label="治疗"
  91. width="200"
  92. show-overflow-tooltip
  93. />
  94. <el-table-column
  95. v-if="codes.includes('JC')"
  96. prop="JC"
  97. label="检查"
  98. width="200"
  99. show-overflow-tooltip
  100. />
  101. <el-table-column
  102. v-if="codes.includes('JJ')"
  103. prop="JJ"
  104. label="检验"
  105. width="200"
  106. show-overflow-tooltip
  107. />
  108. <el-table-column
  109. v-if="codes.includes('BFZ')"
  110. prop="BFZ"
  111. label="并发症"
  112. width="200"
  113. show-overflow-tooltip
  114. />
  115. <el-table-column
  116. v-if="codes.includes('CKWX')"
  117. prop="CKWX"
  118. label="参考文献"
  119. width="200"
  120. show-overflow-tooltip
  121. />
  122. <el-table-column
  123. v-if="codes.includes('SSMC')"
  124. prop="SSMC"
  125. label="手术名称"
  126. width="200"
  127. show-overflow-tooltip
  128. />
  129. <el-table-column
  130. v-if="codes.includes('SSBM')"
  131. prop="SSBM"
  132. label="手术编码"
  133. width="200"
  134. show-overflow-tooltip
  135. />
  136. <el-table-column
  137. v-if="codes.includes('created_at')"
  138. prop="created_at"
  139. label="创建时间"
  140. width="200"
  141. />
  142. <el-table-column
  143. v-if="codes.includes('updated_at')"
  144. prop="updated_at"
  145. label="更新时间"
  146. width="200"
  147. />
  148. <el-table-column
  149. prop=""
  150. label="操作"
  151. width="200"
  152. fixed="right"
  153. >
  154. <template slot-scope="scope">
  155. <el-button type="text" @click="onEdit(scope.row)">编辑</el-button>
  156. <el-button type="text" @click="onDelConfirm(scope.row)">删除</el-button>
  157. </template>
  158. </el-table-column>
  159. </el-table>
  160. </div>
  161. </template>
  162. <script>
  163. import { illnessDelete } from '@/api/knowledge'
  164. import { illnessTemplateExport, illnessImport } from '@/api/excel'
  165. export default {
  166. props: {
  167. data: {
  168. type: Array,
  169. default() {
  170. return []
  171. }
  172. },
  173. loading: {
  174. type: Boolean,
  175. default() {
  176. return false
  177. }
  178. },
  179. codes: {
  180. type: Array,
  181. default() {
  182. return []
  183. }
  184. }
  185. },
  186. computed: {
  187. actionUrl() {
  188. return `${process.env.VUE_APP_BASE_API}/disease/diseaseImport`
  189. }
  190. },
  191. methods: {
  192. beforeUpload(file) {
  193. console.log(file, '导入')
  194. illnessImport({ file }).then(res => {
  195. if (res.data.c === 0) {
  196. this.$emit('refresh')
  197. this.$message.success('成功')
  198. }
  199. })
  200. },
  201. // 删除
  202. onDelConfirm(row) {
  203. this.$confirm(`是否删除【${row.JBMC}】信息?`, '提示', {
  204. confirmButtonText: '确定',
  205. cancelButtonText: '取消',
  206. type: 'warning'
  207. }).then(() => {
  208. illnessDelete({ id: row.id }).then(res => {
  209. const { m } = res
  210. this.$message.success(m || '成功')
  211. this.$emit('refresh')
  212. })
  213. })
  214. },
  215. // 编辑
  216. onEdit(row) {
  217. this.$emit('edit', row)
  218. },
  219. // 模板导出
  220. onTemplateExport() {
  221. illnessTemplateExport().then(res => {
  222. const content = res.data // 后台返回二进制数据
  223. const blob = new Blob([content])
  224. const fileName = `疾病库模板.xlsx`
  225. if ('download' in document.createElement('a')) { // 非IE下载
  226. const elink = document.createElement('a')
  227. elink.download = fileName
  228. elink.style.display = 'none'
  229. elink.href = URL.createObjectURL(blob)
  230. document.body.appendChild(elink)
  231. elink.click()
  232. URL.revokeObjectURL(elink.href) // 释放URL 对象
  233. document.body.removeChild(elink)
  234. } else { // IE10+下载
  235. navigator.msSaveBlob(blob, fileName)
  236. }
  237. })
  238. },
  239. // 模板导出
  240. onExport() {
  241. this.$emit('export')
  242. }
  243. }
  244. }
  245. </script>
  246. <style lang="scss" scoped>
  247. .btn-box {
  248. text-align: right;
  249. margin-bottom: 15px;
  250. }
  251. .upload-btn {
  252. display: inline-block;
  253. margin-right: 10px;
  254. }
  255. </style>