index.vue 6.6 KB

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