|  | @@ -11,12 +11,14 @@ import { usePagination } from '/@/utils/usePagination';
 | 
	
		
			
				|  |  |  import FileDownLoader from '/@/components/FileDowlander/index.vue';
 | 
	
		
			
				|  |  |  import * as api from './api';
 | 
	
		
			
				|  |  |  import { useElTableData } from '/@/utils/useElTableData';
 | 
	
		
			
				|  |  | -import { Download } from '@element-plus/icons-vue';
 | 
	
		
			
				|  |  | +import { Download, Refresh } from '@element-plus/icons-vue';
 | 
	
		
			
				|  |  | +import { ElMessage } from 'element-plus';
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  const date = ref(calculateLastMonthFirstWeek());
 | 
	
		
			
				|  |  |  const dateRange = ref(date.value[0]);
 | 
	
		
			
				|  |  |  const loading = ref(false);
 | 
	
		
			
				|  |  | +const btnLoading = ref(false);
 | 
	
		
			
				|  |  |  const { tableData, total, currentPage, pageSize, handlePageChange } = usePagination(handleQuery);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  const filter = ref({
 | 
	
	
		
			
				|  | @@ -73,8 +75,6 @@ async function handleQuery() {
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  function handleDownload(row: any) {
 | 
	
		
			
				|  |  | -  console.log("(index.vue: 77)=> row", row);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |    const url = row.Url;
 | 
	
		
			
				|  |  |    const fileName = url.split('/').pop();
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -86,6 +86,43 @@ function handleDownload(row: any) {
 | 
	
		
			
				|  |  |    link.click();
 | 
	
		
			
				|  |  |    document.body.removeChild(link);
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +async function queryDownload() {
 | 
	
		
			
				|  |  | +  btnLoading.value = true;
 | 
	
		
			
				|  |  | +  const query = {
 | 
	
		
			
				|  |  | +    ...filter.value,
 | 
	
		
			
				|  |  | +    date_start: date.value[0],
 | 
	
		
			
				|  |  | +    date_end: date.value[1],
 | 
	
		
			
				|  |  | +    reportDate: undefined,
 | 
	
		
			
				|  |  | +    page: currentPage.value,
 | 
	
		
			
				|  |  | +    limit: pageSize.value,
 | 
	
		
			
				|  |  | +  };
 | 
	
		
			
				|  |  | +  try {
 | 
	
		
			
				|  |  | +    const response = await api.wordDownload(query);
 | 
	
		
			
				|  |  | +    if (response.code === 2000) ElMessage.success(response.msg);
 | 
	
		
			
				|  |  | +  } catch(error) {
 | 
	
		
			
				|  |  | +    console.log('Error==>', error);
 | 
	
		
			
				|  |  | +  } finally {
 | 
	
		
			
				|  |  | +    btnLoading.value = false;
 | 
	
		
			
				|  |  | +    await handleQuery();
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +async function handleRefresh(row: any) {
 | 
	
		
			
				|  |  | +  const query = {
 | 
	
		
			
				|  |  | +    search_term: row.searchTerm,
 | 
	
		
			
				|  |  | +    marketplace_Ids: row.marketplace_id,
 | 
	
		
			
				|  |  | +    report_type: row.tableName.split('_').pop(),
 | 
	
		
			
				|  |  | +    date_start: row.daterange.slice(0, 10),
 | 
	
		
			
				|  |  | +    date_end: row.daterange.slice(10),
 | 
	
		
			
				|  |  | +  };
 | 
	
		
			
				|  |  | +  try {
 | 
	
		
			
				|  |  | +    const { code, msg } = await useElTableData(api.wordDownload, query, tableData, total, loading);
 | 
	
		
			
				|  |  | +    if (code === 2000) ElMessage.success({ message: msg, plain: true})
 | 
	
		
			
				|  |  | +  } catch(error) {
 | 
	
		
			
				|  |  | +    console.log('Error==>', error);
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  |  </script>
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  <template>
 | 
	
	
		
			
				|  | @@ -133,18 +170,9 @@ function handleDownload(row: any) {
 | 
	
		
			
				|  |  |          </div>
 | 
	
		
			
				|  |  |        </div>
 | 
	
		
			
				|  |  |        <div class="flex gap-3.5">
 | 
	
		
			
				|  |  | -        <FileDownLoader
 | 
	
		
			
				|  |  | -            :api="api.wordDownload" :query="{
 | 
	
		
			
				|  |  | -              ...filter,
 | 
	
		
			
				|  |  | -              date_start: date[0],
 | 
	
		
			
				|  |  | -              date_end: date[1],
 | 
	
		
			
				|  |  | -              reportDate: undefined
 | 
	
		
			
				|  |  | -            }"
 | 
	
		
			
				|  |  | -            plain
 | 
	
		
			
				|  |  | -            round
 | 
	
		
			
				|  |  | -            type="success">
 | 
	
		
			
				|  |  | +        <el-button @click="queryDownload" :icon="Download" plain round type="success" :loading="btnLoading">
 | 
	
		
			
				|  |  |            文件下载
 | 
	
		
			
				|  |  | -        </FileDownLoader>
 | 
	
		
			
				|  |  | +        </el-button>
 | 
	
		
			
				|  |  |        </div>
 | 
	
		
			
				|  |  |      </el-card>
 | 
	
		
			
				|  |  |      <el-card shadow="hover" style="border: none; margin-bottom: 10px">
 | 
	
	
		
			
				|  | @@ -166,7 +194,7 @@ function handleDownload(row: any) {
 | 
	
		
			
				|  |  |          </el-table-column>
 | 
	
		
			
				|  |  |          <el-table-column align="center" label="日期范围" prop="daterange">
 | 
	
		
			
				|  |  |            <template #default="{ row }">
 | 
	
		
			
				|  |  | -            <span class="font-semibold">{{ row.daterange }}</span>
 | 
	
		
			
				|  |  | +            <span class="font-semibold">{{ row.daterange.slice(0, 10) }} To {{ row.daterange.slice(10) }}</span>
 | 
	
		
			
				|  |  |            </template>
 | 
	
		
			
				|  |  |          </el-table-column>
 | 
	
		
			
				|  |  |          <el-table-column align="center" label="表名" prop="tableName">
 | 
	
	
		
			
				|  | @@ -178,6 +206,7 @@ function handleDownload(row: any) {
 | 
	
		
			
				|  |  |            <template #default="{ row }">
 | 
	
		
			
				|  |  |              <span class="font-semibold">{{ row.State }}</span>
 | 
	
		
			
				|  |  |              <el-button :icon="Download" class="ml-2" link type="success" :disabled="row.State!='success'" @click="handleDownload(row)"></el-button>
 | 
	
		
			
				|  |  | +            <el-button :icon="Refresh" type="primary" link @click="handleRefresh(row)"></el-button>
 | 
	
		
			
				|  |  |            </template>
 | 
	
		
			
				|  |  |          </el-table-column>
 | 
	
		
			
				|  |  |        </el-table>
 |