index.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <script lang="ts" setup>
  2. /**
  3. * @Name: index.vue
  4. * @Description: 竞品监控
  5. * @Author: Cheney
  6. */
  7. import { RefreshLeft, Search } from '@element-plus/icons-vue';
  8. import VerticalDivider from '/src/components/VerticalDivider/index.vue';
  9. import { useResponse } from '/@/utils/useResponse';
  10. import * as api from './api';
  11. import { useTemplateRef } from 'vue';
  12. import { DictionaryStore } from '/@/stores/dictionary';
  13. import { useCustomHeight } from '/@/utils/useCustomHeight';
  14. import DataTable from './component/DataTable.vue';
  15. defineOptions({
  16. name: 'CompetitorMonitor'
  17. });
  18. const { data: staticData } = DictionaryStore();
  19. const baseHeight = {
  20. headerHeight: 50,
  21. dividerHeight: 32,
  22. toolbarHeight: 51,
  23. padding: 40
  24. };
  25. const heightObj = { titleContainer: 48, queryContainer: 80, ...baseHeight };
  26. const { tableHeight } = useCustomHeight(heightObj);
  27. const tableRef: Ref<any> = useTemplateRef('table');
  28. const formInline = reactive<any>({
  29. country: '',
  30. brand: '',
  31. group: '',
  32. status: '',
  33. shop: '',
  34. asin: '',
  35. scoreNumber: '-',
  36. commentNumber: '-',
  37. displayScore: '-'
  38. });
  39. provide('query-parameter', formInline);
  40. const groupOptions: any = ref([]);
  41. const brandsOptions: any = ref([]);
  42. const shopsOptions: any = ref([]);
  43. provide('groupOptions', groupOptions);
  44. provide('brandsOptions', brandsOptions);
  45. provide('shopOptions', shopsOptions);
  46. const statusOptions = [
  47. { label: '正常', value: 1 },
  48. { label: '失败', value: 2 },
  49. { label: '暂停', value: 3 },
  50. { label: '下架', value: 10 }
  51. ];
  52. const isTableReady = ref(false);
  53. onBeforeMount(async () => {
  54. await fetchOptions(); // 确保选项数据加载完成
  55. isTableReady.value = true; // 数据加载完成后设置为 true
  56. });
  57. async function fetchOptions() {
  58. groupOptions.value = (await useResponse(api.getGroupOptions)).data;
  59. brandsOptions.value = (await useResponse(api.getBrandsOptions)).data;
  60. shopsOptions.value = (await useResponse(api.getShopsOptions)).data;
  61. }
  62. const btnLoading = ref(false);
  63. const resetLoading = ref(false);
  64. async function handleQuery() {
  65. btnLoading.value = true;
  66. await tableRef.value?.fetchList(true);
  67. btnLoading.value = false;
  68. }
  69. async function resetParameter() {
  70. for (const key in formInline) {
  71. formInline[key] = '';
  72. }
  73. resetLoading.value = true;
  74. await tableRef.value?.fetchList(true);
  75. resetLoading.value = false;
  76. }
  77. </script>
  78. <template>
  79. <div class="p-5">
  80. <el-card class="h-full" style="color: rgba(0, 0, 0, 0.88);">
  81. <div ref="titleContainer" class="text-xl font-semibold pb-5">竞品监控</div>
  82. <!-- 查询条件 -->
  83. <div ref="queryContainer" class="flex justify-between">
  84. <div class="flex flex-1">
  85. <div class="w-full whitespace-nowrap">
  86. <el-row :gutter="20" style="margin-bottom: 16px;">
  87. <el-col :span="4">
  88. <div class="flex items-center">
  89. <span class="mr-2">国 家</span>
  90. <el-select v-model="formInline.country" clearable placeholder="请选择国家">
  91. <el-option v-for="item in staticData.country_code" :key="item.value" :label="item.label"
  92. :value="item.value" />
  93. </el-select>
  94. </div>
  95. </el-col>
  96. <el-col :span="5">
  97. <div class="flex items-center">
  98. <span class="mr-2">品 牌</span>
  99. <el-select v-model="formInline.brand" clearable placeholder="请选择品牌">
  100. <el-option v-for="item in brandsOptions" :label="item.brand" :value="item.brand" />
  101. </el-select>
  102. </div>
  103. </el-col>
  104. <el-col :span="5">
  105. <div class="flex items-center">
  106. <span class="mr-2">分 组</span>
  107. <el-select v-model="formInline.group" clearable placeholder="请选择分组">
  108. <el-option v-for="item in groupOptions" :label="item.tag" :value="item.tag" />
  109. </el-select>
  110. </div>
  111. </el-col>
  112. <el-col :span="4">
  113. <div class="flex items-center">
  114. <span class="mr-2">状 态</span>
  115. <el-select v-model="formInline.status" clearable placeholder="请选择状态">
  116. <el-option v-for="item in statusOptions" :key="item.value" :label="item.label"
  117. :value="item.value" />
  118. </el-select>
  119. </div>
  120. </el-col>
  121. <el-col :span="6" class="flex">
  122. <div class="flex items-center">
  123. <span class="mr-2">店 铺</span>
  124. <el-input v-model="formInline.shop" clearable placeholder="请输入店铺" />
  125. </div>
  126. </el-col>
  127. </el-row>
  128. <el-row :gutter="20">
  129. <el-col :span="6" class="flex">
  130. <div class="flex items-center">
  131. <span class="mr-2">亚马逊显示评分人数</span>
  132. <el-input-number v-model="formInline.scoreNumber" :min="0" placeholder="请输入">
  133. </el-input-number>
  134. </div>
  135. </el-col>
  136. <el-col :span="6">
  137. <div class="flex items-center">
  138. <span class="mr-2">亚马逊显示评论人数</span>
  139. <el-input-number v-model="formInline.commentNumber" :min="0" placeholder="请输入">
  140. </el-input-number>
  141. </div>
  142. </el-col>
  143. <el-col :span="6">
  144. <div class="flex items-center">
  145. <span class="mr-2">亚马逊显示评分</span>
  146. <el-input-number v-model="formInline.displayScore" :min="0" placeholder="请输入">
  147. </el-input-number>
  148. </div>
  149. </el-col>
  150. <el-col :span="6">
  151. <div class="flex items-center">
  152. <span class="mr-2">ASIN</span>
  153. <el-input v-model="formInline.asin" clearable placeholder="请输入ASIN"></el-input>
  154. </div>
  155. </el-col>
  156. </el-row>
  157. </div>
  158. </div>
  159. <VerticalDivider />
  160. <div class="flex flex-col items-end">
  161. <el-button :icon="Search" :loading="btnLoading" class="mb-4" type="primary" @click="handleQuery">
  162. 查 询
  163. </el-button>
  164. <el-button :icon="RefreshLeft" :loading="resetLoading" color="#ECECF1C9" style="width: 88px; color: #3c3c3c;"
  165. @click="resetParameter">
  166. 重 置
  167. </el-button>
  168. </div>
  169. </div>
  170. <el-divider ref="dividerContainer" style="margin: 20px 0 12px 0;" />
  171. <div v-if="isTableReady" :style="{ height: tableHeight + 'px' }">
  172. <DataTable ref="table" />
  173. </div>
  174. </el-card>
  175. </div>
  176. </template>
  177. <style scoped>
  178. </style>