Browse Source

refactor(product-manage): 重构产品管理模块

- 调整导入顺序,优化代码结构- 使用 ElMessage 组件替换原有的消息提示方式
- 引入 usePagination 和 useTableData钩子
- 统一模板类型初始值
- 移除冗余代码和未使用的变量
WanGxC 7 months ago
parent
commit
968186dab9

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

@@ -6,16 +6,17 @@
  */
  */
 
 
 import { Delete, Download, InfoFilled, Plus, Refresh, Upload } from '@element-plus/icons-vue';
 import { Delete, Download, InfoFilled, Plus, Refresh, Upload } from '@element-plus/icons-vue';
-import * as api from '../api';
+import { ElMessage } from 'element-plus';
+import { usePagination } from '/@/utils/usePagination';
+import { useTableData } from '/@/utils/useTableData';
+import { productColumns } from '../ColumnsTsx';
+import DataTableSlot from './DataTableSlot.vue';
 import PermissionButton from '/src/components/PermissionButton/index.vue';
 import PermissionButton from '/src/components/PermissionButton/index.vue';
-import EditDrawer from './EditDrawer.vue';
 import ImportButton from '/src/components/ImportButton/index.vue';
 import ImportButton from '/src/components/ImportButton/index.vue';
 import VerticalDivider from '/src/components/VerticalDivider/index.vue';
 import VerticalDivider from '/src/components/VerticalDivider/index.vue';
-import { productColumns } from '../ColumnsTsx';
-import DataTableSlot from './DataTableSlot.vue';
+import EditDrawer from './EditDrawer.vue';
 import CreateDialog from '/@/views/product-manage/product-monitor/component/createDialog.vue';
 import CreateDialog from '/@/views/product-manage/product-monitor/component/createDialog.vue';
