TableBox.vue 6.1 KB

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