index.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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. onBeforeMount(async () => {
  55. await fetchOptions(); // 确保选项数据加载完成
  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: 10px;">
  87. <el-col :span="6">
  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="6">
  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="6">
  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="6">
  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-row>
  122. <el-row :gutter="20" style="margin-bottom: 10px;">
  123. <el-col :span="6" class="flex">
  124. <div class="flex items-center">
  125. <span class="mr-2">店 铺</span>
  126. <el-select v-model="formInline.shop" clearable placeholder="请选择店铺">
  127. <el-option v-for="item in shopsOptions" :key="item.id" :label="item.name" :value="item.id" />
  128. </el-select>
  129. </div>
  130. </el-col>
  131. <el-col :span="6">
  132. <div class="flex items-center">
  133. <span class="mr-2">ASIN</span>
  134. <el-input v-model="formInline.asin" clearable placeholder="请输入ASIN"></el-input>
  135. </div>
  136. </el-col>
  137. <el-col :span="6">
  138. <div class="flex items-center">
  139. <span class="mr-2">SKU</span>
  140. <el-input v-model="formInline.sku" clearable placeholder="请输入SKU"></el-input>
  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 v-model="formInline.platformId" clearable placeholder="请输入平台编号"></el-input>
  147. </div>
  148. </el-col>
  149. </el-row>
  150. <el-row :gutter="20">
  151. <el-col :span="6" class="flex">
  152. <div class="flex items-center">
  153. <span class="mr-2">亚马逊显示评分人数</span>
  154. <el-input-number v-model="formInline.scoreNumber" :min="0" placeholder="请输入">
  155. </el-input-number>
  156. </div>
  157. </el-col>
  158. <el-col :span="6">
  159. <div class="flex items-center">
  160. <span class="mr-2">亚马逊显示评论人数</span>
  161. <el-input-number v-model="formInline.commentNumber" :min="0" placeholder="请输入">
  162. </el-input-number>
  163. </div>
  164. </el-col>
  165. <el-col :span="6">
  166. <div class="flex items-center">
  167. <span class="mr-2">亚马逊显示评分</span>
  168. <el-input-number v-model="formInline.displayScore" :min="0" placeholder="请输入">
  169. </el-input-number>
  170. </div>
  171. </el-col>
  172. </el-row>
  173. </div>
  174. </div>
  175. <VerticalDivider />
  176. <div class="flex flex-col items-end">
  177. <el-button :icon="Search" :loading="btnLoading" class="mb-4" type="primary" @click="handleQuery">
  178. 查 询
  179. </el-button>
  180. <el-button :icon="RefreshLeft" :loading="resetLoading" color="#ECECF1C9" style="width: 88px; color: #3c3c3c;"
  181. @click="resetParameter">
  182. 重 置
  183. </el-button>
  184. </div>
  185. </div>
  186. <el-divider ref="dividerContainer" style="margin: 20px 0 12px 0;" />
  187. <div :style="{ height: tableHeight + 'px' }">
  188. <DataTable ref="table" />
  189. </div>
  190. </el-card>
  191. </div>
  192. </template>
  193. <style scoped>
  194. </style>