|
@@ -1,61 +1,68 @@
|
|
|
-<script setup lang="ts">
|
|
|
+<script lang="ts" setup>
|
|
|
/**
|
|
|
* @Name: QueryCondition.vue
|
|
|
* @Description: 搜索词-分析页-条件筛选栏
|
|
|
* @Author: Cheney
|
|
|
*/
|
|
|
import { RefreshLeft, Search } from '@element-plus/icons-vue';
|
|
|
-import { onBeforeMount, onMounted, ref, watch, inject, Ref } from 'vue';
|
|
|
+import { inject, onBeforeMount, onMounted, ref, Ref, watch } from 'vue';
|
|
|
import emitter from '/@/utils/emitter';
|
|
|
import WeekRangePicker from '/@/components/WeekRangePicker/index.vue';
|
|
|
import MonthRangePicker from '/@/components/MonthRangePicker/index.vue';
|
|
|
-import dayjs from 'dayjs'
|
|
|
+import dayjs from 'dayjs';
|
|
|
+import _ from 'lodash';
|
|
|
+
|
|
|
|
|
|
const weekDate = ref([
|
|
|
dayjs().subtract(2, 'week').day(0).format('YYYY-MM-DD'),
|
|
|
- dayjs().subtract(1, 'week').day(6).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'),
|
|
|
+ dayjs().subtract(0, 'month').startOf('month').format('YYYY-MM-DD')
|
|
|
]);
|
|
|
const defaultLabel = ref('ASIN');
|
|
|
const filter = inject<Ref>('filter');
|
|
|
|
|
|
onBeforeMount(() => {
|
|
|
handleDateChange();
|
|
|
-})
|
|
|
+});
|
|
|
+
|
|
|
onMounted(() => {
|
|
|
handleQuery();
|
|
|
});
|
|
|
|
|
|
-watch([weekDate, monthDate], () => {
|
|
|
+watch([ weekDate, monthDate ], () => {
|
|
|
handleDateChange();
|
|
|
-})
|
|
|
+});
|
|
|
|
|
|
watch(
|
|
|
- () => filter.value.layerType,
|
|
|
- (newValue) => {
|
|
|
- if (newValue === 'asin_view') {
|
|
|
- defaultLabel.value = 'ASIN';
|
|
|
- } else if (newValue === 'brand_view') {
|
|
|
- defaultLabel.value = 'Brand';
|
|
|
- } else {
|
|
|
- defaultLabel.value = 'ASIN';
|
|
|
- filter.value.variable = '';
|
|
|
+ () => filter.value.layerType,
|
|
|
+ (newValue) => {
|
|
|
+ if (newValue === 'asin_view') {
|
|
|
+ defaultLabel.value = 'ASIN';
|
|
|
+ } else if (newValue === 'brand_view') {
|
|
|
+ defaultLabel.value = 'Brand';
|
|
|
+ } else {
|
|
|
+ defaultLabel.value = 'ASIN';
|
|
|
+ filter.value.variable = '';
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
);
|
|
|
|
|
|
-function handleQuery() {
|
|
|
+const throttledEmit = _.throttle(() => {
|
|
|
emitter.emit('QueryCondition-sendRequest');
|
|
|
+}, 3000);
|
|
|
+
|
|
|
+function handleQuery() {
|
|
|
+ throttledEmit();
|
|
|
}
|
|
|
|
|
|
function resetCondition() {
|
|
|
- filter.value.layerType = '';
|
|
|
+ filter.value.layerType = 'asin_view';
|
|
|
filter.value.searchTerm = '';
|
|
|
- filter.value.reportType = '';
|
|
|
- filter.value.reportDate = '';
|
|
|
+ filter.value.reportType = 'MONTHLY';
|
|
|
+ // filter.value.reportDate = '';
|
|
|
filter.value.variable = '';
|
|
|
}
|
|
|
|
|
@@ -82,7 +89,7 @@ function handleDateChange() {
|
|
|
</div>
|
|
|
<div>
|
|
|
<span class="font-bold mr-2" style="color: #303133">报告类型:</span>
|
|
|
- <el-select v-model="filter.reportType" @change="handleDateChange" style="width: 100px">
|
|
|
+ <el-select v-model="filter.reportType" style="width: 100px" @change="handleDateChange">
|
|
|
<el-option label="月度" value="MONTHLY"></el-option>
|
|
|
<el-option label="周度" value="WEEKLY"></el-option>
|
|
|
</el-select>
|
|
@@ -97,13 +104,13 @@ function handleDateChange() {
|
|
|
</div>
|
|
|
<div>
|
|
|
<span class="font-bold mr-2" style="color: #303133">报告日期:</span>
|
|
|
- <MonthRangePicker v-model="monthDate" v-if="filter.reportType === 'MONTHLY'" />
|
|
|
- <WeekRangePicker v-model="weekDate" v-else />
|
|
|
+ <MonthRangePicker v-if="filter.reportType === 'MONTHLY'" v-model="monthDate"/>
|
|
|
+ <WeekRangePicker v-else v-model="weekDate"/>
|
|
|
</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>
|
|
|
+ <el-button :icon="Search" plain type="primary" @click="handleQuery">查询</el-button>
|
|
|
+ <el-button :icon="RefreshLeft" color="#0891b2" plain round type="warning" @click="resetCondition">重置</el-button>
|
|
|
</div>
|
|
|
</el-card>
|
|
|
</template>
|