index.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <script lang="ts" setup>
  2. /**
  3. * @Name: index.vue
  4. * @Description: 公司SKU
  5. * @Author: Cheney
  6. */
  7. import { RefreshRight, Search } from '@element-plus/icons-vue';
  8. import DataTable from './component/DataTable.vue';
  9. import VerticalDivider from '/@/components/VerticalDivider/index.vue';
  10. import { useTableHeight } from '/@/utils/useTableHeight';
  11. import { useResponse } from '/@/utils/useResponse';
  12. import * as api from './api';
  13. const titleContainer: Ref<HTMLElement | null> = useTemplateRef('titleContainer');
  14. const queryContainer: Ref<HTMLElement | null> = useTemplateRef('queryContainer');
  15. const { tableHeight } = useTableHeight(titleContainer, queryContainer);
  16. const tableRef: Ref<any> = useTemplateRef('table');
  17. const btnLoading = ref(false);
  18. const formInline = reactive<any>({
  19. brandName: '',
  20. kind: '',
  21. status: '',
  22. sku: ''
  23. });
  24. provide('query-parameter', formInline);
  25. const brandOptions: any = ref([]);
  26. const kindOptions: any = ref([]);
  27. const statusOptions: any = ref([
  28. { key: 1, name: '草稿' },
  29. { key: 3, name: '已发布' }
  30. ]);
  31. onBeforeMount(() => {
  32. fetchOptions();
  33. });
  34. async function fetchOptions() {
  35. brandOptions.value = (await useResponse(api.getBrandOptions)).data;
  36. kindOptions.value = (await useResponse(api.getKindOptions)).data;
  37. }
  38. async function handleQuery() {
  39. btnLoading.value = true;
  40. await tableRef.value?.fetchList(true);
  41. btnLoading.value = false;
  42. }
  43. function resetParameter() {
  44. for (const key in formInline) {
  45. formInline[key] = '';
  46. }
  47. handleQuery();
  48. }
  49. </script>
  50. <template>
  51. <div class="p-5">
  52. <el-card class="h-full" style="color: rgba(0, 0, 0, 0.88);">
  53. <div ref="titleContainer" class="text-xl font-semibold pb-5">公司SKU</div>
  54. <!-- 查询条件 -->
  55. <div ref="queryContainer" class="flex justify-between">
  56. <div class="flex flex-1">
  57. <div class="w-full whitespace-nowrap">
  58. <el-row :gutter="20" style="margin-bottom: 5px;">
  59. <el-col :span="5">
  60. <div class="flex items-center">
  61. <span class="mr-2">品牌名称</span>
  62. <el-select v-model="formInline.brandName" clearable placeholder="请选择品牌名称">
  63. <el-option v-for="item in brandOptions" :key="item.id" :label="item.brand_name" :value="item.id" />
  64. </el-select>
  65. </div>
  66. </el-col>
  67. <el-col :span="5">
  68. <div class="flex items-center">
  69. <span class="mr-2">种 类</span>
  70. <el-select v-model="formInline.kind" clearable placeholder="请选择种类">
  71. <el-option v-for="item in kindOptions" :key="item.id" :label="item.name" :value="item.id" />
  72. </el-select>
  73. </div>
  74. </el-col>
  75. <el-col :span="4">
  76. <div class="flex items-center">
  77. <span class="mr-2">状 态</span>
  78. <el-select v-model="formInline.status" clearable placeholder="请选择">
  79. <el-option v-for="item in statusOptions" :key="item.key" :label="item.name" :value="item.key" />
  80. </el-select>
  81. </div>
  82. </el-col>
  83. <el-col :span="6">
  84. <div class="flex items-center">
  85. <span class="mr-2">SKU</span>
  86. <el-input v-model="formInline.sku" clearable placeholder="请输入SKU" />
  87. </div>
  88. </el-col>
  89. </el-row>
  90. </div>
  91. </div>
  92. <VerticalDivider />
  93. <div class="flex gap-1.5 ml-5">
  94. <el-button :icon="Search" :loading="btnLoading" type="primary" @click="handleQuery">
  95. 查 询
  96. </el-button>
  97. <el-button :icon="RefreshRight" color="#ECECF1C9" style="width: 88px; color: #3c3c3c;" @click="resetParameter">
  98. 重 置
  99. </el-button>
  100. </div>
  101. </div>
  102. <el-divider ref="dividerContainer" style="margin: 20px 0 12px 0;" />
  103. <div :style="{ height: tableHeight + 'px' }">
  104. <DataTable ref="table" />
  105. </div>
  106. </el-card>
  107. </div>
  108. </template>
  109. <style scoped>
  110. </style>