Compare commits
No commits in common. "6b073283bf5a3da9d00eadb676bc8cd63862db67" and "68f79903735d7d671df91ae3fb92c238ea1075fe" have entirely different histories.
6b073283bf
...
68f7990373
@ -1,187 +0,0 @@
|
|||||||
# 登录功能 + 页面渲染框架 · 文件清单与移植指南
|
|
||||||
|
|
||||||
> 目的:把本项目的「登录功能」与「后台菜单驱动的页面渲染框架」完整搬到新项目。
|
|
||||||
> 范围约定:**不含** `userPreference.ts`(用户偏好)、`frontBrand.ts`(域名品牌)、语言切换(`LangSelect` + `lang/` 全量词条)。
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 0. 依赖包
|
|
||||||
|
|
||||||
```jsonc
|
|
||||||
{
|
|
||||||
"vue": "^3",
|
|
||||||
"vue-router": "^4",
|
|
||||||
"pinia": "^2",
|
|
||||||
"axios": "^1",
|
|
||||||
"element-plus": "^2",
|
|
||||||
"nprogress": "^0.2", // 路由进度条(permission.ts)
|
|
||||||
"js-cookie": "^3", // token 存 Cookie(utils/auth.ts)
|
|
||||||
"path-browserify": "^1", // 页签路径拼接(TaskView)
|
|
||||||
"@vueuse/core": "^10", // useWindowSize / useFullscreen
|
|
||||||
"dayjs": "^1", // 顶栏有效期天数计算
|
|
||||||
"qrcode": "^1", // 登录页扫码二维码(若不需要扫码登录可去掉)
|
|
||||||
"sass": "^1" // 布局 SCSS
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
`vite.config.ts` 需要 `@` → `src` 别名,`tsconfig` 需同步 `paths`。
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 1. 登录功能
|
|
||||||
|
|
||||||
| # | 文件 | 职责 | 关键点 |
|
|
||||||
|---|---|---|---|
|
|
||||||
| 1 | `src/views/login/index.vue` | 登录页:账号密码登录、注册、微信扫码登录 | 登录成功 → `router.push(redirect \|\| '/')`;扫码成功后 `setToken` + `userStore.$patch({token})` |
|
|
||||||
| 2 | `src/stores/modules/user.ts` | **登录核心 store** | `login / register / getInfo / changeRole / logout / resetToken / updateToken / checkPermission` |
|
|
||||||
| 3 | `src/api/user/user.ts` | 登录相关接口 | `user.login`、`user.loginByCode`、`user.register`、`user.info`、`user.changeRole`、`user.logout`、`user.getLoginWechatCode`(扫码)、`user.getBindWechatCode` / `user.unbindWechat`(绑定) |
|
|
||||||
| 4 | `src/utils/auth.ts` | token 存取(Cookie,key=`token`) | `getToken / setToken / removeToken` |
|
|
||||||
| 5 | `src/utils/request.ts` | axios 封装 | 请求头 `platform/project`、注入 `Authorization: Bearer <token>`、**响应头新 token 自动回写**、`401/50008/50012/50014` → 弹窗重登 |
|
|
||||||
| 6 | `src/permission.ts` | 路由守卫(登录准入 + 动态路由) | 白名单、getToken 判定、`getInfo()` 拉菜单、失败 `resetToken()` |
|
|
||||||
| 7 | `src/router/index.ts` | `/login`、`/redirect` 常量路由 | `/login` 在 `constantRoutes` 且 `meta.hidden` |
|
|
||||||
| 8 | `src/layout/component/Navbar.vue` | 退出登录入口 | `await userStore.logout(); router.push('/login?redirect=' + route.fullPath)` |
|
|
||||||
| 9 | `.env.development` / `.env.staging` / `.env.production` | `VITE_APP_BASE_API`(后端地址) | `request.ts` 的 `baseURL` |
|
|
||||||
| 10 | `src/lang/zh-CN.ts` / `en-US.ts`(若做 i18n) | `login.*` 文案 | 不做 i18n 时改为硬编码中文 |
|
|
||||||
| 11 | `src/views/redirect/index.vue` | `/redirect` 软刷新中转(登出/刷新链路相关) | 见 2.2 |
|
|
||||||
|
|
||||||
### 登录链路
|
|
||||||
|
|
||||||
```mermaid
|
|
||||||
flowchart LR
|
|
||||||
A[访问页面] --> B{permission.ts<br/>getToken?}
|
|
||||||
B -- 无 --> C[/login?redirect=xxx/]
|
|
||||||
C --> D[views/login/index.vue]
|
|
||||||
D --> E[userStore.login]
|
|
||||||
E --> F[api/user: user.login]
|
|
||||||
F --> G[utils/request.ts POST /system]
|
|
||||||
G --> H[auth.ts setToken Cookie]
|
|
||||||
H --> I[router.push redirect]
|
|
||||||
I --> B
|
|
||||||
B -- 有 --> J[userStore.getInfo → user.info]
|
|
||||||
J --> K[permissionStore.generateRoutes menus]
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 2. 页面渲染框架
|
|
||||||
|
|
||||||
> 核心思想:**后端菜单(`user.menus`)→ `transformMenusToRoutes` → `router.addRoute` → Layout 渲染 → Sidebar/TaskView 消费 `permissionStore.routes`**。
|
|
||||||
|
|
||||||
### 2.1 路由层(4 个文件,框架心脏)
|
|
||||||
|
|
||||||
| 文件 | 职责 |
|
|
||||||
|---|---|
|
|
||||||
| `src/router/index.ts` | `constantRoutes`(`/redirect`、`/login`、`/admin/land`、`/`→dashboard、`/workorder`、`/inbox`、`/profile`、`/download`)、`notFoundRoute`、`notFoundPage`、`transformMenusToRoutes()`、`resolveComponent()`、`resolveViewFromGlob()`、`ParentView`、`createRouter` |
|
|
||||||
| `src/router/map.ts` | `componentMap`:**后端菜单 `component` 字段 → 页面组件** 的静态映射表(避免 Vite 动态 import 报错) |
|
|
||||||
| `src/stores/modules/permission.ts` | `routes` / `addRoutes` / `hasAddRoutes`;`generateRoutes(menus)` → 末尾追加 404 |
|
|
||||||
| `src/permission.ts` | `beforeEach`:白名单 → 取用户信息 → `generateRoutes` → 逐条 `router.addRoute` → `return { ...to, replace: true }` 重进;`afterEach` `NProgress.done()` |
|
|
||||||
|
|
||||||
### 2.2 布局层(Layout / 顶栏 / 页签)
|
|
||||||
|
|
||||||
| 文件 | 职责 |
|
|
||||||
|---|---|
|
|
||||||
| `src/layout/index.vue` | 外壳:`sidebar`(非 top-bottom 模式)+ `fixed-header`(`task-view`)+ `main-box`(`app-main`);响应式 992px 切 `device=mobile` |
|
|
||||||
| `src/layout/component/AppMain.vue` | **页面渲染出口**:`router-view` + `transition` + `keep-alive`;`wrapRouteComponent()` 把路由组件包装成 `name = route.name` 以让 `include` 生效;`:key="route.name ?? route.path"` |
|
|
||||||
| `src/layout/component/TaskView/index.vue` | **顶部容器**:`<navbar>` + 快捷键区 + **页签(tags-view)**;`watch(route)` → `tagsViewStore.addView(route)`;右键菜单刷新/关闭/关闭其他/全部关闭 |
|
|
||||||
| `src/layout/component/TaskView/ScrollPane.vue` | 页签横向滚动容器(横向滚轮) |
|
|
||||||
| `src/layout/component/Navbar.vue` | **顶部导航栏**:Logo、Breadcrumb(sidebar 模式)、TopMenu(top-bottom 模式)、右侧 有效期/全屏/工单角标/语言/AI、**头像下拉(切换角色 + 个人中心 + 退出登录)** |
|
|
||||||
| `src/layout/component/TopMenu.vue` | 顶部横向菜单(`layoutMode === 'top-bottom'` 时使用) |
|
|
||||||
| `src/layout/component/Sidebar/index.vue` | 左侧菜单容器(`el-menu` + `SidebarItem`) |
|
|
||||||
| `src/layout/component/Sidebar/SidebarItem.vue` | 递归菜单项(唯一子项拍平逻辑) |
|
|
||||||
| `src/layout/component/Sidebar/Item.vue` / `SubItem.vue` / `Link.vue` | 菜单项渲染 / 子项模板 / 内外链跳转 |
|
|
||||||
| `src/components/Breadcrumb/index.vue` | 面包屑(依赖 `permissionStore.routes` + `route.matched`) |
|
|
||||||
| `src/components/SvgIcon/index.vue` | 图标组件(`svg-icon` 全局注册;依赖 `vite-plugin-svg-icons` 的 `virtual:svg-icons-register`) |
|
|
||||||
| `src/views/redirect/index.vue` | `/redirect/:path(.*)` 中转页(页签"刷新"软刷新) |
|
|
||||||
| `src/views/404.vue` | 兜底页(动态路由找不到组件时也指向它) |
|
|
||||||
|
|
||||||
### 2.3 状态层(Pinia)
|
|
||||||
|
|
||||||
| 文件 | 职责 | 是否必需 |
|
|
||||||
|---|---|---|
|
|
||||||
| `src/stores/modules/permission.ts` | 动态路由表 | ✅ 必需 |
|
|
||||||
| `src/stores/modules/app.ts` | `sidebar{opened,withoutAnimation}`、`device`、`toggleDevice/toggleSideBar/closeSideBar` | ✅ 必需 |
|
|
||||||
| `src/stores/modules/settings.ts` | `fixedHeader`、`layoutMode('sidebar'\|'top-bottom')`、`shortcutExpanded`(`changeSetting`) | ✅ 必需 |
|
|
||||||
| `src/stores/modules/tagsView.ts` | `visitedViews` / `cachedViews` + `add/del/update` | ✅ 必需(页签 + keep-alive) |
|
|
||||||
| `src/stores/modules/shortcuts.ts` | 快捷键区数据 | ⚠️ 可选(TaskView 引用,可删) |
|
|
||||||
| `src/stores/modules/experimental.ts` | `pageCacheEnabled` / `pageCacheMax` | ⚠️ 可选(AppMain 引用,可给默认值) |
|
|
||||||
| `src/stores/modules/user.ts` | 登录态 | ✅ 必需(见第 1 节) |
|
|
||||||
|
|
||||||
### 2.4 样式层
|
|
||||||
|
|
||||||
`src/styles/index.scss`、`variables.scss`、`variables.module.scss`(Sidebar 用 JS 取色)、`mixin.scss`(`clearfix` 等)、`sidebar.scss`、`transition.scss`(`fade-transform` 过渡)、`element-ui.scss`。
|
|
||||||
|
|
||||||
### 2.5 入口与配置
|
|
||||||
|
|
||||||
| 文件 | 职责 |
|
|
||||||
|---|---|
|
|
||||||
| `src/main.ts` | `createApp` → `pinia` → `router` → `ElementPlus`;`import './permission'`;注册全局 `svg-icon`;`app.mount('#app')`;`document.title` 统一设置 |
|
|
||||||
| `src/App.vue` | `el-config-provider`(Element 语言)+ `<router-view />` |
|
|
||||||
| `src/settings.ts` | `title`、`fixedHeader`、`sidebarLogo`、`shortcutExpanded`、`toolbarMode` 等默认值 |
|
|
||||||
| `src/utils/get-page-title.ts` | 页面标题拼接 |
|
|
||||||
| `src/utils/validate.js` | `isExternal`(Sidebar/TaskView/SvgIcon 依赖) |
|
|
||||||
| `.env.*` | `VITE_APP_BASE_API` 等 |
|
|
||||||
| `index.html` | `#app` 挂载点 + favicon |
|
|
||||||
| `vite.config.ts` | `@` alias、`vite-plugin-svg-icons` |
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 3. 渲染调用链
|
|
||||||
|
|
||||||
```mermaid
|
|
||||||
flowchart TD
|
|
||||||
A["后端 user.info → user.menus"] --> B["stores/permission.ts generateRoutes(menus)"]
|
|
||||||
B --> C["router/index.ts transformMenusToRoutes()"]
|
|
||||||
C --> D{"menu.component 是什么?"}
|
|
||||||
D -- "Layout" --> E["Layout (layout/index.vue)"]
|
|
||||||
D -- "字符串" --> F["componentMap (router/map.ts)"]
|
|
||||||
F --> G["命中 → 直接返回 lazy loader"]
|
|
||||||
F --> H["未命中 → import.meta.glob('@/views/**/*.vue') 兜底"]
|
|
||||||
H --> I["再未命中 → views/404.vue"]
|
|
||||||
C --> J["permission.ts: router.addRoute(route)"]
|
|
||||||
J --> K["Layout 渲染"]
|
|
||||||
K --> L["Sidebar / TopMenu ← permissionStore.routes"]
|
|
||||||
K --> M["TaskView 页签 ← route 变化 addView"]
|
|
||||||
K --> N["AppMain router-view + keep-alive ← tagsView.cachedViews"]
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 4. 照搬不能改的契约(最容易踩坑)
|
|
||||||
|
|
||||||
1. **`componentMap` 的 key 必须与后端菜单 `component` 字段一致**(如 `order/waveOrder`、`system/setting/role/index`);不一致时靠 `import.meta.glob` 兜底,再不一致落到 404。
|
|
||||||
2. **禁止多段路径的模板字符串动态 import**:Vite 生产构建会报 `unknown variable dynamic import`。只能用 `componentMap` 或 `import.meta.glob`。单段路径(如 `warehouse`)才允许 `import(\`@/views/${p}/index.vue\`)`。
|
|
||||||
3. **keep-alive 的 `include` 用「路由 name」**,但 `<script setup>` 页面组件无 `name` → 必须用 `AppMain.vue` 的 `wrapRouteComponent()` 包装成同名组件,否则缓存完全失效。
|
|
||||||
4. **keep-alive 必须常驻**(不能放 `v-if` 里),访问 `/login`、`/404` 等 Layout 外页面会卸载 Layout 并清空缓存,这是正常的。
|
|
||||||
5. **路由 name 冲突**:子路由 name 与父路由相同 → `transformMenusToRoutes` 自动改名为 `${name}_Child`,不要依赖原始 name 做缓存 key 匹配。
|
|
||||||
6. **顶层路由 path 必须以 `/` 开头**(Vue Router 4 要求,代码已自动补)。
|
|
||||||
7. **`notFoundPage` / `notFoundRoute` 必须最后追加**,否则会抢先匹配动态路由。
|
|
||||||
8. `generateRoutes` 后必须 `return { ...to, replace: true }` 让导航重跑一次,否则首次进入白屏。
|
|
||||||
9. **`permission.ts` 判定登录态用 `userStore.user.employees_name`**(不是只用 token),配合 `getToken()`。
|
|
||||||
10. **token 双写**:Cookie(`utils/auth.ts`)+ Pinia(`user.ts`);`request.ts` 收到响应头 `Authorization`/`new-authorization` 会回写两者(续期场景)。
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 5. 移植步骤建议
|
|
||||||
|
|
||||||
1. **初始化**:装依赖 §0,配 `vite.config.ts` 的 `@` 别名 + `vite-plugin-svg-icons`(指向 `src/icons/svg`),`tsconfig` 配 `paths`。
|
|
||||||
2. **拷贝样式**:`src/styles/*` + `src/icons/` + `src/components/SvgIcon/`。
|
|
||||||
3. **拷贝工具**:`utils/auth.ts`、`utils/request.ts`、`utils/validate.js`、`utils/get-page-title.ts`、`settings.ts`、`App.vue`。
|
|
||||||
4. **拷贝状态**:`stores/modules/{app,settings,tagsView,permission,user}.ts`(`app.ts` 里的 `device` 需保留,登录接口要传)。
|
|
||||||
5. **拷贝路由**:`router/{index,map}.ts`(**删掉业务页面路由,只留 `/redirect`、`/login`、`/404`、dashboard 占位**;`map.ts` 按新项目页面重写)。
|
|
||||||
6. **拷贝布局**:`layout/**` + `components/Breadcrumb/`。
|
|
||||||
7. **拷贝登录**:`views/login/index.vue` + `api/user/user.ts`。
|
|
||||||
8. **接守卫**:`main.ts` 里 `import './permission'`。
|
|
||||||
9. **改常量**:`.env` 的 `VITE_APP_BASE_API`、`settings.ts` 的 `title`。
|
|
||||||
10. **验证顺序**:未登录访问任意页 → 跳 `/login`;登录后 `user.info` 拿到 `menus` → 侧边栏出现菜单;点菜单能渲染;开页签;切页签不白屏不重复请求(缓存生效);点退出回登录页。
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 6. 本次明确排除(新项目按需自行决定)
|
|
||||||
|
|
||||||
| 项目 | 关联文件 | 排除后的副作用 |
|
|
||||||
|---|---|---|
|
|
||||||
| 用户偏好 | `stores/modules/userPreference.ts` | 删掉 `permission.ts` 里 `prefs.load()` 三处调用 |
|
|
||||||
| 域名品牌 | `stores/modules/frontBrand.ts`、`api/frontconfig/` | 删掉 `main.ts` 的 `loadBrandByDomain()`、`Login` 页品牌 computed、`Navbar` 的 `mainLogo` 改用固定图 |
|
|
||||||
| 语言切换 | `components/LangSelect/`、`lang/`、`vue-i18n`、`App.vue` 的 `el-config-provider` | ⚠️ **注意**:布局里 `tMenu()` 与 `$t()` 大量出现(`Navbar`、`TaskView`、`Sidebar/Item|SubItem`、`Breadcrumb`、`main.ts`),排除 i18n 后这些调用点要改成纯文本 |
|
|
||||||
| 打印组件 / AI / 工单角标 | `stores/modules/printerComponent.ts`、`layout/component/AiChat/`、`Navbar` 的 `afterSaleWorkCount` | `permission.ts` 的 `ensurePrinterConnectionsAfterLogin()`、`user.ts` 的 `usePrinterComponentStore()` 需一并删除 |
|
|
||||||
| 快捷键 | `stores/modules/shortcuts.ts` | 删 `TaskView` 里的快捷键区块 |
|
|
||||||
@ -2,9 +2,7 @@
|
|||||||
更多设置表单
|
更多设置表单
|
||||||
- 由 UpperTable「字段设置」中的「更多设置」按钮打开
|
- 由 UpperTable「字段设置」中的「更多设置」按钮打开
|
||||||
- 表格工作模式(原字段设置工具栏内嵌的 radio,迁移至此)
|
- 表格工作模式(原字段设置工具栏内嵌的 radio,迁移至此)
|
||||||
- 界面显示(浏览器 localStorage 持久化选项:Scan-box 模式 / 工具栏按钮模式 / 快捷键区域 / 页面布局)
|
|
||||||
- 页面缓存 / tab 缓存分类(开关 / 最大缓存数量 / 应用范围)
|
- 页面缓存 / tab 缓存分类(开关 / 最大缓存数量 / 应用范围)
|
||||||
- 存储:experimental_{userId}_{roleId}(experimental store)、settings_{userId}_{roleId}(settings store)
|
|
||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
<el-dialog
|
<el-dialog
|
||||||
@ -29,49 +27,6 @@
|
|||||||
|
|
||||||
<el-divider />
|
<el-divider />
|
||||||
|
|
||||||
<!-- ===== 界面显示(浏览器持久化选项) ===== -->
|
|
||||||
<div class="more-section">
|
|
||||||
<div class="more-section-title">界面显示</div>
|
|
||||||
<div class="more-section-desc">
|
|
||||||
以下选项保存在当前浏览器(按账号 + 角色隔离),仅影响本机显示,换电脑需重新设置。
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="more-setting-row">
|
|
||||||
<span class="setting-label">Scan-box 显示模式</span>
|
|
||||||
<el-radio-group v-model="scanBoxMode" size="small">
|
|
||||||
<el-radio-button value="compact">紧凑(默认)</el-radio-button>
|
|
||||||
<el-radio-button value="standard">标准</el-radio-button>
|
|
||||||
</el-radio-group>
|
|
||||||
<span class="setting-hint">紧凑模式行高更小,一屏显示更多筛选条件</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="more-setting-row">
|
|
||||||
<span class="setting-label">工具栏按钮模式</span>
|
|
||||||
<el-radio-group v-model="toolbarMode" size="small">
|
|
||||||
<el-radio-button value="tile">平铺(默认)</el-radio-button>
|
|
||||||
<el-radio-button value="collapse">折叠</el-radio-button>
|
|
||||||
</el-radio-group>
|
|
||||||
<span class="setting-hint">订单工具栏按钮组的排列方式</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="more-setting-row">
|
|
||||||
<span class="setting-label">快捷键区域</span>
|
|
||||||
<el-switch v-model="shortcutExpanded" />
|
|
||||||
<span class="setting-hint">展开顶部快捷键面板(默认收起)</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="more-setting-row">
|
|
||||||
<span class="setting-label">页面布局</span>
|
|
||||||
<el-radio-group v-model="layoutMode" size="small">
|
|
||||||
<el-radio-button value="top-bottom">顶部导航</el-radio-button>
|
|
||||||
<el-radio-button value="sidebar">侧边导航</el-radio-button>
|
|
||||||
</el-radio-group>
|
|
||||||
<span class="setting-hint">顶部导航 = 菜单在顶部横向排列</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<el-divider />
|
|
||||||
|
|
||||||
<!-- ===== 页面缓存分类 ===== -->
|
<!-- ===== 页面缓存分类 ===== -->
|
||||||
<div class="more-section">
|
<div class="more-section">
|
||||||
<div class="more-section-title">页面缓存</div>
|
<div class="more-section-title">页面缓存</div>
|
||||||
@ -147,7 +102,6 @@
|
|||||||
import { computed } from 'vue'
|
import { computed } from 'vue'
|
||||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
import { useExperimentalStore } from '@/stores/modules/experimental'
|
import { useExperimentalStore } from '@/stores/modules/experimental'
|
||||||
import { useSettingsStore } from '@/stores/modules/settings'
|
|
||||||
|
|
||||||
const visible = defineModel<boolean>('visible', { default: false })
|
const visible = defineModel<boolean>('visible', { default: false })
|
||||||
|
|
||||||
@ -159,7 +113,6 @@ const dialogVisible = computed({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const experimentalStore = useExperimentalStore()
|
const experimentalStore = useExperimentalStore()
|
||||||
const settingsStore = useSettingsStore()
|
|
||||||
|
|
||||||
const tableMode = computed({
|
const tableMode = computed({
|
||||||
get: () => experimentalStore.tableMode,
|
get: () => experimentalStore.tableMode,
|
||||||
@ -168,40 +121,6 @@ const tableMode = computed({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
/* ===== 界面显示(浏览器持久化:settings store → localStorage settings_{userId}_{roleId}) ===== */
|
|
||||||
|
|
||||||
/** Scan-box 显示模式:standard=标准 / compact=紧凑 */
|
|
||||||
const scanBoxMode = computed({
|
|
||||||
get: () => settingsStore.scanBoxMode,
|
|
||||||
set: (mode: 'standard' | 'compact') => {
|
|
||||||
settingsStore.changeSetting({ key: 'scanBoxMode', value: mode })
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
/** 工具栏按钮组显示模式:tile=平铺 / collapse=折叠 */
|
|
||||||
const toolbarMode = computed({
|
|
||||||
get: () => settingsStore.toolbarMode,
|
|
||||||
set: (mode: 'tile' | 'collapse') => {
|
|
||||||
settingsStore.changeSetting({ key: 'toolbarMode', value: mode })
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
/** 顶部快捷键区域是否展开 */
|
|
||||||
const shortcutExpanded = computed({
|
|
||||||
get: () => settingsStore.shortcutExpanded,
|
|
||||||
set: (expanded: boolean) => {
|
|
||||||
settingsStore.changeSetting({ key: 'shortcutExpanded', value: expanded })
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
/** 页面布局:top-bottom=顶部导航 / sidebar=侧边导航 */
|
|
||||||
const layoutMode = computed({
|
|
||||||
get: () => settingsStore.layoutMode,
|
|
||||||
set: (mode: 'sidebar' | 'top-bottom') => {
|
|
||||||
settingsStore.changeSetting({ key: 'layoutMode', value: mode })
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const tabCacheEnabled = computed({
|
const tabCacheEnabled = computed({
|
||||||
get: () => experimentalStore.tabCacheEnabled,
|
get: () => experimentalStore.tabCacheEnabled,
|
||||||
set: (val: boolean) => {
|
set: (val: boolean) => {
|
||||||
@ -250,20 +169,15 @@ function handlePageCacheMaxChange(val: number | undefined) {
|
|||||||
experimentalStore.setPageCacheMax(Number(val ?? 1))
|
experimentalStore.setPageCacheMax(Number(val ?? 1))
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 恢复全部设置为默认配置(表格工作模式 / 界面显示 / 页面缓存 / tab 缓存) */
|
/** 恢复全部设置为默认配置(表格工作模式 / 页面缓存 / tab 缓存) */
|
||||||
function handleResetDefaults() {
|
function handleResetDefaults() {
|
||||||
ElMessageBox.confirm(
|
ElMessageBox.confirm('确定恢复全部设置为默认配置吗?', '恢复默认', {
|
||||||
'确定恢复全部设置为默认配置吗?表格工作模式、界面显示(Scan-box 模式 / 工具栏按钮模式 / 快捷键区域 / 页面布局)、页面缓存、tab 缓存都将恢复默认。',
|
type: 'warning',
|
||||||
'恢复默认',
|
confirmButtonText: '恢复',
|
||||||
{
|
cancelButtonText: '取消'
|
||||||
type: 'warning',
|
})
|
||||||
confirmButtonText: '恢复',
|
|
||||||
cancelButtonText: '取消'
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.then(() => {
|
.then(() => {
|
||||||
experimentalStore.resetToDefaults()
|
experimentalStore.resetToDefaults()
|
||||||
settingsStore.resetDisplaySettings()
|
|
||||||
ElMessage.success('已恢复默认配置')
|
ElMessage.success('已恢复默认配置')
|
||||||
})
|
})
|
||||||
.catch(() => {})
|
.catch(() => {})
|
||||||
|
|||||||
@ -34,14 +34,12 @@ export default {
|
|||||||
/**
|
/**
|
||||||
* @type {'tile' | 'collapse'}
|
* @type {'tile' | 'collapse'}
|
||||||
* @description Toolbar button display mode: tile (平铺) or collapse (折叠)
|
* @description Toolbar button display mode: tile (平铺) or collapse (折叠)
|
||||||
* 默认:tile(平铺)
|
|
||||||
*/
|
*/
|
||||||
toolbarMode: 'tile',
|
toolbarMode: 'tile',
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {'standard' | 'compact'}
|
* @type {'standard' | 'compact'}
|
||||||
* @description ScanBox display mode: standard (标准) or compact (紧凑)
|
* @description ScanBox display mode: standard (标准) or compact (紧凑)
|
||||||
* 默认:compact(紧凑);可在「字段设置 → 更多设置 → 界面显示」中修改
|
|
||||||
*/
|
*/
|
||||||
scanBoxMode: 'compact'
|
scanBoxMode: 'standard'
|
||||||
}
|
}
|
||||||
|
|||||||
@ -129,18 +129,6 @@ export const useSettingsStore = defineStore('settings', () => {
|
|||||||
saveSettings()
|
saveSettings()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 恢复「界面显示」类浏览器持久化设置为默认值并写回 localStorage
|
|
||||||
* 覆盖:Scan-box 显示模式 / 工具栏按钮模式 / 快捷键区域 / 页面布局
|
|
||||||
*/
|
|
||||||
const resetDisplaySettings = () => {
|
|
||||||
scanBoxModeRef.value = (defaultScanBoxMode as 'standard' | 'compact') || 'standard'
|
|
||||||
toolbarModeRef.value = (defaultToolbarMode as 'tile' | 'collapse') || 'tile'
|
|
||||||
shortcutExpandedRef.value = shortcutExpanded
|
|
||||||
layoutMode.value = 'top-bottom'
|
|
||||||
saveSettings()
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
theme,
|
theme,
|
||||||
showSettings: showSettingsRef,
|
showSettings: showSettingsRef,
|
||||||
@ -151,7 +139,6 @@ export const useSettingsStore = defineStore('settings', () => {
|
|||||||
shortcutExpanded: shortcutExpandedRef,
|
shortcutExpanded: shortcutExpandedRef,
|
||||||
toolbarMode: toolbarModeRef,
|
toolbarMode: toolbarModeRef,
|
||||||
scanBoxMode: scanBoxModeRef,
|
scanBoxMode: scanBoxModeRef,
|
||||||
changeSetting,
|
changeSetting
|
||||||
resetDisplaySettings
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@ -19,52 +19,7 @@
|
|||||||
<div class="app-error" v-if="pdaError">获取版本信息失败</div>
|
<div class="app-error" v-if="pdaError">获取版本信息失败</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="app-action">
|
<div class="app-action">
|
||||||
<el-button type="primary" size="small" :disabled="!pdaData?.downloadUrl" @click="showQrCode('扫描二维码下载 PDA', pdaData?.downloadUrl)">
|
<el-button type="primary" size="small" :disabled="!pdaData?.downloadUrl" @click="showQrCode">
|
||||||
下载
|
|
||||||
</el-button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<el-divider border-style="dashed" />
|
|
||||||
|
|
||||||
<!-- Android Worker Station(安卓工作台) -->
|
|
||||||
<div class="app-item" v-loading="loadingAndroid">
|
|
||||||
<div class="app-icon">
|
|
||||||
<el-icon :size="40" color="#e6a23c"><Iphone /></el-icon>
|
|
||||||
</div>
|
|
||||||
<div class="app-info">
|
|
||||||
<div class="app-name">安卓工作台 (Android)</div>
|
|
||||||
<div class="app-version" v-if="androidData">V {{ androidData.version }}</div>
|
|
||||||
<div class="app-date" v-if="androidData">{{ formatDate(androidData.publishedAtUtc) }}</div>
|
|
||||||
<div class="app-error" v-if="androidError">获取版本信息失败</div>
|
|
||||||
</div>
|
|
||||||
<div class="app-action">
|
|
||||||
<el-button
|
|
||||||
type="warning"
|
|
||||||
size="small"
|
|
||||||
:disabled="!androidData?.url"
|
|
||||||
@click="showQrCode('扫描二维码下载 安卓工作台', androidData?.url)"
|
|
||||||
>
|
|
||||||
下载
|
|
||||||
</el-button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<el-divider border-style="dashed" />
|
|
||||||
|
|
||||||
<!-- Windows Worker Station(Windows工作台) -->
|
|
||||||
<div class="app-item" v-loading="loadingWindows">
|
|
||||||
<div class="app-icon">
|
|
||||||
<el-icon :size="40" color="#e6a23c"><Monitor /></el-icon>
|
|
||||||
</div>
|
|
||||||
<div class="app-info">
|
|
||||||
<div class="app-name">Windows工作台</div>
|
|
||||||
<div class="app-version" v-if="windowsData">V {{ windowsData.version }}</div>
|
|
||||||
<div class="app-date" v-if="windowsData">{{ formatDate(windowsData.publishedAtUtc) }}</div>
|
|
||||||
<div class="app-error" v-if="windowsError">获取版本信息失败</div>
|
|
||||||
</div>
|
|
||||||
<div class="app-action">
|
|
||||||
<el-button type="warning" size="small" :disabled="!windowsData?.url" @click="download(windowsData?.url)">
|
|
||||||
下载
|
下载
|
||||||
</el-button>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
@ -91,17 +46,17 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 二维码下载弹窗(PDA / 安卓工作台共用) -->
|
<!-- 二维码下载弹窗 -->
|
||||||
<el-dialog
|
<el-dialog
|
||||||
v-model="qrCodeVisible"
|
v-model="qrCodeVisible"
|
||||||
:title="qrDialogTitle"
|
title="扫描二维码下载 PDA"
|
||||||
width="300px"
|
width="300px"
|
||||||
align-center
|
align-center
|
||||||
>
|
>
|
||||||
<div class="qrcode-container">
|
<div class="qrcode-container">
|
||||||
<canvas ref="qrCanvas"></canvas>
|
<canvas ref="qrCanvas"></canvas>
|
||||||
<div class="qrcode-tip">请使用手机或平板扫描</div>
|
<div class="qrcode-tip">请使用 PDA 或手机扫描</div>
|
||||||
<div class="qrcode-link" @click="download(qrTargetUrl)">
|
<div class="qrcode-link" v-if="pdaData" @click="download(pdaData.downloadUrl)">
|
||||||
无法扫描?点击直接下载
|
无法扫描?点击直接下载
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -111,7 +66,7 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onMounted, nextTick } from 'vue'
|
import { ref, onMounted, nextTick } from 'vue'
|
||||||
import { Cellphone, Monitor, Iphone } from '@element-plus/icons-vue'
|
import { Cellphone, Monitor } from '@element-plus/icons-vue'
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import QRCode from 'qrcode'
|
import QRCode from 'qrcode'
|
||||||
@ -132,41 +87,15 @@ interface PrintServerVersionInfo {
|
|||||||
publishedAtUtc: string
|
publishedAtUtc: string
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 工作台(散单工作台)版本信息
|
|
||||||
* 与 `worker_station`(安卓 APK)/ `worker_station_windows`(Windows EXE)的 latest.json 字段一致
|
|
||||||
*/
|
|
||||||
interface WorkerStationVersionInfo {
|
|
||||||
version: string
|
|
||||||
file: string
|
|
||||||
url: string
|
|
||||||
sha256?: string
|
|
||||||
publishedAtUtc: string
|
|
||||||
/**
|
|
||||||
* 是否允许跳过该版本:**0 或缺省 = 不可跳过(强制更新)**,1 = 可跳过。
|
|
||||||
* 注:该字段由工作台客户端自身的自更新流程使用,网页端仅作下载入口,不做拦截。
|
|
||||||
*/
|
|
||||||
canSkip?: number
|
|
||||||
}
|
|
||||||
|
|
||||||
const pdaData = ref<PdaVersionInfo | null>(null)
|
const pdaData = ref<PdaVersionInfo | null>(null)
|
||||||
const printData = ref<PrintServerVersionInfo | null>(null)
|
const printData = ref<PrintServerVersionInfo | null>(null)
|
||||||
const androidData = ref<WorkerStationVersionInfo | null>(null)
|
|
||||||
const windowsData = ref<WorkerStationVersionInfo | null>(null)
|
|
||||||
|
|
||||||
const loadingPda = ref(true)
|
const loadingPda = ref(true)
|
||||||
const loadingPrint = ref(true)
|
const loadingPrint = ref(true)
|
||||||
const loadingAndroid = ref(true)
|
|
||||||
const loadingWindows = ref(true)
|
|
||||||
const pdaError = ref(false)
|
const pdaError = ref(false)
|
||||||
const printError = ref(false)
|
const printError = ref(false)
|
||||||
const androidError = ref(false)
|
|
||||||
const windowsError = ref(false)
|
|
||||||
|
|
||||||
const qrCodeVisible = ref(false)
|
const qrCodeVisible = ref(false)
|
||||||
/** 二维码弹窗标题 / 目标地址(PDA、安卓工作台共用) */
|
|
||||||
const qrDialogTitle = ref('扫描二维码下载')
|
|
||||||
const qrTargetUrl = ref('')
|
|
||||||
const qrCanvas = ref<HTMLCanvasElement | null>(null)
|
const qrCanvas = ref<HTMLCanvasElement | null>(null)
|
||||||
|
|
||||||
const formatDate = (dateString: string) => {
|
const formatDate = (dateString: string) => {
|
||||||
@ -174,14 +103,12 @@ const formatDate = (dateString: string) => {
|
|||||||
return dayjs(dateString).format('YYYY-MM-DD HH:mm')
|
return dayjs(dateString).format('YYYY-MM-DD HH:mm')
|
||||||
}
|
}
|
||||||
|
|
||||||
const showQrCode = async (title: string, url?: string) => {
|
const showQrCode = async () => {
|
||||||
if (!url) return
|
if (!pdaData.value?.downloadUrl) return
|
||||||
qrDialogTitle.value = title
|
|
||||||
qrTargetUrl.value = url
|
|
||||||
qrCodeVisible.value = true
|
qrCodeVisible.value = true
|
||||||
await nextTick()
|
await nextTick()
|
||||||
if (qrCanvas.value) {
|
if (qrCanvas.value) {
|
||||||
QRCode.toCanvas(qrCanvas.value, url, {
|
QRCode.toCanvas(qrCanvas.value, pdaData.value.downloadUrl, {
|
||||||
width: 200,
|
width: 200,
|
||||||
margin: 2,
|
margin: 2,
|
||||||
color: {
|
color: {
|
||||||
@ -230,44 +157,6 @@ const fetchPrintServerInfo = async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 安卓工作台(散单工作台 APK)版本信息 */
|
|
||||||
const fetchAndroidInfo = async () => {
|
|
||||||
try {
|
|
||||||
loadingAndroid.value = true
|
|
||||||
androidError.value = false
|
|
||||||
const response = await axios.get('https://dl.wms.gztbyc.com/worker_station/latest.json', {
|
|
||||||
params: { timestamp: new Date().getTime() }
|
|
||||||
})
|
|
||||||
if (response.data) {
|
|
||||||
androidData.value = response.data
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Failed to fetch Android worker station version info', error)
|
|
||||||
androidError.value = true
|
|
||||||
} finally {
|
|
||||||
loadingAndroid.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Windows 工作台(散单工作台 EXE)版本信息 */
|
|
||||||
const fetchWindowsInfo = async () => {
|
|
||||||
try {
|
|
||||||
loadingWindows.value = true
|
|
||||||
windowsError.value = false
|
|
||||||
const response = await axios.get('https://dl.wms.gztbyc.com/worker_station_windows/latest.json', {
|
|
||||||
params: { timestamp: new Date().getTime() }
|
|
||||||
})
|
|
||||||
if (response.data) {
|
|
||||||
windowsData.value = response.data
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Failed to fetch Windows worker station version info', error)
|
|
||||||
windowsError.value = true
|
|
||||||
} finally {
|
|
||||||
loadingWindows.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const download = (url?: string) => {
|
const download = (url?: string) => {
|
||||||
if (url) {
|
if (url) {
|
||||||
window.open(url, '_blank')
|
window.open(url, '_blank')
|
||||||
@ -277,8 +166,6 @@ const download = (url?: string) => {
|
|||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
fetchPdaInfo()
|
fetchPdaInfo()
|
||||||
fetchPrintServerInfo()
|
fetchPrintServerInfo()
|
||||||
fetchAndroidInfo()
|
|
||||||
fetchWindowsInfo()
|
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
import type { ComboGoodsListItem } from '@/api/combogoods/combogoods'
|
import type { ComboGoodsListItem } from '@/api/combogoods/combogoods'
|
||||||
import type { ToolbarButtonConfig } from '@/views/order/orderManagement/config/order-common-config'
|
|
||||||
|
|
||||||
export type ComboGoodsRecord = ComboGoodsListItem & {
|
export type ComboGoodsRecord = ComboGoodsListItem & {
|
||||||
created_at?: string
|
created_at?: string
|
||||||
@ -73,18 +72,6 @@ export const comboGoodsColumns = [
|
|||||||
{ prop: 'actions', label: '操作', width: '150', fixed: 'right' }
|
{ prop: 'actions', label: '操作', width: '150', fixed: 'right' }
|
||||||
]
|
]
|
||||||
|
|
||||||
/**
|
|
||||||
* 组合商品列表主工具栏按钮
|
|
||||||
* 样式 / 顺序对齐「商品明细」(stock/stock 的 stockToolbarButtons):
|
|
||||||
* 刷新(primary)→ 字段设置(default)→ 新增组合商品(primary)→ 快速搜索(primary + plain)
|
|
||||||
*/
|
|
||||||
export const comboGoodsToolbarButtons: ToolbarButtonConfig[] = [
|
|
||||||
{ key: 'refresh', label: '刷新', type: 'primary', size: 'small', loadingKey: 'loading', action: 'loadList' },
|
|
||||||
{ key: 'columnConfig', label: '字段设置', size: 'small', action: 'openColumnConfigPanel' },
|
|
||||||
{ key: 'create', label: '新增组合商品', type: 'primary', size: 'small', action: 'openCreate' },
|
|
||||||
{ key: 'quickSearch', label: '快速搜索', type: 'primary', plain: true, size: 'small', action: 'openSearchDialog' }
|
|
||||||
]
|
|
||||||
|
|
||||||
export const comboGoodsScanFields = [
|
export const comboGoodsScanFields = [
|
||||||
// ===== 组合信息 =====
|
// ===== 组合信息 =====
|
||||||
{
|
{
|
||||||
|
|||||||
@ -17,17 +17,12 @@
|
|||||||
<div class="main-content">
|
<div class="main-content">
|
||||||
<div class="toolbar">
|
<div class="toolbar">
|
||||||
<div class="toolbar-left">
|
<div class="toolbar-left">
|
||||||
<order-toolbar-button-group
|
<el-button size="small" type="primary" :loading="loading" @click="loadList">刷新</el-button>
|
||||||
:buttons="toolbarButtons"
|
<el-button type="success" size="small" @click="openCreate">新增组合商品</el-button>
|
||||||
:resolve-disabled="resolveButtonDisabled"
|
<el-button size="small" type="primary" plain @click="searchDialogVisible = true">快速搜索</el-button>
|
||||||
:resolve-loading="resolveButtonLoading"
|
|
||||||
:resolve-label="resolveButtonLabel"
|
|
||||||
:layout-key="toolbarLayoutKey"
|
|
||||||
@action="handleToolbarButtonClick"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="toolbar-right">
|
<div class="toolbar-right">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -36,7 +31,6 @@
|
|||||||
ref="upperTable"
|
ref="upperTable"
|
||||||
title="组合商品列表"
|
title="组合商品列表"
|
||||||
default-align="center"
|
default-align="center"
|
||||||
:enable-column-config="true"
|
|
||||||
table-id="stock-combo-goods"
|
table-id="stock-combo-goods"
|
||||||
:data="tableData"
|
:data="tableData"
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
@ -97,12 +91,10 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, onMounted, reactive, ref } from 'vue'
|
import { onMounted, reactive, ref } from 'vue'
|
||||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
import ScanBox from '@/components/ScanBox/index.vue'
|
import ScanBox from '@/components/ScanBox/index.vue'
|
||||||
import UpperTable from '@/components/UpperTable/index.vue'
|
import UpperTable from '@/components/UpperTable/index.vue'
|
||||||
import OrderToolbarButtonGroup from '@/views/order/orderManagement/component/OrderToolbarButtonGroup.vue'
|
|
||||||
import type { ToolbarButtonConfig } from '@/views/order/orderManagement/config/order-common-config'
|
|
||||||
import { comboGoodsDelete, comboGoodsList } from '@/api/combogoods/combogoods'
|
import { comboGoodsDelete, comboGoodsList } from '@/api/combogoods/combogoods'
|
||||||
import ComboGoodsFormDialog from './component/ComboGoodsFormDialog.vue'
|
import ComboGoodsFormDialog from './component/ComboGoodsFormDialog.vue'
|
||||||
import ComboGoodsSearchDialog from './component/ComboGoodsSearchDialog.vue'
|
import ComboGoodsSearchDialog from './component/ComboGoodsSearchDialog.vue'
|
||||||
@ -111,7 +103,6 @@ import {
|
|||||||
buildComboGoodsListPayload,
|
buildComboGoodsListPayload,
|
||||||
comboGoodsColumns,
|
comboGoodsColumns,
|
||||||
comboGoodsScanFields,
|
comboGoodsScanFields,
|
||||||
comboGoodsToolbarButtons,
|
|
||||||
formatComboGoodsDateTime,
|
formatComboGoodsDateTime,
|
||||||
formatComboGoodsStatus,
|
formatComboGoodsStatus,
|
||||||
isComboGoodsApiSuccess,
|
isComboGoodsApiSuccess,
|
||||||
@ -121,7 +112,6 @@ import {
|
|||||||
} from './combo-stock-config'
|
} from './combo-stock-config'
|
||||||
|
|
||||||
const scanBox = ref<any>(null)
|
const scanBox = ref<any>(null)
|
||||||
const upperTable = ref<any>(null)
|
|
||||||
|
|
||||||
const presetTree = ref<any[]>([])
|
const presetTree = ref<any[]>([])
|
||||||
const availableFieldsRef = reactive(JSON.parse(JSON.stringify(comboGoodsScanFields)))
|
const availableFieldsRef = reactive(JSON.parse(JSON.stringify(comboGoodsScanFields)))
|
||||||
@ -140,52 +130,6 @@ const formDialogMode = ref<'create' | 'edit'>('create')
|
|||||||
const editingRecord = ref<ComboGoodsRecord | null>(null)
|
const editingRecord = ref<ComboGoodsRecord | null>(null)
|
||||||
const searchDialogVisible = ref(false)
|
const searchDialogVisible = ref(false)
|
||||||
|
|
||||||
// ============================================================
|
|
||||||
// 工具栏(样式 / 布局对齐「商品明细」stock/stock)
|
|
||||||
// 按钮定义见 combo-stock-config.ts 的 comboGoodsToolbarButtons
|
|
||||||
// ============================================================
|
|
||||||
const toolbarButtons: ToolbarButtonConfig[] = comboGoodsToolbarButtons
|
|
||||||
|
|
||||||
const buttonLoadingMap = computed(() => ({
|
|
||||||
loading: loading.value
|
|
||||||
}))
|
|
||||||
|
|
||||||
/** 按钮组重新测量可见按钮的依赖(loading / 按钮集合变化时重算) */
|
|
||||||
const toolbarLayoutKey = computed(() =>
|
|
||||||
JSON.stringify({
|
|
||||||
loading: buttonLoadingMap.value,
|
|
||||||
permissions: toolbarButtons.map((button) => button.key).join(',')
|
|
||||||
})
|
|
||||||
)
|
|
||||||
|
|
||||||
function resolveButtonLoading(loadingKey?: string) {
|
|
||||||
if (!loadingKey) return false
|
|
||||||
return Boolean((buttonLoadingMap.value as Record<string, boolean>)[loadingKey])
|
|
||||||
}
|
|
||||||
|
|
||||||
function resolveButtonDisabled(_disabledKey?: string) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
function resolveButtonLabel(defaultLabel: string, _dynamicLabelKey?: string) {
|
|
||||||
return defaultLabel
|
|
||||||
}
|
|
||||||
|
|
||||||
const toolbarActionMap: Record<string, () => void> = {
|
|
||||||
loadList: () => loadList(),
|
|
||||||
openColumnConfigPanel: () => upperTable.value?.openColumnConfig?.(),
|
|
||||||
openCreate: () => openCreate(),
|
|
||||||
openSearchDialog: () => {
|
|
||||||
searchDialogVisible.value = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleToolbarButtonClick(action: ToolbarButtonConfig['action']) {
|
|
||||||
const handler = toolbarActionMap[action]
|
|
||||||
if (!handler) return
|
|
||||||
handler()
|
|
||||||
}
|
|
||||||
|
|
||||||
async function loadList() {
|
async function loadList() {
|
||||||
if (loading.value) return
|
if (loading.value) return
|
||||||
loading.value = true
|
loading.value = true
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
scanWorkflowField,
|
scanWorkflowField,
|
||||||
type ToolbarButtonConfig
|
type ToolbarButtonConfig
|
||||||
} from '@/views/order/orderManagement/config/order-common-config'
|
} from '@/views/order/orderManagement/config/order-common-config'
|
||||||
import { normalizeBarcodeList } from '@/utils/barcode'
|
import { formatBarcodeText } from '@/utils/barcode'
|
||||||
|
|
||||||
/** ScanBox 筛选字段分组(商品模块专用,保留供其他场景复用) */
|
/** ScanBox 筛选字段分组(商品模块专用,保留供其他场景复用) */
|
||||||
export const STOCK_SCAN_FIELD_GROUPS = {
|
export const STOCK_SCAN_FIELD_GROUPS = {
|
||||||
@ -70,10 +70,9 @@ export const stockColumns = [
|
|||||||
prop: 'barcodes',
|
prop: 'barcodes',
|
||||||
label: '商品条码',
|
label: '商品条码',
|
||||||
width: '120',
|
width: '120',
|
||||||
// 多值折叠(只显示第 1 个 + 「+N」,点击 +N 展开全部),单击条码复制
|
// 超长条码(多个条码以 | 拼接)超过 30 字符时收起,提供「展开 / 收起」
|
||||||
// 表现与「外部库存」(stock/external_stock)的条码列一致
|
textCollapse: 30,
|
||||||
copyAction: 'copy',
|
formatter: (row: any) => formatBarcodeText(row.barcodes)
|
||||||
copyValue: (row: any) => normalizeBarcodeList(row.barcodes)
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'images',
|
prop: 'images',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user