index.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <script lang="ts" setup>
  2. /**
  3. * @Name: index.vue
  4. * @Description: 在线商品
  5. * @Author: Cheney
  6. */
  7. import VerticalDivider from '/src/components/VerticalDivider/index.vue';
  8. import { RefreshLeft, Search } from '@element-plus/icons-vue';
  9. import { useTableHeight } from '/@/utils/useTableHeight';
  10. import DataTable from './component/DataTable.vue';
  11. import { DictionaryStore } from '/@/stores/dictionary';
  12. import { useTemplateRef } from 'vue';
  13. import { useCountryInfoStore } from '/@/stores/countryInfo';
  14. import { useResponse } from '/@/utils/useResponse';
  15. import * as api from './api';
  16. const { data: staticData } = DictionaryStore();
  17. const countryInfoStore = useCountryInfoStore();
  18. const titleContainer: Ref<HTMLElement | null> = useTemplateRef('titleContainer');
  19. const queryContainer: Ref<HTMLElement | null> = useTemplateRef('queryContainer');
  20. const { tableHeight } = useTableHeight(titleContainer, queryContainer);
  21. const tableRef: Ref<any> = useTemplateRef('table');
  22. const btnLoading = ref(false);
  23. const resetLoading = ref(false);
  24. const formInline = reactive<any>({
  25. country: '',
  26. shop: '',
  27. region: '',
  28. delivery: '',
  29. status: '',
  30. asin: '',
  31. sku: '',
  32. platformId: '',
  33. });
  34. provide('query-parameter', formInline);
  35. const shopOptions = ref<any>([]);
  36. onBeforeMount(() => {
  37. fetchShopOptions();
  38. })
  39. async function fetchShopOptions() {
  40. const res = await useResponse(api.getShopOptions)
  41. shopOptions.value = res.data
  42. }
  43. async function handleQuery() {
  44. btnLoading.value = true;
  45. await tableRef.value?.fetchList(true);
  46. btnLoading.value = false;
  47. }
  48. async function resetParameter() {
  49. for (const key in formInline) {
  50. formInline[key] = '';
  51. }
  52. resetLoading.value = true;
  53. await tableRef.value?.fetchList(true);
  54. resetLoading.value = false;
  55. }
  56. </script>
  57. <template>
  58. <div class="p-5">
  59. <el-card class="h-full" style="color: rgba(0, 0, 0, 0.88);">
  60. <div ref="titleContainer" class="text-xl font-semibold pb-5">在线商品</div>
  61. <!-- 查询条件 -->
  62. <div ref="queryContainer" class="flex justify-between">
  63. <div class="flex flex-1">
  64. <div class="w-full whitespace-nowrap">
  65. <el-row :gutter="20" style="margin-bottom: 16px;">
  66. <el-col :span="4">
  67. <div class="flex items-center">
  68. <span class="mr-2">国 家</span>
  69. <el-select v-model="formInline.country" clearable placeholder="请选择国家">
  70. <el-option v-for="item in staticData.country_code" :key="item.value" :label="item.label"
  71. :value="item.value" />
  72. </el-select>
  73. </div>
  74. </el-col>
  75. <el-col :span="5">
  76. <div class="flex items-center">
  77. <span class="mr-2">店 铺</span>
  78. <el-select v-model="formInline.shop" clearable placeholder="请选择店铺">
  79. <el-option v-for="item in shopOptions" :key="item.id" :label="item.name"
  80. :value="item.id" />
  81. </el-select>
  82. </div>
  83. </el-col>
  84. <el-col :span="5">
  85. <div class="flex items-center">
  86. <span class="mr-2">站 点</span>
  87. <el-select v-model="formInline.region" clearable placeholder="请选择站点">
  88. <el-option v-for="item in countryInfoStore.Region" :label="item.name" :value="item.code" />
  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.delivery" clearable placeholder="请选择配送方式">
  96. <el-option label="FBM" value="FBM" />
  97. <el-option label="FBA" value="FBA" />
  98. </el-select>
  99. </div>
  100. </el-col>
  101. <el-col :span="4">
  102. <div class="flex items-center">
  103. <span class="mr-2">状 态</span>
  104. <el-select v-model="formInline.status" clearable placeholder="请选择状态">
  105. <el-option label="在售" value="Active" />
  106. <el-option label="不在售" value="Inactive" />
  107. <el-option label="不完整" value="Incomplete" />
  108. </el-select>
  109. </div>
  110. </el-col>
  111. </el-row>
  112. <el-row :gutter="20">
  113. <el-col :span="6">
  114. <div class="flex items-center">
  115. <span class="mr-2">ASIN</span>
  116. <el-input v-model="formInline.asin" clearable placeholder="请输入ASIN" />
  117. </div>
  118. </el-col>
  119. <el-col :span="6">
  120. <div class="flex items-center">
  121. <span class="mr-2">SKU</span>
  122. <el-input v-model="formInline.sku" clearable placeholder="请输入SKU" />
  123. </div>
  124. </el-col>
  125. <el-col :span="6">
  126. <div class="flex items-center">
  127. <span class="mr-2">平台编号</span>
  128. <el-input v-model="formInline.platformId" clearable placeholder="请输入平台编号" />
  129. </div>
  130. </el-col>
  131. </el-row>
  132. </div>
  133. </div>
  134. <VerticalDivider />
  135. <div class="flex flex-col gap-1.5 items-end">
  136. <el-button :icon="Search" :loading="btnLoading" class="mb-4" type="primary" @click="handleQuery">
  137. 查 询
  138. </el-button>
  139. <el-button :icon="RefreshLeft" :loading="resetLoading" color="#ECECF1C9" style="width: 88px; color: #3c3c3c;"
  140. @click="resetParameter">
  141. 重 置
  142. </el-button>
  143. </div>
  144. </div>
  145. <el-divider ref="dividerContainer" style="margin: 20px 0 12px 0;" />
  146. <div :style="{ height: tableHeight + 'px' }">
  147. <DataTable ref="table" />
  148. </div>
  149. </el-card>
  150. </div>
  151. </template>
  152. <style scoped>
  153. </style>