From c926beb226061a0ed640c0eb258108abfc2a84af Mon Sep 17 00:00:00 2001 From: yin <3313488199@qq.com> Date: Wed, 23 Sep 2026 18:10:36 +0800 Subject: [PATCH] 1 --- src/api/wechat/wechat.ts | 366 ++++- src/components/RichTextEditor/index.vue | 540 +++++++ src/lang/en-US.ts | 4 +- src/lang/zh-CN.ts | 4 +- .../dashboard/components/StatsCardsStore.vue | 70 +- .../components/VideoListDialog.vue | 481 +++++- src/views/data/packingflow/index.vue | 4 +- .../newview/pages/MiniProgramConfigForm.vue | 1415 ++++++++++++++--- 8 files changed, 2568 insertions(+), 316 deletions(-) create mode 100644 src/components/RichTextEditor/index.vue diff --git a/src/api/wechat/wechat.ts b/src/api/wechat/wechat.ts index dd90c11e..86b10a50 100644 --- a/src/api/wechat/wechat.ts +++ b/src/api/wechat/wechat.ts @@ -18,12 +18,18 @@ export type WeChatAuthUrlPayload = { [key: string]: unknown } +/** wechat.getAuthUrl 入参:warehouse_id 可选,缺省取当前登录用户所属仓库 */ +export type WeChatAuthUrlParams = { + /** 仓库 ID(可选;缺省取当前登录用户所属仓库) */ + warehouse_id?: number +} + /** * 获取微信授权链接(由用户点击「去授权」时调用,避免页面加载即跳转/弹窗被拦截)。 * 返回值中链接字段名做多形态兼容,取值见页面 pickUrl()。 */ export function wechatGetAuthUrl( - data: Record = {} + data: WeChatAuthUrlParams = {} ): Promise<{ code?: number; message?: string; data?: WeChatAuthUrlPayload } & Record> { return request({ url: '/system', @@ -78,7 +84,14 @@ export type WeChatQueryAuthData = { [key: string]: unknown } -export function wechatQueryAuth(): Promise< +export type WeChatQueryAuthParams = { + /** 认证任务 ID(可选;缺省时用库中 auth_task_id;小程序已认证时无需传入) */ + taskid?: string +} + +export function wechatQueryAuth( + data: WeChatQueryAuthParams = {} +): Promise< { code?: number; message?: string; data?: WeChatQueryAuthData } & Record > { return request({ @@ -89,41 +102,66 @@ export function wechatQueryAuth(): Promise< v, timestamp: new Date().getTime() }, - data: {}, + data, isSystemApi: true } as any) } /** * 发起小程序认证(wechat.wxaauth)—— 后端分步: - * 图片字段传 COS 文件 URL(http/https)→ 后端下载并调微信 `wxa/sec/wxaapi/uploadmedia` 换 media_id - * → 替换请求体 → 调微信 `wxa/sec/wxaapi/wxaauth`(权限集 18)一步提交。 + * 图片字段传 COS 文件 URL(http/https)→ 后端下载并调微信 `wxa/sec/uploadauthmaterial` 换 mediaid + * → 替换请求体 → 以 `{ auth_data }` 包裹调微信 `wxa/sec/wxaauth`(权限集 18)一步提交。 * 成功后后端回写 `wms_wechat_app.auth_task_id`/`auth_apply_status`,返回 `taskid` 与 `auth_url`; * 小程序已认证(verify_type_id >= 0)时会拒绝重复发起。 */ +export type WeChatWxaauthContactInfo = { + /** 联系人姓名(必填) */ + name: string + /** 联系人邮箱(必填) */ + email: string + /** 联系人手机(选填) */ + mobile?: string +} + +/** wechat.wxaauth 入参(新版 auth_data:6 个必填 + 下列可选字段) */ export type WeChatWxaauthParams = { - /** 联系人类型:1 法人、2 管理员 */ - contact_type: number - /** 联系人姓名 */ - contact_name: string + /** 账号主体类型:1 企业、12 个体工商户、15 个人 */ + customer_type: number + /** 小程序账号名称 */ + account_name: string + /** 命名类型:1 基于自选词汇、2 基于商标 */ + account_name_type: number + /** 支付方式:1 消耗服务商预购包、2 小程序开发者自行支付 */ + pay_type: number + /** 第三方联系电话 */ + third_party_phone: string + /** 联系人信息(name/email 必填,mobile 选填) */ + contact_info: WeChatWxaauthContactInfo + /** 发票信息(服务商代缴可不传) */ + invoice_info?: Record + /** 主体资质材料(mediaid 或 COS URL;**非个人主体必填**,单张) */ + qualification?: string + /** 资质其他材料(mediaid / COS URL 数组,≤10 张) */ + qualification_other?: string[] + /** 名称关键词补充材料(mediaid / COS URL 数组) */ + account_supplemental?: string[] + /** 个人认证身份信息(选填) */ + auth_identification?: Record + /** 个人认证身份材料(mediaid / COS URL 数组) */ + auth_ident_material?: string[] + /** 服务商代缴时必填:服务商 AppID */ + service_appid?: string + /** 打回重填(reauth)时必填:原认证任务 ID */ + taskid?: string /** - * 其余白名单字段(后端透传微信 wxaauth 请求体): - * contact_idcard_number/contact_mobile/contact_cert_photo/contact_nationality/contact_address/contact_email、 - * business_license_copy/business_license_number/business_license_address/business_license_expiration_date、 - * legal_persona_media/legal_persona_idcard_copy/legal_persona_name/legal_persona_idcard_number/ - * legal_persona_address/legal_persona_idcard_expiration_date、business_license_type/apply_type/ - * extra_wxa_secure_info/nickname、pic_list/qualification_list/qualification_extra/license_list/ - * statement_list、store_name/store_main_industry/store_scale/store_floor/store_address/open_type/pay_type。 - * 图片字段(contact_cert_photo/business_license_copy/legal_persona_idcard_copy/legal_persona_media、 - * pic_list 项的 pic_url、qualification_list 项 licence_list/certificate_list 的 value、statement_list 项的 value) - * 支持传 COS 文件 URL;传非 URL 时视为已传 media_id 原样透传。 + * 其余白名单字段(后端透传 auth_data 原样给微信)。 + * 图片字段(qualification / qualification_other[] / account_supplemental[] / auth_ident_material[]) + * 支持传 COS 文件 URL;传非 URL 时视为已传 mediaid 原样透传。 */ [key: string]: unknown } export type WeChatWxaauthData = { - /** 小程序 AppID */ - appid?: string /** 认证任务 ID(已回写 auth_task_id,供 wechat.queryauth 查进度) */ taskid?: string /** 小程序管理员认证链接(可选,打开后继续完成认证) */ @@ -406,6 +444,284 @@ export function wechatSubmitAudit( } as any) } +/** 用户列表 where 条件值:operator 结构(operator 支持 eq/ne/gt/lt/ge/le/in/notin/between/like/contains/notlike/startswith/endswith/isnull/isnotnull) */ +export type WeChatUserWhereValue = { + operator?: string + value?: unknown +} + +/** userList 的 where 字段白名单(后端) */ +export type WeChatUserWhereField = + | 'id' + | 'user_id' + | 'app_id' + | 'openid' + | 'unionid' + | 'nickname' + | 'sex' + | 'login_time' + | 'login_count' + | 'created_at' + | 'updated_at' + +/** + * userList 的 sort 字段白名单(后端)= where 白名单 + `agreement_version_id` + * (协议版本记录 id,小程序登录时自动回写) + */ +export type WeChatUserSortField = WeChatUserWhereField | 'agreement_version_id' + +export type WeChatUserListParams = { + /** 指定 wms_wechat_app.id(可选,须属当前仓库且启用;缺省取当前仓库全部启用小程序) */ + app_id?: number + /** 查询条件:字段级 `{ operator, value }`(字段白名单见 WeChatUserWhereField) */ + where?: Partial> + /** 分页:默认 page=1、pageSize=20 */ + pagination?: { page?: number; pageSize?: number } + /** 排序:sortField 白名单见 WeChatUserSortField,默认 updated_at DESC */ + sort?: { sortField?: WeChatUserSortField; sortOrder?: 'asc' | 'desc' | 'ASC' | 'DESC' } +} + +/** 用户列表项(后端已排除 session_key / access_token / refresh_token 等敏感字段) */ +export type WeChatUserItem = { + id?: number + /** 绑定的真实账号 ID(0=未绑定) */ + user_id?: number + app_id?: number + openid?: string + unionid?: string + nickname?: string + /** 微信性别:0 未知、1 男、2 女 */ + sex?: number + headimgurl?: string + login_time?: number | string + login_count?: number + /** 是否已绑定真实账号(user_id > 0) */ + is_bound?: boolean + /** + * 用户最近一次登录时同意的**协议版本记录 id**(wms_wechat_agreement_version.id,由小程序 loginByCode 自动回写); + * 0 / 空表示未记录同意版本;可传给 `wechat.getAgreementVersion` 查看该版本协议原文。 + */ + agreement_version_id?: number + created_at?: string + updated_at?: string + [key: string]: unknown +} + +export type WeChatUserListData = { + list: WeChatUserItem[] + pagination: { page?: number; pageSize?: number; total?: number } + /** 本次查询命中的小程序列表(id/appid/nickname) */ + apps?: { id?: number; appid?: string; nickname?: string }[] + [key: string]: unknown +} + +/** + * 拉取当前仓库小程序的用户列表(wechat.userList)—— + * 按 ctx.user.store_id 取仓库启用小程序(可用 app_id 指定单个,须属当前仓库), + * 支持 where(operator 结构)/ pagination / sort;响应已排除 session_key / access_token / refresh_token 等敏感字段, + * 并附 `is_bound`(user_id > 0 已绑定真实账号)与 `agreement_version_id`(协议版本记录 id, + * 由小程序 loginByCode 自动回写,可传给 wechat.getAgreementVersion 拉取该版本协议内容)。 + */ +export function wechatUserList( + data: WeChatUserListParams = {} +): Promise<{ code?: number; message?: string; data?: WeChatUserListData } & Record> { + return request({ + url: '/system', + method: 'post', + params: { + method: 'wechat.userList', + v, + timestamp: new Date().getTime() + }, + data, + isSystemApi: true + } as any) +} + +/** + * 获取指定协议版本内容(wechat.getAgreementVersion)—— **需登录、免接口权限**。 + * 传版本记录 id(`wms_wechat_agreement_version.id`,可由 `wechat.userList` 的 `agreement_version_id` 获取), + * 后端校验该版本对应 appid 属于**当前仓库的启用小程序**后返回协议内容(含 appid / nickname / text)。 + */ +export type WeChatAgreementVersionParams = { + /** 协议版本记录 id(wms_wechat_agreement_version.id) */ + id: number +} + +export type WeChatAgreementVersionData = { + /** 协议版本记录 id */ + id: number + /** 小程序 AppID */ + appid: string + /** 小程序名称 */ + nickname?: string + /** 协议富文本内容 */ + text: string +} + +export function wechatGetAgreementVersion( + data: WeChatAgreementVersionParams +): Promise< + { code?: number; message?: string; data?: WeChatAgreementVersionData } & Record +> { + return request({ + url: '/system', + method: 'post', + params: { + method: 'wechat.getAgreementVersion', + v, + timestamp: new Date().getTime() + }, + data, + isSystemApi: true + } as any) +} + +/** + * 按工号绑定微信(wechat.bindByEmployee)—— PC 管理员操作,需登录 + 仓库上下文 + `wechat.bindByEmployee` 权限。 + * 传工号 id(wms_account_store_employee.id)与微信绑定记录 id(wms_user_oauth.id,来自 wechat.userList 的 id), + * 后端查工号关联的账号 id 后写入 `wms_user_oauth.user_id` 完成绑定。 + * + * - 已绑定**同一**账号时幂等返回(`already_bound=true`); + * - 以下情况会被拒绝:该微信已绑定其他账号、工号已解除或不属于当前仓库、 + * 微信记录不属于当前仓库的小程序、账号被禁用。 + */ +export type WeChatBindByEmployeeParams = { + /** 工号 id(wms_account_store_employee.id) */ + id: number + /** 微信绑定记录 id(wms_user_oauth.id,可在 wechat.userList 结果中获取) */ + oauth_id: number +} + +export type WeChatBindByEmployeeData = { + /** 微信绑定记录 id */ + oauth_id: number + /** 是否此前已绑定同一账号(幂等调用) */ + already_bound: boolean + /** 工号信息 */ + employee: { id?: number; account_id?: number; store_id?: number; real_name?: string } + /** 绑定的账号信息 */ + account: { id?: number; username?: string; real_name?: string } +} + +export function wechatBindByEmployee( + data: WeChatBindByEmployeeParams +): Promise< + { code?: number; message?: string; data?: WeChatBindByEmployeeData } & Record +> { + return request({ + url: '/system', + method: 'post', + params: { + method: 'wechat.bindByEmployee', + v, + timestamp: new Date().getTime() + }, + data, + isSystemApi: true + } as any) +} + +/** + * 获取当前仓库小程序的「用户须知」(wechat.getUserAgreement)—— 需登录 + 仓库上下文。 + * 按当前登录仓库取启用小程序(wms_wechat_app),从副表拉取**最新版本**(id 自增即最新); + * 仓库未绑定小程序时提示「无小程序,需要先绑定」,无版本时提示「该小程序暂无用户须知」。 + */ +export type WeChatUserAgreementData = { + /** 当前仓库小程序 AppID */ + appid: string + /** 小程序名称 */ + nickname?: string + /** 最新协议版本记录 id(wms_wechat_agreement_version.id,id 自增即最新) */ + version_id: number + /** 用户须知富文本内容 */ + text: string +} + +export function wechatGetUserAgreement(): Promise< + { code?: number; message?: string; data?: WeChatUserAgreementData } & Record +> { + return request({ + url: '/system', + method: 'post', + params: { + method: 'wechat.getUserAgreement', + v, + timestamp: new Date().getTime() + }, + data: {}, + isSystemApi: true + } as any) +} + +/** + * 获取小程序用户须知富文本(wechat.getUserAgreementText)—— **免登录**,入参 `appId`。 + * 按 appid 查 `wms_wechat_app.user_agreement`,Redis 缓存 24 小时(`from_cache` 标识是否命中)。 + * + * ⚠️ 这是给**小程序端**(无登录态)读取用户须知用的;网页端有登录态,回显请用 wechat.getUserAgreement。 + */ +export type WeChatUserAgreementTextParams = { + /** 小程序 AppID(wx...) */ + appId: string +} + +export type WeChatUserAgreementTextData = { + /** 小程序 AppID */ + appid: string + /** 最新协议版本记录 id(wms_wechat_agreement_version.id,id 自增即最新) */ + version_id: number + /** 用户须知富文本内容 */ + text: string + /** 是否命中 24h 缓存 */ + from_cache: boolean +} + +export function wechatGetUserAgreementText( + data: WeChatUserAgreementTextParams +): Promise< + { code?: number; message?: string; data?: WeChatUserAgreementTextData } & Record +> { + return request({ + url: '/system', + method: 'post', + params: { + method: 'wechat.getUserAgreementText', + v, + timestamp: new Date().getTime() + }, + data, + isSystemApi: true + } as any) +} + +/** + * 设置当前仓库小程序的「用户须知」(wechat.setUserAgreement)—— 需登录 + 仓库上下文。 + * **每次提交自动新增一个版本**(直接插入副表 `wms_wechat_agreement_version`,id 自增即最新), + * 并清除 getUserAgreementText 的 24h 缓存;`text` 可传空字符串。 + */ +export type WeChatSetUserAgreementParams = { + /** 用户须知富文本内容(可传空字符串清空) */ + text: string +} + +export function wechatSetUserAgreement( + data: WeChatSetUserAgreementParams +): Promise< + { code?: number; message?: string; data?: WeChatUserAgreementData } & Record +> { + return request({ + url: '/system', + method: 'post', + params: { + method: 'wechat.setUserAgreement', + v, + timestamp: new Date().getTime() + }, + data, + isSystemApi: true + } as any) +} + export const wechat = { getAuthUrl: wechatGetAuthUrl, queryAuth: wechatQueryAuth, @@ -415,7 +731,13 @@ export const wechat = { getTemplateList: wechatGetTemplateList, commit: wechatCommit, getTrialQRCode: wechatGetTrialQRCode, - submitAudit: wechatSubmitAudit + submitAudit: wechatSubmitAudit, + userList: wechatUserList, + bindByEmployee: wechatBindByEmployee, + getUserAgreement: wechatGetUserAgreement, + getAgreementVersion: wechatGetAgreementVersion, + getUserAgreementText: wechatGetUserAgreementText, + setUserAgreement: wechatSetUserAgreement } export default wechat diff --git a/src/components/RichTextEditor/index.vue b/src/components/RichTextEditor/index.vue new file mode 100644 index 00000000..798cce3a --- /dev/null +++ b/src/components/RichTextEditor/index.vue @@ -0,0 +1,540 @@ + +