Sfoglia il codice sorgente

快捷入口提交

hurx 1 settimana fa
parent
commit
98a49e740d

+ 63 - 0
src/api/enterprisePurchase/quickEntryItems/index.ts

@@ -0,0 +1,63 @@
+import request from '@/utils/request';
+import { AxiosPromise } from 'axios';
+import { QuickEntryItemsVO, QuickEntryItemsForm, QuickEntryItemsQuery } from '@/api/enterprisePurchase/quickEntryItems/types';
+
+/**
+ * 查询快捷入口项列列表
+ * @param query
+ * @returns {*}
+ */
+
+export const listQuickEntryItems = (query?: QuickEntryItemsQuery): AxiosPromise<QuickEntryItemsVO[]> => {
+  return request({
+    url: '/mall/quickEntryItems/list',
+    method: 'get',
+    params: query
+  });
+};
+
+/**
+ * 查询快捷入口项列详细
+ * @param id
+ */
+export const getQuickEntryItems = (id: string | number): AxiosPromise<QuickEntryItemsVO> => {
+  return request({
+    url: '/mall/quickEntryItems/' + id,
+    method: 'get'
+  });
+};
+
+/**
+ * 新增快捷入口项列
+ * @param data
+ */
+export const addQuickEntryItems = (data: QuickEntryItemsForm) => {
+  return request({
+    url: '/mall/quickEntryItems',
+    method: 'post',
+    data: data
+  });
+};
+
+/**
+ * 修改快捷入口项列
+ * @param data
+ */
+export const updateQuickEntryItems = (data: QuickEntryItemsForm) => {
+  return request({
+    url: '/mall/quickEntryItems',
+    method: 'put',
+    data: data
+  });
+};
+
+/**
+ * 删除快捷入口项列
+ * @param id
+ */
+export const delQuickEntryItems = (id: string | number | Array<string | number>) => {
+  return request({
+    url: '/mall/quickEntryItems/' + id,
+    method: 'delete'
+  });
+};

+ 146 - 0
src/api/enterprisePurchase/quickEntryItems/types.ts

@@ -0,0 +1,146 @@
+export interface QuickEntryItemsVO {
+  /**
+   * 主键ID
+   */
+  id: string | number;
+
+  /**
+   * 关联模块ID
+   */
+  moduleId: string | number;
+
+  /**
+   * 排序权重
+   */
+  sortOrder: number;
+
+  /**
+   * 入口名称
+   */
+  name: string;
+
+  /**
+   * 图标地址
+   */
+  iconUrl: string;
+
+  /**
+   * 角标文字
+   */
+  tagText: string;
+
+  /**
+   * 入口跳转地址
+   */
+  jumpLink: string;
+
+  /**
+   * 状态 (1启用 0禁用)
+   */
+  status: number;
+
+  /**
+   * 备注
+   */
+  remark: string;
+
+}
+
+export interface QuickEntryItemsForm extends BaseEntity {
+  /**
+   * 主键ID
+   */
+  id?: string | number;
+
+  /**
+   * 关联模块ID
+   */
+  moduleId?: string | number;
+
+  /**
+   * 排序权重
+   */
+  sortOrder?: number;
+
+  /**
+   * 入口名称
+   */
+  name?: string;
+
+  /**
+   * 图标地址
+   */
+  iconUrl?: string;
+
+  /**
+   * 角标文字
+   */
+  tagText?: string;
+
+  /**
+   * 入口跳转地址
+   */
+  jumpLink?: string;
+
+  /**
+   * 状态 (1启用 0禁用)
+   */
+  status?: number;
+
+  /**
+   * 备注
+   */
+  remark?: string;
+
+}
+
+export interface QuickEntryItemsQuery extends PageQuery {
+
+  /**
+   * 关联模块ID
+   */
+  moduleId?: string | number;
+
+  /**
+   * 排序权重
+   */
+  sortOrder?: number;
+
+  /**
+   * 入口名称
+   */
+  name?: string;
+
+  /**
+   * 图标地址
+   */
+  iconUrl?: string;
+
+  /**
+   * 角标文字
+   */
+  tagText?: string;
+
+  /**
+   * 入口跳转地址
+   */
+  jumpLink?: string;
+
+  /**
+   * 状态 (1启用 0禁用)
+   */
+  status?: number;
+
+  /**
+   * 平台标识
+   */
+  platformCode?: string;
+
+    /**
+     * 日期范围参数
+     */
+    params?: any;
+}
+
+
+

+ 63 - 0
src/api/enterprisePurchase/quickEntryModule/index.ts

