index.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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: 'ProductMonitor'
  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: 116, ...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. sku: '',
  36. platformId: '',
  37. scoreNumber: '-',
  38. commentNumber: '-',
  39. displayScore: '-'
  40. });
  41. provide('query-parameter', formInline);
  42. const groupOptions = ref<any>([]);
  43. const brandsOptions = ref<any>([]);
  44. const shopsOptions = ref<any>([]);
  45. provide('groupOptions', groupOptions);
  46. provide('brandsOptions', brandsOptions);
  47. provide('shopOptions', shopsOptions);
  48. const statusOptions = [
  49. { label: '正常', value: 1 },
  50. { label: '失败', value: 2 },
  51. { label: '暂停', value: 3 },
  52. { label: '下架', value: 10 }
  53. ];
  54. const isTableReady = ref(false);
  55. onBeforeMount(async () => {
  56. await fetchOptions(); // 确保选项数据加载完成
  57. isTableReady.value = true; // 数据加载完成后设置为 true
  58. });
  59. async function fetchOptions() {
  60. groupOptions.value = (await useResponse(api.getGroupOptions)).data;
  61. brandsOptions.value = (await useResponse(api.getBrandsOptions)).data;
  62. shopsOptions.value = (await useResponse(api.getShopsOptions)).data;
  63. }
  64. const btnLoading = ref(false);
  65. const resetLoading = ref(false);
  66. async function handleQuery() {
  67. btnLoading.value = true;
  68. await tableRef.value?.fetchList(true);
  69. btnLoading.value = false;
  70. }
  71. async function resetParameter() {
  72. for (const key in formInline) {
  73. formInline[key] = '';
  74. }
  75. resetLoading.value = true;
  76. await tableRef.value?.fetchList(true);
  77. resetLoading.value = false;
  78. }
  79. </script>
  80. <template>
  81. <div class="p-5">
  82. <el-card class="h-full" style="color: rgba(0, 0, 0, 0.88);">
  83. <div ref="titleContainer" class="text-xl font-semibold pb-5">商品监控</div>
  84. <!-- 查询条件 -->
  85. <div ref="queryContainer" class="flex justify-between">
  86. <div class="flex flex-1">
  87. <div class="w-full whitespace-nowrap">
  88. <el-row :gutter="20" style="margin-bottom: 10px;">
  89. <el-col :span="6">
  90. <div class="flex items-center">
  91. <span class="mr-2">国 家</span>
  92. <el-select v-model="formInline.country" clearable placeholder="请选择国家">
  93. <el-option v-for="item in staticData.country_code" :key="item.value" :label="item.label"
  94. :value="item.value" />
  95. </el-select>
  96. </div>
  97. </el-col>
  98. <el-col :span="6">
  99. <div class="flex items-center">
  100. <span class="mr-2">品 牌</span>
  101. <el-select v-model="formInline.brand" clearable placeholder="请选择品牌">
  102. <el-option v-for="item in brandsOptions" :label="item.brand" :value="item.brand" />
  103. </el-select>
  104. </div>
  105. </el-col>
  106. <el-col :span="6">
  107. <div class="flex items-center">
  108. <span class="mr-2">分 组</span>
  109. <el-select v-model="formInline.group" clearable placeholder="请选择分组">
  110. <el-option v-for="item in groupOptions" :label="item.tag" :value="item.tag" />
  111. </el-select>
  112. </div>
  113. </el-col>
  114. <el-col :span="6">
  115. <div class="flex items-center">
  116. <span class="mr-2">状 态</span>
  117. <el-select v-model="formInline.status" clearable placeholder="请选择状态">
  118. <el-option v-for="item in statusOptions" :key="item.value" :label="item.label"
  119. :value="item.value" />
  120. </el-select>
  121. </div>
  122. </el-col>
  123. </el-row>
  124. <el-row :gutter="20" style="margin-bottom: 10px;">
  125. <el-col :span="6" class="flex">
  126. <div class="flex items-center">
  127. <span class="mr-2">店 铺</span>
  128. <el-select v-model="formInline.shop" clearable placeholder="请选择店铺">
  129. <el-option v-for="item in shopsOptions" :key="item.id" :label="item.name" :value="item.id" />
  130. </el-select>
  131. </div>
  132. </el-col>
  133. <el-col :span="6">
  134. <div class="flex items-center">
  135. <span class="mr-2">ASIN</span>
  136. <el-input v-model="formInline.asin" clearable placeholder="请输入ASIN"></el-input>
  137. </div>
  138. </el-col>
  139. <el-col :span="6">
  140. <div class="flex items-center">
  141. <span class="mr-2">SKU</span>
  142. <el-input v-model="formInline.sku" clearable placeholder="请输入SKU"></el-input>
  143. </div>
  144. </el-col>
  145. <el-col :span="6">
  146. <div class="flex items-center">
  147. <span class="mr-2">平台编号</span>
  148. <el-input v-model="formInline.platformId" clearable placeholder="请输入平台编号"></el-input>
  149. </div>
  150. </el-col>
  151. </el-row>
  152. <el-row :gutter="20">
  153. <el-col :span="6" class="flex">
  154. <div class="flex items-center">
  155. <span class="mr-2">亚马逊显示评分人数</span>
  156. <el-input-number v-model="formInline.scoreNumber" :min="0" placeholder="请输入">
  157. </el-input-number>
  158. </div>
  159. </el-col>
  160. <el-col :span="6">
  161. <div class="flex items-center">
  162. <span class="mr-2">亚马逊显示评论人数</span>
  163. <el-input-number v-model="formInline.commentNumber" :min="0" placeholder="请输入">
  164. </el-input-number>
  165. </div>
  166. </el-col>
  167. <el-col :span="6">
  168. <div class="flex items-center">
  169. <span class="mr-2">亚马逊显示评分</span>
  170. <el-input-number v-model="formInline.displayScore" :min="0" placeholder="请输入">
  171. </el-input-number>
  172. </div>
  173. </el-col>
  174. </el-row>
  175. </div>
  176. </div>
  177. <VerticalDivider />
  178. <div class="flex flex-col items-end">
  179. <el-button :icon="Search" :loading="btnLoading" class="mb-4" type="primary" @click="handleQuery">
  180. 查 询
  181. </el-button>
  182. <el-button :icon="RefreshLeft" :loading="resetLoading" color="#ECECF1C9" style="width: 88px; color: #3c3c3c;"
  183. @click="resetParameter">
  184. 重 置
  185. </el-button>
  186. </div>
  187. </div>
  188. <el-divider ref="dividerContainer" style="margin: 20px 0 12px 0;" />
  189. <div v-if="isTableReady" :style="{ height: tableHeight + 'px' }">
  190. <DataTable ref="table" />
  191. </div>
  192. </el-card>
  193. </div>
  194. </template>
  195. <style scoped>
  196. </style>