c98155f14f0ae30e5780a85499db682160251094.svn-base 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <template>
  2. <a-card :bordered="false">
  3. <!-- 查询区域 -->
  4. <div class="table-page-search-wrapper">
  5. <a-form layout="inline" @keyup.enter.native="searchQuery">
  6. <a-row :gutter="24">
  7. <a-col :md="6" :sm="8">
  8. <a-form-item label="文件名称">
  9. <a-input placeholder="请输入文件名称" v-model="queryParam.fileName"></a-input>
  10. </a-form-item>
  11. </a-col>
  12. <a-col :md="6" :sm="8">
  13. <a-form-item label="文件地址">
  14. <a-input placeholder="请输入文件地址" v-model="queryParam.url"></a-input>
  15. </a-form-item>
  16. </a-col>
  17. <a-col :md="6" :sm="8">
  18. <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
  19. <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
  20. <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
  21. </span>
  22. </a-col>
  23. </a-row>
  24. </a-form>
  25. </div>
  26. <!-- 操作按钮区域 -->
  27. <div class="table-operator">
  28. <!-- <a-button type="primary" icon="download" @click="handleExportXls('文件列表')">导出</a-button>-->
  29. <a-upload
  30. name="file"
  31. :multiple="false"
  32. :action="uploadAction"
  33. :headers="tokenHeader"
  34. :showUploadList="false"
  35. :beforeUpload="beforeUpload"
  36. @change="handleChange">
  37. <a-button>
  38. <a-icon type="upload"/>
  39. OSS文件上传
  40. </a-button>
  41. </a-upload>
  42. <a-upload
  43. name="file"
  44. :multiple="false"
  45. :action="minioUploadAction"
  46. :headers="tokenHeader"
  47. :showUploadList="false"
  48. :beforeUpload="beforeUpload"
  49. @change="handleChange">
  50. <a-button>
  51. <a-icon type="upload"/>
  52. MINIO文件上传
  53. </a-button>
  54. </a-upload>
  55. </div>
  56. <!-- table区域-begin -->
  57. <div>
  58. <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
  59. <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a
  60. style="font-weight: 600">{{
  61. selectedRowKeys.length }}</a>项
  62. <a style="margin-left: 24px" @click="onClearSelected">清空</a>
  63. </div>
  64. <a-table
  65. ref="table"
  66. size="middle"
  67. bordered
  68. rowKey="id"
  69. :columns="columns"
  70. :dataSource="dataSource"
  71. :pagination="ipagination"
  72. :loading="loading"
  73. :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
  74. @change="handleTableChange">
  75. <span slot="action" slot-scope="text, record">
  76. <a @click="handlePreview(record)">预览</a>
  77. <a-divider type="vertical"/>
  78. <a @click="ossDelete(record.id)">删除</a>
  79. </span>
  80. </a-table>
  81. </div>
  82. <!-- table区域-end -->
  83. </a-card>
  84. </template>
  85. <script>
  86. import {JeecgListMixin} from '@/mixins/JeecgListMixin'
  87. export default {
  88. name: "OSSFileList",
  89. mixins: [JeecgListMixin],
  90. data() {
  91. return {
  92. description: '文件列表',
  93. // 表头
  94. columns: [
  95. {
  96. title: '#',
  97. dataIndex: '',
  98. key: 'rowIndex',
  99. width: 60,
  100. align: "center",
  101. customRender: function (t, r, index) {
  102. return parseInt(index) + 1;
  103. }
  104. },
  105. {
  106. title: '文件名称',
  107. align: "center",
  108. dataIndex: 'fileName'
  109. },
  110. {
  111. title: '文件地址',
  112. align: "center",
  113. dataIndex: 'url'
  114. },
  115. {
  116. title: '操作',
  117. dataIndex: 'action',
  118. align: "center",
  119. scopedSlots: {customRender: 'action'},
  120. }
  121. ],
  122. url: {
  123. upload: "/sys/oss/file/upload",
  124. list: "/sys/oss/file/list",
  125. delete: "/sys/oss/file/delete",
  126. minioUpload: "/sys/upload/uploadMinio"
  127. }
  128. }
  129. },
  130. computed: {
  131. uploadAction() {
  132. return window._CONFIG['domianURL'] + this.url.upload;
  133. },
  134. minioUploadAction() {
  135. return window._CONFIG['domianURL'] + this.url.minioUpload;
  136. },
  137. },
  138. methods: {
  139. beforeUpload(file) {
  140. var fileType = file.type;
  141. if (fileType === 'image') {
  142. if (fileType.indexOf('image') < 0) {
  143. this.$message.warning('请上传图片');
  144. return false;
  145. }
  146. } else if (fileType === 'file') {
  147. if (fileType.indexOf('image') >= 0) {
  148. this.$message.warning('请上传文件');
  149. return false;
  150. }
  151. }
  152. return true
  153. },
  154. handleChange(info) {
  155. if (info.file.status === 'done') {
  156. if (info.file.response.success) {
  157. this.loadData()
  158. this.$message.success(`${info.file.name} 上传成功!`);
  159. } else {
  160. this.$message.error(`${info.file.response.message}`);
  161. }
  162. } else if (info.file.status === 'error') {
  163. this.$message.error(`${info.file.response.message}`);
  164. }
  165. },
  166. ossDelete(id) {
  167. var that = this;
  168. that.$confirm({
  169. title: "确认删除",
  170. content: "是否删除选中文件?",
  171. onOk: function () {
  172. that.handleDelete(id)
  173. }
  174. });
  175. },
  176. handlePreview(record) {
  177. if (record && record.url) {
  178. let url = window._CONFIG['onlinePreviewDomainURL'] + '?url=' + encodeURIComponent(record.url)
  179. window.open(url, '_blank')
  180. }
  181. }
  182. }
  183. }
  184. </script>
  185. <style scoped>
  186. @import '~@assets/less/common.less';
  187. </style>