@@ -0,0 +1,63 @@
+import request from '@/utils/request';
+import { AxiosPromise } from 'axios';
+import { QuickEntryModuleVO, QuickEntryModuleForm, QuickEntryModuleQuery } from '@/api/enterprisePurchase/quickEntryModule/types';
+
+/**
+ * 查询快捷入口模块配置列表
+ * @param query
+ * @returns {*}
+ */
+
+export const listQuickEntryModule = (query?: QuickEntryModuleQuery): AxiosPromise<QuickEntryModuleVO[]> => {
+  return request({
+    url: '/mall/quickEntryModule/list',
+    method: 'get',
+    params: query
+  });
+};
+
+/**
+ * 查询快捷入口模块配置详细
+ * @param id
+ */
+export const getQuickEntryModule = (id: string | number): AxiosPromise<QuickEntryModuleVO> => {
+  return request({
+    url: '/mall/quickEntryModule/' + id,
+    method: 'get'
+  });
+};
+
+/**
+ * 新增快捷入口模块配置
+ * @param data
+ */
+export const addQuickEntryModule = (data: QuickEntryModuleForm) => {
+  return request({
+    url: '/mall/quickEntryModule',
+    method: 'post',
+    data: data
+  });
+};
+
+/**
+ * 修改快捷入口模块配置
+ * @param data
+ */
+export const updateQuickEntryModule = (data: QuickEntryModuleForm) => {
+  return request({
+    url: '/mall/quickEntryModule',
+    method: 'put',
+    data: data
+  });
+};
+
+/**
+ * 删除快捷入口模块配置
+ * @param id
+ */
+export const delQuickEntryModule = (id: string | number | Array<string | number>) => {
+  return request({
+    url: '/mall/quickEntryModule/' + id,
+    method: 'delete'
+  });
+};

+ 71 - 0
src/api/enterprisePurchase/quickEntryModule/types.ts

@@ -0,0 +1,71 @@
+export interface QuickEntryModuleVO {
+  /**
+   * 主键ID
+   */
+  id: string | number;
+
+  /**
+   * 模块名称
+   */
+  moduleName: string;
+
+  /**
+   * 模块跳转链接
+   */
+  jumpLink: string;
+
+  /**
+   * 备注
+   */
+  remark: string;
+
+}
+
+export interface QuickEntryModuleForm extends BaseEntity {
+  /**
+   * 主键ID
+   */
+  id?: string | number;
+
+  /**
+   * 模块名称
+   */
+  moduleName?: string;
+
+  /**
+   * 模块跳转链接
+   */
+  jumpLink?: string;
+
+  /**
+   * 备注
+   */
+  remark?: string;
+
+}
+
+export interface QuickEntryModuleQuery extends PageQuery {
+
+  /**
+   * 模块名称
+   */
+  moduleName?: string;
+
+  /**
+   * 模块跳转链接
+   */
+  jumpLink?: string;
+
+  /**
+   * 平台标识
+   */
+  platformCode?: string;
+
+    /**
+     * 日期范围参数
+     */
+    params?: any;
+}
+
+
+

+ 153 - 43
src/views/enterprisePurchase/index.vue

