index.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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 { RefreshRight, 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 { useResponse } from '/@/utils/useResponse';
  13. import * as api from './api';
  14. import { useTemplateRef } from 'vue';
  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 btnLoading = ref(false);
  21. const formInline = reactive({
  22. country: '',
  23. brand: '',
  24. group: '',
  25. status: '',
  26. asin: '',
  27. sku: '',
  28. shop: '',
  29. });
  30. provide('query-parameter', formInline)
  31. const groupOptions:any = ref([])
  32. const brandsOptions:any = ref([])
  33. onBeforeMount(() => {
  34. fetchGroupOptions()
  35. fetchBrandsOptions()
  36. })
  37. async function fetchGroupOptions() {
  38. const res = await useResponse(api.getGroupOptions)
  39. groupOptions.value = res.data
  40. }
  41. async function fetchBrandsOptions() {
  42. const res = await useResponse(api.getBrandsOptions)
  43. brandsOptions.value = res.data
  44. }
  45. async function handleQuery() {
  46. btnLoading.value = true;
  47. await tableRef.value?.fetchList();
  48. btnLoading.value = false;
  49. }
  50. </script>
  51. <template>
  52. <div class="p-5 flex-grow">
  53. <el-card class="h-full" style="color: rgba(0, 0, 0, 0.88);">
  54. <div ref="titleContainer" class="text-xl font-semibold pb-7">商品列表</div>
  55. <!-- 查询条件 -->
  56. <div ref="queryContainer" class="flex justify-between">
  57. <div class="flex flex-1">
  58. <div class="w-full whitespace-nowrap">
  59. <el-row :gutter="20" style="margin-bottom: 16px;">
  60. <el-col :span="6">
  61. <div class="flex items-center">
  62. <span class="mr-2">国 家</span>
  63. <el-select v-model="formInline.country" clearable placeholder="请选择国家">
  64. <el-option v-for="item in staticData.country_code" :key="item.value" :label="item.label"
  65. :value="item.value" />
  66. </el-select>
  67. </div>
  68. </el-col>
  69. <el-col :span="6">
  70. <div class="flex items-center">
  71. <span class="mr-2">品 牌</span>
  72. <el-select v-model="formInline.brand" clearable placeholder="请选择品牌">
  73. <el-option v-for="item in brandsOptions" :label="item.brand" :value="item.brand" />
  74. </el-select>
  75. </div>
  76. </el-col>
  77. <el-col :span="6">
  78. <div class="flex items-center">
  79. <span class="mr-2">分 组</span>
  80. <el-select v-model="formInline.group" clearable placeholder="请选择分组">
  81. <el-option v-for="item in groupOptions" :label="item.tag" :value="item.tag" />
  82. </el-select>
  83. </div>
  84. </el-col>
  85. <el-col :span="6">
  86. <div class="flex items-center">
  87. <span class="mr-2">状 态</span>
  88. <el-select v-model="formInline.status" clearable placeholder="请选择状态">
  89. <el-option v-for="item in staticData.goods_status" :key="item.value" :label="item.label"
  90. :value="item.value" />
  91. </el-select>
  92. </div>
  93. </el-col>
  94. </el-row>
  95. <el-row :gutter="20">
  96. <el-col :span="6">
  97. <div class="flex items-center">
  98. <span class="mr-2">ASIN</span>
  99. <el-input v-model="formInline.asin" clearable placeholder="请输入ASIN"></el-input>
  100. </div>
  101. </el-col>
  102. <el-col :span="6">
  103. <div class="flex items-center">
  104. <span class="mr-2">SKU</span>
  105. <el-input v-model="formInline.sku" clearable placeholder="请输入SKU"></el-input>
  106. </div>
  107. </el-col>
  108. <el-col :span="6" class="flex">
  109. <div class="flex items-center">
  110. <span class="mr-2">店 铺</span>
  111. <el-input v-model="formInline.shop" clearable placeholder="请输入店铺"></el-input>
  112. </div>
  113. </el-col>
  114. </el-row>
  115. </div>
  116. </div>
  117. <VerticalDivider />
  118. <div class="flex flex-col gap-1.5 items-end">
  119. <el-button :icon="Search" :loading="btnLoading" class="mb-4" type="primary" @click="handleQuery">
  120. 查 询
  121. </el-button>
  122. <el-button :icon="RefreshRight" color="#ECECF1C9" style="width: 88px; color: #3c3c3c;">
  123. 重 置
  124. </el-button>
  125. </div>
  126. </div>
  127. <el-divider ref="dividerContainer" style="margin: 20px 0 12px 0;" />
  128. <div :style="{ height: tableHeight + 'px' }">
  129. <DataTable ref="table" />
  130. </div>
  131. </el-card>
  132. </div>
  133. </template>
  134. <style scoped>
  135. </style>