|
@@ -7,19 +7,29 @@
|
|
|
|
|
|
import { RefreshRight, Search } from '@element-plus/icons-vue';
|
|
import { RefreshRight, Search } from '@element-plus/icons-vue';
|
|
import VerticalDivider from '/src/components/VerticalDivider/index.vue';
|
|
import VerticalDivider from '/src/components/VerticalDivider/index.vue';
|
|
-import DataTable from './component/DataTable.vue';
|
|
|
|
-import { useTableHeight } from '/@/utils/useTableHeight';
|
|
|
|
import { useResponse } from '/@/utils/useResponse';
|
|
import { useResponse } from '/@/utils/useResponse';
|
|
import * as api from './api';
|
|
import * as api from './api';
|
|
import { useTemplateRef } from 'vue';
|
|
import { useTemplateRef } from 'vue';
|
|
import { DictionaryStore } from '/@/stores/dictionary';
|
|
import { DictionaryStore } from '/@/stores/dictionary';
|
|
|
|
+import { useCustomHeight } from '/@/utils/useCustomHeight';
|
|
|
|
|
|
|
|
|
|
|
|
+const DataTable = defineAsyncComponent(() => import('./component/DataTable.vue'));
|
|
|
|
+
|
|
|
|
+defineOptions({
|
|
|
|
+ name: 'CompetitorMonitor'
|
|
|
|
+});
|
|
|
|
+
|
|
const { data: staticData } = DictionaryStore();
|
|
const { data: staticData } = DictionaryStore();
|
|
|
|
|
|
-const titleContainer: Ref<HTMLElement | null> = useTemplateRef('titleContainer');
|
|
|
|
-const queryContainer: Ref<HTMLElement | null> = useTemplateRef('queryContainer');
|
|
|
|
-const { tableHeight } = useTableHeight(titleContainer, queryContainer);
|
|
|
|
|
|
+const baseHeight = {
|
|
|
|
+ headerHeight: 50,
|
|
|
|
+ dividerHeight: 32,
|
|
|
|
+ toolbarHeight: 51,
|
|
|
|
+ padding: 40
|
|
|
|
+};
|
|
|
|
+const heightObj = { titleContainer: 48, queryContainer: 80, ...baseHeight };
|
|
|
|
+const { tableHeight } = useCustomHeight(heightObj);
|
|
|
|
|
|
const tableRef: Ref<any> = useTemplateRef('table');
|
|
const tableRef: Ref<any> = useTemplateRef('table');
|
|
|
|
|
|
@@ -49,27 +59,19 @@ const statusOptions = [
|
|
{ label: '失败', value: 2 },
|
|
{ label: '失败', value: 2 },
|
|
{ label: '暂停', value: 3 },
|
|
{ label: '暂停', value: 3 },
|
|
{ label: '下架', value: 10 }
|
|
{ label: '下架', value: 10 }
|
|
-]
|
|
|
|
-
|
|
|
|
-onBeforeMount(() => {
|
|
|
|
- fetchGroupOptions();
|
|
|
|
- fetchBrandsOptions();
|
|
|
|
- fetchShopsOptions();
|
|
|
|
-});
|
|
|
|
|
|
+];
|
|
|
|
|
|
-async function fetchGroupOptions() {
|
|
|
|
- const res = await useResponse(api.getGroupOptions);
|
|
|
|
- groupOptions.value = res.data;
|
|
|
|
-}
|
|
|
|
|
|
+const isTableReady = ref(false);
|
|
|
|
|
|
-async function fetchBrandsOptions() {
|
|
|
|
- const res = await useResponse(api.getBrandsOptions);
|
|
|
|
- brandsOptions.value = res.data;
|
|
|
|
-}
|
|
|
|
|
|
+onBeforeMount(async () => {
|
|
|
|
+ await fetchOptions(); // 确保选项数据加载完成
|
|
|
|
+ isTableReady.value = true; // 数据加载完成后设置为 true
|
|
|
|
+});
|
|
|
|
|
|
-async function fetchShopsOptions() {
|
|
|
|
- const res = await useResponse(api.getShopsOptions);
|
|
|
|
- shopsOptions.value = res.data;
|
|
|
|
|
|
+async function fetchOptions() {
|
|
|
|
+ groupOptions.value = (await useResponse(api.getGroupOptions)).data;
|
|
|
|
+ brandsOptions.value = (await useResponse(api.getBrandsOptions)).data;
|
|
|
|
+ shopsOptions.value = (await useResponse(api.getShopsOptions)).data;
|
|
}
|
|
}
|
|
|
|
|
|
const btnLoading = ref(false);
|
|
const btnLoading = ref(false);
|
|
@@ -174,14 +176,14 @@ function resetParameter() {
|
|
<el-button :icon="Search" :loading="btnLoading" class="mb-4" type="primary" @click="handleQuery">
|
|
<el-button :icon="Search" :loading="btnLoading" class="mb-4" type="primary" @click="handleQuery">
|
|
查 询
|
|
查 询
|
|
</el-button>
|
|
</el-button>
|
|
- <el-button :icon="RefreshRight" color="#ECECF1C9" style="width: 88px; color: #3c3c3c;"
|
|
|
|
|
|
+ <el-button :icon="RefreshRight" color="#ECECF1C9" style="width: 88px; color: #3c3c3c;"
|
|
@click="resetParameter">
|
|
@click="resetParameter">
|
|
重 置
|
|
重 置
|
|
</el-button>
|
|
</el-button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<el-divider ref="dividerContainer" style="margin: 20px 0 12px 0;" />
|
|
<el-divider ref="dividerContainer" style="margin: 20px 0 12px 0;" />
|
|
- <div :style="{ height: tableHeight + 'px' }">
|
|
|
|
|
|
+ <div v-if="isTableReady" :style="{ height: tableHeight + 'px' }">
|
|
<DataTable ref="table" />
|
|
<DataTable ref="table" />
|
|
</div>
|
|
</div>
|
|
</el-card>
|
|
</el-card>
|