-import { ElMessage } from 'element-plus';
-import { batchDeleteRow } from '../api';
+import * as api from '../api';
 
 
 
 
 interface Parameter {
 interface Parameter {

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

@@ -7,9 +7,9 @@
 
 
 import { useCountryInfoStore } from '/@/stores/countryInfo';
 import { useCountryInfoStore } from '/@/stores/countryInfo';
 import { Delete, InfoFilled, Operation } from '@element-plus/icons-vue';
 import { Delete, InfoFilled, Operation } from '@element-plus/icons-vue';
+import { getTagType } from '/@/utils/useTagColor';
 import PermissionButton from '/@/components/PermissionButton/index.vue';
 import PermissionButton from '/@/components/PermissionButton/index.vue';
 import ProductInfo from '/@/views/product-manage/product-list/component/ProductInfo.vue';
 import ProductInfo from '/@/views/product-manage/product-list/component/ProductInfo.vue';
-import { getTagType } from '/@/utils/useTagColor';
 import ProgressBar from '/@/views/product-manage/product-monitor/component/ProgressBar.vue';
 import ProgressBar from '/@/views/product-manage/product-monitor/component/ProgressBar.vue';
 
 
 
 

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

@@ -85,7 +85,7 @@ function closeDrawer() {
                v-model="editOpen"
                v-model="editOpen"
                :close-on-click-modal="false"
                :close-on-click-modal="false"
                :close-on-press-escape="false"
                :close-on-press-escape="false"
-               :title="`商品监控 - 编辑 `"
+               :title="`竞品监控- 编辑 `"
                size="25%">
                size="25%">
       <el-form
       <el-form
           ref="ruleFormRef"
           ref="ruleFormRef"

+ 10 - 8
src/views/product-manage/product-list/component/DataTable.vue

@@ -5,17 +5,19 @@
  * @Author: Cheney
  * @Author: Cheney
  */
  */
 
 
-import { Download, Message, Money, Open, Operation, Refresh } from '@element-plus/icons-vue';
-import * as api from '../api';
+import { Download, Message, Money, Open, Refresh } from '@element-plus/icons-vue';
+import { ElMessage } from 'element-plus';
+import { usePagination } from '/@/utils/usePagination';
+import { useTableData } from '/@/utils/useTableData';
+import { productColumns } from '../ColumnsTsx';
+import DataTableSlot from './DataTableSlot.vue';
+import { downloadFile } from '/@/utils/service';
 import PermissionButton from '/src/components/PermissionButton/index.vue';
 import PermissionButton from '/src/components/PermissionButton/index.vue';
-import EditDrawer from '/src/views/product-manage/product-list/component/EditDrawer.vue';
-import NoticeDialog from '/src/views/product-manage/product-list/component/NoticeDialog.vue';
 import ImportButton from '/src/components/ImportButton/index.vue';
 import ImportButton from '/src/components/ImportButton/index.vue';
 import VerticalDivider from '/src/components/VerticalDivider/index.vue';
 import VerticalDivider from '/src/components/VerticalDivider/index.vue';
-import { productColumns } from '../ColumnsTsx';
-import { downloadFile } from '/@/utils/service';
-import DataTableSlot from './DataTableSlot.vue';
-import { ElMessage } from 'element-plus';
+import EditDrawer from '/src/views/product-manage/product-list/component/EditDrawer.vue';
+import NoticeDialog from '/src/views/product-manage/product-list/component/NoticeDialog.vue';
+import * as api from '../api';
 
 
 
 
 interface Parameter {
 interface Parameter {

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

@@ -7,9 +7,9 @@
 
 
 import { useCountryInfoStore } from '/@/stores/countryInfo';
 import { useCountryInfoStore } from '/@/stores/countryInfo';
 import { Message, Operation } from '@element-plus/icons-vue';
 import { Message, Operation } from '@element-plus/icons-vue';
+import { getTagType } from '/@/utils/useTagColor';
 import PermissionButton from '/@/components/PermissionButton/index.vue';
 import PermissionButton from '/@/components/PermissionButton/index.vue';
 import ProductInfo from '/@/views/product-manage/product-list/component/ProductInfo.vue';
 import ProductInfo from '/@/views/product-manage/product-list/component/ProductInfo.vue';
-import { getTagType } from '/@/utils/useTagColor';
 
 
 
 
 const props = defineProps<{
 const props = defineProps<{

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

@@ -51,7 +51,6 @@ function isOptionDisabled(id: any) {
 }
 }
 
 
 function removeTag(tag: any) {
 function removeTag(tag: any) {
-  console.log('tag=> ', tag);
   staffTags.value = staffTags.value.filter((t: any) => t.id !== tag.id);
   staffTags.value = staffTags.value.filter((t: any) => t.id !== tag.id);
   staffSelect.value = '';
   staffSelect.value = '';
 }
 }

+ 15 - 21
src/views/product-manage/product-monitor/component/DataTable.vue

@@ -6,15 +6,17 @@
  */
  */
 
 
 import { Delete, Download, InfoFilled, Plus, Refresh, Upload } from '@element-plus/icons-vue';
 import { Delete, Download, InfoFilled, Plus, Refresh, Upload } from '@element-plus/icons-vue';
-import * as api from '../api';
-import PermissionButton from '/src/components/PermissionButton/index.vue';
-import EditDrawer from './EditDrawer.vue';
-import ImportButton from '/src/components/ImportButton/index.vue';
-import VerticalDivider from '/src/components/VerticalDivider/index.vue';
+import { ElMessage } from 'element-plus';
+import { usePagination } from '/@/utils/usePagination';
+import { useTableData } from '/@/utils/useTableData';
 import { productColumns } from '../ColumnsTsx';
 import { productColumns } from '../ColumnsTsx';
 import DataTableSlot from '/@/views/product-manage/product-monitor/component/DataTableSlot.vue';
 import DataTableSlot from '/@/views/product-manage/product-monitor/component/DataTableSlot.vue';
+import PermissionButton from '/src/components/PermissionButton/index.vue';
+import VerticalDivider from '/src/components/VerticalDivider/index.vue';
+import ImportButton from '/src/components/ImportButton/index.vue';
+import EditDrawer from './EditDrawer.vue';
 import CreateDialog from '/@/views/product-manage/product-monitor/component/createDialog.vue';
 import CreateDialog from '/@/views/product-manage/product-monitor/component/createDialog.vue';
-import { ElMessage } from 'element-plus';
+import * as api from '../api';
 
 
 
 
 interface Parameter {
 interface Parameter {
@@ -77,9 +79,7 @@ const editOpen = ref(false);
 const createOpen = ref(false);
 const createOpen = ref(false);
 const rowData = ref({});
 const rowData = ref({});
 
 
-const dialogVisible = ref(false);
-
-const templateType = ref();
+const templateType = ref('item1');
 
 
 onMounted(() => {
 onMounted(() => {
   fetchList();
   fetchList();
@@ -107,7 +107,6 @@ async function fetchList() {
   await useTableData(api.getTableData, query, gridOptions);
   await useTableData(api.getTableData, query, gridOptions);
   await gridRef.value.loadColumn(productColumns);
   await gridRef.value.loadColumn(productColumns);
   gridOptions.showHeader = Boolean(gridOptions.data?.length);
   gridOptions.showHeader = Boolean(gridOptions.data?.length);
-
 }
 }
 
 
 function handleRefresh() {
 function handleRefresh() {
@@ -231,25 +230,20 @@ defineExpose({ fetchList });
           </template>
           </template>
           <template #actions="{ confirm, cancel }">
           <template #actions="{ confirm, cancel }">
             <el-button size="small" @click="cancel">No!</el-button>
             <el-button size="small" @click="cancel">No!</el-button>
-            <el-button
-                size="small"
-                type="danger"
-                @click="confirm"
-            >
-              Yes?
-            </el-button>
+            <el-button size="small" type="danger" @click="confirm">Yes?</el-button>
           </template>
           </template>
         </el-popconfirm>
         </el-popconfirm>
         <PermissionButton :icon="Plus" plain round type="primary" @click="handleCreate">
         <PermissionButton :icon="Plus" plain round type="primary" @click="handleCreate">
           新 增
           新 增
         </PermissionButton>
         </PermissionButton>
         <div class="custom-el-input">
         <div class="custom-el-input">
-          <el-select v-model="templateType" placeholder="Select" style="width: 190px">
+          <el-select v-model="templateType" style="width: 190px">
             <template #prefix>
             <template #prefix>
               <div class="flex items-center">
               <div class="flex items-center">
-                <el-button bg size="small" style="margin-left: -7px; font-size: 14px; border-radius: 29px;" text
-                           type="success"
-                           @click.stop="downloadTemplate">下载
+                <el-button size="small" type="success" text
+                           style="margin-left: -7px; font-size: 14px; border-radius: 29px;"
+                           @click.stop="downloadTemplate">
+                  下载
                 </el-button>
                 </el-button>
                 <VerticalDivider style="margin-left: 7px" />
                 <VerticalDivider style="margin-left: 7px" />
               </div>
               </div>

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

@@ -7,9 +7,9 @@
 
 
 import { useCountryInfoStore } from '/@/stores/countryInfo';
 import { useCountryInfoStore } from '/@/stores/countryInfo';
 import { Delete, InfoFilled, Operation } from '@element-plus/icons-vue';
 import { Delete, InfoFilled, Operation } from '@element-plus/icons-vue';
+import { getTagType } from '/@/utils/useTagColor';
 import PermissionButton from '/@/components/PermissionButton/index.vue';
 import PermissionButton from '/@/components/PermissionButton/index.vue';
 import ProductInfo from '/@/views/product-manage/product-list/component/ProductInfo.vue';
 import ProductInfo from '/@/views/product-manage/product-list/component/ProductInfo.vue';
-import { getTagType } from '/@/utils/useTagColor';
 import ProgressBar from '/@/views/product-manage/product-monitor/component/ProgressBar.vue';
 import ProgressBar from '/@/views/product-manage/product-monitor/component/ProgressBar.vue';
 
 
 
 

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

@@ -91,7 +91,7 @@ function closeDrawer() {
                v-model="editOpen"
                v-model="editOpen"
                :close-on-click-modal="false"
                :close-on-click-modal="false"
                :close-on-press-escape="false"
                :close-on-press-escape="false"
-               :title="`商品监控 - 编辑 `"
+               :title="`商品监控- 编辑 `"
                size="25%">
                size="25%">
       <el-form
       <el-form
           ref="ruleFormRef"
           ref="ruleFormRef"

+ 9 - 9
vite.config.ts

@@ -37,15 +37,15 @@ const viteConfig = defineConfig((mode: ConfigEnv) => {
               // 默认导入
               // 默认导入
               ['default', 'dayjs']
               ['default', 'dayjs']
             ],
             ],
-            '/@/utils/useTableData': [
-              'useTableData'
-            ],
-            '/@/utils/usePagination': [
-              'usePagination'
-            ],
-            '/@/utils/useResponse': [
-              'useResponse'
-            ]
+            // '/@/utils/useTableData': [
+            //   'useTableData'
+            // ],
+            // '/@/utils/usePagination': [
+            //   'usePagination'
+            // ],
+            // '/@/utils/useResponse': [
+            //   'useResponse'
+            // ]
           },
           },
         ],
         ],
         resolvers: [ElementPlusResolver()],
         resolvers: [ElementPlusResolver()],