@@ -1472,19 +1472,18 @@ import { listCategoryMain, getCategoryMain, delCategoryMain, addCategoryMain, up
 import { CategoryMainVO, CategoryMainQuery, CategoryMainForm } from '@/api/enterprisePurchase/categoryMain/types';
 import { listScenarioCards, getScenarioCards, delScenarioCards, addScenarioCards, updateScenarioCards } from '@/api/enterprisePurchase/scenarioCards';
 import { ScenarioCardsVO, ScenarioCardsQuery, ScenarioCardsForm } from '@/api/enterprisePurchase/scenarioCards/types';
+import { listScenarioGlobalSettings, addScenarioGlobalSettings, updateScenarioGlobalSettings } from '@/api/enterprisePurchase/scenarioGlobalSettings';
+import { ScenarioGlobalSettingsForm } from '@/api/enterprisePurchase/scenarioGlobalSettings/types';
+import { listQuickEntryModule, addQuickEntryModule, updateQuickEntryModule } from '@/api/enterprisePurchase/quickEntryModule';
+import { QuickEntryModuleVO, QuickEntryModuleQuery, QuickEntryModuleForm } from '@/api/enterprisePurchase/quickEntryModule/types';
 import {
-  listScenarioGlobalSettings,
-  getScenarioGlobalSettings,
-  delScenarioGlobalSettings,
-  addScenarioGlobalSettings,
-  updateScenarioGlobalSettings
-} from '@/api/enterprisePurchase/scenarioGlobalSettings';
-import {
-  ScenarioGlobalSettingsVO,
-  ScenarioGlobalSettingsQuery,
-  ScenarioGlobalSettingsForm
-} from '@/api/enterprisePurchase/scenarioGlobalSettings/types';
-
+  listQuickEntryItems,
+  getQuickEntryItems,
+  delQuickEntryItems,
+  addQuickEntryItems,
+  updateQuickEntryItems
+} from '@/api/enterprisePurchase/quickEntryItems';
+import { QuickEntryItemsVO, QuickEntryItemsQuery, QuickEntryItemsForm } from '@/api/enterprisePurchase/quickEntryItems/types';
 import {
   listHeaderCategory,
   getHeaderCategory,
@@ -1572,6 +1571,8 @@ const handleMainSave = async () => {
       saveLeftAdConfig();
     } else if (activeSubTab.value == 'scenario') {
       saveScenarioGlobalSettings();
+    } else if (activeSubTab.value == 'quick-entry') {
+      saveQuickEntryModule();
     }
   } catch (error) {
     console.error('保存配置失败:', error);
@@ -2879,25 +2880,74 @@ const confirmSelect = () => {
 // 快捷入口模块逻辑
 const qePageIndex = ref(0);
 const quickEntrySettings = reactive({
+  id: null as string | number | null,
   moduleName: '企业工作台',
   jumpLink: ''
 });
 
-const quickEntryList = ref([
-  { id: 1, name: '订单中心', icon: '', tag: '', link: '', status: 1 },
-  { id: 2, name: '发票中心', icon: '', tag: '', link: '', status: 1 },
-  { id: 3, name: '采购清单', icon: '', tag: '', link: '', status: 1 },
-  { id: 4, name: '多地下单', icon: '', tag: '', link: '', status: 1 },
-  { id: 5, name: '达量返', icon: '', tag: '返100', link: '', status: 1 },
-  { id: 6, name: '智能选品', icon: '', tag: '', link: '', status: 1 },
-  { id: 7, name: '电子合同', icon: '', tag: '', link: '', status: 1 },
-  { id: 8, name: '极速认款', icon: '', tag: '', link: '', status: 1 },
-  { id: 9, name: '采购报告', icon: '', tag: '', link: '', status: 1 },
-  { id: 10, name: '对公转账', icon: '', tag: '', link: '', status: 1 },
-  { id: 11, name: '员工饭卡', icon: '', tag: '', link: '', status: 1 },
-  { id: 12, name: '计划购', icon: '', tag: '', link: '', status: 1 },
-  { id: 13, name: '预算管理', icon: '', tag: '', link: '', status: 1 }
-]);
+// 获取快捷入口模块配置
+const getQuickEntryModuleList = async () => {
+  try {
+    const res = await listQuickEntryModule();
+    if (res.code === 200 && res.rows && res.rows.length > 0) {
+      const data = res.rows[0];
+      quickEntrySettings.id = data.id;
+      quickEntrySettings.moduleName = data.moduleName || '';
+      quickEntrySettings.jumpLink = data.jumpLink || '';
+    }
+  } catch (error) {
+    console.error('获取快捷入口模块配置失败:', error);
+    ElMessage.error('获取快捷入口模块配置失败');
+  }
+};
+
+// 保存快捷入口模块配置
+const saveQuickEntryModule = async () => {
+  const data: QuickEntryModuleForm = {
+    moduleName: quickEntrySettings.moduleName,
+    jumpLink: quickEntrySettings.jumpLink
+  };
+
+  try {
+    let res;
+    if (quickEntrySettings.id) {
+      res = await updateQuickEntryModule({ ...data, id: quickEntrySettings.id });
+    } else {
+      res = await addQuickEntryModule(data);
+      if (res.code === 200 && res.data) {
+        quickEntrySettings.id = res.data.id;
+      }
+    }
+    if (res.code === 200) {
+      ElMessage.success('快捷入口模块配置保存成功');
+    } else {
+      ElMessage.error(res.msg || '保存失败');
+    }
+  } catch (error) {
+    console.error('保存快捷入口模块配置失败:', error);
+    ElMessage.error('保存失败');
+  }
+};
+
+const quickEntryList = ref<QuickEntryItemsVO[]>([]);
+
+// 获取快捷入口项列表
+const getQuickEntryItemsList = async () => {
+  try {
+    const res = await listQuickEntryItems();
+    if (res.code === 200 && res.rows) {
+      quickEntryList.value = res.rows.map((item: QuickEntryItemsVO) => ({
+        ...item,
+        icon: (item as any).iconUrl || '',
+        tag: (item as any).tagText || '',
+        link: (item as any).jumpLink || ''
+      }));
+    }
+  } catch (error) {
+    console.error('获取快捷入口项列表失败:', error);
+    ElMessage.error('获取快捷入口项列表失败');
+  }
+};
 
 const qePageCount = computed(() => Math.ceil(quickEntryList.value.filter((i) => i.status === 1).length / 8));
 
@@ -2924,32 +2974,90 @@ const handleEditQuickEntry = (row, index) => {
   quickEntryDialogVisible.value = true;
 };
 
-const submitQuickEntryForm = () => {
+const submitQuickEntryForm = async () => {
   if (!quickEntryForm.name) return ElMessage.warning('请输入入口名称');
-  const data = JSON.parse(JSON.stringify(quickEntryForm));
-  if (quickEntryDialogType.value === 'add') {
-    data.id = Date.now();
-    quickEntryList.value.push(data);
-    ElMessage.success('新增成功');
-  } else {
-    quickEntryList.value[qeEditIndex.value] = data;
-    ElMessage.success('修改成功');
+
+  const data: QuickEntryItemsForm = {
+    name: quickEntryForm.name,
+    iconUrl: quickEntryForm.icon,
+    tagText: quickEntryForm.tag,
+    jumpLink: quickEntryForm.link,
+    status: quickEntryForm.status,
+    sortOrder: quickEntryList.value.length
+  };
+
+  try {
+    if (quickEntryDialogType.value === 'add') {
+      const res = await addQuickEntryItems(data);
+      if (res.code === 200) {
+        ElMessage.success('新增成功');
+        quickEntryDialogVisible.value = false;
+        getQuickEntryItemsList();
+      } else {
+        ElMessage.error(res.msg || '新增失败');
+      }
+    } else {
+      const id = quickEntryList.value[qeEditIndex.value]?.id;
+      const res = await updateQuickEntryItems({ ...data, id });
+      if (res.code === 200) {
+        ElMessage.success('修改成功');
+        quickEntryDialogVisible.value = false;
+        getQuickEntryItemsList();
+      } else {
+        ElMessage.error(res.msg || '修改失败');
+      }
+    }
+  } catch (error) {
+    console.error('操作失败:', error);
+    ElMessage.error('操作失败');
   }
-  quickEntryDialogVisible.value = false;
 };
 
-const handleDeleteQuickEntry = (index) => {
-  ElMessageBox.confirm('确定要删除该入口吗?', '提示', { type: 'warning' }).then(() => {
-    quickEntryList.value.splice(index, 1);
-    ElMessage.success('删除成功');
-  });
+const handleDeleteQuickEntry = async (index: number) => {
+  const item = quickEntryList.value[index];
+  try {
+    await ElMessageBox.confirm('确定要删除该入口吗?', '提示', { type: 'warning' });
+    const res = await delQuickEntryItems(item.id);
+    if (res.code === 200) {
+      ElMessage.success('删除成功');
+      getQuickEntryItemsList();
+    } else {
+      ElMessage.error(res.msg || '删除失败');
+    }
+  } catch (error) {
+    if (error !== 'cancel') {
+      console.error('删除失败:', error);
+      ElMessage.error('删除失败');
+    }
+  }
 };
 
-const moveQE = (index, direction) => {
+const moveQE = async (index: number, direction: number) => {
   const newIndex = index + direction;
   if (newIndex < 0 || newIndex >= quickEntryList.value.length) return;
   const item = quickEntryList.value.splice(index, 1)[0];
   quickEntryList.value.splice(newIndex, 0, item);
+
+  // 同步排序到后端
+  try {
+    const start = Math.min(index, newIndex);
+    const end = Math.max(index, newIndex);
+    for (let i = start; i <= end; i++) {
+      const row = quickEntryList.value[i] as any;
+      await updateQuickEntryItems({
+        id: row.id,
+        name: row.name,
+        iconUrl: row.icon || row.iconUrl,
+        tagText: row.tag || row.tagText,
+        jumpLink: row.link || row.jumpLink,
+        status: row.status,
+        sortOrder: i
+      });
+    }
+  } catch (error) {
+    console.error('排序更新失败:', error);
+    ElMessage.error('排序更新失败');
+  }
 };
 
 watch(
@@ -2970,6 +3078,8 @@ onMounted(() => {
   getCategoryList();
   getScenarioGlobalSettingsList();
   getScenarioList();
+  getQuickEntryModuleList();
+  getQuickEntryItemsList();
   // 获取左侧广告配置
   nextTick(() => {
     updateNavArrows();