瀏覽代碼

refactor(stores): 重构国家信息存储并优化相关组件

- 将 countries 数组重命名为 Countries
- 移除未使用的 Region 变量
- 更新相关组件中的引用,使用新的 Countries 变量
- 删除市场店铺组件中的冗余代码
- 优化数据表格组件的结构
WanGxC 7 月之前
父節點
當前提交
230812f582

+ 2 - 2
src/stores/countryInfo.ts

@@ -1,6 +1,6 @@
 // 列出国家信息的pinia
 export const useCountryInfoStore = defineStore('countryInfo', () => {
-  const countries = [
+  const Countries = [
     { name: '美国', code: 'US', color: '#3C3B6E' }, // 深蓝色
     { name: '英国', code: 'UK', color: '#00247D' }, // 深蓝色
     { name: '德国', code: 'DE', color: '#000000' }, // 黑色
@@ -36,5 +36,5 @@ export const useCountryInfoStore = defineStore('countryInfo', () => {
     { name: '中东站', code: 'ME', color: '#006C35' }, // 绿色
   ]
 
-  return { countries, Region };
+  return { Countries, Region };
 });

+ 1 - 1
src/views/product-manage/competitor-monitor/component/DataTable.vue

@@ -242,7 +242,7 @@ defineExpose({ fetchList });
           <el-select v-model="templateType" placeholder="Select" style="width: 190px">
             <template #prefix>
               <div class="flex items-center">
-                <el-button bg size="small" text type="success"
+                <el-button size="small" text type="success"
                            style="margin-left: -7px; font-size: 14px; border-radius: 29px;"
                            @click.stop="downloadTemplate">下载
                 </el-button>

+ 1 - 1
src/views/product-manage/competitor-monitor/component/DataTableSlot.vue

@@ -22,7 +22,7 @@ const { row, field } = props;
 const emit = defineEmits([ 'edit-row', 'handle-delete' ]);
 
 const countryInfoStore = useCountryInfoStore();
-const country = countryInfoStore.countries.find(c => c.code == row.country_code);
+const country = countryInfoStore.Countries.find(c => c.code == row.country_code);
 const color = country ? country.color : '#3875F6';
 
 const statusText = row.status === 1 ? '在售' : '停售';

+ 1 - 1
src/views/product-manage/product-list/component/DataTableSlot.vue

@@ -21,7 +21,7 @@ const { row, field } = props;
 const emit = defineEmits([ 'edit-row', 'handle-notice', 'handle-monitor' ]);
 
 const countryInfoStore = useCountryInfoStore();
-const country = countryInfoStore.countries.find(c => c.code == row.country_code);
+const country = countryInfoStore.Countries.find(c => c.code == row.country_code);
 const color = country ? country.color : '#3875F6';
 
 const statusText = row.status === 1 ? '在售' : '停售';

+ 1 - 1
src/views/product-manage/product-monitor/component/DataTableSlot.vue

@@ -22,7 +22,7 @@ const { row, field } = props;
 const emit = defineEmits([ 'edit-row', 'handle-delete' ]);
 
 const countryInfoStore = useCountryInfoStore();
-const country = countryInfoStore.countries.find(c => c.code == row.country_code);
+const country = countryInfoStore.Countries.find(c => c.code == row.country_code);
 const color = country ? country.color : '#3875F6';
 
 const statusText = row.status === 1 ? '在售' : '停售';

+ 0 - 53
src/views/store-manage/market-store/component/DataTable.vue

@@ -60,8 +60,6 @@ const gridOptions: any = reactive({
   data: ''
 });
 
-const checkedList = ref<Set<number>>(new Set());
-
 const editOpen = ref(false);
 const rowData = ref({});
 
@@ -90,48 +88,6 @@ function handleRefresh() {
   fetchList();
 }
 
-function selectChangeEvent({ checked, row }: any) {
-  if (checked) {
-    checkedList.value.add(row.id); // 获取单个数据
-  } else {
-    checkedList.value.delete(row.id);
-  }
-}
-
-function selectAllChangeEvent({ checked }: any) {
-  const $grid = gridRef.value;
-  if ($grid) {
-    const records = $grid.getData(); // 获取所有数据
-    if (checked) {
-      records.forEach((item: any) => {
-        checkedList.value.add(item.id);
-      });
-    } else {
-      checkedList.value.clear();
-    }
-  }
-}
-
-function handleEdit(row: any) {
-  editOpen.value = true;
-  rowData.value = row;
-}
-
-function handleNotice(row: any) {
-  dialogVisible.value = true;
-  rowData.value = row;
-}
-
-async function switchMonitor(row: any) {
-  const res = await useResponse(api.postMonitor, { ids: [ row.id ], status: row.is_monitor ? 1 : 0 });
-  if (res && res.code === 2000) {
-    ElMessage.success('操作成功!');
-  } else {
-    row.is_monitor = !row.is_monitor;
-    ElMessage.error('操作失败!');
-  }
-}
-
 defineExpose({ fetchList });
 </script>
 
@@ -145,16 +101,7 @@ defineExpose({ fetchList });
           <Refresh />
         </el-icon>
       </el-button>
-      <!--<el-button circle class="mr-3 toolbar-btn" @click="handleDownload">-->
-      <!--  <el-icon>-->
-      <!--    <Download />-->
-      <!--  </el-icon>-->
-      <!--</el-button>-->
     </template>
-    <!--<template #top>-->
-    <!--  <div class="mb-2"></div>-->
-    <!--</template>-->
-    <!-- 分页 -->
     <template #pager>
       <vxe-pager
           v-model:currentPage="gridOptions.pagerConfig.page"

+ 3 - 5
src/views/store-manage/market-store/component/DataTableSlot.vue

@@ -6,10 +6,7 @@
  */
 
 import { useCountryInfoStore } from '/@/stores/countryInfo';
-import { Message, Operation } from '@element-plus/icons-vue';
 import { getTagType } from '/@/utils/useTagColor';
-import PermissionButton from '/@/components/PermissionButton/index.vue';
-import ProductInfo from '/@/views/product-manage/product-list/component/ProductInfo.vue';
 
 
 const props = defineProps<{
@@ -19,7 +16,7 @@ const props = defineProps<{
 const { row, field } = props;
 
 const countryInfoStore = useCountryInfoStore();
-const country = countryInfoStore.countries.find(c => c.code == row.country_code);
+const country = countryInfoStore.Countries.find(c => c.code == row.country_code);
 const color = country ? country.color : '#3875F6';
 const region = countryInfoStore.Region.find(r => r.code == row.region);
 </script>
@@ -27,7 +24,7 @@ const region = countryInfoStore.Region.find(r => r.code == row.region);
 <template>
   <div class="font-medium">
     <div v-if="field === 'region'">
-      <el-tag :disable-transitions="true" :type=getTagType(row.region)  >
+      <el-tag :disable-transitions="true" :type=getTagType(row.region)>
         {{ region ? region.name : '-' }}
       </el-tag>
     </div>
@@ -36,6 +33,7 @@ const region = countryInfoStore.Region.find(r => r.code == row.region);
         {{ country ? country.name : '-' }}
       </el-tag>
     </div>
+    <!-- 动态获取 -->
     <div v-else>
       {{ row[field] }}
     </div>

+ 4 - 10
src/views/store-manage/market-store/index.vue

@@ -1,4 +1,4 @@
-<script setup lang="ts">
+<script lang="ts" setup>
 /**
  * @Name: index.vue
  * @Description: 市场店铺
@@ -10,8 +10,6 @@ import { RefreshRight, Search } from '@element-plus/icons-vue';
 import { useTableHeight } from '/@/utils/useTableHeight';
 import DataTable from './component/DataTable.vue';
 import { DictionaryStore } from '/@/stores/dictionary';
-import { useResponse } from '/@/utils/useResponse';
-import * as api from './api';
 import { useTemplateRef } from 'vue';
 import { useCountryInfoStore } from '/@/stores/countryInfo';
 
@@ -30,15 +28,10 @@ const btnLoading = ref(false);
 const formInline = reactive<any>({
   country: '',
   region: '',
-  shop: '',
+  shop: ''
 });
 provide('query-parameter', formInline);
 
-onBeforeMount(() => {
-  
-});
-
-
 async function handleQuery() {
   btnLoading.value = true;
   await tableRef.value?.fetchList();
@@ -92,7 +85,8 @@ function resetParameter() {
           <el-button :icon="Search" :loading="btnLoading" class="mb-4" type="primary" @click="handleQuery">
             查 询
           </el-button>
-          <el-button :icon="RefreshRight" color="#ECECF1C9" style="width: 88px; color: #3c3c3c;" @click="resetParameter">
+          <el-button :icon="RefreshRight" color="#ECECF1C9" style="width: 88px; color: #3c3c3c;"
+                     @click="resetParameter">
             重 置
           </el-button>
         </div>