Compare commits
24 Commits
50636d0e06
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d1b8988de2 | ||
|
|
bb43f3f31d | ||
|
|
4ebd3c2bb9 | ||
|
|
50c1a4af22 | ||
|
|
f7722e19df | ||
|
|
0b974bd36a | ||
|
|
a067fd8357 | ||
|
|
367380e44c | ||
|
|
77dbabb1f1 | ||
|
|
f917062d76 | ||
|
|
093cf9acd0 | ||
|
|
5fa940e9ba | ||
|
|
f552dd370c | ||
|
|
fe9492ab69 | ||
|
|
d0779fe37c | ||
|
|
b0e9fe6450 | ||
|
|
631d54f269 | ||
|
|
0f038e7818 | ||
|
|
53f23d4e69 | ||
|
|
6ecc649a1c | ||
|
|
6af8fd7b09 | ||
|
|
123d259f92 | ||
|
|
fd1eca95a6 | ||
|
|
a96f62d60b |
@@ -1,382 +1,335 @@
|
|||||||
---
|
---
|
||||||
name: vue-project-structure
|
name: vue-project-structure
|
||||||
description: cz-web 项目(Vue 3 + TypeScript + Vite 网页端站点)的目录结构与编码规范强制 skill。当在本项目中新增、创建、移动、重构或修改任何 src/ 下的代码文件(.vue/.ts/.less)、路由、store、API、组件、页面时,必须加载本 skill,先读取项目目录、再按本规范确定文件归属与写法。本项目是**网页端站点(非中后台)**:页面按名称组织(home/news/product…),接口层在 api/、数据层在 Pinia、页面只经 store 取数,样式使用**less**。凡是涉及"新文件放哪"、"页面数据怎么拿"、"页面/公共组件归属"、"命名"、"功能对应哪些文件"的任务也必须使用本 skill。
|
description: Vue 3 与 uni-app(Vue3) 项目的目录结构与编码规范通用 skill。当在任意 Vue 3 或 uni-app(Vue3) 项目中新增、创建、移动、重构、修改 src/ 下的代码文件(.vue/.ts/.less/.scss)、路由、Pinia store、API、组件、页面、分包时,必须先加载本 skill。核心内容:先探测项目形态(Vue3 网页端/中后台 或 uni-app 小程序),再套用对应目录骨架;页面统一为「index.vue + cpns/」两件套(不使用 index.ts barrel);数据流固定为 页面 → store → api 单向;含 pages.json 注册与分包规范。凡是涉及"新文件放哪""页面数据怎么拿""公共组件 vs 页面私有组件归属""命名""分包""功能对应哪些文件"的任务也必须使用本 skill。本 skill 与具体仓库无关,可在任何 Vue 3 / uni-app 项目中直接复用。
|
||||||
version: 2.0.0
|
version: 4.0.0
|
||||||
---
|
---
|
||||||
|
|
||||||
# cz-web 项目目录结构规范(强制 · 网页端)
|
# Vue 3项目目录结构规范(通用 · 先探测后套用)
|
||||||
|
|
||||||
> 完整版调试文档见 `docs/vue-project-guide.md`(其中中后台相关部分已废弃),**本 skill 为唯一现行规范,以其为准**;未覆盖场景参照 Vue 3 官方目录约定。
|
> 适用范围:**Vue 3**(含 uni-app 的 Vue 3 版本)。不涉及 Vue 2。
|
||||||
|
> 本 skill 与具体仓库无关:执行顺序永远是 **① 探测现状 → ② 选定骨架变体 → ③ 按规范落位**。项目内已有显式文档(`AGENTS.md`/`CLAUDE.md`、`docs/` 下的结构说明)优先级高于本 skill。
|
||||||
|
|
||||||
## 第一步:读取项目目录(每次加载必做)
|
---
|
||||||
|
|
||||||
动手写任何代码前,先用工具映射当前项目结构,确认正在操作的正确层级:
|
## 第零步:探测项目形态(每次加载必做)
|
||||||
|
|
||||||
1. 用 `codegraph_files` 或 `glob` 列出 `src/` 下的现行目录结构(如某目录尚不存在,应在对应职责目录创建,而不是自创新顶层目录)。
|
### 0.1 读取证据
|
||||||
2. 读取目标文件及其同级文件,确认现有命名风格与组织方式(页面名、store 名、api 名必须一致)。
|
|
||||||
3. 只有在目录树确认完毕后,才允许创建/修改文件。
|
|
||||||
|
|
||||||
## 核心原则
|
| 要看什么 | 怎么看 |
|
||||||
|
| ---------- | --------------------------------------------------------------------------- |
|
||||||
|
| 依赖清单 | `package.json`:是否有 `@dcloudio/*`、`pinia`、`vue-router` |
|
||||||
|
| 是否小程序 | 存在 `pages.json`、`manifest.json`;`App.vue` 含 `onLaunch` |
|
||||||
|
| 构建工具 | `vite.config.*`(Vue 3 必配);`vue.config.*` 为 Vue CLI |
|
||||||
|
| 目录现状 | 列出 `src/`(uni-app 通常无 src 包裹,直接根目录)的实际结构 |
|
||||||
|
| 样式方案 | 现有 `.less` → less;`.scss` → scss |
|
||||||
|
| 语言 | 有 `tsconfig.json` → TypeScript |
|
||||||
|
| 目标平台 | `manifest.json` 的 `mp-weixin`/`h5`/`app` 等;`pages.json` 的 `subPackages` |
|
||||||
|
|
||||||
1. **三层数据流(页面 → store → api)**:页面组件只通过 **Pinia store** 获取数据;store 是数据层,负责调用 **api 层**接口取数并维护状态;api 层只发请求。**页面禁止直接 import api**。
|
### 0.2 判定形态
|
||||||
2. **按页面/页面名组织(一页一套)**:`views/<page>/`、`api/<page>.ts`、`stores/modules/<page>.ts`、`types/business/<page>.d.ts` 四者同名对应,方便分层查看。
|
|
||||||
3. **组件两级归属**:`components/` 只放**跨页面复用的公共组件**;`views/<page>/cpns/` 放**该页面独有的组件**。
|
|
||||||
4. **网页端(非中后台)**:无侧边栏菜单/权限路由/TabsBar 体系;页面以业务(首页、新闻、产品、关于我们…)划分。
|
|
||||||
5. **样式使用 less**:全局样式为 `.less` 文件,组件内 `<style lang="less" scoped>`。
|
|
||||||
|
|
||||||
## 数据流架构(强约束)
|
```mermaid
|
||||||
|
graph TD
|
||||||
|
A[读 package.json + 目录] --> B{含 @dcloudio/* ?}
|
||||||
|
B -->|是| U[形态 B: uni-app Vue3]
|
||||||
|
B -->|否| D{有 layout 壳 + 权限路由?}
|
||||||
|
D -->|是| M[形态 A2: 中后台]
|
||||||
|
D -->|否| W[形态 A1: 网页端站点]
|
||||||
|
U --> U1{pages.json 有 subPackages?}
|
||||||
|
U1 -->|是| U2[大应用: 必须分包]
|
||||||
|
U1 -->|否| U3[小应用: 主包即可]
|
||||||
|
```
|
||||||
|
|
||||||
|
| 形态 | 判据 | 骨架 |
|
||||||
|
| ---------------------- | ---------------------------------------------- | ----------------------------------- |
|
||||||
|
| **A1 Vue3 网页端站点** | 无权限路由,业务按页面名划分 | 骨架 A |
|
||||||
|
| **A2 Vue3 中后台** | 有 `layout/` 壳、`permission.ts`、表格表单密集 | 骨架 A + 中后台补充 |
|
||||||
|
| **B uni-app(Vue3)** | 依赖含 `@dcloudio/*`,存在 `pages.json` | 骨架 B(**页面注册用 pages.json**) |
|
||||||
|
|
||||||
|
### 0.3 探测结论必须先复述
|
||||||
|
|
||||||
|
动手改代码前,先输出:
|
||||||
|
|
||||||
|
```
|
||||||
|
探测结论:形态=B uni-app(Vue3 + Vite + TS + Pinia + scss,含 subPackages 3 个)
|
||||||
|
页面结构:index.vue + cpns/(无 index.ts)
|
||||||
|
样式方案:scss(uni.scss 已存在)
|
||||||
|
```
|
||||||
|
|
||||||
|
探测不明确时**先问用户**,不要猜。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 第一步:读取目标区域(探测后必做)
|
||||||
|
|
||||||
|
1. 列出将要操作目录的现行结构(目录不存在则新建,**不要自创新顶层目录**)。
|
||||||
|
2. 读取目标文件 + 同级 2 个文件,确认既有命名/导出/样式风格。
|
||||||
|
3. 确认该业务域"页面 / api / store / 类型"在本项目中的实际路径。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 核心原则(形态无关)
|
||||||
|
|
||||||
|
1. **三层数据流:页面 → store → api**。页面只通过 store 取数;store 调用 api 并维护状态;api 只发请求。**页面禁止直接 import api**。
|
||||||
|
2. **业务同名单点**:同一业务域的 `页面目录` / `api 文件` / `store 文件` / `类型文件` 同名对应。
|
||||||
|
3. **页面两件套(无 barrel)**:页面目录 = `index.vue` + `cpns/`。**不建 `index.ts`**,路由直接指向 `@/views/<page>/index.vue`。
|
||||||
|
4. **组件两级归属**:跨 ≥2 个页面/分包复用 → 全局 `components/`;单页面独有 → 该页面的 `cpns/`。
|
||||||
|
5. **技术选型跟随现状**:用 Pinia 就不引 Vuex;用 scss 就不写 less;用 TS 就不落 `.js`。**不擅自更换技术栈**。
|
||||||
|
6. **最小改动**:只改与本次需求相关的行;无关死代码只报告、不删除。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 骨架 A:Vue 3 网页端 / 中后台
|
||||||
|
|
||||||
|
```
|
||||||
|
src/
|
||||||
|
├── api/<domain>.ts # 接口层:按业务命名,一域一文件
|
||||||
|
├── assets/ # 参与构建的静态资源(images/ icons/ fonts/)
|
||||||
|
├── components/ # 跨页面复用的公共组件(禁含具体业务)
|
||||||
|
│ └── index.ts # barrel 统一导出(仅公共组件目录需要)
|
||||||
|
├── composables/ # 通用组合式逻辑(useLoading / useScroll / useCountDown)
|
||||||
|
├── directives/ # 自定义指令(lazy / debounce / throttle)+ index.ts 注册
|
||||||
|
├── layout/ # 全站骨架(网页端:Header+router-view+Footer)
|
||||||
|
├── router/ # index.ts(createRouter)、routes.ts、guard.ts
|
||||||
|
├── stores/
|
||||||
|
│ ├── index.ts # pinia 实例
|
||||||
|
│ └── modules/<domain>.ts
|
||||||
|
├── styles/ # variables / mixins / reset / common + 入口
|
||||||
|
├── types/ # api.d.ts / router.d.ts / business/<domain>.d.ts
|
||||||
|
├── utils/ # request.ts(唯一 axios 实例)/ storage / validate / format
|
||||||
|
└── views/
|
||||||
|
└── <page>/ # ★ 页面 = index.vue + cpns/
|
||||||
|
├── index.vue # 页面主组件(路由直接指向它)
|
||||||
|
├── detail.vue # 同页面模块的次级页面(如列表/详情)
|
||||||
|
└── cpns/ # 仅本页使用的组件
|
||||||
|
├── Head.vue
|
||||||
|
└── Banner.vue
|
||||||
|
```
|
||||||
|
|
||||||
|
路由写法(**不经过 index.ts**):
|
||||||
|
|
||||||
|
```ts
|
||||||
|
{
|
||||||
|
path: '/news',
|
||||||
|
name: 'News',
|
||||||
|
component: () => import('@/views/news/index.vue'), // 直接指向 .vue
|
||||||
|
meta: { title: '新闻列表' },
|
||||||
|
}
|
||||||
|
{
|
||||||
|
path: '/news/:id',
|
||||||
|
name: 'NewsDetail',
|
||||||
|
component: () => import('@/views/news/detail.vue'),
|
||||||
|
meta: { title: '新闻详情' },
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### A2 中后台补充(在骨架 A 上增加)
|
||||||
|
|
||||||
|
```
|
||||||
|
src/
|
||||||
|
├── layout/
|
||||||
|
│ ├── index.vue # 后台外壳:侧边栏 + 顶栏 + tab 缓存 + <router-view/>
|
||||||
|
│ └── components/ # Sider / Header / Breadcrumb / TagsView
|
||||||
|
├── router/
|
||||||
|
│ ├── routes.ts # constantRoutes(无权限)
|
||||||
|
│ └── modules.ts # asyncRoutes(按角色过滤)
|
||||||
|
├── permission.ts # 守卫:登录态 → 白名单 → 动态路由注入
|
||||||
|
├── stores/modules/ # user(token/角色/权限)、permission(动态路由)、app(侧栏/主题)
|
||||||
|
└── views/<module>/<page>/ # 按模块再分页面,如 views/system/user/index.vue
|
||||||
|
```
|
||||||
|
|
||||||
|
- 权限:`meta: { title, icon, roles: [], perms: [] }`,由 `permission.ts` 统一处理,页面用 `hasPermi('sys:user:add')` 判断。
|
||||||
|
- 表格页统一结构:`搜索区 + 工具栏 + 表格 + 分页`,分页用公共 `Pagination` 组件。
|
||||||
|
- 动态路由必须 `router.addRoute` 注入后 `next({ ...to, replace: true })`,避免空白页。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 骨架 B:uni-app(Vue 3)
|
||||||
|
|
||||||
|
```
|
||||||
|
├── pages.json # ★ 唯一页面注册入口(路径、导航栏、分包)
|
||||||
|
├── manifest.json # 应用配置(appid、平台配置、原生插件)
|
||||||
|
├── uni.scss # ★ 全局 scss 变量(uni-app 约定入口)
|
||||||
|
├── App.vue # 全局生命周期 onLaunch/onShow/onHide
|
||||||
|
├── main.ts # createApp、注册 pinia、引入全局样式
|
||||||
|
├── api/<domain>.ts # 接口层(uni.request 封装为函数)
|
||||||
|
├── stores/modules/<domain>.ts # 状态层
|
||||||
|
├── utils/
|
||||||
|
│ ├── request.ts # 封装 uni.request 的唯一请求层
|
||||||
|
│ └── storage.ts # uni.getStorageSync 封装
|
||||||
|
├── components/ # 跨页面/跨分包复用的自定义组件
|
||||||
|
├── static/ # 不参与编译的静态资源(不要用 assets)
|
||||||
|
├── composables/
|
||||||
|
├── types/
|
||||||
|
├── pages/ # ★ 主包页面
|
||||||
|
│ ├── index/
|
||||||
|
│ │ ├── index.vue
|
||||||
|
│ │ └── cpns/
|
||||||
|
│ └── login/
|
||||||
|
│ ├── index.vue
|
||||||
|
│ └── cpns/
|
||||||
|
└── subpackages/ # 分包页面(仅分包项目)
|
||||||
|
└── news/
|
||||||
|
├── detail.vue
|
||||||
|
└── cpns/
|
||||||
|
```
|
||||||
|
|
||||||
|
uni-app 硬性约定:
|
||||||
|
|
||||||
|
- 页面**必须**在 `pages.json` 的 `pages` / `subPackages[].pages` 注册,路径不带扩展名、不以 `/` 开头。
|
||||||
|
- 页面目录同样遵循 **`index.vue` + `cpns/`**,不建 `index.ts`。
|
||||||
|
- 主包体积敏感:**非首屏必需**页面一律放 `subPackages`;静态大图放 `static/`。
|
||||||
|
- 跨分包随意 import 受限;公共依赖优先放主包或做分包异步化。
|
||||||
|
- 平台差异(`#ifdef MP-WEIXIN / H5 / APP-PLUS`)集中封装并注释,禁止散落全项目。
|
||||||
|
- 用 `uni.request` / `uni.chooseImage` / `uni.navigateTo`,不混用 `wx.*`;tabBar 页用 `switchTab`(不能带参数)。
|
||||||
|
- 组件模板优先 `view/text/image`,不用 `div/span/img`。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 数据流架构(强约束,两形态通用)
|
||||||
|
|
||||||
```text
|
```text
|
||||||
页面组件 (views/home/index.vue)
|
页面组件 (views/news/index.vue 或 pages/news/index.vue)
|
||||||
│ ① 页面只调用 store 的 action / 读取 store 的 state(模板渲染数据)
|
│ ① 只读 store state / 调 store action
|
||||||
▼
|
▼
|
||||||
Pinia store (stores/modules/home.ts) —— 数据层
|
状态层 (stores/modules/news.ts) —— 数据层:取数 + 状态 + 缓存 + 跨页共享
|
||||||
│ ② store 的 action 内部调用 api 接口函数 → await → 写入 state / 返回结果
|
│ ② action 内部调用 api 函数 → await → 写 state
|
||||||
▼
|
▼
|
||||||
API (api/home.ts) —— 接口层
|
API (api/news.ts) —— 接口层:只发请求、只返回带类型的数据
|
||||||
│ ③ 经 utils/request.ts 发 HTTP 请求
|
│ ③ request.ts(axios / uni.request 封装)
|
||||||
▼
|
▼
|
||||||
后端服务器
|
后端
|
||||||
```
|
```
|
||||||
|
|
||||||
铁律:
|
铁律:
|
||||||
|
|
||||||
- **页面禁止 `import` api 层文件**;获取数据必须调对应页面 store 的方法。
|
- 页面**禁止** import api;取数必须走 store。
|
||||||
- **api 层是纯接口层**:只发请求、返回数据(带类型),不做业务状态处理、不缓存。
|
- api 是**纯接口层**:不发业务判断、不缓存、不 toast。
|
||||||
- **store 承担取数 + 数据状态 + 页面间共享 + 缓存**;与页面同名的 store 责任边界即该页面。
|
- store 承担取数、状态、缓存、跨页共享;本地缓存用 `storage.ts`,不直接写 `localStorage` / `uni.setStorageSync`。
|
||||||
- 调用链必须是 `页面 → store → api` 单向,禁止跳过 store 或反向依赖。
|
- 依赖方向单向:`页面 → store → api`,禁止反向与跨层直连。
|
||||||
|
|
||||||
## src/ 目录结构(强制划分)
|
---
|
||||||
|
|
||||||
```
|
## 各层职责速查
|
||||||
src/
|
|
||||||
├── api/ # ★ 接口层:按页面命名,一页一文件(home.ts、news.ts、product.ts、about.ts)
|
| 层 | 目录 | 一句话职责 | 禁止 |
|
||||||
├── assets/ # 参与构建的静态资源(images/、icons/、fonts/)
|
| ------------ | --------------------------------------------------------- | ---------------------------------------- | ------------------------------ |
|
||||||
├── components/ # ★ 公共组件:仅跨页面复用的全站通用组件(禁含具体页面业务)
|
| 页面 | `views/<page>/index.vue`(uni:`pages/<page>/index.vue`) | 渲染 + 交互 + 编排 | 直接调 api、直接 axios/request |
|
||||||
│ ├── AppHeader.vue # 全站头部(导航)
|
| 页面私有组件 | `views/<page>/cpns/`(uni 同名) | 仅本页用 | 被其他页 import |
|
||||||
│ ├── AppFooter.vue # 全站页脚
|
| 公共组件 | `components/` | ≥2 处复用 | 含单页业务逻辑 |
|
||||||
│ ├── AppButton.vue # 通用按钮
|
| 状态层 | `stores/modules/<domain>.ts` | 取数 + 状态 + 缓存 | 拼 URL、写 UI 逻辑 |
|
||||||
│ ├── AppSwiper.vue # 通用轮播
|
| 接口层 | `api/<domain>.ts` | 请求分发 + 类型 | 状态、弹窗提示 |
|
||||||
│ └── index.ts # 统一导出
|
| 请求层 | `utils/request.ts` | 唯一实例/封装:token、统一解包、错误提示 | 被页面直接 import axios |
|
||||||
├── composables/ # 通用组合式逻辑(useScroll、useLoading、useCountDown、useIntersection)
|
| 工具 | `utils/`(纯函数) / `composables/`(响应式) | — | 互相混放 |
|
||||||
├── directives/ # 自定义指令(lazy 图片懒加载、debounce、throttle + index.ts 统一注册)
|
|
||||||
├── layout/ # 全站布局骨架:index.vue = <AppHeader/> + <router-view/> + <AppFooter/>
|
> **页面私有组件目录名统一用 `cpns/`**(不再用 `components/`,避免与全局 `components/` 混淆)。
|
||||||
├── router/ # 路由:index.ts(入口)、routes.ts(静态路由表)、guard.ts(守卫,可选)
|
|
||||||
├── stores/ # ★ 数据层(Pinia):按页面命名,一页一 store
|
### 组件归属判定(唯一判据)
|
||||||
│ ├── index.ts # pinia 实例(main.ts 中 app.use(pinia))
|
|
||||||
│ └── modules/
|
```mermaid
|
||||||
│ ├── home.ts # useHomeStore:首页数据(banner、推荐、公告)
|
graph TD
|
||||||
│ ├── news.ts # useNewsStore:新闻列表/分页/详情
|
A[新组件] --> B{被几个页面/分包使用?}
|
||||||
│ ├── product.ts # useProductStore:产品列表/详情
|
B -->|1 个| C[放该页面 cpns/]
|
||||||
│ └── site.ts # useSiteStore:站点公共数据(站点配置、全局 loading),非页面级
|
B -->|≥2 个| D{业务无关还是业务相关?}
|
||||||
├── styles/ # ★ 全局样式(less)
|
D -->|业务无关<br/>按钮/弹窗/上传| E[全局 components/]
|
||||||
│ ├── index.less # 样式入口(main.ts 引入),组织以下文件
|
D -->|业务相关| F[全局 components/<domain>/]
|
||||||
│ ├── variables.less # ★ less 变量唯一来源(颜色/间距/字号/圆角),禁止组件内魔法色值
|
F --> G[差异用 props 注入]
|
||||||
│ ├── mixins.less # 混合宏(flex、文本省略、滚动条)
|
|
||||||
│ ├── reset.less # 样式重置
|
|
||||||
│ └── common.less # 通用工具类(容器宽度、间距类)
|
|
||||||
├── types/ # 类型定义
|
|
||||||
│ ├── global.d.ts # 全局声明(Window 扩展、import.meta.env 兜底)
|
|
||||||
│ ├── api.d.ts # 接口通用结构:ApiResponse<T>、PageResult<T>
|
|
||||||
│ ├── router.d.ts # RouteMeta 扩展
|
|
||||||
│ └── business/ # 按页面与 api 对应:home.d.ts / news.d.ts / product.d.ts
|
|
||||||
├── utils/ # 纯函数工具(无 Vue 依赖):request.ts、storage.ts、validate.ts、format.ts
|
|
||||||
└── views/ # ★ 页面:一页一目录
|
|
||||||
├── home/
|
|
||||||
│ ├── index.vue # 页面主组件(路由通过 index.ts 加载)
|
|
||||||
│ ├── index.ts # 页面出口(barrel):export default 页面 + 导出本页独有组件
|
|
||||||
│ └── cpns/ # 页面独有组件(head、banner、news-list 等,仅本页面使用)
|
|
||||||
│ ├── Head.vue
|
|
||||||
│ └── Banner.vue
|
|
||||||
├── news/
|
|
||||||
│ ├── index.vue # 列表页
|
|
||||||
│ ├── detail.vue # 详情页
|
|
||||||
│ ├── index.ts
|
|
||||||
│ └── cpns/
|
|
||||||
├── product/ # 同上结构
|
|
||||||
├── about/ # 同上结构
|
|
||||||
└── login/ # 登录(仅存在会员体系时)
|
|
||||||
```
|
```
|
||||||
|
|
||||||
**命名一致性(可分层互查)**:页面 `home` → `api/home.ts` + `stores/modules/home.ts`(`useHomeStore`) + `types/business/home.d.ts` + `views/home/`,四者同名。
|
### 命名一致性
|
||||||
|
|
||||||
## src/ 每个文件的作用(新建/修改文件前先对照本节定位)
|
同一业务域 `news` 的四层落位:
|
||||||
|
|
||||||
### 入口与根文件
|
| 层 | Vue 形态 | uni-app 形态 |
|
||||||
|
| -------- | ----------------------------------------- | ------------------------------------------ |
|
||||||
|
| 页面 | `views/news/index.vue` | `pages/news/index.vue` + `pages.json` 注册 |
|
||||||
|
| 私有组件 | `views/news/cpns/` | `pages/news/cpns/` |
|
||||||
|
| 接口 | `api/news.ts` | `api/news.ts` |
|
||||||
|
| 状态 | `stores/modules/news.ts` → `useNewsStore` | 同左 |
|
||||||
|
| 类型 | `types/business/news.d.ts` | `types/business/news.d.ts` |
|
||||||
|
|
||||||
| 文件 | 作用 |
|
---
|
||||||
| -------------- | --------------------------------------------------------------------------------------------------------------------------------- |
|
|
||||||
| `src/main.ts` | 应用入口:`createApp(App)`,注册 `pinia`、`router`、自定义指令(`setupDirectives`)、引入全局 `styles/index.less`。不写业务逻辑。 |
|
|
||||||
| `src/App.vue` | 根组件,承载 `<router-view/>` 与全局过渡;不含业务代码。 |
|
|
||||||
| `src/env.d.ts` | Vite 环境变量类型声明(`ImportMetaEnv` / `ImportMeta`)。 |
|
|
||||||
|
|
||||||
### `api/` —— 接口层(一页一文件,与页面同名)
|
## 规范速查(形态无关的硬性项)
|
||||||
|
|
||||||
| 文件 | 作用 |
|
|
||||||
| ---------------- | ------------------------------------------------------ |
|
|
||||||
| `api/home.ts` | 首页接口:`getHomeBanner`、`getRecommend`、`getNotice` |
|
|
||||||
| `api/news.ts` | 新闻接口:`getNewsList`、`getNewsDetail` |
|
|
||||||
| `api/product.ts` | 产品接口:`getProductList`、`getProductDetail` |
|
|
||||||
| `api/about.ts` | 关于我们/公司介绍接口 |
|
|
||||||
| `api/auth.ts` | 登录/注册/用户信息(仅会员体系需要时) |
|
|
||||||
|
|
||||||
> **纯接口层**:函数只负责 `request<T>({ url, method, params/data })`,不做数据加工、不维护状态。新增页面 → 新建 `api/<page>.ts`。
|
|
||||||
|
|
||||||
### `components/` —— 公共组件(仅跨页面复用)
|
|
||||||
|
|
||||||
| 文件 | 作用 |
|
|
||||||
| -------------------------- | ------------------------------------------------------------ |
|
|
||||||
| `components/AppHeader.vue` | 全站头部:logo、导航菜单(路由跳转) |
|
|
||||||
| `components/AppFooter.vue` | 全站页脚:版权、友链 |
|
|
||||||
| `components/AppButton.vue` | 通用按钮(disabled/loading/类型统一) |
|
|
||||||
| `components/AppSwiper.vue` | 通用轮播(首页 banner、产品图) |
|
|
||||||
| `components/index.ts` | 统一导出(barrel),页面与页面组件统一从 `@/components` 导入 |
|
|
||||||
|
|
||||||
> 判定:被 ≥2 个页面使用 → 放这里;仅 1 个页面使用 → 放 `views/<page>/cpns/`。
|
|
||||||
|
|
||||||
### `composables/` —— 通用组合式逻辑(与 UI 解耦)
|
|
||||||
|
|
||||||
| 文件 | 作用 |
|
|
||||||
| -------------------------------- | ------------------------ |
|
|
||||||
| `composables/useScroll.ts` | 滚动监听/吸顶/回到顶部 |
|
|
||||||
| `composables/useLoading.ts` | 请求 loading 状态管理 |
|
|
||||||
| `composables/useCountDown.ts` | 倒计时(验证码等) |
|
|
||||||
| `composables/useIntersection.ts` | 元素可见性(配合懒加载) |
|
|
||||||
|
|
||||||
### `directives/` —— 自定义指令
|
|
||||||
|
|
||||||
| 文件 | 作用 |
|
|
||||||
| ------------------------ | --------------------------------------------- |
|
|
||||||
| `directives/lazy.ts` | `v-lazy` 图片懒加载(网页端常用) |
|
|
||||||
| `directives/debounce.ts` | `v-debounce` 防抖 |
|
|
||||||
| `directives/throttle.ts` | `v-throttle` 节流 |
|
|
||||||
| `directives/index.ts` | `setupDirectives(app)` 统一注册,main.ts 调用 |
|
|
||||||
|
|
||||||
### `layout/` —— 全站布局骨架
|
|
||||||
|
|
||||||
| 文件 | 作用 |
|
|
||||||
| -------------------- | -------------------------------------------------------------------------- |
|
|
||||||
| `layout/index.vue` | 全站公共布局:`<AppHeader/>` + `<router-view/>` + `<AppFooter/>`,仅此一层 |
|
|
||||||
| `layout/components/` | 布局内部组件(如返回顶部按钮);需要全站复用的上移 `components/` |
|
|
||||||
|
|
||||||
### `router/` —— 路由系统(网页端:静态路由为主)
|
|
||||||
|
|
||||||
| 文件 | 作用 |
|
|
||||||
| ------------------ | ------------------------------------------------------------------------- |
|
|
||||||
| `router/index.ts` | 创建 `createRouter`(createWebHistory)+ 注册静态路由 + 挂守卫 |
|
|
||||||
| `router/routes.ts` | 静态路由表:`/home`、`/news`、`/news/:id`、`/product`、`/about`、404 兜底 |
|
|
||||||
| `router/guard.ts` | 路由守卫(可选):登录态校验(会员页)、滚动位置恢复、document.title |
|
|
||||||
|
|
||||||
```ts
|
|
||||||
// 路由加载页面(指向 views/home/index.ts —— 页面出口)
|
|
||||||
{
|
|
||||||
path: '/home',
|
|
||||||
name: 'Home',
|
|
||||||
component: () => import('@/views/home'), // 解析到 index.ts 的 default(index.vue)
|
|
||||||
meta: { title: '首页' },
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### `stores/modules/` —— 数据层(Pinia,一页一 store,与页面同名)
|
|
||||||
|
|
||||||
| 文件 | 作用 |
|
|
||||||
| --------------------------- | ------------------------------------------------------------------------------------------- |
|
|
||||||
| `stores/modules/home.ts` | `useHomeStore`:state(banner/推荐/公告)+ actions(`fetchHomeData`,内部调 `api/home.ts`) |
|
|
||||||
| `stores/modules/news.ts` | `useNewsStore`:列表/分页/详情 state + `fetchNewsList`、`fetchNewsDetail` |
|
|
||||||
| `stores/modules/product.ts` | `useProductStore`:产品列表/详情/分类筛选 |
|
|
||||||
| `stores/modules/site.ts` | `useSiteStore`:站点配置、全局 loading、主题(非页面级公共数据) |
|
|
||||||
| `stores/modules/user.ts` | `useUserStore`:登录态/token(仅会员体系需要时) |
|
|
||||||
|
|
||||||
```ts
|
|
||||||
// stores/modules/home.ts —— 数据层写法示例(页面 → store → api)
|
|
||||||
import { defineStore } from 'pinia'
|
|
||||||
import { ref } from 'vue'
|
|
||||||
import { getHomeBanner, getRecommend } from '@/api/home'
|
|
||||||
import type { Banner, RecommendItem } from '@/types/business/home'
|
|
||||||
|
|
||||||
export const useHomeStore = defineStore('home', () => {
|
|
||||||
const banners = ref<Banner[]>([])
|
|
||||||
const recommends = ref<RecommendItem[]>([])
|
|
||||||
|
|
||||||
async function fetchHomeData() {
|
|
||||||
// ① store 调 api 层拿数据
|
|
||||||
const [bannerData, recommendData] = await Promise.all([
|
|
||||||
getHomeBanner(),
|
|
||||||
getRecommend(),
|
|
||||||
])
|
|
||||||
// ② 写入 state——完成页面所需数据
|
|
||||||
banners.value = bannerData
|
|
||||||
recommends.value = recommendData
|
|
||||||
}
|
|
||||||
|
|
||||||
return { banners, recommends, fetchHomeData }
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
### `styles/` —— 全局样式(less)
|
|
||||||
|
|
||||||
| 文件 | 作用 |
|
|
||||||
| ----------------------- | ------------------------------------------------------------------------------------ |
|
|
||||||
| `styles/index.less` | 入口,main.ts `import '@/styles/index.less'` |
|
|
||||||
| `styles/variables.less` | ★ 变量唯一来源:`@primary-color`、`@text-color`、`@font-size-base`、`@spacing-base`… |
|
|
||||||
| `styles/mixins.less` | 混合宏(flex、文本省略) |
|
|
||||||
| `styles/reset.less` | 重置 |
|
|
||||||
| `styles/common.less` | 通用工具类 |
|
|
||||||
|
|
||||||
组件内样式:`<style lang="less" scoped>`,变量经 vite `css.preprocessorOptions.less.additionalData` 自动注入 `@import '@/styles/variables.less';`,组件内直接使用 `@primary-color`。
|
|
||||||
|
|
||||||
### `types/` —— 类型定义
|
|
||||||
|
|
||||||
| 文件 | 作用 |
|
|
||||||
| -------------------------- | --------------------------------------------------------------------- |
|
|
||||||
| `types/api.d.ts` | `ApiResponse<T> { code, msg, data }`、`PageResult<T> { list, total }` |
|
|
||||||
| `types/router.d.ts` | `declare module 'vue-router'` 扩展 `RouteMeta`(title 等) |
|
|
||||||
| `types/business/home.d.ts` | 首页实体类型(Banner/RecommendItem),与 `api/home.ts` 对应 |
|
|
||||||
| `types/business/news.d.ts` | 新闻实体(NewsItem/NewsQuery),与 `api/news.ts` 对应 |
|
|
||||||
|
|
||||||
> 新页面 → 新建 `types/business/<page>.d.ts`;禁止在组件内散落实体类型。
|
|
||||||
|
|
||||||
### `utils/` —— 纯函数工具
|
|
||||||
|
|
||||||
| 文件 | 作用 |
|
|
||||||
| ------------------- | ------------------------------------------------------------------------------------------------------------------------- |
|
|
||||||
| `utils/request.ts` | ★ 唯一 axios 实例:拦截器注入 token/统一解包 `ApiResponse`/统一错误提示,导出 `request<T>`。组件与页面禁止再 import axios |
|
|
||||||
| `utils/storage.ts` | localStorage/sessionStorage 泛型封装 |
|
|
||||||
| `utils/validate.ts` | 校验规则(手机号/邮箱/URL) |
|
|
||||||
| `utils/format.ts` | 格式化(金额/日期/千分位) |
|
|
||||||
|
|
||||||
### `views/` —— 页面(一页一目录,三件套:index.vue + index.ts + cpns/)
|
|
||||||
|
|
||||||
| 文件/目录 | 作用 |
|
|
||||||
| ---------------------------- | --------------------------------------------------------------------------------------------------------------------- |
|
|
||||||
| `views/home/index.vue` | 首页主组件:组合 `cpns/` 的独有组件,数据由 `useHomeStore` 提供 |
|
|
||||||
| `views/home/index.ts` | **页面出口(barrel)**:`export { default } from './index.vue'` + 导出 `cpns/` 组件;路由与外部引用统一走它"展示"页面 |
|
|
||||||
| `views/home/cpns/Head.vue` | 首页独有头部区块(banner 下导航条等),仅本页使用 |
|
|
||||||
| `views/home/cpns/Banner.vue` | 首页独有轮播区块(渲染 store 的 banners) |
|
|
||||||
| `views/news/index.vue` | 新闻列表页 |
|
|
||||||
| `views/news/detail.vue` | 新闻详情页(与 index.vue 同目录,同页面模块) |
|
|
||||||
| `views/news/index.ts` | 出口 barrel(同上) |
|
|
||||||
| `views/news/cpns/` | 新闻页独有组件(筛选栏、列表项卡片) |
|
|
||||||
|
|
||||||
```ts
|
|
||||||
// views/home/index.ts —— 页面出口(barrel)写法
|
|
||||||
export { default } from './index.vue' // 页面主组件(default)
|
|
||||||
export { default as HomeHead } from './cpns/Head.vue'
|
|
||||||
export { default as HomeBanner } from './cpns/Banner.vue'
|
|
||||||
```
|
|
||||||
|
|
||||||
> 页面独有组件的归属判定:**只属于某一个页面 → 进该页面 `cpns/`;被 ≥2 个页面共用 → 上移 `components/`**。
|
|
||||||
|
|
||||||
## 项目功能模块图(功能 → 涉及文件)
|
|
||||||
|
|
||||||
| 功能 | 涉及文件 | 说明 |
|
|
||||||
| --------------------- | --------------------------------------------------------------------------------------- | ------------------------------ |
|
|
||||||
| 全站布局(头部/页脚) | `layout/index.vue` + `components/AppHeader.vue` + `components/AppFooter.vue` | 路由首层挂在 layout 下 |
|
|
||||||
| 首页 | `api/home.ts` + `stores/modules/home.ts` + `views/home/`(index.vue + index.ts + cpns) | 页面 → store → api 取数 |
|
|
||||||
| 新闻中心 | `api/news.ts` + `stores/modules/news.ts` + `views/news/` | 列表 + 详情 |
|
|
||||||
| 产品展示 | `api/product.ts` + `stores/modules/product.ts` + `views/product/` | 列表 + 详情 + 分类 |
|
|
||||||
| 关于我们 | `api/about.ts` + `stores/modules/about.ts` + `views/about/` | 公司介绍内容 |
|
|
||||||
| 会员登录(可选) | `api/auth.ts` + `stores/modules/user.ts` + `views/login/` + `router/guard.ts` | 登录态/token |
|
|
||||||
| 轮播/动效 | `components/AppSwiper.vue` + `composables/useScroll.ts` + `directives/lazy.ts` | 首页 banner、图片懒加载 |
|
|
||||||
| 站点公共数据 | `stores/modules/site.ts` + `styles/variables.less` | 站点配置、全局 loading、主题色 |
|
|
||||||
|
|
||||||
## 统一规范速查
|
|
||||||
|
|
||||||
### 路由规范
|
|
||||||
|
|
||||||
- 路由 `component` 指向页面出口:`() => import('@/views/<page>')`(解析到 `index.ts` 的 default = `index.vue`)
|
|
||||||
- 每个路由必须声明 `meta.title`;`RouteMeta` 扩展在 `src/types/router.d.ts`
|
|
||||||
- 网页端以静态路由为主,无需动态权限路由;嵌套页面(news 列表/详情)在同一页面目录下
|
|
||||||
- 公共页面挂载在 `layout/index.vue` 下,页面自身不重复写 header/footer
|
|
||||||
|
|
||||||
### 状态管理(Pinia)规范 —— 数据层
|
|
||||||
|
|
||||||
- store 文件:`src/stores/modules/<page>.ts`,命名 `use<Page>Store`(PascalCase),与 api/views 同名
|
|
||||||
- **统一组合式(setup)写法**:state 用 `ref`,getters 用 `computed`,actions 用普通函数,最后 return 全部
|
|
||||||
- **store 的 action 负责调用对应页面 api 层的接口取数**,页面只调 action
|
|
||||||
- 组件内:state/getters 用 `storeToRefs` 解构;actions 直接解构调用
|
|
||||||
- 简单展示型数据也走 store(保持数据层统一),页面禁止直接 import api
|
|
||||||
|
|
||||||
### 接口 API 规范 —— 接口层
|
|
||||||
|
|
||||||
- **全项目唯一 axios 实例**在 `src/utils/request.ts`,禁止页面/组件 import axios
|
|
||||||
- 统一响应结构 `ApiResponse<T> { code, msg, data }`(见 `types/api.d.ts`)
|
|
||||||
- 接口函数名 = 动词 + 资源:`getHomeBanner` / `getNewsList` / `getNewsDetail` / `getProductList`
|
|
||||||
- `api/<page>.ts` 只做请求分发,不做数据处理;处理与状态归 store
|
|
||||||
- baseURL 用环境变量 `import.meta.env.VITE_API_BASE_URL` 区分环境(.env / .env.development / .env.production)
|
|
||||||
- 错误统一由拦截器兜底,store/页面仅在需特殊处理时 catch
|
|
||||||
|
|
||||||
### 组件规范
|
### 组件规范
|
||||||
|
|
||||||
- 公共组件 `components/`:文件 PascalCase(AppHeader.vue);被 ≥2 页面使用才放这里
|
- 统一 `<script setup lang="ts">`。
|
||||||
- 页面独有组件 `views/<page>/cpns/`:**严禁被其他页面 import**;语义化命名(Head.vue、Banner.vue)
|
- props:`defineProps<Props>()` + `withDefaults`;emits:`defineEmits<{ change: [val: number] }>()`,事件名 camelCase。
|
||||||
- 页面结构三件套:`index.vue`(页面) + `index.ts`(出口 barrel) + `cpns/`(独有组件)
|
- 模板内不写复杂表达式(超过一次三元/逻辑运算即抽方法或 computed)。
|
||||||
- 组件统一 `<script setup lang="ts">`;props 用 `defineProps<Props>()` + `withDefaults`;emits 用 `defineEmits<{ 事件名: [参数类型] }>()`
|
- 单文件 > 400 行 → 拆到同页面 `cpns/`。
|
||||||
- 组件事件 camelCase 命名;模板内不放复杂表达式;样式默认 `<style lang="less" scoped>`
|
- uni-app 组件模板用 `view/text/image`。
|
||||||
- 单文件超 400 行即拆分到 `cpns/`
|
|
||||||
|
|
||||||
### 样式规范(less)
|
### 样式规范
|
||||||
|
|
||||||
- 全项目使用 **less**,禁止新增 `.scss/.css` 业务样式
|
- **跟随项目既有方案**(less 或 scss),不混用两套预处理器。
|
||||||
- 全局变量统一在 `styles/variables.less`;组件内禁止魔法色值
|
- 变量单一来源:Vue 项目 `src/styles/variables.*`;uni-app 项目 `uni.scss`。
|
||||||
- vite `css.preprocessorOptions.less` 配置 `additionalData` 自动注入 variables
|
- 组件内禁止魔法色值/魔法间距。
|
||||||
- 依赖:`pnpm add -D less`(vite 内置 less 编译支持)
|
- Vue 项目:`<style scoped lang="less|scss">`;uni-app 页面样式**不加 `scoped`**(小程序不支持),靠类名隔离。
|
||||||
|
|
||||||
### 工程化硬性约定
|
### 类型规范
|
||||||
|
|
||||||
- **导入一律 `@/` 别名**;禁止跨目录相对路径(`../` 超过一层即违规)
|
- 实体类型 → `types/business/<domain>.d.ts`;接口通用结构 → `types/api.d.ts`。
|
||||||
- utils 与 composables 判据:**需要响应式状态或生命周期 → composables;否则 → utils**
|
- **禁止** `as any` / `@ts-ignore` / `@ts-expect-error`。
|
||||||
- 类型归位:实体类型 → `types/business/<page>.d.ts`(与 api 同名);接口结构 → `types/api.d.ts`
|
|
||||||
- **禁止 `as any` / `@ts-ignore` / `@ts-expect-error`**
|
|
||||||
|
|
||||||
## 后续使用方式(工作流)
|
### 导入规范
|
||||||
|
|
||||||
### 场景速查:想做什么 → 去找哪个文件
|
- 有别名(`@/`)的项目一律用别名;禁止多级跨层 `../../../`。
|
||||||
|
- uni-app 需在 `vite.config` 的 `resolve.alias` 或 `tsconfig` 的 `paths` 配置 `@/`。
|
||||||
|
|
||||||
| 想做的事 | 动哪个文件 | 注意 |
|
### 请求规范
|
||||||
| --------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------- |
|
|
||||||
| 给首页加一块新数据 | `api/home.ts` 加接口函数 → `stores/modules/home.ts` 加 action/state → `views/home/index.vue` 调 store action,结构放 `views/home/cpns/` 新组件 | 遵循数据流:页面 → store → api |
|
|
||||||
| 新增一个页面模块(如 news) | `types/business/news.d.ts` → `api/news.ts` → `stores/modules/news.ts` → `views/news/`(index.vue+index.ts+cpns) → `router/routes.ts` 注册 | 四者同名,走七步流程 |
|
|
||||||
| 页面要取数据 | 调对应 `use<Page>Store` 的 action(`storeToRefs` 取 state) | **禁止直接 import api** |
|
|
||||||
| 一个组件多个页面要用 | 放 `components/`(公共组件) | 从 `@/components` 导入 |
|
|
||||||
| 一个组件只有本页面用 | 放 `views/<page>/cpns/` | 禁止其他页面引用 |
|
|
||||||
| 改全站颜色/字体/间距 | `styles/variables.less` | 禁止组件内魔法值 |
|
|
||||||
| 图片懒加载 | 模板 `v-lazy`(`directives/lazy.ts`) | 勿手写滚动判断 |
|
|
||||||
| 通用逻辑(响应式) | `composables/` | 纯函数则 `utils/` |
|
|
||||||
| 弹窗/表单等小块 | 页面内 `cpns/` | 复用时上移 components/ |
|
|
||||||
| 路由新增页面 | `router/routes.ts` 注册 | component 指向 `@/views/<page>` |
|
|
||||||
|
|
||||||
### 新增页面模块七步流程(以"新闻 news"为例)
|
- 全项目**唯一**请求实例/封装:`utils/request.ts`;页面与组件禁止直接 `axios` / `uni.request` / `fetch`。
|
||||||
|
- baseURL 走环境变量(`import.meta.env.VITE_*`)。
|
||||||
|
- 错误统一由拦截器兜底,业务侧仅在需要特殊处理时 `catch`。
|
||||||
|
|
||||||
1. **类型**:`types/business/news.d.ts` 定义 `NewsItem / NewsQuery / PageResult`
|
---
|
||||||
2. **接口层**:`api/news.ts`(`getNewsList`、`getNewsDetail`,走 `request<T>`)
|
|
||||||
3. **数据层**:`stores/modules/news.ts`(`useNewsStore`,action 内调用 api 函数取数)
|
|
||||||
4. **页面**:`views/news/index.vue`(列表)+ `views/news/detail.vue`(详情)+ `views/news/index.ts`(出口 barrel)+ `views/news/cpns/`(独有组件)
|
|
||||||
5. **路由**:`router/routes.ts` 注册(`component: () => import('@/views/news')`,配 `meta.title`)
|
|
||||||
6. **复用检查**:被 ≥2 页面使用的组件上移 `components/`
|
|
||||||
7. **验证**:`pnpm build`(含 vue-tsc 类型检查)零错误
|
|
||||||
|
|
||||||
### 日常开发姿势
|
## 工作流
|
||||||
|
|
||||||
- **每次动手前**:按"第一步"读取目录,确认目标文件存在与现状,再决定新建还是修改。
|
### 场景速查:想做什么 → 改哪些文件
|
||||||
- **新建文件前**:对照"src/ 每个文件的作用"确认归属(api/stores/views 四者同名)。
|
|
||||||
- **改数据相关代码**:先确认数据流方向——页面只碰 store,store 只碰 api,api 只发请求。
|
| 想做的事 | 动作 |
|
||||||
- **组件归属**:先自问"有几个页面用它"——1 个 → cpns/;≥2 个 → components/。
|
| ---------------------- | ------------------------------------------------------------------------------------------ |
|
||||||
- **规格冲突时**:本 skill 为唯一现行规范;未覆盖场景 → 询问用户或按最贴近的既有模式执行后复述假设。
|
| 给已有页面加一块新数据 | api 加函数 → store 加 action/state → 页面调 action,UI 放该页 `cpns/` 新组件 |
|
||||||
|
| 新增业务模块 | 类型 → api → store → 页面目录(index.vue + cpns/) → 路由(Vue)或 `pages.json`(uni-app) |
|
||||||
|
| 页面要取数据 | 调 `use<Domain>Store`;**禁止**直接 import api |
|
||||||
|
| 组件多页要用 | 上移 `components/` |
|
||||||
|
| 组件仅本页用 | 留在该页面 `cpns/` |
|
||||||
|
| 改全局颜色/间距 | 样式变量文件(`variables.*` / `uni.scss`) |
|
||||||
|
| 小程序主包体积超标 | 把非首屏页面迁入 `subPackages` |
|
||||||
|
|
||||||
|
### 新增业务模块流程(以 `news` 为例)
|
||||||
|
|
||||||
|
1. **类型** `types/business/news.d.ts`
|
||||||
|
2. **接口** `api/news.ts`
|
||||||
|
3. **状态** `stores/modules/news.ts`(action 内调 api)
|
||||||
|
4. **页面** `views/news/index.vue`(或 `pages/news/index.vue`)+ `cpns/`
|
||||||
|
5. **注册** `router/routes.ts`(`component: () => import('@/views/news/index.vue')`)或 `pages.json`
|
||||||
|
6. **复用检查** ≥2 处复用的上移 `components/`
|
||||||
|
7. **验证** 类型检查 + 构建零错误(`pnpm build` / `npm run build` / `vue-tsc --noEmit`)
|
||||||
|
|
||||||
|
### 最小改动纪律
|
||||||
|
|
||||||
|
- 每次动手前先读现状,确认是"新建"还是"修改"。
|
||||||
|
- 只碰与需求相关的行;不顺手重构、不顺手换技术栈。
|
||||||
|
- 规范冲突时:项目内显式文档 > 本 skill;本 skill 未覆盖时,先说明假设再执行。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## 修改代码时的强制检查清单
|
## 修改代码时的强制检查清单
|
||||||
|
|
||||||
修改任何已存在文件时,逐条核对(不满足即视为违反规范,必须先修正再继续):
|
修改任何已存在文件时逐条核对,不满足必须先修正:
|
||||||
|
|
||||||
- [ ] 文件是否位于其职责对应的目录(接口在 api/、数据在 stores/modules/、页面在 views/<page>/ 等)
|
- [ ] 文件位于其职责对应目录(接口在 api/、状态在 stores/、页面在 views|pages/)
|
||||||
- [ ] **页面是否直接 import 了 api 层?(违规——数据必须经 store)**
|
- [ ] **页面是否直接 import 了 api?**(违规)
|
||||||
- [ ] **store 名 / api 文件名 / 页面目录名 / 类型文件名 是否与页面一致(可分层互查)**
|
- [ ] api / store / 页面 / 类型 是否同业务域命名一致
|
||||||
- [ ] 导入是否使用 `@/` 别名
|
- [ ] 页面目录是否只有 `index.vue`(+ 同模块次级页面)+ `cpns/`,**没有多余 `index.ts`**
|
||||||
- [ ] 组件归属是否正确:≥2 页面共用 → components/;单页面独有 → views/<page>/cpns/
|
- [ ] 私有组件是否在 `cpns/` 且无其他页面 import
|
||||||
- [ ] 不在组件里直接 new axios 实例 / 直接调用原生 fetch
|
- [ ] 导入使用 `@/` 别名,无多级跨层相对路径
|
||||||
- [ ] 样式是否使用 **less**(`<style lang="less" scoped>` / \*.less),颜色是否取自 variables.less
|
- [ ] 未在组件内直接 `axios` / `uni.request` / `fetch`
|
||||||
- [ ] 类型是否齐全(无 `as any`、无 `@ts-ignore`)
|
- [ ] 样式沿用项目既有预处理器,色值取自变量文件
|
||||||
- [ ] 新页面是否有完整三件套(index.vue + index.ts + cpns/)并在 router 注册
|
- [ ] uni-app:新页面已在 `pages.json` 注册;未把非首屏页放进主包;页面样式未加 `scoped`
|
||||||
- [ ] 运行时 `pnpm build`(含 vue-tsc 类型检查)零错误
|
- [ ] 无 `as any` / `@ts-ignore`
|
||||||
|
- [ ] 构建/类型检查零错误
|
||||||
|
|
||||||
> 本规范为项目强约束:**新增与修改的代码必须严格遵循**。发现不符合结构约定的代码,应指出问题并要求按规范调整,而不是放任通过。
|
> 发现不符合规范的历史代码:**指出问题并给出改法**,除非本次需求正好涉及,否则不擅自批量重构。
|
||||||
|
|||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -19,6 +19,7 @@ RTK.md
|
|||||||
specs2
|
specs2
|
||||||
.shots
|
.shots
|
||||||
docs
|
docs
|
||||||
|
.claude
|
||||||
|
|
||||||
# Editor directories and files
|
# Editor directories and files
|
||||||
.vscode/*
|
.vscode/*
|
||||||
|
|||||||
@@ -14,7 +14,6 @@
|
|||||||
{ "id": "1002", "billNo": "2026083222P345", "projectId": "1", "projectNo": "20260813ZK2Q5f45", "projectName": "社区康养智能服务系统", "userId": "1", "amount": "20100.00", "contractId": null, "billType": "PROGRESS", "periodName": "第二期", "periodRatio": "33.00", "status": "PENDING", "payChannel": null, "transactionNo": null, "tradeName": null, "payTime": null, "dueDate": null },
|
{ "id": "1002", "billNo": "2026083222P345", "projectId": "1", "projectNo": "20260813ZK2Q5f45", "projectName": "社区康养智能服务系统", "userId": "1", "amount": "20100.00", "contractId": null, "billType": "PROGRESS", "periodName": "第二期", "periodRatio": "33.00", "status": "PENDING", "payChannel": null, "transactionNo": null, "tradeName": null, "payTime": null, "dueDate": null },
|
||||||
{ "id": "1003", "billNo": "2026083222P345", "projectId": "1", "projectNo": "20260813ZK2Q5f45", "projectName": "社区康养智能服务系统", "userId": "1", "amount": "20100.00", "contractId": null, "billType": "FINAL", "periodName": "第三期", "periodRatio": "33.00", "status": "UNSTARTED", "payChannel": null, "transactionNo": null, "tradeName": null, "payTime": null, "dueDate": null }
|
{ "id": "1003", "billNo": "2026083222P345", "projectId": "1", "projectNo": "20260813ZK2Q5f45", "projectName": "社区康养智能服务系统", "userId": "1", "amount": "20100.00", "contractId": null, "billType": "FINAL", "periodName": "第三期", "periodRatio": "33.00", "status": "UNSTARTED", "payChannel": null, "transactionNo": null, "tradeName": null, "payTime": null, "dueDate": null }
|
||||||
],
|
],
|
||||||
"billPlans": [],
|
|
||||||
"invoices": [
|
"invoices": [
|
||||||
{ "id": "1", "billId": "1001", "invoiceTitle": "测试", "taxNo": null, "invoiceType": "电子普通发票", "amount": "20100.00", "status": "ISSUED", "invoiceNo": null, "invoiceFile": "https://example.com/inv.pdf", "applyTime": "2026-8-17 17:00", "invoiceDate": null, "createTime": "2026-8-17 17:00" },
|
{ "id": "1", "billId": "1001", "invoiceTitle": "测试", "taxNo": null, "invoiceType": "电子普通发票", "amount": "20100.00", "status": "ISSUED", "invoiceNo": null, "invoiceFile": "https://example.com/inv.pdf", "applyTime": "2026-8-17 17:00", "invoiceDate": null, "createTime": "2026-8-17 17:00" },
|
||||||
{ "id": "2", "billId": "1001", "invoiceTitle": "测试", "taxNo": null, "invoiceType": "电子普通发票", "amount": "20100.00", "status": "ISSUED", "invoiceNo": null, "invoiceFile": "https://example.com/inv2.pdf", "applyTime": "2026-8-17 17:00", "invoiceDate": null, "createTime": "2026-8-17 17:00" }
|
{ "id": "2", "billId": "1001", "invoiceTitle": "测试", "taxNo": null, "invoiceType": "电子普通发票", "amount": "20100.00", "status": "ISSUED", "invoiceNo": null, "invoiceFile": "https://example.com/inv2.pdf", "applyTime": "2026-8-17 17:00", "invoiceDate": null, "createTime": "2026-8-17 17:00" }
|
||||||
|
|||||||
7
package-lock.json
generated
7
package-lock.json
generated
@@ -12,6 +12,7 @@
|
|||||||
"axios": "^1.20.0",
|
"axios": "^1.20.0",
|
||||||
"element-plus": "^2.14.5",
|
"element-plus": "^2.14.5",
|
||||||
"pinia": "^4.0.3",
|
"pinia": "^4.0.3",
|
||||||
|
"qrcode-generator": "^2.0.4",
|
||||||
"vue": "^3.5.42",
|
"vue": "^3.5.42",
|
||||||
"vue-router": "^4.6.4"
|
"vue-router": "^4.6.4"
|
||||||
},
|
},
|
||||||
@@ -1836,6 +1837,12 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"optional": true
|
"optional": true
|
||||||
},
|
},
|
||||||
|
"node_modules/qrcode-generator": {
|
||||||
|
"version": "2.0.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/qrcode-generator/-/qrcode-generator-2.0.4.tgz",
|
||||||
|
"integrity": "sha512-mZSiP6RnbHl4xL2Ap5HfkjLnmxfKcPWpWe/c+5XxCuetEenqmNFf1FH/ftXPCtFG5/TDobjsjz6sSNL0Sr8Z9g==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/rolldown": {
|
"node_modules/rolldown": {
|
||||||
"version": "1.2.10",
|
"version": "1.2.10",
|
||||||
"resolved": "https://registry.npmmirror.com/rolldown/-/rolldown-1.2.10.tgz",
|
"resolved": "https://registry.npmmirror.com/rolldown/-/rolldown-1.2.10.tgz",
|
||||||
|
|||||||
@@ -1,16 +1,24 @@
|
|||||||
import { request, CLIENT_ID } from '@/utils/request'
|
import { request, CLIENT_ID } from '@/utils/request'
|
||||||
import type { LoginResult as AuthLoginResult, RegisterResult } from '@/types/business/auth'
|
import type {
|
||||||
|
LoginResult as AuthLoginResult,
|
||||||
|
RegisterResult,
|
||||||
|
} from '@/types/business/auth'
|
||||||
import type {
|
import type {
|
||||||
LoginBySmsParams,
|
LoginBySmsParams,
|
||||||
LoginResult,
|
LoginResult,
|
||||||
|
RegisterParams,
|
||||||
ResetPasswordParams,
|
ResetPasswordParams,
|
||||||
|
SmsCodeParams,
|
||||||
User,
|
User,
|
||||||
} from '@/types/business/user'
|
} from '@/types/business/user'
|
||||||
import { isPhone, isValidPassword } from '@/utils/validate'
|
import { isPhone, isValidPassword } from '@/utils/validate'
|
||||||
|
|
||||||
export const PC_CLIENT_ID = CLIENT_ID
|
export const PC_CLIENT_ID = CLIENT_ID
|
||||||
|
|
||||||
export function loginByAccountApi(data: { username: string; password: string }): Promise<AuthLoginResult> {
|
export function loginByAccountApi(data: {
|
||||||
|
username: string
|
||||||
|
password: string
|
||||||
|
}): Promise<AuthLoginResult> {
|
||||||
return request<AuthLoginResult>({
|
return request<AuthLoginResult>({
|
||||||
url: '/auth/login',
|
url: '/auth/login',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
@@ -23,33 +31,39 @@ export function loginByAccountApi(data: { username: string; password: string }):
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function registerByAccountApi(data: { username: string; password: string }): Promise<RegisterResult> {
|
export function registerByAccountApi(
|
||||||
|
data: RegisterParams,
|
||||||
|
): Promise<RegisterResult> {
|
||||||
return request<RegisterResult>({
|
return request<RegisterResult>({
|
||||||
url: '/auth/register',
|
url: '/web/auth/register',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data: {
|
data: {
|
||||||
username: data.username,
|
phoneNumber: data.phoneNumber,
|
||||||
|
smsCode: data.smsCode,
|
||||||
password: data.password,
|
password: data.password,
|
||||||
userType: 'sys_user',
|
confirmPassword: data.confirmPassword,
|
||||||
clientId: PC_CLIENT_ID,
|
|
||||||
grantType: 'password',
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(api): 以下为原 mock 逻辑(保留,待后端对应接口就绪后替换)
|
export function sendSmsCode(data: SmsCodeParams): Promise<void> {
|
||||||
|
return request<void>({
|
||||||
|
url: '/web/auth/sms/code',
|
||||||
|
method: 'post',
|
||||||
|
data: {
|
||||||
|
phoneNumber: data.phoneNumber,
|
||||||
|
scene: data.scene,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const SIX_DIGIT_CODE = /^\d{6}$/
|
const SIX_DIGIT_CODE = /^\d{6}$/
|
||||||
|
|
||||||
export function sendSmsCode(phone: string): Promise<void> {
|
|
||||||
if (!isPhone(phone)) return Promise.reject(new Error('手机号格式不正确'))
|
|
||||||
return Promise.resolve()
|
|
||||||
}
|
|
||||||
|
|
||||||
export function loginBySms(params: LoginBySmsParams): Promise<LoginResult> {
|
export function loginBySms(params: LoginBySmsParams): Promise<LoginResult> {
|
||||||
const { phone, code } = params
|
const { phone, code } = params
|
||||||
if (!isPhone(phone)) return Promise.reject(new Error('手机号格式不正确'))
|
if (!isPhone(phone)) return Promise.reject(new Error('手机号格式不正确'))
|
||||||
if (!SIX_DIGIT_CODE.test(code)) return Promise.reject(new Error('验证码格式不正确,应为6位数字'))
|
if (!SIX_DIGIT_CODE.test(code))
|
||||||
|
return Promise.reject(new Error('验证码格式不正确,应为6位数字'))
|
||||||
const user: User = {
|
const user: User = {
|
||||||
id: 'u1',
|
id: 'u1',
|
||||||
nickname: '王永志',
|
nickname: '王永志',
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { request, serializeQuery } from '@/utils/request'
|
|||||||
import type {
|
import type {
|
||||||
CaseSelectionModel,
|
CaseSelectionModel,
|
||||||
ProjectCaseAndCaseCountVo,
|
ProjectCaseAndCaseCountVo,
|
||||||
|
ProjectCaseCountResultVo,
|
||||||
ProjectCaseUserBo,
|
ProjectCaseUserBo,
|
||||||
ProjectCaseVo,
|
ProjectCaseVo,
|
||||||
} from '@/types/business/cases'
|
} from '@/types/business/cases'
|
||||||
@@ -42,6 +43,14 @@ export function getCaseCategories(): Promise<CaseSelectionModel> {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 案例总数与按业务类型统计(已按案例数倒序,无案例分类补 0)。 */
|
||||||
|
export function getProjectCaseCount(): Promise<ProjectCaseCountResultVo> {
|
||||||
|
return request<ProjectCaseCountResultVo>({
|
||||||
|
url: '/web/projectCase/count',
|
||||||
|
method: 'get',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export function getFeaturedCases(type?: string): Promise<ProjectCaseVo[]> {
|
export function getFeaturedCases(type?: string): Promise<ProjectCaseVo[]> {
|
||||||
return request<ProjectCaseVo[]>({
|
return request<ProjectCaseVo[]>({
|
||||||
url: '/web/projectCase/mostViewed',
|
url: '/web/projectCase/mostViewed',
|
||||||
|
|||||||
@@ -1,102 +1,94 @@
|
|||||||
import type { FileInfo, PageResult } from '@/types/api'
|
import type {
|
||||||
import type { Contract, ContractQuery } from '@/types/business/contract'
|
ContractPageResult,
|
||||||
|
ContractPreviewVo,
|
||||||
|
ContractQrTokenVo,
|
||||||
|
ContractQuery,
|
||||||
|
ContractSignProgressVo,
|
||||||
|
ContractVo,
|
||||||
|
} from '@/types/business/contract'
|
||||||
|
import { request } from '@/utils/request'
|
||||||
|
|
||||||
// TODO(api): 待接口文档到位后,将以下 mock 替换为 request<T> 调用
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
// GET /web/contract/page → 合同中心列表(表格分页)
|
||||||
|
// pageNum/pageSize 分页;keyword 模糊匹配合同编号 / 标题 / 项目名
|
||||||
|
// 返回 { total, rows: ContractVo[] }
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
function mockFile(name: string, size: number, uploadTime: string): FileInfo {
|
export function getContractList(query: ContractQuery): Promise<ContractPageResult> {
|
||||||
return { name, size, uploadTime, url: '' }
|
return request<ContractPageResult>({
|
||||||
}
|
url: '/web/contract/page',
|
||||||
|
method: 'get',
|
||||||
const DETAIL_ID = 'contract-001'
|
params: {
|
||||||
|
keyword: query.keyword || undefined,
|
||||||
const MOCK_CONTRACTS: Contract[] = [
|
pageNum: query.pageNum,
|
||||||
{
|
pageSize: query.pageSize,
|
||||||
id: 'contract-001',
|
},
|
||||||
contractNo: 'C8K2M202408001',
|
|
||||||
contractName: '智慧城市建设项目技术服务合同',
|
|
||||||
contractType: '互联网软件通用/app开发',
|
|
||||||
contractAmount: 201000,
|
|
||||||
relatedProjectName: '智慧城市大数据平台建设项目',
|
|
||||||
projectNo: 'P8K2M202408001',
|
|
||||||
signStatus: '履行中',
|
|
||||||
signDate: '2026-8-17 14:00',
|
|
||||||
effectiveDate: '2026-8-17 14:00',
|
|
||||||
expiryDate: '2026-8-17 14:00',
|
|
||||||
files: [mockFile('项目需求规格说明书.pdf', 2516582, '2026-8-17 14:00')],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'contract-002',
|
|
||||||
contractNo: 'C8K2M202408002',
|
|
||||||
contractName: '智慧城市建设项目硬件电路设计合同',
|
|
||||||
contractType: '硬件电路通用/电路版设计',
|
|
||||||
contractAmount: 180000,
|
|
||||||
relatedProjectName: '三甲医院指挥医疗信息化系统',
|
|
||||||
projectNo: 'P8K2M202408001',
|
|
||||||
signStatus: '已过期',
|
|
||||||
signDate: '2026-8-17 14:00',
|
|
||||||
effectiveDate: '2026-8-17 14:00',
|
|
||||||
expiryDate: '2026-8-17 14:00',
|
|
||||||
files: [mockFile('硬件电路设计合同.pdf', 1468006, '2026-8-17 14:00')],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'contract-003',
|
|
||||||
contractNo: 'C8K2M202408003',
|
|
||||||
contractName: '智慧城市建设项目物联网全案合同',
|
|
||||||
contractType: '物联网全案通用/一套门禁卡',
|
|
||||||
contractAmount: 96000,
|
|
||||||
relatedProjectName: '社区康养智能服务系统',
|
|
||||||
projectNo: 'P8K2M202408001',
|
|
||||||
signStatus: '待签署',
|
|
||||||
effectiveDate: '2026-8-17 14:00',
|
|
||||||
expiryDate: '2026-8-17 14:00',
|
|
||||||
files: [mockFile('物联网全案合同.pdf', 1258291, '2026-8-17 14:00')],
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
const CONTRACT_DETAIL: Contract = {
|
|
||||||
id: DETAIL_ID,
|
|
||||||
contractNo: 'C8K2M202408001',
|
|
||||||
contractName: '社区康养智能服务系统开发合同',
|
|
||||||
contractType: '互联网软件开发',
|
|
||||||
contractAmount: 201000,
|
|
||||||
relatedProjectName: '社区康养智能服务系统',
|
|
||||||
projectNo: '20260813ZZ251245',
|
|
||||||
signStatus: '履行中',
|
|
||||||
signDate: '2024-10-15',
|
|
||||||
effectiveDate: '2024-10-15',
|
|
||||||
expiryDate: '2024-10-15',
|
|
||||||
files: [mockFile('项目需求规格说明书.pdf', 2516582, '2024-10-15')],
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getContractList(query: ContractQuery): Promise<PageResult<Contract>> {
|
|
||||||
const filtered = MOCK_CONTRACTS.filter((item) => {
|
|
||||||
if (
|
|
||||||
query.keyword
|
|
||||||
&& !item.contractName.includes(query.keyword)
|
|
||||||
&& !item.contractNo.includes(query.keyword)
|
|
||||||
) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
const pageSize = query.pageSize > 0 ? query.pageSize : 8
|
|
||||||
const start = (query.page - 1) * pageSize
|
|
||||||
return Promise.resolve({
|
|
||||||
list: filtered.slice(start, start + pageSize),
|
|
||||||
total: filtered.length,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getContractDetail(id: string): Promise<Contract | null> {
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
if (id === DETAIL_ID) return Promise.resolve({ ...CONTRACT_DETAIL, files: [...CONTRACT_DETAIL.files] })
|
// GET /web/contract/{id} → 合同详情 ContractVo
|
||||||
const found = MOCK_CONTRACTS.find((item) => item.id === id) ?? null
|
// GET /web/contract/preview/{id} → ContractPreviewVo(合同 PDF 地址)
|
||||||
return Promise.resolve(found ? { ...found, files: [...found.files] } : null)
|
// GET /web/contract/download/{id} → String(仅「已签署」合同可下载)
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
export function getContractDetail(id: string): Promise<ContractVo> {
|
||||||
|
return request<ContractVo>({
|
||||||
|
url: `/web/contract/${id}`,
|
||||||
|
method: 'get',
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getSignQr(_id: string): Promise<{ expiresInSeconds: number }> {
|
export function getContractPreview(id: string): Promise<ContractPreviewVo> {
|
||||||
return Promise.resolve({ expiresInSeconds: 272 })
|
return request<ContractPreviewVo>({
|
||||||
|
url: `/web/contract/preview/${id}`,
|
||||||
|
method: 'get',
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function refreshSignQr(_id: string): Promise<{ expiresInSeconds: number }> {
|
export function getContractDownloadUrl(id: string): Promise<string> {
|
||||||
return Promise.resolve({ expiresInSeconds: 272 })
|
return request<string>({
|
||||||
|
url: `/web/contract/download/${id}`,
|
||||||
|
method: 'get',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
// GET /web/contract/sign/progress/{id} → 签署进度 ContractSignProgressVo
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
export function getContractSignProgress(id: string): Promise<ContractSignProgressVo> {
|
||||||
|
return request<ContractSignProgressVo>({
|
||||||
|
url: `/web/contract/sign/progress/${id}`,
|
||||||
|
method: 'get',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
// POST /web/contract/sign/qr-init/{contractId} → String(完整落地页 URL,Redis TTL 5 分钟)
|
||||||
|
// GET /web/contract/sign/qr-status/{contractId} → Boolean(sign_status === SIGNED)
|
||||||
|
// GET /web/contract/sign/qr-token/{token} → ContractQrTokenVo(扫码落地页数据)
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
export function initContractSignQr(contractId: string): Promise<string> {
|
||||||
|
return request<string>({
|
||||||
|
url: `/web/contract/sign/qr-init/${contractId}`,
|
||||||
|
method: 'post',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getContractSignQrStatus(contractId: string): Promise<boolean> {
|
||||||
|
return request<boolean>({
|
||||||
|
url: `/web/contract/sign/qr-status/${contractId}`,
|
||||||
|
method: 'get',
|
||||||
|
// 轮询接口:失败由调用方静默降级,避免每 3 秒弹一次错误提示
|
||||||
|
silent: true,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getContractSignQrToken(token: string): Promise<ContractQrTokenVo> {
|
||||||
|
return request<ContractQrTokenVo>({
|
||||||
|
url: `/web/contract/sign/qr-token/${encodeURIComponent(token)}`,
|
||||||
|
method: 'get',
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,377 +1,328 @@
|
|||||||
import type { PageResult } from '@/types/api'
|
|
||||||
import type {
|
import type {
|
||||||
Bill,
|
|
||||||
BillQuery,
|
BillQuery,
|
||||||
BillVo,
|
DictOptionVo,
|
||||||
FinanceStats,
|
FinanceBillStatisticsVo,
|
||||||
Invoice,
|
FinanceBillVo,
|
||||||
InvoiceQuery,
|
FinanceInvoiceApplyBo,
|
||||||
InvoiceTitle,
|
FinanceInvoiceAvailableVo,
|
||||||
InvoiceTitlePayload,
|
FinanceInvoicePreviewVo,
|
||||||
PayMethod,
|
FinanceInvoiceQuery,
|
||||||
PayOrderResponse,
|
FinanceInvoiceSendEmailBo,
|
||||||
Payment,
|
FinanceInvoiceTitleBo,
|
||||||
PaymentResult,
|
FinanceInvoiceTitleVo,
|
||||||
|
FinanceInvoiceVo,
|
||||||
|
FinancePageResult,
|
||||||
|
FinancePayQueryVo,
|
||||||
|
FinancePayResultVo,
|
||||||
|
FinanceRefundBo,
|
||||||
|
FinanceRefundQuery,
|
||||||
|
FinanceRefundVo,
|
||||||
|
FinanceSummaryQuery,
|
||||||
|
FinanceSummaryVo,
|
||||||
|
PayChannelCode,
|
||||||
|
PayChannelVo,
|
||||||
} from '@/types/business/finance'
|
} from '@/types/business/finance'
|
||||||
import { toBills, toPlanBills, type PlanLike } from '@/utils/billVo'
|
import { toBillStatusCode } from '@/utils/billVo'
|
||||||
import { toPayMethod } from '@/utils/payMeta'
|
import service, { request } from '@/utils/request'
|
||||||
import { request } from '@/utils/request'
|
|
||||||
|
|
||||||
const MOCK_BILLS: Bill[] = [
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
{
|
// GET /web/finance/summary → 财务中心首页统计(累计消费总额 + 业务类型分布)
|
||||||
id: 'bill-001',
|
// year / dimension(YEAR|MONTH|QUARTER) / month(1-12) / quarter(1-4)
|
||||||
planName: '第一期·预付款 比例33%',
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
billNo: '20260813ZZ251245',
|
|
||||||
tradeNo: 'T20260819153035678K2M001',
|
|
||||||
projectName: '某大型银行数字化转型方案',
|
|
||||||
amount: 20000,
|
|
||||||
status: '已支付',
|
|
||||||
createTime: '2026-8-17 14:00',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'bill-002',
|
|
||||||
planName: '第二期·进度款 比例30%',
|
|
||||||
billNo: '20260813ZZ251246',
|
|
||||||
projectName: '智慧城市大数据平台建设项目',
|
|
||||||
amount: 20100,
|
|
||||||
status: '待支付',
|
|
||||||
createTime: '2026-8-17 14:00',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'bill-003',
|
|
||||||
planName: '第三期·验收款 比例27%',
|
|
||||||
billNo: '20260813ZZ251247',
|
|
||||||
projectName: '三甲医院指挥医疗信息化系统',
|
|
||||||
amount: 20000,
|
|
||||||
status: '未到期',
|
|
||||||
createTime: '2026-8-17 14:00',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'bill-004',
|
|
||||||
planName: '第四期·尾款 比例10%',
|
|
||||||
billNo: '20260813ZZ251248',
|
|
||||||
projectName: '智慧城市大数据平台建设项目',
|
|
||||||
amount: 20100,
|
|
||||||
status: '未到期',
|
|
||||||
createTime: '2026-8-17 14:00',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'bill-005',
|
|
||||||
planName: '第二期·进度款 比例30%',
|
|
||||||
billNo: '20260813ZZ251249',
|
|
||||||
projectName: '三甲医院指挥医疗信息化系统',
|
|
||||||
amount: 20100,
|
|
||||||
status: '待支付',
|
|
||||||
createTime: '2026-8-16 10:30',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'bill-006',
|
|
||||||
planName: '第一期·预付款 比例33%',
|
|
||||||
billNo: '20260813ZZ251250',
|
|
||||||
tradeNo: 'T20260819153035678K2M002',
|
|
||||||
projectName: '某大型银行数字化转型方案',
|
|
||||||
amount: 20000,
|
|
||||||
status: '已支付',
|
|
||||||
createTime: '2026-8-15 09:12',
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
const MOCK_INVOICES: Invoice[] = [
|
export function getFinanceSummary(query: FinanceSummaryQuery = {}): Promise<FinanceSummaryVo> {
|
||||||
{
|
const dimension = query.dimension ?? 'YEAR'
|
||||||
id: 'invoice-001',
|
return request<FinanceSummaryVo>({
|
||||||
planName: '第一期·预付款 比例33%',
|
url: '/web/finance/summary',
|
||||||
billNo: '20260813ZZ251245',
|
method: 'get',
|
||||||
tradeNo: 'T20260819153035678K2M001',
|
params: {
|
||||||
projectName: '某大型银行数字化转型方案',
|
year: query.year,
|
||||||
amount: 20000,
|
dimension,
|
||||||
status: '已开票',
|
month: dimension === 'MONTH' ? query.month : undefined,
|
||||||
applyTime: '2026-8-17 14:00',
|
quarter: dimension === 'QUARTER' ? query.quarter : undefined,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
id: 'invoice-002',
|
|
||||||
planName: '第一期·预付款 比例33%',
|
|
||||||
billNo: '20260813ZZ251250',
|
|
||||||
tradeNo: 'T20260819153035678K2M002',
|
|
||||||
projectName: '某大型银行数字化转型方案',
|
|
||||||
amount: 20000,
|
|
||||||
status: '开票中',
|
|
||||||
applyTime: '2026-8-17 14:00',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'invoice-003',
|
|
||||||
planName: '第二期·进度款 比例30%',
|
|
||||||
billNo: '20260813ZZ251249',
|
|
||||||
projectName: '三甲医院指挥医疗信息化系统',
|
|
||||||
amount: 20100,
|
|
||||||
status: '未开票',
|
|
||||||
applyTime: '2026-8-17 14:00',
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
const MOCK_TITLES: InvoiceTitle[] = [
|
|
||||||
{
|
|
||||||
id: 'title-001',
|
|
||||||
type: '企业单位',
|
|
||||||
title: '山东日照有限有限公司',
|
|
||||||
taxNo: '344683434513543543545535',
|
|
||||||
isDefault: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'title-002',
|
|
||||||
type: '企业单位',
|
|
||||||
title: '山东省一周练七次有限公司',
|
|
||||||
taxNo: '6856754615216565476846',
|
|
||||||
isDefault: false,
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
const MOCK_PAYMENTS = new Map<string, Payment>()
|
|
||||||
|
|
||||||
const MOCK_RESULTS = new Map<string, PaymentResult>()
|
|
||||||
MOCK_RESULTS.set('bill-001', {
|
|
||||||
method: 'wechat',
|
|
||||||
amount: 20000,
|
|
||||||
payTime: '2026-01-21 15:00:00',
|
|
||||||
tradeNo: 'T20260819153035678K2M001',
|
|
||||||
bills: [{ ...MOCK_BILLS[0] }],
|
|
||||||
})
|
|
||||||
MOCK_RESULTS.set('bill-006', {
|
|
||||||
method: 'wechat',
|
|
||||||
amount: 20000,
|
|
||||||
payTime: '2026-01-21 15:00:00',
|
|
||||||
tradeNo: 'T20260819153035678K2M002',
|
|
||||||
bills: [{ ...MOCK_BILLS[5] }],
|
|
||||||
})
|
|
||||||
|
|
||||||
const DEFAULT_STATS: FinanceStats = {
|
|
||||||
totalExpense: 1726823900,
|
|
||||||
month: '2026年1',
|
|
||||||
pendingCount: 3,
|
|
||||||
distribution: [
|
|
||||||
{ name: '生产智造', value: 25, color: '#3370ff' },
|
|
||||||
{ name: '物联网全案', value: 25, color: '#34c724' },
|
|
||||||
{ name: '硬件电路', value: 25, color: '#ff8f1f' },
|
|
||||||
{ name: '互联网软件', value: 25, color: '#f54a45' },
|
|
||||||
],
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getFinanceStats(period?: string): Promise<FinanceStats> {
|
|
||||||
void period
|
|
||||||
return Promise.resolve(structuredClone(DEFAULT_STATS))
|
|
||||||
}
|
|
||||||
|
|
||||||
function isRealBillId(id: string): boolean {
|
|
||||||
return /^\d+$/.test(id)
|
|
||||||
}
|
|
||||||
|
|
||||||
async function fetchOwnBills(): Promise<Bill[]> {
|
|
||||||
const rows = await request<BillVo[]>({ url: '/web/bill/list', method: 'get' })
|
|
||||||
return toBills(rows)
|
|
||||||
}
|
|
||||||
|
|
||||||
function matchBillKeyword(item: Bill, keyword: string): boolean {
|
|
||||||
if (!keyword) return true
|
|
||||||
return (
|
|
||||||
item.planName.includes(keyword) ||
|
|
||||||
item.billNo.includes(keyword) ||
|
|
||||||
item.projectName.includes(keyword) ||
|
|
||||||
(item.tradeNo?.includes(keyword) ?? false)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function getBillList(query: BillQuery): Promise<PageResult<Bill>> {
|
|
||||||
const all = await fetchOwnBills()
|
|
||||||
const filtered = all.filter((item) => {
|
|
||||||
if (query.status !== 'all' && item.status !== query.status) return false
|
|
||||||
return matchBillKeyword(item, query.keyword)
|
|
||||||
})
|
|
||||||
const start = (query.page - 1) * query.pageSize
|
|
||||||
return { list: filtered.slice(start, start + query.pageSize), total: filtered.length }
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function getBillDetail(id: string): Promise<Bill | null> {
|
|
||||||
const rows = await request<BillVo[]>({ url: '/web/bill/list', method: 'get', params: { ids: id } })
|
|
||||||
return toBills(rows)[0] ?? null
|
|
||||||
}
|
|
||||||
|
|
||||||
// ═══════════════════════════════════════════════════════════════════════
|
|
||||||
// ---------------------------------------------------------------------
|
|
||||||
// ═══════════════════════════════════════════════════════════════════════
|
|
||||||
|
|
||||||
export function createPayment(billId: string, method: PayMethod): Promise<Payment> {
|
|
||||||
const bill = MOCK_BILLS.find((item) => item.id === billId)
|
|
||||||
if (!bill) return Promise.reject(new Error('账单不存在'))
|
|
||||||
const payment: Payment = {
|
|
||||||
billId,
|
|
||||||
method,
|
|
||||||
amount: bill.amount,
|
|
||||||
qrExpiresInSeconds: 300,
|
|
||||||
}
|
|
||||||
MOCK_PAYMENTS.set(billId, payment)
|
|
||||||
return Promise.resolve({ ...payment })
|
|
||||||
}
|
|
||||||
|
|
||||||
export function switchPaymentMethod(billId: string, method: PayMethod): Promise<Payment> {
|
|
||||||
return createPayment(billId, method)
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function getPayResult(billId: string): Promise<PaymentResult | null> {
|
|
||||||
if (isRealBillId(billId)) {
|
|
||||||
const bill = await getBillDetail(billId)
|
|
||||||
if (!bill || bill.status !== '已支付') return null
|
|
||||||
return {
|
|
||||||
method: toPayMethod(bill.payChannel),
|
|
||||||
amount: bill.amount,
|
|
||||||
payTime: bill.payTime ?? '—',
|
|
||||||
tradeNo: bill.tradeNo ?? '—',
|
|
||||||
bills: [bill],
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return getLegacyPayResult(billId)
|
|
||||||
}
|
|
||||||
|
|
||||||
function getLegacyPayResult(billId: string): Promise<PaymentResult | null> {
|
|
||||||
const existing = MOCK_RESULTS.get(billId)
|
|
||||||
if (existing) return Promise.resolve(structuredClone(existing))
|
|
||||||
|
|
||||||
const payment = MOCK_PAYMENTS.get(billId)
|
|
||||||
const bill = MOCK_BILLS.find((item) => item.id === billId)
|
|
||||||
if (!payment || !bill) return Promise.resolve(null)
|
|
||||||
|
|
||||||
const tradeNo = bill.tradeNo ?? 'T20260819153035678K2M001'
|
|
||||||
if (bill.status !== '已支付') {
|
|
||||||
bill.status = '已支付'
|
|
||||||
bill.tradeNo = tradeNo
|
|
||||||
}
|
|
||||||
const result: PaymentResult = {
|
|
||||||
method: payment.method,
|
|
||||||
amount: payment.amount,
|
|
||||||
payTime: '2026-01-21 15:00:00',
|
|
||||||
tradeNo,
|
|
||||||
bills: [{ ...bill }],
|
|
||||||
}
|
|
||||||
MOCK_RESULTS.set(billId, result)
|
|
||||||
return Promise.resolve(structuredClone(result))
|
|
||||||
}
|
|
||||||
|
|
||||||
function matchInvoiceKeyword(item: Invoice, keyword: string): boolean {
|
|
||||||
if (!keyword) return true
|
|
||||||
return (
|
|
||||||
item.planName.includes(keyword) ||
|
|
||||||
item.billNo.includes(keyword) ||
|
|
||||||
item.projectName.includes(keyword) ||
|
|
||||||
(item.tradeNo?.includes(keyword) ?? false)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getInvoiceList(query: InvoiceQuery): Promise<PageResult<Invoice>> {
|
|
||||||
const filtered = MOCK_INVOICES.filter((item) => {
|
|
||||||
if (query.status !== 'all' && item.status !== query.status) return false
|
|
||||||
return matchInvoiceKeyword(item, query.keyword)
|
|
||||||
})
|
|
||||||
const start = (query.page - 1) * query.pageSize
|
|
||||||
return Promise.resolve({
|
|
||||||
list: filtered.slice(start, start + query.pageSize).map((item) => ({ ...item })),
|
|
||||||
total: filtered.length,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function applyInvoice(id: string): Promise<Invoice> {
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
const found = MOCK_INVOICES.find((item) => item.id === id)
|
// GET /web/bill/page → 账单分页列表 { total, rows }
|
||||||
if (!found) return Promise.reject(new Error('发票记录不存在'))
|
// GET /web/bill/statistics → 账单顶部统计(金额合计 / 总笔数 / 待支付笔数)
|
||||||
found.status = '开票中'
|
// GET /web/bill/{id} → 账单详情
|
||||||
return Promise.resolve({ ...found })
|
// 查询参数:keyword / status(UNSTARTED/PENDING/PAID/CANCELLED) / bizType /
|
||||||
}
|
// pageNum / pageSize / orderByColumn / isAsc
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
export function getInvoiceTitles(): Promise<InvoiceTitle[]> {
|
function toBillFilter(query: BillQuery): Record<string, unknown> {
|
||||||
return Promise.resolve(MOCK_TITLES.map((item) => ({ ...item })))
|
return {
|
||||||
}
|
keyword: query.keyword || undefined,
|
||||||
|
status: toBillStatusCode(query.status),
|
||||||
export function createInvoiceTitle(payload: InvoiceTitlePayload): Promise<InvoiceTitle> {
|
|
||||||
const created: InvoiceTitle = {
|
|
||||||
id: `title-${Date.now()}`,
|
|
||||||
...payload,
|
|
||||||
isDefault: false,
|
|
||||||
}
|
}
|
||||||
MOCK_TITLES.push(created)
|
|
||||||
return Promise.resolve({ ...created })
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function updateInvoiceTitle(id: string, payload: InvoiceTitlePayload): Promise<InvoiceTitle> {
|
export function getBillList(query: BillQuery): Promise<FinancePageResult<FinanceBillVo>> {
|
||||||
const found = MOCK_TITLES.find((item) => item.id === id)
|
return request<FinancePageResult<FinanceBillVo>>({
|
||||||
if (!found) return Promise.reject(new Error('抬头不存在'))
|
url: '/web/bill/page',
|
||||||
found.type = payload.type
|
method: 'get',
|
||||||
found.title = payload.title
|
params: {
|
||||||
found.taxNo = payload.taxNo
|
...toBillFilter(query),
|
||||||
return Promise.resolve({ ...found })
|
pageNum: query.page,
|
||||||
|
pageSize: query.pageSize,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getBillStatistics(query: BillQuery): Promise<FinanceBillStatisticsVo> {
|
||||||
|
return request<FinanceBillStatisticsVo>({
|
||||||
|
url: '/web/bill/statistics',
|
||||||
|
method: 'get',
|
||||||
|
params: toBillFilter(query),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getBillDetail(id: string): Promise<FinanceBillVo> {
|
||||||
|
return request<FinanceBillVo>({
|
||||||
|
url: `/web/bill/${id}`,
|
||||||
|
method: 'get',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
// GET /web/bill/export?format=excel|pdf → 导出账单明细(二进制文件流)
|
||||||
|
// 该接口不返回统一 JSON 包装,直接用 axios 实例取 Blob。
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
export type ExportFormat = 'excel' | 'pdf'
|
||||||
|
|
||||||
|
export async function exportBillReport(
|
||||||
|
query: BillQuery,
|
||||||
|
format: ExportFormat = 'excel',
|
||||||
|
): Promise<Blob> {
|
||||||
|
const resp = await service.get<Blob>('/web/bill/export', {
|
||||||
|
params: {
|
||||||
|
...toBillFilter(query),
|
||||||
|
format,
|
||||||
|
},
|
||||||
|
responseType: 'blob',
|
||||||
|
})
|
||||||
|
return resp.data
|
||||||
|
}
|
||||||
|
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
// GET /web/pay/channels → 可用支付通道
|
||||||
|
// POST /web/pay/bill → 单笔支付 { id, payChannel } → { outTradeNo, qrCode }
|
||||||
|
// POST /web/pay/bill/batch → 多账单合并支付 { ids, payChannel } → { outTradeNo, qrCode }
|
||||||
|
// GET /web/pay/query/{outTradeNo} → 支付结果(status/transactionNo/payTime)
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
export function getPayChannels(): Promise<PayChannelVo[]> {
|
||||||
|
return request<PayChannelVo[]>({
|
||||||
|
url: '/web/pay/channels',
|
||||||
|
method: 'get',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function payBill(id: string, payChannel: PayChannelCode): Promise<FinancePayResultVo> {
|
||||||
|
return request<FinancePayResultVo>({
|
||||||
|
url: '/web/pay/bill',
|
||||||
|
method: 'post',
|
||||||
|
data: { id, payChannel },
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function payBills(ids: string[], payChannel: PayChannelCode): Promise<FinancePayResultVo> {
|
||||||
|
return request<FinancePayResultVo>({
|
||||||
|
url: '/web/pay/bill/batch',
|
||||||
|
method: 'post',
|
||||||
|
data: { ids, payChannel },
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** silent:轮询时静默失败,避免瞬时网络异常反复弹提示。 */
|
||||||
|
export function queryPayResult(outTradeNo: string, silent = false): Promise<FinancePayQueryVo> {
|
||||||
|
return request<FinancePayQueryVo>({
|
||||||
|
url: `/web/pay/query/${encodeURIComponent(outTradeNo)}`,
|
||||||
|
method: 'get',
|
||||||
|
silent,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
// POST /web/pay/refund → 申请退款,返回退款单 ID
|
||||||
|
// GET /web/pay/refund/page → 我的退款分页列表
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
export function applyRefund(payload: FinanceRefundBo): Promise<number> {
|
||||||
|
return request<number>({
|
||||||
|
url: '/web/pay/refund',
|
||||||
|
method: 'post',
|
||||||
|
data: payload,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getRefundPage(query: FinanceRefundQuery): Promise<FinancePageResult<FinanceRefundVo>> {
|
||||||
|
return request<FinancePageResult<FinanceRefundVo>>({
|
||||||
|
url: '/web/pay/refund/page',
|
||||||
|
method: 'get',
|
||||||
|
params: {
|
||||||
|
billId: query.billId,
|
||||||
|
amount: query.amount,
|
||||||
|
reason: query.reason || undefined,
|
||||||
|
status: query.status || undefined,
|
||||||
|
orderByColumn: query.orderByColumn,
|
||||||
|
isAsc: query.isAsc,
|
||||||
|
pageNum: query.page,
|
||||||
|
pageSize: query.pageSize,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
// 发票抬头
|
||||||
|
// GET /web/finance/invoice/title/list
|
||||||
|
// POST /web/finance/invoice/title
|
||||||
|
// PUT /web/finance/invoice/title
|
||||||
|
// DELETE /web/finance/invoice/title/{id}
|
||||||
|
// PUT /web/finance/invoice/title/default/{id}
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
export function getInvoiceTitleList(): Promise<FinanceInvoiceTitleVo[]> {
|
||||||
|
return request<FinanceInvoiceTitleVo[]>({
|
||||||
|
url: '/web/finance/invoice/title/list',
|
||||||
|
method: 'get',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createInvoiceTitle(payload: FinanceInvoiceTitleBo): Promise<number> {
|
||||||
|
return request<number>({
|
||||||
|
url: '/web/finance/invoice/title',
|
||||||
|
method: 'post',
|
||||||
|
data: payload,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function updateInvoiceTitle(payload: FinanceInvoiceTitleBo): Promise<void> {
|
||||||
|
return request<void>({
|
||||||
|
url: '/web/finance/invoice/title',
|
||||||
|
method: 'put',
|
||||||
|
data: payload,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function deleteInvoiceTitle(id: string): Promise<void> {
|
export function deleteInvoiceTitle(id: string): Promise<void> {
|
||||||
const index = MOCK_TITLES.findIndex((item) => item.id === id)
|
return request<void>({
|
||||||
if (index < 0) return Promise.reject(new Error('抬头不存在'))
|
url: `/web/finance/invoice/title/${encodeURIComponent(id)}`,
|
||||||
MOCK_TITLES.splice(index, 1)
|
method: 'delete',
|
||||||
return Promise.resolve()
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setDefaultTitle(id: string): Promise<InvoiceTitle[]> {
|
export function setDefaultInvoiceTitle(id: string): Promise<void> {
|
||||||
for (const item of MOCK_TITLES) {
|
return request<void>({
|
||||||
item.isDefault = item.id === id
|
url: `/web/finance/invoice/title/default/${encodeURIComponent(id)}`,
|
||||||
}
|
method: 'put',
|
||||||
return Promise.resolve(MOCK_TITLES.map((item) => ({ ...item })))
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function exportReport(): Promise<void> {
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
return Promise.resolve()
|
// 开票申请 / 发票记录
|
||||||
}
|
// GET /web/finance/invoice/available → 可开票账单(已支付且尚无有效发票)
|
||||||
|
// POST /web/finance/invoice/apply → 申请开票 { billId, titleId, invoiceType }
|
||||||
|
// GET /web/finance/invoice/page → 发票记录分页
|
||||||
|
// GET /web/finance/invoice/{id} → 发票记录详情
|
||||||
|
// GET /web/finance/invoice/preview/{id} → 预览电子发票(仅已开票)
|
||||||
|
// GET /web/finance/invoice/download/{id} → 下载电子发票(仅已开票)
|
||||||
|
// POST /web/finance/invoice/send-email → 发送电子发票到邮箱(仅已开票)
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
// ═══════════════════════════════════════════════════════════════════════
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
// ═══════════════════════════════════════════════════════════════════════
|
// GET /web/system/dict/data/type/invoice_status → 发票状态字典
|
||||||
|
// 字典项:0 未开票 / 1 开票中 / 2 已开票(颜色取 listClass)
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
export async function getCheckoutBills(requirementId: string, ids: string[] = []): Promise<Bill[]> {
|
export const INVOICE_STATUS_DICT = 'invoice_status'
|
||||||
if (!/^\d+$/.test(requirementId)) return []
|
|
||||||
const vo = await request<{ billPlans?: PlanLike[] }>({
|
export function getInvoiceStatusDict(): Promise<DictOptionVo[]> {
|
||||||
url: `/web/requirementPool/get/finance/${requirementId}`,
|
return request<DictOptionVo[]>({
|
||||||
|
url: `/web/system/dict/data/type/${INVOICE_STATUS_DICT}`,
|
||||||
method: 'get',
|
method: 'get',
|
||||||
})
|
})
|
||||||
const all = toPlanBills(vo?.billPlans)
|
|
||||||
return ids.length > 0
|
|
||||||
? all.filter((bill) => ids.includes(bill.id))
|
|
||||||
: all.filter((bill) => bill.status === '待支付')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getPlanPayResult(requirementId: string, planId: string): Promise<PaymentResult | null> {
|
export function getAvailableInvoiceBills(): Promise<FinanceInvoiceAvailableVo[]> {
|
||||||
const bills = await getCheckoutBills(requirementId, [planId])
|
return request<FinanceInvoiceAvailableVo[]>({
|
||||||
const bill = bills[0]
|
url: '/web/finance/invoice/available',
|
||||||
if (!bill || bill.status !== '已支付') return null
|
method: 'get',
|
||||||
return {
|
})
|
||||||
method: toPayMethod(bill.payChannel),
|
}
|
||||||
amount: bill.amount,
|
|
||||||
payTime: bill.payTime ?? '—',
|
export function applyInvoice(payload: FinanceInvoiceApplyBo): Promise<number> {
|
||||||
tradeNo: bill.tradeNo ?? '—',
|
return request<number>({
|
||||||
bills: [bill],
|
url: '/web/finance/invoice/apply',
|
||||||
|
method: 'post',
|
||||||
|
data: payload,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getInvoicePage(query: FinanceInvoiceQuery): Promise<FinancePageResult<FinanceInvoiceVo>> {
|
||||||
|
return request<FinancePageResult<FinanceInvoiceVo>>({
|
||||||
|
url: '/web/finance/invoice/page',
|
||||||
|
method: 'get',
|
||||||
|
params: {
|
||||||
|
status: query.status,
|
||||||
|
orderByColumn: query.orderByColumn,
|
||||||
|
isAsc: query.isAsc,
|
||||||
|
pageNum: query.page,
|
||||||
|
pageSize: query.pageSize,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getInvoiceDetail(id: string): Promise<FinanceInvoiceVo> {
|
||||||
|
return request<FinanceInvoiceVo>({
|
||||||
|
url: `/web/finance/invoice/${encodeURIComponent(id)}`,
|
||||||
|
method: 'get',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function previewInvoice(id: string): Promise<FinanceInvoicePreviewVo> {
|
||||||
|
return request<FinanceInvoicePreviewVo>({
|
||||||
|
url: `/web/finance/invoice/preview/${encodeURIComponent(id)}`,
|
||||||
|
method: 'get',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface InvoiceDownloadFile {
|
||||||
|
blob: Blob
|
||||||
|
/** 服务器通过 download-filename 响应头下发的文件名 */
|
||||||
|
fileName?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 从 download-filename 响应头取文件名(可能经过 URL 编码)。 */
|
||||||
|
function resolveDownloadFileName(value: unknown): string | undefined {
|
||||||
|
const raw = Array.isArray(value) ? value[0] : value
|
||||||
|
if (typeof raw !== 'string' || !raw) return undefined
|
||||||
|
try {
|
||||||
|
return decodeURIComponent(raw)
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
return raw
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createWechatNativeOrder(
|
/** 下载电子发票(PDF 文件流,不走统一 JSON 包装)。 */
|
||||||
orderNo: string,
|
export async function downloadInvoice(id: string): Promise<InvoiceDownloadFile> {
|
||||||
amount: number,
|
const resp = await service.get<Blob>(`/web/finance/invoice/download/${encodeURIComponent(id)}`, {
|
||||||
billIds: string[] = [],
|
responseType: 'blob',
|
||||||
): Promise<PayOrderResponse> {
|
|
||||||
return request<PayOrderResponse>({
|
|
||||||
url: '/pay/web/wechat/native',
|
|
||||||
method: 'post',
|
|
||||||
data: { orderNo, amount, billIds },
|
|
||||||
})
|
})
|
||||||
|
return {
|
||||||
|
blob: resp.data,
|
||||||
|
fileName: resolveDownloadFileName(resp.headers['download-filename']),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createAlipayPageOrder(
|
export function sendInvoiceEmail(payload: FinanceInvoiceSendEmailBo): Promise<void> {
|
||||||
outTradeNo: string,
|
return request<void>({
|
||||||
amount: number,
|
url: '/web/finance/invoice/send-email',
|
||||||
billIds: string[] = [],
|
|
||||||
): Promise<PayOrderResponse> {
|
|
||||||
return request<PayOrderResponse>({
|
|
||||||
url: '/pay/web/alipay/page',
|
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data: { outTradeNo, amount, billIds },
|
data: payload,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,146 +1,145 @@
|
|||||||
import type { PageResult } from '@/types/api'
|
import type { PageResult } from '@/types/api'
|
||||||
import type { Message, MessageQuery } from '@/types/business/message'
|
import type {
|
||||||
|
Message,
|
||||||
|
MessageApiType,
|
||||||
|
MessageCenterVo,
|
||||||
|
MessagePageVo,
|
||||||
|
MessageQuery,
|
||||||
|
MessageType,
|
||||||
|
MessageVo,
|
||||||
|
} from '@/types/business/message'
|
||||||
|
import { getChatCenterMessages, readAllChatMessages } from '@/api/service'
|
||||||
|
import { request } from '@/utils/request'
|
||||||
|
import {
|
||||||
|
toCenterMessages,
|
||||||
|
toMessage,
|
||||||
|
toMessageApiType,
|
||||||
|
toMessageApiTypes,
|
||||||
|
toMessages,
|
||||||
|
WEB_MESSAGE_TYPES,
|
||||||
|
} from '@/utils/messageVo'
|
||||||
|
|
||||||
// TODO(api): 待接口文档到位后,将以下 mock 替换为 request<T> 调用
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
// GET /web/message/center → 状态通知 / 系统通知入口未读数(cs 由客服模块提供)
|
||||||
|
// GET /web/message/list → type + pageNum/pageSize,返回 { total, rows }
|
||||||
|
// GET /web/message/detail → id + type
|
||||||
|
// POST /web/message/readAll → type
|
||||||
|
// GET /web/chat/message/centerList → 在线客服页签消息分页列表
|
||||||
|
// POST /web/chat/message/readAll → 在线客服一键全部已读
|
||||||
|
// 列表行字段见 SysMessageVo:messageId/title/message/content/createTime/path/data
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
const MOCK_MESSAGES: Message[] = [
|
/** silent:轮询未读数时静默失败,避免瞬时网络异常反复弹提示。 */
|
||||||
{
|
export function getMessageCenter(silent = false): Promise<MessageCenterVo> {
|
||||||
id: 'msg-001',
|
return request<MessageCenterVo>({
|
||||||
type: '系统通知',
|
url: '/web/message/center',
|
||||||
title: '【新功能】物联网全案"整机联调"看板正式上线',
|
method: 'get',
|
||||||
summary: '整机联调看板已上线,支持联调进度、问题闭环与交付物一览。',
|
silent,
|
||||||
content: '尊敬的用户:\n\n为了提升物联网全案项目的交付透明度,平台已正式上线"整机联调"看板功能。\n\n一、功能亮点\n1、联调进度实时同步:设备接入、协议联调、场景验证各阶段进度一目了然;\n2、问题闭环跟踪:联调过程中产生的缺陷与阻塞项统一登记、分派、闭环;\n3、交付物一览:联调报告、测试记录、验收文档集中展示,随时查阅下载。\n\n二、使用方式\n进入「项目中心 → 项目详情 → 整机联调」即可查看对应看板。已有进行中的物联网全案项目将自动迁移历史数据,无需重新配置。\n\n三、温馨提示\n如在使用过程中遇到问题,可通过「在线客服」联系我们,或联系专属项目经理协助处理。\n\n智联智造平台产品团队\n2026年8月',
|
|
||||||
publishTime: '2026-08-06 10:00',
|
|
||||||
isRead: false,
|
|
||||||
attachments: [
|
|
||||||
{ name: '物联网全案服务介绍.pdf', size: 2.5 * 1024 * 1024, uploadTime: '2026-08-06 10:00', url: '' },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'msg-002',
|
|
||||||
type: '系统通知',
|
|
||||||
title: '平台 v2.6 版本更新公告',
|
|
||||||
summary: '新增需求提报模板、案例库对比功能,并优化了消息中心体验。',
|
|
||||||
content: '尊敬的用户:\n\n平台 v2.6 版本已于近日发布,本次更新内容如下:\n\n一、新增功能\n1、需求提报模板:常用需求类型支持保存为模板,一键复用;\n2、案例库对比:最多选择 4 个案例进行横向对比,辅助决策;\n3、消息中心改版:分类标签、关键词搜索、全部已读一站式处理。\n\n二、体验优化\n1、列表页加载性能提升约 40%;\n2、移动端适配细节修复;\n3、附件上传支持 1GB 大文件。\n\n感谢您一直以来的支持,祝使用愉快!',
|
|
||||||
publishTime: '2026-07-15 14:30',
|
|
||||||
isRead: false,
|
|
||||||
attachments: [],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'msg-003',
|
|
||||||
type: '系统通知',
|
|
||||||
title: '关于平台服务时间调整的通知',
|
|
||||||
summary: '自 2026-09-01 起,在线客服服务时间调整为 9:00-21:00。',
|
|
||||||
content: '尊敬的用户:\n\n为进一步提升服务质量,自 2026 年 9 月 1 日起,在线客服服务时间调整如下:\n\n服务时间:每日 9:00 - 21:00(法定节假日照常服务)\n非服务时段提交的留言,我们将在下一个服务时段内尽快回复。\n\n紧急事务可通过专属项目经理电话联系。\n\n感谢您的理解与支持!',
|
|
||||||
publishTime: '2026-08-28 09:00',
|
|
||||||
isRead: true,
|
|
||||||
attachments: [],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'msg-004',
|
|
||||||
type: '状态通知',
|
|
||||||
title: '合同生效通知',
|
|
||||||
summary: '您的合同已正式生效,合同编号 CZ-2026-0815 已开始生效。',
|
|
||||||
content: '您好:\n\n您的合同已正式生效。\n\n合同编号:CZ-2026-0815\n合同名称:智能园区综合管理平台开发合同\n生效日期:2026-08-15\n\n合同已开始生效,可随时在「合同中心」查看详情及履约进度。\n\n如有疑问,请联系您的专属项目经理。',
|
|
||||||
publishTime: '2026-08-15 16:42',
|
|
||||||
isRead: false,
|
|
||||||
attachments: [],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'msg-005',
|
|
||||||
type: '状态通知',
|
|
||||||
title: '项目进度更新:需求确认阶段已完成',
|
|
||||||
summary: '「智能工厂物联网整体解决方案」需求确认已完成,即将进入方案设计。',
|
|
||||||
content: '您好:\n\n您的项目进度已更新:\n\n项目名称:智能工厂物联网整体解决方案\n当前阶段:需求确认 ✅ 已完成\n下一阶段:方案设计\n\n项目组将于 3 个工作日内提交初步方案,届时会再次通知您。您也可以前往「项目中心」查看详细进度与里程碑。\n\n感谢您的配合!',
|
|
||||||
publishTime: '2026-08-20 11:05',
|
|
||||||
isRead: false,
|
|
||||||
attachments: [],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'msg-006',
|
|
||||||
type: '状态通知',
|
|
||||||
title: '账单待办提醒',
|
|
||||||
summary: '您有一笔待付款账单,账单编号 BILL-202608-023,请及时处理。',
|
|
||||||
content: '您好:\n\n您有一笔待付款账单,请及时处理:\n\n账单编号:BILL-202608-023\n关联项目:电商中台系统定制开发\n账单金额:150,000.00 元\n到期日期:2026-09-10\n\n请前往「财务中心 → 账单管理」完成支付。如对账单有疑问,请通过在线客服联系我们。\n\n温馨提示:逾期支付可能影响项目排期,请留意处理时间。',
|
|
||||||
publishTime: '2026-08-25 10:00',
|
|
||||||
isRead: true,
|
|
||||||
attachments: [],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'msg-007',
|
|
||||||
type: '在线客服',
|
|
||||||
title: '您好,请问有什么可以帮您的?',
|
|
||||||
summary: '专属客服小助手已收到您的咨询,将尽快为您答复。',
|
|
||||||
content: '您好,欢迎咨询智联智造平台!\n\n我是您的专属客服小助手,请问有什么可以帮您的?\n\n您可以咨询:\n1、物联网全案开发的流程与周期\n2、项目进度查询\n3、合同与账单相关问题\n4、平台操作指引\n\n我们将在服务时间内尽快回复您。',
|
|
||||||
publishTime: '2026-08-21 10:25',
|
|
||||||
isRead: false,
|
|
||||||
attachments: [],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'msg-008',
|
|
||||||
type: '在线客服',
|
|
||||||
title: '您的咨询已有回复',
|
|
||||||
summary: '关于"整机联调周期"的咨询已回复,点击查看详细内容。',
|
|
||||||
content: '您好:\n\n关于您咨询的"整机联调周期"问题,客服回复如下:\n\n一般物联网全案项目的整机联调周期为 2-4 周,具体取决于设备数量、协议复杂度与场景验证范围。常规智能家居类项目约 2 周,工业场景多设备联调约 3-4 周。\n\n详细排期以项目计划为准,您可在「项目中心」查看最新里程碑。\n\n如还有其他问题,欢迎继续咨询!',
|
|
||||||
publishTime: '2026-08-19 15:40',
|
|
||||||
isRead: true,
|
|
||||||
attachments: [],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'msg-009',
|
|
||||||
type: '在线客服',
|
|
||||||
title: '会话满意度回访',
|
|
||||||
summary: '您上次的会话已结束,欢迎对本次服务进行评价。',
|
|
||||||
content: '您好:\n\n您于 2026-08-18 的会话已结束,感谢您的咨询!\n\n欢迎对本次服务进行评价,您的反馈将帮助我们持续改进。如问题未得到解决,可直接回复本条消息,我们将重新为您跟进。\n\n祝您使用愉快!',
|
|
||||||
publishTime: '2026-08-18 17:00',
|
|
||||||
isRead: false,
|
|
||||||
attachments: [],
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
function applyFilters(query: MessageQuery): Message[] {
|
|
||||||
return MOCK_MESSAGES.filter((item) => {
|
|
||||||
if (query.type !== 'all' && item.type !== query.type) return false
|
|
||||||
if (query.keyword && !item.title.includes(query.keyword) && !item.summary.includes(query.keyword)) return false
|
|
||||||
return true
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getMessageList(query: MessageQuery): Promise<PageResult<Message>> {
|
function getMessagePage(
|
||||||
const filtered = applyFilters(query)
|
type: MessageApiType,
|
||||||
|
pageNum: number,
|
||||||
|
pageSize: number,
|
||||||
|
): Promise<MessagePageVo<MessageVo>> {
|
||||||
|
return request<MessagePageVo<MessageVo>>({
|
||||||
|
url: '/web/message/list',
|
||||||
|
method: 'get',
|
||||||
|
params: { type, pageNum, pageSize },
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function filterByKeyword(list: Message[], keyword: string): Message[] {
|
||||||
|
if (!keyword) return list
|
||||||
|
return list.filter((item) => item.title.includes(keyword) || item.summary.includes(keyword))
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 「全部」后端不支持一次查多个 type,按状态通知 + 系统通知 + 在线客服分别取到当前页并合并排序;
|
||||||
|
* 单个 tab 直接按 pageNum/pageSize 分页,在线客服走独立接口 /web/chat/message/centerList。
|
||||||
|
*/
|
||||||
|
export async function getMessageList(query: MessageQuery): Promise<PageResult<Message>> {
|
||||||
|
const keyword = query.keyword.trim()
|
||||||
|
|
||||||
|
if (query.type === '在线客服') {
|
||||||
|
const page = await getChatCenterMessages({ pageNum: query.page, pageSize: query.pageSize })
|
||||||
|
return {
|
||||||
|
list: filterByKeyword(toCenterMessages(page.rows), keyword),
|
||||||
|
total: Number(page.total ?? 0),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const types: MessageApiType[] = query.type === 'all' ? WEB_MESSAGE_TYPES : [toMessageApiType(query.type)]
|
||||||
|
const fetchSize = query.type === 'all' ? query.page * query.pageSize : query.pageSize
|
||||||
|
|
||||||
|
const [pages, chatPage] = await Promise.all([
|
||||||
|
Promise.all(
|
||||||
|
types.map((type) =>
|
||||||
|
query.type === 'all'
|
||||||
|
// 单个入口失败不影响另一个入口展示
|
||||||
|
? getMessagePage(type, 1, fetchSize).catch(() => null)
|
||||||
|
: getMessagePage(type, query.page, fetchSize),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
query.type === 'all'
|
||||||
|
? getChatCenterMessages({ pageNum: 1, pageSize: fetchSize }).catch(() => null)
|
||||||
|
: null,
|
||||||
|
])
|
||||||
|
|
||||||
|
let total = 0
|
||||||
|
const rows: Message[] = []
|
||||||
|
pages.forEach((page, index) => {
|
||||||
|
if (!page) return
|
||||||
|
total += Number(page.total ?? 0)
|
||||||
|
rows.push(...toMessages(page.rows, types[index] ?? types[0]))
|
||||||
|
})
|
||||||
|
if (chatPage) {
|
||||||
|
total += Number(chatPage.total ?? 0)
|
||||||
|
rows.push(...toCenterMessages(chatPage.rows))
|
||||||
|
}
|
||||||
|
|
||||||
|
const sorted = filterByKeyword(rows, keyword)
|
||||||
|
.sort((a, b) => b.publishTime.localeCompare(a.publishTime))
|
||||||
|
|
||||||
|
if (query.type !== 'all') {
|
||||||
|
return { list: sorted, total: Number(pages[0]?.total ?? 0) }
|
||||||
|
}
|
||||||
|
|
||||||
const start = (query.page - 1) * query.pageSize
|
const start = (query.page - 1) * query.pageSize
|
||||||
return Promise.resolve({
|
return { list: sorted.slice(start, start + query.pageSize), total }
|
||||||
list: filtered.slice(start, start + query.pageSize),
|
}
|
||||||
total: filtered.length,
|
|
||||||
|
export async function getMessageDetail(
|
||||||
|
id: string,
|
||||||
|
type: MessageApiType,
|
||||||
|
): Promise<Message | null> {
|
||||||
|
const vo = await request<MessageVo | null>({
|
||||||
|
url: '/web/message/detail',
|
||||||
|
method: 'get',
|
||||||
|
params: { id, type },
|
||||||
})
|
})
|
||||||
|
return vo ? toMessage(vo, type) : null
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getMessageDetail(id: string): Promise<Message | null> {
|
export async function markAllRead(type: MessageType | 'all'): Promise<void> {
|
||||||
const found = MOCK_MESSAGES.find((item) => item.id === id) ?? null
|
const requests: Promise<void>[] = []
|
||||||
return Promise.resolve(found ? { ...found } : null)
|
|
||||||
}
|
|
||||||
|
|
||||||
export function markAllRead(): Promise<void> {
|
// 在线客服是独立接口且不区分 type,按范围分别调用
|
||||||
for (const item of MOCK_MESSAGES) {
|
if (type === 'all' || type === '在线客服') {
|
||||||
item.isRead = true
|
requests.push(readAllChatMessages())
|
||||||
}
|
}
|
||||||
return Promise.resolve()
|
if (type !== '在线客服') {
|
||||||
}
|
toMessageApiTypes(type).forEach((item) => {
|
||||||
|
requests.push(
|
||||||
export function markRead(id: string): Promise<void> {
|
request<void>({
|
||||||
const found = MOCK_MESSAGES.find((item) => item.id === id)
|
url: '/web/message/readAll',
|
||||||
if (found) found.isRead = true
|
method: 'post',
|
||||||
return Promise.resolve()
|
params: { type: item },
|
||||||
}
|
}),
|
||||||
|
)
|
||||||
export function getTabCounts(): Promise<{ all: number; 在线客服: number; 状态通知: number; 系统通知: number }> {
|
})
|
||||||
const counts = { all: MOCK_MESSAGES.length, 在线客服: 0, 状态通知: 0, 系统通知: 0 }
|
|
||||||
for (const item of MOCK_MESSAGES) {
|
|
||||||
counts[item.type] += 1
|
|
||||||
}
|
}
|
||||||
return Promise.resolve(counts)
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getUnreadCount(): Promise<number> {
|
await Promise.all(requests)
|
||||||
return Promise.resolve(MOCK_MESSAGES.filter((item) => !item.isRead).length)
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import service from '@/utils/request'
|
import service from '@/utils/request'
|
||||||
|
import { readBlobErrorMessage } from '@/utils/download'
|
||||||
|
|
||||||
export async function fetchOssPreviewBlob(ossId: string | number): Promise<Blob> {
|
export async function fetchOssPreviewBlob(ossId: string | number): Promise<Blob> {
|
||||||
const resp = await service.get(`/web/workOrderDraft/preview/${ossId}`, {
|
const resp = await service.get(`/web/workOrderDraft/preview/${ossId}`, {
|
||||||
@@ -6,3 +7,14 @@ export async function fetchOssPreviewBlob(ossId: string | number): Promise<Blob>
|
|||||||
})
|
})
|
||||||
return resp.data as Blob
|
return resp.data as Blob
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 下载 OSS 文件(用于编辑弹窗里刚上传、尚未保存的附件)。 */
|
||||||
|
export async function downloadOssFile(ossId: string | number): Promise<Blob> {
|
||||||
|
const resp = await service.get<Blob>(`/web/resource/oss/download/${ossId}`, {
|
||||||
|
responseType: 'blob',
|
||||||
|
})
|
||||||
|
if (resp.data.type.startsWith('application/json')) {
|
||||||
|
throw new Error(await readBlobErrorMessage(resp.data))
|
||||||
|
}
|
||||||
|
return resp.data
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,403 +1,404 @@
|
|||||||
import type { BusinessType, PageResult } from '@/types/api'
|
import type { BusinessType, FileInfo, PageResult } from '@/types/api'
|
||||||
import type { Case } from '@/types/business/cases'
|
import type { Case, ProjectCaseVo } from '@/types/business/cases'
|
||||||
import type {
|
import type {
|
||||||
Address,
|
Address,
|
||||||
ChangePasswordParams,
|
ChangePasswordParams,
|
||||||
Feedback,
|
Feedback,
|
||||||
|
FeedbackVo,
|
||||||
FavoritesQuery,
|
FavoritesQuery,
|
||||||
HelpFaqGroup,
|
HelpFaqGroup,
|
||||||
ListQuery,
|
ListQuery,
|
||||||
Profile,
|
Profile,
|
||||||
|
ProfilePageVo,
|
||||||
|
ProfileUploadVo,
|
||||||
Qualification,
|
Qualification,
|
||||||
QualificationInput,
|
QualificationInput,
|
||||||
|
UserAddressVo,
|
||||||
|
UserQualificationVo,
|
||||||
} from '@/types/business/profile'
|
} from '@/types/business/profile'
|
||||||
|
import { getProjectCaseCount } from '@/api/cases'
|
||||||
|
import {
|
||||||
|
getAccountSecurity,
|
||||||
|
getUserProfile,
|
||||||
|
updateUserProfile as updateUserProfileApi,
|
||||||
|
} from '@/api/user'
|
||||||
|
import { formatDate, toBusinessType } from '@/utils/format'
|
||||||
|
import { toCase } from '@/utils/caseVo'
|
||||||
|
import { readBlobErrorMessage, resolveContentDispositionFileName } from '@/utils/download'
|
||||||
|
import {
|
||||||
|
toAddressBo,
|
||||||
|
toAddresses,
|
||||||
|
toFeedbackBo,
|
||||||
|
toProfile,
|
||||||
|
toQualificationBo,
|
||||||
|
toQualifications,
|
||||||
|
} from '@/utils/profileVo'
|
||||||
|
import service, { request } from '@/utils/request'
|
||||||
|
|
||||||
// TODO(api): 待接口文档到位后,将以下 mock 替换为 request<T> 调用(页面 → store → api 数据流不变)
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
// 个人资料 / 账号安全
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
const MOCK_PROFILE: Profile = {
|
export async function getProfile(): Promise<Profile> {
|
||||||
nickname: '王永志',
|
const [user, security] = await Promise.all([
|
||||||
phone: '186****618',
|
getUserProfile(),
|
||||||
email: 'yongzh******4@163.com',
|
// 账号安全接口异常不阻塞基本资料展示(老用户字段也可能为 null)
|
||||||
passwordModifiedAt: '15天前',
|
getAccountSecurity().catch(() => null),
|
||||||
|
])
|
||||||
|
return toProfile(user, security)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getProfile(): Promise<Profile> {
|
export async function updateNickname(name: string): Promise<Profile> {
|
||||||
return Promise.resolve({ ...MOCK_PROFILE })
|
await updateUserProfileApi({ nickName: name })
|
||||||
|
return getProfile()
|
||||||
}
|
}
|
||||||
|
|
||||||
export function updateNickname(name: string): Promise<Profile> {
|
export async function updateAvatar(avatar: string): Promise<Profile> {
|
||||||
MOCK_PROFILE.nickname = name
|
await updateUserProfileApi({ avatar })
|
||||||
return Promise.resolve({ ...MOCK_PROFILE })
|
return getProfile()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 通用文件上传(POST /web/profile/upload,字段名固定 file)。 */
|
||||||
|
export function uploadProfileFile(file: File): Promise<ProfileUploadVo> {
|
||||||
|
const data = new FormData()
|
||||||
|
data.append('file', file)
|
||||||
|
return request<ProfileUploadVo>({
|
||||||
|
url: '/web/profile/upload',
|
||||||
|
method: 'post',
|
||||||
|
data,
|
||||||
|
headers: { 'Content-Type': 'multipart/form-data' },
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 上传并转成页面 FileInfo,便于附件列表统一展示。 */
|
||||||
|
export async function uploadProfileAttachment(file: File): Promise<FileInfo> {
|
||||||
|
const vo = await uploadProfileFile(file)
|
||||||
|
return {
|
||||||
|
ossId: vo.ossId,
|
||||||
|
name: vo.originalName || file.name,
|
||||||
|
size: file.size,
|
||||||
|
uploadTime: formatDate(new Date()),
|
||||||
|
url: vo.url,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function changePassword(params: ChangePasswordParams): Promise<void> {
|
export function changePassword(params: ChangePasswordParams): Promise<void> {
|
||||||
MOCK_PROFILE.passwordModifiedAt = '刚刚'
|
return request<void>({
|
||||||
void params
|
url: '/web/profile/password/reset',
|
||||||
return Promise.resolve()
|
method: 'post',
|
||||||
|
data: {
|
||||||
|
phoneNumber: params.phoneNumber ?? '',
|
||||||
|
smsCode: params.code,
|
||||||
|
newPassword: params.password,
|
||||||
|
confirmPassword: params.password,
|
||||||
|
},
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function bindPhone(phone: string, code: string): Promise<Profile> {
|
/** 发送绑定手机号用的短信验证码。 */
|
||||||
void code
|
export function sendBindSmsCode(phone: string): Promise<void> {
|
||||||
MOCK_PROFILE.phone = phone
|
return request<void>({
|
||||||
return Promise.resolve({ ...MOCK_PROFILE })
|
url: '/web/profile/sms/send',
|
||||||
|
method: 'post',
|
||||||
|
params: { phone },
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function bindEmail(email: string, code: string): Promise<Profile> {
|
/** 发送绑定邮箱的邮件验证码(发到目标邮箱)。 */
|
||||||
void code
|
export function sendBindEmailCode(email: string): Promise<void> {
|
||||||
MOCK_PROFILE.email = email
|
return request<void>({
|
||||||
return Promise.resolve({ ...MOCK_PROFILE })
|
url: '/web/profile/email/send',
|
||||||
|
method: 'post',
|
||||||
|
params: { email },
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function unbindEmail(): Promise<Profile> {
|
export async function bindPhone(phone: string, code: string): Promise<Profile> {
|
||||||
MOCK_PROFILE.email = ''
|
await request<void>({
|
||||||
return Promise.resolve({ ...MOCK_PROFILE })
|
url: '/web/profile/phone/bind',
|
||||||
|
method: 'post',
|
||||||
|
params: { phone, code },
|
||||||
|
})
|
||||||
|
return getProfile()
|
||||||
}
|
}
|
||||||
|
|
||||||
export function verifyIdentity(phone: string, code: string): Promise<void> {
|
export function unbindPhone(): Promise<void> {
|
||||||
void phone
|
return request<void>({
|
||||||
void code
|
url: '/web/profile/phone/unbind',
|
||||||
return Promise.resolve()
|
method: 'post',
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function deleteAccount(): Promise<void> {
|
export async function bindEmail(email: string, code: string): Promise<Profile> {
|
||||||
return Promise.resolve()
|
await request<void>({
|
||||||
|
url: '/web/profile/email/bind',
|
||||||
|
method: 'post',
|
||||||
|
params: { email, code },
|
||||||
|
})
|
||||||
|
return getProfile()
|
||||||
}
|
}
|
||||||
|
|
||||||
const MOCK_ADDRESSES: Address[] = [
|
export async function unbindEmail(): Promise<Profile> {
|
||||||
{
|
await request<void>({
|
||||||
id: 'addr-1',
|
url: '/web/profile/email/unbind',
|
||||||
receiverName: '王永志',
|
method: 'post',
|
||||||
phone: '18556669516',
|
})
|
||||||
region: '山东省日照市东港区',
|
return getProfile()
|
||||||
detailAddress: '凌云购物广场三楼',
|
}
|
||||||
isDefault: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'addr-2',
|
|
||||||
receiverName: '王永志',
|
|
||||||
phone: '18556669516',
|
|
||||||
region: '山东省日照市东港区',
|
|
||||||
detailAddress: '海曲东路 12 号研发中心 A 座 8 层',
|
|
||||||
isDefault: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'addr-3',
|
|
||||||
receiverName: '李晓婷',
|
|
||||||
phone: '13863331234',
|
|
||||||
region: '山东省青岛市市南区',
|
|
||||||
detailAddress: '香港中路 76 号 A 座 18 层',
|
|
||||||
isDefault: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'addr-4',
|
|
||||||
receiverName: '王永志',
|
|
||||||
phone: '18556669516',
|
|
||||||
region: '山东省济南市历下区',
|
|
||||||
detailAddress: '经十路 9999 号舜耕大厦 12 层',
|
|
||||||
isDefault: false,
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
function paginate<T>(list: T[], query: ListQuery): PageResult<T> {
|
/** 注销账号:验证码合并到 cancel,phone 必须是账号绑定手机号。 */
|
||||||
|
export function deleteAccount(phone: string, code: string): Promise<void> {
|
||||||
|
return request<void>({
|
||||||
|
url: '/web/profile/cancel',
|
||||||
|
method: 'post',
|
||||||
|
params: { phone, code },
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
// 地址:/web/profile/address/*
|
||||||
|
// 列表接口返回全量数组,前端按页切片以复用现有分页组件。
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
export async function getAddresses(query: ListQuery): Promise<PageResult<Address>> {
|
||||||
|
const rows = await request<UserAddressVo[]>({
|
||||||
|
url: '/web/profile/address/list',
|
||||||
|
method: 'get',
|
||||||
|
})
|
||||||
|
const list = toAddresses(rows)
|
||||||
const start = (query.page - 1) * query.pageSize
|
const start = (query.page - 1) * query.pageSize
|
||||||
return {
|
return { list: list.slice(start, start + query.pageSize), total: list.length }
|
||||||
list: list.slice(start, start + query.pageSize),
|
|
||||||
total: list.length,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getAddresses(query: ListQuery): Promise<PageResult<Address>> {
|
export async function createAddress(input: Omit<Address, 'id' | 'isDefault'>): Promise<Address> {
|
||||||
return Promise.resolve(paginate(MOCK_ADDRESSES, query))
|
const id = await request<number | string>({
|
||||||
|
url: '/web/profile/address',
|
||||||
|
method: 'post',
|
||||||
|
data: toAddressBo(input),
|
||||||
|
})
|
||||||
|
return { id: String(id ?? ''), ...input, isDefault: false }
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createAddress(input: Omit<Address, 'id' | 'isDefault'>): Promise<Address> {
|
export async function updateAddress(
|
||||||
const created: Address = {
|
id: string,
|
||||||
...input,
|
input: Omit<Address, 'id' | 'isDefault'>,
|
||||||
id: `addr-${Date.now()}`,
|
): Promise<Address> {
|
||||||
isDefault: MOCK_ADDRESSES.length === 0,
|
await request<void>({
|
||||||
}
|
url: `/web/profile/address/${encodeURIComponent(id)}`,
|
||||||
MOCK_ADDRESSES.push(created)
|
method: 'put',
|
||||||
return Promise.resolve({ ...created })
|
data: toAddressBo(input),
|
||||||
}
|
})
|
||||||
|
return { id, ...input, isDefault: false }
|
||||||
export function updateAddress(id: string, input: Omit<Address, 'id' | 'isDefault'>): Promise<Address> {
|
|
||||||
const found = MOCK_ADDRESSES.find((item) => item.id === id)
|
|
||||||
if (!found) return Promise.reject(new Error('地址不存在'))
|
|
||||||
Object.assign(found, input)
|
|
||||||
return Promise.resolve({ ...found })
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function deleteAddress(id: string): Promise<void> {
|
export function deleteAddress(id: string): Promise<void> {
|
||||||
const index = MOCK_ADDRESSES.findIndex((item) => item.id === id)
|
return request<void>({
|
||||||
if (index >= 0) MOCK_ADDRESSES.splice(index, 1)
|
url: `/web/profile/address/${encodeURIComponent(id)}`,
|
||||||
return Promise.resolve()
|
method: 'delete',
|
||||||
}
|
|
||||||
|
|
||||||
export function setDefaultAddress(id: string): Promise<Address[]> {
|
|
||||||
for (const item of MOCK_ADDRESSES) {
|
|
||||||
item.isDefault = item.id === id
|
|
||||||
}
|
|
||||||
return Promise.resolve(MOCK_ADDRESSES.map((item) => ({ ...item })))
|
|
||||||
}
|
|
||||||
|
|
||||||
const MOCK_FAVORITES: Case[] = [
|
|
||||||
{
|
|
||||||
id: 'fav-1',
|
|
||||||
title: '自动化生产线升级改造项目',
|
|
||||||
category: 'manufacturing',
|
|
||||||
cover: '',
|
|
||||||
finishDate: '2026/8/10',
|
|
||||||
teamSize: 50,
|
|
||||||
scale: '300万',
|
|
||||||
industry: '自动化',
|
|
||||||
duration: '150个工作日',
|
|
||||||
clientType: '企业',
|
|
||||||
sections: [
|
|
||||||
{ title: '项目背景', content: '<p>传统产线效率低、人工依赖高,客户需要通过自动化升级提升产能与品控水平。</p>' },
|
|
||||||
{ title: '客户痛点', content: '<p>1、产线依赖人工巡检,异常响应慢;2、设备数据孤岛,缺乏统一监控;3、工艺参数无法追溯。</p>' },
|
|
||||||
{ title: '需求描述', content: '<p>建设产线数据采集与监控平台,完成关键工位自动化改造,打通 MES 系统接口。</p>' },
|
|
||||||
{ title: '交付物', content: '<p>1、产线自动化改造方案;2、PLC 控制程序与上位机软件;3、数据看板与运维手册;4、培训与质保服务。</p>' },
|
|
||||||
],
|
|
||||||
video: '',
|
|
||||||
isFavorite: true,
|
|
||||||
favoriteCount: 0,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'fav-2',
|
|
||||||
title: '智能工厂物联网整体解决方案',
|
|
||||||
category: 'iot',
|
|
||||||
cover: '',
|
|
||||||
finishDate: '2026/8/10',
|
|
||||||
teamSize: 30,
|
|
||||||
scale: '500万',
|
|
||||||
industry: '工厂服务',
|
|
||||||
duration: '200个工作日',
|
|
||||||
clientType: '企业',
|
|
||||||
sections: [
|
|
||||||
{ title: '项目背景', content: '<p>园区工厂多系统独立运行,能耗与设备管理粗放,需要整体数字化升级。</p>' },
|
|
||||||
{ title: '客户痛点', content: '<p>1、门禁/监控/能耗子系统数据不互通;2、能源浪费缺乏精细监测;3、决策缺少实时数据支撑。</p>' },
|
|
||||||
{ title: '需求描述', content: '<p>构建 IoT 平台接入设备数据,建设综合驾驶舱,实现能耗监测与智能告警。</p>' },
|
|
||||||
{ title: '交付物', content: '<p>1、IoT 接入平台;2、综合驾驶舱大屏;3、能耗分析系统;4、集成联调与培训服务。</p>' },
|
|
||||||
],
|
|
||||||
video: '',
|
|
||||||
isFavorite: true,
|
|
||||||
favoriteCount: 0,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'fav-3',
|
|
||||||
title: '智能穿戴设备PCB设计与量产',
|
|
||||||
category: 'hardware',
|
|
||||||
cover: '',
|
|
||||||
finishDate: '2026/8/10',
|
|
||||||
teamSize: 50,
|
|
||||||
scale: '10-50万',
|
|
||||||
industry: '智能设备',
|
|
||||||
duration: '30个工作日',
|
|
||||||
clientType: '企业',
|
|
||||||
sections: [
|
|
||||||
{ title: '项目背景', content: '<p>客户推出新一代智能穿戴产品,需要高集成度低功耗 PCB 设计并快速量产。</p>' },
|
|
||||||
{ title: '客户痛点', content: '<p>1、板载空间受限,器件布局密集;2、功耗要求严格;3、量产良率需爬坡。</p>' },
|
|
||||||
{ title: '需求描述', content: '<p>完成原理图与 PCB 设计、打样验证、SMT 贴片与整机装配量产。</p>' },
|
|
||||||
{ title: '交付物', content: '<p>1、原理图与 PCB 设计文件;2、样板与测试报告;3、量产良率报告;4、BOM 与工艺文件。</p>' },
|
|
||||||
],
|
|
||||||
video: '',
|
|
||||||
isFavorite: true,
|
|
||||||
favoriteCount: 0,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'fav-4',
|
|
||||||
title: '智能园区综合管理平台开发',
|
|
||||||
category: 'internet',
|
|
||||||
cover: '',
|
|
||||||
finishDate: '2026/8/10',
|
|
||||||
teamSize: 20,
|
|
||||||
scale: '200万',
|
|
||||||
industry: '园区服务',
|
|
||||||
duration: '200个工作日',
|
|
||||||
clientType: '企业',
|
|
||||||
sections: [
|
|
||||||
{ title: '项目背景', content: '<p>传统园区管理普遍"数据孤岛",安防、能耗、物业、招商等系统独立运行,缺乏联动,管理手段依赖人工巡检和纸质流程。</p>' },
|
|
||||||
{ title: '客户痛点', content: '<p>1、运营效率低下:安保依赖人工巡逻;2、系统孤岛严重:门禁、监控、停车、能耗等子系统独立建设;3、能源浪费突出;4、服务体验欠佳;5、决策缺乏依据;6、安全隐患犹存。</p>' },
|
|
||||||
{ title: '需求描述', content: '<p>打造集"感知、预警、分析、决策、服务"于一体的智能园区综合管理平台,打通园区各子系统壁垒,实现全场景数字化覆盖。</p>' },
|
|
||||||
{ title: '交付物', content: '<p>1、Web 端管理平台(驾驶舱/安防/能源/物业);2、移动端服务门户;3、IoT 平台与数据大屏;4、全套技术文档;5、培训与不少于1年免费质保。</p>' },
|
|
||||||
],
|
|
||||||
video: '',
|
|
||||||
isFavorite: true,
|
|
||||||
favoriteCount: 0,
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
export function getFavorites(query: FavoritesQuery): Promise<PageResult<Case>> {
|
|
||||||
const filtered = MOCK_FAVORITES.filter((item) => {
|
|
||||||
if (query.category !== 'all' && item.category !== query.category) return false
|
|
||||||
if (query.keyword && !item.title.includes(query.keyword)) return false
|
|
||||||
return true
|
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setDefaultAddress(id: string): Promise<void> {
|
||||||
|
return request<void>({
|
||||||
|
url: `/web/profile/address/${encodeURIComponent(id)}/default`,
|
||||||
|
method: 'post',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
// 收藏:/web/profile/favorite/{caseId}、/web/profile/favorite/page
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
export async function getFavorites(query: FavoritesQuery): Promise<PageResult<Case>> {
|
||||||
|
const page = await request<ProfilePageVo<ProjectCaseVo>>({
|
||||||
|
url: '/web/profile/favorite/page',
|
||||||
|
method: 'get',
|
||||||
|
params: { pageNum: query.page, pageSize: query.pageSize },
|
||||||
|
})
|
||||||
|
const rows = (page?.rows ?? []).filter((item) => item != null && item.id != null)
|
||||||
|
return { list: rows.map((vo) => toCase(vo)), total: Number(page?.total ?? 0) }
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 案例分类统计:走 /web/projectCase/count,不再拉收藏列表本地汇总。 */
|
||||||
|
export async function getCaseCounts(): Promise<Partial<Record<BusinessType, number>>> {
|
||||||
|
const stats = await getProjectCaseCount()
|
||||||
|
const counts: Partial<Record<BusinessType, number>> = {}
|
||||||
|
for (const item of stats?.projectCaseCounts ?? []) {
|
||||||
|
if (item == null) continue
|
||||||
|
const type = toBusinessType(item.businessType)
|
||||||
|
counts[type] = (counts[type] ?? 0) + (item.caseCount ?? 0)
|
||||||
|
}
|
||||||
|
return counts
|
||||||
|
}
|
||||||
|
|
||||||
|
export function favoriteCase(caseId: string): Promise<void> {
|
||||||
|
return request<void>({
|
||||||
|
url: `/web/profile/favorite/${encodeURIComponent(caseId)}`,
|
||||||
|
method: 'post',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function unfavoriteCase(caseId: string): Promise<void> {
|
||||||
|
return request<void>({
|
||||||
|
url: `/web/profile/unfavorite/${encodeURIComponent(caseId)}`,
|
||||||
|
method: 'post',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
// 资质:/web/profile/qualification/*
|
||||||
|
// 列表接口返回全量数组,前端按页切片以复用现有分页组件。
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
export async function getQualifications(query: ListQuery): Promise<PageResult<Qualification>> {
|
||||||
|
const rows = await request<UserQualificationVo[]>({
|
||||||
|
url: '/web/profile/qualification/list',
|
||||||
|
method: 'get',
|
||||||
|
})
|
||||||
|
const list = toQualifications(rows)
|
||||||
const start = (query.page - 1) * query.pageSize
|
const start = (query.page - 1) * query.pageSize
|
||||||
return Promise.resolve({
|
return { list: list.slice(start, start + query.pageSize), total: list.length }
|
||||||
list: filtered.slice(start, start + query.pageSize).map((item) => ({ ...item })),
|
}
|
||||||
total: filtered.length,
|
|
||||||
|
export async function createQualification(input: QualificationInput): Promise<Qualification> {
|
||||||
|
const id = await request<number | string>({
|
||||||
|
url: '/web/profile/qualification',
|
||||||
|
method: 'post',
|
||||||
|
data: toQualificationBo(input),
|
||||||
})
|
})
|
||||||
|
return { id: String(id ?? ''), ...input, status: '审核中' }
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getCaseCounts(): Promise<Partial<Record<BusinessType, number>>> {
|
export async function updateQualification(
|
||||||
const counts: Partial<Record<BusinessType, number>> = {
|
id: string,
|
||||||
internet: 1,
|
input: QualificationInput,
|
||||||
hardware: 1,
|
): Promise<Qualification> {
|
||||||
iot: 1,
|
await request<void>({
|
||||||
manufacturing: 1,
|
url: `/web/profile/qualification/${encodeURIComponent(id)}`,
|
||||||
}
|
method: 'put',
|
||||||
return Promise.resolve(counts)
|
data: toQualificationBo(input),
|
||||||
}
|
})
|
||||||
|
return { id, ...input, status: '审核中' }
|
||||||
const MOCK_QUALIFICATIONS: Qualification[] = [
|
|
||||||
{
|
|
||||||
id: 'qual-1',
|
|
||||||
type: '体系认证',
|
|
||||||
certName: 'ISO9001 质量管理体系认证证书',
|
|
||||||
certNo: 'ISO202609080075',
|
|
||||||
issuer: '中国质量认证中心',
|
|
||||||
validFrom: '2026-9-10',
|
|
||||||
validTo: '2027-9-10',
|
|
||||||
status: '已认证',
|
|
||||||
attachments: [
|
|
||||||
{ name: '体系认证证书', size: 1_048_576, uploadTime: '2026-09-10', url: '' },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'qual-2',
|
|
||||||
type: '营业执照',
|
|
||||||
certName: '营业执照',
|
|
||||||
certNo: '91371102MA3XX8876Q',
|
|
||||||
issuer: '日照市东港区市场监督管理局',
|
|
||||||
validFrom: '2020-3-15',
|
|
||||||
validTo: '2030-3-14',
|
|
||||||
status: '审核中',
|
|
||||||
attachments: [
|
|
||||||
{ name: '营业执照', size: 820_000, uploadTime: '2026-09-12', url: '' },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'qual-3',
|
|
||||||
type: '检测报告',
|
|
||||||
certName: '智能终端产品第三方检测报告',
|
|
||||||
certNo: 'WT20260512001',
|
|
||||||
issuer: '山东省产品质量检验研究院',
|
|
||||||
validFrom: '2026-5-12',
|
|
||||||
validTo: '2027-5-12',
|
|
||||||
status: '未通过',
|
|
||||||
attachments: [
|
|
||||||
{ name: '检测报告', size: 2_097_152, uploadTime: '2026-05-15', url: '' },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'qual-4',
|
|
||||||
type: '生产许可证',
|
|
||||||
certName: '全国工业产品生产许可证',
|
|
||||||
certNo: 'XK06-123-45678',
|
|
||||||
issuer: '山东省市场监督管理局',
|
|
||||||
validFrom: '2024-1-8',
|
|
||||||
validTo: '2029-1-7',
|
|
||||||
status: '已认证',
|
|
||||||
attachments: [
|
|
||||||
{ name: '生产许可证', size: 1_258_291, uploadTime: '2024-01-10', url: '' },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
export function getQualifications(query: ListQuery): Promise<PageResult<Qualification>> {
|
|
||||||
return Promise.resolve(paginate(MOCK_QUALIFICATIONS, query))
|
|
||||||
}
|
|
||||||
|
|
||||||
export function createQualification(input: QualificationInput): Promise<Qualification> {
|
|
||||||
const created: Qualification = {
|
|
||||||
...input,
|
|
||||||
id: `qual-${Date.now()}`,
|
|
||||||
status: '审核中',
|
|
||||||
}
|
|
||||||
MOCK_QUALIFICATIONS.unshift(created)
|
|
||||||
return Promise.resolve({ ...created })
|
|
||||||
}
|
|
||||||
|
|
||||||
export function updateQualification(id: string, input: QualificationInput): Promise<Qualification> {
|
|
||||||
const found = MOCK_QUALIFICATIONS.find((item) => item.id === id)
|
|
||||||
if (!found) return Promise.reject(new Error('资质不存在'))
|
|
||||||
found.type = input.type
|
|
||||||
found.certName = input.certName
|
|
||||||
found.certNo = input.certNo
|
|
||||||
found.issuer = input.issuer
|
|
||||||
found.validFrom = input.validFrom
|
|
||||||
found.validTo = input.validTo
|
|
||||||
found.attachments = input.attachments
|
|
||||||
if (found.status === '未通过') found.status = '审核中'
|
|
||||||
return Promise.resolve({ ...found })
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function deleteQualification(id: string): Promise<void> {
|
export function deleteQualification(id: string): Promise<void> {
|
||||||
const index = MOCK_QUALIFICATIONS.findIndex((item) => item.id === id)
|
return request<void>({
|
||||||
if (index >= 0) MOCK_QUALIFICATIONS.splice(index, 1)
|
url: `/web/profile/qualification/${encodeURIComponent(id)}`,
|
||||||
return Promise.resolve()
|
method: 'delete',
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function submitFeedback(feedback: Feedback): Promise<void> {
|
export function resubmitQualification(id: string): Promise<void> {
|
||||||
void feedback
|
return request<void>({
|
||||||
return Promise.resolve()
|
url: `/web/profile/qualification/${encodeURIComponent(id)}/resubmit`,
|
||||||
|
method: 'post',
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface QualificationDownloadFile {
|
||||||
|
blob: Blob
|
||||||
|
/** 后端通过 Content-Disposition 下发的文件名(证书名称 + 序号 + 扩展名) */
|
||||||
|
fileName?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下载已保存的资质附件(文件流,不走统一 JSON 包装)。
|
||||||
|
* index 为该附件在列表中的下标,从 0 开始,不传默认 0。
|
||||||
|
*/
|
||||||
|
export async function downloadQualificationAttachment(
|
||||||
|
id: string,
|
||||||
|
index = 0,
|
||||||
|
): Promise<QualificationDownloadFile> {
|
||||||
|
const resp = await service.get<Blob>(
|
||||||
|
`/web/profile/qualification/${encodeURIComponent(id)}/download`,
|
||||||
|
{ params: { index }, responseType: 'blob' },
|
||||||
|
)
|
||||||
|
// 后端报错时返回 JSON,被 axios 包成 Blob
|
||||||
|
if (resp.data.type.startsWith('application/json')) {
|
||||||
|
throw new Error(await readBlobErrorMessage(resp.data))
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
blob: resp.data,
|
||||||
|
fileName: resolveContentDispositionFileName(resp.headers['content-disposition']),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
// 反馈:/web/profile/feedback、/web/profile/feedback/page
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
export async function submitFeedback(feedback: Feedback): Promise<void> {
|
||||||
|
await request<void>({
|
||||||
|
url: '/web/profile/feedback',
|
||||||
|
method: 'post',
|
||||||
|
data: toFeedbackBo(feedback),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 我的反馈分页(页面暂未使用,接口先接好)。 */
|
||||||
|
export function getFeedbackPage(query: ListQuery): Promise<ProfilePageVo<FeedbackVo>> {
|
||||||
|
return request<ProfilePageVo<FeedbackVo>>({
|
||||||
|
url: '/web/profile/feedback/page',
|
||||||
|
method: 'get',
|
||||||
|
params: { pageNum: query.page, pageSize: query.pageSize },
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 后端确认不提供 FAQ 接口(2026-11-03),保留设计稿静态文案。 */
|
||||||
export function getHelpFaqs(): Promise<HelpFaqGroup[]> {
|
export function getHelpFaqs(): Promise<HelpFaqGroup[]> {
|
||||||
return Promise.resolve([
|
return Promise.resolve([
|
||||||
{
|
{
|
||||||
title: '1. 账户与登录',
|
title: '账户与登录',
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
q: '如何注册账号?',
|
q: '如何注册账号?',
|
||||||
a: '点击页面右上角"注册",输入手机号并获取验证码,设置 6-20 位登录密码即可完成注册。',
|
a: '打开APP后点击“注册”,输入手机号获取验证码,设置登录密码即可完成注册。',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
q: '忘记密码怎么办?',
|
q: '忘记密码怎么办?',
|
||||||
a: '在登录页点击"忘记密码",通过绑定手机号验证码验证身份后即可重新设置密码。',
|
a: '在登录页面点击“忘记密码”,输入注册手机号获取验证码,验证通过后即可重置新密码。',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
q: '一个账号可以多地登录吗?',
|
q: '一个账号可以多端登录吗?',
|
||||||
a: '同一账号同时仅允许在 1 台设备上保持在线,超出将自动踢出最早登录的设备。',
|
a: '同一账号仅允许在 1 台设备上保持在线,超出将自动踢出最早登录的设备。',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
q: '如何修改绑定手机号?',
|
q: '如何修改绑定手机号?',
|
||||||
a: '进入 个人中心 → 账号安全 → 绑定手机,验证原手机号后即可绑定新号码。',
|
a: '进入「我的 -> 设置 -> 账户安全 -> 更换手机号」,验证原手机号后即可绑定新号码。',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '2. 功能使用指南',
|
title: '功能使用指南',
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
q: '如何提交需求?',
|
q: '如何提交报修/工单?',
|
||||||
a: '进入"发布需求"页面,填写需求描述、预算、周期等信息并提交,专业顾问将在一个工作日内与您联系。',
|
a: '首页点击「报修」 -> 选择报修类型 -> 填写问题描述并上传图片 -> 提交。提交后可在「我的 -> 我的工单」中查看处理进度。',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
q: '如何查看我的消息?',
|
q: '如何预约会议室?',
|
||||||
a: '登录后点击右上角消息图标,或进入 个人中心 → 消息通知,即可查看系统通知与顾问消息。',
|
a: '进入「服务 -> 会议室预订」,选择日期、时间段及会议室,确认后提交预约,预约成功将收到消息通知。',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
q: '如何申请售后?',
|
q: '如何查看我的消息通知?',
|
||||||
a: '在"我的订单"中找到对应项目,点击"申请售后"填写问题描述并上传附件,平台将尽快为您处理。',
|
a: '首页右上角铃铛图标进入消息中心,支持按“全部 / 未读 / 系统通知 / 业务提醒”分类查看。',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '3. 系统与权限',
|
title: '系统与权限',
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
q: '无权限怎么办?',
|
q: 'APP提示“无权限”怎么办?',
|
||||||
a: '请确认当前账号角色是否具备该模块权限;如仍无法访问,请联系专属客服或平台管理员为您开通。',
|
a: '部分功能需要管理员授权后方可使用,请联系贵司系统管理员为您分配对应角色权限。',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
q: '收不到通知怎么办?',
|
q: '为什么收不到推送通知?',
|
||||||
a: '请检查浏览器通知权限与消息设置是否开启;若仍未收到,请联系客服核实账号通知配置。',
|
a: '请检查:①手机系统设置中是否允许本APP发送通知;②APP内「我的 -> 设置 -> 消息推送」是否已开启。',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
q: '支持哪些浏览器?',
|
q: 'APP支持哪些系统版本?',
|
||||||
a: '推荐使用 Chrome、Edge、Firefox、Safari 等主流浏览器的最新版本访问本平台。',
|
a: 'iOS 13.0 及以上版本,Android 8.0 及以上版本。建议使用最新系统版本以获得最佳体验。',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,68 +1,94 @@
|
|||||||
import type { ChatMessage } from '@/types/business/service'
|
import type {
|
||||||
|
ChatUploadVo,
|
||||||
|
CsMessageCenterQuery,
|
||||||
|
CsMessagePageVo,
|
||||||
|
CsMessageVo,
|
||||||
|
CsSessionPreviewVo,
|
||||||
|
CsSessionVo,
|
||||||
|
SendCsMessageParams,
|
||||||
|
} from '@/types/business/service'
|
||||||
|
import { request } from '@/utils/request'
|
||||||
|
|
||||||
// TODO(api): 待接口文档到位后,将以下 mock 替换为 request<T> 调用
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
// POST /web/chat/session/init → 获取/创建当前客户的客服会话
|
||||||
|
// GET /web/chat/message/list → 按 sessionId 拉会话消息
|
||||||
|
// POST /web/chat/message → 客户发送消息(TEXT/IMAGE/FILE/VOICE)
|
||||||
|
// GET /web/chat/session/preview → 消息中心「在线客服」卡片未读数 + 最新一条
|
||||||
|
// GET /web/chat/message/centerList → 消息中心「在线客服」页签消息分页列表
|
||||||
|
// POST /web/chat/message/readAll → 消息中心「在线客服」一键全部已读
|
||||||
|
// 文档未提供聊天附件上传接口,复用用户端 OSS 上传(files 多文件,取首个结果)
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
let seq = 0
|
export function initChatSession(params?: {
|
||||||
|
chatType?: string
|
||||||
function nextId(prefix: string): string {
|
contact?: string
|
||||||
seq += 1
|
}): Promise<CsSessionVo> {
|
||||||
return `${prefix}-${Date.now()}-${seq}`
|
return request<CsSessionVo>({
|
||||||
}
|
url: '/web/chat/session/init',
|
||||||
|
method: 'post',
|
||||||
function nowTime(): string {
|
params: {
|
||||||
const date = new Date()
|
chatType: params?.chatType || undefined,
|
||||||
const pad = (n: number): string => (n < 10 ? `0${n}` : String(n))
|
contact: params?.contact || undefined,
|
||||||
return `今天 ${pad(date.getHours())}:${pad(date.getMinutes())}`
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getChatHistory(): Promise<ChatMessage[]> {
|
|
||||||
return Promise.resolve([
|
|
||||||
{
|
|
||||||
id: 'chat-001',
|
|
||||||
role: 'assistant',
|
|
||||||
content: '您好,欢迎咨询智联智造平台!我是您的专属客服小助手,请问有什么可以帮您的?',
|
|
||||||
time: '今天 10:23',
|
|
||||||
},
|
},
|
||||||
{
|
|
||||||
id: 'chat-002',
|
|
||||||
role: 'user',
|
|
||||||
content: '我想咨询一下物联网全案开发的流程和周期',
|
|
||||||
time: '今天 10:23',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'chat-003',
|
|
||||||
role: 'assistant',
|
|
||||||
content: '',
|
|
||||||
file: { name: '物联网全案服务介绍.pdf', size: 2.5 * 1024 * 1024 },
|
|
||||||
time: '今天 10:24',
|
|
||||||
},
|
|
||||||
])
|
|
||||||
}
|
|
||||||
|
|
||||||
export function sendChatMessage(content: string): Promise<ChatMessage> {
|
|
||||||
return Promise.resolve({
|
|
||||||
id: nextId('chat'),
|
|
||||||
role: 'user',
|
|
||||||
content,
|
|
||||||
time: nowTime(),
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function uploadChatFile(file: File): Promise<ChatMessage> {
|
export function getChatMessages(
|
||||||
return Promise.resolve({
|
sessionId: number | string,
|
||||||
id: nextId('chat'),
|
silent = false,
|
||||||
role: 'user',
|
): Promise<CsMessageVo[]> {
|
||||||
content: '',
|
return request<CsMessageVo[]>({
|
||||||
file: { name: file.name, size: file.size },
|
url: '/web/chat/message/list',
|
||||||
time: nowTime(),
|
method: 'get',
|
||||||
|
params: { sessionId },
|
||||||
|
silent,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function mockAutoReply(): Promise<ChatMessage> {
|
export function sendChatMessage(payload: SendCsMessageParams): Promise<CsMessageVo> {
|
||||||
return Promise.resolve({
|
return request<CsMessageVo>({
|
||||||
id: nextId('chat'),
|
url: '/web/chat/message',
|
||||||
role: 'assistant',
|
method: 'post',
|
||||||
content: '收到您的消息,专属客服稍后为您答复~',
|
data: payload,
|
||||||
time: nowTime(),
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 消息中心「在线客服」页签消息分页列表。 */
|
||||||
|
export function getChatCenterMessages(query: CsMessageCenterQuery): Promise<CsMessagePageVo> {
|
||||||
|
return request<CsMessagePageVo>({
|
||||||
|
url: '/web/chat/message/centerList',
|
||||||
|
method: 'get',
|
||||||
|
params: query,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 消息中心「在线客服」一键全部已读。 */
|
||||||
|
export function readAllChatMessages(): Promise<void> {
|
||||||
|
return request<void>({
|
||||||
|
url: '/web/chat/message/readAll',
|
||||||
|
method: 'post',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** silent:轮询未读数时静默失败,避免瞬时网络异常反复弹提示。 */
|
||||||
|
export function getChatSessionPreview(silent = false): Promise<CsSessionPreviewVo> {
|
||||||
|
return request<CsSessionPreviewVo>({
|
||||||
|
url: '/web/chat/session/preview',
|
||||||
|
method: 'get',
|
||||||
|
silent,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function uploadChatFile(file: File): Promise<ChatUploadVo & { url: string }> {
|
||||||
|
const form = new FormData()
|
||||||
|
form.append('files', file)
|
||||||
|
const rows = await request<ChatUploadVo[]>({
|
||||||
|
url: '/app/requirement/oss/upload',
|
||||||
|
method: 'post',
|
||||||
|
data: form,
|
||||||
|
headers: { 'Content-Type': 'multipart/form-data' },
|
||||||
|
})
|
||||||
|
const uploaded = rows?.[0]
|
||||||
|
if (!uploaded?.url) throw new Error('文件上传失败')
|
||||||
|
return { ...uploaded, url: uploaded.url }
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
import { request } from '@/utils/request'
|
import { request } from '@/utils/request'
|
||||||
import type { UserProfileVo } from '@/types/business/user'
|
import type {
|
||||||
|
AccountSecurityVo,
|
||||||
|
UserProfileUpdatePayload,
|
||||||
|
UserProfileVo,
|
||||||
|
} from '@/types/business/user'
|
||||||
|
|
||||||
export async function getUserProfile(): Promise<UserProfileVo> {
|
export async function getUserProfile(): Promise<UserProfileVo> {
|
||||||
const data = await request<{ user: UserProfileVo }>({
|
const data = await request<{ user: UserProfileVo }>({
|
||||||
@@ -8,3 +12,23 @@ export async function getUserProfile(): Promise<UserProfileVo> {
|
|||||||
})
|
})
|
||||||
return data.user
|
return data.user
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 账号安全信息:密码修改时间等(WEB 端复用 APP 接口)。 */
|
||||||
|
export async function getAccountSecurity(): Promise<AccountSecurityVo> {
|
||||||
|
const data = await request<AccountSecurityVo & { accountSecurity?: AccountSecurityVo }>({
|
||||||
|
url: '/app/account/security',
|
||||||
|
method: 'get',
|
||||||
|
silent: true,
|
||||||
|
})
|
||||||
|
// 兼容后端可能包一层 accountSecurity 的返回结构
|
||||||
|
return data?.accountSecurity ?? data
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 更新个人资料,只提交传入的字段。 */
|
||||||
|
export function updateUserProfile(payload: UserProfileUpdatePayload): Promise<void> {
|
||||||
|
return request<void>({
|
||||||
|
url: '/web/system/user/profile',
|
||||||
|
method: 'put',
|
||||||
|
data: payload,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
BIN
src/assets/home/chahua.png
Normal file
BIN
src/assets/home/chahua.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.0 KiB |
@@ -85,90 +85,71 @@ const coreBusiness = [
|
|||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
.app-footer {
|
.app-footer {
|
||||||
// 设计稿:footer 顶 y=1942,总高 481px。各行绝对坐标换算为相对 footer 顶:
|
|
||||||
// 列标题 54 / 内容首行 115 / legal[0] 332 / legal[1] 371。
|
|
||||||
min-height: @footer-height;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
background: @footer-bg;
|
background: @footer-bg;
|
||||||
color: @white;
|
color: @white;
|
||||||
|
padding: @spacing-xl 0 @spacing-base;
|
||||||
|
|
||||||
&__inner {
|
&__inner {
|
||||||
.flex(row, flex-start, flex-start);
|
.flex(row, space-between, flex-start);
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: @spacing-xl;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-width: 1920px;
|
max-width: @page-content;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
height: 250px;
|
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
padding-top: 54px;
|
padding: 0 @page-gutter;
|
||||||
padding-left: clamp(
|
|
||||||
@spacing-base,
|
|
||||||
calc((100% - 1609px) / 2),
|
|
||||||
155px
|
|
||||||
);
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&__about {
|
&__about {
|
||||||
flex: 0 1 625px; // x155 → 780
|
flex: 0 1 360px;
|
||||||
|
max-width: 420px;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__brand {
|
&__brand {
|
||||||
.flex(row, flex-start);
|
.flex(row, flex-start);
|
||||||
margin-bottom: 20px;
|
margin-bottom: @spacing-sm;
|
||||||
margin-left: 45px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&__name {
|
&__name {
|
||||||
font-size: 28px;
|
font-size: @font-size-lg;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
line-height: 41px;
|
line-height: 1.4;
|
||||||
color: @white;
|
color: @white;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__desc {
|
&__desc {
|
||||||
margin-top: 0;
|
margin: 0;
|
||||||
font-size: 16px;
|
font-size: @font-size-sm;
|
||||||
font-weight: 500;
|
font-weight: 400;
|
||||||
line-height: 23px;
|
line-height: 1.6;
|
||||||
|
color: fade(@white, 72%);
|
||||||
}
|
}
|
||||||
|
|
||||||
&__col {
|
&__col {
|
||||||
.flex(column, flex-start, flex-start);
|
.flex(column, flex-start, flex-start);
|
||||||
gap: 0;
|
gap: 2px;
|
||||||
|
flex: 0 0 auto;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
|
|
||||||
&--core {
|
|
||||||
flex: 0 0 193px;
|
|
||||||
margin-left: 142px;
|
|
||||||
}
|
|
||||||
&--nav {
|
|
||||||
flex: 0 0 80px;
|
|
||||||
margin-left: 142px;
|
|
||||||
}
|
|
||||||
&--contact {
|
|
||||||
flex: 0 0 253px;
|
|
||||||
margin-left: 174px;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&__title {
|
&__title {
|
||||||
margin-bottom: 20px;
|
margin: 0 0 @spacing-sm;
|
||||||
font-size: 28px;
|
font-size: @font-size-base;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
line-height: 41px;
|
line-height: 1.4;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
color: @white;
|
color: @white;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__link {
|
&__link {
|
||||||
font-size: 16px;
|
font-size: @font-size-sm;
|
||||||
font-weight: 500;
|
font-weight: 400;
|
||||||
line-height: 23px;
|
line-height: 1.7;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: color 0.2s;
|
transition: color 0.2s;
|
||||||
|
color: fade(@white, 72%);
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
color: @primary-light;
|
color: @primary-light;
|
||||||
@@ -176,32 +157,31 @@ const coreBusiness = [
|
|||||||
}
|
}
|
||||||
|
|
||||||
&__contact {
|
&__contact {
|
||||||
font-size: 16px;
|
font-size: @font-size-sm;
|
||||||
font-weight: 500;
|
font-weight: 400;
|
||||||
line-height: 23px;
|
line-height: 1.7;
|
||||||
|
color: fade(@white, 72%);
|
||||||
}
|
}
|
||||||
|
|
||||||
&__bottom {
|
&__bottom {
|
||||||
width: 867px;
|
width: 100%;
|
||||||
max-width: calc(100% - 32px);
|
max-width: @page-content;
|
||||||
margin: 0 auto;
|
margin: @spacing-lg auto 0;
|
||||||
padding-bottom: 20px;
|
padding: @spacing-base @page-gutter 0;
|
||||||
text-align: left;
|
border-top: 1px solid fade(@white, 10%);
|
||||||
// legal[0] 需落在相对 footer 顶 332px 处
|
text-align: center;
|
||||||
margin-top: 62px;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__legal {
|
&__legal {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font-size: 14px;
|
font-size: @font-size-xs;
|
||||||
font-weight: 500;
|
font-weight: 400;
|
||||||
line-height: 23px;
|
line-height: 1.6;
|
||||||
white-space: nowrap;
|
color: fade(@white, 55%);
|
||||||
color: @white;
|
|
||||||
|
|
||||||
&--icp {
|
&--icp {
|
||||||
margin-top: 16px;
|
margin-top: @spacing-xs;
|
||||||
margin-left: 315px;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onMounted } from 'vue'
|
import { computed, onMounted, onUnmounted, watch } from 'vue'
|
||||||
|
import { useRoute } from 'vue-router'
|
||||||
import { storeToRefs } from 'pinia'
|
import { storeToRefs } from 'pinia'
|
||||||
import { useMessageStore } from '@/stores/modules/message'
|
import { useMessageStore } from '@/stores/modules/message'
|
||||||
|
import { useUserStore } from '@/stores/modules/user'
|
||||||
|
|
||||||
interface NavItem {
|
interface NavItem {
|
||||||
label: string
|
label: string
|
||||||
@@ -18,9 +20,59 @@ const navItems: NavItem[] = [
|
|||||||
{ label: '个人中心', path: '/profile' },
|
{ label: '个人中心', path: '/profile' },
|
||||||
]
|
]
|
||||||
|
|
||||||
|
// 首页 path 为 '/',是其它所有路径的前缀;用 Vue Router 默认的
|
||||||
|
// router-link-active(包含匹配)会导致首页在所有页面都被点亮。
|
||||||
|
// 这里自算激活态:首页仅严格等于 '/' 时高亮,其它菜单等于其路径或以 '/path/' 开头
|
||||||
|
// (覆盖子路由,如 /project/123 点亮「项目中心」)。
|
||||||
|
const route = useRoute()
|
||||||
|
const activePath = computed(() => route.path)
|
||||||
|
function isActive(item: NavItem): boolean {
|
||||||
|
const current = activePath.value
|
||||||
|
if (item.path === '/') return current === '/'
|
||||||
|
return current === item.path || current.startsWith(item.path + '/')
|
||||||
|
}
|
||||||
|
|
||||||
const messageStore = useMessageStore()
|
const messageStore = useMessageStore()
|
||||||
const { unreadCount } = storeToRefs(messageStore)
|
const { unreadCount } = storeToRefs(messageStore)
|
||||||
onMounted(() => void messageStore.fetchUnreadCount())
|
const userStore = useUserStore()
|
||||||
|
const { isLoggedIn } = storeToRefs(userStore)
|
||||||
|
|
||||||
|
/* ------------------------------ 未读数轮询 ------------------------------ */
|
||||||
|
|
||||||
|
/** 顶部铃铛未读数轮询间隔 */
|
||||||
|
const UNREAD_POLL_INTERVAL = 5_000
|
||||||
|
let unreadTimer: ReturnType<typeof setInterval> | undefined
|
||||||
|
|
||||||
|
/** 未登录时接口必然失败,不轮询;轮询请求静默失败,避免网络抖动弹提示。 */
|
||||||
|
function refreshUnread(): void {
|
||||||
|
if (!isLoggedIn.value) return
|
||||||
|
void messageStore.fetchUnreadCount(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
function onVisibilityChange(): void {
|
||||||
|
if (document.visibilityState === 'visible') refreshUnread()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 登录后立即拉取一次,不必等下一个轮询周期
|
||||||
|
watch(isLoggedIn, (loggedIn) => {
|
||||||
|
if (loggedIn) refreshUnread()
|
||||||
|
})
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
refreshUnread()
|
||||||
|
unreadTimer = setInterval(() => {
|
||||||
|
if (document.visibilityState === 'visible') refreshUnread()
|
||||||
|
}, UNREAD_POLL_INTERVAL)
|
||||||
|
document.addEventListener('visibilitychange', onVisibilityChange)
|
||||||
|
})
|
||||||
|
|
||||||
|
onUnmounted(() => {
|
||||||
|
if (unreadTimer) {
|
||||||
|
clearInterval(unreadTimer)
|
||||||
|
unreadTimer = undefined
|
||||||
|
}
|
||||||
|
document.removeEventListener('visibilitychange', onVisibilityChange)
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -32,6 +84,7 @@ onMounted(() => void messageStore.fetchUnreadCount())
|
|||||||
:key="item.path"
|
:key="item.path"
|
||||||
:to="item.path"
|
:to="item.path"
|
||||||
class="app-header__nav-item"
|
class="app-header__nav-item"
|
||||||
|
:class="{ 'app-header__nav-item--active': isActive(item) }"
|
||||||
>
|
>
|
||||||
{{ item.label }}
|
{{ item.label }}
|
||||||
</RouterLink>
|
</RouterLink>
|
||||||
@@ -92,29 +145,29 @@ onMounted(() => void messageStore.fetchUnreadCount())
|
|||||||
|
|
||||||
&__nav {
|
&__nav {
|
||||||
.flex(row, center);
|
.flex(row, center);
|
||||||
gap: @header-nav-gap;
|
gap: clamp(@spacing-lg, 4vw, 56px);
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
|
||||||
&-item {
|
&-item {
|
||||||
position: relative;
|
position: relative;
|
||||||
.flex(row, center);
|
.flex(row, center);
|
||||||
height: 100%;
|
height: 100%;
|
||||||
font-size: 18px;
|
font-size: @font-size-md;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
color: @black;
|
color: @heading-color;
|
||||||
transition: color 0.2s;
|
transition: color 0.2s;
|
||||||
|
|
||||||
&:hover,
|
&:hover,
|
||||||
&.router-link-active {
|
&--active {
|
||||||
color: @home-tab-active;
|
color: @home-tab-active;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.router-link-active::after {
|
&--active::after {
|
||||||
content: '';
|
content: '';
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 50%;
|
left: 50%;
|
||||||
bottom: 11px;
|
bottom: 12px;
|
||||||
width: 29px;
|
width: 24px;
|
||||||
height: 2px;
|
height: 2px;
|
||||||
border-radius: 1px;
|
border-radius: 1px;
|
||||||
background: @home-tab-active;
|
background: @home-tab-active;
|
||||||
@@ -125,20 +178,21 @@ onMounted(() => void messageStore.fetchUnreadCount())
|
|||||||
|
|
||||||
&__actions {
|
&__actions {
|
||||||
.flex(row, flex-end, center);
|
.flex(row, flex-end, center);
|
||||||
gap: 29px;
|
gap: @spacing-base;
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__action {
|
&__action {
|
||||||
.flex(row, center);
|
.flex(row, center);
|
||||||
gap: 5px;
|
gap: @spacing-xs;
|
||||||
width: 106px;
|
min-width: 96px;
|
||||||
height: 36px;
|
height: 36px;
|
||||||
border-radius: @radius-sm;
|
padding: 0 @spacing-base;
|
||||||
|
border-radius: @radius-round;
|
||||||
background: @primary-color;
|
background: @primary-color;
|
||||||
color: @white;
|
color: @white;
|
||||||
font-size: 16px;
|
font-size: @font-size-sm;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
transition: opacity 0.2s;
|
transition: opacity 0.2s;
|
||||||
|
|
||||||
@@ -147,8 +201,8 @@ onMounted(() => void messageStore.fetchUnreadCount())
|
|||||||
}
|
}
|
||||||
|
|
||||||
&-icon {
|
&-icon {
|
||||||
width: 18px;
|
width: 16px;
|
||||||
height: 18px;
|
height: 16px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,7 +236,7 @@ onMounted(() => void messageStore.fetchUnreadCount())
|
|||||||
}
|
}
|
||||||
|
|
||||||
&__login {
|
&__login {
|
||||||
font-size: 16px;
|
font-size: @font-size-base;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,16 +97,16 @@ const meta = computed<Array<{ label: string; value: string }>>(() => [
|
|||||||
|
|
||||||
&__tag {
|
&__tag {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 87px;
|
top: 12px;
|
||||||
left: 22px;
|
left: 12px;
|
||||||
height: 44px;
|
height: 28px;
|
||||||
padding: 0 14px;
|
padding: 0 @spacing-sm;
|
||||||
border-radius: @radius-sm;
|
border-radius: @radius-sm;
|
||||||
background: @primary-strong;
|
background: @primary-strong;
|
||||||
color: @white;
|
color: @white;
|
||||||
font-size: 28px;
|
font-size: @font-size-sm;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
line-height: 44px;
|
line-height: 28px;
|
||||||
|
|
||||||
&--hardware {
|
&--hardware {
|
||||||
background: @tag-hardware;
|
background: @tag-hardware;
|
||||||
|
|||||||
@@ -292,15 +292,15 @@ function clearChips(): void {
|
|||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
.case-filter {
|
.case-filter {
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
width: 516px;
|
width: @cases-filter-width;
|
||||||
padding: 15px 0 40px;
|
padding: @spacing-lg 0 @spacing-xl;
|
||||||
border-radius: @radius-base;
|
border-radius: @radius-base;
|
||||||
background: @white;
|
background: @white;
|
||||||
|
|
||||||
&__head,
|
&__head,
|
||||||
&__group,
|
&__group,
|
||||||
&__actions {
|
&__actions {
|
||||||
padding: 0 50px 0 35px;
|
padding: 0 @spacing-lg;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__head {
|
&__head {
|
||||||
@@ -308,15 +308,15 @@ function clearChips(): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
&__title {
|
&__title {
|
||||||
font-size: 28px;
|
font-size: @font-size-xl;
|
||||||
font-weight: 500;
|
font-weight: 600;
|
||||||
line-height: 41px;
|
line-height: 1.4;
|
||||||
color: @cases-filter-title;
|
color: @cases-filter-title;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__link {
|
&__link {
|
||||||
color: @primary-strong;
|
color: @primary-strong;
|
||||||
font-size: 16px;
|
font-size: @font-size-sm;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
color: @primary-hover;
|
color: @primary-hover;
|
||||||
@@ -324,32 +324,36 @@ function clearChips(): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
&__group {
|
&__group {
|
||||||
margin-top: 24px;
|
margin-top: @spacing-lg;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__head + &__group {
|
&__head + &__group {
|
||||||
margin-top: 11px;
|
margin-top: @spacing-base;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__group-title {
|
&__group-title {
|
||||||
font-size: 24px;
|
font-size: @font-size-md;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
line-height: 35px;
|
line-height: 1.4;
|
||||||
color: @cases-text;
|
color: @cases-text;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__rows {
|
&__rows {
|
||||||
margin-top: 19px;
|
margin-top: @spacing-sm;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__row {
|
&__row {
|
||||||
.flex(row, flex-start, center);
|
.flex(row, flex-start, center);
|
||||||
gap: 12px;
|
gap: @spacing-sm;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 50px;
|
height: 40px;
|
||||||
padding: 0;
|
padding: 0 @spacing-sm;
|
||||||
|
border-radius: @radius-sm;
|
||||||
color: @cases-text;
|
color: @cases-text;
|
||||||
font-size: 20px;
|
font-size: @font-size-base;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
transition: background 0.2s;
|
transition: background 0.2s;
|
||||||
|
|
||||||
@@ -367,8 +371,8 @@ function clearChips(): void {
|
|||||||
&__box {
|
&__box {
|
||||||
position: relative;
|
position: relative;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
width: 16px;
|
width: 14px;
|
||||||
height: 16px;
|
height: 14px;
|
||||||
border: 1px solid @cases-input-border;
|
border: 1px solid @cases-input-border;
|
||||||
border-radius: 2px;
|
border-radius: 2px;
|
||||||
|
|
||||||
@@ -380,9 +384,9 @@ function clearChips(): void {
|
|||||||
content: '';
|
content: '';
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 1px;
|
top: 1px;
|
||||||
left: 4px;
|
left: 3px;
|
||||||
width: 5px;
|
width: 4px;
|
||||||
height: 8px;
|
height: 7px;
|
||||||
border: solid @white;
|
border: solid @white;
|
||||||
border-width: 0 2px 2px 0;
|
border-width: 0 2px 2px 0;
|
||||||
transform: rotate(45deg);
|
transform: rotate(45deg);
|
||||||
@@ -397,7 +401,7 @@ function clearChips(): void {
|
|||||||
|
|
||||||
&__row-count {
|
&__row-count {
|
||||||
color: @cases-muted;
|
color: @cases-muted;
|
||||||
font-size: 16px;
|
font-size: @font-size-sm;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -409,17 +413,17 @@ function clearChips(): void {
|
|||||||
&__pills {
|
&__pills {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||||
gap: 24px 33px;
|
gap: @spacing-sm;
|
||||||
margin-top: 21px;
|
margin-top: @spacing-sm;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__pill {
|
&__pill {
|
||||||
height: 53px;
|
height: 36px;
|
||||||
padding: 0 @spacing-sm;
|
padding: 0 @spacing-sm;
|
||||||
border-radius: @radius-base;
|
border-radius: @radius-base;
|
||||||
background: @pill-bg;
|
background: @pill-bg;
|
||||||
color: @cases-text;
|
color: @cases-text;
|
||||||
font-size: 20px;
|
font-size: @font-size-sm;
|
||||||
.ellipsis();
|
.ellipsis();
|
||||||
transition: all 0.2s;
|
transition: all 0.2s;
|
||||||
|
|
||||||
@@ -429,15 +433,14 @@ function clearChips(): void {
|
|||||||
|
|
||||||
&.is-active,
|
&.is-active,
|
||||||
&.is-light {
|
&.is-light {
|
||||||
background: @pill-selected-bg;
|
background: @filter-selected-bg;
|
||||||
color: @white;
|
color: @primary-strong;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ElDatePicker 有两层元素:外层 div.case-filter__date 与内部 .el-range-editor,
|
// ElDatePicker 有两层元素:外层 div.case-filter__date 与内部 .el-range-editor,
|
||||||
// 真正控制盒子尺寸的是内层。所以尺寸/背景/圆角都要用 :deep() 打到内层,
|
// 真正控制盒子尺寸的是内层。所以尺寸/背景/圆角都要用 :deep() 打到内层。
|
||||||
// 且不能写在 &__date 上——那样只命中外层,视觉上看不到变化。
|
|
||||||
&__date-wrap {
|
&__date-wrap {
|
||||||
grid-column: 1 / -1;
|
grid-column: 1 / -1;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
@@ -448,7 +451,7 @@ function clearChips(): void {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
height: 53px;
|
height: 36px;
|
||||||
padding: 0 @spacing-sm;
|
padding: 0 @spacing-sm;
|
||||||
border-radius: @radius-base;
|
border-radius: @radius-base;
|
||||||
background: @input-bg;
|
background: @input-bg;
|
||||||
@@ -461,7 +464,7 @@ function clearChips(): void {
|
|||||||
&__date {
|
&__date {
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
height: 53px;
|
height: 36px;
|
||||||
padding: 0 @spacing-sm;
|
padding: 0 @spacing-sm;
|
||||||
border-radius: @radius-base;
|
border-radius: @radius-base;
|
||||||
background: @input-bg;
|
background: @input-bg;
|
||||||
@@ -481,32 +484,33 @@ function clearChips(): void {
|
|||||||
|
|
||||||
:deep(.el-range-input) {
|
:deep(.el-range-input) {
|
||||||
flex: 0 1 auto;
|
flex: 0 1 auto;
|
||||||
width: 92px;
|
width: 88px;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
color: @cases-text;
|
color: @cases-text;
|
||||||
font-size: 20px;
|
font-size: @font-size-sm;
|
||||||
|
|
||||||
&::placeholder {
|
&::placeholder {
|
||||||
color: @cases-text;
|
color: @cases-muted;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
:deep(.el-range-separator) {
|
:deep(.el-range-separator) {
|
||||||
flex: 0 0 auto;
|
flex: 0 0 auto;
|
||||||
margin: 0 @spacing-xs;
|
margin: 0 @spacing-xs;
|
||||||
color: @cases-text;
|
color: @cases-muted;
|
||||||
font-size: 20px;
|
font-size: @font-size-sm;
|
||||||
line-height: 53px;
|
line-height: 36px;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.is-focus {
|
&.is-focus {
|
||||||
background: @input-bg;
|
background: @white;
|
||||||
|
box-shadow: 0 0 0 1px @cases-accent inset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&__selected {
|
&__selected {
|
||||||
margin: 23px 50px 0 35px;
|
margin: @spacing-lg @spacing-lg 0;
|
||||||
padding: 16px 24px 21px;
|
padding: @spacing-base;
|
||||||
border-radius: @radius-base;
|
border-radius: @radius-base;
|
||||||
background: @chips-panel-bg;
|
background: @chips-panel-bg;
|
||||||
}
|
}
|
||||||
@@ -517,30 +521,30 @@ function clearChips(): void {
|
|||||||
|
|
||||||
&__selected-title {
|
&__selected-title {
|
||||||
color: @cases-text;
|
color: @cases-text;
|
||||||
font-size: 20px;
|
font-size: @font-size-base;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__selected-empty {
|
&__selected-empty {
|
||||||
margin-top: @spacing-sm;
|
margin-top: @spacing-sm;
|
||||||
color: @cases-muted;
|
color: @cases-muted;
|
||||||
font-size: 14px;
|
font-size: @font-size-sm;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__chips {
|
&__chips {
|
||||||
.flex(row, flex-start, center);
|
.flex(row, flex-start, center);
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
gap: 14px 13px;
|
gap: @spacing-sm;
|
||||||
margin-top: 16px;
|
margin-top: @spacing-sm;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__chip {
|
&__chip {
|
||||||
height: 32px;
|
height: 28px;
|
||||||
padding: 0 @spacing-sm;
|
padding: 0 @spacing-sm;
|
||||||
border-radius: @radius-round;
|
border-radius: @radius-round;
|
||||||
background: @white;
|
background: @white;
|
||||||
color: @cases-accent;
|
color: @cases-accent;
|
||||||
font-size: 14px;
|
font-size: @font-size-sm;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
transition: color 0.2s;
|
transition: color 0.2s;
|
||||||
|
|
||||||
@@ -551,32 +555,32 @@ function clearChips(): void {
|
|||||||
|
|
||||||
&__actions {
|
&__actions {
|
||||||
.flex(row, flex-start, center);
|
.flex(row, flex-start, center);
|
||||||
gap: 13px;
|
gap: @spacing-sm;
|
||||||
margin-top: 30px;
|
margin-top: @spacing-lg;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__reset {
|
&__reset {
|
||||||
width: 135px;
|
flex: 0 0 88px;
|
||||||
height: 30px;
|
height: 32px;
|
||||||
border-radius: @radius-round;
|
border-radius: @radius-round;
|
||||||
background: @cases-reset-bg;
|
background: @cases-reset-bg;
|
||||||
color: @black;
|
color: @text-color;
|
||||||
font-size: 14px;
|
font-size: @font-size-sm;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
transition: filter 0.2s;
|
transition: color 0.2s;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
filter: brightness(0.96);
|
color: @primary-color;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&__confirm {
|
&__confirm {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
height: 30px;
|
height: 32px;
|
||||||
border-radius: @radius-round;
|
border-radius: @radius-round;
|
||||||
background: @cases-confirm;
|
background: @cases-confirm;
|
||||||
color: @white;
|
color: @white;
|
||||||
font-size: 14px;
|
font-size: @font-size-sm;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
transition: background 0.2s;
|
transition: background 0.2s;
|
||||||
|
|
||||||
@@ -4,9 +4,11 @@ import { computed } from 'vue'
|
|||||||
interface Props {
|
interface Props {
|
||||||
keyword: string
|
keyword: string
|
||||||
favoriteOnly: boolean
|
favoriteOnly: boolean
|
||||||
|
/** 是否显示「收藏列表」切换按钮(案例库显示,收藏页本身不显示) */
|
||||||
|
showFavoriteToggle?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
const props = defineProps<Props>()
|
const props = withDefaults(defineProps<Props>(), { showFavoriteToggle: true })
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
'update:keyword': [keyword: string]
|
'update:keyword': [keyword: string]
|
||||||
@@ -44,6 +46,7 @@ const keyword = computed<string>({
|
|||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
|
v-if="showFavoriteToggle"
|
||||||
class="case-search__fav"
|
class="case-search__fav"
|
||||||
:class="{ 'is-active': favoriteOnly }"
|
:class="{ 'is-active': favoriteOnly }"
|
||||||
@click="emit('toggleFavoriteOnly')"
|
@click="emit('toggleFavoriteOnly')"
|
||||||
@@ -59,29 +62,27 @@ const keyword = computed<string>({
|
|||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
.case-search {
|
.case-search {
|
||||||
.flex(row, flex-start, center);
|
.flex(row, flex-start, center);
|
||||||
gap: 24px;
|
gap: @spacing-base;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 128px;
|
min-height: 64px;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
// 设计稿 #31:输入框 x=653(栏左 606 + 47),重置 1305,搜索 1429
|
padding: 0 @spacing-lg;
|
||||||
padding: 0 47px;
|
|
||||||
border-radius: @radius-base;
|
border-radius: @radius-base;
|
||||||
background: @white;
|
background: @white;
|
||||||
|
|
||||||
&__field {
|
&__field {
|
||||||
position: relative;
|
position: relative;
|
||||||
// 输入框右边界 1245 → 重置按钮 1305,设计稿间距 60
|
flex: 0 1 360px;
|
||||||
margin-right: 36px;
|
min-width: 0;
|
||||||
flex: 0 0 592px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&__icon {
|
&__icon {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 50%;
|
top: 50%;
|
||||||
right: 16px;
|
right: @spacing-base;
|
||||||
left: auto;
|
left: auto;
|
||||||
width: 27px;
|
width: 18px;
|
||||||
height: 27px;
|
height: 18px;
|
||||||
transform: translateY(-50%);
|
transform: translateY(-50%);
|
||||||
fill: none;
|
fill: none;
|
||||||
stroke: @cases-icon;
|
stroke: @cases-icon;
|
||||||
@@ -90,15 +91,15 @@ const keyword = computed<string>({
|
|||||||
|
|
||||||
&__input {
|
&__input {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 49px;
|
height: 36px;
|
||||||
padding: 0 52px 0 20px;
|
padding: 0 40px 0 @spacing-base;
|
||||||
border: 1px solid @cases-input-border;
|
border: 1px solid @cases-input-border;
|
||||||
border-radius: @radius-sm;
|
border-radius: @radius-round;
|
||||||
background: @white;
|
background: @input-bg;
|
||||||
color: @cases-text;
|
color: @cases-text;
|
||||||
font-size: 20px;
|
font-size: @font-size-base;
|
||||||
outline: none;
|
outline: none;
|
||||||
transition: border-color 0.2s;
|
transition: border-color 0.2s, background-color 0.2s;
|
||||||
|
|
||||||
&::placeholder {
|
&::placeholder {
|
||||||
color: @text-color-disabled;
|
color: @text-color-disabled;
|
||||||
@@ -106,22 +107,24 @@ const keyword = computed<string>({
|
|||||||
|
|
||||||
&:focus {
|
&:focus {
|
||||||
border-color: @cases-accent;
|
border-color: @cases-accent;
|
||||||
|
background: @white;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&__btn {
|
&__btn {
|
||||||
min-width: 100px;
|
flex-shrink: 0;
|
||||||
height: 49px;
|
min-width: 72px;
|
||||||
padding: 0 @spacing-base;
|
height: 36px;
|
||||||
border-radius: @radius-sm;
|
padding: 0 @spacing-lg;
|
||||||
background: @cases-accent;
|
border-radius: @radius-round;
|
||||||
color: @white;
|
background: @pill-bg;
|
||||||
font-size: 20px;
|
color: @text-color;
|
||||||
|
font-size: @font-size-base;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
transition: all 0.2s;
|
transition: all 0.2s;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
background: @primary-hover;
|
color: @primary-color;
|
||||||
}
|
}
|
||||||
|
|
||||||
&--primary {
|
&--primary {
|
||||||
@@ -140,7 +143,7 @@ const keyword = computed<string>({
|
|||||||
gap: @spacing-xs;
|
gap: @spacing-xs;
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
color: @heading-color;
|
color: @heading-color;
|
||||||
font-size: 16px;
|
font-size: @font-size-base;
|
||||||
transition: color 0.2s;
|
transition: color 0.2s;
|
||||||
|
|
||||||
&:hover,
|
&:hover,
|
||||||
69
src/components/EllipsisText.vue
Normal file
69
src/components/EllipsisText.vue
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
||||||
|
import { ElTooltip } from 'element-plus'
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
text: string
|
||||||
|
placement?: 'top' | 'bottom' | 'left' | 'right'
|
||||||
|
}
|
||||||
|
|
||||||
|
const props = withDefaults(defineProps<Props>(), {
|
||||||
|
placement: 'top',
|
||||||
|
})
|
||||||
|
|
||||||
|
const root = ref<HTMLElement | null>(null)
|
||||||
|
const overflow = ref(false)
|
||||||
|
|
||||||
|
function check(): void {
|
||||||
|
const el = root.value
|
||||||
|
if (!el) return
|
||||||
|
overflow.value = el.scrollWidth > el.clientWidth + 1
|
||||||
|
}
|
||||||
|
|
||||||
|
let ro: ResizeObserver | null = null
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
check()
|
||||||
|
if (root.value && typeof ResizeObserver !== 'undefined') {
|
||||||
|
ro = new ResizeObserver(() => check())
|
||||||
|
ro.observe(root.value)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
ro?.disconnect()
|
||||||
|
ro = null
|
||||||
|
})
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.text,
|
||||||
|
() => check(),
|
||||||
|
)
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<span ref="root" class="ellipsis-text">
|
||||||
|
<ElTooltip :content="text" :disabled="!overflow" :placement="placement" effect="dark">
|
||||||
|
<span class="ellipsis-text__inner">{{ text }}</span>
|
||||||
|
</ElTooltip>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style lang="less" scoped>
|
||||||
|
.ellipsis-text {
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
|
margin-top: 6px;
|
||||||
|
font-size: @font-size-base;
|
||||||
|
font-weight: 600;
|
||||||
|
color: @profile-ink;
|
||||||
|
line-height: 20px;
|
||||||
|
.ellipsis();
|
||||||
|
|
||||||
|
&__inner {
|
||||||
|
display: inline-block;
|
||||||
|
max-width: 100%;
|
||||||
|
vertical-align: bottom;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -71,54 +71,55 @@ const emit = defineEmits<{
|
|||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
.filter-panel {
|
.filter-panel {
|
||||||
padding: 24px 36px;
|
padding: @spacing-lg;
|
||||||
border-radius: @radius-base;
|
border-radius: @radius-base;
|
||||||
background: @white;
|
background: @white;
|
||||||
|
|
||||||
&__bar {
|
&__bar {
|
||||||
.flex(row, flex-start);
|
.flex(row, flex-start, center);
|
||||||
gap: 18px;
|
gap: @spacing-base;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__input {
|
&__input {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
max-width: 456px;
|
max-width: 360px;
|
||||||
margin-right: 28px;
|
margin-right: 0;
|
||||||
height: 38px;
|
height: 36px;
|
||||||
padding: 0 @spacing-base;
|
padding: 0 @spacing-base;
|
||||||
border: 1px solid @cases-input-border;
|
border: 1px solid @border-color;
|
||||||
border-radius: @radius-sm;
|
border-radius: @radius-round;
|
||||||
background: @white;
|
background: @input-bg;
|
||||||
color: @cases-text;
|
color: @text-color;
|
||||||
font-size: 15px;
|
font-size: @font-size-base;
|
||||||
outline: none;
|
outline: none;
|
||||||
transition: border-color 0.2s;
|
transition: border-color 0.2s, background-color 0.2s;
|
||||||
|
|
||||||
&::placeholder {
|
&::placeholder {
|
||||||
color: @cases-input-border;
|
color: @text-color-disabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
&:focus {
|
&:focus {
|
||||||
border-color: @cases-accent;
|
border-color: @primary-color;
|
||||||
|
background: @white;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&__btn {
|
&__btn {
|
||||||
min-width: 77px;
|
min-width: 72px;
|
||||||
height: 38px;
|
height: 36px;
|
||||||
padding: 0 @spacing-base;
|
padding: 0 @spacing-lg;
|
||||||
border-radius: @radius-sm;
|
border-radius: @radius-round;
|
||||||
background: @cases-accent;
|
background: @pill-bg;
|
||||||
color: @white;
|
color: @text-color;
|
||||||
font-size: 15px;
|
font-size: @font-size-base;
|
||||||
transition: all 0.2s;
|
transition: all 0.2s;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
background: @primary-hover;
|
color: @primary-color;
|
||||||
}
|
}
|
||||||
|
|
||||||
&--primary {
|
&--primary {
|
||||||
background: @cases-accent;
|
background: @primary-color;
|
||||||
color: @white;
|
color: @white;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
@@ -131,26 +132,26 @@ const emit = defineEmits<{
|
|||||||
&__chips {
|
&__chips {
|
||||||
.flex(row, flex-start, center);
|
.flex(row, flex-start, center);
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
gap: 11px 10px;
|
gap: @spacing-sm;
|
||||||
margin-top: @spacing-base;
|
margin-top: @spacing-base;
|
||||||
padding: 12px 18px 16px;
|
padding: @spacing-base;
|
||||||
border-radius: @radius-base;
|
border-radius: @radius-base;
|
||||||
background: @chips-panel-bg;
|
background: @chips-panel-bg;
|
||||||
font-size: 15px;
|
font-size: @font-size-base;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__chips-label {
|
&__chips-label {
|
||||||
color: @cases-text;
|
color: @text-color;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__chip {
|
&__chip {
|
||||||
height: 25px;
|
height: 28px;
|
||||||
padding: 0 @spacing-sm;
|
padding: 0 @spacing-sm;
|
||||||
border-radius: @radius-round;
|
border-radius: @radius-round;
|
||||||
background: @white;
|
background: @white;
|
||||||
color: @cases-accent;
|
color: @primary-color;
|
||||||
font-size: 11px;
|
font-size: @font-size-sm;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
transition: all 0.2s;
|
transition: all 0.2s;
|
||||||
|
|
||||||
|
|||||||
@@ -23,23 +23,25 @@ defineProps<Props>()
|
|||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
.page-head {
|
.page-head {
|
||||||
background: @white;
|
background: @white;
|
||||||
padding-bottom: 72px;
|
padding: @spacing-lg 0;
|
||||||
|
border-bottom: 1px solid @border-color;
|
||||||
|
|
||||||
&__title {
|
&__title {
|
||||||
padding-top: 52px;
|
padding-top: 0;
|
||||||
font-size: 22px;
|
font-size: @font-size-title;
|
||||||
font-weight: 700;
|
font-weight: 600;
|
||||||
line-height: 29px;
|
line-height: 1.3;
|
||||||
color: @finance-ink;
|
color: @heading-color;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__slogan {
|
&__slogan {
|
||||||
|
text-align: left;
|
||||||
padding-bottom: 0;
|
padding-bottom: 0;
|
||||||
margin-top: 9px;
|
margin-top: @spacing-sm;
|
||||||
font-size: 13px;
|
font-size: @font-size-base;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
line-height: 17px;
|
line-height: 1.5;
|
||||||
color: @finance-muted-text;
|
color: @text-color-secondary;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -67,18 +67,18 @@ function go(page: number): void {
|
|||||||
.pagination {
|
.pagination {
|
||||||
.flex(row, center);
|
.flex(row, center);
|
||||||
gap: @spacing-xs;
|
gap: @spacing-xs;
|
||||||
padding: 12px 0;
|
padding: @spacing-base 0;
|
||||||
|
|
||||||
&__btn {
|
&__btn {
|
||||||
.flex(row, center);
|
.flex(row, center);
|
||||||
min-width: 20px;
|
min-width: 28px;
|
||||||
height: 25px;
|
height: 28px;
|
||||||
padding: 0 3px;
|
padding: 0 6px;
|
||||||
border: 1px solid @border-color;
|
border: 1px solid @border-color;
|
||||||
border-radius: @radius-sm;
|
border-radius: @radius-sm;
|
||||||
background: @white;
|
background: @white;
|
||||||
color: @text-color-secondary;
|
color: @text-color;
|
||||||
font-size: 11px;
|
font-size: @font-size-sm;
|
||||||
transition: all 0.2s;
|
transition: all 0.2s;
|
||||||
|
|
||||||
&:hover:not(:disabled):not(.is-ellipsis) {
|
&:hover:not(:disabled):not(.is-ellipsis) {
|
||||||
@@ -87,9 +87,10 @@ function go(page: number): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
&.is-active {
|
&.is-active {
|
||||||
border-color: @cases-page-active-bg;
|
border-color: @primary-strong;
|
||||||
background: @cases-page-active-bg;
|
background: @primary-light;
|
||||||
color: @primary-strong;
|
color: @primary-strong;
|
||||||
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.is-ellipsis {
|
&.is-ellipsis {
|
||||||
|
|||||||
@@ -4,9 +4,11 @@ import { getPasswordLevel } from '@/utils/validate'
|
|||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
password: string
|
password: string
|
||||||
|
/** 是否显示右侧「密码强度:X」文字(登录/注册页显示,个人中心设计稿不显示) */
|
||||||
|
showLabel?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
const props = defineProps<Props>()
|
const props = withDefaults(defineProps<Props>(), { showLabel: true })
|
||||||
|
|
||||||
const level = computed(() => getPasswordLevel(props.password))
|
const level = computed(() => getPasswordLevel(props.password))
|
||||||
|
|
||||||
@@ -28,7 +30,7 @@ const levelIndex = computed(() => (level.value === 'strong' ? 3 : level.value ==
|
|||||||
:class="{ 'is-on': password && i <= levelIndex, [`is-${level}`]: password && i <= levelIndex }"
|
:class="{ 'is-on': password && i <= levelIndex, [`is-${level}`]: password && i <= levelIndex }"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<span class="pwd-strength__label" :class="`is-${level}`">{{ password ? `密码强度:${levelText}` : '' }}</span>
|
<span v-if="showLabel" class="pwd-strength__label" :class="`is-${level}`">{{ password ? `密码强度:${levelText}` : '' }}</span>
|
||||||
<p v-if="password && level === 'weak'" class="pwd-strength__tip">
|
<p v-if="password && level === 'weak'" class="pwd-strength__tip">
|
||||||
密码等级过低,请重新输入(建议字母+数字+符号组合)
|
密码等级过低,请重新输入(建议字母+数字+符号组合)
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
@@ -1,23 +1,29 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, onMounted, ref } from 'vue'
|
import { computed, ref, watch } from 'vue'
|
||||||
|
import qrcode from 'qrcode-generator'
|
||||||
import { useCountDown } from '@/composables/useCountDown'
|
import { useCountDown } from '@/composables/useCountDown'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
expiresIn?: number
|
expiresIn?: number
|
||||||
size?: number
|
size?: number
|
||||||
|
/** 二维码内容;未传时保持占位样式(如支付页) */
|
||||||
|
content?: string
|
||||||
|
/** 是否展示有效期倒计时;支付二维码 2 小时有效,无需前端倒计时/刷新 */
|
||||||
|
countdown?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
const props = withDefaults(defineProps<Props>(), {
|
const props = withDefaults(defineProps<Props>(), {
|
||||||
expiresIn: 272,
|
expiresIn: 272,
|
||||||
size: 200,
|
size: 200,
|
||||||
|
countdown: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
const emit = defineEmits<{ refresh: [] }>()
|
const emit = defineEmits<{ refresh: []; expire: [] }>()
|
||||||
|
|
||||||
const { seconds, start } = useCountDown(props.expiresIn)
|
const { seconds, start } = useCountDown(props.expiresIn)
|
||||||
const started = ref(false)
|
const started = ref(!props.countdown)
|
||||||
|
|
||||||
const expired = computed(() => started.value && seconds.value <= 0)
|
const expired = computed(() => props.countdown && started.value && seconds.value <= 0)
|
||||||
|
|
||||||
const countdownText = computed(() => {
|
const countdownText = computed(() => {
|
||||||
const m = Math.floor(seconds.value / 60)
|
const m = Math.floor(seconds.value / 60)
|
||||||
@@ -25,14 +31,44 @@ const countdownText = computed(() => {
|
|||||||
return `${String(m).padStart(2, '0')}:${String(s).padStart(2, '0')}`
|
return `${String(m).padStart(2, '0')}:${String(s).padStart(2, '0')}`
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const qrSvg = computed(() => {
|
||||||
|
if (!props.content) return ''
|
||||||
|
try {
|
||||||
|
const qr = qrcode(0, 'M')
|
||||||
|
qr.addData(props.content)
|
||||||
|
qr.make()
|
||||||
|
return qr.createSvgTag({ cellSize: 4, margin: 2, scalable: true })
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
/** 调用方传入 content 但内容尚未就绪(等待接口返回 token) */
|
||||||
|
const pending = computed(() => props.content !== undefined && !props.content && !expired.value)
|
||||||
|
|
||||||
function refresh(): void {
|
function refresh(): void {
|
||||||
|
if (!props.countdown) return
|
||||||
start(props.expiresIn)
|
start(props.expiresIn)
|
||||||
|
started.value = true
|
||||||
emit('refresh')
|
emit('refresh')
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
watch(
|
||||||
start(props.expiresIn)
|
() => props.content,
|
||||||
started.value = true
|
(content) => {
|
||||||
|
if (!props.countdown) return
|
||||||
|
// 未传 content 时沿用「进入页面即倒计时」的占位行为;传了 content 则等内容就绪再倒计时
|
||||||
|
if (content === undefined || content) {
|
||||||
|
start(props.expiresIn)
|
||||||
|
started.value = true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ immediate: true },
|
||||||
|
)
|
||||||
|
|
||||||
|
watch(expired, (value) => {
|
||||||
|
if (value) emit('expire')
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -44,8 +80,13 @@ onMounted(() => {
|
|||||||
:style="{ width: `${size}px`, height: `${size}px` }"
|
:style="{ width: `${size}px`, height: `${size}px` }"
|
||||||
@click="refresh"
|
@click="refresh"
|
||||||
>
|
>
|
||||||
<!-- TODO(api): 二维码内容由支付/签署接口返回后渲染 -->
|
<template v-if="!expired && qrSvg">
|
||||||
<template v-if="!expired">
|
<div class="qr-panel__code" v-html="qrSvg" />
|
||||||
|
</template>
|
||||||
|
<template v-else-if="pending">
|
||||||
|
<span class="qr-panel__tip">二维码生成中…</span>
|
||||||
|
</template>
|
||||||
|
<template v-else-if="!expired">
|
||||||
<span class="qr-panel__icon">▦</span>
|
<span class="qr-panel__icon">▦</span>
|
||||||
<span class="qr-panel__tip">扫码支付/签署</span>
|
<span class="qr-panel__tip">扫码支付/签署</span>
|
||||||
</template>
|
</template>
|
||||||
@@ -54,8 +95,11 @@ onMounted(() => {
|
|||||||
<span class="qr-panel__tip">二维码已过期<br>点击刷新</span>
|
<span class="qr-panel__tip">二维码已过期<br>点击刷新</span>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
<p class="qr-panel__status text-secondary">
|
<p v-if="countdown" class="qr-panel__status text-secondary">
|
||||||
<template v-if="!expired">
|
<template v-if="pending">
|
||||||
|
请稍候,正在生成签署二维码
|
||||||
|
</template>
|
||||||
|
<template v-else-if="!expired">
|
||||||
<span class="qr-panel__countdown">二维码将在 <strong class="qr-panel__count">{{ countdownText }}</strong> 后失效</span>(过期可点击二维码刷新)
|
<span class="qr-panel__countdown">二维码将在 <strong class="qr-panel__count">{{ countdownText }}</strong> 后失效</span>(过期可点击二维码刷新)
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
@@ -85,6 +129,20 @@ onMounted(() => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&__code {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
padding: @spacing-sm;
|
||||||
|
background: @white;
|
||||||
|
box-sizing: border-box;
|
||||||
|
|
||||||
|
:deep(svg) {
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
&__icon {
|
&__icon {
|
||||||
font-size: 56px;
|
font-size: 56px;
|
||||||
color: @heading-color;
|
color: @heading-color;
|
||||||
|
|||||||
@@ -32,42 +32,44 @@ function onGetCode(): void {
|
|||||||
.sms-code {
|
.sms-code {
|
||||||
.flex(row, stretch);
|
.flex(row, stretch);
|
||||||
gap: @spacing-sm;
|
gap: @spacing-sm;
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
&__input {
|
&__input {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
height: 40px;
|
height: 44px;
|
||||||
padding: 0 12px;
|
padding: 0 @spacing-base;
|
||||||
border: 1px solid #dde1e7;
|
border: 1px solid @border-color;
|
||||||
border-radius: @radius-sm;
|
border-radius: @radius-base;
|
||||||
background: @white;
|
background: @bg-color-light;
|
||||||
font-size: 13px;
|
font-size: @font-size-base;
|
||||||
color: #1f2937;
|
color: @heading-color;
|
||||||
outline: none;
|
outline: none;
|
||||||
transition: border-color 0.2s;
|
transition: border-color 0.2s, background 0.2s;
|
||||||
|
box-sizing: border-box;
|
||||||
|
|
||||||
&:focus {
|
&:focus {
|
||||||
border-color: @primary-strong;
|
border-color: @primary-strong;
|
||||||
|
background: @white;
|
||||||
}
|
}
|
||||||
|
|
||||||
&::placeholder {
|
&::placeholder {
|
||||||
color: #1f2937;
|
color: @text-color-secondary;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设计稿 #38:「获取验证码」是带蓝色描边的独立按钮(62×16 文字居中),
|
|
||||||
// 不是纯文字链接。按键宽 88px,与输入框间距 @spacing-sm。
|
|
||||||
&__btn {
|
&__btn {
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
width: 88px;
|
min-width: 120px;
|
||||||
height: 40px;
|
height: 44px;
|
||||||
padding: 0;
|
padding: 0 @spacing-base;
|
||||||
border: 1px solid @primary-strong;
|
border: 1px solid @primary-strong;
|
||||||
border-radius: @radius-sm;
|
border-radius: @radius-base;
|
||||||
background: @white;
|
background: @white;
|
||||||
color: @primary-strong;
|
color: @primary-strong;
|
||||||
font-size: 12px;
|
font-size: @font-size-sm;
|
||||||
font-weight: 400;
|
font-weight: 500;
|
||||||
|
white-space: nowrap;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: all 0.2s;
|
transition: all 0.2s;
|
||||||
@@ -78,8 +80,9 @@ function onGetCode(): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
&:disabled {
|
&:disabled {
|
||||||
border-color: @text-color-disabled;
|
border-color: @border-color;
|
||||||
color: @text-color-disabled;
|
background: @bg-color-light;
|
||||||
|
color: @text-color-secondary;
|
||||||
cursor: not-allowed;
|
cursor: not-allowed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,3 +15,7 @@ export { default as SmsCodeInput } from './SmsCodeInput.vue'
|
|||||||
export { default as PasswordStrength } from './PasswordStrength.vue'
|
export { default as PasswordStrength } from './PasswordStrength.vue'
|
||||||
export { default as ConfirmDialog } from './ConfirmDialog.vue'
|
export { default as ConfirmDialog } from './ConfirmDialog.vue'
|
||||||
export { default as QrCodePanel } from './QrCodePanel.vue'
|
export { default as QrCodePanel } from './QrCodePanel.vue'
|
||||||
|
export { default as CasesFilter } from './CasesFilter.vue'
|
||||||
|
export { default as CasesSearchBar } from './CasesSearchBar.vue'
|
||||||
|
export { default as CasesGrid } from './CasesGrid.vue'
|
||||||
|
export { default as EllipsisText } from './EllipsisText.vue'
|
||||||
|
|||||||
60
src/composables/usePayPoll.ts
Normal file
60
src/composables/usePayPoll.ts
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
import { onScopeDispose, ref } from 'vue'
|
||||||
|
import { useFinanceStore } from '@/stores/modules/finance'
|
||||||
|
|
||||||
|
/** 轮询间隔(毫秒) */
|
||||||
|
const POLL_INTERVAL = 2500
|
||||||
|
/** 最长轮询时长:3 分钟 */
|
||||||
|
const POLL_TIMEOUT = 3 * 60 * 1000
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付结果轮询:二维码展示后每 2.5 秒查询一次,最多 3 分钟。
|
||||||
|
* 查询到 SUCCESS 即停止轮询并回调;网络异常静默重试。
|
||||||
|
*/
|
||||||
|
export function usePayPoll(onSuccess: (outTradeNo: string) => void) {
|
||||||
|
const financeStore = useFinanceStore()
|
||||||
|
const polling = ref(false)
|
||||||
|
let timer: ReturnType<typeof setInterval> | null = null
|
||||||
|
let deadline = 0
|
||||||
|
|
||||||
|
function stop(): void {
|
||||||
|
if (timer !== null) {
|
||||||
|
clearInterval(timer)
|
||||||
|
timer = null
|
||||||
|
}
|
||||||
|
polling.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
async function check(outTradeNo: string): Promise<boolean> {
|
||||||
|
try {
|
||||||
|
const result = await financeStore.queryPay(outTradeNo, true)
|
||||||
|
if (result?.status === 'SUCCESS') {
|
||||||
|
stop()
|
||||||
|
onSuccess(outTradeNo)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
// 轮询失败不打断流程,交给下一次重试
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
function start(outTradeNo: string): void {
|
||||||
|
stop()
|
||||||
|
if (!outTradeNo) return
|
||||||
|
polling.value = true
|
||||||
|
deadline = Date.now() + POLL_TIMEOUT
|
||||||
|
void check(outTradeNo)
|
||||||
|
timer = setInterval(() => {
|
||||||
|
if (Date.now() >= deadline) {
|
||||||
|
stop()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
void check(outTradeNo)
|
||||||
|
}, POLL_INTERVAL)
|
||||||
|
}
|
||||||
|
|
||||||
|
onScopeDispose(stop)
|
||||||
|
|
||||||
|
return { polling, start, stop, check }
|
||||||
|
}
|
||||||
@@ -8,6 +8,7 @@ const layoutRoutes: RouteRecordRaw = {
|
|||||||
{ path: 'business/:type', name: 'BusinessDetail', component: () => import('@/views/home/detail.vue'), meta: { title: '业务详情' } },
|
{ path: 'business/:type', name: 'BusinessDetail', component: () => import('@/views/home/detail.vue'), meta: { title: '业务详情' } },
|
||||||
{ path: 'cases', name: 'Cases', component: () => import('@/views/cases'), meta: { title: '成功案例库' } },
|
{ path: 'cases', name: 'Cases', component: () => import('@/views/cases'), meta: { title: '成功案例库' } },
|
||||||
{ path: 'cases/:id', name: 'CaseDetail', component: () => import('@/views/cases/detail.vue'), meta: { title: '案例详情' } },
|
{ path: 'cases/:id', name: 'CaseDetail', component: () => import('@/views/cases/detail.vue'), meta: { title: '案例详情' } },
|
||||||
|
{ path: 'favorites', name: 'Favorites', component: () => import('@/views/profile/favorites.vue'), meta: { title: '收藏列表', requiresAuth: true } },
|
||||||
{ path: 'demand', name: 'Demand', component: () => import('@/views/demand'), meta: { title: '需求提报', requiresAuth: true, noFooter: true } },
|
{ path: 'demand', name: 'Demand', component: () => import('@/views/demand'), meta: { title: '需求提报', requiresAuth: true, noFooter: true } },
|
||||||
|
|
||||||
{ path: 'project', name: 'Project', component: () => import('@/views/project'), meta: { title: '项目中心', requiresAuth: true } },
|
{ path: 'project', name: 'Project', component: () => import('@/views/project'), meta: { title: '项目中心', requiresAuth: true } },
|
||||||
@@ -35,8 +36,11 @@ const layoutRoutes: RouteRecordRaw = {
|
|||||||
children: [
|
children: [
|
||||||
{ path: '', redirect: '/profile/security' },
|
{ path: '', redirect: '/profile/security' },
|
||||||
{ path: 'security', name: 'ProfileSecurity', component: () => import('@/views/profile/security.vue'), meta: { title: '账号安全', requiresAuth: true } },
|
{ path: 'security', name: 'ProfileSecurity', component: () => import('@/views/profile/security.vue'), meta: { title: '账号安全', requiresAuth: true } },
|
||||||
|
{ path: 'security/change-password', name: 'ProfileChangePassword', component: () => import('@/views/profile/change-password.vue'), meta: { title: '修改密码', requiresAuth: true } },
|
||||||
|
{ path: 'security/bind-phone', name: 'ProfileBindPhone', component: () => import('@/views/profile/bind-phone.vue'), meta: { title: '绑定手机号', requiresAuth: true } },
|
||||||
|
{ path: 'security/bind-email', name: 'ProfileBindEmail', component: () => import('@/views/profile/bind-email.vue'), meta: { title: '绑定邮箱', requiresAuth: true } },
|
||||||
|
{ path: 'security/delete-account', name: 'ProfileDeleteAccount', component: () => import('@/views/profile/delete-account.vue'), meta: { title: '注销账号', requiresAuth: true } },
|
||||||
{ path: 'address', name: 'ProfileAddress', component: () => import('@/views/profile/address.vue'), meta: { title: '地址管理', requiresAuth: true } },
|
{ path: 'address', name: 'ProfileAddress', component: () => import('@/views/profile/address.vue'), meta: { title: '地址管理', requiresAuth: true } },
|
||||||
{ path: 'favorites', name: 'ProfileFavorites', component: () => import('@/views/profile/favorites.vue'), meta: { title: '收藏列表', requiresAuth: true } },
|
|
||||||
{ path: 'qualifications', name: 'ProfileQualifications', component: () => import('@/views/profile/qualifications.vue'), meta: { title: '资质列表', requiresAuth: true } },
|
{ path: 'qualifications', name: 'ProfileQualifications', component: () => import('@/views/profile/qualifications.vue'), meta: { title: '资质列表', requiresAuth: true } },
|
||||||
{ path: 'feedback', name: 'ProfileFeedback', component: () => import('@/views/profile/feedback.vue'), meta: { title: '意见反馈', requiresAuth: true } },
|
{ path: 'feedback', name: 'ProfileFeedback', component: () => import('@/views/profile/feedback.vue'), meta: { title: '意见反馈', requiresAuth: true } },
|
||||||
{ path: 'help', name: 'ProfileHelp', component: () => import('@/views/profile/help.vue'), meta: { title: '帮助中心', requiresAuth: true } },
|
{ path: 'help', name: 'ProfileHelp', component: () => import('@/views/profile/help.vue'), meta: { title: '帮助中心', requiresAuth: true } },
|
||||||
|
|||||||
@@ -1,18 +1,23 @@
|
|||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import type { PageResult } from '@/types/api'
|
|
||||||
import type { Contract, ContractQuery } from '@/types/business/contract'
|
import type { Contract, ContractQuery } from '@/types/business/contract'
|
||||||
import {
|
import {
|
||||||
getContractDetail,
|
getContractDetail,
|
||||||
|
getContractDownloadUrl,
|
||||||
getContractList,
|
getContractList,
|
||||||
getSignQr,
|
getContractPreview,
|
||||||
refreshSignQr,
|
getContractSignQrStatus,
|
||||||
|
initContractSignQr,
|
||||||
} from '@/api/contract'
|
} from '@/api/contract'
|
||||||
|
import { toContract } from '@/utils/contractVo'
|
||||||
|
|
||||||
|
/** 扫码签署二维码服务端 Redis TTL(5 分钟),用于页面倒计时。 */
|
||||||
|
const SIGN_QR_TTL_SECONDS = 300
|
||||||
|
|
||||||
function createDefaultQuery(): ContractQuery {
|
function createDefaultQuery(): ContractQuery {
|
||||||
return {
|
return {
|
||||||
keyword: '',
|
keyword: '',
|
||||||
page: 1,
|
pageNum: 1,
|
||||||
pageSize: 8,
|
pageSize: 8,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -22,16 +27,30 @@ export const useContractStore = defineStore('contract', () => {
|
|||||||
const list = ref<Contract[]>([])
|
const list = ref<Contract[]>([])
|
||||||
const total = ref(0)
|
const total = ref(0)
|
||||||
const current = ref<Contract | null>(null)
|
const current = ref<Contract | null>(null)
|
||||||
const signExpires = ref(272)
|
/** 后端 qr-init 返回的完整落地页 URL(含 token),直接用于渲染二维码。 */
|
||||||
|
const signQrUrl = ref('')
|
||||||
|
const signExpires = ref(SIGN_QR_TTL_SECONDS)
|
||||||
|
|
||||||
async function fetchList(): Promise<void> {
|
async function fetchList(): Promise<void> {
|
||||||
const result: PageResult<Contract> = await getContractList(query.value)
|
try {
|
||||||
list.value = result.list
|
const result = await getContractList(query.value)
|
||||||
total.value = result.total
|
list.value = (result?.rows ?? []).map(toContract)
|
||||||
|
total.value = result?.total ?? 0
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
console.warn('[contract] 合同列表加载失败', error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchDetail(id: string): Promise<void> {
|
async function fetchDetail(id: string): Promise<void> {
|
||||||
current.value = await getContractDetail(id)
|
try {
|
||||||
|
const vo = await getContractDetail(id)
|
||||||
|
current.value = vo ? toContract(vo) : null
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
current.value = null
|
||||||
|
console.warn('[contract] 合同详情加载失败', error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setQuery(next: ContractQuery): void {
|
function setQuery(next: ContractQuery): void {
|
||||||
@@ -39,7 +58,7 @@ export const useContractStore = defineStore('contract', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function search(): Promise<void> {
|
async function search(): Promise<void> {
|
||||||
query.value = { ...query.value, page: 1 }
|
query.value = { ...query.value, pageNum: 1 }
|
||||||
await fetchList()
|
await fetchList()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,14 +67,27 @@ export const useContractStore = defineStore('contract', () => {
|
|||||||
await fetchList()
|
await fetchList()
|
||||||
}
|
}
|
||||||
|
|
||||||
async function changePage(page: number): Promise<void> {
|
async function changePage(pageNum: number): Promise<void> {
|
||||||
query.value = { ...query.value, page }
|
query.value = { ...query.value, pageNum }
|
||||||
await fetchList()
|
await fetchList()
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchSignQr(id: string, refresh = false): Promise<void> {
|
async function fetchSignQr(id: string): Promise<void> {
|
||||||
const result = refresh ? await refreshSignQr(id) : await getSignQr(id)
|
signQrUrl.value = await initContractSignQr(id)
|
||||||
signExpires.value = result.expiresInSeconds
|
signExpires.value = SIGN_QR_TTL_SECONDS
|
||||||
|
}
|
||||||
|
|
||||||
|
async function fetchSignQrStatus(id: string): Promise<boolean> {
|
||||||
|
return getContractSignQrStatus(id)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function fetchPreviewUrl(id: string): Promise<string> {
|
||||||
|
const vo = await getContractPreview(id)
|
||||||
|
return vo?.file ?? ''
|
||||||
|
}
|
||||||
|
|
||||||
|
async function fetchDownloadUrl(id: string): Promise<string> {
|
||||||
|
return (await getContractDownloadUrl(id)) ?? ''
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -63,6 +95,7 @@ export const useContractStore = defineStore('contract', () => {
|
|||||||
list,
|
list,
|
||||||
total,
|
total,
|
||||||
current,
|
current,
|
||||||
|
signQrUrl,
|
||||||
signExpires,
|
signExpires,
|
||||||
fetchList,
|
fetchList,
|
||||||
fetchDetail,
|
fetchDetail,
|
||||||
@@ -71,5 +104,8 @@ export const useContractStore = defineStore('contract', () => {
|
|||||||
resetQuery,
|
resetQuery,
|
||||||
changePage,
|
changePage,
|
||||||
fetchSignQr,
|
fetchSignQr,
|
||||||
|
fetchSignQrStatus,
|
||||||
|
fetchPreviewUrl,
|
||||||
|
fetchDownloadUrl,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,11 +1,18 @@
|
|||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import type { PageResult } from '@/types/api'
|
|
||||||
import type {
|
import type {
|
||||||
Bill,
|
Bill,
|
||||||
BillQuery,
|
BillQuery,
|
||||||
|
BillStatistics,
|
||||||
|
DictOptionVo,
|
||||||
|
FinanceBillVo,
|
||||||
|
FinancePayQueryVo,
|
||||||
|
FinancePayResultVo,
|
||||||
FinanceStats,
|
FinanceStats,
|
||||||
|
FinanceSummaryQuery,
|
||||||
Invoice,
|
Invoice,
|
||||||
|
InvoiceApplyPayload,
|
||||||
|
InvoiceAvailableBill,
|
||||||
InvoiceQuery,
|
InvoiceQuery,
|
||||||
InvoiceTitle,
|
InvoiceTitle,
|
||||||
InvoiceTitlePayload,
|
InvoiceTitlePayload,
|
||||||
@@ -14,37 +21,61 @@ import type {
|
|||||||
Payment,
|
Payment,
|
||||||
PaymentResult,
|
PaymentResult,
|
||||||
} from '@/types/business/finance'
|
} from '@/types/business/finance'
|
||||||
|
import type { ExportFormat, InvoiceDownloadFile } from '@/api/finance'
|
||||||
import {
|
import {
|
||||||
applyInvoice as applyInvoiceApi,
|
applyInvoice as applyInvoiceApi,
|
||||||
createAlipayPageOrder as createAlipayPageOrderApi,
|
createInvoiceTitle as createInvoiceTitleApi,
|
||||||
createInvoiceTitle,
|
deleteInvoiceTitle as deleteInvoiceTitleApi,
|
||||||
createPayment as createPaymentApi,
|
downloadInvoice as downloadInvoiceApi,
|
||||||
createWechatNativeOrder as createWechatNativeOrderApi,
|
exportBillReport,
|
||||||
deleteInvoiceTitle,
|
getAvailableInvoiceBills,
|
||||||
exportReport as exportReportApi,
|
getBillDetail as getBillDetailApi,
|
||||||
getBillDetail,
|
getBillList as getBillListApi,
|
||||||
getBillList,
|
getBillStatistics as getBillStatisticsApi,
|
||||||
getCheckoutBills,
|
getFinanceSummary,
|
||||||
getFinanceStats,
|
getInvoiceDetail as getInvoiceDetailApi,
|
||||||
getInvoiceList,
|
getInvoicePage,
|
||||||
getInvoiceTitles,
|
getInvoiceStatusDict,
|
||||||
getPlanPayResult,
|
getInvoiceTitleList,
|
||||||
getPayResult,
|
payBill as payBillApi,
|
||||||
setDefaultTitle as setDefaultTitleApi,
|
payBills as payBillsApi,
|
||||||
switchPaymentMethod as switchPaymentMethodApi,
|
previewInvoice as previewInvoiceApi,
|
||||||
updateInvoiceTitle,
|
queryPayResult,
|
||||||
|
sendInvoiceEmail as sendInvoiceEmailApi,
|
||||||
|
setDefaultInvoiceTitle,
|
||||||
|
updateInvoiceTitle as updateInvoiceTitleApi,
|
||||||
} from '@/api/finance'
|
} from '@/api/finance'
|
||||||
|
import { toBill, toBillStatistics, toBills, toFinanceStats } from '@/utils/billVo'
|
||||||
|
import {
|
||||||
|
toInvoice,
|
||||||
|
toInvoiceAvailableBills,
|
||||||
|
toInvoiceStatusParam,
|
||||||
|
toInvoiceTitleBo,
|
||||||
|
toInvoiceTitles,
|
||||||
|
toInvoices,
|
||||||
|
} from '@/utils/invoiceVo'
|
||||||
|
import { toPayChannel, toPayMethod } from '@/utils/payMeta'
|
||||||
|
|
||||||
function createDefaultBillQuery(): BillQuery {
|
function createDefaultBillQuery(): BillQuery {
|
||||||
return { keyword: '', status: 'all', page: 1, pageSize: 6 }
|
return { keyword: '', status: 'all', page: 1, pageSize: 6 }
|
||||||
}
|
}
|
||||||
|
|
||||||
function createDefaultInvoiceQuery(): InvoiceQuery {
|
function createDefaultInvoiceQuery(): InvoiceQuery {
|
||||||
return { keyword: '', status: 'all', page: 1, pageSize: 6 }
|
return { status: '', page: 1, pageSize: 6 }
|
||||||
|
}
|
||||||
|
|
||||||
|
function toPayOrder(vo: FinancePayResultVo, method: PayMethod): PayOrderResponse {
|
||||||
|
return {
|
||||||
|
channel: toPayChannel(method),
|
||||||
|
qrCode: vo?.qrCode,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useFinanceStore = defineStore('finance', () => {
|
export const useFinanceStore = defineStore('finance', () => {
|
||||||
const stats = ref<FinanceStats | null>(null)
|
const stats = ref<FinanceStats | null>(null)
|
||||||
|
/** 累计消费总额卡片单独按月份统计,避免月份选择器影响下方图表 */
|
||||||
|
const overviewStats = ref<FinanceStats | null>(null)
|
||||||
|
const billStats = ref<BillStatistics>({ totalAmount: 0, totalCount: 0, pendingCount: 0 })
|
||||||
|
|
||||||
const list = ref<Bill[]>([])
|
const list = ref<Bill[]>([])
|
||||||
const total = ref(0)
|
const total = ref(0)
|
||||||
@@ -57,21 +88,53 @@ export const useFinanceStore = defineStore('finance', () => {
|
|||||||
const checkoutBills = ref<Bill[]>([])
|
const checkoutBills = ref<Bill[]>([])
|
||||||
const checkoutLoading = ref(false)
|
const checkoutLoading = ref(false)
|
||||||
const payOrder = ref<PayOrderResponse | null>(null)
|
const payOrder = ref<PayOrderResponse | null>(null)
|
||||||
|
const payOutTradeNo = ref('')
|
||||||
|
|
||||||
const invoices = ref<Invoice[]>([])
|
const invoices = ref<Invoice[]>([])
|
||||||
const invoiceTotal = ref(0)
|
const invoiceTotal = ref(0)
|
||||||
const invoiceQuery = ref<InvoiceQuery>(createDefaultInvoiceQuery())
|
const invoiceQuery = ref<InvoiceQuery>(createDefaultInvoiceQuery())
|
||||||
|
const availableBills = ref<InvoiceAvailableBill[]>([])
|
||||||
|
const invoiceStatusOptions = ref<DictOptionVo[]>([])
|
||||||
|
|
||||||
const titles = ref<InvoiceTitle[]>([])
|
const titles = ref<InvoiceTitle[]>([])
|
||||||
|
|
||||||
async function fetchStats(period?: string): Promise<void> {
|
async function fetchStats(query: FinanceSummaryQuery = {}): Promise<void> {
|
||||||
stats.value = await getFinanceStats(period)
|
try {
|
||||||
|
const [summary, statistics] = await Promise.all([
|
||||||
|
getFinanceSummary(query),
|
||||||
|
getBillStatisticsApi(createDefaultBillQuery()),
|
||||||
|
])
|
||||||
|
stats.value = toFinanceStats(summary, statistics)
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
console.warn('[finance] 财务概览加载失败', error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 只刷新「累计消费总额」卡片,不影响图表使用的 stats */
|
||||||
|
async function fetchOverviewStats(query: FinanceSummaryQuery = {}): Promise<void> {
|
||||||
|
try {
|
||||||
|
const summary = await getFinanceSummary(query)
|
||||||
|
overviewStats.value = toFinanceStats(summary, null)
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
console.warn('[finance] 累计消费总额加载失败', error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchList(): Promise<void> {
|
async function fetchList(): Promise<void> {
|
||||||
const pageData: PageResult<Bill> = await getBillList(query.value)
|
try {
|
||||||
list.value = pageData.list
|
const [pageData, statistics] = await Promise.all([
|
||||||
total.value = pageData.total
|
getBillListApi(query.value),
|
||||||
|
getBillStatisticsApi(query.value),
|
||||||
|
])
|
||||||
|
list.value = toBills(pageData?.rows)
|
||||||
|
total.value = Number(pageData?.total ?? 0)
|
||||||
|
billStats.value = toBillStatistics(statistics)
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
console.warn('[finance] 账单列表加载失败', error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setQuery(next: BillQuery): void {
|
function setQuery(next: BillQuery): void {
|
||||||
@@ -94,48 +157,142 @@ export const useFinanceStore = defineStore('finance', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function fetchDetail(id: string): Promise<void> {
|
async function fetchDetail(id: string): Promise<void> {
|
||||||
currentBill.value = await getBillDetail(id)
|
try {
|
||||||
|
const vo = await getBillDetailApi(id)
|
||||||
|
currentBill.value = vo ? toBill(vo) : null
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
currentBill.value = null
|
||||||
|
console.warn('[finance] 账单详情加载失败', error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function createPayment(billId: string, method: PayMethod): Promise<void> {
|
async function createPayment(billId: string, method: PayMethod): Promise<void> {
|
||||||
payment.value = await createPaymentApi(billId, method)
|
const vo = await payBillApi(billId, toPayChannel(method))
|
||||||
|
payOutTradeNo.value = vo?.outTradeNo ?? ''
|
||||||
|
payOrder.value = toPayOrder(vo, method)
|
||||||
|
payment.value = {
|
||||||
|
billId,
|
||||||
|
method,
|
||||||
|
amount: currentBill.value?.amount ?? Number(vo?.mergedAmount ?? 0),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function switchPaymentMethod(billId: string, method: PayMethod): Promise<void> {
|
/** 单笔走 /web/pay/bill,多笔合并走 /web/pay/bill/batch。 */
|
||||||
payment.value = await switchPaymentMethodApi(billId, method)
|
async function payOrders(ids: string[], method: PayMethod): Promise<void> {
|
||||||
|
const channel = toPayChannel(method)
|
||||||
|
const vo = ids.length === 1
|
||||||
|
? await payBillApi(ids[0], channel)
|
||||||
|
: await payBillsApi(ids, channel)
|
||||||
|
payOutTradeNo.value = vo?.outTradeNo ?? ''
|
||||||
|
payOrder.value = toPayOrder(vo, method)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchResult(billId: string, requirementId = ''): Promise<void> {
|
function queryPay(outTradeNo: string, silent = false): Promise<FinancePayQueryVo> {
|
||||||
result.value = requirementId
|
return queryPayResult(outTradeNo, silent)
|
||||||
? await getPlanPayResult(requirementId, billId)
|
|
||||||
: await getPayResult(billId)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadCheckout(requirementId: string, ids: string[] = []): Promise<void> {
|
async function fetchResult(outTradeNo: string, ids: string[]): Promise<void> {
|
||||||
|
try {
|
||||||
|
const rows = await Promise.all(
|
||||||
|
ids.map((id) => getBillDetailApi(id).catch(() => null)),
|
||||||
|
)
|
||||||
|
const bills = rows
|
||||||
|
.filter((vo): vo is FinanceBillVo => vo != null)
|
||||||
|
.map(toBill)
|
||||||
|
const payQuery = outTradeNo ? await queryPayResult(outTradeNo) : null
|
||||||
|
|
||||||
|
if (!payQuery && bills.length === 0) {
|
||||||
|
result.value = null
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const first = bills[0]
|
||||||
|
result.value = {
|
||||||
|
method: toPayMethod(first?.payChannel),
|
||||||
|
amount: bills.reduce((sum, bill) => sum + bill.amount, 0),
|
||||||
|
payTime: payQuery?.payTime ?? first?.payTime ?? '—',
|
||||||
|
tradeNo: payQuery?.transactionNo ?? first?.tradeNo ?? '—',
|
||||||
|
bills,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
result.value = null
|
||||||
|
console.warn('[finance] 支付结果加载失败', error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadCheckout(ids: string[]): Promise<void> {
|
||||||
checkoutLoading.value = true
|
checkoutLoading.value = true
|
||||||
try {
|
try {
|
||||||
checkoutBills.value = await getCheckoutBills(requirementId, ids)
|
if (ids.length === 0) {
|
||||||
} finally {
|
checkoutBills.value = []
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const rows = await Promise.all(
|
||||||
|
ids.map((id) => getBillDetailApi(id).catch(() => null)),
|
||||||
|
)
|
||||||
|
checkoutBills.value = rows
|
||||||
|
.filter((vo): vo is FinanceBillVo => vo != null)
|
||||||
|
.map(toBill)
|
||||||
|
}
|
||||||
|
finally {
|
||||||
checkoutLoading.value = false
|
checkoutLoading.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function payByWechatNative(orderNo: string, amount: number, billIds: string[]): Promise<void> {
|
|
||||||
payOrder.value = await createWechatNativeOrderApi(orderNo, amount, billIds)
|
|
||||||
}
|
|
||||||
|
|
||||||
async function payByAlipayPage(orderNo: string, amount: number, billIds: string[]): Promise<void> {
|
|
||||||
payOrder.value = await createAlipayPageOrderApi(orderNo, amount, billIds)
|
|
||||||
}
|
|
||||||
|
|
||||||
function clearPayOrder(): void {
|
function clearPayOrder(): void {
|
||||||
payOrder.value = null
|
payOrder.value = null
|
||||||
|
payOutTradeNo.value = ''
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 发票状态字典(0 未开票 / 1 开票中 / 2 已开票)。 */
|
||||||
|
async function fetchInvoiceStatusOptions(): Promise<void> {
|
||||||
|
try {
|
||||||
|
const rows = await getInvoiceStatusDict()
|
||||||
|
invoiceStatusOptions.value = [...(rows ?? [])].sort(
|
||||||
|
(a, b) => (a.dictSort ?? 0) - (b.dictSort ?? 0),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
console.warn('[finance] 发票状态字典加载失败', error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchInvoices(): Promise<void> {
|
async function fetchInvoices(): Promise<void> {
|
||||||
const pageData: PageResult<Invoice> = await getInvoiceList(invoiceQuery.value)
|
try {
|
||||||
invoices.value = pageData.list
|
const pageData = await getInvoicePage({
|
||||||
invoiceTotal.value = pageData.total
|
status: toInvoiceStatusParam(invoiceQuery.value.status),
|
||||||
|
page: invoiceQuery.value.page,
|
||||||
|
pageSize: invoiceQuery.value.pageSize,
|
||||||
|
})
|
||||||
|
invoices.value = toInvoices(pageData?.rows)
|
||||||
|
invoiceTotal.value = Number(pageData?.total ?? 0)
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
console.warn('[finance] 发票记录加载失败', error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function fetchInvoiceDetail(id: string): Promise<Invoice | null> {
|
||||||
|
const vo = await getInvoiceDetailApi(id)
|
||||||
|
return vo ? toInvoice(vo) : null
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 预览电子发票,返回 PDF 直链(仅已开票)。 */
|
||||||
|
async function fetchPreviewUrl(id: string): Promise<string | null> {
|
||||||
|
const vo = await previewInvoiceApi(id)
|
||||||
|
return vo?.file ?? null
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 下载电子发票,返回 PDF 文件流与文件名(仅已开票)。 */
|
||||||
|
async function fetchDownloadFile(id: string): Promise<InvoiceDownloadFile> {
|
||||||
|
return downloadInvoiceApi(id)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 发送电子发票到邮箱;不传 email 则由后端取用户绑定邮箱。 */
|
||||||
|
async function sendInvoiceEmail(invoiceId: string, email?: string): Promise<void> {
|
||||||
|
await sendInvoiceEmailApi({ invoiceId, email })
|
||||||
}
|
}
|
||||||
|
|
||||||
function setInvoiceQuery(next: InvoiceQuery): void {
|
function setInvoiceQuery(next: InvoiceQuery): void {
|
||||||
@@ -152,41 +309,54 @@ export const useFinanceStore = defineStore('finance', () => {
|
|||||||
await fetchInvoices()
|
await fetchInvoices()
|
||||||
}
|
}
|
||||||
|
|
||||||
async function applyInvoice(id: string): Promise<void> {
|
async function fetchAvailableBills(): Promise<void> {
|
||||||
const updated = await applyInvoiceApi(id)
|
const rows = await getAvailableInvoiceBills()
|
||||||
const index = invoices.value.findIndex((item) => item.id === id)
|
availableBills.value = toInvoiceAvailableBills(rows)
|
||||||
if (index >= 0) invoices.value[index] = updated
|
}
|
||||||
|
|
||||||
|
async function applyInvoice(payload: InvoiceApplyPayload): Promise<void> {
|
||||||
|
await applyInvoiceApi(payload)
|
||||||
|
await Promise.allSettled([fetchInvoices(), fetchAvailableBills()])
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchTitles(): Promise<void> {
|
async function fetchTitles(): Promise<void> {
|
||||||
titles.value = await getInvoiceTitles()
|
try {
|
||||||
|
const rows = await getInvoiceTitleList()
|
||||||
|
titles.value = toInvoiceTitles(rows)
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
console.warn('[finance] 发票抬头加载失败', error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function createTitle(payload: InvoiceTitlePayload): Promise<void> {
|
async function createTitle(payload: InvoiceTitlePayload): Promise<void> {
|
||||||
await createInvoiceTitle(payload)
|
await createInvoiceTitleApi(toInvoiceTitleBo(payload))
|
||||||
await fetchTitles()
|
await fetchTitles()
|
||||||
}
|
}
|
||||||
|
|
||||||
async function updateTitle(id: string, payload: InvoiceTitlePayload): Promise<void> {
|
async function updateTitle(id: string, payload: InvoiceTitlePayload): Promise<void> {
|
||||||
await updateInvoiceTitle(id, payload)
|
await updateInvoiceTitleApi(toInvoiceTitleBo(payload, id))
|
||||||
await fetchTitles()
|
await fetchTitles()
|
||||||
}
|
}
|
||||||
|
|
||||||
async function deleteTitle(id: string): Promise<void> {
|
async function deleteTitle(id: string): Promise<void> {
|
||||||
await deleteInvoiceTitle(id)
|
await deleteInvoiceTitleApi(id)
|
||||||
await fetchTitles()
|
await fetchTitles()
|
||||||
}
|
}
|
||||||
|
|
||||||
async function setDefaultTitle(id: string): Promise<void> {
|
async function setDefaultTitle(id: string): Promise<void> {
|
||||||
titles.value = await setDefaultTitleApi(id)
|
await setDefaultInvoiceTitle(id)
|
||||||
|
await fetchTitles()
|
||||||
}
|
}
|
||||||
|
|
||||||
async function exportReport(): Promise<void> {
|
async function exportReport(format: ExportFormat = 'excel'): Promise<Blob> {
|
||||||
await exportReportApi()
|
return exportBillReport(query.value, format)
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
stats,
|
stats,
|
||||||
|
overviewStats,
|
||||||
|
billStats,
|
||||||
list,
|
list,
|
||||||
total,
|
total,
|
||||||
query,
|
query,
|
||||||
@@ -196,11 +366,15 @@ export const useFinanceStore = defineStore('finance', () => {
|
|||||||
checkoutBills,
|
checkoutBills,
|
||||||
checkoutLoading,
|
checkoutLoading,
|
||||||
payOrder,
|
payOrder,
|
||||||
|
payOutTradeNo,
|
||||||
invoices,
|
invoices,
|
||||||
invoiceTotal,
|
invoiceTotal,
|
||||||
invoiceQuery,
|
invoiceQuery,
|
||||||
|
availableBills,
|
||||||
|
invoiceStatusOptions,
|
||||||
titles,
|
titles,
|
||||||
fetchStats,
|
fetchStats,
|
||||||
|
fetchOverviewStats,
|
||||||
fetchList,
|
fetchList,
|
||||||
setQuery,
|
setQuery,
|
||||||
search,
|
search,
|
||||||
@@ -208,16 +382,21 @@ export const useFinanceStore = defineStore('finance', () => {
|
|||||||
changePage,
|
changePage,
|
||||||
fetchDetail,
|
fetchDetail,
|
||||||
createPayment,
|
createPayment,
|
||||||
switchPaymentMethod,
|
payOrders,
|
||||||
|
queryPay,
|
||||||
fetchResult,
|
fetchResult,
|
||||||
loadCheckout,
|
loadCheckout,
|
||||||
payByWechatNative,
|
|
||||||
payByAlipayPage,
|
|
||||||
clearPayOrder,
|
clearPayOrder,
|
||||||
|
fetchInvoiceStatusOptions,
|
||||||
fetchInvoices,
|
fetchInvoices,
|
||||||
|
fetchInvoiceDetail,
|
||||||
|
fetchPreviewUrl,
|
||||||
|
fetchDownloadFile,
|
||||||
|
sendInvoiceEmail,
|
||||||
setInvoiceQuery,
|
setInvoiceQuery,
|
||||||
searchInvoices,
|
searchInvoices,
|
||||||
changeInvoicePage,
|
changeInvoicePage,
|
||||||
|
fetchAvailableBills,
|
||||||
applyInvoice,
|
applyInvoice,
|
||||||
fetchTitles,
|
fetchTitles,
|
||||||
createTitle,
|
createTitle,
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ function toBusinessLine(vo: ProjectSubmissionVo): BusinessLine {
|
|||||||
desc: subtitle,
|
desc: subtitle,
|
||||||
slogan: subtitle,
|
slogan: subtitle,
|
||||||
icon: vo.logoUrl ?? '',
|
icon: vo.logoUrl ?? '',
|
||||||
|
cover: vo.coverUrl ?? '',
|
||||||
serviceContent,
|
serviceContent,
|
||||||
contents,
|
contents,
|
||||||
serviceTypes,
|
serviceTypes,
|
||||||
@@ -99,6 +100,7 @@ function toBusinessLineFromInfo(info: ProjectSubmissionInfo): BusinessLine {
|
|||||||
desc: subtitle,
|
desc: subtitle,
|
||||||
slogan: subtitle,
|
slogan: subtitle,
|
||||||
icon: ps.logoUrl ?? '',
|
icon: ps.logoUrl ?? '',
|
||||||
|
cover: ps.coverUrl ?? '',
|
||||||
serviceContent,
|
serviceContent,
|
||||||
contents,
|
contents,
|
||||||
serviceTypes,
|
serviceTypes,
|
||||||
|
|||||||
@@ -2,15 +2,20 @@ import { defineStore } from 'pinia'
|
|||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
import type { PageResult } from '@/types/api'
|
import type { PageResult } from '@/types/api'
|
||||||
import type { Message, MessageQuery } from '@/types/business/message'
|
import type {
|
||||||
|
Message,
|
||||||
|
MessageApiType,
|
||||||
|
MessageCenterVo,
|
||||||
|
MessageQuery,
|
||||||
|
} from '@/types/business/message'
|
||||||
|
import type { CsSessionPreviewVo } from '@/types/business/service'
|
||||||
import {
|
import {
|
||||||
|
getMessageCenter,
|
||||||
getMessageDetail,
|
getMessageDetail,
|
||||||
getMessageList,
|
getMessageList,
|
||||||
getTabCounts,
|
|
||||||
getUnreadCount,
|
|
||||||
markAllRead as markAllReadApi,
|
markAllRead as markAllReadApi,
|
||||||
markRead as markReadApi,
|
|
||||||
} from '@/api/message'
|
} from '@/api/message'
|
||||||
|
import { getChatSessionPreview } from '@/api/service'
|
||||||
|
|
||||||
export interface MessageTabCounts {
|
export interface MessageTabCounts {
|
||||||
all: number
|
all: number
|
||||||
@@ -36,20 +41,30 @@ export const useMessageStore = defineStore('message', () => {
|
|||||||
const unreadCount = ref(0)
|
const unreadCount = ref(0)
|
||||||
const tabCounts = ref<MessageTabCounts>({ all: 0, 在线客服: 0, 状态通知: 0, 系统通知: 0 })
|
const tabCounts = ref<MessageTabCounts>({ all: 0, 在线客服: 0, 状态通知: 0, 系统通知: 0 })
|
||||||
|
|
||||||
|
interface CenterPayload {
|
||||||
|
center: MessageCenterVo | null
|
||||||
|
preview: CsSessionPreviewVo | null
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* center 接口提供状态通知/系统通知计数,在线客服入口由 /web/chat/session/preview 单独提供;
|
||||||
|
* 挂载时高频并发调用,合并为一次请求。
|
||||||
|
*/
|
||||||
|
let centerRequest: Promise<CenterPayload> | null = null
|
||||||
|
|
||||||
async function fetchList(): Promise<void> {
|
async function fetchList(): Promise<void> {
|
||||||
const result: PageResult<Message> = await getMessageList(query.value)
|
const result: PageResult<Message> = await getMessageList(query.value)
|
||||||
list.value = result.list
|
list.value = result.list
|
||||||
total.value = result.total
|
total.value = result.total
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchDetail(id: string): Promise<void> {
|
async function fetchDetail(id: string, type: MessageApiType): Promise<void> {
|
||||||
const detail = await getMessageDetail(id)
|
const detail = await getMessageDetail(id, type)
|
||||||
current.value = detail
|
current.value = detail
|
||||||
if (detail && !detail.isRead) {
|
if (detail) {
|
||||||
await markReadApi(id)
|
// 详情接口会将该条置为已读,刷新入口未读数与 tab 计数
|
||||||
detail.isRead = true
|
detail.isRead = true
|
||||||
if (unreadCount.value > 0) unreadCount.value -= 1
|
await fetchCenter()
|
||||||
await fetchTabCounts()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,18 +88,36 @@ export const useMessageStore = defineStore('message', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function markAllRead(): Promise<void> {
|
async function markAllRead(): Promise<void> {
|
||||||
await markAllReadApi()
|
await markAllReadApi(query.value.type)
|
||||||
ElMessage.success('已全部标记为已读')
|
ElMessage.success('已全部标记为已读')
|
||||||
await Promise.all([fetchList(), fetchUnreadCount(), fetchTabCounts()])
|
await Promise.all([fetchList(), fetchCenter()])
|
||||||
if (current.value) current.value.isRead = true
|
if (current.value) current.value.isRead = true
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchUnreadCount(): Promise<void> {
|
/** silent:顶部铃铛轮询时静默失败,避免网络抖动反复弹提示。 */
|
||||||
unreadCount.value = await getUnreadCount()
|
async function fetchCenter(silent = false): Promise<void> {
|
||||||
}
|
if (!centerRequest) {
|
||||||
|
centerRequest = Promise.all([
|
||||||
async function fetchTabCounts(): Promise<void> {
|
getMessageCenter(silent).catch(() => null),
|
||||||
tabCounts.value = await getTabCounts()
|
getChatSessionPreview(silent).catch(() => null),
|
||||||
|
])
|
||||||
|
.then(([center, preview]) => ({ center, preview }))
|
||||||
|
.finally(() => {
|
||||||
|
centerRequest = null
|
||||||
|
})
|
||||||
|
}
|
||||||
|
const { center, preview } = await centerRequest
|
||||||
|
const status = Number(center?.status?.unreadCount ?? 0)
|
||||||
|
const system = Number(center?.system?.unreadCount ?? 0)
|
||||||
|
// center.cs 本接口固定返回 null,在线客服未读数以 preview 为准
|
||||||
|
const cs = Number(preview?.unreadCount ?? center?.cs?.unreadCount ?? 0)
|
||||||
|
unreadCount.value = status + system + cs
|
||||||
|
tabCounts.value = {
|
||||||
|
all: status + system + cs,
|
||||||
|
在线客服: cs,
|
||||||
|
状态通知: status,
|
||||||
|
系统通知: system,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -101,7 +134,8 @@ export const useMessageStore = defineStore('message', () => {
|
|||||||
resetQuery,
|
resetQuery,
|
||||||
changePage,
|
changePage,
|
||||||
markAllRead,
|
markAllRead,
|
||||||
fetchUnreadCount,
|
// 顶部铃铛与消息中心页共用 center 接口
|
||||||
fetchTabCounts,
|
fetchUnreadCount: fetchCenter,
|
||||||
|
fetchTabCounts: fetchCenter,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import { fetchOssPreviewBlob } from '@/api/oss'
|
import { downloadOssFile, fetchOssPreviewBlob } from '@/api/oss'
|
||||||
import { resolvePreviewKind, PREVIEW_TEXT_MAX_BYTES, type PreviewKind } from '@/utils/filePreview'
|
import { resolvePreviewKind, PREVIEW_TEXT_MAX_BYTES, type PreviewKind } from '@/utils/filePreview'
|
||||||
import type { FileInfo } from '@/types/api'
|
import type { FileInfo } from '@/types/api'
|
||||||
|
|
||||||
@@ -72,6 +72,11 @@ export const useOssStore = defineStore('oss', () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 下载已上传的 OSS 文件(尚未保存到业务记录的附件)。 */
|
||||||
|
async function fetchDownloadBlob(ossId: string | number): Promise<Blob> {
|
||||||
|
return downloadOssFile(ossId)
|
||||||
|
}
|
||||||
|
|
||||||
function closePreview(): void {
|
function closePreview(): void {
|
||||||
revokeObjectUrl()
|
revokeObjectUrl()
|
||||||
visible.value = false
|
visible.value = false
|
||||||
@@ -96,5 +101,6 @@ export const useOssStore = defineStore('oss', () => {
|
|||||||
totalBytes,
|
totalBytes,
|
||||||
openPreview,
|
openPreview,
|
||||||
closePreview,
|
closePreview,
|
||||||
|
fetchDownloadBlob,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -23,20 +23,26 @@ import {
|
|||||||
deleteAccount as deleteAccountApi,
|
deleteAccount as deleteAccountApi,
|
||||||
deleteAddress,
|
deleteAddress,
|
||||||
deleteQualification,
|
deleteQualification,
|
||||||
|
downloadQualificationAttachment as downloadQualificationAttachmentApi,
|
||||||
getAddresses,
|
getAddresses,
|
||||||
getCaseCounts,
|
getCaseCounts,
|
||||||
getFavorites,
|
getFavorites,
|
||||||
getHelpFaqs,
|
getHelpFaqs,
|
||||||
getProfile,
|
getProfile,
|
||||||
getQualifications,
|
getQualifications,
|
||||||
|
sendBindEmailCode as sendBindEmailCodeApi,
|
||||||
|
sendBindSmsCode as sendBindSmsCodeApi,
|
||||||
setDefaultAddress,
|
setDefaultAddress,
|
||||||
submitFeedback as submitFeedbackApi,
|
submitFeedback as submitFeedbackApi,
|
||||||
unbindEmail,
|
unbindEmail,
|
||||||
updateAddress,
|
updateAddress,
|
||||||
|
updateAvatar,
|
||||||
updateNickname,
|
updateNickname,
|
||||||
updateQualification,
|
updateQualification,
|
||||||
verifyIdentity,
|
uploadProfileAttachment,
|
||||||
} from '@/api/profile'
|
} from '@/api/profile'
|
||||||
|
import type { FileInfo } from '@/types/api'
|
||||||
|
import type { QualificationDownloadFile } from '@/api/profile'
|
||||||
import { storage } from '@/utils/storage'
|
import { storage } from '@/utils/storage'
|
||||||
|
|
||||||
function createDefaultAddressQuery(): ListQuery {
|
function createDefaultAddressQuery(): ListQuery {
|
||||||
@@ -63,12 +69,35 @@ export const useProfileStore = defineStore('profile', () => {
|
|||||||
ElMessage.success('昵称修改成功')
|
ElMessage.success('昵称修改成功')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function saveAvatar(url: string): Promise<void> {
|
||||||
|
profile.value = await updateAvatar(url)
|
||||||
|
ElMessage.success('头像修改成功')
|
||||||
|
}
|
||||||
|
|
||||||
async function changePasswordAction(params: ChangePasswordParams): Promise<void> {
|
async function changePasswordAction(params: ChangePasswordParams): Promise<void> {
|
||||||
await changePassword(params)
|
// 后端固定使用账号绑定手机号,这里仍补一个 phoneNumber 兼容旧入参
|
||||||
|
await changePassword({ ...params, phoneNumber: profile.value?.phone })
|
||||||
profile.value = await getProfile()
|
profile.value = await getProfile()
|
||||||
ElMessage.success('密码修改成功')
|
ElMessage.success('密码修改成功')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 发送换绑手机号的短信验证码。 */
|
||||||
|
async function sendBindSmsCodeAction(phone: string): Promise<void> {
|
||||||
|
await sendBindSmsCodeApi(phone)
|
||||||
|
ElMessage.success('验证码已发送')
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 发送绑定邮箱的邮件验证码(发到目标邮箱)。 */
|
||||||
|
async function sendBindEmailCodeAction(email: string): Promise<void> {
|
||||||
|
await sendBindEmailCodeApi(email)
|
||||||
|
ElMessage.success('验证码已发送')
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 上传资质/反馈等附件,返回带 url 与 ossId 的 FileInfo。 */
|
||||||
|
async function uploadAttachment(file: File): Promise<FileInfo> {
|
||||||
|
return uploadProfileAttachment(file)
|
||||||
|
}
|
||||||
|
|
||||||
async function bindPhoneAction(phone: string, code: string): Promise<void> {
|
async function bindPhoneAction(phone: string, code: string): Promise<void> {
|
||||||
profile.value = await bindPhone(phone, code)
|
profile.value = await bindPhone(phone, code)
|
||||||
ElMessage.success('手机号绑定成功')
|
ElMessage.success('手机号绑定成功')
|
||||||
@@ -84,12 +113,10 @@ export const useProfileStore = defineStore('profile', () => {
|
|||||||
ElMessage.success('已取消邮箱绑定')
|
ElMessage.success('已取消邮箱绑定')
|
||||||
}
|
}
|
||||||
|
|
||||||
async function verifyIdentityAction(phone: string, code: string): Promise<void> {
|
/** 验证 + 注销一步完成,phone 必须是账号绑定手机号。 */
|
||||||
await verifyIdentity(phone, code)
|
async function deleteAccountAction(phone: string, code: string): Promise<void> {
|
||||||
}
|
await deleteAccountApi(phone, code)
|
||||||
|
profile.value = null
|
||||||
async function deleteAccountAction(): Promise<void> {
|
|
||||||
await deleteAccountApi()
|
|
||||||
storage.remove('token')
|
storage.remove('token')
|
||||||
ElMessage.success('注销成功')
|
ElMessage.success('注销成功')
|
||||||
}
|
}
|
||||||
@@ -198,6 +225,14 @@ export const useProfileStore = defineStore('profile', () => {
|
|||||||
await fetchQualifications()
|
await fetchQualifications()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 下载已保存的资质附件;index 从 0 开始。 */
|
||||||
|
async function fetchQualificationAttachment(
|
||||||
|
id: string,
|
||||||
|
index = 0,
|
||||||
|
): Promise<QualificationDownloadFile> {
|
||||||
|
return downloadQualificationAttachmentApi(id, index)
|
||||||
|
}
|
||||||
|
|
||||||
async function submitFeedbackAction(feedback: Feedback): Promise<void> {
|
async function submitFeedbackAction(feedback: Feedback): Promise<void> {
|
||||||
await submitFeedbackApi(feedback)
|
await submitFeedbackApi(feedback)
|
||||||
}
|
}
|
||||||
@@ -212,11 +247,14 @@ export const useProfileStore = defineStore('profile', () => {
|
|||||||
profile,
|
profile,
|
||||||
fetchProfile,
|
fetchProfile,
|
||||||
saveNickname,
|
saveNickname,
|
||||||
|
saveAvatar,
|
||||||
changePassword: changePasswordAction,
|
changePassword: changePasswordAction,
|
||||||
|
sendBindSmsCode: sendBindSmsCodeAction,
|
||||||
|
sendBindEmailCode: sendBindEmailCodeAction,
|
||||||
|
uploadAttachment,
|
||||||
bindPhone: bindPhoneAction,
|
bindPhone: bindPhoneAction,
|
||||||
bindEmail: bindEmailAction,
|
bindEmail: bindEmailAction,
|
||||||
unbindEmail: unbindEmailAction,
|
unbindEmail: unbindEmailAction,
|
||||||
verifyIdentity: verifyIdentityAction,
|
|
||||||
deleteAccount: deleteAccountAction,
|
deleteAccount: deleteAccountAction,
|
||||||
addresses,
|
addresses,
|
||||||
addressTotal,
|
addressTotal,
|
||||||
@@ -244,6 +282,7 @@ export const useProfileStore = defineStore('profile', () => {
|
|||||||
updateQualification: updateQualificationAction,
|
updateQualification: updateQualificationAction,
|
||||||
deleteQualification: deleteQualificationAction,
|
deleteQualification: deleteQualificationAction,
|
||||||
changeQualificationPage,
|
changeQualificationPage,
|
||||||
|
fetchQualificationAttachment,
|
||||||
submitFeedback: submitFeedbackAction,
|
submitFeedback: submitFeedbackAction,
|
||||||
helpFaqs,
|
helpFaqs,
|
||||||
fetchHelpFaqs,
|
fetchHelpFaqs,
|
||||||
|
|||||||
@@ -1,19 +1,101 @@
|
|||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import type { ChatMessage } from '@/types/business/service'
|
import type {
|
||||||
|
ChatMessage,
|
||||||
|
CsContentType,
|
||||||
|
CsSessionVo,
|
||||||
|
} from '@/types/business/service'
|
||||||
import {
|
import {
|
||||||
getChatHistory,
|
getChatMessages,
|
||||||
mockAutoReply,
|
initChatSession,
|
||||||
sendChatMessage,
|
sendChatMessage,
|
||||||
uploadChatFile,
|
uploadChatFile,
|
||||||
} from '@/api/service'
|
} from '@/api/service'
|
||||||
|
import { toChatMessage, toChatMessages } from '@/utils/serviceVo'
|
||||||
|
|
||||||
export const useServiceStore = defineStore('service', () => {
|
export const useServiceStore = defineStore('service', () => {
|
||||||
|
const session = ref<CsSessionVo | null>(null)
|
||||||
const messages = ref<ChatMessage[]>([])
|
const messages = ref<ChatMessage[]>([])
|
||||||
const sending = ref(false)
|
const sending = ref(false)
|
||||||
|
|
||||||
async function fetchHistory(): Promise<void> {
|
/** 会话初始化并发合并,避免页面挂载和首次发送各建一次会话。 */
|
||||||
messages.value = await getChatHistory()
|
let sessionRequest: Promise<CsSessionVo | null> | null = null
|
||||||
|
|
||||||
|
async function ensureSession(): Promise<CsSessionVo | null> {
|
||||||
|
if (session.value?.id !== undefined && session.value?.id !== null) {
|
||||||
|
return session.value
|
||||||
|
}
|
||||||
|
if (!sessionRequest) {
|
||||||
|
sessionRequest = initChatSession()
|
||||||
|
.then((data) => {
|
||||||
|
session.value = data
|
||||||
|
return data
|
||||||
|
})
|
||||||
|
.catch(() => null)
|
||||||
|
.finally(() => {
|
||||||
|
sessionRequest = null
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return sessionRequest
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 轮询/手动刷新共用的在途标记,避免重叠请求把旧结果盖回新结果之上。 */
|
||||||
|
let fetching = false
|
||||||
|
|
||||||
|
function messageSignature(list: ChatMessage[]): string {
|
||||||
|
return list.map((item) => item.id).join('|')
|
||||||
|
}
|
||||||
|
|
||||||
|
async function fetchHistory(silent = false): Promise<void> {
|
||||||
|
if (fetching) return
|
||||||
|
fetching = true
|
||||||
|
try {
|
||||||
|
const current = await ensureSession()
|
||||||
|
if (current?.id === undefined || current?.id === null) {
|
||||||
|
messages.value = []
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const next = toChatMessages(await getChatMessages(current.id, silent))
|
||||||
|
// 内容没变就不替换数组,避免轮询反复触发列表重渲染
|
||||||
|
if (messageSignature(next) !== messageSignature(messages.value)) {
|
||||||
|
messages.value = next
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
// 错误提示由 request 拦截器统一处理
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
fetching = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ------------------------------ 消息同步(HTTP 轮询) ------------------------------ */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 后端未提供 websocket 端点,与客服工作台保持一致改用轮询:
|
||||||
|
* 每 SYNC_INTERVAL 毫秒静默拉取一次当前会话消息,页面隐藏时暂停。
|
||||||
|
*/
|
||||||
|
const SYNC_INTERVAL = 5000
|
||||||
|
let syncTimer: ReturnType<typeof setInterval> | undefined
|
||||||
|
|
||||||
|
function onVisibilityChange(): void {
|
||||||
|
if (document.visibilityState === 'visible') void fetchHistory(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
function startSync(): void {
|
||||||
|
stopSync()
|
||||||
|
syncTimer = setInterval(() => {
|
||||||
|
if (document.visibilityState === 'visible') void fetchHistory(true)
|
||||||
|
}, SYNC_INTERVAL)
|
||||||
|
document.addEventListener('visibilitychange', onVisibilityChange)
|
||||||
|
}
|
||||||
|
|
||||||
|
function stopSync(): void {
|
||||||
|
if (syncTimer) {
|
||||||
|
clearInterval(syncTimer)
|
||||||
|
syncTimer = undefined
|
||||||
|
}
|
||||||
|
document.removeEventListener('visibilitychange', onVisibilityChange)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function send(content: string): Promise<void> {
|
async function send(content: string): Promise<void> {
|
||||||
@@ -21,37 +103,70 @@ export const useServiceStore = defineStore('service', () => {
|
|||||||
if (!trimmed || sending.value) return
|
if (!trimmed || sending.value) return
|
||||||
sending.value = true
|
sending.value = true
|
||||||
try {
|
try {
|
||||||
const userMsg = await sendChatMessage(trimmed)
|
const current = await ensureSession()
|
||||||
messages.value.push(userMsg)
|
if (current?.id === undefined || current?.id === null) return
|
||||||
window.setTimeout(() => {
|
const vo = await sendChatMessage({
|
||||||
void mockAutoReply().then((reply) => {
|
sessionId: current.id,
|
||||||
messages.value.push(reply)
|
senderType: 'USER',
|
||||||
sending.value = false
|
contentType: 'TEXT',
|
||||||
})
|
content: trimmed,
|
||||||
}, 600)
|
})
|
||||||
|
messages.value.push(toChatMessage(vo))
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
sending.value = false
|
// 错误提示由 request 拦截器统一处理
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function sendFile(file: File): Promise<void> {
|
|
||||||
if (sending.value) return
|
|
||||||
sending.value = true
|
|
||||||
try {
|
|
||||||
const fileMsg = await uploadChatFile(file)
|
|
||||||
messages.value.push(fileMsg)
|
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
sending.value = false
|
sending.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function sendFiles(files: File[]): Promise<void> {
|
||||||
|
if (files.length === 0 || sending.value) return
|
||||||
|
sending.value = true
|
||||||
|
try {
|
||||||
|
const current = await ensureSession()
|
||||||
|
if (current?.id === undefined || current?.id === null) return
|
||||||
|
// 拖拽可一次带入多个文件,按顺序逐个上传,避免并发互相顶掉
|
||||||
|
for (const file of files) {
|
||||||
|
const uploaded = await uploadChatFile(file)
|
||||||
|
const contentType: CsContentType = file.type.startsWith('image/') ? 'IMAGE' : 'FILE'
|
||||||
|
const vo = await sendChatMessage({
|
||||||
|
sessionId: current.id,
|
||||||
|
senderType: 'USER',
|
||||||
|
contentType,
|
||||||
|
fileUrl: uploaded.url,
|
||||||
|
fileSize: file.size,
|
||||||
|
})
|
||||||
|
const message = toChatMessage(vo)
|
||||||
|
// 上传接口能拿到原始文件名,优先用它展示
|
||||||
|
if (message.file && uploaded.originalName) {
|
||||||
|
message.file.name = uploaded.originalName
|
||||||
|
}
|
||||||
|
messages.value.push(message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
// 错误提示由 request 拦截器统一处理
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
sending.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function sendFile(file: File): Promise<void> {
|
||||||
|
await sendFiles([file])
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
session,
|
||||||
messages,
|
messages,
|
||||||
sending,
|
sending,
|
||||||
fetchHistory,
|
fetchHistory,
|
||||||
|
startSync,
|
||||||
|
stopSync,
|
||||||
send,
|
send,
|
||||||
sendFile,
|
sendFile,
|
||||||
|
sendFiles,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -4,7 +4,9 @@ import { ElMessage } from 'element-plus'
|
|||||||
import type {
|
import type {
|
||||||
LoginByAccountParams,
|
LoginByAccountParams,
|
||||||
LoginBySmsParams,
|
LoginBySmsParams,
|
||||||
|
RegisterParams,
|
||||||
ResetPasswordParams,
|
ResetPasswordParams,
|
||||||
|
SmsScene,
|
||||||
User,
|
User,
|
||||||
} from '@/types/business/user'
|
} from '@/types/business/user'
|
||||||
import {
|
import {
|
||||||
@@ -12,10 +14,7 @@ import {
|
|||||||
resetPassword as resetPasswordApi,
|
resetPassword as resetPasswordApi,
|
||||||
sendSmsCode as sendSmsCodeApi,
|
sendSmsCode as sendSmsCodeApi,
|
||||||
} from '@/api/auth'
|
} from '@/api/auth'
|
||||||
import {
|
import { loginByAccountApi, registerByAccountApi } from '@/api/auth'
|
||||||
loginByAccountApi,
|
|
||||||
registerByAccountApi,
|
|
||||||
} from '@/api/auth'
|
|
||||||
import { storage } from '@/utils/storage'
|
import { storage } from '@/utils/storage'
|
||||||
|
|
||||||
export const useUserStore = defineStore('user', () => {
|
export const useUserStore = defineStore('user', () => {
|
||||||
@@ -25,12 +24,14 @@ export const useUserStore = defineStore('user', () => {
|
|||||||
|
|
||||||
const isLoggedIn = computed(() => Boolean(token.value))
|
const isLoggedIn = computed(() => Boolean(token.value))
|
||||||
|
|
||||||
async function sendSmsCode(phone: string): Promise<void> {
|
async function sendSmsCode(
|
||||||
|
phone: string,
|
||||||
|
scene: SmsScene = 'register',
|
||||||
|
): Promise<void> {
|
||||||
try {
|
try {
|
||||||
await sendSmsCodeApi(phone)
|
await sendSmsCodeApi({ phoneNumber: phone, scene })
|
||||||
ElMessage.success('验证码已发送')
|
ElMessage.success('验证码已发送')
|
||||||
}
|
} catch (error) {
|
||||||
catch (error) {
|
|
||||||
ElMessage.error(error instanceof Error ? error.message : '验证码发送失败')
|
ElMessage.error(error instanceof Error ? error.message : '验证码发送失败')
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
@@ -42,19 +43,22 @@ export const useUserStore = defineStore('user', () => {
|
|||||||
storage.set('token', payload.token)
|
storage.set('token', payload.token)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loginByAccount(params: LoginByAccountParams): Promise<boolean> {
|
async function loginByAccount(
|
||||||
|
params: LoginByAccountParams,
|
||||||
|
): Promise<boolean> {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
try {
|
try {
|
||||||
const result = await loginByAccountApi({ username: params.account, password: params.password })
|
const result = await loginByAccountApi({
|
||||||
|
username: params.account,
|
||||||
|
password: params.password,
|
||||||
|
})
|
||||||
applyLogin({ token: result.access_token, user: null })
|
applyLogin({ token: result.access_token, user: null })
|
||||||
ElMessage.success('登录成功')
|
ElMessage.success('登录成功')
|
||||||
return true
|
return true
|
||||||
}
|
} catch (error) {
|
||||||
catch (error) {
|
|
||||||
ElMessage.error(error instanceof Error ? error.message : '登录失败')
|
ElMessage.error(error instanceof Error ? error.message : '登录失败')
|
||||||
return false
|
return false
|
||||||
}
|
} finally {
|
||||||
finally {
|
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -66,28 +70,24 @@ export const useUserStore = defineStore('user', () => {
|
|||||||
applyLogin({ token: result.token, user: result.user })
|
applyLogin({ token: result.token, user: result.user })
|
||||||
ElMessage.success('登录成功')
|
ElMessage.success('登录成功')
|
||||||
return true
|
return true
|
||||||
}
|
} catch (error) {
|
||||||
catch (error) {
|
|
||||||
ElMessage.error(error instanceof Error ? error.message : '登录失败')
|
ElMessage.error(error instanceof Error ? error.message : '登录失败')
|
||||||
return false
|
return false
|
||||||
}
|
} finally {
|
||||||
finally {
|
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function register(params: { username: string; password: string; confirmPassword: string }): Promise<boolean> {
|
async function register(params: RegisterParams): Promise<boolean> {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
try {
|
try {
|
||||||
await registerByAccountApi({ username: params.username, password: params.password })
|
await registerByAccountApi(params)
|
||||||
ElMessage.success('注册成功,请登录')
|
ElMessage.success('注册成功,请登录')
|
||||||
return true
|
return true
|
||||||
}
|
} catch (error) {
|
||||||
catch (error) {
|
|
||||||
ElMessage.error(error instanceof Error ? error.message : '注册失败')
|
ElMessage.error(error instanceof Error ? error.message : '注册失败')
|
||||||
return false
|
return false
|
||||||
}
|
} finally {
|
||||||
finally {
|
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -98,12 +98,10 @@ export const useUserStore = defineStore('user', () => {
|
|||||||
await resetPasswordApi(params)
|
await resetPasswordApi(params)
|
||||||
ElMessage.success('修改成功,请登录')
|
ElMessage.success('修改成功,请登录')
|
||||||
return true
|
return true
|
||||||
}
|
} catch (error) {
|
||||||
catch (error) {
|
|
||||||
ElMessage.error(error instanceof Error ? error.message : '修改失败')
|
ElMessage.error(error instanceof Error ? error.message : '修改失败')
|
||||||
return false
|
return false
|
||||||
}
|
} finally {
|
||||||
finally {
|
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,9 +85,8 @@
|
|||||||
.flex(column, center, center);
|
.flex(column, center, center);
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
// 设计稿三页的标题顶分别为 306/287/268,卡片在 1080 视口中居中后
|
// 底部多留白,整体视觉中心上移,「欢迎登录」不再偏下
|
||||||
// 会比标注高 15px,用上内边距把内容整体下移补平。
|
padding: 24px 0 120px;
|
||||||
padding: 80px 0 40px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设计稿表单区统一 693px 宽。标题/副标题按自身文字宽度相对表单居中,
|
// 设计稿表单区统一 693px 宽。标题/副标题按自身文字宽度相对表单居中,
|
||||||
|
|||||||
@@ -77,7 +77,7 @@
|
|||||||
|
|
||||||
@header-height: 72px;
|
@header-height: 72px;
|
||||||
@header-nav-gap: 94px;
|
@header-nav-gap: 94px;
|
||||||
@footer-height: 481px;
|
@footer-height: 280px;
|
||||||
@footer-inset: 70px;
|
@footer-inset: 70px;
|
||||||
|
|
||||||
// 登录/注册/找回密码三页共用的品牌区宽度。设计稿 #36/#38/#39 的左侧渐变
|
// 登录/注册/找回密码三页共用的品牌区宽度。设计稿 #36/#38/#39 的左侧渐变
|
||||||
@@ -90,10 +90,10 @@
|
|||||||
@shadow-lg: 0 4px 16px rgba(31, 39, 51, 0.12);
|
@shadow-lg: 0 4px 16px rgba(31, 39, 51, 0.12);
|
||||||
|
|
||||||
@filter-selected-bg: #e7eeff;
|
@filter-selected-bg: #e7eeff;
|
||||||
@pill-bg: #ededed;
|
@pill-bg: #f5f6f8;
|
||||||
@pill-selected-bg: #075cff;
|
@pill-selected-bg: #075cff;
|
||||||
@chips-panel-bg: #eaf1ff;
|
@chips-panel-bg: #eaf1ff;
|
||||||
@input-bg: #ededed;
|
@input-bg: #f5f6f8;
|
||||||
@tag-hardware: #4caf50;
|
@tag-hardware: #4caf50;
|
||||||
@tag-iot: #5720ba;
|
@tag-iot: #5720ba;
|
||||||
@tag-manufacturing: #ff8f1f;
|
@tag-manufacturing: #ff8f1f;
|
||||||
@@ -105,19 +105,23 @@
|
|||||||
@cases-filter-title: #222222;
|
@cases-filter-title: #222222;
|
||||||
@cases-text: #333333;
|
@cases-text: #333333;
|
||||||
@cases-muted: #666666;
|
@cases-muted: #666666;
|
||||||
@cases-input-border: #999999;
|
@cases-input-border: #cdd3dd;
|
||||||
@cases-icon: #797979;
|
@cases-icon: #797979;
|
||||||
@cases-reset-bg: #f0f0f0;
|
@cases-reset-bg: #f5f6f8;
|
||||||
@cases-card-border: #e1dfdf;
|
@cases-card-border: #e4e7ec;
|
||||||
@cases-card-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
|
@cases-card-shadow: 0 2px 8px rgba(31, 39, 51, 0.06);
|
||||||
@cases-page-active-bg: #e0e9fa;
|
@cases-page-active-bg: #e0e9fa;
|
||||||
|
@cases-filter-width: 320px;
|
||||||
|
|
||||||
@demand-selected-bg: #024fff;
|
@demand-selected-bg: #024fff;
|
||||||
@demand-accent: #024fff;
|
@demand-accent: #024fff;
|
||||||
@demand-secondary-bg: #075cff;
|
@demand-secondary-bg: #075cff;
|
||||||
|
|
||||||
@project-table-head-bg: #e8e8e8;
|
@project-table-head-bg: #f7f8fa;
|
||||||
@project-table-line: #bbbbbb;
|
@project-table-line: #e4e7ec;
|
||||||
|
@project-filter-width: 320px;
|
||||||
|
@project-pill-bg: #f5f6f8;
|
||||||
|
@project-input-bg: #f5f6f8;
|
||||||
|
|
||||||
@project-accent: #024fff;
|
@project-accent: #024fff;
|
||||||
@project-track: #edeff2;
|
@project-track: #edeff2;
|
||||||
@@ -181,8 +185,8 @@
|
|||||||
@demand-ink: #121212;
|
@demand-ink: #121212;
|
||||||
@demand-heading: #333333;
|
@demand-heading: #333333;
|
||||||
@demand-subtitle: #666666;
|
@demand-subtitle: #666666;
|
||||||
@demand-line: #999999;
|
@demand-line: #e4e7ec;
|
||||||
@demand-upload-bg: #ededed;
|
@demand-upload-bg: #f5f6f8;
|
||||||
@demand-radio-idle: #c7c2c2;
|
@demand-radio-idle: #c7c2c2;
|
||||||
@auth-gradient-from: #505be8;
|
@auth-gradient-from: #505be8;
|
||||||
@auth-gradient-to: #8b3fe8;
|
@auth-gradient-to: #8b3fe8;
|
||||||
@@ -208,7 +212,7 @@
|
|||||||
@project-cell: #4b5563;
|
@project-cell: #4b5563;
|
||||||
@project-card: #ffffff;
|
@project-card: #ffffff;
|
||||||
@project-field-bg: #f3f4f6;
|
@project-field-bg: #f3f4f6;
|
||||||
@project-input-border: #dde1e7;
|
@project-input-border: #e4e7ec;
|
||||||
@project-head-bg: #f7f8fa;
|
@project-head-bg: #f7f8fa;
|
||||||
@project-upload-tag: #ef4444;
|
@project-upload-tag: #ef4444;
|
||||||
@project-banner-soft: #fdeeee;
|
@project-banner-soft: #fdeeee;
|
||||||
@@ -223,12 +227,12 @@
|
|||||||
|
|
||||||
@contract-accent: #075cff;
|
@contract-accent: #075cff;
|
||||||
@contract-muted: #666666;
|
@contract-muted: #666666;
|
||||||
@contract-head-text: #222222;
|
@contract-head-text: #666666;
|
||||||
@contract-cell-text: #333333;
|
@contract-cell-text: #333333;
|
||||||
@contract-line: #999999;
|
@contract-line: #e4e7ec;
|
||||||
@contract-table-head-bg: #ededed;
|
@contract-table-head-bg: #f7f8fa;
|
||||||
@contract-placeholder: #b3b9c4;
|
@contract-placeholder: #b3b9c4;
|
||||||
@contract-reset-bg: #eef0f3;
|
@contract-reset-bg: #f5f6f8;
|
||||||
@contract-qr-bg: #d6d6d6;
|
@contract-qr-bg: #d6d6d6;
|
||||||
|
|
||||||
@finance-hero-gradient: linear-gradient(
|
@finance-hero-gradient: linear-gradient(
|
||||||
@@ -239,8 +243,8 @@
|
|||||||
);
|
);
|
||||||
@finance-chart-bar: #4a90c4;
|
@finance-chart-bar: #4a90c4;
|
||||||
@finance-chart-grid: #edeef2;
|
@finance-chart-grid: #edeef2;
|
||||||
@finance-table-head-bg: #f1f3f5;
|
@finance-table-head-bg: #f7f8fa;
|
||||||
@finance-field-bg: #f3f4f6;
|
@finance-field-bg: #f5f6f8;
|
||||||
@finance-page-active: #d5e2fe;
|
@finance-page-active: #d5e2fe;
|
||||||
@finance-summary-cta: #ffb754;
|
@finance-summary-cta: #ffb754;
|
||||||
@finance-result-circle: #7ed321;
|
@finance-result-circle: #7ed321;
|
||||||
@@ -252,9 +256,9 @@
|
|||||||
@profile-nav-active-bg: #e7eeff;
|
@profile-nav-active-bg: #e7eeff;
|
||||||
@profile-card-border: #f0f1f3;
|
@profile-card-border: #f0f1f3;
|
||||||
@profile-line: #e5e7eb;
|
@profile-line: #e5e7eb;
|
||||||
@profile-input-border: #dde1e7;
|
@profile-input-border: #e4e7ec;
|
||||||
@profile-radius: 6px;
|
@profile-radius: 6px;
|
||||||
@profile-page-bg: #f4f6f8;
|
@profile-page-bg: #f4f5f9;
|
||||||
@profile-ink: #1f2937;
|
@profile-ink: #1f2937;
|
||||||
@profile-hotline-bg: #d6e4fb;
|
@profile-hotline-bg: #d6e4fb;
|
||||||
@profile-icon-pwd: #c7d2fe;
|
@profile-icon-pwd: #c7d2fe;
|
||||||
@@ -265,6 +269,9 @@
|
|||||||
@profile-user-avatar: #8976ed;
|
@profile-user-avatar: #8976ed;
|
||||||
@profile-page-active-bg: #d1e0fe;
|
@profile-page-active-bg: #d1e0fe;
|
||||||
@profile-quiet-btn: #eef0f3;
|
@profile-quiet-btn: #eef0f3;
|
||||||
|
@profile-tag-ok-bg: #e0f0e0;
|
||||||
|
@profile-input-disabled-bg: #f3f4f6;
|
||||||
|
@profile-verify-banner-bg: #edf3fe;
|
||||||
|
|
||||||
@contract-ink: #121212;
|
@contract-ink: #121212;
|
||||||
@contract-page-bg: #f4f6f8;
|
@contract-page-bg: #f4f6f8;
|
||||||
@@ -275,3 +282,31 @@
|
|||||||
@finance-entry-text: #4b5563;
|
@finance-entry-text: #4b5563;
|
||||||
@finance-axis-text: #9ca3af;
|
@finance-axis-text: #9ca3af;
|
||||||
@finance-ink: #1f2937;
|
@finance-ink: #1f2937;
|
||||||
|
// 财务中心首页快捷入口图标(设计稿 #20,蓝湖 fallback 无切图,色值取自封面采样)
|
||||||
|
@finance-entry-bill-bg: #e9f1fe;
|
||||||
|
@finance-entry-bill-icon: #1f67ef;
|
||||||
|
@finance-entry-pending-bg: #fff4e5;
|
||||||
|
@finance-entry-invoice-bg: #f1ecfe;
|
||||||
|
@finance-entry-invoice-icon: #7c5ce0;
|
||||||
|
@finance-entry-export-bg: #e6f6ec;
|
||||||
|
@finance-entry-badge-bg: #f53f3f;
|
||||||
|
@finance-chart-switch-active: #024fff;
|
||||||
|
@finance-switch-active-bg: #e8f0ff;
|
||||||
|
@finance-switch-idle-bg: #f2f4f7;
|
||||||
|
|
||||||
|
// 消息中心(设计稿 #22)
|
||||||
|
@message-page-bg: #f4f6f8;
|
||||||
|
@message-tabs-text: #4b5563;
|
||||||
|
@message-tabs-badge: #f53f3f;
|
||||||
|
@message-toolbar-btn-border: #e5e7eb;
|
||||||
|
@message-pager-active-bg: #edf3fe;
|
||||||
|
@message-item-icon: #3b82f6;
|
||||||
|
|
||||||
|
// 在线客服(设计稿 #42)
|
||||||
|
@service-card-line: #f0f1f3;
|
||||||
|
@service-scroll-bg: #fafbfc;
|
||||||
|
@service-input-bg: #f7f8fa;
|
||||||
|
@service-bar-bg: #f8f8f9;
|
||||||
|
@service-header-name: #1f2937;
|
||||||
|
@service-avatar-text: #8d99ae;
|
||||||
|
@service-bubble-text: #1f2937;
|
||||||
|
|||||||
6
src/types/business/cases.d.ts
vendored
6
src/types/business/cases.d.ts
vendored
@@ -88,6 +88,12 @@ export interface ProjectCaseCountVo {
|
|||||||
caseCount: number | null
|
caseCount: number | null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** GET /web/projectCase/count 返回。 */
|
||||||
|
export interface ProjectCaseCountResultVo {
|
||||||
|
total: number | null
|
||||||
|
projectCaseCounts: ProjectCaseCountVo[] | null
|
||||||
|
}
|
||||||
|
|
||||||
export interface ProjectCaseAndCaseCountVo {
|
export interface ProjectCaseAndCaseCountVo {
|
||||||
projectCasePage: ProjectCasePageVo | null
|
projectCasePage: ProjectCasePageVo | null
|
||||||
projectCaseStatisticsVo: ProjectCaseStatisticsVo | null
|
projectCaseStatisticsVo: ProjectCaseStatisticsVo | null
|
||||||
|
|||||||
86
src/types/business/contract.d.ts
vendored
86
src/types/business/contract.d.ts
vendored
@@ -1,7 +1,88 @@
|
|||||||
|
|
||||||
import type { FileInfo } from '@/types/api'
|
import type { FileInfo } from '@/types/api'
|
||||||
|
|
||||||
export type SignStatus = '履行中' | '已过期' | '待签署'
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
// 接口出参(字段与 /web/contract 接口文档一一对应)
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
/** ContractVo:合同列表 / 详情 / 扫码落地页共用。 */
|
||||||
|
export interface ContractVo {
|
||||||
|
id: number | string
|
||||||
|
contractNo: string | null
|
||||||
|
projectId: number | string | null
|
||||||
|
projectNo: string | null
|
||||||
|
projectName: string | null
|
||||||
|
/** 合同类型,取自关联项目的 business_type 字典值(中文)。 */
|
||||||
|
bizType: string | null
|
||||||
|
userId: number | string | null
|
||||||
|
/** 合同名称(页面「合同名称」)。 */
|
||||||
|
title: string | null
|
||||||
|
amount: number | string | null
|
||||||
|
/** 签署方信息(JSON 字符串)。 */
|
||||||
|
signParties: string | null
|
||||||
|
/** 签署状态:PENDING / SIGNING / SIGNED / VOID / EXPIRED。 */
|
||||||
|
signStatus: string | null
|
||||||
|
/** 履约状态:INACTIVE / IN_EFFECT / EXPIRED / TERMINATED。 */
|
||||||
|
status: string | null
|
||||||
|
signDate: string | null
|
||||||
|
effectDate: string | null
|
||||||
|
expireDate: string | null
|
||||||
|
/** 合同 PDF 文件地址。 */
|
||||||
|
file: string | null
|
||||||
|
}
|
||||||
|
|
||||||
|
/** GET /web/contract/page 的 data。 */
|
||||||
|
export interface ContractPageResult {
|
||||||
|
total: number
|
||||||
|
rows: ContractVo[]
|
||||||
|
}
|
||||||
|
|
||||||
|
/** GET /web/contract/preview/{id} 的 data。 */
|
||||||
|
export interface ContractPreviewVo {
|
||||||
|
contractId: number | string | null
|
||||||
|
contractNo: string | null
|
||||||
|
title: string | null
|
||||||
|
/** 合同 PDF 文件地址。 */
|
||||||
|
file: string | null
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 各签署方记录。 */
|
||||||
|
export interface ContractSignRecordVo {
|
||||||
|
signId: number | string | null
|
||||||
|
/** PARTY_A 甲方 / PARTY_B 乙方。 */
|
||||||
|
signerType: string | null
|
||||||
|
signerName: string | null
|
||||||
|
/** SMS 短信验证码 / FACE 人脸识别。 */
|
||||||
|
signType: string | null
|
||||||
|
signTime: string | null
|
||||||
|
/** PENDING 待验证 / SUCCESS 成功 / FAILED 失败。 */
|
||||||
|
result: string | null
|
||||||
|
/** 手写签名图片地址。 */
|
||||||
|
signatureImg: string | null
|
||||||
|
}
|
||||||
|
|
||||||
|
/** GET /web/contract/sign/progress/{id} 的 data。 */
|
||||||
|
export interface ContractSignProgressVo {
|
||||||
|
contractId: number | string | null
|
||||||
|
contractNo: string | null
|
||||||
|
signStatus: string | null
|
||||||
|
parties: ContractSignRecordVo[]
|
||||||
|
}
|
||||||
|
|
||||||
|
/** GET /web/contract/sign/qr-token/{token} 的 data。 */
|
||||||
|
export interface ContractQrTokenVo {
|
||||||
|
token: string
|
||||||
|
contract: ContractVo
|
||||||
|
progress: ContractSignProgressVo
|
||||||
|
/** token 过期时间(与 Redis TTL 一致,默认 5 分钟)。 */
|
||||||
|
expireTime: string
|
||||||
|
}
|
||||||
|
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
// 页面模型(展示字段保持不变,由 utils/contractVo 从 ContractVo 映射)
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
export type SignStatus = '待签署' | '签署中' | '已签署' | '已作废' | '已过期'
|
||||||
|
|
||||||
export interface Contract {
|
export interface Contract {
|
||||||
id: string
|
id: string
|
||||||
@@ -9,6 +90,7 @@ export interface Contract {
|
|||||||
contractName: string
|
contractName: string
|
||||||
contractType: string
|
contractType: string
|
||||||
contractAmount: number
|
contractAmount: number
|
||||||
|
relatedProjectId: string
|
||||||
relatedProjectName: string
|
relatedProjectName: string
|
||||||
projectNo: string
|
projectNo: string
|
||||||
signStatus: SignStatus
|
signStatus: SignStatus
|
||||||
@@ -20,6 +102,6 @@ export interface Contract {
|
|||||||
|
|
||||||
export interface ContractQuery {
|
export interface ContractQuery {
|
||||||
keyword: string
|
keyword: string
|
||||||
page: number
|
pageNum: number
|
||||||
pageSize: number
|
pageSize: number
|
||||||
}
|
}
|
||||||
|
|||||||
390
src/types/business/finance.d.ts
vendored
390
src/types/business/finance.d.ts
vendored
@@ -1,62 +1,22 @@
|
|||||||
|
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
// 页面模型
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
export type BillStatus = '待支付' | '已支付' | '未到期' | '已取消'
|
export type BillStatus = '待支付' | '已支付' | '未到期' | '已取消'
|
||||||
|
|
||||||
export type BillStatusCode = 'UNSTARTED' | 'PENDING' | 'PAID' | 'CANCELLED'
|
export type BillStatusCode = 'UNSTARTED' | 'PENDING' | 'PAID' | 'CANCELLED'
|
||||||
|
|
||||||
export interface BillVo {
|
|
||||||
id: number | string
|
|
||||||
billNo?: string
|
|
||||||
projectId?: number | string
|
|
||||||
projectNo?: string
|
|
||||||
projectName?: string
|
|
||||||
userId?: number | string
|
|
||||||
amount?: number
|
|
||||||
bizType?: string
|
|
||||||
billType?: string
|
|
||||||
periodName?: string
|
|
||||||
periodRatio?: number
|
|
||||||
status?: BillStatusCode | string
|
|
||||||
payChannel?: string
|
|
||||||
transactionNo?: string
|
|
||||||
tradeName?: string
|
|
||||||
payTime?: string
|
|
||||||
dueDate?: string
|
|
||||||
createTime?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface BillPlanVo {
|
|
||||||
id: number | string
|
|
||||||
projectId?: number | string
|
|
||||||
projectNo?: string
|
|
||||||
projectName?: string
|
|
||||||
userId?: number | string
|
|
||||||
bizType?: string
|
|
||||||
totalAmount?: number | string
|
|
||||||
periods?: number
|
|
||||||
currentPeriod?: number
|
|
||||||
periodRule?: string
|
|
||||||
nextDate?: string
|
|
||||||
status?: string
|
|
||||||
orderNo?: string
|
|
||||||
transactionNo?: string
|
|
||||||
payChannel?: string
|
|
||||||
payAmount?: number | string
|
|
||||||
payStatus?: string
|
|
||||||
payTime?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export type InvoiceStatus = '已开票' | '开票中' | '未开票'
|
|
||||||
|
|
||||||
export type PayMethod = 'wechat' | 'alipay'
|
export type PayMethod = 'wechat' | 'alipay'
|
||||||
|
|
||||||
export interface PayOrderResponse {
|
export type PayChannelCode = 'WECHAT' | 'ALIPAY' | 'BANK' | 'WORKWX'
|
||||||
channel: string
|
|
||||||
scene: string
|
export type FinanceDimension = 'YEAR' | 'MONTH' | 'QUARTER'
|
||||||
codeUrl?: string
|
|
||||||
formBody?: string
|
/** 财务中心首页图表视图:月度账单 / 上半年。 */
|
||||||
orderString?: string
|
export type FinancePeriod = 'month' | 'half'
|
||||||
h5Url?: string
|
|
||||||
}
|
export type PayStatus = 'CREATED' | 'SUCCESS' | 'FAILED' | 'REFUNDED'
|
||||||
|
|
||||||
export interface Bill {
|
export interface Bill {
|
||||||
id: string
|
id: string
|
||||||
@@ -78,11 +38,16 @@ export interface BillQuery {
|
|||||||
pageSize: number
|
pageSize: number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface BillStatistics {
|
||||||
|
totalAmount: number
|
||||||
|
totalCount: number
|
||||||
|
pendingCount: number
|
||||||
|
}
|
||||||
|
|
||||||
export interface Payment {
|
export interface Payment {
|
||||||
billId: string
|
billId: string
|
||||||
method: PayMethod
|
method: PayMethod
|
||||||
amount: number
|
amount: number
|
||||||
qrExpiresInSeconds: number
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PaymentResult {
|
export interface PaymentResult {
|
||||||
@@ -93,20 +58,60 @@ export interface PaymentResult {
|
|||||||
bills: Bill[]
|
bills: Bill[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface FinanceStats {
|
||||||
|
totalExpense: number
|
||||||
|
/** 周期标签,如 2026年 / 2026年03月(取接口 periodLabel)。 */
|
||||||
|
month: string
|
||||||
|
pendingCount: number
|
||||||
|
distribution: Array<{ name: string; value: number; color: string }>
|
||||||
|
dimension: FinanceDimension
|
||||||
|
year: number
|
||||||
|
/** 全年逐月金额(仅 dimension=YEAR 有值,固定 12 项,无数据补 0)。 */
|
||||||
|
monthly: number[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PayOrderResponse {
|
||||||
|
channel: string
|
||||||
|
/** 二维码内容字符串,直接用于前端生成二维码 */
|
||||||
|
qrCode?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 发票记录状态:0 未开票 / 1 开票中 / 2 已开票。 */
|
||||||
|
export type InvoiceStatus = '0' | '1' | '2'
|
||||||
|
|
||||||
|
/** 字典数据项(/web/system/dict/data/type/{type})。 */
|
||||||
|
export interface DictOptionVo {
|
||||||
|
dictLabel: string
|
||||||
|
dictValue: string
|
||||||
|
dictSort?: number
|
||||||
|
/** 标签样式:info / warning / success ... */
|
||||||
|
listClass?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export type InvoiceType = 'GENERAL' | 'SPECIAL'
|
||||||
|
|
||||||
export interface Invoice {
|
export interface Invoice {
|
||||||
id: string
|
id: string
|
||||||
planName: string
|
invoiceNo?: string
|
||||||
billNo: string
|
billId: string
|
||||||
tradeNo?: string
|
|
||||||
projectName: string
|
projectName: string
|
||||||
|
titleName: string
|
||||||
|
taxNo?: string
|
||||||
|
invoiceType?: InvoiceType | string
|
||||||
amount: number
|
amount: number
|
||||||
|
transactionNo?: string
|
||||||
status: InvoiceStatus
|
status: InvoiceStatus
|
||||||
|
/** 状态文案,由后端翻译下发 */
|
||||||
|
statusName?: string
|
||||||
|
invoiceFile?: string
|
||||||
|
issueTime?: string
|
||||||
applyTime: string
|
applyTime: string
|
||||||
|
remark?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface InvoiceQuery {
|
export interface InvoiceQuery {
|
||||||
keyword: string
|
/** 空字符串表示全部 */
|
||||||
status: InvoiceStatus | 'all'
|
status: InvoiceStatus | ''
|
||||||
page: number
|
page: number
|
||||||
pageSize: number
|
pageSize: number
|
||||||
}
|
}
|
||||||
@@ -125,9 +130,268 @@ export interface InvoiceTitlePayload {
|
|||||||
taxNo: string
|
taxNo: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface FinanceStats {
|
/** 可开票账单(已支付且尚无有效发票记录)。 */
|
||||||
totalExpense: number
|
export interface InvoiceAvailableBill {
|
||||||
month: string
|
billId: string
|
||||||
pendingCount: number
|
billNo: string
|
||||||
distribution: Array<{ name: string; value: number; color: string }>
|
periodName: string
|
||||||
|
billType: string
|
||||||
|
projectName: string
|
||||||
|
amount: number
|
||||||
|
payTime?: string
|
||||||
|
transactionNo?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface InvoiceApplyPayload {
|
||||||
|
billId: string
|
||||||
|
titleId: string
|
||||||
|
invoiceType: InvoiceType
|
||||||
|
}
|
||||||
|
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
// 接口出参(字段与财务中心接口文档一一对应)
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
/** 分页出参:{ total, rows }。 */
|
||||||
|
export interface FinancePageResult<T> {
|
||||||
|
total: number
|
||||||
|
rows: T[]
|
||||||
|
}
|
||||||
|
|
||||||
|
/** FinanceBillVo:账单分页 / 详情共用。 */
|
||||||
|
export interface FinanceBillVo {
|
||||||
|
id: number | string
|
||||||
|
billNo?: string
|
||||||
|
projectId?: number | string
|
||||||
|
projectNo?: string
|
||||||
|
projectName?: string
|
||||||
|
userId?: number | string
|
||||||
|
bizType?: string
|
||||||
|
billType?: string
|
||||||
|
periodName?: string
|
||||||
|
periodRatio?: number
|
||||||
|
amount?: number
|
||||||
|
status?: BillStatusCode | string
|
||||||
|
dueDate?: string
|
||||||
|
payChannel?: string
|
||||||
|
transactionNo?: string
|
||||||
|
tradeName?: string
|
||||||
|
payTime?: string
|
||||||
|
contractId?: number | string
|
||||||
|
supplementaryRemark?: string
|
||||||
|
createTime?: string
|
||||||
|
updateTime?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 兼容旧引用:账单 Vo 即 FinanceBillVo。 */
|
||||||
|
export type BillVo = FinanceBillVo
|
||||||
|
|
||||||
|
/** 逐月数据:仅 dimension=YEAR 时返回,固定 12 条。 */
|
||||||
|
export interface FinanceMonthlyPoint {
|
||||||
|
month?: number
|
||||||
|
amount?: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface BusinessTypeDistributionVo {
|
||||||
|
bizType?: string
|
||||||
|
bizTypeName?: string
|
||||||
|
totalAmount?: number
|
||||||
|
monthlyData?: FinanceMonthlyPoint[] | null
|
||||||
|
}
|
||||||
|
|
||||||
|
/** GET /web/finance/summary 查询参数。 */
|
||||||
|
export interface FinanceSummaryQuery {
|
||||||
|
dimension?: FinanceDimension
|
||||||
|
year?: number
|
||||||
|
month?: number
|
||||||
|
quarter?: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FinanceSummaryVo {
|
||||||
|
totalAmount?: number
|
||||||
|
year?: number
|
||||||
|
dimension?: FinanceDimension | string
|
||||||
|
periodLabel?: string
|
||||||
|
distributions?: BusinessTypeDistributionVo[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FinanceBillStatisticsVo {
|
||||||
|
totalAmount?: number
|
||||||
|
totalCount?: number
|
||||||
|
pendingCount?: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PayChannelVo {
|
||||||
|
code?: string
|
||||||
|
name?: string
|
||||||
|
enabled?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FinancePayResultVo {
|
||||||
|
outTradeNo?: string
|
||||||
|
mergedAmount?: number
|
||||||
|
/** 二维码内容字符串(顶层字段,当前仅支付宝通道返回) */
|
||||||
|
qrCode?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FinancePayQueryVo {
|
||||||
|
status?: PayStatus | string
|
||||||
|
transactionNo?: string
|
||||||
|
payTime?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 发票抬头出参(/web/finance/invoice/title/list)。 */
|
||||||
|
export interface FinanceInvoiceTitleVo {
|
||||||
|
userId?: number | string
|
||||||
|
id: number | string
|
||||||
|
titleType?: string
|
||||||
|
titleName?: string
|
||||||
|
taxNo?: string
|
||||||
|
isDefault?: number
|
||||||
|
type?: string
|
||||||
|
createTime?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 发票抬头入参(新增/编辑)。 */
|
||||||
|
export interface FinanceInvoiceTitleBo {
|
||||||
|
id?: number | string
|
||||||
|
titleType: 'ENTERPRISE' | 'PERSONAL'
|
||||||
|
titleName: string
|
||||||
|
taxNo?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 可开票账单(/web/finance/invoice/available)。 */
|
||||||
|
export interface FinanceInvoiceAvailableVo {
|
||||||
|
billId?: number | string
|
||||||
|
billNo?: string
|
||||||
|
periodName?: string
|
||||||
|
billType?: string
|
||||||
|
projectName?: string
|
||||||
|
amount?: number
|
||||||
|
payTime?: string
|
||||||
|
transactionNo?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 开票申请入参(/web/finance/invoice/apply)。 */
|
||||||
|
export interface FinanceInvoiceApplyBo {
|
||||||
|
billId: number | string
|
||||||
|
titleId: number | string
|
||||||
|
invoiceType: 'GENERAL' | 'SPECIAL'
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 发票记录出参(分页 / 详情)。 */
|
||||||
|
export interface FinanceInvoiceVo {
|
||||||
|
id: number | string
|
||||||
|
invoiceNo?: string
|
||||||
|
billId?: number | string
|
||||||
|
projectId?: number | string
|
||||||
|
projectName?: string
|
||||||
|
titleType?: string
|
||||||
|
titleName?: string
|
||||||
|
taxNo?: string
|
||||||
|
invoiceType?: string
|
||||||
|
amount?: number
|
||||||
|
transactionNo?: string
|
||||||
|
status?: string
|
||||||
|
/** 状态文案,由后端翻译下发 */
|
||||||
|
statusName?: string
|
||||||
|
invoiceFile?: string
|
||||||
|
issueTime?: string
|
||||||
|
remark?: string
|
||||||
|
createTime?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 预览电子发票出参(/web/finance/invoice/preview/{id})。 */
|
||||||
|
export interface FinanceInvoicePreviewVo {
|
||||||
|
invoiceId?: number | string
|
||||||
|
invoiceNo?: string
|
||||||
|
titleName?: string
|
||||||
|
/** 电子发票文件地址(PDF 直链) */
|
||||||
|
file?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 发送电子发票到邮箱入参(/web/finance/invoice/send-email)。 */
|
||||||
|
export interface FinanceInvoiceSendEmailBo {
|
||||||
|
invoiceId: number | string
|
||||||
|
/** 收件邮箱;不传则取用户绑定邮箱 */
|
||||||
|
email?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FinanceInvoiceQuery {
|
||||||
|
status?: InvoiceStatus
|
||||||
|
page: number
|
||||||
|
pageSize: number
|
||||||
|
orderByColumn?: string
|
||||||
|
isAsc?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FinancePayBo {
|
||||||
|
id: number | string
|
||||||
|
payChannel: PayChannelCode
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FinanceBatchPayBo {
|
||||||
|
ids: Array<number | string>
|
||||||
|
payChannel: PayChannelCode
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FinanceRefundBo {
|
||||||
|
billId?: number | string
|
||||||
|
amount?: number
|
||||||
|
reason?: string
|
||||||
|
status?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FinanceRefundVo {
|
||||||
|
id?: number | string
|
||||||
|
billId?: number | string
|
||||||
|
paymentId?: number | string
|
||||||
|
userId?: number | string
|
||||||
|
refundNo?: string
|
||||||
|
payChannel?: string
|
||||||
|
amount?: number
|
||||||
|
reason?: string
|
||||||
|
status?: string
|
||||||
|
auditRemark?: string
|
||||||
|
transactionNo?: string
|
||||||
|
refundTime?: string
|
||||||
|
payload?: string
|
||||||
|
createBy?: number | string
|
||||||
|
createTime?: string
|
||||||
|
updateBy?: number | string
|
||||||
|
updateTime?: string
|
||||||
|
delFlag?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FinanceRefundQuery {
|
||||||
|
billId?: number | string
|
||||||
|
amount?: number | string
|
||||||
|
reason?: string
|
||||||
|
status?: string
|
||||||
|
page: number
|
||||||
|
pageSize: number
|
||||||
|
orderByColumn?: string
|
||||||
|
isAsc?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 项目财务里沿用的付款计划结构。 */
|
||||||
|
export interface BillPlanVo {
|
||||||
|
id: number | string
|
||||||
|
projectId?: number | string
|
||||||
|
projectNo?: string
|
||||||
|
projectName?: string
|
||||||
|
userId?: number | string
|
||||||
|
bizType?: string
|
||||||
|
totalAmount?: number | string
|
||||||
|
periods?: number
|
||||||
|
currentPeriod?: number
|
||||||
|
periodRule?: string
|
||||||
|
nextDate?: string
|
||||||
|
status?: string
|
||||||
|
orderNo?: string
|
||||||
|
transactionNo?: string
|
||||||
|
payChannel?: string
|
||||||
|
payAmount?: number | string
|
||||||
|
payStatus?: string
|
||||||
|
payTime?: string
|
||||||
}
|
}
|
||||||
|
|||||||
1
src/types/business/home.d.ts
vendored
1
src/types/business/home.d.ts
vendored
@@ -35,6 +35,7 @@ export interface BusinessLine {
|
|||||||
desc: string
|
desc: string
|
||||||
slogan: string
|
slogan: string
|
||||||
icon: string
|
icon: string
|
||||||
|
cover: string
|
||||||
serviceContent: string
|
serviceContent: string
|
||||||
contents: ServiceContentBlock[]
|
contents: ServiceContentBlock[]
|
||||||
serviceTypes: ServiceType[]
|
serviceTypes: ServiceType[]
|
||||||
|
|||||||
46
src/types/business/message.d.ts
vendored
46
src/types/business/message.d.ts
vendored
@@ -3,6 +3,9 @@ import type { FileInfo } from '@/types/api'
|
|||||||
|
|
||||||
export type MessageType = '在线客服' | '状态通知' | '系统通知'
|
export type MessageType = '在线客服' | '状态通知' | '系统通知'
|
||||||
|
|
||||||
|
/** 接口 type 入参:cs=在线客服 / status=状态通知 / system=系统通知 */
|
||||||
|
export type MessageApiType = 'cs' | 'status' | 'system'
|
||||||
|
|
||||||
export interface Message {
|
export interface Message {
|
||||||
id: string
|
id: string
|
||||||
type: MessageType
|
type: MessageType
|
||||||
@@ -20,3 +23,46 @@ export interface MessageQuery {
|
|||||||
page: number
|
page: number
|
||||||
pageSize: number
|
pageSize: number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** GET /web/message/center 单个入口:未读数 + 最新一条标题/时间 */
|
||||||
|
export interface MessageEntryVo {
|
||||||
|
unreadCount?: number | null
|
||||||
|
latestTitle?: string | null
|
||||||
|
latestTime?: string | null
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface MessageCenterVo {
|
||||||
|
cs?: MessageEntryVo | null
|
||||||
|
status?: MessageEntryVo | null
|
||||||
|
system?: MessageEntryVo | null
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GET /web/message/list 列表行 / GET /web/message/detail 返回对象。
|
||||||
|
* 后端返回 Object(SysMessageVo:messageId/title/message/content/createTime/path/data),
|
||||||
|
* 已读标记、客服消息字段按可选兼容。
|
||||||
|
*/
|
||||||
|
export interface MessageVo {
|
||||||
|
messageId?: number | string | null
|
||||||
|
id?: number | string | null
|
||||||
|
category?: string | null
|
||||||
|
type?: string | null
|
||||||
|
source?: string | null
|
||||||
|
title?: string | null
|
||||||
|
message?: string | null
|
||||||
|
content?: string | null
|
||||||
|
data?: unknown
|
||||||
|
path?: string | null
|
||||||
|
createTime?: string | null
|
||||||
|
sendTime?: string | null
|
||||||
|
senderName?: string | null
|
||||||
|
readFlag?: number | boolean | null
|
||||||
|
isRead?: boolean | null
|
||||||
|
attachments?: FileInfo[] | null
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 分页出参:{ total, rows } */
|
||||||
|
export interface MessagePageVo<T> {
|
||||||
|
total?: number | null
|
||||||
|
rows?: T[] | null
|
||||||
|
}
|
||||||
|
|||||||
83
src/types/business/profile.d.ts
vendored
83
src/types/business/profile.d.ts
vendored
@@ -3,14 +3,42 @@ import type { BusinessType, FileInfo } from '@/types/api'
|
|||||||
|
|
||||||
export interface Profile {
|
export interface Profile {
|
||||||
nickname: string
|
nickname: string
|
||||||
|
/** 完整绑定手机号,用于发验证码/注销等操作 */
|
||||||
phone: string
|
phone: string
|
||||||
|
/** 完整绑定邮箱 */
|
||||||
email: string
|
email: string
|
||||||
|
avatar: string
|
||||||
|
/** 上次修改密码时间;老用户可能为空 */
|
||||||
passwordModifiedAt: string
|
passwordModifiedAt: string
|
||||||
|
/** 距上次修改密码天数;老用户可能为 null */
|
||||||
|
passwordModifiedDays: number | null
|
||||||
|
/** 如下字段来自 /app/account/security */
|
||||||
|
passwordSet: boolean
|
||||||
|
phoneBound: boolean
|
||||||
|
emailBound: boolean
|
||||||
|
/** 掩码手机号,仅用于展示 */
|
||||||
|
maskedPhone: string
|
||||||
|
/** 掩码邮箱,仅用于展示 */
|
||||||
|
maskedEmail: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ChangePasswordParams {
|
export interface ChangePasswordParams {
|
||||||
code: string
|
code: string
|
||||||
password: string
|
password: string
|
||||||
|
/** 后端已改为固定使用账号绑定手机号,这里仅作兼容保留 */
|
||||||
|
phoneNumber?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
/** /web/profile/upload 返回(SysOssVo)。 */
|
||||||
|
export interface ProfileUploadVo {
|
||||||
|
ossId: string | number
|
||||||
|
fileName?: string
|
||||||
|
originalName?: string
|
||||||
|
fileSuffix?: string
|
||||||
|
url: string
|
||||||
|
createTime?: string
|
||||||
|
createByName?: string
|
||||||
|
service?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Address {
|
export interface Address {
|
||||||
@@ -71,3 +99,58 @@ export interface HelpFaqGroup {
|
|||||||
title: string
|
title: string
|
||||||
items: HelpFaqItem[]
|
items: HelpFaqItem[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
// 接口出参(字段与个人中心接口文档一一对应)
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
/** 地址出参(/web/profile/address/*)。 */
|
||||||
|
export interface UserAddressVo {
|
||||||
|
id?: number | string
|
||||||
|
userId?: number | string
|
||||||
|
receiver?: string
|
||||||
|
phone?: string
|
||||||
|
province?: string
|
||||||
|
city?: string
|
||||||
|
district?: string
|
||||||
|
detail?: string
|
||||||
|
/** 是否默认地址 1是 0否 */
|
||||||
|
isDefault?: number
|
||||||
|
createTime?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 资质出参(/web/profile/qualification/*)。 */
|
||||||
|
export interface UserQualificationVo {
|
||||||
|
id?: number | string
|
||||||
|
userId?: number | string
|
||||||
|
qualType?: string
|
||||||
|
companyName?: string
|
||||||
|
qualName?: string
|
||||||
|
qualNo?: string
|
||||||
|
issueOrg?: string
|
||||||
|
validStart?: string
|
||||||
|
validEnd?: string
|
||||||
|
/** 资质附件地址 */
|
||||||
|
file?: string
|
||||||
|
/** DRAFT / PENDING / CERTIFIED / REJECTED */
|
||||||
|
status?: string
|
||||||
|
/** 是否默认 1是 0否 */
|
||||||
|
defaultFlag?: number
|
||||||
|
createTime?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 反馈出参(/web/profile/feedback/page)。 */
|
||||||
|
export interface FeedbackVo {
|
||||||
|
id?: number | string
|
||||||
|
userId?: number | string
|
||||||
|
title?: string
|
||||||
|
content?: string
|
||||||
|
attachments?: string
|
||||||
|
createTime?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 分页出参:{ total, rows }。 */
|
||||||
|
export interface ProfilePageVo<T> {
|
||||||
|
total?: number
|
||||||
|
rows?: T[]
|
||||||
|
}
|
||||||
|
|||||||
20
src/types/business/project.d.ts
vendored
20
src/types/business/project.d.ts
vendored
@@ -229,25 +229,6 @@ export interface RequirementBill {
|
|||||||
createTime?: string | null
|
createTime?: string | null
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface RequirementBillPlan {
|
|
||||||
id: string
|
|
||||||
projectId: string | null
|
|
||||||
projectNo: string | null
|
|
||||||
projectName: string | null
|
|
||||||
totalAmount: string | number | null
|
|
||||||
periods: number | null
|
|
||||||
currentPeriod: number | null
|
|
||||||
periodRule: string | null
|
|
||||||
nextDate: string | null
|
|
||||||
status: string | null
|
|
||||||
orderNo: string | null
|
|
||||||
transactionNo: string | null
|
|
||||||
payChannel: string | null
|
|
||||||
payAmount: string | number | null
|
|
||||||
payStatus: string | null
|
|
||||||
payTime: string | null
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface RequirementInvoice {
|
export interface RequirementInvoice {
|
||||||
id: string
|
id: string
|
||||||
billId: string | null
|
billId: string | null
|
||||||
@@ -314,7 +295,6 @@ export interface RequirementFilesVo extends RequirementBaseVo {
|
|||||||
|
|
||||||
export interface RequirementFinanceVo extends RequirementBaseVo {
|
export interface RequirementFinanceVo extends RequirementBaseVo {
|
||||||
bills?: RequirementBill[]
|
bills?: RequirementBill[]
|
||||||
billPlans: RequirementBillPlan[]
|
|
||||||
invoices: RequirementInvoice[]
|
invoices: RequirementInvoice[]
|
||||||
contracts: RequirementContract[]
|
contracts: RequirementContract[]
|
||||||
}
|
}
|
||||||
|
|||||||
96
src/types/business/service.d.ts
vendored
96
src/types/business/service.d.ts
vendored
@@ -1,13 +1,101 @@
|
|||||||
|
|
||||||
export type ChatRole = 'user' | 'assistant'
|
export type ChatRole = 'user' | 'assistant'
|
||||||
|
|
||||||
|
export interface ChatFile {
|
||||||
|
name: string
|
||||||
|
size: number
|
||||||
|
/** 可直接下载的文件地址(上传成功后由后端返回) */
|
||||||
|
url?: string
|
||||||
|
ossId?: string | number
|
||||||
|
}
|
||||||
|
|
||||||
export interface ChatMessage {
|
export interface ChatMessage {
|
||||||
id: string
|
id: string
|
||||||
role: ChatRole
|
role: ChatRole
|
||||||
content: string
|
content: string
|
||||||
file?: {
|
file?: ChatFile
|
||||||
name: string
|
|
||||||
size: number
|
|
||||||
}
|
|
||||||
time: string
|
time: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
// WEB 在线客服接口(/web/chat/*)
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
/** CsSession:GET/POST /web/chat/session/init 返回的会话对象。 */
|
||||||
|
export interface CsSessionVo {
|
||||||
|
id?: number | string | null
|
||||||
|
sessionNo?: string | null
|
||||||
|
userId?: number | string | null
|
||||||
|
userName?: string | null
|
||||||
|
csUserId?: number | string | null
|
||||||
|
csUserName?: string | null
|
||||||
|
contact?: string | null
|
||||||
|
/** WAIT_ACCESS / IN_PROGRESS / FINISHED */
|
||||||
|
status?: string | null
|
||||||
|
chatType?: string | null
|
||||||
|
lastMessage?: string | null
|
||||||
|
lastMsgTime?: string | null
|
||||||
|
unreadUser?: number | null
|
||||||
|
unreadCs?: number | null
|
||||||
|
endTime?: string | null
|
||||||
|
}
|
||||||
|
|
||||||
|
export type CsSenderType = 'USER' | 'CS' | 'SYSTEM'
|
||||||
|
export type CsContentType = 'TEXT' | 'IMAGE' | 'FILE' | 'VOICE'
|
||||||
|
|
||||||
|
/** CsMessage:/web/chat/message、/web/chat/message/list 的消息对象。 */
|
||||||
|
export interface CsMessageVo {
|
||||||
|
id?: number | string | null
|
||||||
|
sessionId?: number | string | null
|
||||||
|
senderType?: string | null
|
||||||
|
senderId?: number | string | null
|
||||||
|
senderName?: string | null
|
||||||
|
senderAvatar?: string | null
|
||||||
|
contentType?: string | null
|
||||||
|
content?: string | null
|
||||||
|
fileUrl?: string | null
|
||||||
|
fileSize?: number | null
|
||||||
|
duration?: number | null
|
||||||
|
/** 0-未读 1-已读 */
|
||||||
|
readFlag?: number | null
|
||||||
|
sendTime?: string | null
|
||||||
|
createTime?: string | null
|
||||||
|
}
|
||||||
|
|
||||||
|
/** GET /web/chat/message/centerList 分页出参:{ total, rows }。 */
|
||||||
|
export interface CsMessagePageVo {
|
||||||
|
total?: number | null
|
||||||
|
rows?: CsMessageVo[] | null
|
||||||
|
}
|
||||||
|
|
||||||
|
/** GET /web/chat/message/centerList 查询参数。 */
|
||||||
|
export interface CsMessageCenterQuery {
|
||||||
|
pageNum: number
|
||||||
|
pageSize: number
|
||||||
|
}
|
||||||
|
|
||||||
|
/** POST /web/chat/message 请求体。 */
|
||||||
|
export interface SendCsMessageParams {
|
||||||
|
sessionId: number | string
|
||||||
|
senderType: CsSenderType
|
||||||
|
contentType: CsContentType
|
||||||
|
content?: string
|
||||||
|
fileUrl?: string
|
||||||
|
fileSize?: number
|
||||||
|
duration?: number
|
||||||
|
}
|
||||||
|
|
||||||
|
/** GET /web/chat/session/preview:消息中心「在线客服」入口预览。 */
|
||||||
|
export interface CsSessionPreviewVo {
|
||||||
|
unreadCount?: number | null
|
||||||
|
latestMessage?: string | null
|
||||||
|
latestTime?: string | null
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 用户端 OSS 上传返回(SysOssVo)。 */
|
||||||
|
export interface ChatUploadVo {
|
||||||
|
ossId?: number | string | null
|
||||||
|
fileName?: string | null
|
||||||
|
originalName?: string | null
|
||||||
|
url?: string | null
|
||||||
|
}
|
||||||
|
|||||||
39
src/types/business/user.d.ts
vendored
39
src/types/business/user.d.ts
vendored
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
export interface User {
|
export interface User {
|
||||||
id: string
|
id: string
|
||||||
nickname: string
|
nickname: string
|
||||||
@@ -18,6 +17,31 @@ export interface UserProfileVo {
|
|||||||
deptName: string
|
deptName: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 账号安全信息(GET /app/account/security,WEB 端复用)。 */
|
||||||
|
export interface AccountSecurityVo {
|
||||||
|
/** 是否已设置密码 */
|
||||||
|
passwordSet?: boolean | null
|
||||||
|
/** 上次修改密码时间;存量老用户可能为 null */
|
||||||
|
passwordModifiedAt?: string | null
|
||||||
|
/** 距上次修改密码天数;存量老用户可能为 null */
|
||||||
|
passwordModifiedDays?: number | null
|
||||||
|
/** 掩码手机号,如 138****8888(仅用于展示) */
|
||||||
|
phoneNumber?: string | null
|
||||||
|
phoneBound?: boolean | null
|
||||||
|
/** 掩码邮箱,如 ab***@qq.com(仅用于展示) */
|
||||||
|
email?: string | null
|
||||||
|
emailBound?: boolean | null
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 个人资料更新入参(PUT /web/system/user/profile,只更新传了的字段)。 */
|
||||||
|
export interface UserProfileUpdatePayload {
|
||||||
|
nickName?: string
|
||||||
|
email?: string
|
||||||
|
phoneNumber?: string
|
||||||
|
gender?: string
|
||||||
|
avatar?: string
|
||||||
|
}
|
||||||
|
|
||||||
export interface LoginByAccountParams {
|
export interface LoginByAccountParams {
|
||||||
account: string
|
account: string
|
||||||
password: string
|
password: string
|
||||||
@@ -33,12 +57,19 @@ export interface LoginResult {
|
|||||||
user: User
|
user: User
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 短信验证码业务场景 */
|
||||||
|
export type SmsScene = 'register' | 'login' | 'reset'
|
||||||
|
|
||||||
|
export interface SmsCodeParams {
|
||||||
|
phoneNumber: string
|
||||||
|
scene: SmsScene
|
||||||
|
}
|
||||||
|
|
||||||
export interface RegisterParams {
|
export interface RegisterParams {
|
||||||
phone: string
|
phoneNumber: string
|
||||||
code: string
|
smsCode: string
|
||||||
password: string
|
password: string
|
||||||
confirmPassword: string
|
confirmPassword: string
|
||||||
agree: boolean
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ResetPasswordParams {
|
export interface ResetPasswordParams {
|
||||||
|
|||||||
@@ -1,4 +1,15 @@
|
|||||||
import type { Bill, BillStatus, BillVo } from '@/types/business/finance'
|
import type {
|
||||||
|
Bill,
|
||||||
|
BillStatistics,
|
||||||
|
BillStatus,
|
||||||
|
BillStatusCode,
|
||||||
|
BillVo,
|
||||||
|
BusinessTypeDistributionVo,
|
||||||
|
FinanceBillStatisticsVo,
|
||||||
|
FinanceDimension,
|
||||||
|
FinanceStats,
|
||||||
|
FinanceSummaryVo,
|
||||||
|
} from '@/types/business/finance'
|
||||||
|
|
||||||
const STATUS_TEXT: Record<string, BillStatus> = {
|
const STATUS_TEXT: Record<string, BillStatus> = {
|
||||||
UNSTARTED: '未到期',
|
UNSTARTED: '未到期',
|
||||||
@@ -7,11 +18,25 @@ const STATUS_TEXT: Record<string, BillStatus> = {
|
|||||||
CANCELLED: '已取消',
|
CANCELLED: '已取消',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const STATUS_CODE: Record<BillStatus, BillStatusCode> = {
|
||||||
|
未到期: 'UNSTARTED',
|
||||||
|
待支付: 'PENDING',
|
||||||
|
已支付: 'PAID',
|
||||||
|
已取消: 'CANCELLED',
|
||||||
|
}
|
||||||
|
|
||||||
|
const DISTRIBUTION_COLORS = ['#3370ff', '#34c724', '#ff8f1f', '#f54a45', '#7b61ff', '#00b8d9']
|
||||||
|
|
||||||
export function toBillStatus(code?: string): BillStatus {
|
export function toBillStatus(code?: string): BillStatus {
|
||||||
if (!code) return '未到期'
|
if (!code) return '未到期'
|
||||||
return STATUS_TEXT[code] ?? '未到期'
|
return STATUS_TEXT[code] ?? '未到期'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 页面状态 → 接口 status 参数(UNSTARTED/PENDING/PAID/CANCELLED)。 */
|
||||||
|
export function toBillStatusCode(status: BillStatus | 'all'): BillStatusCode | undefined {
|
||||||
|
return status === 'all' ? undefined : STATUS_CODE[status]
|
||||||
|
}
|
||||||
|
|
||||||
export function toBill(vo: BillVo): Bill {
|
export function toBill(vo: BillVo): Bill {
|
||||||
return {
|
return {
|
||||||
id: String(vo.id),
|
id: String(vo.id),
|
||||||
@@ -32,6 +57,64 @@ export function toBills(list: BillVo[] | null | undefined): Bill[] {
|
|||||||
return list.filter((item) => item != null && item.id != null).map(toBill)
|
return list.filter((item) => item != null && item.id != null).map(toBill)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function toBillStatistics(vo: FinanceBillStatisticsVo | null | undefined): BillStatistics {
|
||||||
|
return {
|
||||||
|
totalAmount: Number(vo?.totalAmount ?? 0),
|
||||||
|
totalCount: Number(vo?.totalCount ?? 0),
|
||||||
|
pendingCount: Number(vo?.pendingCount ?? 0),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function toDistribution(
|
||||||
|
item: BusinessTypeDistributionVo,
|
||||||
|
index: number,
|
||||||
|
): FinanceStats['distribution'][number] {
|
||||||
|
return {
|
||||||
|
name: item.bizTypeName ?? item.bizType ?? '',
|
||||||
|
value: Number(item.totalAmount ?? 0),
|
||||||
|
color: DISTRIBUTION_COLORS[index % DISTRIBUTION_COLORS.length],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function toFinanceDimension(value?: string): FinanceDimension {
|
||||||
|
if (value === 'MONTH' || value === 'QUARTER') return value
|
||||||
|
return 'YEAR'
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 把各业务类型的逐月金额按月份汇总为 12 项(仅 YEAR 维度有数据)。 */
|
||||||
|
function toMonthlyAmounts(distributions: BusinessTypeDistributionVo[]): number[] {
|
||||||
|
const monthly = Array.from({ length: 12 }, () => 0)
|
||||||
|
for (const item of distributions) {
|
||||||
|
for (const point of item.monthlyData ?? []) {
|
||||||
|
const month = Number(point.month ?? 0)
|
||||||
|
if (month >= 1 && month <= 12) {
|
||||||
|
monthly[month - 1] += Number(point.amount ?? 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return monthly
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 财务概览:累计消费总额 / 周期标签取自 summary,待支付笔数取自账单统计。
|
||||||
|
* 业务类型分布按接口顺序分配图例颜色(接口不返回颜色)。
|
||||||
|
*/
|
||||||
|
export function toFinanceStats(
|
||||||
|
summary: FinanceSummaryVo | null | undefined,
|
||||||
|
statistics?: FinanceBillStatisticsVo | null,
|
||||||
|
): FinanceStats {
|
||||||
|
const distributions = summary?.distributions ?? []
|
||||||
|
return {
|
||||||
|
totalExpense: Number(summary?.totalAmount ?? 0),
|
||||||
|
month: summary?.periodLabel ?? '',
|
||||||
|
pendingCount: Number(statistics?.pendingCount ?? 0),
|
||||||
|
distribution: distributions.map(toDistribution),
|
||||||
|
dimension: toFinanceDimension(summary?.dimension),
|
||||||
|
year: Number(summary?.year ?? new Date().getFullYear()),
|
||||||
|
monthly: toMonthlyAmounts(distributions),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function toPlanStatus(code?: string | null): BillStatus {
|
export function toPlanStatus(code?: string | null): BillStatus {
|
||||||
const value = (code ?? '').toUpperCase()
|
const value = (code ?? '').toUpperCase()
|
||||||
if (value === 'DONE' || value === 'PAID' || value === 'COMPLETED') return '已支付'
|
if (value === 'DONE' || value === 'PAID' || value === 'COMPLETED') return '已支付'
|
||||||
|
|||||||
44
src/utils/contractVo.ts
Normal file
44
src/utils/contractVo.ts
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
import type { FileInfo } from '@/types/api'
|
||||||
|
import type { Contract, ContractVo, SignStatus } from '@/types/business/contract'
|
||||||
|
|
||||||
|
const SIGN_STATUS_LABEL: Record<string, SignStatus> = {
|
||||||
|
PENDING: '待签署',
|
||||||
|
SIGNING: '签署中',
|
||||||
|
SIGNED: '已签署',
|
||||||
|
VOID: '已作废',
|
||||||
|
EXPIRED: '已过期',
|
||||||
|
}
|
||||||
|
|
||||||
|
function toSignStatus(raw: string | null | undefined): SignStatus {
|
||||||
|
return SIGN_STATUS_LABEL[(raw ?? '').trim().toUpperCase()] ?? '待签署'
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 接口只返回单个 PDF 地址,页面文件列表按单条渲染。 */
|
||||||
|
function toFiles(vo: ContractVo, name: string): FileInfo[] {
|
||||||
|
if (!vo.file) return []
|
||||||
|
return [{
|
||||||
|
name,
|
||||||
|
size: 0,
|
||||||
|
uploadTime: vo.signDate ?? '',
|
||||||
|
url: vo.file,
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
|
||||||
|
export function toContract(vo: ContractVo): Contract {
|
||||||
|
const contractName = vo.title || vo.contractNo || ''
|
||||||
|
return {
|
||||||
|
id: String(vo.id),
|
||||||
|
contractNo: vo.contractNo ?? '',
|
||||||
|
contractName,
|
||||||
|
contractType: vo.bizType ?? '',
|
||||||
|
contractAmount: Number(vo.amount ?? 0),
|
||||||
|
relatedProjectId: vo.projectId ? String(vo.projectId) : '',
|
||||||
|
relatedProjectName: vo.projectName ?? '',
|
||||||
|
projectNo: vo.projectNo ?? '',
|
||||||
|
signStatus: toSignStatus(vo.signStatus),
|
||||||
|
signDate: vo.signDate ?? undefined,
|
||||||
|
effectiveDate: vo.effectDate ?? '',
|
||||||
|
expiryDate: vo.expireDate ?? '',
|
||||||
|
files: toFiles(vo, contractName || '合同文件'),
|
||||||
|
}
|
||||||
|
}
|
||||||
46
src/utils/download.ts
Normal file
46
src/utils/download.ts
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
/**
|
||||||
|
* 文件流下载相关工具。
|
||||||
|
* 后端接口出错时会返回 JSON,但 axios 因 responseType=blob 把它包成了 Blob,
|
||||||
|
* 需要先读出 msg 再抛出,避免把错误串当成文件保存下来。
|
||||||
|
*/
|
||||||
|
|
||||||
|
export async function readBlobErrorMessage(blob: Blob, fallback = '下载失败'): Promise<string> {
|
||||||
|
try {
|
||||||
|
const payload = JSON.parse(await blob.text()) as { msg?: string }
|
||||||
|
return payload.msg || fallback
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
return fallback
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 解析 Content-Disposition 中的文件名(优先 RFC 5987 的 filename*)。 */
|
||||||
|
export function resolveContentDispositionFileName(value: unknown): string | undefined {
|
||||||
|
const raw = Array.isArray(value) ? value[0] : value
|
||||||
|
if (typeof raw !== 'string' || !raw) return undefined
|
||||||
|
|
||||||
|
const encoded = /filename\*=UTF-8''([^;]+)/i.exec(raw)
|
||||||
|
if (encoded?.[1]) {
|
||||||
|
try {
|
||||||
|
return decodeURIComponent(encoded[1].trim())
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
return encoded[1].trim()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const plain = /filename="?([^";]+)"?/i.exec(raw)
|
||||||
|
return plain?.[1]?.trim()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 触发浏览器另存文件。 */
|
||||||
|
export function saveBlobAsFile(blob: Blob, fileName: string): void {
|
||||||
|
const url = URL.createObjectURL(blob)
|
||||||
|
const link = document.createElement('a')
|
||||||
|
link.href = url
|
||||||
|
link.download = fileName
|
||||||
|
document.body.appendChild(link)
|
||||||
|
link.click()
|
||||||
|
link.remove()
|
||||||
|
URL.revokeObjectURL(url)
|
||||||
|
}
|
||||||
109
src/utils/invoiceVo.ts
Normal file
109
src/utils/invoiceVo.ts
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
import type {
|
||||||
|
FinanceInvoiceAvailableVo,
|
||||||
|
FinanceInvoiceTitleBo,
|
||||||
|
FinanceInvoiceTitleVo,
|
||||||
|
FinanceInvoiceVo,
|
||||||
|
Invoice,
|
||||||
|
InvoiceAvailableBill,
|
||||||
|
InvoiceStatus,
|
||||||
|
InvoiceTitle,
|
||||||
|
InvoiceTitlePayload,
|
||||||
|
} from '@/types/business/finance'
|
||||||
|
|
||||||
|
export const INVOICE_TYPE_LABELS: Record<string, string> = {
|
||||||
|
GENERAL: '普通发票',
|
||||||
|
SPECIAL: '专用发票',
|
||||||
|
}
|
||||||
|
|
||||||
|
const TITLE_TYPE_LABELS: Record<string, InvoiceTitle['type']> = {
|
||||||
|
ENTERPRISE: '企业单位',
|
||||||
|
PERSONAL: '非企业单位',
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 兼容旧版 PENDING/ISSUED/REJECTED,统一归一化为数字状态码。 */
|
||||||
|
export function toInvoiceStatus(code?: string): InvoiceStatus {
|
||||||
|
if (code === '0' || code === '1' || code === '2') return code
|
||||||
|
if (code === 'ISSUED') return '2'
|
||||||
|
if (code === 'PENDING') return '1'
|
||||||
|
// 驳回已取消,直接回到未开票,用户可重新申请
|
||||||
|
if (code === 'REJECTED') return '0'
|
||||||
|
return '0'
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 页面筛选状态 → 接口 status 参数(空值表示全部,不传)。 */
|
||||||
|
export function toInvoiceStatusParam(status: InvoiceStatus | ''): InvoiceStatus | undefined {
|
||||||
|
return status === '' ? undefined : status
|
||||||
|
}
|
||||||
|
|
||||||
|
export function toInvoice(vo: FinanceInvoiceVo): Invoice {
|
||||||
|
return {
|
||||||
|
id: String(vo.id),
|
||||||
|
invoiceNo: vo.invoiceNo,
|
||||||
|
billId: String(vo.billId ?? ''),
|
||||||
|
projectName: vo.projectName ?? '',
|
||||||
|
titleName: vo.titleName ?? '',
|
||||||
|
taxNo: vo.taxNo,
|
||||||
|
invoiceType: vo.invoiceType,
|
||||||
|
amount: Number(vo.amount ?? 0),
|
||||||
|
transactionNo: vo.transactionNo,
|
||||||
|
status: toInvoiceStatus(vo.status),
|
||||||
|
statusName: vo.statusName ?? '',
|
||||||
|
invoiceFile: vo.invoiceFile,
|
||||||
|
issueTime: vo.issueTime,
|
||||||
|
applyTime: vo.createTime ?? '',
|
||||||
|
remark: vo.remark,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function toInvoices(list: FinanceInvoiceVo[] | null | undefined): Invoice[] {
|
||||||
|
if (!list || list.length === 0) return []
|
||||||
|
return list.filter((item) => item != null && item.id != null).map(toInvoice)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function toInvoiceTitle(vo: FinanceInvoiceTitleVo): InvoiceTitle {
|
||||||
|
const type = TITLE_TYPE_LABELS[vo.titleType ?? '']
|
||||||
|
?? (vo.type === '非企业单位' || vo.type === 'PERSONAL' ? '非企业单位' : '企业单位')
|
||||||
|
return {
|
||||||
|
id: String(vo.id),
|
||||||
|
type,
|
||||||
|
title: vo.titleName ?? '',
|
||||||
|
taxNo: vo.taxNo ?? '',
|
||||||
|
isDefault: Number(vo.isDefault ?? 0) === 1,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function toInvoiceTitles(list: FinanceInvoiceTitleVo[] | null | undefined): InvoiceTitle[] {
|
||||||
|
if (!list || list.length === 0) return []
|
||||||
|
return list.filter((item) => item != null && item.id != null).map(toInvoiceTitle)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function toInvoiceTitleBo(payload: InvoiceTitlePayload, id?: string): FinanceInvoiceTitleBo {
|
||||||
|
return {
|
||||||
|
id,
|
||||||
|
titleType: payload.type === '非企业单位' ? 'PERSONAL' : 'ENTERPRISE',
|
||||||
|
titleName: payload.title,
|
||||||
|
taxNo: payload.taxNo,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function toInvoiceAvailableBill(vo: FinanceInvoiceAvailableVo): InvoiceAvailableBill {
|
||||||
|
return {
|
||||||
|
billId: String(vo.billId ?? ''),
|
||||||
|
billNo: vo.billNo ?? '',
|
||||||
|
periodName: vo.periodName ?? '',
|
||||||
|
billType: vo.billType ?? '',
|
||||||
|
projectName: vo.projectName ?? '',
|
||||||
|
amount: Number(vo.amount ?? 0),
|
||||||
|
payTime: vo.payTime,
|
||||||
|
transactionNo: vo.transactionNo,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function toInvoiceAvailableBills(
|
||||||
|
list: FinanceInvoiceAvailableVo[] | null | undefined,
|
||||||
|
): InvoiceAvailableBill[] {
|
||||||
|
if (!list || list.length === 0) return []
|
||||||
|
return list
|
||||||
|
.filter((item) => item != null && item.billId != null)
|
||||||
|
.map(toInvoiceAvailableBill)
|
||||||
|
}
|
||||||
116
src/utils/messageVo.ts
Normal file
116
src/utils/messageVo.ts
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
import type { Message, MessageApiType, MessageType, MessageVo } from '@/types/business/message'
|
||||||
|
import type { CsMessageVo } from '@/types/business/service'
|
||||||
|
import { formatDate } from '@/utils/format'
|
||||||
|
|
||||||
|
const TYPE_LABEL: Record<MessageApiType, MessageType> = {
|
||||||
|
cs: '在线客服',
|
||||||
|
status: '状态通知',
|
||||||
|
system: '系统通知',
|
||||||
|
}
|
||||||
|
|
||||||
|
const TYPE_CODE: Record<MessageType, MessageApiType> = {
|
||||||
|
在线客服: 'cs',
|
||||||
|
状态通知: 'status',
|
||||||
|
系统通知: 'system',
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 消息中心入口只提供状态通知 + 系统通知(cs 由客服模块提供,本接口返回 null)。 */
|
||||||
|
export const WEB_MESSAGE_TYPES: MessageApiType[] = ['status', 'system']
|
||||||
|
|
||||||
|
/** 接口 type 值 → 页面类型(兼容中文标签)。 */
|
||||||
|
export function toMessageType(raw: string | null | undefined, fallback: MessageType): MessageType {
|
||||||
|
const value = (raw ?? '').trim()
|
||||||
|
if (value === '在线客服' || value === '状态通知' || value === '系统通知') return value
|
||||||
|
const lower = value.toLowerCase()
|
||||||
|
if (lower === 'cs') return '在线客服'
|
||||||
|
if (lower === 'status') return '状态通知'
|
||||||
|
if (lower === 'system') return '系统通知'
|
||||||
|
return fallback
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 页面类型 → 接口 type 值。 */
|
||||||
|
export function toMessageApiType(type: MessageType): MessageApiType {
|
||||||
|
return TYPE_CODE[type]
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 页面 tab(含「全部」)→ readAll 需要逐个传入的接口 type 列表。 */
|
||||||
|
export function toMessageApiTypes(type: MessageType | 'all'): MessageApiType[] {
|
||||||
|
return type === 'all' ? [...WEB_MESSAGE_TYPES] : [TYPE_CODE[type]]
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 接口 createTime/sendTime → 页面展示时间。 */
|
||||||
|
function toMessageTime(raw: string | null | undefined): string {
|
||||||
|
const value = (raw ?? '').trim()
|
||||||
|
if (!value) return ''
|
||||||
|
return formatDate(value) || value
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 已读标记:后端未在文档中固定该字段,兼容 readFlag/isRead;
|
||||||
|
* 都未返回时按已读处理,避免整列表误导为未读。
|
||||||
|
*/
|
||||||
|
function toMessageRead(vo: MessageVo): boolean {
|
||||||
|
if (typeof vo.isRead === 'boolean') return vo.isRead
|
||||||
|
if (typeof vo.readFlag === 'boolean') return vo.readFlag
|
||||||
|
if (typeof vo.readFlag === 'number') return vo.readFlag === 1
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
export function toMessage(vo: MessageVo, fallbackType: MessageApiType): Message {
|
||||||
|
const id = vo.messageId ?? vo.id
|
||||||
|
const content = vo.content ?? vo.message ?? ''
|
||||||
|
return {
|
||||||
|
id: String(id ?? ''),
|
||||||
|
type: toMessageType(vo.type, TYPE_LABEL[fallbackType]),
|
||||||
|
title: vo.title ?? vo.senderName ?? '',
|
||||||
|
summary: vo.message ?? content,
|
||||||
|
content,
|
||||||
|
publishTime: toMessageTime(vo.createTime ?? vo.sendTime),
|
||||||
|
isRead: toMessageRead(vo),
|
||||||
|
attachments: vo.attachments ?? [],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function toMessages(
|
||||||
|
list: MessageVo[] | null | undefined,
|
||||||
|
fallbackType: MessageApiType,
|
||||||
|
): Message[] {
|
||||||
|
if (!list || list.length === 0) return []
|
||||||
|
return list.filter((item) => item != null).map((item) => toMessage(item, fallbackType))
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 非文本消息在列表里的摘要占位。 */
|
||||||
|
const CS_CONTENT_LABEL: Record<string, string> = {
|
||||||
|
IMAGE: '[图片]',
|
||||||
|
FILE: '[文件]',
|
||||||
|
VOICE: '[语音]',
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 在线客服消息(GET /web/chat/message/centerList)→ 消息中心列表行。
|
||||||
|
* 客服消息没有标题,按发送方取展示名;非文本消息用类型占位符做摘要。
|
||||||
|
*/
|
||||||
|
export function toCenterMessage(vo: CsMessageVo): Message {
|
||||||
|
const senderType = (vo.senderType ?? '').trim().toUpperCase()
|
||||||
|
const contentType = (vo.contentType ?? '').trim().toUpperCase()
|
||||||
|
const content = (vo.content ?? '').trim()
|
||||||
|
const fallbackTitle
|
||||||
|
= senderType === 'USER' ? '我' : senderType === 'CS' ? '在线客服' : '系统消息'
|
||||||
|
|
||||||
|
return {
|
||||||
|
id: String(vo.id ?? ''),
|
||||||
|
type: '在线客服',
|
||||||
|
title: (vo.senderName ?? '').trim() || fallbackTitle,
|
||||||
|
summary: CS_CONTENT_LABEL[contentType] ?? content,
|
||||||
|
content,
|
||||||
|
publishTime: toMessageTime(vo.sendTime ?? vo.createTime),
|
||||||
|
// readFlag 缺省时按已读处理,避免整列表误标未读
|
||||||
|
isRead: Number(vo.readFlag ?? 1) !== 0,
|
||||||
|
attachments: [],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function toCenterMessages(list: CsMessageVo[] | null | undefined): Message[] {
|
||||||
|
if (!list || list.length === 0) return []
|
||||||
|
return list.filter((item) => item != null).map(toCenterMessage)
|
||||||
|
}
|
||||||
@@ -7,13 +7,13 @@ export interface PayMethodMeta {
|
|||||||
channel: 'WECHAT' | 'ALIPAY'
|
channel: 'WECHAT' | 'ALIPAY'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 当前仅接入支付宝通道,微信待后续接入。 */
|
||||||
export const PAY_METHODS: PayMethodMeta[] = [
|
export const PAY_METHODS: PayMethodMeta[] = [
|
||||||
{ value: 'wechat', label: '微信支付', hint: '推荐使用', channel: 'WECHAT' },
|
{ value: 'alipay', label: '支付宝支付', hint: '推荐使用', channel: 'ALIPAY' },
|
||||||
{ value: 'alipay', label: '支付宝支付', hint: '其他用户选择', channel: 'ALIPAY' },
|
|
||||||
]
|
]
|
||||||
|
|
||||||
export function toPayChannel(method: PayMethod): PayMethodMeta['channel'] {
|
export function toPayChannel(method: PayMethod): PayMethodMeta['channel'] {
|
||||||
return PAY_METHODS.find((item) => item.value === method)?.channel ?? 'WECHAT'
|
return PAY_METHODS.find((item) => item.value === method)?.channel ?? 'ALIPAY'
|
||||||
}
|
}
|
||||||
|
|
||||||
const CHANNEL_LABELS: Record<string, string> = {
|
const CHANNEL_LABELS: Record<string, string> = {
|
||||||
@@ -29,7 +29,7 @@ export function toChannelLabel(code?: string): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function toPayMethod(code?: string): PayMethod {
|
export function toPayMethod(code?: string): PayMethod {
|
||||||
return code?.toUpperCase() === 'ALIPAY' ? 'alipay' : 'wechat'
|
return code?.toUpperCase() === 'WECHAT' ? 'wechat' : 'alipay'
|
||||||
}
|
}
|
||||||
|
|
||||||
function pad(value: number, length = 2): string {
|
function pad(value: number, length = 2): string {
|
||||||
|
|||||||
238
src/utils/profileVo.ts
Normal file
238
src/utils/profileVo.ts
Normal file
@@ -0,0 +1,238 @@
|
|||||||
|
import type { FileInfo } from '@/types/api'
|
||||||
|
import type {
|
||||||
|
Address,
|
||||||
|
Feedback,
|
||||||
|
Profile,
|
||||||
|
Qualification,
|
||||||
|
QualificationInput,
|
||||||
|
QualificationStatus,
|
||||||
|
QualificationType,
|
||||||
|
UserAddressVo,
|
||||||
|
UserQualificationVo,
|
||||||
|
} from '@/types/business/profile'
|
||||||
|
import type { AccountSecurityVo, UserProfileVo } from '@/types/business/user'
|
||||||
|
import { toAssetUrl } from '@/utils/asset'
|
||||||
|
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
// 个人资料
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
/** /web/system/user/profile + /app/account/security → 页面 Profile。 */
|
||||||
|
export function toProfile(
|
||||||
|
user: UserProfileVo,
|
||||||
|
security?: AccountSecurityVo | null,
|
||||||
|
): Profile {
|
||||||
|
const avatar = (user.avatarUrl ?? '').trim()
|
||||||
|
// 注意:安全接口返回的 phoneNumber/email 是掩码,只能展示,
|
||||||
|
// 不允许回填到 profile.phone/email(发验证码、注销会用到完整值)。
|
||||||
|
return {
|
||||||
|
nickname: (user.nickName || user.userName || '').trim(),
|
||||||
|
phone: user.phoneNumber ?? '',
|
||||||
|
email: user.email ?? '',
|
||||||
|
avatar: toAssetUrl(avatar) || avatar,
|
||||||
|
// 存量老用户没有改密记录,接口返回 null,页面展示占位
|
||||||
|
passwordModifiedAt: security?.passwordModifiedAt ?? '',
|
||||||
|
passwordModifiedDays: security?.passwordModifiedDays ?? null,
|
||||||
|
passwordSet: security?.passwordSet ?? Boolean(user.phoneNumber),
|
||||||
|
phoneBound: security?.phoneBound ?? Boolean(user.phoneNumber),
|
||||||
|
emailBound: security?.emailBound ?? Boolean(user.email),
|
||||||
|
maskedPhone: security?.phoneNumber ?? '',
|
||||||
|
maskedEmail: security?.email ?? '',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
// 地址
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
const MUNICIPALITIES = ['北京市', '上海市', '天津市', '重庆市']
|
||||||
|
const PROVINCE_SUFFIXES = ['省', '自治区', '特别行政区']
|
||||||
|
const CITY_SUFFIXES = ['市', '自治州', '地区', '盟']
|
||||||
|
|
||||||
|
/** 返回 text 中最早出现的后缀结束位置,找不到返回 -1。 */
|
||||||
|
function suffixEnd(text: string, suffixes: string[]): number {
|
||||||
|
let end = -1
|
||||||
|
for (const suffix of suffixes) {
|
||||||
|
const index = text.indexOf(suffix)
|
||||||
|
if (index < 0) continue
|
||||||
|
const candidate = index + suffix.length
|
||||||
|
if (end < 0 || candidate < end) end = candidate
|
||||||
|
}
|
||||||
|
return end
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 页面填写的「省/市/区」整串 → 接口拆分字段。 */
|
||||||
|
export function splitRegion(region: string): { province: string; city: string; district: string } {
|
||||||
|
const text = region.trim()
|
||||||
|
if (!text) return { province: '', city: '', district: '' }
|
||||||
|
|
||||||
|
const municipality = MUNICIPALITIES.find((name) => text.startsWith(name))
|
||||||
|
if (municipality) {
|
||||||
|
return { province: municipality, city: municipality, district: text.slice(municipality.length) }
|
||||||
|
}
|
||||||
|
|
||||||
|
const provinceEnd = suffixEnd(text, PROVINCE_SUFFIXES)
|
||||||
|
const province = provinceEnd > 0 ? text.slice(0, provinceEnd) : ''
|
||||||
|
const rest = province ? text.slice(provinceEnd) : text
|
||||||
|
|
||||||
|
const cityEnd = suffixEnd(rest, CITY_SUFFIXES)
|
||||||
|
const city = cityEnd > 0 ? rest.slice(0, cityEnd) : ''
|
||||||
|
const district = city ? rest.slice(cityEnd) : rest
|
||||||
|
|
||||||
|
return { province, city, district }
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 接口省/市/区 → 页面展示的地区整串(直辖市去重)。 */
|
||||||
|
function joinRegion(vo: UserAddressVo): string {
|
||||||
|
const parts = [vo.province, vo.city, vo.district]
|
||||||
|
.map((item) => (item ?? '').trim())
|
||||||
|
.filter(Boolean)
|
||||||
|
return parts.filter((item, index) => parts.indexOf(item) === index).join('')
|
||||||
|
}
|
||||||
|
|
||||||
|
export function toAddress(vo: UserAddressVo): Address {
|
||||||
|
return {
|
||||||
|
id: String(vo.id ?? ''),
|
||||||
|
receiverName: vo.receiver ?? '',
|
||||||
|
phone: vo.phone ?? '',
|
||||||
|
region: joinRegion(vo),
|
||||||
|
detailAddress: vo.detail ?? '',
|
||||||
|
isDefault: Number(vo.isDefault ?? 0) === 1,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function toAddresses(list: UserAddressVo[] | null | undefined): Address[] {
|
||||||
|
return (list ?? [])
|
||||||
|
.filter((item) => item != null && item.id != null)
|
||||||
|
.map(toAddress)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 页面地址表单 → 接口入参(地区拆成省/市/区)。 */
|
||||||
|
export function toAddressBo(input: Omit<Address, 'id' | 'isDefault'>): {
|
||||||
|
receiver: string
|
||||||
|
phone: string
|
||||||
|
province: string
|
||||||
|
city: string
|
||||||
|
district: string
|
||||||
|
detail: string
|
||||||
|
} {
|
||||||
|
const { province, city, district } = splitRegion(input.region)
|
||||||
|
return {
|
||||||
|
receiver: input.receiverName,
|
||||||
|
phone: input.phone,
|
||||||
|
province,
|
||||||
|
city,
|
||||||
|
district,
|
||||||
|
detail: input.detailAddress,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
// 资质
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
const QUALIFICATION_TYPES: QualificationType[] = [
|
||||||
|
'营业执照',
|
||||||
|
'生产许可证',
|
||||||
|
'体系认证',
|
||||||
|
'检测报告',
|
||||||
|
'授权书',
|
||||||
|
'其他资质',
|
||||||
|
]
|
||||||
|
|
||||||
|
const QUALIFICATION_STATUS: Record<string, QualificationStatus> = {
|
||||||
|
CERTIFIED: '已认证',
|
||||||
|
PENDING: '审核中',
|
||||||
|
DRAFT: '审核中',
|
||||||
|
REJECTED: '未通过',
|
||||||
|
}
|
||||||
|
|
||||||
|
export function toQualificationStatus(code?: string): QualificationStatus {
|
||||||
|
return QUALIFICATION_STATUS[(code ?? '').trim().toUpperCase()] ?? '审核中'
|
||||||
|
}
|
||||||
|
|
||||||
|
function toQualificationType(raw?: string): QualificationType {
|
||||||
|
const value = (raw ?? '').trim()
|
||||||
|
return QUALIFICATION_TYPES.find((item) => item === value) ?? '其他资质'
|
||||||
|
}
|
||||||
|
|
||||||
|
function fileNameFromUrl(url: string): string {
|
||||||
|
const path = url.split('?')[0]?.split('#')[0] ?? ''
|
||||||
|
const segment = path.slice(path.lastIndexOf('/') + 1)
|
||||||
|
if (!segment) return '资质附件'
|
||||||
|
try {
|
||||||
|
return decodeURIComponent(segment)
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
return segment
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function toQualificationFiles(file?: string): FileInfo[] {
|
||||||
|
const url = (file ?? '').trim()
|
||||||
|
if (!url) return []
|
||||||
|
return [{ name: fileNameFromUrl(url), size: 0, uploadTime: '', url }]
|
||||||
|
}
|
||||||
|
|
||||||
|
export function toQualification(vo: UserQualificationVo): Qualification {
|
||||||
|
return {
|
||||||
|
id: String(vo.id ?? ''),
|
||||||
|
type: toQualificationType(vo.qualType),
|
||||||
|
certName: vo.qualName ?? '',
|
||||||
|
certNo: vo.qualNo ?? '',
|
||||||
|
issuer: vo.issueOrg ?? '',
|
||||||
|
validFrom: vo.validStart ?? '',
|
||||||
|
validTo: vo.validEnd ?? '',
|
||||||
|
status: toQualificationStatus(vo.status),
|
||||||
|
attachments: toQualificationFiles(vo.file),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function toQualifications(list: UserQualificationVo[] | null | undefined): Qualification[] {
|
||||||
|
return (list ?? [])
|
||||||
|
.filter((item) => item != null && item.id != null)
|
||||||
|
.map(toQualification)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 页面资质表单 → 接口入参(单附件传 file,多附件同时传 files 数组)。 */
|
||||||
|
export function toQualificationBo(input: QualificationInput): {
|
||||||
|
qualType: string
|
||||||
|
qualName: string
|
||||||
|
qualNo: string
|
||||||
|
issueOrg: string
|
||||||
|
validStart: string
|
||||||
|
validEnd: string
|
||||||
|
file: string
|
||||||
|
files?: string[]
|
||||||
|
} {
|
||||||
|
const urls = input.attachments.map((item) => item.url).filter(Boolean)
|
||||||
|
return {
|
||||||
|
qualType: input.type,
|
||||||
|
qualName: input.certName,
|
||||||
|
qualNo: input.certNo,
|
||||||
|
issueOrg: input.issuer,
|
||||||
|
validStart: input.validFrom,
|
||||||
|
validEnd: input.validTo,
|
||||||
|
file: urls[0] ?? '',
|
||||||
|
...(urls.length > 1 ? { files: urls } : {}),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
// 反馈
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
/** 页面反馈表单 → 接口入参(attachments 为附件地址列表字符串)。 */
|
||||||
|
export function toFeedbackBo(feedback: Feedback): {
|
||||||
|
title: string
|
||||||
|
content: string
|
||||||
|
attachments: string
|
||||||
|
} {
|
||||||
|
const urls = feedback.attachments.map((file) => file.url).filter(Boolean)
|
||||||
|
return {
|
||||||
|
title: feedback.title,
|
||||||
|
content: feedback.description,
|
||||||
|
// 后端要求字符串,按 JSON 数组存附件地址
|
||||||
|
attachments: urls.length > 0 ? JSON.stringify(urls) : '',
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,7 +8,6 @@ import type {
|
|||||||
RequirementAfterSale,
|
RequirementAfterSale,
|
||||||
RequirementAttachment,
|
RequirementAttachment,
|
||||||
RequirementBill,
|
RequirementBill,
|
||||||
RequirementBillPlan,
|
|
||||||
RequirementContract,
|
RequirementContract,
|
||||||
RequirementDetailBundle,
|
RequirementDetailBundle,
|
||||||
RequirementInvoice,
|
RequirementInvoice,
|
||||||
@@ -103,34 +102,6 @@ function toProjectBill(item: RequirementBill): ProjectBill {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function planPeriodLabel(period: number, periods: number): string {
|
|
||||||
if (period <= 1) return '预付款'
|
|
||||||
if (period >= periods) return '尾款'
|
|
||||||
return '进度款'
|
|
||||||
}
|
|
||||||
|
|
||||||
function toPlanCard(item: RequirementBillPlan): ProjectBill {
|
|
||||||
const period = item.currentPeriod ?? 0
|
|
||||||
const periods = item.periods ?? 0
|
|
||||||
const rule = (item.periodRule ?? '').split(',').map((part) => Number(part.trim()))
|
|
||||||
const segment = rule[period - 1]
|
|
||||||
const ratio = Number.isFinite(segment) ? segment : periods > 0 ? 100 / periods : 0
|
|
||||||
const paid = (item.payStatus ?? '').toUpperCase() === 'SUCCESS'
|
|
||||||
return {
|
|
||||||
id: String(item.id),
|
|
||||||
source: 'plan',
|
|
||||||
planName: period > 0 && periods > 0
|
|
||||||
? `第${period}期·${planPeriodLabel(period, periods)}`
|
|
||||||
: (item.periodRule ?? '付款计划'),
|
|
||||||
periodRatio: toRatioText(ratio),
|
|
||||||
billNo: item.orderNo ?? '',
|
|
||||||
amount: Math.round(toNumber(item.totalAmount) * ratio) / 100,
|
|
||||||
status: paid ? '已支付' : toBillStatus(item.status),
|
|
||||||
tradeNo: item.transactionNo ?? undefined,
|
|
||||||
projectName: item.projectName ?? '',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function toTeamMember(item: RequirementMember): TeamMember {
|
function toTeamMember(item: RequirementMember): TeamMember {
|
||||||
const name = item.userName ?? ''
|
const name = item.userName ?? ''
|
||||||
return {
|
return {
|
||||||
@@ -183,9 +154,7 @@ export function toProjectDetail(bundle: RequirementDetailBundle): Project {
|
|||||||
.sort((a, b) => Number(b.isOwner ?? false) - Number(a.isOwner ?? false))
|
.sort((a, b) => Number(b.isOwner ?? false) - Number(a.isOwner ?? false))
|
||||||
.map(toTeamMember),
|
.map(toTeamMember),
|
||||||
files: (files.requirementAttachments ?? []).map(attachmentToFile),
|
files: (files.requirementAttachments ?? []).map(attachmentToFile),
|
||||||
paymentPlans: (finance.billPlans ?? []).length > 0
|
paymentPlans: (finance.bills ?? []).map(toProjectBill),
|
||||||
? (finance.billPlans ?? []).map(toPlanCard)
|
|
||||||
: (finance.bills ?? []).map(toProjectBill),
|
|
||||||
invoiceRecords: (finance.invoices ?? []).map(invoiceToFile),
|
invoiceRecords: (finance.invoices ?? []).map(invoiceToFile),
|
||||||
contractFile: contract ? contractToFile(contract) : undefined,
|
contractFile: contract ? contractToFile(contract) : undefined,
|
||||||
afterSales: afterSales.afterSale
|
afterSales: afterSales.afterSale
|
||||||
|
|||||||
@@ -3,6 +3,13 @@ import { ElMessage } from 'element-plus'
|
|||||||
import type { ApiResponse } from '@/types/api'
|
import type { ApiResponse } from '@/types/api'
|
||||||
import { storage } from '@/utils/storage'
|
import { storage } from '@/utils/storage'
|
||||||
|
|
||||||
|
declare module 'axios' {
|
||||||
|
export interface AxiosRequestConfig {
|
||||||
|
/** 静默请求:失败时不弹全局错误提示(轮询等高频请求使用) */
|
||||||
|
silent?: boolean
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const SUCCESS_CODE = 200
|
const SUCCESS_CODE = 200
|
||||||
|
|
||||||
export const CLIENT_ID = '9f2c4e7a1b3d5c8e2f6a0b4d7c1e9f3a'
|
export const CLIENT_ID = '9f2c4e7a1b3d5c8e2f6a0b4d7c1e9f3a'
|
||||||
@@ -22,7 +29,9 @@ service.interceptors.request.use((config) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
service.interceptors.response.use(undefined, (error) => {
|
service.interceptors.response.use(undefined, (error) => {
|
||||||
ElMessage.error(error?.message || '网络异常,请稍后重试')
|
if (!error?.config?.silent) {
|
||||||
|
ElMessage.error(error?.message || '网络异常,请稍后重试')
|
||||||
|
}
|
||||||
return Promise.reject(error)
|
return Promise.reject(error)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -56,7 +65,9 @@ export async function request<T>(config: AxiosRequestConfig): Promise<T> {
|
|||||||
const resp = await service.request<ApiResponse<T>>(config)
|
const resp = await service.request<ApiResponse<T>>(config)
|
||||||
const payload = resp.data
|
const payload = resp.data
|
||||||
if (payload.code !== SUCCESS_CODE) {
|
if (payload.code !== SUCCESS_CODE) {
|
||||||
ElMessage.error(payload.msg || '请求失败')
|
if (!config.silent) {
|
||||||
|
ElMessage.error(payload.msg || '请求失败')
|
||||||
|
}
|
||||||
return Promise.reject(new Error(payload.msg || '请求失败'))
|
return Promise.reject(new Error(payload.msg || '请求失败'))
|
||||||
}
|
}
|
||||||
return payload.data
|
return payload.data
|
||||||
|
|||||||
48
src/utils/serviceVo.ts
Normal file
48
src/utils/serviceVo.ts
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
import type {
|
||||||
|
ChatMessage,
|
||||||
|
ChatRole,
|
||||||
|
CsMessageVo,
|
||||||
|
} from '@/types/business/service'
|
||||||
|
import { formatDate } from '@/utils/format'
|
||||||
|
|
||||||
|
const TIME_PATTERN = 'MM-DD HH:mm'
|
||||||
|
|
||||||
|
function toChatRole(senderType: string | null | undefined): ChatRole {
|
||||||
|
return (senderType ?? '').trim().toUpperCase() === 'USER' ? 'user' : 'assistant'
|
||||||
|
}
|
||||||
|
|
||||||
|
function toChatTime(raw: string | null | undefined): string {
|
||||||
|
const value = (raw ?? '').trim()
|
||||||
|
if (!value) return ''
|
||||||
|
return formatDate(value, TIME_PATTERN) || value
|
||||||
|
}
|
||||||
|
|
||||||
|
/** OSS 地址没有单独的文件名字段,取 URL 最后一段兜底。 */
|
||||||
|
function toFileName(url: string): string {
|
||||||
|
const clean = url.split('?')[0]?.split('#')[0] ?? ''
|
||||||
|
const name = clean.slice(clean.lastIndexOf('/') + 1)
|
||||||
|
if (!name) return '附件'
|
||||||
|
try {
|
||||||
|
return decodeURIComponent(name)
|
||||||
|
} catch {
|
||||||
|
return name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function toChatMessage(vo: CsMessageVo): ChatMessage {
|
||||||
|
const fileUrl = vo.fileUrl?.trim() ?? ''
|
||||||
|
return {
|
||||||
|
id: String(vo.id ?? ''),
|
||||||
|
role: toChatRole(vo.senderType),
|
||||||
|
content: vo.content ?? '',
|
||||||
|
file: fileUrl
|
||||||
|
? { name: toFileName(fileUrl), size: Number(vo.fileSize ?? 0), url: fileUrl }
|
||||||
|
: undefined,
|
||||||
|
time: toChatTime(vo.sendTime ?? vo.createTime),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function toChatMessages(list: CsMessageVo[] | null | undefined): ChatMessage[] {
|
||||||
|
if (!list || list.length === 0) return []
|
||||||
|
return list.filter((item) => item != null).map(toChatMessage)
|
||||||
|
}
|
||||||
@@ -6,30 +6,79 @@ function goHome(): void {
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<section class="not-found">
|
<section class="not-found">
|
||||||
<h1>404</h1>
|
<div class="not-found__card">
|
||||||
<p class="text-secondary">
|
<p class="not-found__code">
|
||||||
页面不存在或已下线
|
404
|
||||||
</p>
|
</p>
|
||||||
<button class="not-found__back link" @click="goHome">
|
<h1 class="not-found__title">
|
||||||
返回首页
|
页面不存在
|
||||||
</button>
|
</h1>
|
||||||
|
<p class="not-found__desc text-secondary">
|
||||||
|
页面不存在或已下线,请返回首页继续浏览
|
||||||
|
</p>
|
||||||
|
<button
|
||||||
|
class="not-found__back"
|
||||||
|
type="button"
|
||||||
|
@click="goHome"
|
||||||
|
>
|
||||||
|
返回首页
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
.not-found {
|
.not-found {
|
||||||
.flex(column, center);
|
.flex(column, center, center);
|
||||||
gap: @spacing-base;
|
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
|
padding: @spacing-lg;
|
||||||
|
background: @bg-color;
|
||||||
|
|
||||||
h1 {
|
&__card {
|
||||||
font-size: 64px;
|
.flex(column, center, center);
|
||||||
|
gap: @spacing-sm;
|
||||||
|
width: 100%;
|
||||||
|
max-width: 420px;
|
||||||
|
padding: @spacing-xxl @spacing-xl;
|
||||||
|
border-radius: @radius-base;
|
||||||
|
background: @white;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__code {
|
||||||
|
margin: 0;
|
||||||
|
font-size: @font-size-hero;
|
||||||
|
font-weight: 600;
|
||||||
|
line-height: 1;
|
||||||
|
color: @primary-color;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__title {
|
||||||
|
margin: 0;
|
||||||
|
font-size: @font-size-xl;
|
||||||
|
font-weight: 600;
|
||||||
color: @heading-color;
|
color: @heading-color;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__back {
|
&__desc {
|
||||||
color: @primary-color;
|
margin: 0 0 @spacing-base;
|
||||||
font-size: @font-size-base;
|
font-size: @font-size-base;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&__back {
|
||||||
|
height: 40px;
|
||||||
|
padding: 0 @spacing-xl;
|
||||||
|
border: none;
|
||||||
|
border-radius: @radius-round;
|
||||||
|
background: @primary-color;
|
||||||
|
color: @white;
|
||||||
|
font-size: @font-size-base;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background 0.2s;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: @primary-hover;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ const coverStyle = computed(() =>
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<section class="case-hero" :style="coverStyle">
|
<section class="case-hero" :style="coverStyle">
|
||||||
<div class="container case-hero__inner">
|
<div class="case-hero__inner">
|
||||||
<span v-if="tag" class="case-hero__tag">{{ tag }}</span>
|
<span v-if="tag" class="case-hero__tag">{{ tag }}</span>
|
||||||
<h1 class="case-hero__title">
|
<h1 class="case-hero__title">
|
||||||
{{ props.item.title }}
|
{{ props.item.title }}
|
||||||
@@ -31,17 +31,19 @@ const coverStyle = computed(() =>
|
|||||||
.case-hero {
|
.case-hero {
|
||||||
position: relative;
|
position: relative;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 260px;
|
height: 180px;
|
||||||
|
border-radius: @radius-base;
|
||||||
background-color: @primary-color;
|
background-color: @primary-color;
|
||||||
background-position: center;
|
background-position: center;
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
background-size: cover;
|
background-size: cover;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
&::after {
|
&::after {
|
||||||
content: '';
|
content: '';
|
||||||
position: absolute;
|
position: absolute;
|
||||||
inset: 0;
|
inset: 0;
|
||||||
background: linear-gradient(180deg, rgba(15, 23, 42, 0) 42%, rgba(15, 23, 42, 0.55));
|
background: linear-gradient(180deg, fade(@black, 0%) 40%, fade(@black, 45%));
|
||||||
}
|
}
|
||||||
|
|
||||||
&__inner {
|
&__inner {
|
||||||
@@ -50,7 +52,8 @@ const coverStyle = computed(() =>
|
|||||||
.flex(column, flex-end, flex-start);
|
.flex(column, flex-end, flex-start);
|
||||||
gap: @spacing-sm;
|
gap: @spacing-sm;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
padding-bottom: @spacing-lg;
|
box-sizing: border-box;
|
||||||
|
padding: 0 @spacing-lg @spacing-lg;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__tag {
|
&__tag {
|
||||||
@@ -64,9 +67,9 @@ const coverStyle = computed(() =>
|
|||||||
|
|
||||||
&__title {
|
&__title {
|
||||||
color: @white;
|
color: @white;
|
||||||
font-size: @font-size-xxl;
|
font-size: @font-size-title;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
text-shadow: 0 1px 8px rgba(0, 0, 0, 0.35);
|
text-shadow: 0 1px 8px fade(@black, 35%);
|
||||||
display: -webkit-box;
|
display: -webkit-box;
|
||||||
-webkit-line-clamp: 2;
|
-webkit-line-clamp: 2;
|
||||||
-webkit-box-orient: vertical;
|
-webkit-box-orient: vertical;
|
||||||
|
|||||||
@@ -51,19 +51,21 @@ onMounted(load)
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<template v-if="item">
|
<template v-if="item">
|
||||||
<CaseHero :item="item" />
|
<div class="container case-detail__body">
|
||||||
|
<CaseHero :item="item" />
|
||||||
|
|
||||||
<div class="container case-detail__main">
|
<div class="case-detail__main">
|
||||||
<CaseDetailHeader :item="item" @favorite="onFavorite" @share="onShare" />
|
<CaseDetailHeader :item="item" @favorite="onFavorite" @share="onShare" />
|
||||||
<CaseRichText :item="item" />
|
<CaseRichText :item="item" />
|
||||||
|
|
||||||
<button
|
<button
|
||||||
class="case-detail__cta"
|
class="case-detail__cta"
|
||||||
type="button"
|
type="button"
|
||||||
@click="router.push('/demand')"
|
@click="router.push('/demand')"
|
||||||
>
|
>
|
||||||
一键填报类似案例
|
一键填报类似案例
|
||||||
</button>
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -75,27 +77,33 @@ onMounted(load)
|
|||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
.case-detail {
|
.case-detail {
|
||||||
padding-bottom: @spacing-xxl;
|
min-height: 100%;
|
||||||
|
padding-bottom: @spacing-page-bottom;
|
||||||
|
background: @bg-color;
|
||||||
|
|
||||||
&__crumb {
|
&__crumb {
|
||||||
padding-top: 6px;
|
padding-top: @spacing-base;
|
||||||
padding-bottom: 6px;
|
padding-bottom: @spacing-base;
|
||||||
font-size: @font-size-base;
|
font-size: @font-size-sm;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__body {
|
||||||
|
.flex(column, flex-start, stretch);
|
||||||
|
gap: @spacing-base;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__main {
|
&__main {
|
||||||
.flex(column, flex-start, stretch);
|
.flex(column, flex-start, stretch);
|
||||||
gap: @spacing-base;
|
gap: @spacing-base;
|
||||||
padding-top: @spacing-lg;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&__cta {
|
&__cta {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 44px;
|
height: 40px;
|
||||||
border-radius: @radius-base;
|
border-radius: @radius-round;
|
||||||
background: @primary-color;
|
background: @primary-color;
|
||||||
color: @white;
|
color: @white;
|
||||||
font-size: @font-size-lg;
|
font-size: @font-size-base;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: background 0.2s;
|
transition: background 0.2s;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
export { default } from './index.vue'
|
export { default } from './index.vue'
|
||||||
export { default as CasesFilter } from './cpns/CasesFilter.vue'
|
export { CasesFilter, CasesSearchBar, CasesGrid } from '@/components'
|
||||||
export { default as CasesSearchBar } from './cpns/CasesSearchBar.vue'
|
|
||||||
export { default as CasesGrid } from './cpns/CasesGrid.vue'
|
|
||||||
export { default as CaseHero } from './cpns/CaseHero.vue'
|
export { default as CaseHero } from './cpns/CaseHero.vue'
|
||||||
export { default as CaseDetailHeader } from './cpns/CaseDetailHeader.vue'
|
export { default as CaseDetailHeader } from './cpns/CaseDetailHeader.vue'
|
||||||
export { default as CaseRichText } from './cpns/CaseRichText.vue'
|
export { default as CaseRichText } from './cpns/CaseRichText.vue'
|
||||||
|
|||||||
@@ -3,12 +3,9 @@
|
|||||||
import { onMounted } from 'vue'
|
import { onMounted } from 'vue'
|
||||||
import { storeToRefs } from 'pinia'
|
import { storeToRefs } from 'pinia'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
import { PaginationBar } from '@/components'
|
import { CasesFilter, CasesGrid, CasesSearchBar, PaginationBar } from '@/components'
|
||||||
import { useCasesStore } from '@/stores/modules/cases'
|
import { useCasesStore } from '@/stores/modules/cases'
|
||||||
import type { CaseQuery } from '@/types/business/cases'
|
import type { CaseQuery } from '@/types/business/cases'
|
||||||
import CasesFilter from './cpns/CasesFilter.vue'
|
|
||||||
import CasesSearchBar from './cpns/CasesSearchBar.vue'
|
|
||||||
import CasesGrid from './cpns/CasesGrid.vue'
|
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const casesStore = useCasesStore()
|
const casesStore = useCasesStore()
|
||||||
@@ -48,6 +45,8 @@ function onViewDetail(id: string): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
// 收藏页复用本 store 并会置 favoriteOnly=true,进入案例库时重置,避免状态残留
|
||||||
|
casesStore.resetQuery()
|
||||||
void Promise.all([casesStore.fetchCategories(), casesStore.fetchCases()])
|
void Promise.all([casesStore.fetchCategories(), casesStore.fetchCases()])
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
@@ -110,53 +109,49 @@ onMounted(() => {
|
|||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
.cases {
|
.cases {
|
||||||
padding-bottom: 78px;
|
min-height: 100%;
|
||||||
|
padding-bottom: @spacing-page-bottom;
|
||||||
|
background: @bg-color;
|
||||||
|
|
||||||
&__hero {
|
&__hero {
|
||||||
height: 179px;
|
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
padding-top: 32px;
|
padding: @spacing-lg 0;
|
||||||
background: @white;
|
background: @white;
|
||||||
|
border-bottom: 1px solid @border-color;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设计稿 #31:hero 标题 x=112、副标题 x=112;
|
|
||||||
// 主体筛选栏 x=70、右侧操作区右边界 1850。两套留白并存,
|
|
||||||
// 所以 hero 内容单独内缩,不动全局 .container 的 70px 留白。
|
|
||||||
&__hero-inner {
|
&__hero-inner {
|
||||||
padding-left: 112px;
|
padding-left: @spacing-xl;
|
||||||
padding-right: 112px;
|
padding-right: @spacing-xl;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__title {
|
&__title {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font-size: 36px;
|
font-size: @font-size-title;
|
||||||
font-weight: 700;
|
font-weight: 600;
|
||||||
line-height: 52px;
|
line-height: 1.3;
|
||||||
color: @cases-hero-title;
|
color: @cases-hero-title;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__slogan {
|
&__slogan {
|
||||||
margin: 15px 0 0;
|
margin: @spacing-sm 0 0;
|
||||||
font-size: 24px;
|
font-size: @font-size-base;
|
||||||
font-weight: 500;
|
font-weight: 400;
|
||||||
line-height: 37px;
|
line-height: 1.5;
|
||||||
color: @cases-muted;
|
color: @cases-muted;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__body {
|
&__body {
|
||||||
.flex(row, flex-start, flex-start);
|
.flex(row, flex-start, flex-start);
|
||||||
gap: 20px;
|
gap: @spacing-lg;
|
||||||
padding-top: 20px;
|
padding-top: @spacing-lg;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__main {
|
&__main {
|
||||||
// 设计稿:右侧操作区 x=606 w=1244(右边界 1850,与筛选栏区留白 70 对称)。
|
|
||||||
// mixin 签名是 .flex(direction; justify; align),第三参才是 align-items。
|
|
||||||
// 纵向排列时 justify 无意义,align 用 stretch 让子项撑满 1244。
|
|
||||||
.flex(column, flex-start, stretch);
|
.flex(column, flex-start, stretch);
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
gap: 24px;
|
gap: @spacing-lg;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__pager {
|
&__pager {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { computed } from 'vue'
|
||||||
import { StatusTag } from '@/components'
|
import { StatusTag } from '@/components'
|
||||||
import type { FileInfo } from '@/types/api'
|
import type { FileInfo } from '@/types/api'
|
||||||
import type { Contract, SignStatus } from '@/types/business/contract'
|
import type { Contract, SignStatus } from '@/types/business/contract'
|
||||||
@@ -8,7 +9,10 @@ interface Props {
|
|||||||
contract: Contract
|
contract: Contract
|
||||||
}
|
}
|
||||||
|
|
||||||
defineProps<Props>()
|
const props = defineProps<Props>()
|
||||||
|
|
||||||
|
/** 后端规则:仅「已签署」合同允许下载。 */
|
||||||
|
const canDownload = computed(() => props.contract.signStatus === '已签署')
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
viewProject: []
|
viewProject: []
|
||||||
@@ -17,173 +21,187 @@ const emit = defineEmits<{
|
|||||||
}>()
|
}>()
|
||||||
|
|
||||||
const SIGN_VARIANTS: Record<SignStatus, 'primary' | 'success' | 'warning' | 'danger' | 'info'> = {
|
const SIGN_VARIANTS: Record<SignStatus, 'primary' | 'success' | 'warning' | 'danger' | 'info'> = {
|
||||||
'履行中': 'success',
|
|
||||||
'已过期': 'danger',
|
|
||||||
'待签署': 'warning',
|
'待签署': 'warning',
|
||||||
|
'签署中': 'primary',
|
||||||
|
'已签署': 'success',
|
||||||
|
'已作废': 'info',
|
||||||
|
'已过期': 'danger',
|
||||||
|
}
|
||||||
|
|
||||||
|
function fileMeta(file: FileInfo): string {
|
||||||
|
return [file.size ? formatFileSize(file.size) : '', file.uploadTime].filter(Boolean).join(' · ')
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="contract-info">
|
<div class="contract-info">
|
||||||
<h3 class="contract-info__section contract-info__section--1">
|
<section class="contract-info__section">
|
||||||
<span class="contract-info__step">01</span>
|
<h3 class="contract-info__heading">
|
||||||
<span class="contract-info__section-title">合同信息</span>
|
<span class="contract-info__step">01</span>
|
||||||
</h3>
|
<span>合同信息</span>
|
||||||
<div class="contract-info__field contract-info__field--1 contract-info__field--l">
|
</h3>
|
||||||
<span class="contract-info__label">项目名称</span>
|
<div class="contract-info__grid">
|
||||||
<span class="contract-info__value">{{ contract.contractName }}</span>
|
<div class="contract-info__field">
|
||||||
</div>
|
<span class="contract-info__label">项目名称</span>
|
||||||
<div class="contract-info__field contract-info__field--1 contract-info__field--r">
|
<span class="contract-info__value">{{ contract.contractName }}</span>
|
||||||
<span class="contract-info__label">合同类型</span>
|
</div>
|
||||||
<span class="contract-info__value">{{ contract.contractType }}</span>
|
<div class="contract-info__field">
|
||||||
</div>
|
<span class="contract-info__label">合同类型</span>
|
||||||
<div class="contract-info__field contract-info__field--2 contract-info__field--l">
|
<span class="contract-info__value">{{ contract.contractType }}</span>
|
||||||
<span class="contract-info__label">合同编号</span>
|
</div>
|
||||||
<span class="contract-info__value">{{ contract.contractNo }}</span>
|
<div class="contract-info__field">
|
||||||
</div>
|
<span class="contract-info__label">合同编号</span>
|
||||||
<div class="contract-info__field contract-info__field--2 contract-info__field--r">
|
<span class="contract-info__value">{{ contract.contractNo }}</span>
|
||||||
<span class="contract-info__label">签订日期</span>
|
</div>
|
||||||
<span class="contract-info__value">{{ contract.signDate || '—' }}</span>
|
<div class="contract-info__field">
|
||||||
</div>
|
<span class="contract-info__label">签订日期</span>
|
||||||
<div class="contract-info__field contract-info__field--3 contract-info__field--l">
|
<span class="contract-info__value">{{ contract.signDate || '—' }}</span>
|
||||||
<span class="contract-info__label">生效日期</span>
|
</div>
|
||||||
<span class="contract-info__value">{{ contract.effectiveDate }}</span>
|
<div class="contract-info__field">
|
||||||
</div>
|
<span class="contract-info__label">生效日期</span>
|
||||||
<div class="contract-info__field contract-info__field--3 contract-info__field--r">
|
<span class="contract-info__value">{{ contract.effectiveDate }}</span>
|
||||||
<span class="contract-info__label">到期日期</span>
|
</div>
|
||||||
<span class="contract-info__value">{{ contract.expiryDate }}</span>
|
<div class="contract-info__field">
|
||||||
</div>
|
<span class="contract-info__label">到期日期</span>
|
||||||
<div class="contract-info__field contract-info__field--4 contract-info__field--l">
|
<span class="contract-info__value">{{ contract.expiryDate }}</span>
|
||||||
<span class="contract-info__label">合同状态</span>
|
</div>
|
||||||
<StatusTag :label="contract.signStatus" :variant="SIGN_VARIANTS[contract.signStatus]" />
|
<div class="contract-info__field">
|
||||||
</div>
|
<span class="contract-info__label">合同状态</span>
|
||||||
|
<StatusTag :label="contract.signStatus" :variant="SIGN_VARIANTS[contract.signStatus]" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
<h3 class="contract-info__section contract-info__section--2">
|
<section class="contract-info__section">
|
||||||
<span class="contract-info__step">02</span>
|
<h3 class="contract-info__heading">
|
||||||
<span class="contract-info__section-title">关联项目</span>
|
<span class="contract-info__step">02</span>
|
||||||
</h3>
|
<span>关联项目</span>
|
||||||
<div class="contract-info__field contract-info__field--5 contract-info__field--l">
|
</h3>
|
||||||
<span class="contract-info__label">
|
<div class="contract-info__grid">
|
||||||
项目名称
|
<div class="contract-info__field">
|
||||||
<button class="contract-info__link" @click="emit('viewProject')">查看详情</button>
|
<span class="contract-info__label">
|
||||||
</span>
|
项目名称
|
||||||
<span class="contract-info__value">{{ contract.relatedProjectName }}</span>
|
<button
|
||||||
</div>
|
type="button"
|
||||||
<div class="contract-info__field contract-info__field--5 contract-info__field--r">
|
class="contract-info__link"
|
||||||
<span class="contract-info__label">项目编号</span>
|
@click="emit('viewProject')"
|
||||||
<span class="contract-info__value">{{ contract.projectNo }}</span>
|
>
|
||||||
</div>
|
查看详情
|
||||||
|
</button>
|
||||||
<h3 class="contract-info__section contract-info__section--3">
|
|
||||||
<span class="contract-info__step">03</span>
|
|
||||||
<span class="contract-info__section-title">合同文件</span>
|
|
||||||
</h3>
|
|
||||||
<ul class="contract-info__files">
|
|
||||||
<li
|
|
||||||
v-for="(file, index) in contract.files"
|
|
||||||
:key="`${file.name}-${index}`"
|
|
||||||
class="contract-info__file"
|
|
||||||
>
|
|
||||||
<div class="contract-info__file-info">
|
|
||||||
<span class="contract-info__file-name" :title="file.name">{{ file.name }}</span>
|
|
||||||
<span class="contract-info__file-meta">
|
|
||||||
{{ formatFileSize(file.size) }} · {{ file.uploadTime }}
|
|
||||||
</span>
|
</span>
|
||||||
|
<span class="contract-info__value">{{ contract.relatedProjectName }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="contract-info__file-actions">
|
<div class="contract-info__field">
|
||||||
<button class="contract-info__link" @click="emit('preview', file)">
|
<span class="contract-info__label">项目编号</span>
|
||||||
预览
|
<span class="contract-info__value">{{ contract.projectNo }}</span>
|
||||||
</button>
|
|
||||||
<button class="contract-info__link" @click="emit('download', file)">
|
|
||||||
下载
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</div>
|
||||||
<li v-if="contract.files.length === 0" class="contract-info__empty">
|
</section>
|
||||||
暂无合同文件
|
|
||||||
</li>
|
<section class="contract-info__section">
|
||||||
</ul>
|
<h3 class="contract-info__heading">
|
||||||
|
<span class="contract-info__step">03</span>
|
||||||
|
<span>合同文件</span>
|
||||||
|
</h3>
|
||||||
|
<ul class="contract-info__files">
|
||||||
|
<li
|
||||||
|
v-for="(file, index) in contract.files"
|
||||||
|
:key="`${file.name}-${index}`"
|
||||||
|
class="contract-info__file"
|
||||||
|
>
|
||||||
|
<div class="contract-info__file-info">
|
||||||
|
<span class="contract-info__file-name" :title="file.name">{{ file.name }}</span>
|
||||||
|
<span v-if="fileMeta(file)" class="contract-info__file-meta">
|
||||||
|
{{ fileMeta(file) }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="contract-info__file-actions">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="contract-info__link"
|
||||||
|
@click="emit('preview', file)"
|
||||||
|
>
|
||||||
|
预览
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
v-if="canDownload"
|
||||||
|
type="button"
|
||||||
|
class="contract-info__link"
|
||||||
|
@click="emit('download', file)"
|
||||||
|
>
|
||||||
|
下载
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
<li v-if="contract.files.length === 0" class="contract-info__empty">
|
||||||
|
暂无合同文件
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</section>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
.contract-info {
|
.contract-info {
|
||||||
position: relative;
|
width: 100%;
|
||||||
width: 1780px;
|
margin-top: @spacing-base;
|
||||||
height: 1152px;
|
padding: @spacing-xl;
|
||||||
margin-top: 21px;
|
border-radius: @radius-base;
|
||||||
border-radius: @radius-lg;
|
|
||||||
background: @white;
|
background: @white;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
|
||||||
&__section {
|
&__section + &__section {
|
||||||
position: absolute;
|
margin-top: @spacing-xxl;
|
||||||
left: 43px;
|
|
||||||
top: 0;
|
|
||||||
height: 0;
|
|
||||||
|
|
||||||
&--1 { top: 36px; }
|
|
||||||
&--2 { top: 649px; }
|
|
||||||
&--3 { top: 901px; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&__section-title {
|
&__heading {
|
||||||
position: absolute;
|
.flex(row, flex-start, center);
|
||||||
left: 60px;
|
gap: @spacing-sm;
|
||||||
margin: 0;
|
margin: 0 0 @spacing-lg;
|
||||||
font-size: 28px;
|
font-size: @font-size-lg;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
line-height: 41px;
|
line-height: 1.4;
|
||||||
color: @contract-cell-text;
|
color: @contract-cell-text;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__step {
|
&__step {
|
||||||
position: absolute;
|
font-size: @font-size-title;
|
||||||
left: 0;
|
font-weight: 600;
|
||||||
top: 50%;
|
line-height: 1.2;
|
||||||
font-size: 48px;
|
|
||||||
font-weight: 500;
|
|
||||||
line-height: 70px;
|
|
||||||
color: @project-accent;
|
color: @project-accent;
|
||||||
white-space: nowrap;
|
}
|
||||||
transform: translateY(-50%);
|
|
||||||
|
&__grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||||
|
gap: @spacing-lg;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__field {
|
&__field {
|
||||||
.flex(column, flex-start, stretch);
|
.flex(column, flex-start, stretch);
|
||||||
position: absolute;
|
gap: @spacing-sm;
|
||||||
width: 764px;
|
min-width: 0;
|
||||||
gap: 14px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&__field--1 { top: 174px; }
|
|
||||||
&__field--2 { top: 296px; }
|
|
||||||
&__field--3 { top: 418px; }
|
|
||||||
&__field--4 { top: 540px; }
|
|
||||||
&__field--5 { top: 770px; }
|
|
||||||
|
|
||||||
&__field--5:has(&__label) { top: 749px; }
|
|
||||||
|
|
||||||
&__field--l { left: 64px; }
|
|
||||||
&__field--r { left: 940px; }
|
|
||||||
|
|
||||||
&__label {
|
&__label {
|
||||||
font-size: 20px;
|
.flex(row, flex-start, center);
|
||||||
|
gap: @spacing-sm;
|
||||||
|
font-size: @font-size-base;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
line-height: 29px;
|
line-height: 1.4;
|
||||||
color: @contract-cell-text;
|
color: @contract-cell-text;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__value {
|
&__value {
|
||||||
.flex(row, flex-start, center);
|
.flex(row, flex-start, center);
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 49px;
|
height: 40px;
|
||||||
padding: 0 18px;
|
padding: 0 @spacing-base;
|
||||||
border: 1px solid @contract-line;
|
border: 1px solid @border-color;
|
||||||
border-radius: 8px;
|
border-radius: @radius-sm;
|
||||||
background: @contract-page-bg;
|
background: @bg-color-light;
|
||||||
font-size: 20px;
|
font-size: @font-size-base;
|
||||||
line-height: 29px;
|
line-height: 1.4;
|
||||||
color: @contract-cell-text;
|
color: @contract-cell-text;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
.ellipsis();
|
.ellipsis();
|
||||||
@@ -192,19 +210,19 @@ const SIGN_VARIANTS: Record<SignStatus, 'primary' | 'success' | 'warning' | 'dan
|
|||||||
&__field :deep(.status-tag) {
|
&__field :deep(.status-tag) {
|
||||||
.flex(row, flex-start, center);
|
.flex(row, flex-start, center);
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 49px;
|
height: 40px;
|
||||||
padding: 0 18px;
|
padding: 0 @spacing-base;
|
||||||
border: 1px solid @contract-line;
|
border: 1px solid @border-color;
|
||||||
border-radius: 8px;
|
border-radius: @radius-sm;
|
||||||
background: @contract-page-bg;
|
background: @bg-color-light;
|
||||||
font-size: 20px;
|
font-size: @font-size-base;
|
||||||
line-height: 29px;
|
line-height: 1.4;
|
||||||
color: @contract-cell-text;
|
color: @contract-cell-text;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__link {
|
&__link {
|
||||||
font-size: 18px;
|
font-size: @font-size-sm;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
color: @contract-accent;
|
color: @contract-accent;
|
||||||
transition: opacity 0.2s;
|
transition: opacity 0.2s;
|
||||||
@@ -214,18 +232,9 @@ const SIGN_VARIANTS: Record<SignStatus, 'primary' | 'success' | 'warning' | 'dan
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&__label &__link {
|
|
||||||
margin-left: 10px;
|
|
||||||
font-size: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__files {
|
&__files {
|
||||||
.flex(column, flex-start, stretch);
|
.flex(column, flex-start, stretch);
|
||||||
position: absolute;
|
gap: @spacing-sm;
|
||||||
top: 1001px; // 1153 − 152
|
|
||||||
left: 54px; // 124 − 70
|
|
||||||
width: 1640px;
|
|
||||||
gap: 0;
|
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
list-style: none;
|
list-style: none;
|
||||||
@@ -234,28 +243,29 @@ const SIGN_VARIANTS: Record<SignStatus, 'primary' | 'success' | 'warning' | 'dan
|
|||||||
&__file {
|
&__file {
|
||||||
.flex(row, space-between, center);
|
.flex(row, space-between, center);
|
||||||
gap: @spacing-base;
|
gap: @spacing-base;
|
||||||
height: 90px;
|
min-height: 64px;
|
||||||
padding: 0 30px;
|
padding: 0 @spacing-base;
|
||||||
background: @contract-table-head-bg;
|
border-radius: @radius-base;
|
||||||
|
background: @bg-color-light;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__file-info {
|
&__file-info {
|
||||||
.flex(column, flex-start, stretch);
|
.flex(column, flex-start, stretch);
|
||||||
gap: 4px;
|
gap: 2px;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__file-name {
|
&__file-name {
|
||||||
font-size: 20px;
|
font-size: @font-size-base;
|
||||||
line-height: 29px;
|
line-height: 1.4;
|
||||||
color: @contract-cell-text;
|
color: @contract-cell-text;
|
||||||
.ellipsis();
|
.ellipsis();
|
||||||
}
|
}
|
||||||
|
|
||||||
&__file-meta {
|
&__file-meta {
|
||||||
font-size: 14px;
|
font-size: @font-size-sm;
|
||||||
line-height: 20px;
|
line-height: 1.4;
|
||||||
color: @contract-muted;
|
color: @contract-muted;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -267,9 +277,11 @@ const SIGN_VARIANTS: Record<SignStatus, 'primary' | 'success' | 'warning' | 'dan
|
|||||||
|
|
||||||
&__empty {
|
&__empty {
|
||||||
.flex(row, flex-start, center);
|
.flex(row, flex-start, center);
|
||||||
height: 90px;
|
min-height: 64px;
|
||||||
padding: 0 30px;
|
padding: 0 @spacing-base;
|
||||||
font-size: 18px;
|
border-radius: @radius-base;
|
||||||
|
background: @bg-color-light;
|
||||||
|
font-size: @font-size-base;
|
||||||
color: @contract-muted;
|
color: @contract-muted;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,17 +4,23 @@ import SignSteps from './SignSteps.vue'
|
|||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
expiresIn?: number
|
expiresIn?: number
|
||||||
|
content?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
withDefaults(defineProps<Props>(), { expiresIn: 272 })
|
withDefaults(defineProps<Props>(), { expiresIn: 300 })
|
||||||
|
|
||||||
const emit = defineEmits<{ refresh: [] }>()
|
const emit = defineEmits<{ refresh: []; expire: [] }>()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="sign-panel">
|
<div class="sign-panel">
|
||||||
<div class="sign-panel__left">
|
<div class="sign-panel__left">
|
||||||
<QrCodePanel :expires-in="expiresIn" @refresh="emit('refresh')" />
|
<QrCodePanel
|
||||||
|
:expires-in="expiresIn"
|
||||||
|
:content="content"
|
||||||
|
@refresh="emit('refresh')"
|
||||||
|
@expire="emit('expire')"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="sign-panel__right">
|
<div class="sign-panel__right">
|
||||||
<SignSteps />
|
<SignSteps />
|
||||||
@@ -25,9 +31,9 @@ const emit = defineEmits<{ refresh: [] }>()
|
|||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
.sign-panel {
|
.sign-panel {
|
||||||
.flex(row, flex-start, flex-start);
|
.flex(row, flex-start, flex-start);
|
||||||
gap: 48px;
|
gap: @spacing-xl;
|
||||||
padding: 28px 32px;
|
padding: @spacing-xl;
|
||||||
border-radius: @radius-lg;
|
border-radius: @radius-base;
|
||||||
background: @white;
|
background: @white;
|
||||||
|
|
||||||
&__left {
|
&__left {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { ElTable, ElTableColumn } from 'element-plus'
|
||||||
import { StatusTag } from '@/components'
|
import { StatusTag } from '@/components'
|
||||||
import type { Contract, SignStatus } from '@/types/business/contract'
|
import type { Contract, SignStatus } from '@/types/business/contract'
|
||||||
import { formatMoney } from '@/utils/format'
|
import { formatMoney } from '@/utils/format'
|
||||||
@@ -15,143 +16,125 @@ const emit = defineEmits<{
|
|||||||
}>()
|
}>()
|
||||||
|
|
||||||
const SIGN_VARIANTS: Record<SignStatus, 'primary' | 'success' | 'warning' | 'danger' | 'info'> = {
|
const SIGN_VARIANTS: Record<SignStatus, 'primary' | 'success' | 'warning' | 'danger' | 'info'> = {
|
||||||
'履行中': 'success',
|
|
||||||
'已过期': 'danger',
|
|
||||||
'待签署': 'warning',
|
'待签署': 'warning',
|
||||||
|
'签署中': 'primary',
|
||||||
|
'已签署': 'success',
|
||||||
|
'已作废': 'info',
|
||||||
|
'已过期': 'danger',
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="contract-table">
|
<div class="contract-table">
|
||||||
<table class="contract-table__grid">
|
<el-table
|
||||||
<thead>
|
:data="contracts"
|
||||||
<tr>
|
style="width: 100%"
|
||||||
<th>合同编号</th>
|
>
|
||||||
<th>合同名称</th>
|
<el-table-column prop="contractNo" label="合同编号" show-overflow-tooltip />
|
||||||
<th>合同类型</th>
|
<el-table-column prop="contractName" label="合同名称" show-overflow-tooltip />
|
||||||
<th>合同金额</th>
|
<el-table-column prop="contractType" label="合同类型" show-overflow-tooltip />
|
||||||
<th>关联项目</th>
|
<el-table-column label="合同金额" show-overflow-tooltip>
|
||||||
<th>项目编号</th>
|
<template #default="{ row }">
|
||||||
<th>签署状态</th>
|
¥{{ formatMoney((row as Contract).contractAmount) }}
|
||||||
<th>生效时间</th>
|
</template>
|
||||||
<th>到期时间</th>
|
</el-table-column>
|
||||||
<th>操作</th>
|
<el-table-column prop="relatedProjectName" label="关联项目" show-overflow-tooltip />
|
||||||
</tr>
|
<el-table-column prop="projectNo" label="项目编号" show-overflow-tooltip />
|
||||||
</thead>
|
<el-table-column label="签署状态" width="140">
|
||||||
<tbody>
|
<template #default="{ row }">
|
||||||
<tr v-for="item in contracts" :key="item.id">
|
<StatusTag :label="(row as Contract).signStatus" :variant="SIGN_VARIANTS[(row as Contract).signStatus]" />
|
||||||
<td>{{ item.contractNo }}</td>
|
</template>
|
||||||
<td class="contract-table__name" :title="item.contractName">
|
</el-table-column>
|
||||||
{{ item.contractName }}
|
<el-table-column prop="effectiveDate" label="生效时间" show-overflow-tooltip />
|
||||||
</td>
|
<el-table-column prop="expiryDate" label="到期时间" show-overflow-tooltip />
|
||||||
<td>{{ item.contractType }}</td>
|
<el-table-column label="操作" width="180">
|
||||||
<td>¥{{ formatMoney(item.contractAmount) }}</td>
|
<template #default="{ row }">
|
||||||
<td class="contract-table__name" :title="item.relatedProjectName">
|
<div class="contract-table__actions">
|
||||||
{{ item.relatedProjectName }}
|
|
||||||
</td>
|
|
||||||
<td>{{ item.projectNo }}</td>
|
|
||||||
<td>
|
|
||||||
<StatusTag :label="item.signStatus" :variant="SIGN_VARIANTS[item.signStatus]" />
|
|
||||||
</td>
|
|
||||||
<td>{{ item.effectiveDate }}</td>
|
|
||||||
<td>{{ item.expiryDate }}</td>
|
|
||||||
<td class="contract-table__actions">
|
|
||||||
<button
|
<button
|
||||||
v-if="item.signStatus === '待签署'"
|
v-if="(row as Contract).signStatus === '待签署'"
|
||||||
|
type="button"
|
||||||
class="contract-table__btn contract-table__btn--primary"
|
class="contract-table__btn contract-table__btn--primary"
|
||||||
@click="emit('sign', item.id)"
|
@click="emit('sign', (row as Contract).id)"
|
||||||
>
|
>
|
||||||
去签署
|
去签署
|
||||||
</button>
|
</button>
|
||||||
<button class="contract-table__btn" @click="emit('view', item.id)">
|
<button
|
||||||
|
type="button"
|
||||||
|
class="contract-table__btn"
|
||||||
|
@click="emit('view', (row as Contract).id)"
|
||||||
|
>
|
||||||
详情
|
详情
|
||||||
</button>
|
</button>
|
||||||
</td>
|
</div>
|
||||||
</tr>
|
</template>
|
||||||
<tr v-if="contracts.length === 0">
|
</el-table-column>
|
||||||
<td colspan="10" class="contract-table__empty text-secondary">
|
<template #empty>
|
||||||
暂无符合条件的合同
|
<span class="contract-table__empty">暂无符合条件的合同</span>
|
||||||
</td>
|
</template>
|
||||||
</tr>
|
</el-table>
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
.contract-table {
|
.contract-table {
|
||||||
overflow-x: auto;
|
:deep(.el-table) {
|
||||||
.scrollbar();
|
font-size: @font-size-sm;
|
||||||
|
--el-table-border-color: @contract-line;
|
||||||
|
--el-table-header-bg-color: @contract-table-head-bg;
|
||||||
|
--el-table-header-text-color: @contract-head-text;
|
||||||
|
--el-table-text-color: @contract-cell-text;
|
||||||
|
--el-table-row-hover-bg-color: @bg-color-light;
|
||||||
|
background: @white;
|
||||||
|
|
||||||
&__grid {
|
&::before {
|
||||||
width: 100%;
|
display: none;
|
||||||
border: 1px solid @contract-line;
|
|
||||||
border-collapse: collapse;
|
|
||||||
table-layout: fixed;
|
|
||||||
font-size: 20px;
|
|
||||||
|
|
||||||
th,
|
|
||||||
td {
|
|
||||||
padding: 0 10px;
|
|
||||||
border-bottom: 1px solid @contract-line;
|
|
||||||
vertical-align: middle;
|
|
||||||
white-space: nowrap;
|
|
||||||
font-size: 20px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
td.contract-table__name {
|
.el-table__cell {
|
||||||
white-space: normal;
|
padding: 0;
|
||||||
word-break: break-all;
|
border-right: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
th {
|
.cell {
|
||||||
height: 64px;
|
padding: 0 @spacing-sm;
|
||||||
padding-top: 0;
|
font-size: @font-size-sm;
|
||||||
padding-bottom: 0;
|
line-height: 1.4;
|
||||||
|
}
|
||||||
|
|
||||||
|
th.el-table__cell {
|
||||||
|
height: 44px;
|
||||||
|
font-weight: 500;
|
||||||
background: @contract-table-head-bg;
|
background: @contract-table-head-bg;
|
||||||
color: @contract-head-text;
|
border-bottom: 1px solid @contract-line;
|
||||||
font-weight: 400;
|
|
||||||
text-align: center;
|
.cell {
|
||||||
|
color: @contract-head-text;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
td {
|
td.el-table__cell {
|
||||||
height: 96px;
|
height: 64px;
|
||||||
color: @contract-cell-text;
|
color: @contract-cell-text;
|
||||||
line-height: 29px;
|
border-bottom: 1px solid @contract-line;
|
||||||
}
|
}
|
||||||
|
|
||||||
tbody tr:last-child td {
|
.el-table__row:hover > td.el-table__cell {
|
||||||
border-bottom: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
tbody tr:hover td {
|
|
||||||
background: @bg-color-light;
|
background: @bg-color-light;
|
||||||
}
|
}
|
||||||
|
|
||||||
th:nth-child(1) { width: 11%; }
|
|
||||||
th:nth-child(2) { width: 9%; }
|
|
||||||
th:nth-child(3) { width: 10%; }
|
|
||||||
th:nth-child(4) { width: 9%; }
|
|
||||||
th:nth-child(5) { width: 10%; }
|
|
||||||
th:nth-child(6) { width: 11%; }
|
|
||||||
th:nth-child(7) { width: 7%; }
|
|
||||||
th:nth-child(8) { width: 11%; }
|
|
||||||
th:nth-child(9) { width: 11%; }
|
|
||||||
th:nth-child(10) { width: 11%; }
|
|
||||||
}
|
|
||||||
|
|
||||||
&__name {
|
|
||||||
color: @contract-cell-text;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&__actions {
|
&__actions {
|
||||||
.flex(row, center);
|
.flex(row, center);
|
||||||
gap: @spacing-sm;
|
gap: @spacing-base;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__btn {
|
&__btn {
|
||||||
font-size: 13px;
|
font-size: @font-size-sm;
|
||||||
color: @contract-accent;
|
color: @contract-accent;
|
||||||
|
background: transparent;
|
||||||
|
border: none;
|
||||||
|
cursor: pointer;
|
||||||
transition: opacity 0.2s;
|
transition: opacity 0.2s;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
@@ -161,7 +144,6 @@ const SIGN_VARIANTS: Record<SignStatus, 'primary' | 'success' | 'warning' | 'dan
|
|||||||
&--primary {
|
&--primary {
|
||||||
height: 28px;
|
height: 28px;
|
||||||
padding: 0 @spacing-sm;
|
padding: 0 @spacing-sm;
|
||||||
border: none;
|
|
||||||
border-radius: @radius-sm;
|
border-radius: @radius-sm;
|
||||||
background: @contract-accent;
|
background: @contract-accent;
|
||||||
color: @white;
|
color: @white;
|
||||||
@@ -173,6 +155,12 @@ const SIGN_VARIANTS: Record<SignStatus, 'primary' | 'success' | 'warning' | 'dan
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&__empty {
|
||||||
|
display: block;
|
||||||
|
padding: @spacing-xl 0;
|
||||||
|
color: @text-color-secondary;
|
||||||
|
}
|
||||||
|
|
||||||
:deep(.status-tag) {
|
:deep(.status-tag) {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
@@ -180,10 +168,5 @@ const SIGN_VARIANTS: Record<SignStatus, 'primary' | 'success' | 'warning' | 'dan
|
|||||||
color: inherit;
|
color: inherit;
|
||||||
font-size: inherit;
|
font-size: inherit;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__empty {
|
|
||||||
padding: @spacing-xl 0;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import { computed, onMounted, watch } from 'vue'
|
|||||||
import { storeToRefs } from 'pinia'
|
import { storeToRefs } from 'pinia'
|
||||||
import { useRoute, useRouter } from 'vue-router'
|
import { useRoute, useRouter } from 'vue-router'
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
import { AppButton } from '@/components'
|
|
||||||
import type { FileInfo } from '@/types/api'
|
import type { FileInfo } from '@/types/api'
|
||||||
import { useContractStore } from '@/stores/modules/contract'
|
import { useContractStore } from '@/stores/modules/contract'
|
||||||
import ContractInfoCard from './cpns/ContractInfoCard.vue'
|
import ContractInfoCard from './cpns/ContractInfoCard.vue'
|
||||||
@@ -19,23 +18,49 @@ function load(): void {
|
|||||||
void contractStore.fetchDetail(contractId.value)
|
void contractStore.fetchDetail(contractId.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
function onBack(): void {
|
|
||||||
void router.push('/contract')
|
|
||||||
}
|
|
||||||
|
|
||||||
function onViewProject(): void {
|
function onViewProject(): void {
|
||||||
// TODO: 关联项目 id 由接口返回后跳转项目详情
|
const projectId = current.value?.relatedProjectId
|
||||||
ElMessage.info('项目详情跳转待接口接入')
|
if (!projectId) {
|
||||||
|
ElMessage.info('该合同暂未关联项目')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
void router.push(`/project/${projectId}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
function onPreview(file: FileInfo): void {
|
async function onPreview(): Promise<void> {
|
||||||
// TODO(api): 合同文件预览接口
|
try {
|
||||||
ElMessage.info(`「${file.name}」预览待接口接入`)
|
const url = await contractStore.fetchPreviewUrl(contractId.value)
|
||||||
|
if (!url) {
|
||||||
|
ElMessage.info('暂无可预览的合同文件')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
window.open(url, '_blank', 'noopener')
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
console.warn('[contract] 合同预览失败', error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onDownload(file: FileInfo): void {
|
async function onDownload(file: FileInfo): Promise<void> {
|
||||||
// TODO(api): 合同文件下载接口
|
try {
|
||||||
ElMessage.info(`「${file.name}」下载待接口接入`)
|
const url = await contractStore.fetchDownloadUrl(contractId.value)
|
||||||
|
if (!url) {
|
||||||
|
ElMessage.info('暂无可下载的合同文件')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const link = document.createElement('a')
|
||||||
|
link.href = url
|
||||||
|
link.target = '_blank'
|
||||||
|
link.rel = 'noopener'
|
||||||
|
// 没有 download 属性时跨域 URL 只会打开新标签页而不会触发下载
|
||||||
|
link.download = /\.pdf$/i.test(file.name) ? file.name : `${file.name || 'contract'}.pdf`
|
||||||
|
document.body.appendChild(link)
|
||||||
|
link.click()
|
||||||
|
document.body.removeChild(link)
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
console.warn('[contract] 合同下载失败', error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(contractId, load)
|
watch(contractId, load)
|
||||||
@@ -65,54 +90,29 @@ onMounted(load)
|
|||||||
<p v-else class="contract-detail__empty text-secondary">
|
<p v-else class="contract-detail__empty text-secondary">
|
||||||
合同不存在或已下线
|
合同不存在或已下线
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="contract-detail__footer">
|
|
||||||
<AppButton @click="onBack">
|
|
||||||
返回
|
|
||||||
</AppButton>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
.contract-detail {
|
.contract-detail {
|
||||||
padding-bottom: @spacing-xxl;
|
min-height: 100%;
|
||||||
|
padding-bottom: @spacing-page-bottom;
|
||||||
|
background: @bg-color;
|
||||||
|
|
||||||
.container {
|
.container {
|
||||||
.flex(column, flex-start, stretch);
|
.flex(column, flex-start, stretch);
|
||||||
gap: 0;
|
gap: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__breadcrumb {
|
&__breadcrumb {
|
||||||
padding-top: 32px;
|
padding-top: @spacing-lg;
|
||||||
font-size: 24px;
|
font-size: @font-size-sm;
|
||||||
font-weight: 500;
|
font-weight: 400;
|
||||||
line-height: 27px;
|
line-height: 1.5;
|
||||||
color: @contract-muted;
|
color: @contract-muted;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__footer {
|
|
||||||
.flex(row, flex-end);
|
|
||||||
width: 100%;
|
|
||||||
margin-top: 30px;
|
|
||||||
|
|
||||||
:deep(.app-button) {
|
|
||||||
height: 40px;
|
|
||||||
padding: 0 32px;
|
|
||||||
border: none;
|
|
||||||
border-radius: @radius-base;
|
|
||||||
background: @primary-strong;
|
|
||||||
color: @white;
|
|
||||||
font-size: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
:deep(.app-button:hover) {
|
|
||||||
border-color: transparent;
|
|
||||||
background: @primary-color;
|
|
||||||
color: @white;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&__empty {
|
&__empty {
|
||||||
padding: @spacing-xxl 0;
|
padding: @spacing-xxl 0;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ onMounted(() => {
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<PaginationBar
|
<PaginationBar
|
||||||
:page="query.page"
|
:page="query.pageNum"
|
||||||
:page-size="query.pageSize"
|
:page-size="query.pageSize"
|
||||||
:total="total"
|
:total="total"
|
||||||
@page-change="onPageChange"
|
@page-change="onPageChange"
|
||||||
@@ -82,41 +82,40 @@ onMounted(() => {
|
|||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
.contract {
|
.contract {
|
||||||
padding-bottom: @spacing-xxl;
|
min-height: 100%;
|
||||||
|
padding-bottom: @spacing-page-bottom;
|
||||||
|
background: @bg-color;
|
||||||
|
|
||||||
&__head {
|
&__head {
|
||||||
padding: 24px 0 52px;
|
padding: @spacing-lg 0;
|
||||||
background: @white;
|
background: @white;
|
||||||
|
border-bottom: 1px solid @border-color;
|
||||||
.container {
|
|
||||||
padding-left: 42px;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&__title {
|
&__title {
|
||||||
font-size: 36px;
|
font-size: @font-size-title;
|
||||||
font-weight: 700;
|
font-weight: 600;
|
||||||
line-height: 52px;
|
line-height: 1.3;
|
||||||
color: @contract-ink;
|
color: @contract-ink;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__slogan {
|
&__slogan {
|
||||||
margin-top: 13.5px;
|
margin-top: @spacing-sm;
|
||||||
font-size: 24px;
|
font-size: @font-size-base;
|
||||||
font-weight: 500;
|
font-weight: 400;
|
||||||
line-height: 37px;
|
line-height: 1.5;
|
||||||
color: @contract-muted;
|
color: @contract-muted;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.contract .contract__card {
|
.contract .contract__card {
|
||||||
margin-top: 20px;
|
margin-top: @spacing-lg;
|
||||||
padding: 51px 64px 59px;
|
padding: @spacing-lg;
|
||||||
border-radius: @radius-lg;
|
border-radius: @radius-base;
|
||||||
background: @white;
|
background: @white;
|
||||||
|
|
||||||
:deep(.filter-panel) {
|
:deep(.filter-panel) {
|
||||||
margin-bottom: 39px;
|
margin-bottom: @spacing-lg;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
@@ -128,26 +127,19 @@ onMounted(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
:deep(.filter-panel__bar) {
|
:deep(.filter-panel__bar) {
|
||||||
gap: 8px;
|
gap: @spacing-base;
|
||||||
|
}
|
||||||
.filter-panel__btn {
|
|
||||||
margin-left: 78px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.filter-panel__btn--primary {
|
|
||||||
margin-left: 40px;
|
|
||||||
} }
|
|
||||||
|
|
||||||
:deep(.filter-panel__input) {
|
:deep(.filter-panel__input) {
|
||||||
flex: 0 0 592px;
|
flex: 0 1 360px;
|
||||||
width: 592px;
|
width: auto;
|
||||||
max-width: none;
|
max-width: 360px;
|
||||||
margin-right: 0;
|
margin-right: 0;
|
||||||
height: 49px;
|
height: 36px;
|
||||||
border-color: transparent;
|
border: 1px solid @border-color;
|
||||||
border-radius: 0;
|
border-radius: @radius-round;
|
||||||
background: @input-bg;
|
background: @input-bg;
|
||||||
font-size: 20px;
|
font-size: @font-size-base;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,53 +149,50 @@ onMounted(() => {
|
|||||||
|
|
||||||
:deep(.filter-panel__input:focus) {
|
:deep(.filter-panel__input:focus) {
|
||||||
border-color: @primary-strong;
|
border-color: @primary-strong;
|
||||||
|
background: @white;
|
||||||
}
|
}
|
||||||
|
|
||||||
:deep(.filter-panel__btn) {
|
:deep(.filter-panel__btn) {
|
||||||
order: 1;
|
min-width: 72px;
|
||||||
min-width: 0;
|
height: 36px;
|
||||||
height: 29px;
|
padding: 0 @spacing-lg;
|
||||||
padding: 0 12px;
|
|
||||||
border: none;
|
border: none;
|
||||||
border-radius: 0;
|
border-radius: @radius-round;
|
||||||
background: transparent;
|
background: @pill-bg;
|
||||||
color: @contract-placeholder;
|
color: @text-color;
|
||||||
font-size: 20px;
|
font-size: @font-size-base;
|
||||||
}
|
}
|
||||||
|
|
||||||
:deep(.filter-panel__btn:hover) {
|
:deep(.filter-panel__btn:hover) {
|
||||||
border-color: transparent;
|
color: @primary-color;
|
||||||
color: @text-color;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
:deep(.filter-panel__btn--primary) {
|
:deep(.filter-panel__btn--primary) {
|
||||||
order: 2;
|
background: @contract-accent;
|
||||||
border-radius: 0;
|
color: @white;
|
||||||
background: transparent;
|
|
||||||
color: @contract-accent;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
:deep(.filter-panel__btn--primary:hover) {
|
:deep(.filter-panel__btn--primary:hover) {
|
||||||
background: transparent;
|
background: @primary-color;
|
||||||
color: @primary-color;
|
color: @white;
|
||||||
}
|
}
|
||||||
|
|
||||||
:deep(.pagination) {
|
:deep(.pagination) {
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
gap: 10px;
|
gap: @spacing-xs;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
margin-top: 28px;
|
margin-top: @spacing-lg;
|
||||||
}
|
}
|
||||||
|
|
||||||
:deep(.pagination__btn) {
|
:deep(.pagination__btn) {
|
||||||
min-width: 40px;
|
min-width: 28px;
|
||||||
height: 26px;
|
height: 28px;
|
||||||
padding: 0 4px;
|
padding: 0 6px;
|
||||||
border: 1px solid @contract-line;
|
border: 1px solid @border-color;
|
||||||
border-radius: 0;
|
border-radius: @radius-sm;
|
||||||
background: @white;
|
background: @white;
|
||||||
color: @contract-line;
|
color: @text-color;
|
||||||
font-size: 14px;
|
font-size: @font-size-sm;
|
||||||
}
|
}
|
||||||
|
|
||||||
:deep(.pagination__btn:hover:not(:disabled):not(.is-ellipsis)) {
|
:deep(.pagination__btn:hover:not(:disabled):not(.is-ellipsis)) {
|
||||||
@@ -213,8 +202,9 @@ onMounted(() => {
|
|||||||
|
|
||||||
:deep(.pagination__btn.is-active) {
|
:deep(.pagination__btn.is-active) {
|
||||||
border-color: @contract-accent;
|
border-color: @contract-accent;
|
||||||
background: @contract-accent;
|
background: @primary-light;
|
||||||
color: @white;
|
color: @contract-accent;
|
||||||
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
:deep(.pagination__btn.is-ellipsis) {
|
:deep(.pagination__btn.is-ellipsis) {
|
||||||
@@ -222,20 +212,5 @@ onMounted(() => {
|
|||||||
background: transparent;
|
background: transparent;
|
||||||
color: @contract-muted;
|
color: @contract-muted;
|
||||||
}
|
}
|
||||||
|
|
||||||
:deep(.pagination__btn:first-child),
|
|
||||||
:deep(.pagination__btn:last-child) {
|
|
||||||
min-width: auto;
|
|
||||||
padding: 0 2px;
|
|
||||||
border: none;
|
|
||||||
background: transparent;
|
|
||||||
color: @contract-muted;
|
|
||||||
font-size: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
:deep(.pagination__btn:first-child:disabled),
|
|
||||||
:deep(.pagination__btn:last-child:disabled) {
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, onMounted, watch } from 'vue'
|
import { computed, onBeforeUnmount, onMounted, watch } from 'vue'
|
||||||
import { storeToRefs } from 'pinia'
|
import { storeToRefs } from 'pinia'
|
||||||
import { useRoute, useRouter } from 'vue-router'
|
import { useRoute, useRouter } from 'vue-router'
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
@@ -7,20 +7,93 @@ import { AppButton } from '@/components'
|
|||||||
import { useContractStore } from '@/stores/modules/contract'
|
import { useContractStore } from '@/stores/modules/contract'
|
||||||
import ContractSignPanel from './cpns/ContractSignPanel.vue'
|
import ContractSignPanel from './cpns/ContractSignPanel.vue'
|
||||||
|
|
||||||
|
const SIGN_STATUS_POLL_INTERVAL = 3000
|
||||||
|
/** 连续失败达到该次数后停止轮询,避免后端异常时无意义地一直请求。 */
|
||||||
|
const SIGN_STATUS_MAX_FAILURES = 5
|
||||||
|
/** qr-init 带 @RepeatSubmit 防重,短时间内重复刷新会被后端拦截,这里做点击节流。 */
|
||||||
|
const SIGN_QR_REFRESH_COOLDOWN = 5000
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const contractStore = useContractStore()
|
const contractStore = useContractStore()
|
||||||
const { signExpires } = storeToRefs(contractStore)
|
const { signQrUrl, signExpires } = storeToRefs(contractStore)
|
||||||
|
|
||||||
const contractId = computed(() => String(route.params.id))
|
const contractId = computed(() => String(route.params.id))
|
||||||
|
|
||||||
function load(): void {
|
let lastQrInitAt = 0
|
||||||
void contractStore.fetchSignQr(contractId.value)
|
|
||||||
|
let pollTimer: ReturnType<typeof setInterval> | null = null
|
||||||
|
let pollFailures = 0
|
||||||
|
let polling = false
|
||||||
|
|
||||||
|
function stopPolling(): void {
|
||||||
|
if (pollTimer !== null) {
|
||||||
|
clearInterval(pollTimer)
|
||||||
|
pollTimer = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function checkSigned(): Promise<void> {
|
||||||
|
// 单次请求超过 3 秒时避免定时器叠加发起重复请求
|
||||||
|
if (polling) return
|
||||||
|
polling = true
|
||||||
|
try {
|
||||||
|
if (await contractStore.fetchSignQrStatus(contractId.value)) {
|
||||||
|
stopPolling()
|
||||||
|
ElMessage.success('合同签署完成')
|
||||||
|
void router.replace(`/contract/${contractId.value}`)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
pollFailures = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
pollFailures += 1
|
||||||
|
console.warn('[contract] 签署状态轮询失败', error)
|
||||||
|
if (pollFailures >= SIGN_STATUS_MAX_FAILURES) {
|
||||||
|
console.warn('[contract] 签署状态轮询连续失败,已停止轮询')
|
||||||
|
stopPolling()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
polling = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function startPolling(): void {
|
||||||
|
stopPolling()
|
||||||
|
pollFailures = 0
|
||||||
|
pollTimer = setInterval(() => {
|
||||||
|
void checkSigned()
|
||||||
|
}, SIGN_STATUS_POLL_INTERVAL)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function load(): Promise<void> {
|
||||||
|
stopPolling()
|
||||||
|
try {
|
||||||
|
lastQrInitAt = Date.now()
|
||||||
|
await contractStore.fetchSignQr(contractId.value)
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
console.warn('[contract] 签署二维码生成失败', error)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
startPolling()
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onRefresh(): Promise<void> {
|
async function onRefresh(): Promise<void> {
|
||||||
await contractStore.fetchSignQr(contractId.value, true)
|
// 后端 @RepeatSubmit 会拦截短时间内的重复提交,冷却期内直接忽略点击
|
||||||
ElMessage.success('二维码已刷新')
|
if (Date.now() - lastQrInitAt < SIGN_QR_REFRESH_COOLDOWN) return
|
||||||
|
try {
|
||||||
|
lastQrInitAt = Date.now()
|
||||||
|
await contractStore.fetchSignQr(contractId.value)
|
||||||
|
// 二维码过期时轮询已停止,刷新后需要重新开始
|
||||||
|
startPolling()
|
||||||
|
ElMessage.success('二维码已刷新')
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
console.warn('[contract] 签署二维码刷新失败', error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onBack(): void {
|
function onBack(): void {
|
||||||
@@ -29,7 +102,11 @@ function onBack(): void {
|
|||||||
|
|
||||||
watch(contractId, load)
|
watch(contractId, load)
|
||||||
|
|
||||||
onMounted(load)
|
onMounted(() => {
|
||||||
|
void load()
|
||||||
|
})
|
||||||
|
|
||||||
|
onBeforeUnmount(stopPolling)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -49,7 +126,9 @@ onMounted(load)
|
|||||||
|
|
||||||
<ContractSignPanel
|
<ContractSignPanel
|
||||||
:expires-in="signExpires"
|
:expires-in="signExpires"
|
||||||
|
:content="signQrUrl"
|
||||||
@refresh="onRefresh"
|
@refresh="onRefresh"
|
||||||
|
@expire="stopPolling"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div class="contract-sign__footer">
|
<div class="contract-sign__footer">
|
||||||
@@ -63,16 +142,18 @@ onMounted(load)
|
|||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
.contract-sign {
|
.contract-sign {
|
||||||
|
min-height: 100%;
|
||||||
padding-top: @spacing-lg;
|
padding-top: @spacing-lg;
|
||||||
padding-bottom: @spacing-xxl;
|
padding-bottom: @spacing-page-bottom;
|
||||||
|
background: @bg-color;
|
||||||
|
|
||||||
.container {
|
.container {
|
||||||
.flex(column, flex-start, stretch);
|
.flex(column, flex-start, stretch);
|
||||||
gap: 12px;
|
gap: @spacing-base;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__breadcrumb {
|
&__breadcrumb {
|
||||||
font-size: 11px;
|
font-size: @font-size-sm;
|
||||||
color: @text-color-disabled;
|
color: @text-color-disabled;
|
||||||
|
|
||||||
> span:last-child {
|
> span:last-child {
|
||||||
@@ -84,16 +165,16 @@ onMounted(load)
|
|||||||
&__footer {
|
&__footer {
|
||||||
.flex(row, flex-end);
|
.flex(row, flex-end);
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin-top: 19px;
|
margin-top: @spacing-base;
|
||||||
|
|
||||||
:deep(.app-button) {
|
:deep(.app-button) {
|
||||||
height: 30px;
|
height: 36px;
|
||||||
padding: 0 24px;
|
padding: 0 @spacing-lg;
|
||||||
border: none;
|
border: none;
|
||||||
border-radius: @radius-sm;
|
border-radius: @radius-round;
|
||||||
background: @primary-strong;
|
background: @primary-strong;
|
||||||
color: @white;
|
color: @white;
|
||||||
font-size: 11px;
|
font-size: @font-size-sm;
|
||||||
}
|
}
|
||||||
|
|
||||||
:deep(.app-button:hover) {
|
:deep(.app-button:hover) {
|
||||||
|
|||||||
@@ -49,35 +49,32 @@ const emit = defineEmits<{
|
|||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
.demand-bar {
|
.demand-bar {
|
||||||
// 设计稿里操作栏不是 fixed 底栏,而是卡片内的一行:
|
|
||||||
// el66 提示文字 x=240 y=2297,按钮 el36/34/32 x=1009/1288/1567 y=2280 w=232 h=63。
|
|
||||||
// 内容左边界 194,提示文字比它右移 46px;按钮右边界 1799 与输入框右边界齐平。
|
|
||||||
.flex(row, space-between, center);
|
.flex(row, space-between, center);
|
||||||
margin-top: 66px;
|
margin-top: @spacing-xxl;
|
||||||
|
gap: @spacing-lg;
|
||||||
|
|
||||||
&__tip {
|
&__tip {
|
||||||
// 提示文字左边界 240 = 内容左边界 194 + 46。
|
margin: 0;
|
||||||
margin: 0 0 0 114px;
|
font-size: @font-size-base;
|
||||||
font-size: 20px;
|
font-weight: 400;
|
||||||
font-weight: 500;
|
line-height: 1.5;
|
||||||
line-height: 29px;
|
color: @text-color-secondary;
|
||||||
color: @demand-heading;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&__actions {
|
&__actions {
|
||||||
.flex(row, flex-end, center);
|
.flex(row, flex-end, center);
|
||||||
gap: 47px;
|
gap: @spacing-base;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__btn {
|
&__btn {
|
||||||
width: 232px;
|
min-width: 120px;
|
||||||
height: 63px;
|
height: 40px;
|
||||||
padding: 0;
|
padding: 0 @spacing-lg;
|
||||||
border: none;
|
border: none;
|
||||||
border-radius: @radius-base;
|
border-radius: @radius-round;
|
||||||
background: @demand-secondary-bg;
|
background: @demand-secondary-bg;
|
||||||
font-size: 20px;
|
font-size: @font-size-base;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
color: @white;
|
color: @white;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|||||||
@@ -202,11 +202,10 @@ function onDownload(file: DemandAttachment): void {
|
|||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
.demand-attach {
|
.demand-attach {
|
||||||
.flex(column, flex-start, stretch);
|
.flex(column, flex-start, stretch);
|
||||||
// el59标签底 1405 → el54 顶 1419 = 14px;el54 底 1509 → el53 顶 1529 = 20px。
|
gap: @spacing-base;
|
||||||
gap: 14px;
|
|
||||||
|
|
||||||
&__list {
|
&__list {
|
||||||
gap: 20px;
|
gap: @spacing-sm;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__head {
|
&__head {
|
||||||
@@ -215,38 +214,38 @@ function onDownload(file: DemandAttachment): void {
|
|||||||
|
|
||||||
&__label {
|
&__label {
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
font-size: 20px;
|
font-size: @font-size-base;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
line-height: 29px;
|
line-height: 1.4;
|
||||||
color: @demand-heading;
|
color: @demand-heading;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__hint {
|
&__hint {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
margin-left: 20px;
|
margin-left: @spacing-base;
|
||||||
font-size: 16px;
|
font-size: @font-size-sm;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
line-height: 23px;
|
line-height: 1.5;
|
||||||
color: @demand-line;
|
color: @text-color-secondary;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设计稿 el54:x=194 y=1419 w=1605 h=90,整块浅灰上传区。
|
|
||||||
&__drop {
|
&__drop {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 90px;
|
height: 72px;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
border: none;
|
border: 1px dashed @border-color;
|
||||||
border-radius: @radius-sm;
|
border-radius: @radius-base;
|
||||||
background: @demand-upload-bg;
|
background: @bg-color-light;
|
||||||
font-family: inherit;
|
font-family: inherit;
|
||||||
font-size: 16px;
|
font-size: @font-size-base;
|
||||||
color: @demand-line;
|
color: @text-color-secondary;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: background 0.2s, color 0.2s;
|
transition: background 0.2s, color 0.2s, border-color 0.2s;
|
||||||
|
|
||||||
&:hover:not(:disabled) {
|
&:hover:not(:disabled) {
|
||||||
background: darken(@demand-upload-bg, 4%);
|
border-color: @demand-accent;
|
||||||
|
background: @filter-selected-bg;
|
||||||
color: @demand-accent;
|
color: @demand-accent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -262,35 +261,34 @@ function onDownload(file: DemandAttachment): void {
|
|||||||
|
|
||||||
&__list {
|
&__list {
|
||||||
.flex(column, flex-start, stretch);
|
.flex(column, flex-start, stretch);
|
||||||
gap: 20px;
|
gap: @spacing-sm;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
list-style: none;
|
list-style: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
// el53:x=194 y=1529 w=1605 h=90,空态占位块;有附件时列表项本身就是这个高度。
|
|
||||||
&__list:empty {
|
&__list:empty {
|
||||||
height: 90px;
|
height: 72px;
|
||||||
border-radius: @radius-sm;
|
border-radius: @radius-base;
|
||||||
background: @demand-upload-bg;
|
background: @bg-color-light;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__item {
|
&__item {
|
||||||
.flex(row, flex-start, center);
|
.flex(row, flex-start, center);
|
||||||
gap: @spacing-base;
|
gap: @spacing-base;
|
||||||
min-height: 90px;
|
min-height: 64px;
|
||||||
padding: 0 @spacing-lg;
|
padding: 0 @spacing-base;
|
||||||
border-radius: @radius-sm;
|
border-radius: @radius-base;
|
||||||
background: @demand-upload-bg;
|
background: @bg-color-light;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__badge {
|
&__badge {
|
||||||
.flex(row, center);
|
.flex(row, center);
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
width: 44px;
|
width: 36px;
|
||||||
height: 44px;
|
height: 36px;
|
||||||
border-radius: @radius-sm;
|
border-radius: @radius-sm;
|
||||||
font-size: 12px;
|
font-size: @font-size-xs;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
letter-spacing: 0.2px;
|
letter-spacing: 0.2px;
|
||||||
}
|
}
|
||||||
@@ -298,18 +296,18 @@ function onDownload(file: DemandAttachment): void {
|
|||||||
&__meta {
|
&__meta {
|
||||||
.flex(column, flex-start, stretch);
|
.flex(column, flex-start, stretch);
|
||||||
flex: 1;
|
flex: 1;
|
||||||
gap: 4px;
|
gap: 2px;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__name {
|
&__name {
|
||||||
font-size: 20px;
|
font-size: @font-size-base;
|
||||||
color: @demand-ink;
|
color: @demand-ink;
|
||||||
.ellipsis();
|
.ellipsis();
|
||||||
}
|
}
|
||||||
|
|
||||||
&__sub {
|
&__sub {
|
||||||
font-size: 16px;
|
font-size: @font-size-sm;
|
||||||
color: @text-color-secondary;
|
color: @text-color-secondary;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ const emit = defineEmits<{ 'update:modelValue': [value: string] }>()
|
|||||||
v-else
|
v-else
|
||||||
class="biz-types__icon"
|
class="biz-types__icon"
|
||||||
:name="option.icon"
|
:name="option.icon"
|
||||||
:size="68"
|
:size="48"
|
||||||
/>
|
/>
|
||||||
<span class="biz-types__name">{{ option.label }}</span>
|
<span class="biz-types__name">{{ option.label }}</span>
|
||||||
<span v-if="option.desc" class="biz-types__desc">{{ option.desc }}</span>
|
<span v-if="option.desc" class="biz-types__desc">{{ option.desc }}</span>
|
||||||
@@ -63,20 +63,17 @@ const emit = defineEmits<{ 'update:modelValue': [value: string] }>()
|
|||||||
&__grid {
|
&__grid {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(5, 1fr);
|
grid-template-columns: repeat(5, 1fr);
|
||||||
gap: 17px;
|
gap: @spacing-base;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__card {
|
&__card {
|
||||||
position: relative;
|
position: relative;
|
||||||
.flex(column, flex-start, flex-start);
|
.flex(column, flex-start, flex-start);
|
||||||
gap: 0;
|
gap: 0;
|
||||||
height: 206px;
|
min-height: 160px;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
// 设计稿 el21 "互联网软件" y=545 → 卡片 y=439 距顶 106px。
|
padding: @spacing-lg;
|
||||||
// 插画 el4 y=444 h=110 的框底 554 已越过 name 顶545,说明插画切片含
|
border: 1px solid @border-color;
|
||||||
// 透明边距;按文字层定位为准,插画框给68px 见方、左对齐即可。
|
|
||||||
padding: 4px 16px 0;
|
|
||||||
border: 1px solid @demand-line;
|
|
||||||
border-radius: @radius-base;
|
border-radius: @radius-base;
|
||||||
background: @white;
|
background: @white;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
@@ -88,18 +85,17 @@ const emit = defineEmits<{ 'update:modelValue': [value: string] }>()
|
|||||||
}
|
}
|
||||||
|
|
||||||
&.is-active {
|
&.is-active {
|
||||||
border-color: @demand-selected-bg;
|
border-color: @demand-accent;
|
||||||
background: @demand-selected-bg;
|
background: @filter-selected-bg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// el8 "圆形51" x=442 y=467 w=30 h=30:卡片 x=194 w=307,右内缩 29px、上移 22px。
|
|
||||||
&__check {
|
&__check {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 22px;
|
top: @spacing-base;
|
||||||
right: 19px;
|
right: @spacing-base;
|
||||||
width: 30px;
|
width: 20px;
|
||||||
height: 30px;
|
height: 20px;
|
||||||
border: 1px solid @demand-radio-idle;
|
border: 1px solid @demand-radio-idle;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
background: @white;
|
background: @white;
|
||||||
@@ -107,41 +103,42 @@ const emit = defineEmits<{ 'update:modelValue': [value: string] }>()
|
|||||||
}
|
}
|
||||||
|
|
||||||
&__card.is-active &__check {
|
&__card.is-active &__check {
|
||||||
border-color: @white;
|
border-color: @demand-accent;
|
||||||
background: @white;
|
background: @white;
|
||||||
box-shadow: inset 0 0 0 3px @demand-selected-bg;
|
box-shadow: inset 0 0 0 5px @demand-accent;
|
||||||
}
|
}
|
||||||
|
|
||||||
// el4 插画 x=233 / el3 x=542 / el1 x=875 / el2 x=1190:
|
|
||||||
// 四张卡的插画都在卡片左边线右侧 27~39px 处,不是水平居中,按左对齐处理。
|
|
||||||
&__icon {
|
&__icon {
|
||||||
margin-bottom: 33px;
|
margin-bottom: @spacing-base;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__logo {
|
&__logo {
|
||||||
width: 68px;
|
width: 48px;
|
||||||
height: 68px;
|
height: 48px;
|
||||||
margin-bottom: 33px;
|
margin-bottom: @spacing-base;
|
||||||
object-fit: contain;
|
object-fit: contain;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__name {
|
&__name {
|
||||||
font-size: 28px;
|
font-size: @font-size-lg;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
line-height: 45px;
|
line-height: 1.4;
|
||||||
color: @demand-ink;
|
color: @demand-ink;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__desc {
|
&__desc {
|
||||||
font-size: 16px;
|
font-size: @font-size-sm;
|
||||||
font-weight: 500;
|
font-weight: 400;
|
||||||
line-height: 23px;
|
line-height: 1.5;
|
||||||
color: @demand-ink;
|
color: @text-color-secondary;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__card.is-active &__name {
|
||||||
|
color: @demand-accent;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__card.is-active &__name,
|
|
||||||
&__card.is-active &__desc {
|
&__card.is-active &__desc {
|
||||||
color: @white;
|
color: @text-color-secondary;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -23,7 +23,9 @@ function onUserPhone(event: Event): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onRemark(event: Event): void {
|
function onRemark(event: Event): void {
|
||||||
emit('update', { supplementaryRemarks: (event.target as HTMLTextAreaElement).value })
|
emit('update', {
|
||||||
|
supplementaryRemarks: (event.target as HTMLTextAreaElement).value,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -31,7 +33,9 @@ function onRemark(event: Event): void {
|
|||||||
<div class="demand-confirm">
|
<div class="demand-confirm">
|
||||||
<div class="demand-confirm__row">
|
<div class="demand-confirm__row">
|
||||||
<div class="demand-confirm__field">
|
<div class="demand-confirm__field">
|
||||||
<label class="demand-confirm__label" for="demand-user-name">用户名称</label>
|
<label class="demand-confirm__label" for="demand-user-name"
|
||||||
|
>用户名称</label
|
||||||
|
>
|
||||||
<input
|
<input
|
||||||
id="demand-user-name"
|
id="demand-user-name"
|
||||||
class="demand-confirm__input"
|
class="demand-confirm__input"
|
||||||
@@ -40,10 +44,13 @@ function onRemark(event: Event): void {
|
|||||||
:value="props.demand.userName"
|
:value="props.demand.userName"
|
||||||
placeholder="请输入用户名称"
|
placeholder="请输入用户名称"
|
||||||
@input="onUserName"
|
@input="onUserName"
|
||||||
>
|
disabled
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="demand-confirm__field">
|
<div class="demand-confirm__field">
|
||||||
<label class="demand-confirm__label" for="demand-user-phone">用户手机号</label>
|
<label class="demand-confirm__label" for="demand-user-phone"
|
||||||
|
>用户手机号</label
|
||||||
|
>
|
||||||
<input
|
<input
|
||||||
id="demand-user-phone"
|
id="demand-user-phone"
|
||||||
class="demand-confirm__input"
|
class="demand-confirm__input"
|
||||||
@@ -52,7 +59,8 @@ function onRemark(event: Event): void {
|
|||||||
:value="props.demand.userPhone"
|
:value="props.demand.userPhone"
|
||||||
placeholder="请输入用户手机号"
|
placeholder="请输入用户手机号"
|
||||||
@input="onUserPhone"
|
@input="onUserPhone"
|
||||||
>
|
disabled
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -67,7 +75,9 @@ function onRemark(event: Event): void {
|
|||||||
placeholder="其他需要说明的事项…"
|
placeholder="其他需要说明的事项…"
|
||||||
@input="onRemark"
|
@input="onRemark"
|
||||||
/>
|
/>
|
||||||
<span class="demand-confirm__count">{{ remarkLength }}/{{ REMARK_MAX }}字</span>
|
<span class="demand-confirm__count"
|
||||||
|
>{{ remarkLength }}/{{ REMARK_MAX }}字</span
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -99,24 +109,30 @@ function onRemark(event: Event): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
&__label {
|
&__label {
|
||||||
font-size: 20px;
|
font-size: @font-size-base;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
line-height: 29px;
|
line-height: 1.4;
|
||||||
color: @demand-heading;
|
color: @demand-heading;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__input {
|
&__input {
|
||||||
.text-control();
|
.text-control();
|
||||||
height: 49px;
|
height: 40px;
|
||||||
padding: 0 18px;
|
padding: 0 @spacing-base;
|
||||||
border-color: @demand-line;
|
border-color: @border-color;
|
||||||
border-radius: @radius-sm;
|
border-radius: @radius-sm;
|
||||||
font-size: 20px;
|
font-size: @font-size-base;
|
||||||
color: @demand-ink;
|
color: @demand-ink;
|
||||||
|
|
||||||
&::placeholder {
|
&::placeholder {
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
color: @demand-line;
|
color: @text-color-disabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:disabled {
|
||||||
|
background-color: @input-bg;
|
||||||
|
color: @text-color-disabled;
|
||||||
|
cursor: not-allowed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,27 +143,27 @@ function onRemark(event: Event): void {
|
|||||||
|
|
||||||
&__textarea {
|
&__textarea {
|
||||||
.text-control();
|
.text-control();
|
||||||
height: 270px;
|
height: 160px;
|
||||||
min-height: 270px;
|
min-height: 160px;
|
||||||
padding: 10px 18px 24px;
|
padding: @spacing-base;
|
||||||
border-color: @demand-line;
|
border-color: @border-color;
|
||||||
border-radius: @radius-sm;
|
border-radius: @radius-sm;
|
||||||
font-size: 20px;
|
font-size: @font-size-base;
|
||||||
color: @demand-ink;
|
color: @demand-ink;
|
||||||
line-height: 29px;
|
line-height: 1.5;
|
||||||
resize: vertical;
|
resize: vertical;
|
||||||
|
|
||||||
&::placeholder {
|
&::placeholder {
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
color: @demand-line;
|
color: @text-color-disabled;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&__count {
|
&__count {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: @spacing-lg;
|
right: @spacing-base;
|
||||||
bottom: @spacing-sm;
|
bottom: @spacing-sm;
|
||||||
font-size: 16px;
|
font-size: @font-size-sm;
|
||||||
color: @text-color-disabled;
|
color: @text-color-disabled;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -201,9 +201,9 @@ function onBudgetManualBlur(event: Event): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
&__label {
|
&__label {
|
||||||
font-size: 20px;
|
font-size: @font-size-base;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
line-height: 29px;
|
line-height: 1.4;
|
||||||
color: @demand-heading;
|
color: @demand-heading;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,16 +214,16 @@ function onBudgetManualBlur(event: Event): void {
|
|||||||
|
|
||||||
&__input {
|
&__input {
|
||||||
.text-control();
|
.text-control();
|
||||||
height: 49px;
|
height: 40px;
|
||||||
padding: 0 18px;
|
padding: 0 @spacing-base;
|
||||||
border-color: @demand-line;
|
border-color: @border-color;
|
||||||
border-radius: @radius-sm;
|
border-radius: @radius-sm;
|
||||||
font-size: 20px;
|
font-size: @font-size-base;
|
||||||
color: @demand-ink;
|
color: @demand-ink;
|
||||||
|
|
||||||
&::placeholder {
|
&::placeholder {
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
color: @demand-line;
|
color: @text-color-disabled;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -234,47 +234,47 @@ function onBudgetManualBlur(event: Event): void {
|
|||||||
|
|
||||||
&__textarea {
|
&__textarea {
|
||||||
.text-control();
|
.text-control();
|
||||||
height: 270px;
|
height: 160px;
|
||||||
min-height: 270px;
|
min-height: 160px;
|
||||||
padding: 10px 18px 24px;
|
padding: @spacing-base;
|
||||||
border-color: @demand-line;
|
border-color: @border-color;
|
||||||
border-radius: @radius-sm;
|
border-radius: @radius-sm;
|
||||||
font-size: 20px;
|
font-size: @font-size-base;
|
||||||
color: @demand-ink;
|
color: @demand-ink;
|
||||||
line-height: 29px;
|
line-height: 1.5;
|
||||||
resize: vertical;
|
resize: vertical;
|
||||||
|
|
||||||
&::placeholder {
|
&::placeholder {
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
color: @demand-line;
|
color: @text-color-disabled;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&__count {
|
&__count {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: @spacing-lg;
|
right: @spacing-base;
|
||||||
bottom: @spacing-sm;
|
bottom: @spacing-sm;
|
||||||
font-size: 16px;
|
font-size: @font-size-sm;
|
||||||
color: @text-color-disabled;
|
color: @text-color-disabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__budgets {
|
&__budgets {
|
||||||
.flex(row, flex-start, stretch);
|
.flex(row, flex-start, stretch);
|
||||||
gap: 17px;
|
gap: @spacing-base;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__budget {
|
&__budget {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
height: 49px;
|
height: 40px;
|
||||||
padding: 0 @spacing-sm;
|
padding: 0 @spacing-sm;
|
||||||
border: 1px solid @demand-line;
|
border: 1px solid @border-color;
|
||||||
border-radius: @radius-sm;
|
border-radius: @radius-base;
|
||||||
background: @white;
|
background: @white;
|
||||||
font-size: 20px;
|
font-size: @font-size-base;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
font-family: inherit;
|
font-family: inherit;
|
||||||
color: @demand-line;
|
color: @text-color;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: all 0.2s;
|
transition: all 0.2s;
|
||||||
@@ -287,8 +287,8 @@ function onBudgetManualBlur(event: Event): void {
|
|||||||
|
|
||||||
&.is-active {
|
&.is-active {
|
||||||
border-color: @demand-accent;
|
border-color: @demand-accent;
|
||||||
background: @demand-selected-bg;
|
background: @filter-selected-bg;
|
||||||
color: @white;
|
color: @demand-accent;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -298,7 +298,7 @@ function onBudgetManualBlur(event: Event): void {
|
|||||||
|
|
||||||
&::placeholder {
|
&::placeholder {
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
color: @demand-line;
|
color: @text-color-disabled;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -120,7 +120,9 @@ onMounted(() => {
|
|||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
.demand-page {
|
.demand-page {
|
||||||
// 操作栏已收进卡片内(设计稿 el36 y=2280),不需要为fixed 底栏预留空白。
|
min-height: 100%;
|
||||||
|
padding-bottom: @spacing-page-bottom;
|
||||||
|
background: @bg-color;
|
||||||
|
|
||||||
&.is-loading .demand {
|
&.is-loading .demand {
|
||||||
opacity: 0.6;
|
opacity: 0.6;
|
||||||
@@ -128,65 +130,60 @@ onMounted(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
&__hero {
|
&__hero {
|
||||||
height: 179px;
|
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
padding-top: 32px;
|
padding: @spacing-lg 0;
|
||||||
background: @white;
|
background: @white;
|
||||||
|
border-bottom: 1px solid @border-color;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__hero-inner {
|
&__hero-inner {
|
||||||
// 设计稿 el82:标题左边界 112px(hero 白底 1920 宽,标题左起 112)。
|
padding-left: @spacing-xl;
|
||||||
padding-left: 112px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&__title {
|
&__title {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font-size: 36px;
|
font-size: @font-size-title;
|
||||||
font-weight: 700;
|
font-weight: 600;
|
||||||
line-height: 52px;
|
line-height: 1.3;
|
||||||
color: @demand-ink;
|
color: @demand-ink;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__subtitle {
|
&__subtitle {
|
||||||
margin: 15px 0 0;
|
margin: @spacing-sm 0 0;
|
||||||
font-size: 24px;
|
font-size: @font-size-base;
|
||||||
font-weight: 500;
|
font-weight: 400;
|
||||||
line-height: 35px;
|
line-height: 1.5;
|
||||||
color: @demand-subtitle;
|
color: @demand-subtitle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.demand {
|
.demand {
|
||||||
margin-top: 20px; // 271 − (72+179) = 20
|
margin-top: @spacing-lg;
|
||||||
// 设计稿 el83 卡片 x=70 w=1780;内容左边界 194(el68 输入框 x=194 w=1605),
|
padding: @spacing-xl;
|
||||||
// 右边界 1799。故左内边距 56、右内边距 51(不对称是设计稿本身如此)。
|
border-radius: @radius-base;
|
||||||
padding: 48px 51px 114px 56px;
|
|
||||||
background: @white;
|
background: @white;
|
||||||
|
|
||||||
&__heading {
|
&__heading {
|
||||||
// 设计稿三个 heading 的标签都比序号低 23px(el80 "01" y=319 →
|
.flex(row, flex-start, center);
|
||||||
// el79 "选择业务类型*" y=342),不是垂直居中,故用flex-start + margin-top。
|
gap: @spacing-sm;
|
||||||
.flex(row, flex-start, flex-start);
|
margin: 0 0 @spacing-lg;
|
||||||
gap: 4px;
|
padding-left: 0;
|
||||||
margin: 0 0 50px;
|
|
||||||
padding-left: 8px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&__index {
|
&__index {
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
font-size: 48px;
|
font-size: @font-size-title;
|
||||||
font-weight: 500;
|
font-weight: 600;
|
||||||
line-height: 70px;
|
line-height: 1.2;
|
||||||
font-variant-numeric: tabular-nums;
|
font-variant-numeric: tabular-nums;
|
||||||
color: @demand-accent;
|
color: @demand-accent;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__label {
|
&__label {
|
||||||
// 与序号的顶部落差 23px(el80 y=319 → el79 y=342)。
|
margin-top: 0;
|
||||||
margin-top: 23px;
|
font-size: @font-size-lg;
|
||||||
font-size: 28px;
|
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
line-height: 41px;
|
line-height: 1.4;
|
||||||
color: @demand-heading;
|
color: @demand-heading;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,28 +192,24 @@ onMounted(() => {
|
|||||||
color: @danger-color;
|
color: @danger-color;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 内容左边界 194:卡片 x=70 + padding-left 56 + 内容缩进 68。
|
|
||||||
&__heading + * {
|
&__heading + * {
|
||||||
margin-left: 68px;
|
margin-left: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// el29业务类型卡片底 645 → el78 "02" 顶 705 = 60px。
|
|
||||||
&__section + &__section {
|
&__section + &__section {
|
||||||
margin-top: 60px;
|
margin-top: @spacing-xxl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// el53 附件灰块底 1619 → el76 "03" 顶 1689 = 70px。
|
|
||||||
&__section + &__section:last-of-type {
|
&__section + &__section:last-of-type {
|
||||||
margin-top: 70px;
|
margin-top: @spacing-xxl;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__section + &__section &__heading {
|
&__section + &__section &__heading {
|
||||||
margin-bottom: 0;
|
margin-bottom: @spacing-lg;
|
||||||
}
|
}
|
||||||
|
|
||||||
// el78 "02" 底 775 → el70 "项目名称*" 顶 789 = 14px。
|
|
||||||
&__section + &__section &__heading + * {
|
&__section + &__section &__heading + * {
|
||||||
margin-top: 14px;
|
margin-top: 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
import { computed, onMounted, watch } from 'vue'
|
import { computed, onMounted, watch } from 'vue'
|
||||||
import { storeToRefs } from 'pinia'
|
import { storeToRefs } from 'pinia'
|
||||||
import { useRoute, useRouter } from 'vue-router'
|
import { useRoute, useRouter } from 'vue-router'
|
||||||
|
import { ElButton } from 'element-plus'
|
||||||
import { useFinanceStore } from '@/stores/modules/finance'
|
import { useFinanceStore } from '@/stores/modules/finance'
|
||||||
import type { Bill, BillStatus } from '@/types/business/finance'
|
import type { Bill, BillStatus } from '@/types/business/finance'
|
||||||
import { formatMoney } from '@/utils/format'
|
import { formatMoney } from '@/utils/format'
|
||||||
@@ -122,20 +123,20 @@ onMounted(() => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button
|
<el-button
|
||||||
v-if="card.status === '待支付'"
|
v-if="card.status === '待支付'"
|
||||||
class="bill-detail__cta"
|
class="bill-detail__cta"
|
||||||
@click="onPay(currentBill.id)"
|
@click="onPay(currentBill.id)"
|
||||||
>
|
>
|
||||||
立即支付
|
立即支付
|
||||||
</button>
|
</el-button>
|
||||||
<button
|
<el-button
|
||||||
v-else
|
v-else
|
||||||
class="bill-detail__cta"
|
class="bill-detail__cta"
|
||||||
@click="router.push('/finance/bills')"
|
@click="router.push('/finance/bills')"
|
||||||
>
|
>
|
||||||
返回
|
返回
|
||||||
</button>
|
</el-button>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -149,16 +150,17 @@ onMounted(() => {
|
|||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
.bill-detail {
|
.bill-detail {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding-bottom: 325px;
|
min-height: 100%;
|
||||||
background: @contract-page-bg;
|
padding-bottom: @spacing-page-bottom;
|
||||||
|
background: @bg-color;
|
||||||
|
|
||||||
&__breadcrumb {
|
&__breadcrumb {
|
||||||
.flex(row, flex-start, center);
|
.flex(row, flex-start, center);
|
||||||
height: 86px;
|
min-height: 48px;
|
||||||
padding-top: 34px;
|
padding-top: @spacing-lg;
|
||||||
font-size: 13px;
|
font-size: @font-size-sm;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
line-height: 17px;
|
line-height: 1.5;
|
||||||
color: @project-muted;
|
color: @project-muted;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
@@ -350,12 +352,12 @@ onMounted(() => {
|
|||||||
width: 90px;
|
width: 90px;
|
||||||
height: 32px;
|
height: 32px;
|
||||||
border: none;
|
border: none;
|
||||||
|
padding: 0;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
background: @primary-strong;
|
background: @primary-strong;
|
||||||
color: @white;
|
color: @white;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
padding-bottom: 6px;
|
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
transform: translateX(-50%);
|
transform: translateX(-50%);
|
||||||
transition: background 0.2s;
|
transition: background 0.2s;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { computed, onMounted, ref } from 'vue'
|
|||||||
import { storeToRefs } from 'pinia'
|
import { storeToRefs } from 'pinia'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
import { PaginationBar } from '@/components'
|
import { PaginationBar } from '@/components'
|
||||||
|
import { ElRadioGroup, ElRadioButton, ElInput, ElButton } from 'element-plus'
|
||||||
import { useFinanceStore } from '@/stores/modules/finance'
|
import { useFinanceStore } from '@/stores/modules/finance'
|
||||||
import type { BillStatus } from '@/types/business/finance'
|
import type { BillStatus } from '@/types/business/finance'
|
||||||
import BillSummaryBar from './cpns/BillSummaryBar.vue'
|
import BillSummaryBar from './cpns/BillSummaryBar.vue'
|
||||||
@@ -10,7 +11,7 @@ import BillTable from './cpns/BillTable.vue'
|
|||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const financeStore = useFinanceStore()
|
const financeStore = useFinanceStore()
|
||||||
const { query, list, total } = storeToRefs(financeStore)
|
const { query, list, total, billStats } = storeToRefs(financeStore)
|
||||||
|
|
||||||
const keyword = ref('')
|
const keyword = ref('')
|
||||||
const selectedIds = ref<string[]>([])
|
const selectedIds = ref<string[]>([])
|
||||||
@@ -23,9 +24,9 @@ const STATUS_TABS: Array<{ label: string; value: BillStatus | 'all' }> = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
const STATS = computed(() => [
|
const STATS = computed(() => [
|
||||||
{ label: '总笔数', value: String(total.value) },
|
{ label: '总笔数', value: String(billStats.value.totalCount) },
|
||||||
{ label: '总金额', value: String(list.value.reduce((sum, bill) => sum + bill.amount, 0)) },
|
{ label: '总金额', value: String(billStats.value.totalAmount) },
|
||||||
{ label: '待支付', value: String(list.value.filter((bill) => bill.status === '待支付').length) },
|
{ label: '待支付', value: String(billStats.value.pendingCount) },
|
||||||
])
|
])
|
||||||
|
|
||||||
function onTab(value: BillStatus | 'all'): void {
|
function onTab(value: BillStatus | 'all'): void {
|
||||||
@@ -35,6 +36,10 @@ function onTab(value: BillStatus | 'all'): void {
|
|||||||
void financeStore.search()
|
void financeStore.search()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onTabChange(val: string | number | boolean | undefined): void {
|
||||||
|
onTab(val as BillStatus | 'all')
|
||||||
|
}
|
||||||
|
|
||||||
function onSearch(): void {
|
function onSearch(): void {
|
||||||
financeStore.setQuery({ ...query.value, keyword: keyword.value })
|
financeStore.setQuery({ ...query.value, keyword: keyword.value })
|
||||||
void financeStore.search()
|
void financeStore.search()
|
||||||
@@ -87,31 +92,34 @@ onMounted(() => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="bills__toolbar">
|
<div class="bills__toolbar">
|
||||||
<div class="bills__tabs">
|
<el-radio-group
|
||||||
<button
|
class="bills__tabs"
|
||||||
|
:model-value="query.status"
|
||||||
|
@change="onTabChange"
|
||||||
|
>
|
||||||
|
<el-radio-button
|
||||||
v-for="tab in STATUS_TABS"
|
v-for="tab in STATUS_TABS"
|
||||||
:key="tab.value"
|
:key="tab.value"
|
||||||
class="bills__tab"
|
:value="tab.value"
|
||||||
:class="{ 'is-active': query.status === tab.value }"
|
|
||||||
@click="onTab(tab.value)"
|
|
||||||
>
|
>
|
||||||
{{ tab.label }}
|
{{ tab.label }}
|
||||||
</button>
|
</el-radio-button>
|
||||||
</div>
|
</el-radio-group>
|
||||||
|
|
||||||
<input
|
<el-input
|
||||||
v-model="keyword"
|
v-model="keyword"
|
||||||
class="bills__search"
|
class="bills__search"
|
||||||
placeholder="关键字搜索"
|
placeholder="关键字搜索"
|
||||||
|
clearable
|
||||||
@keyup.enter="onSearch"
|
@keyup.enter="onSearch"
|
||||||
>
|
/>
|
||||||
|
|
||||||
<button class="bills__btn bills__btn--reset" @click="onReset">
|
<el-button class="bills__btn bills__btn--reset" @click="onReset">
|
||||||
重置
|
重置
|
||||||
</button>
|
</el-button>
|
||||||
<button class="bills__btn bills__btn--primary" @click="onSearch">
|
<el-button class="bills__btn bills__btn--primary" @click="onSearch">
|
||||||
搜索
|
搜索
|
||||||
</button>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="bills__board">
|
<div class="bills__board">
|
||||||
@@ -146,8 +154,9 @@ onMounted(() => {
|
|||||||
align-items: stretch;
|
align-items: stretch;
|
||||||
gap: 0;
|
gap: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding-bottom: 14px;
|
min-height: 100%;
|
||||||
background: @contract-page-bg;
|
padding-bottom: @spacing-page-bottom;
|
||||||
|
background: @bg-color;
|
||||||
|
|
||||||
&__breadcrumb {
|
&__breadcrumb {
|
||||||
.flex(row, flex-start, center);
|
.flex(row, flex-start, center);
|
||||||
@@ -177,19 +186,21 @@ onMounted(() => {
|
|||||||
&__stats {
|
&__stats {
|
||||||
.flex(row, flex-start, flex-start);
|
.flex(row, flex-start, flex-start);
|
||||||
gap: 0;
|
gap: 0;
|
||||||
height: 106px;
|
min-height: 96px;
|
||||||
margin-top: 11px;
|
margin-top: @spacing-base;
|
||||||
border: 1px solid @finance-card-line;
|
border: none;
|
||||||
border-radius: @radius-base;
|
border-radius: @radius-base;
|
||||||
background: @white;
|
background: @white;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__stat {
|
&__stat {
|
||||||
.flex(column, flex-start, flex-start);
|
.flex(column, center, center);
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
gap: 6px;
|
gap: 6px;
|
||||||
width: 592.67px;
|
padding: 22px 0 0;
|
||||||
padding: 22px 0 0 269px;
|
text-align: center;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,82 +212,80 @@ onMounted(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
&__stat-value {
|
&__stat-value {
|
||||||
font-size: 26px;
|
font-size: @font-size-xl;
|
||||||
font-weight: 700;
|
font-weight: 600;
|
||||||
line-height: 35px;
|
line-height: 1.3;
|
||||||
color: @finance-ink;
|
color: @finance-ink;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__toolbar {
|
&__toolbar {
|
||||||
.flex(row, flex-start, center);
|
.flex(row, flex-start, center);
|
||||||
gap: 0;
|
gap: @spacing-base;
|
||||||
height: 71px;
|
min-height: 64px;
|
||||||
margin-top: 14px;
|
margin-top: @spacing-base;
|
||||||
padding: 0 0 0 22px;
|
padding: 0 @spacing-lg;
|
||||||
border: 1px solid @finance-card-line;
|
border: none;
|
||||||
border-radius: @radius-base;
|
border-radius: @radius-base;
|
||||||
background: @white;
|
background: @white;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__tabs {
|
&__tabs {
|
||||||
.flex(row, flex-start, center);
|
|
||||||
gap: 0;
|
|
||||||
width: 279px;
|
|
||||||
height: 34px;
|
|
||||||
border: 1px solid @border-color;
|
|
||||||
border-radius: 4px;
|
|
||||||
overflow: hidden;
|
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
box-sizing: border-box;
|
|
||||||
padding: 0 11.3px 0 9.2px;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__tab {
|
:deep(.el-radio-button__inner) {
|
||||||
flex: 1 1 0;
|
height: 34px;
|
||||||
height: 32px;
|
padding: 0 11.3px;
|
||||||
border: none;
|
border: 1px solid @border-color;
|
||||||
border-right: 1px solid @border-color;
|
border-radius: 4px;
|
||||||
border-radius: 0;
|
background: @white;
|
||||||
background: @white;
|
color: @finance-entry-text;
|
||||||
color: @finance-entry-text;
|
font-size: 12px;
|
||||||
font-size: 12px;
|
font-weight: 400;
|
||||||
font-weight: 400;
|
line-height: 32px;
|
||||||
transition: all 0.2s;
|
box-shadow: none;
|
||||||
|
|
||||||
&:last-child {
|
|
||||||
border-right: none;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&:hover {
|
:deep(.el-radio-button + .el-radio-button) {
|
||||||
|
margin-left: -1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.el-radio-button.is-active .el-radio-button__inner) {
|
||||||
|
position: relative;
|
||||||
|
z-index: 1;
|
||||||
|
border-color: @primary-strong;
|
||||||
|
background: @filter-selected-bg;
|
||||||
color: @primary-strong;
|
color: @primary-strong;
|
||||||
}
|
|
||||||
|
|
||||||
&.is-active {
|
|
||||||
border-right-color: @primary-strong;
|
|
||||||
background: @primary-strong;
|
|
||||||
color: @white;
|
|
||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
|
box-shadow: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&__search {
|
&__search {
|
||||||
width: 1300px;
|
flex: 0 1 360px;
|
||||||
height: 37px;
|
width: auto;
|
||||||
margin-left: 33px;
|
height: 36px;
|
||||||
padding: 0 16px;
|
margin-left: 0;
|
||||||
border: none;
|
flex-shrink: 1;
|
||||||
border-radius: 0;
|
min-width: 0;
|
||||||
background: @finance-field-bg;
|
|
||||||
color: @finance-entry-text;
|
|
||||||
font-size: 13px;
|
|
||||||
outline: none;
|
|
||||||
box-sizing: border-box;
|
|
||||||
flex-shrink: 0;
|
|
||||||
|
|
||||||
&::placeholder {
|
:deep(.el-input__wrapper) {
|
||||||
color: @contract-placeholder;
|
width: 100%;
|
||||||
|
height: 36px;
|
||||||
|
padding: 0 @spacing-base;
|
||||||
|
background: @finance-field-bg;
|
||||||
|
box-shadow: 0 0 0 1px @border-color inset;
|
||||||
|
border-radius: @radius-round;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.el-input__inner) {
|
||||||
|
color: @finance-entry-text;
|
||||||
|
font-size: 13px;
|
||||||
|
|
||||||
|
&::placeholder {
|
||||||
|
color: @contract-placeholder;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -284,7 +293,6 @@ onMounted(() => {
|
|||||||
height: 32px;
|
height: 32px;
|
||||||
border: none;
|
border: none;
|
||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
background: transparent;
|
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
@@ -293,9 +301,11 @@ onMounted(() => {
|
|||||||
width: 62.2px;
|
width: 62.2px;
|
||||||
margin-left: 15.4px;
|
margin-left: 15.4px;
|
||||||
color: @finance-entry-text;
|
color: @finance-entry-text;
|
||||||
|
background: transparent;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
color: @primary-strong;
|
color: @primary-strong;
|
||||||
|
background: transparent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -311,36 +321,41 @@ onMounted(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
&__board {
|
&__board {
|
||||||
margin-top: 14px;
|
margin-top: @spacing-base;
|
||||||
border: 1px solid @finance-card-line;
|
border: none;
|
||||||
border-radius: @radius-base;
|
border-radius: @radius-base;
|
||||||
background: @white;
|
background: @white;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
padding: @spacing-base @spacing-lg @spacing-lg;
|
||||||
}
|
}
|
||||||
|
|
||||||
:deep(.pagination) {
|
:deep(.pagination) {
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
gap: 3.7px;
|
gap: @spacing-xs;
|
||||||
padding: 8px 26px 30px 0;
|
padding: @spacing-base 0 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
:deep(.pagination__btn) {
|
:deep(.pagination__btn) {
|
||||||
min-width: 0;
|
min-width: 28px;
|
||||||
height: 16px;
|
height: 28px;
|
||||||
padding: 0 3px;
|
padding: 0 6px;
|
||||||
border: none;
|
border: 1px solid @border-color;
|
||||||
border-radius: 0;
|
border-radius: @radius-sm;
|
||||||
background: transparent;
|
background: @white;
|
||||||
color: @finance-muted-text;
|
color: @text-color;
|
||||||
font-size: 12px;
|
font-size: @font-size-sm;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
|
|
||||||
&.is-active {
|
&.is-active {
|
||||||
min-width: 21.45px;
|
min-width: 28px;
|
||||||
|
border-color: @primary-strong;
|
||||||
|
background: @primary-light;
|
||||||
|
color: @primary-strong;
|
||||||
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
&:hover:not(:disabled):not(.is-ellipsis) {
|
&:hover:not(:disabled):not(.is-ellipsis) {
|
||||||
border: none;
|
border-color: @primary-strong;
|
||||||
color: @primary-strong;
|
color: @primary-strong;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,25 +2,21 @@
|
|||||||
import { computed, onBeforeUnmount, ref, watch } from 'vue'
|
import { computed, onBeforeUnmount, ref, watch } from 'vue'
|
||||||
import { storeToRefs } from 'pinia'
|
import { storeToRefs } from 'pinia'
|
||||||
import { useRoute, useRouter } from 'vue-router'
|
import { useRoute, useRouter } from 'vue-router'
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage, ElButton } from 'element-plus'
|
||||||
|
import { usePayPoll } from '@/composables/usePayPoll'
|
||||||
import { useFinanceStore } from '@/stores/modules/finance'
|
import { useFinanceStore } from '@/stores/modules/finance'
|
||||||
import type { PayMethod } from '@/types/business/finance'
|
import type { PayMethod } from '@/types/business/finance'
|
||||||
import { createMerchantOrderNo, PAY_METHODS } from '@/utils/payMeta'
|
import { PAY_METHODS } from '@/utils/payMeta'
|
||||||
import { formatMoney } from '@/utils/format'
|
import { formatMoney } from '@/utils/format'
|
||||||
import CheckoutBillCard from './cpns/CheckoutBillCard.vue'
|
import CheckoutBillCard from './cpns/CheckoutBillCard.vue'
|
||||||
import PayMethodList from './cpns/PayMethodList.vue'
|
import PayMethodList from './cpns/PayMethodList.vue'
|
||||||
import WechatQrDialog from './cpns/WechatQrDialog.vue'
|
import PayQrDialog from './cpns/PayQrDialog.vue'
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const financeStore = useFinanceStore()
|
const financeStore = useFinanceStore()
|
||||||
const { checkoutBills, checkoutLoading, payOrder } = storeToRefs(financeStore)
|
const { checkoutBills, checkoutLoading, payOrder } = storeToRefs(financeStore)
|
||||||
|
|
||||||
const requirementId = computed(() => {
|
|
||||||
const raw = route.query.requirementId
|
|
||||||
return String(Array.isArray(raw) ? raw[0] : (raw ?? '')).trim()
|
|
||||||
})
|
|
||||||
|
|
||||||
const planIds = computed(() => {
|
const planIds = computed(() => {
|
||||||
const raw = route.query.ids
|
const raw = route.query.ids
|
||||||
const text = Array.isArray(raw) ? raw.join(',') : String(raw ?? '')
|
const text = Array.isArray(raw) ? raw.join(',') : String(raw ?? '')
|
||||||
@@ -29,10 +25,12 @@ const planIds = computed(() => {
|
|||||||
|
|
||||||
const billIds = computed(() => checkoutBills.value.map((bill) => bill.id))
|
const billIds = computed(() => checkoutBills.value.map((bill) => bill.id))
|
||||||
|
|
||||||
const method = ref<PayMethod>('wechat')
|
const method = ref<PayMethod>('alipay')
|
||||||
const submitting = ref(false)
|
const submitting = ref(false)
|
||||||
const qrVisible = ref(false)
|
const qrVisible = ref(false)
|
||||||
|
|
||||||
|
const { start: startPoll, stop: stopPoll, check } = usePayPoll(onPaySuccess)
|
||||||
|
|
||||||
const totalAmount = computed(() =>
|
const totalAmount = computed(() =>
|
||||||
checkoutBills.value.reduce((sum, bill) => sum + Number(bill.amount || 0), 0),
|
checkoutBills.value.reduce((sum, bill) => sum + Number(bill.amount || 0), 0),
|
||||||
)
|
)
|
||||||
@@ -44,55 +42,28 @@ const methodLabel = computed(
|
|||||||
const canPay = computed(() => checkoutBills.value.length > 0 && !submitting.value)
|
const canPay = computed(() => checkoutBills.value.length > 0 && !submitting.value)
|
||||||
|
|
||||||
async function load(): Promise<void> {
|
async function load(): Promise<void> {
|
||||||
await financeStore.loadCheckout(requirementId.value, planIds.value)
|
await financeStore.loadCheckout(planIds.value)
|
||||||
}
|
|
||||||
|
|
||||||
function openAlipay(body: string): void {
|
|
||||||
if (/^\s*https?:\/\//i.test(body)) {
|
|
||||||
window.open(body, '_blank', 'noopener')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const holder = document.createElement('div')
|
|
||||||
holder.style.display = 'none'
|
|
||||||
holder.innerHTML = body
|
|
||||||
document.body.appendChild(holder)
|
|
||||||
|
|
||||||
const form = holder.querySelector('form')
|
|
||||||
if (form) {
|
|
||||||
form.submit()
|
|
||||||
window.setTimeout(() => holder.remove(), 0)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
holder.remove()
|
|
||||||
ElMessage.error('支付宝下单返回内容无法识别')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onConfirm(): Promise<void> {
|
async function onConfirm(): Promise<void> {
|
||||||
if (!canPay.value) return
|
if (!canPay.value) return
|
||||||
submitting.value = true
|
submitting.value = true
|
||||||
try {
|
try {
|
||||||
const orderNo = createMerchantOrderNo()
|
await financeStore.payOrders(billIds.value, method.value)
|
||||||
|
|
||||||
if (method.value === 'wechat') {
|
const qrCode = payOrder.value?.qrCode
|
||||||
await financeStore.payByWechatNative(orderNo, totalAmount.value, billIds.value)
|
if (!qrCode) {
|
||||||
const codeUrl = payOrder.value?.codeUrl
|
ElMessage.error('支付宝下单失败:未返回二维码内容')
|
||||||
if (!codeUrl) {
|
return
|
||||||
ElMessage.error('微信下单失败:未返回二维码内容')
|
}
|
||||||
return
|
const outTradeNo = financeStore.payOutTradeNo
|
||||||
}
|
if (!outTradeNo) {
|
||||||
qrVisible.value = true
|
ElMessage.error('未获取到支付单号,请重新发起支付')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
await financeStore.payByAlipayPage(orderNo, totalAmount.value, billIds.value)
|
qrVisible.value = true
|
||||||
const body = payOrder.value?.formBody
|
startPoll(outTradeNo)
|
||||||
if (!body) {
|
|
||||||
ElMessage.error('支付宝下单失败:未返回跳转地址')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
openAlipay(body)
|
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
}
|
}
|
||||||
@@ -101,21 +72,22 @@ async function onConfirm(): Promise<void> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onRefreshQr(): Promise<void> {
|
async function onCheckPaid(): Promise<void> {
|
||||||
try {
|
const outTradeNo = financeStore.payOutTradeNo
|
||||||
await financeStore.payByWechatNative(createMerchantOrderNo(), totalAmount.value, billIds.value)
|
if (!outTradeNo) return
|
||||||
}
|
const done = await check(outTradeNo)
|
||||||
catch {
|
if (!done && qrVisible.value) {
|
||||||
|
ElMessage.warning('支付结果确认中,请稍后再试')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onPaid(): void {
|
function onPaySuccess(outTradeNo: string): void {
|
||||||
qrVisible.value = false
|
qrVisible.value = false
|
||||||
const first = checkoutBills.value[0]
|
const first = checkoutBills.value[0]
|
||||||
if (!first) return
|
if (!first) return
|
||||||
void router.push({
|
void router.push({
|
||||||
path: `/finance/bills/${first.id}/pay/result`,
|
path: `/finance/bills/${first.id}/pay/result`,
|
||||||
query: { requirementId: requirementId.value },
|
query: { outTradeNo, ids: billIds.value.join(',') },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,11 +95,16 @@ function goBack(): void {
|
|||||||
void router.push('/finance/bills')
|
void router.push('/finance/bills')
|
||||||
}
|
}
|
||||||
|
|
||||||
watch([requirementId, planIds], () => {
|
watch(planIds, () => {
|
||||||
void load()
|
void load()
|
||||||
}, { immediate: true })
|
}, { immediate: true })
|
||||||
|
|
||||||
|
watch(qrVisible, (visible) => {
|
||||||
|
if (!visible) stopPoll()
|
||||||
|
})
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
|
stopPoll()
|
||||||
financeStore.clearPayOrder()
|
financeStore.clearPayOrder()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
@@ -172,13 +149,13 @@ onBeforeUnmount(() => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button
|
<el-button
|
||||||
class="checkout__cta"
|
class="checkout__cta"
|
||||||
:disabled="!canPay"
|
:disabled="!canPay"
|
||||||
@click="onConfirm"
|
@click="onConfirm"
|
||||||
>
|
>
|
||||||
{{ submitting ? '处理中…' : '确认支付' }}
|
{{ submitting ? '处理中…' : '确认支付' }}
|
||||||
</button>
|
</el-button>
|
||||||
|
|
||||||
<p class="checkout__summary-tip">
|
<p class="checkout__summary-tip">
|
||||||
支付完成后订单状态将自动更新
|
支付完成后订单状态将自动更新
|
||||||
@@ -191,17 +168,16 @@ onBeforeUnmount(() => {
|
|||||||
<p class="checkout__empty-text">
|
<p class="checkout__empty-text">
|
||||||
未找到待支付账单,请返回账单明细重新选择
|
未找到待支付账单,请返回账单明细重新选择
|
||||||
</p>
|
</p>
|
||||||
<button class="checkout__empty-btn" @click="goBack">
|
<el-button class="checkout__empty-btn" @click="goBack">
|
||||||
返回账单明细
|
返回账单明细
|
||||||
</button>
|
</el-button>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<WechatQrDialog
|
<PayQrDialog
|
||||||
v-model:visible="qrVisible"
|
v-model:visible="qrVisible"
|
||||||
:content="payOrder?.codeUrl ?? ''"
|
:content="payOrder?.qrCode ?? ''"
|
||||||
:amount="totalAmount"
|
:amount="totalAmount"
|
||||||
@refresh="onRefreshQr"
|
@check="onCheckPaid"
|
||||||
@paid="onPaid"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -210,11 +186,13 @@ onBeforeUnmount(() => {
|
|||||||
.checkout {
|
.checkout {
|
||||||
.flex(column, flex-start, stretch);
|
.flex(column, flex-start, stretch);
|
||||||
gap: @spacing-base;
|
gap: @spacing-base;
|
||||||
|
min-height: 100%;
|
||||||
padding-top: @spacing-lg;
|
padding-top: @spacing-lg;
|
||||||
padding-bottom: @spacing-xxl;
|
padding-bottom: @spacing-page-bottom;
|
||||||
|
background: @bg-color;
|
||||||
|
|
||||||
&__breadcrumb {
|
&__breadcrumb {
|
||||||
font-size: @font-size-base;
|
font-size: @font-size-sm;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__layout {
|
&__layout {
|
||||||
@@ -283,6 +261,8 @@ onBeforeUnmount(() => {
|
|||||||
&__cta {
|
&__cta {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 44px;
|
height: 44px;
|
||||||
|
border: none;
|
||||||
|
padding: 0;
|
||||||
border-radius: @radius-round;
|
border-radius: @radius-round;
|
||||||
background: @checkout-cta;
|
background: @checkout-cta;
|
||||||
color: @white;
|
color: @white;
|
||||||
@@ -329,6 +309,12 @@ onBeforeUnmount(() => {
|
|||||||
font-size: @font-size-base;
|
font-size: @font-size-base;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:deep(.checkout__empty-btn.el-button) {
|
||||||
|
border: 1px solid @checkout-cta;
|
||||||
|
background: @checkout-card;
|
||||||
|
color: @checkout-cta;
|
||||||
|
}
|
||||||
|
|
||||||
@media (max-width: 992px) {
|
@media (max-width: 992px) {
|
||||||
&__layout {
|
&__layout {
|
||||||
grid-template-columns: minmax(0, 1fr);
|
grid-template-columns: minmax(0, 1fr);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed } from 'vue'
|
import { computed } from 'vue'
|
||||||
|
import { ElCheckbox, ElButton } from 'element-plus'
|
||||||
import type { Bill } from '@/types/business/finance'
|
import type { Bill } from '@/types/business/finance'
|
||||||
import { formatMoney } from '@/utils/format'
|
import { formatMoney } from '@/utils/format'
|
||||||
|
|
||||||
@@ -30,12 +31,11 @@ function onBatchPay(): void {
|
|||||||
<div class="bill-summary">
|
<div class="bill-summary">
|
||||||
<div class="bill-summary__inner">
|
<div class="bill-summary__inner">
|
||||||
<div class="bill-summary__left">
|
<div class="bill-summary__left">
|
||||||
<input
|
<el-checkbox
|
||||||
class="bill-summary__check"
|
class="bill-summary__check"
|
||||||
type="checkbox"
|
:model-value="canPay"
|
||||||
:checked="canPay"
|
|
||||||
@change="onBatchPay"
|
@change="onBatchPay"
|
||||||
>
|
/>
|
||||||
<span class="bill-summary__text">已选择</span>
|
<span class="bill-summary__text">已选择</span>
|
||||||
<span class="bill-summary__count">{{ selectedBills.length }}</span>
|
<span class="bill-summary__count">{{ selectedBills.length }}</span>
|
||||||
<span class="bill-summary__text">笔订单</span>
|
<span class="bill-summary__text">笔订单</span>
|
||||||
@@ -44,9 +44,9 @@ function onBatchPay(): void {
|
|||||||
<div class="bill-summary__right">
|
<div class="bill-summary__right">
|
||||||
<span class="bill-summary__text">合计:</span>
|
<span class="bill-summary__text">合计:</span>
|
||||||
<span class="bill-summary__amount">¥ {{ formatMoney(selectedAmount, 0) }}</span>
|
<span class="bill-summary__amount">¥ {{ formatMoney(selectedAmount, 0) }}</span>
|
||||||
<button class="bill-summary__cta" :disabled="!canPay" @click="onBatchPay">
|
<el-button class="bill-summary__cta" :disabled="!canPay" @click="onBatchPay">
|
||||||
立即支付
|
立即支付
|
||||||
</button>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -77,11 +77,15 @@ function onBatchPay(): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
&__check {
|
&__check {
|
||||||
width: 15px;
|
|
||||||
height: 15px;
|
height: 15px;
|
||||||
margin: 0 12.25px 0 0;
|
margin: 0 12.25px 0 0;
|
||||||
accent-color: @primary-strong;
|
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
|
|
||||||
|
:deep(.el-checkbox__inner) {
|
||||||
|
width: 15px;
|
||||||
|
height: 15px;
|
||||||
|
border-color: @border-color;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&__text {
|
&__text {
|
||||||
@@ -118,6 +122,7 @@ function onBatchPay(): void {
|
|||||||
width: 84px;
|
width: 84px;
|
||||||
height: 40px;
|
height: 40px;
|
||||||
border: none;
|
border: none;
|
||||||
|
padding: 0;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
background: @finance-summary-cta;
|
background: @finance-summary-cta;
|
||||||
color: @white;
|
color: @white;
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, ref, watch } from 'vue'
|
import { ref, watch } from 'vue'
|
||||||
|
import { ElTable, ElTableColumn } from 'element-plus'
|
||||||
|
import type { TableInstance } from 'element-plus'
|
||||||
import type { Bill } from '@/types/business/finance'
|
import type { Bill } from '@/types/business/finance'
|
||||||
import { formatMoney } from '@/utils/format'
|
import { formatMoney } from '@/utils/format'
|
||||||
|
|
||||||
@@ -16,223 +18,162 @@ const emit = defineEmits<{
|
|||||||
'update:selection': [ids: string[]]
|
'update:selection': [ids: string[]]
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const selection = ref<Set<string>>(new Set(props.selectedIds))
|
const tableRef = ref<TableInstance>()
|
||||||
|
|
||||||
|
function onSelectionChange(rows: Bill[]): void {
|
||||||
|
emit('update:selection', rows.map((row) => row.id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// 外部清空选中(如重置查询)时同步清空 el-table 选择态
|
||||||
watch(
|
watch(
|
||||||
() => props.selectedIds,
|
() => props.selectedIds,
|
||||||
(ids) => {
|
(ids) => {
|
||||||
selection.value = new Set(ids)
|
if (ids.length === 0 && tableRef.value) tableRef.value.clearSelection()
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
const allSelected = computed(
|
|
||||||
() => props.bills.length > 0 && props.bills.every((bill) => selection.value.has(bill.id)),
|
|
||||||
)
|
|
||||||
|
|
||||||
const someSelected = computed(
|
|
||||||
() => props.bills.some((bill) => selection.value.has(bill.id)) && !allSelected.value,
|
|
||||||
)
|
|
||||||
|
|
||||||
function toggle(id: string): void {
|
|
||||||
if (selection.value.has(id)) selection.value.delete(id)
|
|
||||||
else selection.value.add(id)
|
|
||||||
emit('update:selection', [...selection.value])
|
|
||||||
}
|
|
||||||
|
|
||||||
function toggleAll(): void {
|
|
||||||
if (allSelected.value) {
|
|
||||||
for (const bill of props.bills) selection.value.delete(bill.id)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
for (const bill of props.bills) selection.value.add(bill.id)
|
|
||||||
}
|
|
||||||
emit('update:selection', [...selection.value])
|
|
||||||
}
|
|
||||||
|
|
||||||
const COLUMNS = [
|
|
||||||
{ key: 'index', label: '序号', className: 'bill-table__col--index' },
|
|
||||||
{ key: 'planName', label: '账单名称', className: 'bill-table__col--name' },
|
|
||||||
{ key: 'billNo', label: '账单号', className: 'bill-table__col--no' },
|
|
||||||
{ key: 'tradeNo', label: '交易流水号', className: 'bill-table__col--trade' },
|
|
||||||
{ key: 'projectName', label: '项目名称', className: 'bill-table__col--project' },
|
|
||||||
{ key: 'amount', label: '订单金额', className: 'bill-table__col--amount' },
|
|
||||||
{ key: 'status', label: '状态', className: 'bill-table__col--status' },
|
|
||||||
{ key: 'ops', label: '操作', className: 'bill-table__col--ops' },
|
|
||||||
] as const
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<table class="bill-table">
|
<el-table
|
||||||
<colgroup>
|
ref="tableRef"
|
||||||
<col class="bill-table__col--check">
|
class="bill-table"
|
||||||
<col
|
:data="bills"
|
||||||
v-for="column in COLUMNS"
|
row-key="id"
|
||||||
:key="column.key"
|
@selection-change="onSelectionChange"
|
||||||
:class="column.className"
|
>
|
||||||
>
|
<el-table-column
|
||||||
</colgroup>
|
type="selection"
|
||||||
<thead>
|
width="51"
|
||||||
<tr>
|
/>
|
||||||
<th class="bill-table__cell bill-table__cell--check">
|
<el-table-column
|
||||||
<input
|
type="index"
|
||||||
type="checkbox"
|
label="序号"
|
||||||
:checked="allSelected"
|
width="235"
|
||||||
:indeterminate="someSelected"
|
/>
|
||||||
@change="toggleAll"
|
<el-table-column
|
||||||
|
prop="planName"
|
||||||
|
label="账单名称"
|
||||||
|
width="310"
|
||||||
|
show-overflow-tooltip
|
||||||
|
/>
|
||||||
|
<el-table-column
|
||||||
|
prop="billNo"
|
||||||
|
label="账单号"
|
||||||
|
width="148"
|
||||||
|
show-overflow-tooltip
|
||||||
|
/>
|
||||||
|
<el-table-column
|
||||||
|
prop="tradeNo"
|
||||||
|
label="交易流水号"
|
||||||
|
width="394"
|
||||||
|
show-overflow-tooltip
|
||||||
|
/>
|
||||||
|
<el-table-column
|
||||||
|
prop="projectName"
|
||||||
|
label="项目名称"
|
||||||
|
width="339"
|
||||||
|
show-overflow-tooltip
|
||||||
|
/>
|
||||||
|
<el-table-column
|
||||||
|
label="订单金额"
|
||||||
|
width="97"
|
||||||
|
>
|
||||||
|
<template #default="{ row }">
|
||||||
|
{{ formatMoney((row as Bill).amount, 0) }}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column
|
||||||
|
label="状态"
|
||||||
|
width="95"
|
||||||
|
>
|
||||||
|
<template #default="{ row }">
|
||||||
|
{{ (row as Bill).status }}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column
|
||||||
|
label="操作"
|
||||||
|
width="110"
|
||||||
|
fixed="right"
|
||||||
|
>
|
||||||
|
<template #default="{ row }">
|
||||||
|
<span class="bill-table__ops">
|
||||||
|
<el-button
|
||||||
|
v-if="(row as Bill).status === '待支付'"
|
||||||
|
link
|
||||||
|
type="primary"
|
||||||
|
class="bill-table__link"
|
||||||
|
@click="emit('pay', (row as Bill).id)"
|
||||||
>
|
>
|
||||||
</th>
|
去支付
|
||||||
<th
|
</el-button>
|
||||||
v-for="column in COLUMNS"
|
<el-button
|
||||||
:key="column.key"
|
link
|
||||||
class="bill-table__cell"
|
type="primary"
|
||||||
>
|
class="bill-table__link"
|
||||||
{{ column.label }}
|
@click="emit('view', (row as Bill).id)"
|
||||||
</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr v-for="(bill, index) in bills" :key="bill.id">
|
|
||||||
<td class="bill-table__cell bill-table__cell--check">
|
|
||||||
<input
|
|
||||||
type="checkbox"
|
|
||||||
:checked="selection.has(bill.id)"
|
|
||||||
@change="toggle(bill.id)"
|
|
||||||
>
|
>
|
||||||
</td>
|
详情
|
||||||
<td class="bill-table__cell">
|
</el-button>
|
||||||
{{ index + 1 }}
|
</span>
|
||||||
</td>
|
</template>
|
||||||
<td class="bill-table__cell">
|
</el-table-column>
|
||||||
{{ bill.planName }}
|
|
||||||
</td>
|
<template #empty>
|
||||||
<td class="bill-table__cell">
|
<span class="bill-table__empty">暂无账单数据</span>
|
||||||
{{ bill.billNo }}
|
</template>
|
||||||
</td>
|
</el-table>
|
||||||
<td class="bill-table__cell">
|
|
||||||
{{ bill.tradeNo ?? '—' }}
|
|
||||||
</td>
|
|
||||||
<td class="bill-table__cell">
|
|
||||||
{{ bill.projectName }}
|
|
||||||
</td>
|
|
||||||
<td class="bill-table__cell">
|
|
||||||
{{ formatMoney(bill.amount, 0) }}
|
|
||||||
</td>
|
|
||||||
<td class="bill-table__cell">
|
|
||||||
{{ bill.status }}
|
|
||||||
</td>
|
|
||||||
<td class="bill-table__cell bill-table__cell--ops">
|
|
||||||
<span class="bill-table__ops">
|
|
||||||
<button
|
|
||||||
v-if="bill.status === '待支付'"
|
|
||||||
class="bill-table__link"
|
|
||||||
@click="emit('pay', bill.id)"
|
|
||||||
>
|
|
||||||
去支付
|
|
||||||
</button>
|
|
||||||
<button class="bill-table__link" @click="emit('view', bill.id)">
|
|
||||||
详情
|
|
||||||
</button>
|
|
||||||
</span>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr v-if="bills.length === 0">
|
|
||||||
<td colspan="9" class="bill-table__empty">
|
|
||||||
暂无账单数据
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
.bill-table {
|
.bill-table {
|
||||||
width: 1765px;
|
width: 100%;
|
||||||
margin: 6.5px 0 0 14.5px;
|
margin: @spacing-sm 0 0;
|
||||||
border-collapse: collapse;
|
font-size: @font-size-sm;
|
||||||
table-layout: fixed;
|
|
||||||
font-size: 12px;
|
|
||||||
color: @finance-entry-text;
|
color: @finance-entry-text;
|
||||||
|
|
||||||
&__col--check { width: 51px; }
|
:deep(.el-table) {
|
||||||
&__col--index { width: 235.4px; }
|
--el-table-border-color: @border-color;
|
||||||
&__col--name { width: 310.2px; }
|
|
||||||
&__col--no { width: 148px; }
|
|
||||||
&__col--trade { width: 394.1px; }
|
|
||||||
&__col--project { width: 339.4px; }
|
|
||||||
&__col--amount { width: 97px; }
|
|
||||||
&__col--status { width: 95px; }
|
|
||||||
&__col--ops { width: 95.5px; }
|
|
||||||
|
|
||||||
&__cell {
|
&::before {
|
||||||
height: 43.77px;
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.el-table__header-wrapper th.el-table__cell) {
|
||||||
|
height: 44px;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
border-bottom: 1px solid @project-divider;
|
|
||||||
text-align: left;
|
|
||||||
vertical-align: middle;
|
|
||||||
white-space: nowrap;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
box-sizing: border-box;
|
|
||||||
|
|
||||||
&:not(&--check):not(&--ops) {
|
|
||||||
padding-left: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
&--check {
|
|
||||||
padding-left: 43.5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
&--ops {
|
|
||||||
padding-right: 22px;
|
|
||||||
text-align: right;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@col-pad-1: 43.5px;
|
|
||||||
@col-pad-2: 149.9px;
|
|
||||||
@col-pad-3: 8px;
|
|
||||||
@col-pad-4: 17px;
|
|
||||||
@col-pad-5: 5px;
|
|
||||||
@col-pad-6: 14.6px;
|
|
||||||
@col-pad-7: 4.6px;
|
|
||||||
@col-pad-8: 6px;
|
|
||||||
|
|
||||||
thead &__cell,
|
|
||||||
tbody &__cell {
|
|
||||||
&:nth-child(1) { padding-left: @col-pad-1; }
|
|
||||||
&:nth-child(2) { padding-left: @col-pad-2; }
|
|
||||||
&:nth-child(3) { padding-left: @col-pad-3; }
|
|
||||||
&:nth-child(4) { padding-left: @col-pad-4; }
|
|
||||||
&:nth-child(5) { padding-left: @col-pad-5; }
|
|
||||||
&:nth-child(6) { padding-left: @col-pad-6; }
|
|
||||||
&:nth-child(7) { padding-left: @col-pad-7; }
|
|
||||||
&:nth-child(8) { padding-left: @col-pad-8; }
|
|
||||||
&:nth-child(9) { padding-left: 0; padding-right: 10px; }
|
|
||||||
}
|
|
||||||
|
|
||||||
thead &__cell {
|
|
||||||
height: 41.77px;
|
|
||||||
background: @finance-table-head-bg;
|
background: @finance-table-head-bg;
|
||||||
border-right: 1px solid @project-divider;
|
border-right: none;
|
||||||
color: @finance-entry-text;
|
border-bottom: 1px solid @border-color;
|
||||||
font-size: 12px;
|
color: @text-color-secondary;
|
||||||
font-weight: 600;
|
font-size: @font-size-sm;
|
||||||
|
font-weight: 500;
|
||||||
&:first-child {
|
text-align: left;
|
||||||
border-left: 1px solid @project-divider;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tbody tr:hover {
|
:deep(.el-table__body-wrapper td.el-table__cell) {
|
||||||
|
height: 56px;
|
||||||
|
padding: 0;
|
||||||
|
border-right: none;
|
||||||
|
border-bottom: 1px solid @border-color;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.el-table__body tr:hover > td.el-table__cell) {
|
||||||
background: @bg-color-light;
|
background: @bg-color-light;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__cell--check input {
|
:deep(.el-table .cell) {
|
||||||
width: 14px;
|
padding-left: @spacing-sm;
|
||||||
height: 14px;
|
padding-right: @spacing-sm;
|
||||||
margin: 0;
|
line-height: normal;
|
||||||
accent-color: @primary-strong;
|
white-space: nowrap;
|
||||||
vertical-align: middle;
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.el-table-column--selection .cell) {
|
||||||
|
padding-left: @spacing-base;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__ops {
|
&__ops {
|
||||||
@@ -240,31 +181,19 @@ const COLUMNS = [
|
|||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
|
gap: @spacing-base;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__link {
|
&__link {
|
||||||
padding: 0;
|
font-size: @font-size-sm;
|
||||||
border: none;
|
|
||||||
background: transparent;
|
|
||||||
color: @primary-strong;
|
|
||||||
font-size: 12px;
|
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
transition: color 0.2s;
|
padding: 0;
|
||||||
|
cursor: pointer;
|
||||||
+ .bill-table__link {
|
|
||||||
margin-left: 18.36px;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
color: @primary-color;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&__empty {
|
&__empty {
|
||||||
height: 43.77px;
|
|
||||||
color: @project-muted;
|
color: @project-muted;
|
||||||
text-align: center;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed } from 'vue'
|
import { computed } from 'vue'
|
||||||
|
import { ElButton } from 'element-plus'
|
||||||
|
import type { FinancePeriod } from '@/types/business/finance'
|
||||||
|
|
||||||
interface DistributionItem {
|
interface DistributionItem {
|
||||||
name: string
|
name: string
|
||||||
@@ -9,10 +11,15 @@ interface DistributionItem {
|
|||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
distribution: DistributionItem[]
|
distribution: DistributionItem[]
|
||||||
|
/** 全年逐月金额(dimension=YEAR 时接口返回,12 项) */
|
||||||
|
monthly: number[]
|
||||||
|
period: FinancePeriod
|
||||||
}
|
}
|
||||||
|
|
||||||
const props = defineProps<Props>()
|
const props = defineProps<Props>()
|
||||||
|
|
||||||
|
const emit = defineEmits<{ periodChange: [period: FinancePeriod] }>()
|
||||||
|
|
||||||
const total = computed(() => props.distribution.reduce((sum, item) => sum + item.value, 0))
|
const total = computed(() => props.distribution.reduce((sum, item) => sum + item.value, 0))
|
||||||
|
|
||||||
const gradient = computed(() => {
|
const gradient = computed(() => {
|
||||||
@@ -26,13 +33,54 @@ const gradient = computed(() => {
|
|||||||
return `conic-gradient(${stops.join(', ')})`
|
return `conic-gradient(${stops.join(', ')})`
|
||||||
})
|
})
|
||||||
|
|
||||||
function percentOf(value: number): number {
|
interface PeriodOption {
|
||||||
if (total.value <= 0) return 0
|
label: string
|
||||||
return Math.round((value / total.value) * 100)
|
value: FinancePeriod
|
||||||
}
|
}
|
||||||
|
|
||||||
const AXIS = [250, 200, 150, 100, 50]
|
// 设计稿 #20 右上角切换:月度账单(激活)/ 上半
|
||||||
const MONTHS = ['1月', '2月', '3月', '4月', '5月']
|
const PERIODS: PeriodOption[] = [
|
||||||
|
{ label: '月度账单', value: 'month' },
|
||||||
|
{ label: '上半', value: 'half' },
|
||||||
|
]
|
||||||
|
|
||||||
|
const TICK_COUNT = 5
|
||||||
|
const DEFAULT_AXIS_MAX = 250
|
||||||
|
|
||||||
|
/** 月度账单按业务类型分布取值;上半年取 YEAR 维度的 1-6 月逐月金额。 */
|
||||||
|
const bars = computed(() => {
|
||||||
|
if (props.period === 'half') {
|
||||||
|
return props.monthly.slice(0, 6).map((value, index) => ({
|
||||||
|
label: `${index + 1}月`,
|
||||||
|
value,
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
return props.distribution.map((item) => ({
|
||||||
|
label: item.name,
|
||||||
|
value: item.value,
|
||||||
|
}))
|
||||||
|
})
|
||||||
|
|
||||||
|
const axisMax = computed(() => {
|
||||||
|
const max = Math.max(0, ...bars.value.map((bar) => bar.value))
|
||||||
|
if (max <= 0) return DEFAULT_AXIS_MAX
|
||||||
|
const rough = max / TICK_COUNT
|
||||||
|
const magnitude = 10 ** Math.floor(Math.log10(rough))
|
||||||
|
const step = Math.ceil(rough / magnitude) * magnitude
|
||||||
|
return step * TICK_COUNT
|
||||||
|
})
|
||||||
|
|
||||||
|
const axis = computed(() =>
|
||||||
|
Array.from({ length: TICK_COUNT }, (_, index) =>
|
||||||
|
Math.round((axisMax.value / TICK_COUNT) * (TICK_COUNT - index)),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
// 柱高按 Y 轴量程绝对值换算,非占比
|
||||||
|
function heightPercentOf(value: number): number {
|
||||||
|
if (value <= 0) return 0
|
||||||
|
return Math.min((value / axisMax.value) * 100, 100)
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -41,32 +89,44 @@ const MONTHS = ['1月', '2月', '3月', '4月', '5月']
|
|||||||
业务类型分布
|
业务类型分布
|
||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
|
<div class="finance-chart__switch">
|
||||||
|
<el-button
|
||||||
|
v-for="item in PERIODS"
|
||||||
|
:key="item.value"
|
||||||
|
class="finance-chart__switch-btn"
|
||||||
|
:class="{ 'is-active': period === item.value }"
|
||||||
|
@click="emit('periodChange', item.value)"
|
||||||
|
>
|
||||||
|
{{ item.label }}
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="finance-chart__body">
|
<div class="finance-chart__body">
|
||||||
<ul class="finance-chart__axis" aria-hidden="true">
|
<ul class="finance-chart__axis" aria-hidden="true">
|
||||||
<li v-for="v in AXIS" :key="v" class="finance-chart__axis-item">
|
<li v-for="v in axis" :key="v" class="finance-chart__axis-item">
|
||||||
{{ v }}
|
{{ v }}
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<div class="finance-chart__plot">
|
<div class="finance-chart__plot">
|
||||||
<div class="finance-chart__grid" aria-hidden="true">
|
<div class="finance-chart__grid" aria-hidden="true">
|
||||||
<i v-for="v in AXIS" :key="v" class="finance-chart__line" />
|
<i v-for="v in axis" :key="v" class="finance-chart__line" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="finance-chart__bars">
|
<div class="finance-chart__bars">
|
||||||
<span
|
<span
|
||||||
v-for="item in distribution"
|
v-for="(bar, i) in bars"
|
||||||
:key="item.name"
|
:key="`${bar.label}-${i}`"
|
||||||
class="finance-chart__bar"
|
class="finance-chart__bar"
|
||||||
:style="{ height: `${Math.max(percentOf(item.value), 6)}%` }"
|
:style="{ height: `${heightPercentOf(bar.value)}%` }"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="finance-chart__pie" :style="{ background: gradient }" />
|
<div class="finance-chart__pie" :style="{ background: gradient }" />
|
||||||
|
|
||||||
<ul class="finance-chart__months" aria-hidden="true">
|
<ul class="finance-chart__months" aria-hidden="true">
|
||||||
<li v-for="m in MONTHS" :key="m" class="finance-chart__month">
|
<li v-for="(bar, i) in bars" :key="`${bar.label}-${i}`" class="finance-chart__month">
|
||||||
{{ m }}
|
{{ bar.label }}
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
@@ -78,6 +138,10 @@ const MONTHS = ['1月', '2月', '3月', '4月', '5月']
|
|||||||
:key="item.name"
|
:key="item.name"
|
||||||
class="finance-chart__legend-item"
|
class="finance-chart__legend-item"
|
||||||
>
|
>
|
||||||
|
<i
|
||||||
|
class="finance-chart__dot"
|
||||||
|
:style="{ background: item.color }"
|
||||||
|
/>
|
||||||
<span class="finance-chart__name">{{ item.name }}</span>
|
<span class="finance-chart__name">{{ item.name }}</span>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
@@ -116,6 +180,42 @@ const MONTHS = ['1月', '2月', '3月', '4月', '5月']
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&__switch {
|
||||||
|
.flex(row, flex-end, center);
|
||||||
|
gap: 8px;
|
||||||
|
position: absolute;
|
||||||
|
top: 25px;
|
||||||
|
right: 23px;
|
||||||
|
|
||||||
|
:deep(.el-button + .el-button) {
|
||||||
|
margin-left: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&__switch-btn {
|
||||||
|
height: 24px;
|
||||||
|
margin-left: 0;
|
||||||
|
padding: 0 12px;
|
||||||
|
border: none;
|
||||||
|
border-radius: @radius-round;
|
||||||
|
background: @finance-switch-idle-bg;
|
||||||
|
font-size: 11px;
|
||||||
|
font-weight: 500;
|
||||||
|
line-height: 24px;
|
||||||
|
color: @finance-muted-text;
|
||||||
|
transition: color 0.2s, background 0.2s;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: @finance-switch-idle-bg;
|
||||||
|
color: @finance-chart-switch-active;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.is-active {
|
||||||
|
background: @finance-switch-active-bg;
|
||||||
|
color: @finance-chart-switch-active;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
&__body {
|
&__body {
|
||||||
.flex(row, flex-start, flex-start);
|
.flex(row, flex-start, flex-start);
|
||||||
gap: 0;
|
gap: 0;
|
||||||
@@ -126,7 +226,8 @@ const MONTHS = ['1月', '2月', '3月', '4月', '5月']
|
|||||||
.flex(column, space-between, flex-start);
|
.flex(column, space-between, flex-start);
|
||||||
width: 34px;
|
width: 34px;
|
||||||
height: 234px;
|
height: 234px;
|
||||||
margin: 0;
|
// 设计稿 #20:Y 轴刻度文字左缘 x=103(卡左 70 + padding 23 + 10)
|
||||||
|
margin: 0 0 0 10px;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
list-style: none;
|
list-style: none;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
@@ -164,7 +265,7 @@ const MONTHS = ['1月', '2月', '3月', '4月', '5月']
|
|||||||
.flex(row, space-around, flex-end);
|
.flex(row, space-around, flex-end);
|
||||||
position: absolute;
|
position: absolute;
|
||||||
inset: 0;
|
inset: 0;
|
||||||
padding: 0 40px;
|
// 无横向 padding:柱子与下方月份标签同为 space-around,中心才能对齐(设计稿 #20 柱月对齐)
|
||||||
}
|
}
|
||||||
|
|
||||||
&__bar {
|
&__bar {
|
||||||
@@ -200,7 +301,8 @@ const MONTHS = ['1月', '2月', '3月', '4月', '5月']
|
|||||||
.flex(row, flex-start, center);
|
.flex(row, flex-start, center);
|
||||||
gap: 27px;
|
gap: 27px;
|
||||||
margin: 41px 0 0;
|
margin: 41px 0 0;
|
||||||
padding: 0 0 0 662px;
|
// 设计稿 #20:图例文字左缘 x=809(卡左 70 + padding 23 + 704 + 圆点 6 + gap 6)
|
||||||
|
padding: 0 0 0 704px;
|
||||||
list-style: none;
|
list-style: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -212,6 +314,13 @@ const MONTHS = ['1月', '2月', '3月', '4月', '5月']
|
|||||||
color: @finance-muted-text;
|
color: @finance-muted-text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&__dot {
|
||||||
|
flex-shrink: 0;
|
||||||
|
width: 6px;
|
||||||
|
height: 6px;
|
||||||
|
border-radius: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
&__name {
|
&__name {
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,34 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { ElDatePicker } from 'element-plus'
|
||||||
import type { FinanceStats } from '@/types/business/finance'
|
import type { FinanceStats } from '@/types/business/finance'
|
||||||
import { formatMoney } from '@/utils/format'
|
import { formatMoney } from '@/utils/format'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
stats: FinanceStats | null
|
stats: FinanceStats | null
|
||||||
|
/** 'year' 表示当年全年,或具体月份 YYYY-MM */
|
||||||
|
period: string
|
||||||
}
|
}
|
||||||
|
|
||||||
defineProps<Props>()
|
const props = defineProps<Props>()
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
periodChange: [period: string]
|
periodChange: [period: string]
|
||||||
export: []
|
export: []
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
|
const year = new Date().getFullYear()
|
||||||
|
|
||||||
|
/** 不允许选择未来月份 */
|
||||||
|
function isFutureMonth(date: Date): boolean {
|
||||||
|
const today = new Date()
|
||||||
|
return date.getFullYear() > today.getFullYear()
|
||||||
|
|| (date.getFullYear() === today.getFullYear() && date.getMonth() > today.getMonth())
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 清空月份时回到「全年」 */
|
||||||
|
function onPeriodChange(value: string | number | Date | null): void {
|
||||||
|
emit('periodChange', typeof value === 'string' && value ? value : 'year')
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -25,10 +42,19 @@ const emit = defineEmits<{
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button class="finance-overview__period-link" @click="emit('periodChange', 'year')">
|
<div class="finance-overview__month">
|
||||||
{{ stats?.month || '2026年账单' }}
|
<ElDatePicker
|
||||||
<span aria-hidden="true">›</span>
|
:model-value="props.period === 'year' ? '' : props.period"
|
||||||
</button>
|
type="month"
|
||||||
|
format="YYYY年MM月"
|
||||||
|
value-format="YYYY-MM"
|
||||||
|
:placeholder="`${year}年全年`"
|
||||||
|
:clearable="true"
|
||||||
|
:editable="false"
|
||||||
|
:disabled-date="isFutureMonth"
|
||||||
|
@update:model-value="onPeriodChange"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -62,20 +88,48 @@ const emit = defineEmits<{
|
|||||||
color: @white;
|
color: @white;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__period-link {
|
&__month {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 25px;
|
top: 22px;
|
||||||
right: 27px;
|
right: 17px;
|
||||||
border: none;
|
width: 125px;
|
||||||
background: transparent;
|
|
||||||
font-size: 11px;
|
|
||||||
font-weight: 500;
|
|
||||||
line-height: 15px;
|
|
||||||
color: @white;
|
|
||||||
cursor: pointer;
|
|
||||||
transition: opacity 0.2s;
|
|
||||||
|
|
||||||
&:hover {
|
:deep(.el-date-editor) {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.el-input__wrapper) {
|
||||||
|
padding: 0;
|
||||||
|
background: transparent;
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.el-input__inner) {
|
||||||
|
min-width: 0;
|
||||||
|
padding: 0 16px 0 0;
|
||||||
|
color: @white;
|
||||||
|
font-size: 11px;
|
||||||
|
font-weight: 500;
|
||||||
|
text-align: left;
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
|
&::placeholder {
|
||||||
|
color: @white;
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 日历图标和文字挨在一起
|
||||||
|
:deep(.el-input__prefix) {
|
||||||
|
margin-right: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.el-input__prefix),
|
||||||
|
:deep(.el-input__suffix) {
|
||||||
|
color: @white;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover :deep(.el-input__inner) {
|
||||||
opacity: 0.8;
|
opacity: 0.8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
248
src/views/finance/cpns/InvoiceApplyDialog.vue
Normal file
248
src/views/finance/cpns/InvoiceApplyDialog.vue
Normal file
@@ -0,0 +1,248 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { ref, watch } from 'vue'
|
||||||
|
import { ElMessage, ElSelect, ElOption, ElRadio, ElButton } from 'element-plus'
|
||||||
|
import type {
|
||||||
|
InvoiceApplyPayload,
|
||||||
|
InvoiceAvailableBill,
|
||||||
|
InvoiceTitle,
|
||||||
|
InvoiceType,
|
||||||
|
} from '@/types/business/finance'
|
||||||
|
import { INVOICE_TYPE_LABELS } from '@/utils/invoiceVo'
|
||||||
|
import { formatMoney } from '@/utils/format'
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
bills: InvoiceAvailableBill[]
|
||||||
|
titles: InvoiceTitle[]
|
||||||
|
/** 从某条已驳回记录进入时,优先选中的账单 */
|
||||||
|
preselectBillId?: string
|
||||||
|
submitting?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
const props = defineProps<Props>()
|
||||||
|
|
||||||
|
const visible = defineModel<boolean>('visible', { default: false })
|
||||||
|
|
||||||
|
const emit = defineEmits<{ submit: [payload: InvoiceApplyPayload] }>()
|
||||||
|
|
||||||
|
const billId = ref('')
|
||||||
|
const titleId = ref('')
|
||||||
|
const invoiceType = ref<InvoiceType>('GENERAL')
|
||||||
|
|
||||||
|
function defaultTitleId(): string {
|
||||||
|
return props.titles.find((item) => item.isDefault)?.id ?? props.titles[0]?.id ?? ''
|
||||||
|
}
|
||||||
|
|
||||||
|
function reset(): void {
|
||||||
|
const preferred = props.preselectBillId
|
||||||
|
const preferredExists = Boolean(preferred) && props.bills.some((bill) => bill.billId === preferred)
|
||||||
|
billId.value = preferredExists && preferred ? preferred : (props.bills[0]?.billId ?? '')
|
||||||
|
titleId.value = defaultTitleId()
|
||||||
|
invoiceType.value = 'GENERAL'
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(visible, (open) => {
|
||||||
|
if (open) reset()
|
||||||
|
})
|
||||||
|
|
||||||
|
// 抬头/账单可能在弹窗打开后才加载完成,补选默认项
|
||||||
|
watch(
|
||||||
|
() => props.titles,
|
||||||
|
(list) => {
|
||||||
|
if (visible.value && !titleId.value && list.length > 0) titleId.value = defaultTitleId()
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.bills,
|
||||||
|
(list) => {
|
||||||
|
if (visible.value && !billId.value && list.length > 0) billId.value = list[0].billId
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
function onSubmit(): void {
|
||||||
|
if (!billId.value) {
|
||||||
|
ElMessage.warning('请选择要开票的账单')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!titleId.value) {
|
||||||
|
ElMessage.warning('请选择发票抬头')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
emit('submit', {
|
||||||
|
billId: billId.value,
|
||||||
|
titleId: titleId.value,
|
||||||
|
invoiceType: invoiceType.value,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function onCancel(): void {
|
||||||
|
visible.value = false
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Teleport to="body">
|
||||||
|
<div v-if="visible" class="invoice-apply" @click.self="onCancel">
|
||||||
|
<div class="invoice-apply__panel">
|
||||||
|
<h3 class="invoice-apply__title">
|
||||||
|
申请开票
|
||||||
|
</h3>
|
||||||
|
|
||||||
|
<div class="invoice-apply__field">
|
||||||
|
<span class="invoice-apply__label">选择账单</span>
|
||||||
|
<el-select
|
||||||
|
v-model="billId"
|
||||||
|
class="invoice-apply__control"
|
||||||
|
placeholder="请选择可开票账单"
|
||||||
|
:disabled="bills.length === 0"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="bill in bills"
|
||||||
|
:key="bill.billId"
|
||||||
|
:value="bill.billId"
|
||||||
|
:label="`${bill.billNo} · ${bill.periodName} · ¥${formatMoney(bill.amount)}`"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="invoice-apply__field">
|
||||||
|
<span class="invoice-apply__label">发票抬头</span>
|
||||||
|
<el-select
|
||||||
|
v-model="titleId"
|
||||||
|
class="invoice-apply__control"
|
||||||
|
placeholder="请选择发票抬头"
|
||||||
|
:disabled="titles.length === 0"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="title in titles"
|
||||||
|
:key="title.id"
|
||||||
|
:value="title.id"
|
||||||
|
:label="`${title.title}(${title.type})`"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="invoice-apply__field">
|
||||||
|
<span class="invoice-apply__label">发票类型</span>
|
||||||
|
<el-radio v-model="invoiceType" value="GENERAL">
|
||||||
|
{{ INVOICE_TYPE_LABELS.GENERAL }}
|
||||||
|
</el-radio>
|
||||||
|
<el-radio v-model="invoiceType" value="SPECIAL">
|
||||||
|
{{ INVOICE_TYPE_LABELS.SPECIAL }}
|
||||||
|
</el-radio>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p v-if="bills.length === 0" class="invoice-apply__empty">
|
||||||
|
暂无可开票账单(仅已支付且未开票的账单可申请)
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="invoice-apply__footer">
|
||||||
|
<el-button class="invoice-apply__btn" @click="onCancel">
|
||||||
|
取消
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
class="invoice-apply__btn invoice-apply__btn--confirm"
|
||||||
|
:disabled="bills.length === 0 || titles.length === 0 || submitting"
|
||||||
|
@click="onSubmit"
|
||||||
|
>
|
||||||
|
{{ submitting ? '提交中…' : '提交申请' }}
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Teleport>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style lang="less" scoped>
|
||||||
|
.invoice-apply {
|
||||||
|
position: fixed;
|
||||||
|
inset: 0;
|
||||||
|
z-index: 1000;
|
||||||
|
.flex(row, center);
|
||||||
|
background: rgba(0, 0, 0, 0.45);
|
||||||
|
|
||||||
|
&__panel {
|
||||||
|
width: 480px;
|
||||||
|
max-width: calc(100vw - 32px);
|
||||||
|
padding: @spacing-lg;
|
||||||
|
border-radius: @radius-lg;
|
||||||
|
background: @white;
|
||||||
|
box-shadow: @shadow-lg;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__title {
|
||||||
|
margin-bottom: @spacing-base;
|
||||||
|
font-size: @font-size-lg;
|
||||||
|
font-weight: 600;
|
||||||
|
color: @heading-color;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__field {
|
||||||
|
.flex(row, flex-start, center);
|
||||||
|
gap: @spacing-sm;
|
||||||
|
margin-bottom: @spacing-base;
|
||||||
|
|
||||||
|
:deep(.el-radio__label) {
|
||||||
|
color: @text-color;
|
||||||
|
font-size: @font-size-base;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&__label {
|
||||||
|
width: 72px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
font-size: @font-size-base;
|
||||||
|
color: @text-color;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__control {
|
||||||
|
flex: 1;
|
||||||
|
|
||||||
|
:deep(.el-select__wrapper) {
|
||||||
|
min-height: 34px;
|
||||||
|
background: @bg-color-light;
|
||||||
|
box-shadow: none;
|
||||||
|
border-radius: @radius-base;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&__empty {
|
||||||
|
margin-top: @spacing-sm;
|
||||||
|
font-size: @font-size-sm;
|
||||||
|
color: @text-color-secondary;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__footer {
|
||||||
|
.flex(row, flex-end);
|
||||||
|
gap: @spacing-sm;
|
||||||
|
margin-top: @spacing-lg;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__btn {
|
||||||
|
height: 34px;
|
||||||
|
padding: 0 @spacing-base;
|
||||||
|
border: 1px solid @border-color-dark;
|
||||||
|
border-radius: @radius-base;
|
||||||
|
background: @white;
|
||||||
|
color: @text-color;
|
||||||
|
font-size: @font-size-base;
|
||||||
|
transition: all 0.2s;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
border-color: @primary-color;
|
||||||
|
color: @primary-color;
|
||||||
|
}
|
||||||
|
|
||||||
|
&--confirm {
|
||||||
|
border-color: @primary-color;
|
||||||
|
background: @primary-color;
|
||||||
|
color: @white;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: @primary-hover;
|
||||||
|
color: @white;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { ElButton } from 'element-plus'
|
||||||
import type { InvoiceTitle } from '@/types/business/finance'
|
import type { InvoiceTitle } from '@/types/business/finance'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -20,18 +21,31 @@ const emit = defineEmits<{
|
|||||||
<span v-if="invoiceTitle.isDefault" class="invoice-title-card__badge">默认抬头</span>
|
<span v-if="invoiceTitle.isDefault" class="invoice-title-card__badge">默认抬头</span>
|
||||||
<span v-else class="invoice-title-card__badge-placeholder" />
|
<span v-else class="invoice-title-card__badge-placeholder" />
|
||||||
<div class="invoice-title-card__actions">
|
<div class="invoice-title-card__actions">
|
||||||
<button
|
<el-button
|
||||||
|
v-if="!invoiceTitle.isDefault"
|
||||||
|
link
|
||||||
|
type="primary"
|
||||||
class="invoice-title-card__btn"
|
class="invoice-title-card__btn"
|
||||||
@click="emit('setDefault', invoiceTitle.id)"
|
@click="emit('setDefault', invoiceTitle.id)"
|
||||||
>
|
>
|
||||||
{{ invoiceTitle.isDefault ? '取消默认' : '设为默认' }}
|
设为默认
|
||||||
</button>
|
</el-button>
|
||||||
<button class="invoice-title-card__btn" @click="emit('delete', invoiceTitle.id)">
|
<el-button
|
||||||
|
link
|
||||||
|
type="primary"
|
||||||
|
class="invoice-title-card__btn"
|
||||||
|
@click="emit('delete', invoiceTitle.id)"
|
||||||
|
>
|
||||||
删除
|
删除
|
||||||
</button>
|
</el-button>
|
||||||
<button class="invoice-title-card__btn" @click="emit('edit', invoiceTitle)">
|
<el-button
|
||||||
|
link
|
||||||
|
type="primary"
|
||||||
|
class="invoice-title-card__btn"
|
||||||
|
@click="emit('edit', invoiceTitle)"
|
||||||
|
>
|
||||||
编辑
|
编辑
|
||||||
</button>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -104,6 +118,7 @@ const emit = defineEmits<{
|
|||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
color: @primary-strong;
|
color: @primary-strong;
|
||||||
|
background: transparent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { reactive, watch } from 'vue'
|
import { reactive, watch } from 'vue'
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage, ElInput, ElRadio, ElButton } from 'element-plus'
|
||||||
import type { InvoiceTitle, InvoiceTitlePayload } from '@/types/business/finance'
|
import type { InvoiceTitle, InvoiceTitlePayload } from '@/types/business/finance'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -27,8 +27,12 @@ watch(visible, (open) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
function onSave(): void {
|
function onSave(): void {
|
||||||
if (!form.title.trim() || !form.taxNo.trim()) {
|
if (!form.title.trim()) {
|
||||||
ElMessage.warning('请填写发票抬头与税号')
|
ElMessage.warning('请填写发票抬头')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (form.type === '企业单位' && !form.taxNo.trim()) {
|
||||||
|
ElMessage.warning('企业单位请填写税号')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
emit('save', { type: form.type, title: form.title.trim(), taxNo: form.taxNo.trim() })
|
emit('save', { type: form.type, title: form.title.trim(), taxNo: form.taxNo.trim() })
|
||||||
@@ -50,41 +54,39 @@ function onCancel(): void {
|
|||||||
|
|
||||||
<div class="title-dialog__field">
|
<div class="title-dialog__field">
|
||||||
<span class="title-dialog__label">抬头类型</span>
|
<span class="title-dialog__label">抬头类型</span>
|
||||||
<label class="title-dialog__radio">
|
<el-radio v-model="form.type" value="企业单位">
|
||||||
<input v-model="form.type" type="radio" value="企业单位">
|
|
||||||
企业单位
|
企业单位
|
||||||
</label>
|
</el-radio>
|
||||||
<label class="title-dialog__radio">
|
<el-radio v-model="form.type" value="非企业单位">
|
||||||
<input v-model="form.type" type="radio" value="非企业单位">
|
|
||||||
非企业单位
|
非企业单位
|
||||||
</label>
|
</el-radio>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="title-dialog__field">
|
<div class="title-dialog__field">
|
||||||
<span class="title-dialog__label">发票抬头</span>
|
<span class="title-dialog__label">发票抬头</span>
|
||||||
<input
|
<el-input
|
||||||
v-model="form.title"
|
v-model="form.title"
|
||||||
class="title-dialog__input"
|
class="title-dialog__input"
|
||||||
placeholder="请输入发票抬头"
|
placeholder="请输入发票抬头"
|
||||||
>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="title-dialog__field">
|
<div class="title-dialog__field">
|
||||||
<span class="title-dialog__label">税号</span>
|
<span class="title-dialog__label">税号</span>
|
||||||
<input
|
<el-input
|
||||||
v-model="form.taxNo"
|
v-model="form.taxNo"
|
||||||
class="title-dialog__input"
|
class="title-dialog__input"
|
||||||
placeholder="请输入税号"
|
placeholder="请输入税号"
|
||||||
>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="title-dialog__footer">
|
<div class="title-dialog__footer">
|
||||||
<button class="title-dialog__btn" @click="onCancel">
|
<el-button class="title-dialog__btn" @click="onCancel">
|
||||||
取消
|
取消
|
||||||
</button>
|
</el-button>
|
||||||
<button class="title-dialog__btn title-dialog__btn--confirm" @click="onSave">
|
<el-button class="title-dialog__btn title-dialog__btn--confirm" @click="onSave">
|
||||||
保存
|
保存
|
||||||
</button>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -119,6 +121,11 @@ function onCancel(): void {
|
|||||||
.flex(row, flex-start, center);
|
.flex(row, flex-start, center);
|
||||||
gap: @spacing-sm;
|
gap: @spacing-sm;
|
||||||
margin-bottom: @spacing-base;
|
margin-bottom: @spacing-base;
|
||||||
|
|
||||||
|
:deep(.el-radio__label) {
|
||||||
|
color: @text-color;
|
||||||
|
font-size: @font-size-base;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&__label {
|
&__label {
|
||||||
@@ -128,31 +135,19 @@ function onCancel(): void {
|
|||||||
color: @text-color;
|
color: @text-color;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__radio {
|
|
||||||
.flex(row, flex-start, center);
|
|
||||||
gap: @spacing-xs;
|
|
||||||
font-size: @font-size-base;
|
|
||||||
color: @text-color;
|
|
||||||
cursor: pointer;
|
|
||||||
|
|
||||||
input {
|
|
||||||
accent-color: @primary-color;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&__input {
|
&__input {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
height: 34px;
|
|
||||||
padding: 0 @spacing-sm;
|
|
||||||
border: 1px solid @border-color;
|
|
||||||
border-radius: @radius-base;
|
|
||||||
background: @bg-color-light;
|
|
||||||
font-size: @font-size-base;
|
|
||||||
outline: none;
|
|
||||||
transition: border-color 0.2s;
|
|
||||||
|
|
||||||
&:focus {
|
:deep(.el-input__wrapper) {
|
||||||
border-color: @primary-color;
|
height: 34px;
|
||||||
|
background: @bg-color-light;
|
||||||
|
box-shadow: none;
|
||||||
|
border-radius: @radius-base;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.el-input__inner) {
|
||||||
|
color: @text-color;
|
||||||
|
font-size: @font-size-base;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,179 +0,0 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
import { ref, watch } from 'vue'
|
|
||||||
import type { PayMethod } from '@/types/business/finance'
|
|
||||||
|
|
||||||
interface Props {
|
|
||||||
method: PayMethod
|
|
||||||
}
|
|
||||||
|
|
||||||
const props = defineProps<Props>()
|
|
||||||
|
|
||||||
const visible = defineModel<boolean>('visible', { default: false })
|
|
||||||
|
|
||||||
const emit = defineEmits<{ confirm: [method: PayMethod] }>()
|
|
||||||
|
|
||||||
const selected = ref<PayMethod>(props.method)
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => props.method,
|
|
||||||
(value) => {
|
|
||||||
selected.value = value
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
watch(visible, (open) => {
|
|
||||||
if (open) selected.value = props.method
|
|
||||||
})
|
|
||||||
|
|
||||||
function onConfirm(): void {
|
|
||||||
emit('confirm', selected.value)
|
|
||||||
visible.value = false
|
|
||||||
}
|
|
||||||
|
|
||||||
function onCancel(): void {
|
|
||||||
visible.value = false
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<Teleport to="body">
|
|
||||||
<div v-if="visible" class="pay-method-dialog" @click.self="onCancel">
|
|
||||||
<div class="pay-method-dialog__panel">
|
|
||||||
<h3 class="pay-method-dialog__title">
|
|
||||||
切换支付方式
|
|
||||||
</h3>
|
|
||||||
|
|
||||||
<label
|
|
||||||
class="pay-method-dialog__option"
|
|
||||||
:class="{ 'is-active': selected === 'wechat' }"
|
|
||||||
>
|
|
||||||
<input
|
|
||||||
v-model="selected"
|
|
||||||
type="radio"
|
|
||||||
value="wechat"
|
|
||||||
class="pay-method-dialog__radio"
|
|
||||||
>
|
|
||||||
<span class="pay-method-dialog__name">微信支付</span>
|
|
||||||
<span class="pay-method-dialog__tip text-secondary">推荐使用</span>
|
|
||||||
</label>
|
|
||||||
|
|
||||||
<label
|
|
||||||
class="pay-method-dialog__option"
|
|
||||||
:class="{ 'is-active': selected === 'alipay' }"
|
|
||||||
>
|
|
||||||
<input
|
|
||||||
v-model="selected"
|
|
||||||
type="radio"
|
|
||||||
value="alipay"
|
|
||||||
class="pay-method-dialog__radio"
|
|
||||||
>
|
|
||||||
<span class="pay-method-dialog__name">支付宝支付</span>
|
|
||||||
<span class="pay-method-dialog__tip text-secondary">其他用户选择</span>
|
|
||||||
</label>
|
|
||||||
|
|
||||||
<div class="pay-method-dialog__footer">
|
|
||||||
<button class="pay-method-dialog__btn" @click="onCancel">
|
|
||||||
取消
|
|
||||||
</button>
|
|
||||||
<button class="pay-method-dialog__btn pay-method-dialog__btn--confirm" @click="onConfirm">
|
|
||||||
确认
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</Teleport>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style lang="less" scoped>
|
|
||||||
.pay-method-dialog {
|
|
||||||
position: fixed;
|
|
||||||
inset: 0;
|
|
||||||
z-index: 1000;
|
|
||||||
.flex(row, center);
|
|
||||||
background: rgba(0, 0, 0, 0.45);
|
|
||||||
|
|
||||||
&__panel {
|
|
||||||
width: 420px;
|
|
||||||
max-width: calc(100vw - 32px);
|
|
||||||
padding: @spacing-lg;
|
|
||||||
border-radius: @radius-lg;
|
|
||||||
background: @white;
|
|
||||||
box-shadow: @shadow-lg;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__title {
|
|
||||||
margin-bottom: @spacing-base;
|
|
||||||
font-size: @font-size-lg;
|
|
||||||
font-weight: 600;
|
|
||||||
color: @heading-color;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__option {
|
|
||||||
.flex(row, flex-start, center);
|
|
||||||
gap: @spacing-sm;
|
|
||||||
padding: @spacing-base;
|
|
||||||
margin-bottom: @spacing-sm;
|
|
||||||
border: 1px solid @border-color;
|
|
||||||
border-radius: @radius-base;
|
|
||||||
cursor: pointer;
|
|
||||||
transition: all 0.2s;
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
border-color: @primary-color;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.is-active {
|
|
||||||
border-color: @primary-color;
|
|
||||||
background: @primary-light;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&__radio {
|
|
||||||
accent-color: @primary-color;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__name {
|
|
||||||
font-size: @font-size-base;
|
|
||||||
color: @heading-color;
|
|
||||||
font-weight: 500;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__tip {
|
|
||||||
margin-left: auto;
|
|
||||||
font-size: @font-size-sm;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__footer {
|
|
||||||
.flex(row, flex-end);
|
|
||||||
gap: @spacing-sm;
|
|
||||||
margin-top: @spacing-base;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__btn {
|
|
||||||
height: 34px;
|
|
||||||
padding: 0 @spacing-base;
|
|
||||||
border: 1px solid @border-color-dark;
|
|
||||||
border-radius: @radius-base;
|
|
||||||
background: @white;
|
|
||||||
color: @text-color;
|
|
||||||
font-size: @font-size-base;
|
|
||||||
transition: all 0.2s;
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
border-color: @primary-color;
|
|
||||||
color: @primary-color;
|
|
||||||
}
|
|
||||||
|
|
||||||
&--confirm {
|
|
||||||
border-color: @primary-color;
|
|
||||||
background: @primary-color;
|
|
||||||
color: @white;
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
background: @primary-hover;
|
|
||||||
color: @white;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,35 +1,22 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, ref, watch } from 'vue'
|
import { computed } from 'vue'
|
||||||
import qrcode from 'qrcode-generator'
|
import qrcode from 'qrcode-generator'
|
||||||
import { useCountDown } from '@/composables/useCountDown'
|
|
||||||
import { formatMoney } from '@/utils/format'
|
import { formatMoney } from '@/utils/format'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
visible: boolean
|
visible: boolean
|
||||||
|
/** 后端返回的二维码内容字符串 */
|
||||||
content: string
|
content: string
|
||||||
amount: number
|
amount: number
|
||||||
expiresIn?: number
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const props = withDefaults(defineProps<Props>(), { expiresIn: 300 })
|
const props = defineProps<Props>()
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
'update:visible': [visible: boolean]
|
'update:visible': [visible: boolean]
|
||||||
refresh: []
|
check: []
|
||||||
paid: []
|
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const { seconds, start, reset: resetCountDown } = useCountDown(props.expiresIn)
|
|
||||||
const started = ref(false)
|
|
||||||
|
|
||||||
const expired = computed(() => started.value && seconds.value <= 0)
|
|
||||||
|
|
||||||
const countdownText = computed(() => {
|
|
||||||
const m = Math.floor(seconds.value / 60)
|
|
||||||
const s = seconds.value % 60
|
|
||||||
return `${String(m).padStart(2, '0')}:${String(s).padStart(2, '0')}`
|
|
||||||
})
|
|
||||||
|
|
||||||
const qrSvg = computed(() => {
|
const qrSvg = computed(() => {
|
||||||
if (!props.content) return ''
|
if (!props.content) return ''
|
||||||
try {
|
try {
|
||||||
@@ -37,78 +24,45 @@ const qrSvg = computed(() => {
|
|||||||
qr.addData(props.content)
|
qr.addData(props.content)
|
||||||
qr.make()
|
qr.make()
|
||||||
return qr.createSvgTag({ cellSize: 4, margin: 2, scalable: true })
|
return qr.createSvgTag({ cellSize: 4, margin: 2, scalable: true })
|
||||||
} catch {
|
}
|
||||||
|
catch {
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
watch(
|
|
||||||
() => [props.visible, props.content] as const,
|
|
||||||
([visible, content]) => {
|
|
||||||
if (visible && content) {
|
|
||||||
start(props.expiresIn)
|
|
||||||
started.value = true
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (!visible) {
|
|
||||||
resetCountDown()
|
|
||||||
started.value = false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{ immediate: true },
|
|
||||||
)
|
|
||||||
|
|
||||||
function close(): void {
|
function close(): void {
|
||||||
emit('update:visible', false)
|
emit('update:visible', false)
|
||||||
}
|
}
|
||||||
|
|
||||||
function refresh(): void {
|
|
||||||
start(props.expiresIn)
|
|
||||||
started.value = true
|
|
||||||
emit('refresh')
|
|
||||||
}
|
|
||||||
|
|
||||||
function onPaid(): void {
|
|
||||||
emit('paid')
|
|
||||||
}
|
|
||||||
|
|
||||||
function onBoxClick(): void {
|
|
||||||
if (expired.value) refresh()
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Teleport to="body">
|
<Teleport to="body">
|
||||||
<div v-if="visible" class="wx-qr" @click.self="close">
|
<div v-if="visible" class="pay-qr" @click.self="close">
|
||||||
<div class="wx-qr__panel">
|
<div class="pay-qr__panel">
|
||||||
<h3 class="wx-qr__title">微信扫码支付</h3>
|
<h3 class="pay-qr__title">
|
||||||
<p class="wx-qr__amount">¥{{ formatMoney(amount) }}</p>
|
支付宝扫码支付
|
||||||
|
</h3>
|
||||||
|
<p class="pay-qr__amount">
|
||||||
|
¥{{ formatMoney(amount) }}
|
||||||
|
</p>
|
||||||
|
|
||||||
<div
|
<div class="pay-qr__box">
|
||||||
class="wx-qr__box"
|
<div v-if="qrSvg" class="pay-qr__code" v-html="qrSvg" />
|
||||||
:class="{ 'is-expired': expired }"
|
<div v-else class="pay-qr__mask">
|
||||||
@click="onBoxClick"
|
<span class="pay-qr__mask-icon">▦</span>
|
||||||
>
|
<span class="pay-qr__mask-text">二维码生成中</span>
|
||||||
<div v-if="!expired && qrSvg" class="wx-qr__code" v-html="qrSvg" />
|
|
||||||
<div v-else class="wx-qr__mask">
|
|
||||||
<span class="wx-qr__mask-icon">⟳</span>
|
|
||||||
<span class="wx-qr__mask-text">
|
|
||||||
{{ expired ? '二维码已过期' : '二维码生成中' }}<br />点击刷新
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p class="wx-qr__status">
|
<p class="pay-qr__status">
|
||||||
<template v-if="!expired">
|
请使用手机支付宝 <strong>[扫一扫]</strong> 扫描上方二维码完成支付,支付成功后自动跳转
|
||||||
请使用手机微信 <strong>[扫一扫]</strong> 扫描上方二维码, 二维码
|
|
||||||
<strong class="wx-qr__count">{{ countdownText }}</strong> 后失效
|
|
||||||
</template>
|
|
||||||
<template v-else> 二维码已过期,请点击二维码或下方按钮刷新 </template>
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="wx-qr__actions">
|
<div class="pay-qr__actions">
|
||||||
<button class="wx-qr__btn" @click="refresh">刷新二维码</button>
|
<button class="pay-qr__btn" @click="close">
|
||||||
<button class="wx-qr__btn wx-qr__btn--cta" @click="onPaid">
|
取消支付
|
||||||
|
</button>
|
||||||
|
<button class="pay-qr__btn pay-qr__btn--cta" @click="emit('check')">
|
||||||
我已完成支付
|
我已完成支付
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -118,7 +72,7 @@ function onBoxClick(): void {
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
.wx-qr {
|
.pay-qr {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
inset: 0;
|
inset: 0;
|
||||||
z-index: 1000;
|
z-index: 1000;
|
||||||
@@ -156,11 +110,6 @@ function onBoxClick(): void {
|
|||||||
border: 1px solid @checkout-line;
|
border: 1px solid @checkout-line;
|
||||||
border-radius: @radius-base;
|
border-radius: @radius-base;
|
||||||
background: @checkout-card;
|
background: @checkout-card;
|
||||||
|
|
||||||
&.is-expired {
|
|
||||||
background: @bg-color;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&__code {
|
&__code {
|
||||||
@@ -204,11 +153,6 @@ function onBoxClick(): void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&__count {
|
|
||||||
color: @checkout-amount;
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__actions {
|
&__actions {
|
||||||
.flex(row, center);
|
.flex(row, center);
|
||||||
gap: @spacing-sm;
|
gap: @spacing-sm;
|
||||||
@@ -3,9 +3,8 @@ export { default as FinanceOverview } from './cpns/FinanceOverview.vue'
|
|||||||
export { default as FinanceChart } from './cpns/FinanceChart.vue'
|
export { default as FinanceChart } from './cpns/FinanceChart.vue'
|
||||||
export { default as BillTable } from './cpns/BillTable.vue'
|
export { default as BillTable } from './cpns/BillTable.vue'
|
||||||
export { default as BillSummaryBar } from './cpns/BillSummaryBar.vue'
|
export { default as BillSummaryBar } from './cpns/BillSummaryBar.vue'
|
||||||
export { default as PayMethodDialog } from './cpns/PayMethodDialog.vue'
|
|
||||||
export { default as InvoiceTitleCard } from './cpns/InvoiceTitleCard.vue'
|
export { default as InvoiceTitleCard } from './cpns/InvoiceTitleCard.vue'
|
||||||
export { default as InvoiceTitleDialog } from './cpns/InvoiceTitleDialog.vue'
|
export { default as InvoiceTitleDialog } from './cpns/InvoiceTitleDialog.vue'
|
||||||
export { default as CheckoutBillCard } from './cpns/CheckoutBillCard.vue'
|
export { default as CheckoutBillCard } from './cpns/CheckoutBillCard.vue'
|
||||||
export { default as PayMethodList } from './cpns/PayMethodList.vue'
|
export { default as PayMethodList } from './cpns/PayMethodList.vue'
|
||||||
export { default as WechatQrDialog } from './cpns/WechatQrDialog.vue'
|
export { default as PayQrDialog } from './cpns/PayQrDialog.vue'
|
||||||
|
|||||||
@@ -1,35 +1,105 @@
|
|||||||
<!-- 页面:财务中心(Finance) -->
|
<!-- 页面:财务中心(Finance) -->
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onMounted } from 'vue'
|
import { onMounted, ref } from 'vue'
|
||||||
import { storeToRefs } from 'pinia'
|
import { storeToRefs } from 'pinia'
|
||||||
import { RouterLink } from 'vue-router'
|
import { RouterLink } from 'vue-router'
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
import { PageHead } from '@/components'
|
import { PageHead } from '@/components'
|
||||||
import { useFinanceStore } from '@/stores/modules/finance'
|
import { useFinanceStore } from '@/stores/modules/finance'
|
||||||
|
import type { FinancePeriod, FinanceSummaryQuery } from '@/types/business/finance'
|
||||||
import FinanceChart from './cpns/FinanceChart.vue'
|
import FinanceChart from './cpns/FinanceChart.vue'
|
||||||
import FinanceOverview from './cpns/FinanceOverview.vue'
|
import FinanceOverview from './cpns/FinanceOverview.vue'
|
||||||
|
|
||||||
const financeStore = useFinanceStore()
|
const financeStore = useFinanceStore()
|
||||||
const { stats } = storeToRefs(financeStore)
|
const { stats, overviewStats } = storeToRefs(financeStore)
|
||||||
|
|
||||||
const ENTRIES = [
|
const ENTRIES = [
|
||||||
{ label: '账单明细', to: '/finance/bills' },
|
{ key: 'bill', label: '账单明细', to: '/finance/bills' },
|
||||||
{ label: '待支付', to: '/finance/bills' },
|
{ key: 'pending', label: '待支付', to: '/finance/bills' },
|
||||||
{ label: '发票申请', to: '/finance/invoices' },
|
{ key: 'invoice', label: '发票申请', to: '/finance/invoices' },
|
||||||
{ label: '报表导出', to: '' },
|
{ key: 'export', label: '报表导出', to: '' },
|
||||||
] as const
|
] as const
|
||||||
|
|
||||||
function onPeriodChange(period: string): void {
|
const chartPeriod = ref<FinancePeriod>('month')
|
||||||
void financeStore.fetchStats(period)
|
const now = new Date()
|
||||||
|
|
||||||
|
/** 累计消费总额:默认当年全年,可切换具体月份 */
|
||||||
|
const overviewPeriod = ref('year')
|
||||||
|
|
||||||
|
/** 下方图表仍按当前月/当前年请求,不受月份选择器影响 */
|
||||||
|
function buildChartQuery(): FinanceSummaryQuery {
|
||||||
|
if (chartPeriod.value === 'half') {
|
||||||
|
return { dimension: 'YEAR', year: now.getFullYear() }
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
dimension: 'MONTH',
|
||||||
|
year: now.getFullYear(),
|
||||||
|
month: now.getMonth() + 1,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildOverviewQuery(): FinanceSummaryQuery {
|
||||||
|
if (overviewPeriod.value === 'year') {
|
||||||
|
return { dimension: 'YEAR', year: now.getFullYear() }
|
||||||
|
}
|
||||||
|
const [year, month] = overviewPeriod.value.split('-').map(Number)
|
||||||
|
return {
|
||||||
|
dimension: 'MONTH',
|
||||||
|
year: year || now.getFullYear(),
|
||||||
|
month: month || now.getMonth() + 1,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadStats(): void {
|
||||||
|
void financeStore.fetchStats(buildChartQuery())
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadOverviewStats(): void {
|
||||||
|
void financeStore.fetchOverviewStats(buildOverviewQuery())
|
||||||
|
}
|
||||||
|
|
||||||
|
function onPeriodChange(period: FinancePeriod): void {
|
||||||
|
if (chartPeriod.value === period) return
|
||||||
|
chartPeriod.value = period
|
||||||
|
loadStats()
|
||||||
|
}
|
||||||
|
|
||||||
|
function onOverviewPeriodChange(period: string): void {
|
||||||
|
if (!period || period === overviewPeriod.value) return
|
||||||
|
overviewPeriod.value = period
|
||||||
|
// 只刷新累计消费总额,不动下方图表
|
||||||
|
loadOverviewStats()
|
||||||
|
}
|
||||||
|
|
||||||
|
function downloadBlob(blob: Blob, filename: string): void {
|
||||||
|
const url = URL.createObjectURL(blob)
|
||||||
|
const link = document.createElement('a')
|
||||||
|
link.href = url
|
||||||
|
link.download = filename
|
||||||
|
document.body.appendChild(link)
|
||||||
|
link.click()
|
||||||
|
link.remove()
|
||||||
|
URL.revokeObjectURL(url)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onExport(): Promise<void> {
|
async function onExport(): Promise<void> {
|
||||||
await financeStore.export()
|
try {
|
||||||
ElMessage.success('报表导出成功(演示)')
|
const blob = await financeStore.export('excel')
|
||||||
|
if (!blob || blob.size === 0) {
|
||||||
|
ElMessage.error('导出内容为空')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
downloadBlob(blob, `账单明细_${new Date().toISOString().slice(0, 10)}.xlsx`)
|
||||||
|
ElMessage.success('报表导出成功')
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
// 请求异常已由 request.ts 统一提示
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
void financeStore.fetchStats()
|
loadStats()
|
||||||
|
loadOverviewStats()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -43,32 +113,126 @@ onMounted(() => {
|
|||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="finance__top">
|
<div class="finance__top">
|
||||||
<FinanceOverview
|
<FinanceOverview
|
||||||
:stats="stats"
|
:stats="overviewStats"
|
||||||
@period-change="onPeriodChange"
|
:period="overviewPeriod"
|
||||||
|
@period-change="onOverviewPeriodChange"
|
||||||
@export="onExport"
|
@export="onExport"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div class="finance__entries">
|
<div class="finance__entries">
|
||||||
<template v-for="entry in ENTRIES" :key="entry.label">
|
<template v-for="entry in ENTRIES" :key="entry.key">
|
||||||
<RouterLink
|
<RouterLink
|
||||||
v-if="entry.to"
|
v-if="entry.to"
|
||||||
:to="entry.to"
|
:to="entry.to"
|
||||||
class="finance__entry"
|
class="finance__entry"
|
||||||
>
|
>
|
||||||
{{ entry.label }}
|
<span
|
||||||
|
class="finance__entry-icon"
|
||||||
|
:class="`finance__entry-icon--${entry.key}`"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
v-if="entry.key === 'bill'"
|
||||||
|
viewBox="0 0 20 20"
|
||||||
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
stroke-width="1.5"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
>
|
||||||
|
<rect
|
||||||
|
x="4"
|
||||||
|
y="2.5"
|
||||||
|
width="12"
|
||||||
|
height="15"
|
||||||
|
rx="1.5"
|
||||||
|
/>
|
||||||
|
<path d="M7 7h6M7 10h6M7 13h4" />
|
||||||
|
</svg>
|
||||||
|
<svg
|
||||||
|
v-else-if="entry.key === 'pending'"
|
||||||
|
viewBox="0 0 20 20"
|
||||||
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
stroke-width="1.5"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
>
|
||||||
|
<rect
|
||||||
|
x="2.5"
|
||||||
|
y="4.5"
|
||||||
|
width="15"
|
||||||
|
height="11"
|
||||||
|
rx="1.5"
|
||||||
|
/>
|
||||||
|
<path d="M2.5 8.5h15" />
|
||||||
|
</svg>
|
||||||
|
<svg
|
||||||
|
v-else-if="entry.key === 'invoice'"
|
||||||
|
viewBox="0 0 20 20"
|
||||||
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
stroke-width="1.5"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
>
|
||||||
|
<rect
|
||||||
|
x="4"
|
||||||
|
y="2.5"
|
||||||
|
width="12"
|
||||||
|
height="15"
|
||||||
|
rx="1.5"
|
||||||
|
/>
|
||||||
|
<path d="M7.5 7h5M7.5 10.5h5M7.5 14h2.5" />
|
||||||
|
</svg>
|
||||||
|
<svg
|
||||||
|
v-else
|
||||||
|
viewBox="0 0 20 20"
|
||||||
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
stroke-width="1.5"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
>
|
||||||
|
<path d="M10 13V4M6.5 7.5 10 4l3.5 3.5M4 15.5h12" />
|
||||||
|
</svg>
|
||||||
|
<i
|
||||||
|
v-if="entry.key === 'pending' && (stats?.pendingCount ?? 0) > 0"
|
||||||
|
class="finance__entry-badge"
|
||||||
|
>
|
||||||
|
{{ stats?.pendingCount }}
|
||||||
|
</i>
|
||||||
|
</span>
|
||||||
|
<span class="finance__entry-label">{{ entry.label }}</span>
|
||||||
</RouterLink>
|
</RouterLink>
|
||||||
<button
|
<button
|
||||||
v-else
|
v-else
|
||||||
class="finance__entry"
|
class="finance__entry"
|
||||||
@click="onExport"
|
@click="onExport"
|
||||||
>
|
>
|
||||||
{{ entry.label }}
|
<span class="finance__entry-icon finance__entry-icon--export">
|
||||||
|
<svg
|
||||||
|
viewBox="0 0 20 20"
|
||||||
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
stroke-width="1.5"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
>
|
||||||
|
<path d="M10 13V4M6.5 7.5 10 4l3.5 3.5M4 15.5h12" />
|
||||||
|
</svg>
|
||||||
|
</span>
|
||||||
|
<span class="finance__entry-label">{{ entry.label }}</span>
|
||||||
</button>
|
</button>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<FinanceChart :distribution="stats?.distribution ?? []" />
|
<FinanceChart
|
||||||
|
:distribution="stats?.distribution ?? []"
|
||||||
|
:monthly="stats?.monthly ?? []"
|
||||||
|
:period="chartPeriod"
|
||||||
|
@period-change="onPeriodChange"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -76,27 +240,32 @@ onMounted(() => {
|
|||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
.finance {
|
.finance {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
min-height: 100%;
|
||||||
|
padding-bottom: @spacing-page-bottom;
|
||||||
|
background: @bg-color;
|
||||||
|
|
||||||
&__top {
|
&__top {
|
||||||
.flex(row, flex-start, stretch);
|
.flex(row, flex-start, stretch);
|
||||||
gap: 14px;
|
gap: @spacing-base;
|
||||||
margin-top: -56px;
|
margin-top: @spacing-lg;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__entries {
|
&__entries {
|
||||||
.flex(row, space-between, center);
|
.flex(row, space-between, center);
|
||||||
flex: 0 0 672px;
|
flex: 0 0 672px;
|
||||||
height: 135px;
|
height: 135px;
|
||||||
padding: 0 34px;
|
padding: 0 66px;
|
||||||
border: 1px solid @finance-card-line;
|
border: none;
|
||||||
border-radius: @radius-base;
|
border-radius: @radius-base;
|
||||||
background: @white;
|
background: @white;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__entry {
|
&__entry {
|
||||||
.flex(row, center, center);
|
.flex(column, center, center);
|
||||||
height: 100%;
|
gap: 8px;
|
||||||
|
// 等宽保证 space-between 下四入口中心等距 161.5px(设计稿 #20)
|
||||||
|
width: 56px;
|
||||||
border: none;
|
border: none;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
color: @finance-entry-text;
|
color: @finance-entry-text;
|
||||||
@@ -110,5 +279,56 @@ onMounted(() => {
|
|||||||
color: @primary-strong;
|
color: @primary-strong;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&__entry-icon {
|
||||||
|
position: relative;
|
||||||
|
.flex(row, center, center);
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
border-radius: 10px;
|
||||||
|
|
||||||
|
svg {
|
||||||
|
width: 20px;
|
||||||
|
height: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&--bill {
|
||||||
|
background: @finance-entry-bill-bg;
|
||||||
|
color: @finance-entry-bill-icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
&--pending {
|
||||||
|
background: @finance-entry-pending-bg;
|
||||||
|
color: @finance-pending;
|
||||||
|
}
|
||||||
|
|
||||||
|
&--invoice {
|
||||||
|
background: @finance-entry-invoice-bg;
|
||||||
|
color: @finance-entry-invoice-icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
&--export {
|
||||||
|
background: @finance-entry-export-bg;
|
||||||
|
color: @finance-paid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&__entry-badge {
|
||||||
|
position: absolute;
|
||||||
|
top: -7px;
|
||||||
|
// 设计稿 #20:badge 叠在图标右上内侧(右缘距图标右约 7px)
|
||||||
|
right: 7px;
|
||||||
|
min-width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
padding: 0 4px;
|
||||||
|
border-radius: 8px;
|
||||||
|
background: @finance-entry-badge-bg;
|
||||||
|
color: @white;
|
||||||
|
font-size: 9px;
|
||||||
|
font-style: normal;
|
||||||
|
line-height: 16px;
|
||||||
|
text-align: center;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, onMounted, ref } from 'vue'
|
import { computed, onMounted, ref } from 'vue'
|
||||||
import { storeToRefs } from 'pinia'
|
import { storeToRefs } from 'pinia'
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage, ElButton, ElPagination } from 'element-plus'
|
||||||
import { ConfirmDialog } from '@/components'
|
import { ConfirmDialog } from '@/components'
|
||||||
import { useFinanceStore } from '@/stores/modules/finance'
|
import { useFinanceStore } from '@/stores/modules/finance'
|
||||||
import type { InvoiceTitle, InvoiceTitlePayload } from '@/types/business/finance'
|
import type { InvoiceTitle, InvoiceTitlePayload } from '@/types/business/finance'
|
||||||
@@ -24,7 +24,6 @@ const pageCount = computed(() => Math.max(1, Math.ceil(titles.value.length / PAG
|
|||||||
const pagedTitles = computed(() =>
|
const pagedTitles = computed(() =>
|
||||||
titles.value.slice((page.value - 1) * PAGE_SIZE, page.value * PAGE_SIZE),
|
titles.value.slice((page.value - 1) * PAGE_SIZE, page.value * PAGE_SIZE),
|
||||||
)
|
)
|
||||||
const pages = computed(() => Array.from({ length: Math.max(5, pageCount.value) }, (_, i) => i + 1))
|
|
||||||
|
|
||||||
function go(next: number): void {
|
function go(next: number): void {
|
||||||
if (next < 1 || next > pageCount.value) return
|
if (next < 1 || next > pageCount.value) return
|
||||||
@@ -42,13 +41,18 @@ function onEdit(item: InvoiceTitle): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function onSave(payload: InvoiceTitlePayload): Promise<void> {
|
async function onSave(payload: InvoiceTitlePayload): Promise<void> {
|
||||||
if (editing.value) {
|
try {
|
||||||
await financeStore.updateTitle(editing.value.id, payload)
|
if (editing.value) {
|
||||||
ElMessage.success('抬头已更新')
|
await financeStore.updateTitle(editing.value.id, payload)
|
||||||
|
ElMessage.success('抬头已更新')
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
await financeStore.createTitle(payload)
|
||||||
|
ElMessage.success('抬头已新增')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
catch {
|
||||||
await financeStore.createTitle(payload)
|
// 请求异常已由 request.ts 统一提示
|
||||||
ElMessage.success('抬头已新增')
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,16 +62,27 @@ function onDelete(id: string): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function onConfirmDelete(): Promise<void> {
|
async function onConfirmDelete(): Promise<void> {
|
||||||
await financeStore.deleteTitle(pendingDeleteId.value)
|
try {
|
||||||
pendingDeleteId.value = ''
|
await financeStore.deleteTitle(pendingDeleteId.value)
|
||||||
ElMessage.success('抬头已删除')
|
pendingDeleteId.value = ''
|
||||||
|
if (page.value > pageCount.value) page.value = pageCount.value
|
||||||
|
ElMessage.success('抬头已删除')
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
// 请求异常已由 request.ts 统一提示
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onSetDefault(id: string): Promise<void> {
|
async function onSetDefault(id: string): Promise<void> {
|
||||||
const item = titles.value.find((title) => title.id === id)
|
const item = titles.value.find((title) => title.id === id)
|
||||||
if (!item) return
|
if (!item || item.isDefault) return
|
||||||
await financeStore.setDefaultTitle(id)
|
try {
|
||||||
ElMessage.success(item.isDefault ? '已取消默认抬头' : '已设为默认抬头')
|
await financeStore.setDefaultTitle(id)
|
||||||
|
ElMessage.success('已设为默认抬头')
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
// 请求异常已由 request.ts 统一提示
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
@@ -89,9 +104,9 @@ onMounted(() => {
|
|||||||
<h2 class="invoice-titles__title">
|
<h2 class="invoice-titles__title">
|
||||||
发票管理
|
发票管理
|
||||||
</h2>
|
</h2>
|
||||||
<button class="invoice-titles__create" @click="onCreate">
|
<el-button class="invoice-titles__create" @click="onCreate">
|
||||||
+ 新增抬头
|
+ 新增抬头
|
||||||
</button>
|
</el-button>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<div class="invoice-titles__list">
|
<div class="invoice-titles__list">
|
||||||
@@ -108,23 +123,14 @@ onMounted(() => {
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<nav class="invoice-titles__pager" aria-label="分页">
|
<el-pagination
|
||||||
<button class="invoice-titles__page" :disabled="page <= 1" @click="go(page - 1)">
|
class="invoice-titles__pager"
|
||||||
‹
|
layout="prev, pager, next"
|
||||||
</button>
|
:page-size="PAGE_SIZE"
|
||||||
<button
|
:total="titles.length"
|
||||||
v-for="item in pages"
|
:current-page="page"
|
||||||
:key="item"
|
@current-change="go"
|
||||||
class="invoice-titles__page"
|
/>
|
||||||
:class="{ 'is-active': item === page }"
|
|
||||||
@click="go(item)"
|
|
||||||
>
|
|
||||||
{{ item }}
|
|
||||||
</button>
|
|
||||||
<button class="invoice-titles__page" :disabled="page >= pageCount" @click="go(page + 1)">
|
|
||||||
›
|
|
||||||
</button>
|
|
||||||
</nav>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<InvoiceTitleDialog
|
<InvoiceTitleDialog
|
||||||
@@ -147,16 +153,17 @@ onMounted(() => {
|
|||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
.invoice-titles {
|
.invoice-titles {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding-bottom: 459px;
|
min-height: 100%;
|
||||||
background: @contract-page-bg;
|
padding-bottom: @spacing-page-bottom;
|
||||||
|
background: @bg-color;
|
||||||
|
|
||||||
&__breadcrumb {
|
&__breadcrumb {
|
||||||
.flex(row, flex-start, center);
|
.flex(row, flex-start, center);
|
||||||
height: 81px;
|
min-height: 48px;
|
||||||
padding-top: 36px;
|
padding-top: @spacing-lg;
|
||||||
font-size: 13px;
|
font-size: @font-size-sm;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
line-height: 17px;
|
line-height: 1.5;
|
||||||
color: @project-muted;
|
color: @project-muted;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
@@ -177,9 +184,9 @@ onMounted(() => {
|
|||||||
|
|
||||||
&__head {
|
&__head {
|
||||||
.flex(row, space-between, center);
|
.flex(row, space-between, center);
|
||||||
height: 62px;
|
min-height: 56px;
|
||||||
padding: 0 33.56px 0 36px;
|
padding: 0 @spacing-lg;
|
||||||
border: 1px solid @finance-card-line;
|
border: none;
|
||||||
border-radius: @radius-base;
|
border-radius: @radius-base;
|
||||||
background: @white;
|
background: @white;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
@@ -197,6 +204,7 @@ onMounted(() => {
|
|||||||
height: 34px;
|
height: 34px;
|
||||||
margin-right: -5px;
|
margin-right: -5px;
|
||||||
border: none;
|
border: none;
|
||||||
|
padding: 0;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
background: @primary-strong;
|
background: @primary-strong;
|
||||||
color: @white;
|
color: @white;
|
||||||
@@ -223,33 +231,34 @@ onMounted(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
&__pager {
|
&__pager {
|
||||||
.flex(row, flex-end, center);
|
|
||||||
gap: 3.7px;
|
|
||||||
margin-top: 8px;
|
margin-top: 8px;
|
||||||
padding-right: 2.4px;
|
padding-right: 2.4px;
|
||||||
}
|
justify-content: flex-end;
|
||||||
|
|
||||||
&__page {
|
:deep(.el-pagination button),
|
||||||
min-width: 21.45px;
|
:deep(.el-pagination .el-pager li) {
|
||||||
height: 16px;
|
min-width: 21.45px;
|
||||||
padding: 0 3px;
|
height: 16px;
|
||||||
border: none;
|
padding: 0 3px;
|
||||||
border-radius: 0;
|
border: none;
|
||||||
background: transparent;
|
border-radius: 0;
|
||||||
color: @finance-muted-text;
|
background: transparent;
|
||||||
font-size: 12px;
|
color: @finance-muted-text;
|
||||||
font-weight: 400;
|
font-size: 12px;
|
||||||
transition: color 0.2s;
|
font-weight: 400;
|
||||||
|
transition: color 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
&:hover:not(:disabled) {
|
:deep(.el-pagination .el-pager li.is-active) {
|
||||||
|
color: @primary-strong;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.el-pagination button:hover:not(:disabled)) {
|
||||||
color: @primary-strong;
|
color: @primary-strong;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.is-active {
|
:deep(.el-pagination button:disabled) {
|
||||||
color: @primary-strong;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:disabled {
|
|
||||||
cursor: not-allowed;
|
cursor: not-allowed;
|
||||||
opacity: 0.5;
|
opacity: 0.5;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,86 +1,166 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, onMounted, ref } from 'vue'
|
import { computed, onMounted, ref } from 'vue'
|
||||||
import { storeToRefs } from 'pinia'
|
import { storeToRefs } from 'pinia'
|
||||||
import { RouterLink } from 'vue-router'
|
import { RouterLink, useRoute, useRouter } from 'vue-router'
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage, ElMessageBox, ElButton, ElTable, ElTableColumn } from 'element-plus'
|
||||||
import { FilterPanel, PaginationBar, StatusTag } from '@/components'
|
import { PaginationBar, StatusTag } from '@/components'
|
||||||
import { useFinanceStore } from '@/stores/modules/finance'
|
import { useFinanceStore } from '@/stores/modules/finance'
|
||||||
import type { Invoice, InvoiceStatus } from '@/types/business/finance'
|
import { useProfileStore } from '@/stores/modules/profile'
|
||||||
|
import type { Invoice, InvoiceApplyPayload, InvoiceStatus } from '@/types/business/finance'
|
||||||
import { formatMoney } from '@/utils/format'
|
import { formatMoney } from '@/utils/format'
|
||||||
|
import { INVOICE_TYPE_LABELS } from '@/utils/invoiceVo'
|
||||||
|
import InvoiceApplyDialog from './cpns/InvoiceApplyDialog.vue'
|
||||||
|
|
||||||
|
const router = useRouter()
|
||||||
|
const route = useRoute()
|
||||||
|
|
||||||
const financeStore = useFinanceStore()
|
const financeStore = useFinanceStore()
|
||||||
const { titles, invoices, invoiceQuery, invoiceTotal } = storeToRefs(financeStore)
|
const { titles, invoices, invoiceQuery, invoiceTotal, availableBills, invoiceStatusOptions } = storeToRefs(financeStore)
|
||||||
|
|
||||||
const keyword = ref('')
|
const profileStore = useProfileStore()
|
||||||
const selectedIds = ref<string[]>([])
|
const { profile } = storeToRefs(profileStore)
|
||||||
|
|
||||||
|
const applyVisible = ref(false)
|
||||||
|
const applying = ref(false)
|
||||||
|
const applyBillId = ref<string | undefined>(undefined)
|
||||||
|
|
||||||
const defaultTitle = computed(() => titles.value.find((item) => item.isDefault) ?? titles.value[0] ?? null)
|
const defaultTitle = computed(() => titles.value.find((item) => item.isDefault) ?? titles.value[0] ?? null)
|
||||||
|
|
||||||
const STATUS_TABS: Array<{ label: string; value: InvoiceStatus | 'all' }> = [
|
type TagVariant = 'primary' | 'success' | 'warning' | 'danger' | 'info'
|
||||||
{ label: '全部', value: 'all' },
|
|
||||||
{ label: '已开票', value: '已开票' },
|
|
||||||
{ label: '开票中', value: '开票中' },
|
|
||||||
{ label: '未开票', value: '未开票' },
|
|
||||||
]
|
|
||||||
|
|
||||||
const STATUS_VARIANTS: Record<InvoiceStatus, 'success' | 'warning' | 'info'> = {
|
/** 发票状态选项卡:字典 + 首项「全部」(value 为空,表示不传 status)。 */
|
||||||
已开票: 'success',
|
const STATUS_TABS = computed<Array<{ label: string; value: InvoiceStatus | '' }>>(() => [
|
||||||
开票中: 'warning',
|
{ label: '全部', value: '' },
|
||||||
未开票: 'info',
|
...invoiceStatusOptions.value.map((item) => ({
|
||||||
|
label: item.dictLabel,
|
||||||
|
value: item.dictValue as InvoiceStatus,
|
||||||
|
})),
|
||||||
|
])
|
||||||
|
|
||||||
|
/** 状态文案优先用后端 statusName,缺失时回退字典文案。 */
|
||||||
|
function statusLabel(invoice: Invoice): string {
|
||||||
|
return invoice.statusName
|
||||||
|
|| invoiceStatusOptions.value.find((item) => item.dictValue === invoice.status)?.dictLabel
|
||||||
|
|| '—'
|
||||||
}
|
}
|
||||||
|
|
||||||
function onTab(value: InvoiceStatus | 'all'): void {
|
/** 标签颜色取字典 listClass(info/warning/success)。 */
|
||||||
|
function statusVariant(status: InvoiceStatus): TagVariant {
|
||||||
|
const listClass = invoiceStatusOptions.value.find((item) => item.dictValue === status)?.listClass
|
||||||
|
if (listClass === 'primary' || listClass === 'success' || listClass === 'warning' || listClass === 'danger') {
|
||||||
|
return listClass
|
||||||
|
}
|
||||||
|
return 'info'
|
||||||
|
}
|
||||||
|
|
||||||
|
function onTab(value: InvoiceStatus | ''): void {
|
||||||
if (invoiceQuery.value.status === value) return
|
if (invoiceQuery.value.status === value) return
|
||||||
financeStore.setInvoiceQuery({ ...invoiceQuery.value, status: value, keyword: keyword.value })
|
financeStore.setInvoiceQuery({ ...invoiceQuery.value, status: value })
|
||||||
selectedIds.value = []
|
|
||||||
void financeStore.searchInvoices()
|
void financeStore.searchInvoices()
|
||||||
}
|
}
|
||||||
|
|
||||||
function onSearch(): void {
|
|
||||||
financeStore.setInvoiceQuery({ ...invoiceQuery.value, keyword: keyword.value })
|
|
||||||
void financeStore.searchInvoices()
|
|
||||||
}
|
|
||||||
|
|
||||||
function onReset(): void {
|
|
||||||
keyword.value = ''
|
|
||||||
selectedIds.value = []
|
|
||||||
financeStore.setInvoiceQuery({ keyword: '', status: 'all', page: 1, pageSize: invoiceQuery.value.pageSize })
|
|
||||||
void financeStore.fetchInvoices()
|
|
||||||
}
|
|
||||||
|
|
||||||
function onPageChange(page: number): void {
|
function onPageChange(page: number): void {
|
||||||
void financeStore.changeInvoicePage(page)
|
void financeStore.changeInvoicePage(page)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onApply(invoice: Invoice): Promise<void> {
|
async function onOpenApply(billId?: string): Promise<void> {
|
||||||
await financeStore.applyInvoice(invoice.id)
|
applyBillId.value = billId || undefined
|
||||||
ElMessage.success('开票申请已提交')
|
try {
|
||||||
}
|
await financeStore.fetchAvailableBills()
|
||||||
|
applyVisible.value = true
|
||||||
function onPreview(): void {
|
|
||||||
ElMessage.info('附件待接口接入')
|
|
||||||
}
|
|
||||||
|
|
||||||
function onDownload(): void {
|
|
||||||
ElMessage.info('附件待接口接入')
|
|
||||||
}
|
|
||||||
|
|
||||||
function onSendEmail(): void {
|
|
||||||
ElMessage.success('发票已发送至绑定邮箱(演示)')
|
|
||||||
}
|
|
||||||
|
|
||||||
function onToggleSelect(id: string): void {
|
|
||||||
if (selectedIds.value.includes(id)) {
|
|
||||||
selectedIds.value = selectedIds.value.filter((item) => item !== id)
|
|
||||||
}
|
}
|
||||||
else {
|
catch {
|
||||||
selectedIds.value = [...selectedIds.value, id]
|
// 请求异常已由 request.ts 统一提示
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function onSubmitApply(payload: InvoiceApplyPayload): Promise<void> {
|
||||||
|
applying.value = true
|
||||||
|
try {
|
||||||
|
await financeStore.applyInvoice(payload)
|
||||||
|
applyVisible.value = false
|
||||||
|
ElMessage.success('开票申请已提交')
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
// 请求异常已由 request.ts 统一提示
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
applying.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 已驳回的发票可重新发起开票申请。 */
|
||||||
|
function onApplyForRow(invoice: Invoice): void {
|
||||||
|
void onOpenApply(invoice.billId)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function onPreview(invoice: Invoice): Promise<void> {
|
||||||
|
try {
|
||||||
|
const url = await financeStore.fetchPreviewUrl(invoice.id)
|
||||||
|
if (!url) {
|
||||||
|
ElMessage.warning('暂无可预览的发票文件')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
window.open(url, '_blank', 'noopener')
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
// 请求异常已由 request.ts 统一提示
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function onDownload(invoice: Invoice): Promise<void> {
|
||||||
|
try {
|
||||||
|
const { blob, fileName } = await financeStore.fetchDownloadFile(invoice.id)
|
||||||
|
if (!blob || blob.size === 0) {
|
||||||
|
ElMessage.warning('暂无可下载的发票文件')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const url = URL.createObjectURL(blob)
|
||||||
|
const link = document.createElement('a')
|
||||||
|
link.href = url
|
||||||
|
link.download = fileName || `${invoice.invoiceNo || 'invoice'}.pdf`
|
||||||
|
document.body.appendChild(link)
|
||||||
|
link.click()
|
||||||
|
link.remove()
|
||||||
|
URL.revokeObjectURL(url)
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
// 请求异常已由 request.ts 统一提示
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function onSendEmail(invoice: Invoice): Promise<void> {
|
||||||
|
if (!profile.value?.email) {
|
||||||
|
try {
|
||||||
|
await ElMessageBox.confirm('您还未绑定邮箱,请先绑定邮箱后再发送发票', '提示', {
|
||||||
|
confirmButtonText: '去绑定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
void router.push({ name: 'ProfileBindEmail', query: { redirect: route.fullPath } })
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
// 用户取消
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await financeStore.sendInvoiceEmail(invoice.id)
|
||||||
|
ElMessage.success('发票已发送至绑定邮箱')
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
// 请求异常已由 request.ts 统一提示
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
keyword.value = invoiceQuery.value.keyword
|
void Promise.all([
|
||||||
void Promise.all([financeStore.fetchTitles(), financeStore.fetchInvoices()])
|
financeStore.fetchInvoiceStatusOptions(),
|
||||||
|
financeStore.fetchTitles(),
|
||||||
|
financeStore.fetchInvoices(),
|
||||||
|
profileStore.fetchProfile().catch(() => null),
|
||||||
|
])
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -113,87 +193,146 @@ onMounted(() => {
|
|||||||
</RouterLink>
|
</RouterLink>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<div class="invoices__tabs">
|
<div class="invoices__toolbar">
|
||||||
<button
|
<div class="invoices__tabs">
|
||||||
v-for="tab in STATUS_TABS"
|
<el-button
|
||||||
:key="tab.value"
|
v-for="tab in STATUS_TABS"
|
||||||
class="invoices__tab"
|
:key="tab.value"
|
||||||
:class="{ 'is-active': invoiceQuery.status === tab.value }"
|
class="invoices__tab"
|
||||||
@click="onTab(tab.value)"
|
:class="{ 'is-active': invoiceQuery.status === tab.value }"
|
||||||
>
|
@click="onTab(tab.value)"
|
||||||
{{ tab.label }}
|
>
|
||||||
</button>
|
{{ tab.label }}
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<el-button class="invoices__apply" @click="onOpenApply()">
|
||||||
|
+ 申请开票
|
||||||
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<FilterPanel
|
|
||||||
v-model:keyword="keyword"
|
|
||||||
keyword-placeholder="搜索发票抬头 / 账单号 / 项目名称"
|
|
||||||
@search="onSearch"
|
|
||||||
@reset="onReset"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div class="invoices__table card">
|
<div class="invoices__table card">
|
||||||
<table class="invoices__table-el">
|
<el-table
|
||||||
<thead>
|
class="invoices__table-el"
|
||||||
<tr>
|
:data="invoices"
|
||||||
<th class="invoices__check">
|
row-key="id"
|
||||||
多选
|
>
|
||||||
</th>
|
<el-table-column
|
||||||
<th>序号</th>
|
type="index"
|
||||||
<th>账单名称</th>
|
label="序号"
|
||||||
<th>账单号</th>
|
width="60"
|
||||||
<th>交易流水号</th>
|
/>
|
||||||
<th>项目名称</th>
|
<el-table-column
|
||||||
<th>订单金额</th>
|
label="发票号码"
|
||||||
<th>状态</th>
|
min-width="150"
|
||||||
<th>申请时间</th>
|
show-overflow-tooltip
|
||||||
<th>操作</th>
|
>
|
||||||
</tr>
|
<template #default="{ row }">
|
||||||
</thead>
|
{{ (row as Invoice).invoiceNo || '—' }}
|
||||||
<tbody>
|
</template>
|
||||||
<tr v-for="(invoice, index) in invoices" :key="invoice.id">
|
</el-table-column>
|
||||||
<td class="invoices__check">
|
<el-table-column
|
||||||
<input
|
prop="projectName"
|
||||||
type="checkbox"
|
label="项目名称"
|
||||||
:checked="selectedIds.includes(invoice.id)"
|
min-width="160"
|
||||||
@change="onToggleSelect(invoice.id)"
|
show-overflow-tooltip
|
||||||
>
|
/>
|
||||||
</td>
|
<el-table-column
|
||||||
<td>{{ index + 1 }}</td>
|
prop="titleName"
|
||||||
<td>{{ invoice.planName }}</td>
|
label="发票抬头"
|
||||||
<td>{{ invoice.billNo }}</td>
|
min-width="180"
|
||||||
<td>{{ invoice.tradeNo ?? '—' }}</td>
|
show-overflow-tooltip
|
||||||
<td>{{ invoice.projectName }}</td>
|
/>
|
||||||
<td class="invoices__amount">¥{{ formatMoney(invoice.amount) }}</td>
|
<el-table-column
|
||||||
<td>
|
label="发票类型"
|
||||||
<StatusTag :label="invoice.status" :variant="STATUS_VARIANTS[invoice.status]" />
|
width="100"
|
||||||
</td>
|
>
|
||||||
<td>{{ invoice.applyTime }}</td>
|
<template #default="{ row }">
|
||||||
<td class="invoices__ops">
|
{{ INVOICE_TYPE_LABELS[(row as Invoice).invoiceType ?? ''] ?? '—' }}
|
||||||
<template v-if="invoice.status === '已开票'">
|
</template>
|
||||||
<button class="invoices__link" @click="onPreview">
|
</el-table-column>
|
||||||
|
<el-table-column
|
||||||
|
label="开票金额"
|
||||||
|
width="110"
|
||||||
|
>
|
||||||
|
<template #default="{ row }">
|
||||||
|
<span class="invoices__amount">¥{{ formatMoney((row as Invoice).amount) }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column
|
||||||
|
prop="transactionNo"
|
||||||
|
label="交易流水号"
|
||||||
|
min-width="180"
|
||||||
|
show-overflow-tooltip
|
||||||
|
/>
|
||||||
|
<el-table-column
|
||||||
|
label="状态"
|
||||||
|
width="90"
|
||||||
|
>
|
||||||
|
<template #default="{ row }">
|
||||||
|
<StatusTag
|
||||||
|
:label="statusLabel(row as Invoice)"
|
||||||
|
:variant="statusVariant((row as Invoice).status)"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column
|
||||||
|
prop="applyTime"
|
||||||
|
label="申请时间"
|
||||||
|
width="140"
|
||||||
|
show-overflow-tooltip
|
||||||
|
/>
|
||||||
|
<el-table-column
|
||||||
|
label="操作"
|
||||||
|
width="180"
|
||||||
|
fixed="right"
|
||||||
|
>
|
||||||
|
<template #default="{ row }">
|
||||||
|
<span class="invoices__ops">
|
||||||
|
<template v-if="(row as Invoice).status === '2'">
|
||||||
|
<el-button
|
||||||
|
link
|
||||||
|
type="primary"
|
||||||
|
class="invoices__link"
|
||||||
|
@click="onPreview(row as Invoice)"
|
||||||
|
>
|
||||||
预览
|
预览
|
||||||
</button>
|
</el-button>
|
||||||
<button class="invoices__link" @click="onDownload">
|
<el-button
|
||||||
|
link
|
||||||
|
type="primary"
|
||||||
|
class="invoices__link"
|
||||||
|
@click="onDownload(row as Invoice)"
|
||||||
|
>
|
||||||
下载
|
下载
|
||||||
</button>
|
</el-button>
|
||||||
<button class="invoices__link" @click="onSendEmail">
|
<el-button
|
||||||
|
link
|
||||||
|
type="primary"
|
||||||
|
class="invoices__link"
|
||||||
|
@click="onSendEmail(row as Invoice)"
|
||||||
|
>
|
||||||
发送邮箱
|
发送邮箱
|
||||||
</button>
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
<span v-else-if="invoice.status === '开票中'" class="invoices__dash">—</span>
|
<el-button
|
||||||
<button v-else class="invoices__link" @click="onApply(invoice)">
|
v-else-if="(row as Invoice).status === '0'"
|
||||||
|
link
|
||||||
|
type="primary"
|
||||||
|
class="invoices__link"
|
||||||
|
@click="onApplyForRow(row as Invoice)"
|
||||||
|
>
|
||||||
申请开票
|
申请开票
|
||||||
</button>
|
</el-button>
|
||||||
</td>
|
<span v-else class="invoices__dash">—</span>
|
||||||
</tr>
|
</span>
|
||||||
<tr v-if="invoices.length === 0">
|
</template>
|
||||||
<td colspan="10" class="invoices__empty text-secondary">
|
</el-table-column>
|
||||||
暂无发票记录
|
|
||||||
</td>
|
<template #empty>
|
||||||
</tr>
|
<span class="invoices__empty text-secondary">暂无发票记录</span>
|
||||||
</tbody>
|
</template>
|
||||||
</table>
|
</el-table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<PaginationBar
|
<PaginationBar
|
||||||
@@ -204,8 +343,18 @@ onMounted(() => {
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<p class="invoices__tip text-secondary">
|
<p class="invoices__tip text-secondary">
|
||||||
开票将使用默认抬头,如需调整请前往 <RouterLink to="/finance/invoice-titles" class="link">管理抬头</RouterLink>。
|
仅已支付且未开票的账单可申请开票,开票进度可在本页查看。抬头管理请前往
|
||||||
|
<RouterLink to="/finance/invoice-titles" class="link">管理抬头</RouterLink>。
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<InvoiceApplyDialog
|
||||||
|
v-model:visible="applyVisible"
|
||||||
|
:bills="availableBills"
|
||||||
|
:titles="titles"
|
||||||
|
:preselect-bill-id="applyBillId"
|
||||||
|
:submitting="applying"
|
||||||
|
@submit="onSubmitApply"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -216,8 +365,10 @@ onMounted(() => {
|
|||||||
gap: @spacing-base;
|
gap: @spacing-base;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-width: @container-width;
|
max-width: @container-width;
|
||||||
|
min-height: 100%;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
padding: @spacing-lg @spacing-base @spacing-xxl;
|
padding: @spacing-lg @spacing-base @spacing-page-bottom;
|
||||||
|
background: @bg-color;
|
||||||
|
|
||||||
&__breadcrumb {
|
&__breadcrumb {
|
||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
@@ -270,30 +421,64 @@ onMounted(() => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&__toolbar {
|
||||||
|
.flex(row, space-between, center);
|
||||||
|
gap: @spacing-base;
|
||||||
|
}
|
||||||
|
|
||||||
&__tabs {
|
&__tabs {
|
||||||
.flex(row, flex-start);
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: flex-start;
|
||||||
gap: @spacing-sm;
|
gap: @spacing-sm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&__apply {
|
||||||
|
height: 34px;
|
||||||
|
padding: 0 @spacing-base;
|
||||||
|
border: none;
|
||||||
|
border-radius: @radius-base;
|
||||||
|
background: @primary-strong;
|
||||||
|
color: @white;
|
||||||
|
font-size: @font-size-base;
|
||||||
|
font-weight: 500;
|
||||||
|
transition: background 0.2s;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: @primary-color;
|
||||||
|
color: @white;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
&__tab {
|
&__tab {
|
||||||
height: 34px;
|
height: 34px;
|
||||||
|
margin: 0;
|
||||||
padding: 0 @spacing-base;
|
padding: 0 @spacing-base;
|
||||||
border: 1px solid @border-color;
|
border: 1px solid @border-color;
|
||||||
border-radius: @radius-base;
|
border-radius: @radius-base;
|
||||||
background: @white;
|
background: @white;
|
||||||
color: @text-color;
|
color: @text-color;
|
||||||
font-size: @font-size-base;
|
font-size: @font-size-base;
|
||||||
|
font-weight: 400;
|
||||||
transition: all 0.2s;
|
transition: all 0.2s;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
border-color: @primary-color;
|
border-color: @primary-color;
|
||||||
|
background: @white;
|
||||||
color: @primary-color;
|
color: @primary-color;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.is-active {
|
&.is-active {
|
||||||
border-color: @primary-color;
|
border-color: @primary-color;
|
||||||
background: @primary-color;
|
background: @filter-selected-bg;
|
||||||
color: @white;
|
color: @primary-color;
|
||||||
|
font-weight: 500;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
border-color: @primary-color;
|
||||||
|
background: @filter-selected-bg;
|
||||||
|
color: @primary-color;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -307,32 +492,35 @@ onMounted(() => {
|
|||||||
|
|
||||||
&__table-el {
|
&__table-el {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
border-collapse: collapse;
|
|
||||||
font-size: @font-size-base;
|
font-size: @font-size-base;
|
||||||
color: @text-color;
|
color: @text-color;
|
||||||
|
|
||||||
th,
|
:deep(th.el-table__cell) {
|
||||||
td {
|
background: @bg-color-light;
|
||||||
padding: @spacing-sm;
|
|
||||||
text-align: left;
|
|
||||||
white-space: nowrap;
|
|
||||||
border-bottom: 1px solid @border-color;
|
border-bottom: 1px solid @border-color;
|
||||||
}
|
|
||||||
|
|
||||||
th {
|
|
||||||
background: @bg-color-light;
|
|
||||||
color: @text-color-secondary;
|
color: @text-color-secondary;
|
||||||
|
font-size: @font-size-base;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
tbody tr:hover {
|
:deep(td.el-table__cell) {
|
||||||
|
padding: @spacing-sm 0;
|
||||||
|
border-bottom: 1px solid @border-color;
|
||||||
|
font-size: @font-size-base;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.el-table__body tr:hover > td.el-table__cell) {
|
||||||
background: @bg-color-light;
|
background: @bg-color-light;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
&__check {
|
:deep(.el-table .cell) {
|
||||||
width: 48px;
|
padding-left: @spacing-sm;
|
||||||
text-align: center;
|
padding-right: @spacing-sm;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&__amount {
|
&__amount {
|
||||||
@@ -341,17 +529,23 @@ onMounted(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
&__ops {
|
&__ops {
|
||||||
.flex(row, flex-start);
|
display: inline-flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
gap: @spacing-sm;
|
gap: @spacing-sm;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__link {
|
&__link {
|
||||||
|
padding: 0;
|
||||||
|
border: none;
|
||||||
|
background: transparent;
|
||||||
color: @primary-color;
|
color: @primary-color;
|
||||||
font-size: @font-size-base;
|
font-size: @font-size-base;
|
||||||
transition: color 0.2s;
|
transition: color 0.2s;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
color: @primary-hover;
|
color: @primary-hover;
|
||||||
|
background: transparent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
import { computed, onMounted } from 'vue'
|
import { computed, onMounted } from 'vue'
|
||||||
import { storeToRefs } from 'pinia'
|
import { storeToRefs } from 'pinia'
|
||||||
import { useRoute, useRouter } from 'vue-router'
|
import { useRoute, useRouter } from 'vue-router'
|
||||||
|
import { ElButton } from 'element-plus'
|
||||||
import { useFinanceStore } from '@/stores/modules/finance'
|
import { useFinanceStore } from '@/stores/modules/finance'
|
||||||
import { formatMoney } from '@/utils/format'
|
import { formatMoney } from '@/utils/format'
|
||||||
|
|
||||||
@@ -12,18 +13,25 @@ const { result } = storeToRefs(financeStore)
|
|||||||
|
|
||||||
const billId = computed(() => String(route.params.id))
|
const billId = computed(() => String(route.params.id))
|
||||||
|
|
||||||
const requirementId = computed(() => {
|
const outTradeNo = computed(() => {
|
||||||
const raw = route.query.requirementId
|
const raw = route.query.outTradeNo
|
||||||
return String(Array.isArray(raw) ? raw[0] : (raw ?? '')).trim()
|
return String(Array.isArray(raw) ? raw[0] : (raw ?? '')).trim()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const ids = computed(() => {
|
||||||
|
const raw = route.query.ids
|
||||||
|
const text = Array.isArray(raw) ? raw.join(',') : String(raw ?? '')
|
||||||
|
const list = text.split(',').map((id) => id.trim()).filter(Boolean)
|
||||||
|
return list.length > 0 ? list : [billId.value]
|
||||||
|
})
|
||||||
|
|
||||||
const methodLabel = computed(() => {
|
const methodLabel = computed(() => {
|
||||||
if (!result.value) return '—'
|
if (!result.value) return '—'
|
||||||
return result.value.method === 'wechat' ? '微信支付' : '支付宝支付'
|
return result.value.method === 'wechat' ? '微信支付' : '支付宝支付'
|
||||||
})
|
})
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
void financeStore.fetchResult(billId.value, requirementId.value)
|
void financeStore.fetchResult(outTradeNo.value, ids.value)
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -110,13 +118,12 @@ onMounted(() => {
|
|||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<div class="pay-result__footer">
|
<div class="pay-result__footer">
|
||||||
<button
|
<el-button
|
||||||
class="pay-result__back"
|
class="pay-result__back"
|
||||||
type="button"
|
@click="router.push('/finance/bills')"
|
||||||
@click="router.push('/finance/bills')"
|
>
|
||||||
>
|
返回
|
||||||
返回
|
</el-button>
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</template>
|
</template>
|
||||||
@@ -131,15 +138,16 @@ onMounted(() => {
|
|||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
.pay-result {
|
.pay-result {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding-bottom: 344px;
|
min-height: 100%;
|
||||||
background: @contract-page-bg;
|
padding-bottom: @spacing-page-bottom;
|
||||||
|
background: @bg-color;
|
||||||
|
|
||||||
&__breadcrumb {
|
&__breadcrumb {
|
||||||
.flex(row, flex-start, center);
|
.flex(row, flex-start, center);
|
||||||
padding-top: 22px;
|
padding-top: @spacing-lg;
|
||||||
font-size: 13px;
|
font-size: @font-size-sm;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
line-height: 17px;
|
line-height: 1.5;
|
||||||
color: @project-muted;
|
color: @project-muted;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,13 +172,13 @@ onMounted(() => {
|
|||||||
|
|
||||||
&__check {
|
&__check {
|
||||||
.flex(row, center, center);
|
.flex(row, center, center);
|
||||||
width: 120px;
|
width: 72px;
|
||||||
height: 120px;
|
height: 72px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
background: @finance-result-circle;
|
background: @finance-result-circle;
|
||||||
color: @white;
|
color: @white;
|
||||||
font-size: 56px;
|
font-size: @font-size-hero;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
line-height: 1;
|
line-height: 1;
|
||||||
}
|
}
|
||||||
@@ -311,6 +319,7 @@ onMounted(() => {
|
|||||||
width: 84px;
|
width: 84px;
|
||||||
height: 32px;
|
height: 32px;
|
||||||
border: none;
|
border: none;
|
||||||
|
padding: 0;
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
background: @primary-strong;
|
background: @primary-strong;
|
||||||
color: @white;
|
color: @white;
|
||||||
|
|||||||
@@ -1,62 +1,56 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, onMounted, ref } from 'vue'
|
import { computed, onBeforeUnmount, onMounted } from 'vue'
|
||||||
import { storeToRefs } from 'pinia'
|
import { storeToRefs } from 'pinia'
|
||||||
import { useRoute, useRouter } from 'vue-router'
|
import { useRoute, useRouter } from 'vue-router'
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
import { AppButton, QrCodePanel } from '@/components'
|
import { AppButton, QrCodePanel } from '@/components'
|
||||||
|
import { usePayPoll } from '@/composables/usePayPoll'
|
||||||
import { useFinanceStore } from '@/stores/modules/finance'
|
import { useFinanceStore } from '@/stores/modules/finance'
|
||||||
import type { PayMethod } from '@/types/business/finance'
|
|
||||||
import { formatMoney } from '@/utils/format'
|
import { formatMoney } from '@/utils/format'
|
||||||
import PayMethodDialog from './cpns/PayMethodDialog.vue'
|
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const financeStore = useFinanceStore()
|
const financeStore = useFinanceStore()
|
||||||
const { payment, currentBill } = storeToRefs(financeStore)
|
const { payment, currentBill, payOrder } = storeToRefs(financeStore)
|
||||||
|
const { start: startPoll, stop: stopPoll, check } = usePayPoll(onPaySuccess)
|
||||||
|
|
||||||
const billId = computed(() => String(route.params.id))
|
const billId = computed(() => String(route.params.id))
|
||||||
|
|
||||||
const dialogVisible = ref(false)
|
const methodLabel = '支付宝支付'
|
||||||
|
|
||||||
const method = computed<PayMethod>(() => payment.value?.method ?? 'wechat')
|
const steps = [
|
||||||
|
'打开手机支付宝',
|
||||||
|
'对准屏幕上方的二维码进行扫描,核对金额后确认支付',
|
||||||
|
'输入支付密码完成支付,本页将自动跳转至支付结果页',
|
||||||
|
]
|
||||||
|
|
||||||
const methodLabel = computed(() => (method.value === 'wechat' ? '微信支付' : '支付宝支付'))
|
function onPaySuccess(outTradeNo: string): void {
|
||||||
|
void router.push({
|
||||||
const steps = computed<string[]>(() =>
|
path: `/finance/bills/${billId.value}/pay/result`,
|
||||||
method.value === 'wechat'
|
query: { outTradeNo, ids: billId.value },
|
||||||
? [
|
})
|
||||||
'打开手机微信',
|
|
||||||
'扫描左侧二维码',
|
|
||||||
'输入支付密码完成支付,本页将自动跳转至支付结果页',
|
|
||||||
]
|
|
||||||
: [
|
|
||||||
'打开手机支付宝',
|
|
||||||
'对准屏幕上方的二维码进行扫描,核对金额后确认支付',
|
|
||||||
'输入支付密码完成支付',
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
function onRefresh(): void {
|
|
||||||
void financeStore.switchPaymentMethod(billId.value, method.value)
|
|
||||||
ElMessage.success('二维码已刷新')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function onConfirmMethod(next: PayMethod): void {
|
async function onCheckPaid(): Promise<void> {
|
||||||
void financeStore.switchPaymentMethod(billId.value, next)
|
const outTradeNo = financeStore.payOutTradeNo
|
||||||
ElMessage.success('二维码已刷新')
|
if (!outTradeNo) return
|
||||||
|
const done = await check(outTradeNo)
|
||||||
|
if (!done) ElMessage.warning('支付结果确认中,请稍后再试')
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onPaid(): Promise<void> {
|
async function initPayment(): Promise<void> {
|
||||||
await financeStore.createPayment(billId.value, method.value)
|
await financeStore.fetchDetail(billId.value)
|
||||||
void router.push(`/finance/bills/${billId.value}/pay/result`)
|
if (currentBill.value?.status !== '待支付') return
|
||||||
|
await financeStore.createPayment(billId.value, 'alipay')
|
||||||
|
const outTradeNo = financeStore.payOutTradeNo
|
||||||
|
if (outTradeNo) startPoll(outTradeNo)
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
void Promise.all([
|
void initPayment()
|
||||||
financeStore.createPayment(billId.value, 'wechat'),
|
|
||||||
financeStore.fetchDetail(billId.value),
|
|
||||||
])
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
onBeforeUnmount(stopPoll)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -77,11 +71,8 @@ onMounted(() => {
|
|||||||
<section class="pay__left">
|
<section class="pay__left">
|
||||||
<div class="pay__left-top">
|
<div class="pay__left-top">
|
||||||
<p class="pay__method">
|
<p class="pay__method">
|
||||||
{{ methodLabel }} · 请使用手机微信 <strong>[扫一扫]</strong> 扫描下方二维码完成支付
|
{{ methodLabel }} · 请使用手机支付宝 <strong>[扫一扫]</strong> 扫描下方二维码完成支付
|
||||||
</p>
|
</p>
|
||||||
<AppButton class="pay__switch" @click="dialogVisible = true">
|
|
||||||
切换支付方式
|
|
||||||
</AppButton>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="pay__amount-block">
|
<div class="pay__amount-block">
|
||||||
@@ -92,8 +83,8 @@ onMounted(() => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<QrCodePanel
|
<QrCodePanel
|
||||||
:expires-in="payment?.qrExpiresInSeconds ?? 300"
|
:content="payOrder?.qrCode ?? ''"
|
||||||
@refresh="onRefresh"
|
:countdown="false"
|
||||||
/>
|
/>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
@@ -141,19 +132,13 @@ onMounted(() => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="pay__footer">
|
<div class="pay__footer">
|
||||||
<AppButton type="primary" size="lg" @click="onPaid">
|
<AppButton type="primary" size="lg" @click="onCheckPaid">
|
||||||
完成支付
|
我已完成支付
|
||||||
</AppButton>
|
</AppButton>
|
||||||
<AppButton @click="router.push('/finance/bills')">
|
<AppButton @click="router.push('/finance/bills')">
|
||||||
返回
|
返回
|
||||||
</AppButton>
|
</AppButton>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<PayMethodDialog
|
|
||||||
v-model:visible="dialogVisible"
|
|
||||||
:method="method"
|
|
||||||
@confirm="onConfirmMethod"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -161,8 +146,10 @@ onMounted(() => {
|
|||||||
.pay {
|
.pay {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-width: @container-width;
|
max-width: @container-width;
|
||||||
|
min-height: 100%;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
padding: @spacing-lg @spacing-base @spacing-xxl;
|
padding: @spacing-lg @spacing-base @spacing-page-bottom;
|
||||||
|
background: @bg-color;
|
||||||
|
|
||||||
&__breadcrumb {
|
&__breadcrumb {
|
||||||
margin-bottom: @spacing-base;
|
margin-bottom: @spacing-base;
|
||||||
@@ -235,8 +222,8 @@ onMounted(() => {
|
|||||||
|
|
||||||
&__amount {
|
&__amount {
|
||||||
margin-top: 4px;
|
margin-top: 4px;
|
||||||
font-size: 26px;
|
font-size: @font-size-xl;
|
||||||
font-weight: 700;
|
font-weight: 600;
|
||||||
color: @danger-color;
|
color: @danger-color;
|
||||||
line-height: 1.2;
|
line-height: 1.2;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,59 +61,92 @@ onBeforeUnmount(stopAutoplay)
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<section class="home-banner">
|
<section class="home-banner">
|
||||||
<div class="home-banner__carousel" aria-hidden="true">
|
<div class="home-banner__stage">
|
||||||
<div
|
<div class="home-banner__carousel" aria-hidden="true">
|
||||||
v-for="(src, index) in slides"
|
<div
|
||||||
:key="`${src}-${index}`"
|
v-for="(src, index) in slides"
|
||||||
class="home-banner__slide"
|
:key="`${src}-${index}`"
|
||||||
:class="{ 'home-banner__slide--active': index === activeIndex }"
|
class="home-banner__slide"
|
||||||
>
|
:class="{ 'home-banner__slide--active': index === activeIndex }"
|
||||||
<img
|
|
||||||
class="home-banner__image"
|
|
||||||
:class="{ 'home-banner__image--inline': !hasBanners }"
|
|
||||||
:src="src"
|
|
||||||
alt=""
|
|
||||||
>
|
>
|
||||||
|
<img
|
||||||
|
class="home-banner__image"
|
||||||
|
:class="{ 'home-banner__image--inline': !hasBanners }"
|
||||||
|
:src="src"
|
||||||
|
alt=""
|
||||||
|
>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="home-banner__inner">
|
<div class="home-banner__inner">
|
||||||
<h1 class="home-banner__title">虫子智造研发一体化平台</h1>
|
<h1 class="home-banner__title">
|
||||||
<p class="home-banner__subtitle">一站式智能软硬件研发与量产综合服务商</p>
|
虫子智造研发一体化平台
|
||||||
|
</h1>
|
||||||
|
<p class="home-banner__subtitle">
|
||||||
|
一站式智能软硬件研发与量产综合服务商
|
||||||
|
</p>
|
||||||
|
|
||||||
<div class="home-banner__actions">
|
<div class="home-banner__actions">
|
||||||
<button class="home-banner__btn home-banner__btn--primary" type="button" @click="goDemand">
|
<button
|
||||||
需求提报
|
class="home-banner__btn home-banner__btn--primary"
|
||||||
</button>
|
type="button"
|
||||||
<button class="home-banner__btn home-banner__btn--ghost" type="button" @click="goCases">
|
@click="goDemand"
|
||||||
案例中心
|
>
|
||||||
</button>
|
需求提报
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
class="home-banner__btn home-banner__btn--ghost"
|
||||||
|
type="button"
|
||||||
|
@click="goCases"
|
||||||
|
>
|
||||||
|
案例中心
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div v-if="slides.length > 1" class="home-banner__dots" role="tablist" aria-label="头图轮播">
|
<div
|
||||||
<button
|
v-if="slides.length > 1"
|
||||||
v-for="(_, index) in slides"
|
class="home-banner__dots"
|
||||||
:key="index"
|
role="tablist"
|
||||||
class="home-banner__dot"
|
aria-label="头图轮播"
|
||||||
:class="{ 'home-banner__dot--active': index === activeIndex }"
|
>
|
||||||
type="button"
|
<button
|
||||||
role="tab"
|
v-for="(_, index) in slides"
|
||||||
:aria-selected="index === activeIndex"
|
:key="index"
|
||||||
@click="goTo(index)"
|
class="home-banner__dot"
|
||||||
/>
|
:class="{ 'home-banner__dot--active': index === activeIndex }"
|
||||||
|
type="button"
|
||||||
|
role="tab"
|
||||||
|
:aria-selected="index === activeIndex"
|
||||||
|
@click="goTo(index)"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
.home-banner {
|
.home-banner {
|
||||||
position: relative;
|
|
||||||
height: 661px;
|
|
||||||
overflow: hidden;
|
|
||||||
background: @home-banner-bg;
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
flex: 0 0 auto;
|
flex: 0 0 auto;
|
||||||
|
padding: @spacing-lg @home-gutter 0;
|
||||||
|
box-sizing: border-box;
|
||||||
|
background: transparent;
|
||||||
|
|
||||||
|
@media (max-width: 1600px) {
|
||||||
|
padding: @spacing-lg @spacing-lg 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__stage {
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
max-width: @home-content;
|
||||||
|
height: 420px;
|
||||||
|
margin: 0 auto;
|
||||||
|
overflow: hidden;
|
||||||
|
border-radius: @radius-base;
|
||||||
|
background: @home-banner-bg;
|
||||||
|
}
|
||||||
|
|
||||||
&__carousel {
|
&__carousel {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
@@ -138,15 +171,14 @@ onBeforeUnmount(stopAutoplay)
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
object-fit: cover;
|
object-fit: cover;
|
||||||
|
|
||||||
// 内置插图:按设计稿定位与尺寸原样显示,不铺满
|
|
||||||
&--inline {
|
&--inline {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 31px;
|
top: 24px;
|
||||||
right: 269px;
|
right: 48px;
|
||||||
left: auto;
|
left: auto;
|
||||||
bottom: auto;
|
bottom: auto;
|
||||||
width: 723px;
|
width: 420px;
|
||||||
height: 598px;
|
height: 348px;
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
object-fit: contain;
|
object-fit: contain;
|
||||||
}
|
}
|
||||||
@@ -156,50 +188,48 @@ onBeforeUnmount(stopAutoplay)
|
|||||||
position: relative;
|
position: relative;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-width: @container-width;
|
|
||||||
height: 100%;
|
height: 100%;
|
||||||
margin: 0 auto;
|
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__title {
|
&__title {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 184px;
|
top: 96px;
|
||||||
left: 150px;
|
left: 64px;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
color: @banner-title-color;
|
color: @banner-title-color;
|
||||||
font-size: @font-size-hero-lg;
|
font-size: @font-size-hero;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
line-height: 87px;
|
line-height: 1.25;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__subtitle {
|
&__subtitle {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 287px;
|
top: 168px;
|
||||||
left: 150px;
|
left: 64px;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
color: @banner-title-color;
|
color: @banner-title-color;
|
||||||
font-size: 24px;
|
font-size: @font-size-lg;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
line-height: 35px;
|
line-height: 1.4;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__actions {
|
&__actions {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 392px;
|
top: 232px;
|
||||||
left: 150px;
|
left: 64px;
|
||||||
.flex(row, flex-start, center);
|
.flex(row, flex-start, center);
|
||||||
gap: 20px;
|
gap: @spacing-base;
|
||||||
pointer-events: auto;
|
pointer-events: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__btn {
|
&__btn {
|
||||||
width: 183px;
|
width: 140px;
|
||||||
height: 55px;
|
height: 44px;
|
||||||
border-radius: 8px;
|
border-radius: @radius-base;
|
||||||
font-size: 18px;
|
font-size: @font-size-base;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
line-height: 1;
|
line-height: 1;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
@@ -220,7 +250,7 @@ onBeforeUnmount(stopAutoplay)
|
|||||||
content: '';
|
content: '';
|
||||||
position: absolute;
|
position: absolute;
|
||||||
inset: 0;
|
inset: 0;
|
||||||
border-radius: 8px;
|
border-radius: @radius-base;
|
||||||
padding: 2px;
|
padding: 2px;
|
||||||
background: linear-gradient(135deg, @btn-gradient-from 0%, @btn-gradient-to 100%);
|
background: linear-gradient(135deg, @btn-gradient-from 0%, @btn-gradient-to 100%);
|
||||||
-webkit-mask:
|
-webkit-mask:
|
||||||
@@ -238,16 +268,17 @@ onBeforeUnmount(stopAutoplay)
|
|||||||
|
|
||||||
&__dots {
|
&__dots {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 929px;
|
left: 50%;
|
||||||
top: 594px;
|
bottom: @spacing-base;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
.flex(row, flex-start, center);
|
.flex(row, center, center);
|
||||||
gap: 13px;
|
gap: @spacing-sm;
|
||||||
|
transform: translateX(-50%);
|
||||||
}
|
}
|
||||||
|
|
||||||
&__dot {
|
&__dot {
|
||||||
width: 5px;
|
width: 6px;
|
||||||
height: 5px;
|
height: 6px;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
border: none;
|
border: none;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
@@ -255,7 +286,7 @@ onBeforeUnmount(stopAutoplay)
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
||||||
&--active {
|
&--active {
|
||||||
width: 44px;
|
width: 28px;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
background: @home-banner-dot;
|
background: @home-banner-dot;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { BusinessType } from '@/types/api'
|
import type { BusinessType } from '@/types/api'
|
||||||
import type { BusinessLine } from '@/types/business/home'
|
import type { BusinessLine } from '@/types/business/home'
|
||||||
|
import defaultCover from '@/assets/home/chahua.png'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
lines: BusinessLine[]
|
lines: BusinessLine[]
|
||||||
@@ -9,6 +10,16 @@ interface Props {
|
|||||||
defineProps<Props>()
|
defineProps<Props>()
|
||||||
|
|
||||||
const FALLBACK_ACTIVE: BusinessType[] = ['internet']
|
const FALLBACK_ACTIVE: BusinessType[] = ['internet']
|
||||||
|
|
||||||
|
function isImageUrl(value: string): boolean {
|
||||||
|
return /^(https?:)?\/\//i.test(value) || value.startsWith('/') || value.startsWith('data:')
|
||||||
|
}
|
||||||
|
|
||||||
|
function coverSrc(line: BusinessLine): string {
|
||||||
|
const remote = (line.cover || line.icon).trim()
|
||||||
|
if (remote && isImageUrl(remote)) return remote
|
||||||
|
return defaultCover
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -25,6 +36,11 @@ const FALLBACK_ACTIVE: BusinessType[] = ['internet']
|
|||||||
'home-business__card--active': FALLBACK_ACTIVE.includes(line.id),
|
'home-business__card--active': FALLBACK_ACTIVE.includes(line.id),
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
|
<img
|
||||||
|
class="home-business__cover"
|
||||||
|
:src="coverSrc(line)"
|
||||||
|
:alt="line.name"
|
||||||
|
>
|
||||||
<span class="home-business__check" aria-hidden="true" />
|
<span class="home-business__check" aria-hidden="true" />
|
||||||
<h4 class="home-business__name">
|
<h4 class="home-business__name">
|
||||||
{{ line.name }}
|
{{ line.name }}
|
||||||
@@ -39,61 +55,73 @@ const FALLBACK_ACTIVE: BusinessType[] = ['internet']
|
|||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
.home-business {
|
.home-business {
|
||||||
padding: 44px 70px 54px;
|
padding: @spacing-xl;
|
||||||
border: 1px solid @home-section-border;
|
border: none;
|
||||||
border-radius: @radius-lg;
|
border-radius: @radius-base;
|
||||||
background: @white;
|
background: @white;
|
||||||
|
|
||||||
&__title {
|
&__title {
|
||||||
margin: 0 0 47px;
|
margin: 0 0 @spacing-lg;
|
||||||
font-size: @font-size-xxl;
|
font-size: @font-size-xl;
|
||||||
font-weight: 700;
|
font-weight: 600;
|
||||||
color: @home-ink;
|
color: @home-ink;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__grid {
|
&__grid {
|
||||||
display: flex;
|
display: grid;
|
||||||
gap: 22px;
|
grid-template-columns: repeat(4, 1fr);
|
||||||
|
gap: @spacing-base;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__card {
|
&__card {
|
||||||
position: relative;
|
position: relative;
|
||||||
.flex(column, flex-start, flex-start);
|
.flex(column, flex-start, flex-start);
|
||||||
flex: 0 1 368px;
|
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
height: 206px;
|
min-height: 168px;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
padding: 0 20px;
|
padding: @spacing-lg;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
border: 1px solid @home-business-border;
|
border: 1px solid @border-color;
|
||||||
border-radius: @radius-base;
|
border-radius: @radius-base;
|
||||||
background: @white;
|
background: @white;
|
||||||
transition:
|
transition:
|
||||||
transform 0.2s,
|
transform 0.2s,
|
||||||
box-shadow 0.2s;
|
box-shadow 0.2s,
|
||||||
|
border-color 0.2s;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
|
border-color: @primary-color;
|
||||||
box-shadow: @shadow-base;
|
box-shadow: @shadow-base;
|
||||||
transform: translateY(-2px);
|
transform: translateY(-2px);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&__cover {
|
||||||
|
display: block;
|
||||||
|
width: 72px;
|
||||||
|
height: 72px;
|
||||||
|
object-fit: contain;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
&__check {
|
&__check {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 27px;
|
top: @spacing-base;
|
||||||
right: 37px;
|
right: @spacing-base;
|
||||||
|
z-index: 1;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
width: 31px;
|
width: 20px;
|
||||||
height: 31px;
|
height: 20px;
|
||||||
border: 1px solid @home-ring;
|
border: 1px solid @home-ring;
|
||||||
border-radius: @radius-round;
|
border-radius: @radius-round;
|
||||||
|
background: @white;
|
||||||
|
|
||||||
&::after {
|
&::after {
|
||||||
content: '';
|
content: '';
|
||||||
position: absolute;
|
position: absolute;
|
||||||
inset: 0;
|
inset: 0;
|
||||||
width: 21px;
|
width: 12px;
|
||||||
height: 21px;
|
height: 12px;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
border-radius: @radius-round;
|
border-radius: @radius-round;
|
||||||
background: @white;
|
background: @white;
|
||||||
@@ -102,37 +130,43 @@ const FALLBACK_ACTIVE: BusinessType[] = ['internet']
|
|||||||
}
|
}
|
||||||
|
|
||||||
&__name {
|
&__name {
|
||||||
margin: 104px 0 0;
|
margin: @spacing-base 0 0;
|
||||||
font-size: @font-size-title;
|
padding-right: @spacing-xl;
|
||||||
|
font-size: @font-size-lg;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
line-height: 41px;
|
line-height: 1.4;
|
||||||
color: @home-ink;
|
color: @home-ink;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__desc {
|
&__desc {
|
||||||
margin: 4px 0 0;
|
margin: @spacing-xs 0 0;
|
||||||
font-size: @font-size-md;
|
padding-right: @spacing-xl;
|
||||||
font-weight: 500;
|
font-size: @font-size-sm;
|
||||||
line-height: 23px;
|
font-weight: 400;
|
||||||
color: @home-ink;
|
line-height: 1.5;
|
||||||
.multi-ellipsis(1);
|
color: @text-color-secondary;
|
||||||
|
.multi-ellipsis(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
&__card--active {
|
&__card--active {
|
||||||
border-color: @primary-strong;
|
border-color: @primary-color;
|
||||||
background: @primary-strong;
|
background: @filter-selected-bg;
|
||||||
|
|
||||||
.home-business__check {
|
.home-business__check {
|
||||||
border-color: @white;
|
border-color: @primary-color;
|
||||||
|
|
||||||
&::after {
|
&::after {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
|
background: @primary-color;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.home-business__name,
|
.home-business__name {
|
||||||
|
color: @primary-strong;
|
||||||
|
}
|
||||||
|
|
||||||
.home-business__desc {
|
.home-business__desc {
|
||||||
color: @white;
|
color: @text-color-secondary;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,9 +33,7 @@ const visibleCases = computed<Case[]>(() => props.cases.slice(0, 4))
|
|||||||
<template>
|
<template>
|
||||||
<section class="home-cases">
|
<section class="home-cases">
|
||||||
<div class="home-cases__head">
|
<div class="home-cases__head">
|
||||||
<h3 class="home-cases__title">
|
<h3 class="home-cases__title">案例库精选</h3>
|
||||||
案例库精选
|
|
||||||
</h3>
|
|
||||||
<div class="home-cases__tabs">
|
<div class="home-cases__tabs">
|
||||||
<button
|
<button
|
||||||
v-for="cat in categories"
|
v-for="cat in categories"
|
||||||
@@ -60,7 +58,12 @@ const visibleCases = computed<Case[]>(() => props.cases.slice(0, 4))
|
|||||||
@click="$router.push(`/cases/${item.id}`)"
|
@click="$router.push(`/cases/${item.id}`)"
|
||||||
>
|
>
|
||||||
<div class="home-cases__cover">
|
<div class="home-cases__cover">
|
||||||
<img v-if="item.cover" v-lazy="item.cover" class="home-cases__img" :alt="item.title">
|
<img
|
||||||
|
v-if="item.cover"
|
||||||
|
v-lazy="item.cover"
|
||||||
|
class="home-cases__img"
|
||||||
|
:alt="item.title"
|
||||||
|
/>
|
||||||
<div v-else class="home-cases__img home-cases__img--placeholder" />
|
<div v-else class="home-cases__img home-cases__img--placeholder" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -85,26 +88,26 @@ const visibleCases = computed<Case[]>(() => props.cases.slice(0, 4))
|
|||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
.home-cases {
|
.home-cases {
|
||||||
padding: 40px 66px 60px;
|
padding: @spacing-xl;
|
||||||
border: 1px solid @home-section-border;
|
border: none;
|
||||||
border-radius: @radius-lg;
|
border-radius: @radius-base;
|
||||||
background: @white;
|
background: @white;
|
||||||
|
|
||||||
&__head {
|
&__head {
|
||||||
.flex(row, flex-start);
|
.flex(row, flex-start, center);
|
||||||
gap: 24px;
|
gap: @spacing-lg;
|
||||||
margin-bottom: 47px;
|
margin-bottom: @spacing-lg;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__title {
|
&__title {
|
||||||
font-size: @font-size-xxl;
|
font-size: @font-size-xl;
|
||||||
font-weight: 700;
|
font-weight: 600;
|
||||||
color: @home-ink;
|
color: @home-ink;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__tabs {
|
&__tabs {
|
||||||
.flex(row, center);
|
.flex(row, center);
|
||||||
gap: 36px;
|
gap: @spacing-lg;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__tab {
|
&__tab {
|
||||||
@@ -140,25 +143,29 @@ const visibleCases = computed<Case[]>(() => props.cases.slice(0, 4))
|
|||||||
}
|
}
|
||||||
|
|
||||||
&__grid {
|
&__grid {
|
||||||
display: flex;
|
display: grid;
|
||||||
gap: 24px;
|
grid-template-columns: repeat(4, 1fr);
|
||||||
|
gap: @spacing-lg;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__card {
|
&__card {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
flex: 0 1 368px;
|
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
height: 248px;
|
min-height: 220px;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
border: 1px solid @home-case-border;
|
border: 1px solid @border-color;
|
||||||
border-radius: @radius-base;
|
border-radius: @radius-base;
|
||||||
background: @white;
|
background: @white;
|
||||||
box-shadow: 0 4px 10px fade(@black, 8%);
|
box-shadow: none;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: transform 0.2s, box-shadow 0.2s;
|
transition:
|
||||||
|
transform 0.2s,
|
||||||
|
box-shadow 0.2s,
|
||||||
|
border-color 0.2s;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
box-shadow: 0 6px 14px fade(@black, 12%);
|
border-color: @primary-color;
|
||||||
|
box-shadow: @shadow-base;
|
||||||
transform: translateY(-2px);
|
transform: translateY(-2px);
|
||||||
|
|
||||||
.home-cases__view {
|
.home-cases__view {
|
||||||
@@ -184,7 +191,7 @@ const visibleCases = computed<Case[]>(() => props.cases.slice(0, 4))
|
|||||||
}
|
}
|
||||||
|
|
||||||
&__body {
|
&__body {
|
||||||
padding: 0 20px;
|
padding: 0 20px 10px 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__name {
|
&__name {
|
||||||
@@ -200,7 +207,7 @@ const visibleCases = computed<Case[]>(() => props.cases.slice(0, 4))
|
|||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 1fr 1fr 1fr;
|
grid-template-columns: 1fr 1fr 1fr;
|
||||||
gap: 0 @spacing-lg;
|
gap: 0 @spacing-lg;
|
||||||
margin-top: 43px;
|
margin-top: 20px;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
line-height: 20px;
|
line-height: 20px;
|
||||||
color: @home-body;
|
color: @home-body;
|
||||||
|
|||||||
@@ -173,15 +173,15 @@ function onMore(): void {
|
|||||||
position: relative;
|
position: relative;
|
||||||
.flex(column, flex-start, stretch);
|
.flex(column, flex-start, stretch);
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
flex: 0 0 529px;
|
flex: 0 0 420px;
|
||||||
width: 529px;
|
width: 420px;
|
||||||
height: 245px;
|
min-height: 0;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
gap: 0;
|
gap: 0;
|
||||||
padding: 18px 40px 28px;
|
padding: @spacing-lg;
|
||||||
border: 1px solid @home-card-border;
|
border: none;
|
||||||
border-radius: @radius-lg;
|
border-radius: @radius-base;
|
||||||
background: @white;
|
background: @white;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|
||||||
@@ -190,22 +190,22 @@ function onMore(): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
&__title {
|
&__title {
|
||||||
font-size: @font-size-xxl;
|
font-size: @font-size-xl;
|
||||||
font-weight: 700;
|
font-weight: 600;
|
||||||
line-height: 52px;
|
line-height: 1.4;
|
||||||
color: @home-ink;
|
color: @home-ink;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__list {
|
&__list {
|
||||||
.flex(row, flex-start, flex-start);
|
.flex(row, flex-start, flex-start);
|
||||||
gap: 30px;
|
gap: @spacing-base;
|
||||||
margin-top: 17px;
|
margin-top: @spacing-base;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__item {
|
&__item {
|
||||||
.flex(column, flex-start, center);
|
.flex(column, flex-start, center);
|
||||||
gap: 8px;
|
gap: @spacing-sm;
|
||||||
flex: none;
|
flex: none;
|
||||||
transition: transform 0.2s;
|
transition: transform 0.2s;
|
||||||
|
|
||||||
@@ -216,14 +216,14 @@ function onMore(): void {
|
|||||||
|
|
||||||
&__tile {
|
&__tile {
|
||||||
display: block;
|
display: block;
|
||||||
width: 97px;
|
width: 72px;
|
||||||
height: 97px;
|
height: 72px;
|
||||||
border-radius: @radius-base;
|
border-radius: @radius-base;
|
||||||
object-fit: cover;
|
object-fit: cover;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__label {
|
&__label {
|
||||||
font-size: @font-size-lg;
|
font-size: @font-size-sm;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
color: @home-ink;
|
color: @home-ink;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
@@ -231,15 +231,16 @@ function onMore(): void {
|
|||||||
|
|
||||||
&__more {
|
&__more {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 120px;
|
top: 50%;
|
||||||
right: 25px;
|
right: @spacing-base;
|
||||||
width: 32px;
|
width: 28px;
|
||||||
height: 32px;
|
height: 28px;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
border: 0;
|
border: 0;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
color: #c9cdd4;
|
color: @text-color-disabled;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
transform: translateY(-50%);
|
||||||
transition: color 0.2s;
|
transition: color 0.2s;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
|
|||||||
@@ -27,10 +27,10 @@ defineProps<Props>()
|
|||||||
.home-contents {
|
.home-contents {
|
||||||
&__block {
|
&__block {
|
||||||
margin-bottom: @spacing-base;
|
margin-bottom: @spacing-base;
|
||||||
padding: 40px 45px 0;
|
padding: @spacing-xl;
|
||||||
border-radius: @radius-lg;
|
border-radius: @radius-base;
|
||||||
background: @white;
|
background: @white;
|
||||||
min-height: 593px;
|
min-height: 0;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
|
||||||
&:last-child {
|
&:last-child {
|
||||||
@@ -39,10 +39,10 @@ defineProps<Props>()
|
|||||||
}
|
}
|
||||||
|
|
||||||
&__title {
|
&__title {
|
||||||
margin: 0 0 301px;
|
margin: 0 0 @spacing-lg;
|
||||||
font-size: 36px;
|
font-size: @font-size-xl;
|
||||||
font-weight: 700;
|
font-weight: 600;
|
||||||
line-height: 52px;
|
line-height: 1.4;
|
||||||
color: @home-ink;
|
color: @home-ink;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,40 +43,41 @@ function isImageIcon(icon?: string): boolean {
|
|||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
.home-service-types {
|
.home-service-types {
|
||||||
margin-bottom: 20px;
|
margin-bottom: @spacing-base;
|
||||||
padding: 24px 42px 0;
|
padding: @spacing-lg @spacing-xl;
|
||||||
border-radius: @radius-lg;
|
border-radius: @radius-base;
|
||||||
background: @white;
|
background: @white;
|
||||||
height: 287px;
|
min-height: 0;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
|
||||||
&__title {
|
&__title {
|
||||||
margin: 0 0 132px;
|
margin: 0 0 @spacing-lg;
|
||||||
font-size: 36px;
|
font-size: @font-size-xl;
|
||||||
font-weight: 700;
|
font-weight: 600;
|
||||||
line-height: 52px;
|
line-height: 1.4;
|
||||||
color: @home-ink;
|
color: @home-ink;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__list {
|
&__list {
|
||||||
.flex(row, flex-start);
|
.flex(row, flex-start);
|
||||||
gap: 0;
|
gap: @spacing-base;
|
||||||
|
flex-wrap: wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__item {
|
&__item {
|
||||||
.flex(column, center);
|
.flex(column, center);
|
||||||
width: 187px;
|
width: 120px;
|
||||||
gap: 47px;
|
gap: @spacing-base;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__icon {
|
&__icon {
|
||||||
.flex(row, center);
|
.flex(row, center);
|
||||||
width: 68px;
|
width: 48px;
|
||||||
height: 68px;
|
height: 48px;
|
||||||
border-radius: @radius-round;
|
border-radius: @radius-round;
|
||||||
background: @primary-light;
|
background: @primary-light;
|
||||||
color: @white;
|
color: @white;
|
||||||
font-size: 24px;
|
font-size: @font-size-lg;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user