index.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <template>
  2. <el-drawer v-model="drawerVisible" :destroy-on-close="true" size="950px" :title="drawerProps.title">
  3. <el-tabs v-model="activeName">
  4. <el-tab-pane label="导入日志" name="1">
  5. <div class="drawer-table-box">
  6. <ProTable
  7. :columns="iColumns"
  8. :height="400"
  9. :tool-button="false"
  10. row-key="id"
  11. :init-param="{ type: '0' }"
  12. :request-api="listImportExportApi"
  13. >
  14. <template #status="scope">
  15. <div class="i-text">
  16. <span v-show="scope.row.status == 1" style="margin-right: 8px">
  17. <i class="dot-class" style="background-color: #67c23a"></i>
  18. </span>
  19. <span v-show="scope.row.status == 0" style="margin-right: 8px">
  20. <i class="dot-class" style="background-color: #f56c6c"></i>
  21. </span>
  22. <span v-show="scope.row.status == 2" style="margin-right: 8px">
  23. <i class="dot-class" style="background-color: #e6a23c"></i>
  24. </span>
  25. <span> </span>
  26. </div>
  27. </template>
  28. <!-- 表格操作 -->
  29. <template #operation="scope">
  30. <el-button type="primary" link @click="handleDownload(scope.row)"> 下载 </el-button>
  31. <el-button type="primary" link @click="handleLog(scope.row)"> 日志 </el-button>
  32. </template>
  33. </ProTable>
  34. </div>
  35. </el-tab-pane>
  36. <el-tab-pane label="导出日志" name="second">
  37. <div class="drawer-table-box">
  38. <ProTable
  39. :columns="eColumns"
  40. :height="400"
  41. :tool-button="false"
  42. row-key="id"
  43. :init-param="{ type: '1' }"
  44. :request-api="listImportExportApi"
  45. >
  46. <!-- 表格操作 -->
  47. <template #operation="scope">
  48. <el-button type="primary" link @click="handleDownload(scope.row)"> 下载 </el-button>
  49. <el-button type="primary" link @click="handleLog(scope.row)"> 日志 </el-button>
  50. </template>
  51. </ProTable>
  52. </div>
  53. </el-tab-pane>
  54. </el-tabs>
  55. </el-drawer>
  56. </template>
  57. <script setup lang="ts" name="IEDrawer">
  58. import { ColumnProps } from '@/components/ProTable/interface'
  59. import { listImportExportApi } from '@/api/modules/system/importExport'
  60. import useDownload from '@/hooks/useDownload'
  61. import { ImportExportVO } from '@/api/interface/system/importExport'
  62. import { ElMessageBox } from 'element-plus'
  63. const { proxy } = getCurrentInstance() as ComponentInternalInstance
  64. const { excel_status } = toRefs<any>(proxy?.useDict('excel_status'))
  65. const activeName = ref('1')
  66. interface DrawerProps {
  67. title: string
  68. }
  69. const drawerVisible = ref(false)
  70. const drawerProps = ref<DrawerProps>({
  71. title: '我的导入导出'
  72. })
  73. // const tableData = [
  74. // {
  75. // id: 11,
  76. // name: 'Tom',
  77. // status: '1',
  78. // createBy: 'wanggaokun',
  79. // updateTime: '2024-06-21 17:25:33'
  80. // }
  81. // ]
  82. /** 下载按钮操作 */
  83. const handleDownload = (row: ImportExportVO) => {
  84. useDownload.oss(row.ossId)
  85. }
  86. const handleLog = (row: ImportExportVO) => {
  87. ElMessageBox.alert(row.logInfo, '日志信息', {
  88. dangerouslyUseHTMLString: true
  89. })
  90. }
  91. // 导入信息表格配置项
  92. const iColumns = reactive<ColumnProps<any>[]>([
  93. {
  94. type: 'index',
  95. label: '序号',
  96. width: 60
  97. },
  98. {
  99. prop: 'name',
  100. label: '文件名称',
  101. search: {
  102. el: 'input'
  103. }
  104. },
  105. {
  106. prop: 'status',
  107. label: '状态',
  108. enum: excel_status,
  109. search: {
  110. el: 'select'
  111. },
  112. width: 120
  113. },
  114. {
  115. prop: 'createBy',
  116. label: '操作人',
  117. search: {
  118. el: 'input'
  119. },
  120. width: 220
  121. },
  122. {
  123. prop: 'updateTime',
  124. label: '操作时间',
  125. search: {
  126. el: 'date-picker',
  127. props: { type: 'datetimerange', valueFormat: 'YYYY-MM-DD HH:mm:ss' }
  128. },
  129. width: 220
  130. },
  131. { prop: 'operation', label: '操作' }
  132. ])
  133. // 导出信息表格配置项
  134. const eColumns = reactive<ColumnProps<any>[]>([
  135. {
  136. type: 'index',
  137. label: '序号',
  138. width: 60
  139. },
  140. {
  141. prop: 'name',
  142. label: '文件名称',
  143. search: {
  144. el: 'input'
  145. }
  146. },
  147. {
  148. prop: 'createBy',
  149. label: '操作人',
  150. width: 220
  151. },
  152. {
  153. prop: 'updateTime',
  154. label: '操作时间',
  155. width: 220
  156. },
  157. {
  158. prop: 'status',
  159. label: '状态',
  160. tag: true,
  161. enum: excel_status,
  162. search: {
  163. el: 'select'
  164. },
  165. width: 120
  166. },
  167. { prop: 'operation', label: '操作' }
  168. ])
  169. // 接收父组件传过来的参数
  170. const acceptParams = () => {
  171. drawerVisible.value = true
  172. }
  173. defineExpose({
  174. acceptParams
  175. })
  176. </script>
  177. <style scoped lang="scss">
  178. .dot-class {
  179. display: block;
  180. width: 10px;
  181. height: 10px;
  182. margin-left: 10px; // 这个用于圆点居中
  183. border-radius: 50%;
  184. }
  185. .i-text {
  186. display: flex;
  187. align-items: center;
  188. justify-content: center;
  189. }
  190. </style>