|  | @@ -0,0 +1,108 @@
 | 
	
		
			
				|  |  | +<script setup lang="ts">
 | 
	
		
			
				|  |  | +/**
 | 
	
		
			
				|  |  | + * @Name: QueryCondition.vue
 | 
	
		
			
				|  |  | + * @Description:
 | 
	
		
			
				|  |  | + * @Author: Cheney
 | 
	
		
			
				|  |  | + */
 | 
	
		
			
				|  |  | +import { RefreshLeft, Search, Upload, View } from '@element-plus/icons-vue';
 | 
	
		
			
				|  |  | +import { reactive, ref, watch } from 'vue';
 | 
	
		
			
				|  |  | +import * as api from './api';
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +const emit = defineEmits(['dataFetched']);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +const defaultLabel = ref('ASIN');
 | 
	
		
			
				|  |  | +const filter = reactive({
 | 
	
		
			
				|  |  | +  layerType: '',
 | 
	
		
			
				|  |  | +  searchTerm: '',
 | 
	
		
			
				|  |  | +  reportType: '',
 | 
	
		
			
				|  |  | +  reportDate: '',
 | 
	
		
			
				|  |  | +  variable: '',
 | 
	
		
			
				|  |  | +});
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +watch(
 | 
	
		
			
				|  |  | +  () => filter.layerType,
 | 
	
		
			
				|  |  | +  (newValue) => {
 | 
	
		
			
				|  |  | +    if (newValue === 'asin_view') {
 | 
	
		
			
				|  |  | +      defaultLabel.value = 'ASIN';
 | 
	
		
			
				|  |  | +      // filter.variable = 'asin';
 | 
	
		
			
				|  |  | +    } else if (newValue === 'brand_view') {
 | 
	
		
			
				|  |  | +      defaultLabel.value = 'Brand';
 | 
	
		
			
				|  |  | +      // filter.variable = 'brand';
 | 
	
		
			
				|  |  | +    } else {
 | 
	
		
			
				|  |  | +      defaultLabel.value = 'ASIN';
 | 
	
		
			
				|  |  | +      filter.variable = '';
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +async function handleQuery() {
 | 
	
		
			
				|  |  | +  const query = {
 | 
	
		
			
				|  |  | +    date_start: filter.reportDate[0],
 | 
	
		
			
				|  |  | +    date_end: filter.reportDate[1],
 | 
	
		
			
				|  |  | +    layer_type: filter.layerType,
 | 
	
		
			
				|  |  | +    search_term: filter.searchTerm,
 | 
	
		
			
				|  |  | +    report_range: filter.reportType,
 | 
	
		
			
				|  |  | +    [filter.variable]: filter.variable,
 | 
	
		
			
				|  |  | +  };
 | 
	
		
			
				|  |  | +  try {
 | 
	
		
			
				|  |  | +    const response = await api.getAsinMetrics(query);
 | 
	
		
			
				|  |  | +    emit('dataFetched', response.data);
 | 
	
		
			
				|  |  | +  } catch (error) {
 | 
	
		
			
				|  |  | +    console.error('==Error==', error);
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +function resetCondition() {
 | 
	
		
			
				|  |  | +  filter.layerType = '';
 | 
	
		
			
				|  |  | +  filter.searchTerm = '';
 | 
	
		
			
				|  |  | +  filter.reportType = '';
 | 
	
		
			
				|  |  | +  filter.reportDate = '';
 | 
	
		
			
				|  |  | +  filter.variable = '';
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +</script>
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +<template>
 | 
	
		
			
				|  |  | +  <el-card body-class="flex justify-between gap-3.5" shadow="hover" style="border: none; margin-bottom: 10px">
 | 
	
		
			
				|  |  | +    <div class="flex flex-wrap gap-7">
 | 
	
		
			
				|  |  | +      <div>
 | 
	
		
			
				|  |  | +        <span class="font-bold mr-2" style="color: #303133">报告类型:</span>
 | 
	
		
			
				|  |  | +        <el-select v-model="filter.layerType" style="width: 130px">
 | 
	
		
			
				|  |  | +          <el-option label="Asin View" value="asin_view"></el-option>
 | 
	
		
			
				|  |  | +          <el-option label="Brand View" value="brand_view"></el-option>
 | 
	
		
			
				|  |  | +        </el-select>
 | 
	
		
			
				|  |  | +      </div>
 | 
	
		
			
				|  |  | +      <div>
 | 
	
		
			
				|  |  | +        <span class="font-bold mr-2" style="color: #303133">报告类型:</span>
 | 
	
		
			
				|  |  | +        <el-select v-model="filter.reportType" style="width: 100px">
 | 
	
		
			
				|  |  | +          <el-option label="月度" value="MONTHLY"></el-option>
 | 
	
		
			
				|  |  | +          <el-option label="周度" value="WEEKLY"></el-option>
 | 
	
		
			
				|  |  | +        </el-select>
 | 
	
		
			
				|  |  | +      </div>
 | 
	
		
			
				|  |  | +      <div>
 | 
	
		
			
				|  |  | +        <span class="font-bold mr-2" style="color: #303133">搜索词:</span>
 | 
	
		
			
				|  |  | +        <el-input v-model="filter.searchTerm" style="width: 200px"></el-input>
 | 
	
		
			
				|  |  | +      </div>
 | 
	
		
			
				|  |  | +      <div>
 | 
	
		
			
				|  |  | +        <span class="font-bold mr-2" style="color: #303133">{{ defaultLabel }}:</span>
 | 
	
		
			
				|  |  | +        <el-input v-model="filter.variable" style="width: 200px"></el-input>
 | 
	
		
			
				|  |  | +      </div>
 | 
	
		
			
				|  |  | +      <div>
 | 
	
		
			
				|  |  | +        <span class="font-bold mr-2" style="color: #303133">报告日期:</span>
 | 
	
		
			
				|  |  | +        <el-date-picker
 | 
	
		
			
				|  |  | +          v-model="filter.reportDate"
 | 
	
		
			
				|  |  | +          type="daterange"
 | 
	
		
			
				|  |  | +          range-separator="To"
 | 
	
		
			
				|  |  | +          start-placeholder="开始日期"
 | 
	
		
			
				|  |  | +          end-placeholder="结束日期"
 | 
	
		
			
				|  |  | +          value-format="YYYY-MM-DD"
 | 
	
		
			
				|  |  | +          :disabled-date="(time: Date) => time > new Date()"/>
 | 
	
		
			
				|  |  | +      </div>
 | 
	
		
			
				|  |  | +    </div>
 | 
	
		
			
				|  |  | +    <div class="flex gap-3.5">
 | 
	
		
			
				|  |  | +      <el-button type="primary" plain :icon="Search" @click="handleQuery">查询</el-button>
 | 
	
		
			
				|  |  | +      <el-button type="warning" plain round :icon="RefreshLeft" color="#0891b2" @click="resetCondition">重置</el-button>
 | 
	
		
			
				|  |  | +    </div>
 | 
	
		
			
				|  |  | +  </el-card>
 | 
	
		
			
				|  |  | +</template>
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +<style scoped></style>
 |