|
@@ -11,17 +11,20 @@ import dayjs from 'dayjs';
|
|
|
import { getTableData } from './api';
|
|
|
import { ElMessage } from 'element-plus';
|
|
|
import { brandColumns } from './useColumns';
|
|
|
-import { usePublicData } from '/@/stores/publicData';
|
|
|
-import { storeToRefs } from 'pinia';
|
|
|
-
|
|
|
-const publicData = usePublicData();
|
|
|
-const { dateRange } = storeToRefs(publicData);
|
|
|
+import WeekRangePicker from '/@/components/WeekRangePicker/index.vue';
|
|
|
+import MonthRangePicker from '/@/components/MonthRangePicker/index.vue';
|
|
|
+
|
|
|
+const weekDate = ref([
|
|
|
+ dayjs().subtract(2, 'week').day(0).format('YYYY-MM-DD'),
|
|
|
+ dayjs().subtract(1, 'week').day(6).format('YYYY-MM-DD'),
|
|
|
+]);
|
|
|
+const monthDate = ref([
|
|
|
+ dayjs().subtract(2, 'month').startOf('month').format('YYYY-MM-DD'),
|
|
|
+ dayjs().subtract(0, 'month').startOf('month').format('YYYY-MM-DD'),
|
|
|
+]);
|
|
|
const reportTypeSelect = ref('weekly');
|
|
|
const searchTermInp = ref('zosi');
|
|
|
-// const asinInp = ref('B0');
|
|
|
const tableLoading = ref(false);
|
|
|
-const downloadLoading = ref(false);
|
|
|
-const date = ref([dateRange.value[0], dateRange.value[1]]);
|
|
|
|
|
|
const gridOptions: any = reactive({
|
|
|
height: 'auto',
|
|
@@ -50,7 +53,7 @@ onBeforeMount(() => {
|
|
|
fetchTableData();
|
|
|
});
|
|
|
|
|
|
-watch(date, () => {
|
|
|
+watch([weekDate, monthDate], () => {
|
|
|
fetchTableData();
|
|
|
});
|
|
|
|
|
@@ -67,10 +70,8 @@ async function handleSelectChange() {
|
|
|
async function refreshTable() {
|
|
|
tablePage.currentPage = 1;
|
|
|
tablePage.pageSize = 20;
|
|
|
- // asinInp.value = '';
|
|
|
searchTermInp.value = '';
|
|
|
reportTypeSelect.value = 'weekly';
|
|
|
- // marketplaceSelect.value = marketplaceIdEnum[0].value;
|
|
|
await fetchTableData();
|
|
|
}
|
|
|
|
|
@@ -79,12 +80,10 @@ async function fetchTableData() {
|
|
|
const query = {
|
|
|
page: tablePage.currentPage,
|
|
|
limit: tablePage.pageSize,
|
|
|
- // asin: asinInp.value,
|
|
|
search_term: searchTermInp.value,
|
|
|
report_type: reportTypeSelect.value,
|
|
|
- // marketplace_Ids: marketplaceSelect.value,
|
|
|
- date_start: date.value[0],
|
|
|
- date_end: date.value[1],
|
|
|
+ date_start: reportTypeSelect.value == 'weekly' ? weekDate.value[0] : monthDate.value[0],
|
|
|
+ date_end: reportTypeSelect.value == 'weekly' ? weekDate.value[1] : monthDate.value[1],
|
|
|
};
|
|
|
try {
|
|
|
const response = await getTableData(query);
|
|
@@ -168,40 +167,13 @@ function calculateLastWeek() {
|
|
|
@clear="handleSelectChange"
|
|
|
style="width: 240px" />
|
|
|
</div>
|
|
|
- <!--<div>-->
|
|
|
- <!-- <span class="font-medium mr-0.5">ASIN </span>-->
|
|
|
- <!-- <el-input-->
|
|
|
- <!-- v-model="asinInp"-->
|
|
|
- <!-- @keyup.enter="handleQueryChange"-->
|
|
|
- <!-- :prefix-icon="Search"-->
|
|
|
- <!-- placeholder="输入后回车查询"-->
|
|
|
- <!-- clearable-->
|
|
|
- <!-- @clear="handleSelectChange"-->
|
|
|
- <!-- style="width: 180px" />-->
|
|
|
- <!--</div>-->
|
|
|
<div>
|
|
|
<span class="font-medium mr-0.5">报告日期 </span>
|
|
|
- <el-date-picker
|
|
|
- v-model="date"
|
|
|
- type="daterange"
|
|
|
- value-format="YYYY-MM-DD"
|
|
|
- range-separator="To"
|
|
|
- :disabled-date="(time: Date) => time > new Date()"
|
|
|
- :popper-options="{ placement: 'bottom-end' }"
|
|
|
- :clearable="false" />
|
|
|
+ <MonthRangePicker v-model="monthDate" v-if="reportTypeSelect === 'monthly'" />
|
|
|
+ <WeekRangePicker v-model="weekDate" v-else />
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="flex">
|
|
|
- <!--<el-button-->
|
|
|
- <!-- type="success"-->
|
|
|
- <!-- plain-->
|
|
|
- <!-- @click="handleDownload"-->
|
|
|
- <!-- :icon="Download"-->
|
|
|
- <!-- round-->
|
|
|
- <!-- :loading="downloadLoading"-->
|
|
|
- <!-- :disabled="!tableData.length"-->
|
|
|
- <!-- >下载表格-->
|
|
|
- <!--</el-button>-->
|
|
|
<el-button @click="refreshTable" :icon="Refresh" circle></el-button>
|
|
|
</div>
|
|
|
</div>
|