|
|
@@ -0,0 +1,301 @@
|
|
|
+<template>
|
|
|
+ <div v-loading="loading">
|
|
|
+ <div class="white-box">
|
|
|
+ <el-tabs v-model="moduleName" @tab-click="handleFilterStatusClick">
|
|
|
+ <el-tab-pane label="All" name="all" :lazy="true" /><!-- 全部 -->
|
|
|
+ <el-tab-pane
|
|
|
+ v-for="(item,key) in allModuleName"
|
|
|
+ :key="key"
|
|
|
+ :label="item.label"
|
|
|
+ :name="item.value"
|
|
|
+ :lazy="true"
|
|
|
+ />
|
|
|
+ </el-tabs>
|
|
|
+ <div class="filter-box">
|
|
|
+ <filter-user :filter-types.sync="filterTypes" :filter-btn-name="$t('common.screen')" @select-value="handleFilterUser" />
|
|
|
+ </div>
|
|
|
+ <el-table
|
|
|
+ ref="multipleTable"
|
|
|
+ class="table-box"
|
|
|
+ :data="tableData"
|
|
|
+ stripe
|
|
|
+ style="width: 100%;"
|
|
|
+ :height="tool.getTableHeight(true)"
|
|
|
+ @selection-change="handleSelectionChange"
|
|
|
+ >
|
|
|
+ <!-- <el-table-column type="selection" width="55"></el-table-column>-->
|
|
|
+ <!-- <el-table-column
|
|
|
+ :label="$t('file.exportName')"
|
|
|
+ prop="EXPORT_NAME"
|
|
|
+ :width="flexWidth('EXPORT_NAME',tableData,$t('file.exportName'))"
|
|
|
+ > --><!-- 导出名称 -->
|
|
|
+ <el-table-column
|
|
|
+ :label="$t('file.exportName')"
|
|
|
+ prop="EXPORT_NAME"
|
|
|
+ :width="flexWidth('EXPORT_NAME',tableData,$t('file.exportName'))"
|
|
|
+ >
|
|
|
+ <!-- <template slot-scope="scope">
|
|
|
+ {{ scope.row.EXPORT_NAME }}
|
|
|
+ </template> -->
|
|
|
+
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ :label="$t('file.route')"
|
|
|
+ prop="EXPORT_PERCENT"
|
|
|
+ :width="flexWidth('EXPORT_PERCENT',tableData,$t('file.download'))"
|
|
|
+ ><!-- 路径 -->
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-button
|
|
|
+ v-if="Number(scope.row.EXPORT_PERCENT)===100"
|
|
|
+ type="success"
|
|
|
+ size="small"
|
|
|
+ @click="singleDownload(scope.row)"
|
|
|
+ >{{ $t('file.download') }}
|
|
|
+ </el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ :label="$t('file.operationAdministrator')"
|
|
|
+ prop="ADMIN_NAME"
|
|
|
+ :width="flexWidth('ADMIN_NAME',tableData,$t('file.operationAdministrator'))"
|
|
|
+ ><!-- 操作管理员 -->
|
|
|
+ <!-- <template slot-scope="scope">
|
|
|
+ {{ scope.row.ADMIN_NAME }}
|
|
|
+ </template> -->
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ :label="$t('file.exportProgress')"
|
|
|
+ prop="EXPORT_PERCENT"
|
|
|
+ :width="flexWidth('EXPORT_PERCENT',tableData,$t('file.exportProgress'))"
|
|
|
+ ><!-- 导出进度 -->
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-progress
|
|
|
+ type="circle"
|
|
|
+ :percentage="Number.parseInt(percentList['EXPORT_PERCENT'][scope.row.ID])"
|
|
|
+ :width="50"
|
|
|
+ :stroke-width="3"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column :label="$t('file.exportStart')" width="180"><!-- 导出开始 -->
|
|
|
+ <template slot-scope="scope">
|
|
|
+ {{ tool.formatDate(scope.row.STARTED_AT) }}
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column :label="$t('file.exportComplete')" width="180"><!-- 导出完成 -->
|
|
|
+ <template slot-scope="scope">
|
|
|
+ {{ tool.formatDate(scope.row.ENDED_AT) }}
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column :label="$t('file.createTime')" width="180"><!-- 创建时间 -->
|
|
|
+ <template slot-scope="scope">
|
|
|
+ {{ tool.formatDate(scope.row.CREATED_AT) }}
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <!-- <el-table-column fixed="right" label="操作" width="180">-->
|
|
|
+ <!-- <template slot-scope="scope">-->
|
|
|
+ <!-- <el-dropdown size="small" trigger="click" v-if="permission.hasPermission(`file/export-delete`)">-->
|
|
|
+ <!-- <el-button type="primary" size="small" @click.stop="">-->
|
|
|
+ <!-- 操作该数据<i class="el-icon-arrow-down el-icon--right"></i>-->
|
|
|
+ <!-- </el-button>-->
|
|
|
+ <!-- <el-dropdown-menu slot="dropdown">-->
|
|
|
+ <!-- <el-dropdown-item command="delete" @click.native="handleDelete(scope.row)">删除</el-dropdown-item>-->
|
|
|
+ <!-- </el-dropdown-menu>-->
|
|
|
+ <!-- </el-dropdown>-->
|
|
|
+ <!-- </template>-->
|
|
|
+ <!-- </el-table-column>-->
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ <!-- <div class="white-box-footer"
|
|
|
+ >-->
|
|
|
+ <!-- <el-dropdown size="small" trigger="click" v-if="permission.hasPermission(`file/export-delete`)">-->
|
|
|
+ <!-- <el-button type="primary" size="small">-->
|
|
|
+ <!-- 所选数据<i class="el-icon-arrow-down el-icon--right"></i>-->
|
|
|
+ <!-- </el-button>-->
|
|
|
+ <!-- <el-dropdown-menu slot="dropdown">-->
|
|
|
+ <!-- <el-dropdown-item command="delete" @click.native="handleDelete()">删除</el-dropdown-item>-->
|
|
|
+ <!-- </el-dropdown-menu>-->
|
|
|
+ <!-- </el-dropdown>-->
|
|
|
+ <!-- <pagination :total="totalCount" :page_size="pageSize" @size-change="handleSizeChange"-->
|
|
|
+ <!-- @current-change="handleCurrentChange"></pagination>-->
|
|
|
+ <!-- </div>-->
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import tool from '@/utils/tool'
|
|
|
+import FilterUser from '@/components/FilterUser'
|
|
|
+import permission from '@/utils/permission'
|
|
|
+import filterHelper from '../../utils/filterHelper'
|
|
|
+import { fetchExport } from '@/api/file'
|
|
|
+import store from '@/utils/vuexStore'
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: 'FileExport',
|
|
|
+ components: { FilterUser },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ tableData: null,
|
|
|
+ multipleSelection: [],
|
|
|
+ loading: true,
|
|
|
+ currentPage: 1,
|
|
|
+ totalPages: 1,
|
|
|
+ totalCount: 1,
|
|
|
+ pageSize: 20,
|
|
|
+ tool: tool,
|
|
|
+ EXPORT_NAME: '',
|
|
|
+ permission: permission,
|
|
|
+ filterTypes: {
|
|
|
+ 'EXPORT_NAME': { isUserTable: false, name: this.$t('file.exportName') }, // 导出名称
|
|
|
+ 'STARTED_AT': { isUserTable: false, name: this.$t('file.exportStartTime'), other: 'date' }, // 导出开始时间
|
|
|
+ 'ENDED_AT': { isUserTable: false, name: this.$t('file.exportEndTime'), other: 'date' }, // 导出结束时间
|
|
|
+ 'createdAt': { isUserTable: false, name: this.$t('file.creationTime'), other: 'date' }// 创建时间
|
|
|
+ },
|
|
|
+ filterModel: {},
|
|
|
+ filterStatus: '0',
|
|
|
+ auditStatus: ['not approved', 'approved', 'rejected'], // '未审核', '已审核', '已拒绝'
|
|
|
+ allModuleName: null,
|
|
|
+ moduleName: 'all',
|
|
|
+ percentList: {
|
|
|
+ 'EXPORT_PERCENT': {}
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ this.getData()
|
|
|
+ store.state.socket.onMessageCallback = this.onMessageCallback
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ singleDownload(row) {
|
|
|
+ const url = (row.REMOTE_URL) ? row.REMOTE_URL : process.env.VUE_APP_CDN_API + '/' + 'upload/excel_export' + '/' + row.FILE_NAME
|
|
|
+ window.open(url)
|
|
|
+ },
|
|
|
+ handleSelectionChange(val) {
|
|
|
+ this.multipleSelection = val
|
|
|
+ },
|
|
|
+ handleCurrentChange(page) {
|
|
|
+ this.getData(page, this.pageSize)
|
|
|
+ },
|
|
|
+ handleSizeChange(pageSize) {
|
|
|
+ this.getData(this.currentPage, pageSize)
|
|
|
+ },
|
|
|
+ handleDownload(url) {
|
|
|
+ window.open(url)
|
|
|
+ },
|
|
|
+ handleFilterStatusClick(tab, event) {
|
|
|
+ this.getData()
|
|
|
+ },
|
|
|
+ handleFilterUser(filterData) {
|
|
|
+ filterHelper.handleFilterUser(this, filterData)
|
|
|
+ },
|
|
|
+ handleFilter() {
|
|
|
+ this.getData()
|
|
|
+ },
|
|
|
+ getData(page, pageSize) {
|
|
|
+ if (page === undefined) page = 1
|
|
|
+ if (pageSize === undefined) pageSize = 20
|
|
|
+ const filterData = this.filterModel
|
|
|
+ filterData.moduleName = this.moduleName !== 'all' ? `=,${this.moduleName}` : ''
|
|
|
+ let paramsData = {
|
|
|
+ page: page,
|
|
|
+ pageSize: pageSize
|
|
|
+ }
|
|
|
+ paramsData = Object.assign(paramsData, filterData)
|
|
|
+ console.log(paramsData)
|
|
|
+ fetchExport(paramsData).then(response => {
|
|
|
+ this.allModuleName = response.data.allModuleName
|
|
|
+ this.tableData = response.data.list
|
|
|
+ console.log(this.tableData)
|
|
|
+ this.currentPage = page
|
|
|
+ this.totalPages = parseInt(response.data.totalPages)
|
|
|
+ this.totalCount = parseInt(response.data.totalCount)
|
|
|
+ this.pageSize = pageSize
|
|
|
+ this.loading = false
|
|
|
+ const EXPORT_PERCENT = ['EXPORT_PERCENT']
|
|
|
+ if (EXPORT_PERCENT !== null) {
|
|
|
+ if (EXPORT_PERCENT.length > 0) {
|
|
|
+ for (const i in this.tableData) {
|
|
|
+ for (const j in EXPORT_PERCENT) {
|
|
|
+ this.$set(this.percentList[EXPORT_PERCENT[j]], this.tableData[i].ID, this.tableData[i][EXPORT_PERCENT[j]])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, null, ['EXPORT_PERCENT'])
|
|
|
+ },
|
|
|
+ onMessageCallback(data) {
|
|
|
+ console.log(data)
|
|
|
+ if (data) {
|
|
|
+ if (data.other && data.other.MODEL === 'EXPORT' && data.other.ID) {
|
|
|
+ this.$set(this.percentList[data.other.FIELD], data.other.ID, data.percent)
|
|
|
+ }
|
|
|
+ if (data.percent && data.percent === 100) {
|
|
|
+ this.getData(this.currentPage, this.pageSize)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * flexWidth
|
|
|
+ * @param prop 每列的prop 可传''
|
|
|
+ * @param tableData 表格数据
|
|
|
+ * @param title 标题长内容短的,传标题 可不传
|
|
|
+ * @param num 列中有标签等加的富余量
|
|
|
+ * @returns 列的宽度
|
|
|
+ * 注:prop,title有一个必传
|
|
|
+ */
|
|
|
+ flexWidth(prop, tableData = '', title, num = 0) {
|
|
|
+ if (tableData === undefined || tableData === null) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let flexWidth = 0// 初始化表格列宽
|
|
|
+ let columnContent = ''// 占位最宽的内容
|
|
|
+ const canvas = document.createElement('canvas')
|
|
|
+ const context = canvas.getContext('2d')
|
|
|
+ context.font = '14px Microsoft YaHei'
|
|
|
+ if ((prop === '') && title) { // 标题长内容少的,取标题的值,
|
|
|
+ columnContent = title
|
|
|
+ } else { // 获取该列中占位最宽的内容
|
|
|
+ let index = 0
|
|
|
+ for (let i = 0; i < Object.values(tableData).length; i++) {
|
|
|
+ const now_temp = tableData[i][prop] + ''
|
|
|
+ const max_temp = tableData[index][prop] + ''
|
|
|
+ const now_temp_w = context.measureText(now_temp).width
|
|
|
+ const max_temp_w = context.measureText(max_temp).width
|
|
|
+ if (now_temp_w > max_temp_w) {
|
|
|
+ index = i
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (tableData[index] === undefined || tableData[index] === null) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ columnContent = tableData[index][prop]
|
|
|
+ // 比较占位最宽的值跟标题、标题为空的留出四个位置
|
|
|
+ const column_w = context.measureText(columnContent).width
|
|
|
+ const title_w = context.measureText(title).width
|
|
|
+ if (column_w < title_w) {
|
|
|
+ columnContent = title || '留四个字'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 计算最宽内容的列宽
|
|
|
+ const width = context.measureText(columnContent)
|
|
|
+ flexWidth = width.width + 40 + num
|
|
|
+ return flexWidth + 'px'
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+ .table-box .el-form-item__label {
|
|
|
+ width: 100px;
|
|
|
+ color: #99a9bf;
|
|
|
+ }
|
|
|
+
|
|
|
+ .table-box .el-form-item {
|
|
|
+ width: 30%;
|
|
|
+ margin-right: 0;
|
|
|
+ margin-bottom: 0;
|
|
|
+ }
|
|
|
+</style>
|