Compare commits

...
6 Commits
Author SHA1 Message Date
zlwu 3a396d79a2 chore(mobile-h5): 切换本地联调环境与测试 AppID
continuous-integration/drone/tag Build is passing
按用户本地验收要求,将 APP_ENV 切换为 local,使用本机 API 和移动 H5 地址,并将微信 AppID 切换为测试号。
2026-11-10 09:37:04 +08:00
zlwu 9c4944702b fix(db): 补充协议操作日志旧表纠偏脚本
为同名旧表与现行日志模型不兼容的情况提供迁移脚本,并在原建表脚本注明纠偏入口。保留有数据的旧表为备份;本次仅提交现有脚本,未执行数据库迁移。
2026-11-10 09:37:04 +08:00
cykj e06f89dcf6 Merge pull request 'fix(mobile): 修复协议单保存前项目校验异常' (#79) from codex/issue-78-protocol-save into V2.0 2026-11-10 01:24:10 +00:00
zlwu f343f12645 fix(mobile): 修复协议单项目校验引用导致保存中断
循环模板内字符串 ref 被 Vue 收集为数组,调用 validate 时在请求前抛错。改用函数 ref 保持单组件实例,并覆盖两角色新增、编辑及项目校验提示。关联工单 #78。
2026-11-10 09:21:29 +08:00
zlwuandCursor 1032631318 chore(mobile-h5): 微信小程序 AppID 切换为生产
将 mp-weixin.appid 改为 wx2b139581f4c855e4,与 APP_ENV=prod 对齐。

Refs: #77
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-09 16:32:24 +08:00
zlwuandCursor f9f79479e8 chore(mobile-h5): 小程序切换为生产环境配置
将 APP_ENV 设为 prod,API/OA H5/MinIO 指向 xwyd.zkxw.cn,便于发生产版。

Refs: #76
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-09 16:27:28 +08:00
5 changed files with 235 additions and 2 deletions

No files matched your search

@@ -1,6 +1,10 @@
-- Issue #24:协议单操作过程日志(before / action / after)
-- MySQL 5.7;可重复执行(CREATE IF NOT EXISTS)。上线前须备份并在目标副本验证。
-- DDL 隐式提交;该脚本不作为自动应用启动步骤。
--
-- 注意:若目标库已存在同名「采集协议单操作日志」旧表(含 collection_protocol_id /
-- operation_code 等列),本脚本会因 IF NOT EXISTS 直接跳过,不会纠偏。
-- 生产纠偏请改用:2026-11-09-protocol-operation-log-rebuild.sql
CREATE TABLE IF NOT EXISTS biz_protocol_operation_log (
id VARCHAR(64) NOT NULL,
@@ -0,0 +1,119 @@
-- =============================================================================
-- 协议操作日志:兼容生产旧表同名冲突,重建为 Issue #24 模型
-- MySQL 5.7;可重复执行。上线前须备份,并在目标副本验证。
--
-- 背景:
-- 生产曾有「采集协议单操作日志」同名表(collection_protocol_id / operation_*),
-- 与当前代码(biz_type / before_json / after_json)不兼容。
-- 旧脚本 2026-11-05-protocol-operation-log.sql 使用 CREATE IF NOT EXISTS,
-- 遇到旧表会直接跳过,无法纠偏。本脚本用于生产纠偏与新环境兜底。
--
-- 行为:
-- 1) 已是新模型(有 biz_type)→ 跳过结构变更
-- 2) 旧模型且 0 行 → DROP 后按新模型 CREATE
-- 3) 旧模型且有数据 → RENAME 为 biz_protocol_operation_log_legacy_20261109 再 CREATE
-- 4) 表不存在 → 直接 CREATE
-- =============================================================================
SET @db := DATABASE();
SET @table_exists := (
SELECT COUNT(*) FROM information_schema.tables
WHERE table_schema = @db AND table_name = 'biz_protocol_operation_log'
);
SET @has_legacy_col := (
SELECT COUNT(*) FROM information_schema.columns
WHERE table_schema = @db
AND table_name = 'biz_protocol_operation_log'
AND column_name = 'collection_protocol_id'
);
SET @has_new_col := (
SELECT COUNT(*) FROM information_schema.columns
WHERE table_schema = @db
AND table_name = 'biz_protocol_operation_log'
AND column_name = 'biz_type'
);
SET @is_legacy := IF(@table_exists > 0 AND @has_legacy_col > 0 AND @has_new_col = 0, 1, 0);
SET @legacy_rows := 0;
SET @cnt_sql := IF(
@is_legacy = 1,
'SET @legacy_rows = (SELECT COUNT(*) FROM `biz_protocol_operation_log`)',
'SET @legacy_rows = 0'
);
PREPARE pol_stmt FROM @cnt_sql;
EXECUTE pol_stmt;
DEALLOCATE PREPARE pol_stmt;
-- 空旧表:直接删除
SET @drop_sql := IF(
@is_legacy = 1 AND @legacy_rows = 0,
'DROP TABLE `biz_protocol_operation_log`',
'SELECT ''skip drop empty legacy biz_protocol_operation_log'' AS migration_status'
);
PREPARE pol_stmt FROM @drop_sql;
EXECUTE pol_stmt;
DEALLOCATE PREPARE pol_stmt;
-- 有数据的旧表:改名保留,避免丢历史(当前生产为 0 行,通常不会走到这里)
SET @legacy_backup_exists := (
SELECT COUNT(*) FROM information_schema.tables
WHERE table_schema = @db AND table_name = 'biz_protocol_operation_log_legacy_20261109'
);
SET @rename_sql := IF(
@is_legacy = 1 AND @legacy_rows > 0 AND @legacy_backup_exists = 0,
'RENAME TABLE `biz_protocol_operation_log` TO `biz_protocol_operation_log_legacy_20261109`',
IF(
@is_legacy = 1 AND @legacy_rows > 0 AND @legacy_backup_exists > 0,
'SELECT ''ERROR: legacy backup biz_protocol_operation_log_legacy_20261109 already exists; resolve manually'' AS migration_status',
'SELECT ''skip rename legacy biz_protocol_operation_log'' AS migration_status'
)
);
PREPARE pol_stmt FROM @rename_sql;
EXECUTE pol_stmt;
DEALLOCATE PREPARE pol_stmt;
-- 新模型建表(纠偏后或全新环境)
CREATE TABLE IF NOT EXISTS `biz_protocol_operation_log` (
`id` VARCHAR(64) NOT NULL COMMENT '主键ID',
`biz_type` VARCHAR(32) NOT NULL COMMENT '业务类型 cell_storage/research_donation',
`biz_id` VARCHAR(64) NOT NULL COMMENT '协议单或捐赠单ID',
`protocol_no` VARCHAR(64) NULL COMMENT '协议/捐赠编号快照',
`action` VARCHAR(32) NOT NULL COMMENT '动作 create/update/delete/void/activate/expire/to_research/to_storage/audit',
`client_channel` VARCHAR(16) NOT NULL DEFAULT 'web' COMMENT '来源端 web/mini',
`before_json` MEDIUMTEXT NULL COMMENT '操作前协议信息JSON',
`after_json` MEDIUMTEXT NULL COMMENT '操作后协议信息JSON',
`operator_user_id` VARCHAR(64) NULL COMMENT '操作人用户ID',
`operator_user_name` VARCHAR(64) NULL COMMENT '操作人姓名快照',
`operate_time` DATETIME NOT NULL COMMENT '业务操作时间',
`tenant_no` VARCHAR(64) NOT NULL COMMENT '租户编号',
`order_num` INT NULL COMMENT '排序号',
`remark` VARCHAR(512) NULL COMMENT '备注',
`create_by` VARCHAR(64) NULL COMMENT '创建人id',
`create_dept_id` VARCHAR(64) NOT NULL DEFAULT '' COMMENT '创建人部门ID',
`create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_by` VARCHAR(64) NULL COMMENT '更新人id',
`update_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`del_flag` SMALLINT NOT NULL DEFAULT 0 COMMENT '删除标记',
PRIMARY KEY (`id`),
KEY `ix_pol_biz` (`tenant_no`, `biz_type`, `biz_id`, `del_flag`),
KEY `ix_pol_time` (`tenant_no`, `operate_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='协议单操作过程日志';
-- 验收:新模型关键列应存在
SELECT
COLUMN_NAME,
COLUMN_TYPE,
IS_NULLABLE,
COLUMN_COMMENT
FROM information_schema.columns
WHERE table_schema = DATABASE()
AND table_name = 'biz_protocol_operation_log'
AND COLUMN_NAME IN (
'biz_type', 'biz_id', 'action', 'before_json', 'after_json',
'client_channel', 'operate_time', 'collection_protocol_id', 'operation_code'
)
ORDER BY ORDINAL_POSITION;
+1 -1
View File
@@ -6,7 +6,7 @@
*
* 微信公众平台须为对应环境配置 request / 业务域名(HTTPS)
*/
export const APP_ENV = 'test' // 'local' | 'test' | 'prod'
export const APP_ENV = 'local' // 'local' | 'test' | 'prod'
const ENV_PRESETS = {
local: {
@@ -0,0 +1,110 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import { readFileSync } from 'node:fs'
import vm from 'node:vm'
import * as Vue from 'vue'
import { compile } from '@vue/compiler-dom'
import { projectValidation } from './project-assignment.js'
const source = readFileSync(new URL('../views/market/MarketModuleForm.vue', import.meta.url), 'utf8')
// Render the real loop/slot/ref structure; native host nodes need no browser or service.
const template = source.slice(source.indexOf('<template v-for="section in leadingSections"'), source.indexOf('\n\n <section'))
const render = new Function('Vue', compile(template, { prefixIdentifiers: true }).code)(Vue)
const submitSource = source.slice(source.indexOf('async function submit()'), source.indexOf('\nasync function confirmLeave()'))
const renderer = Vue.createRenderer({
createElement: () => ({}), createText: () => ({}), createComment: () => ({}),
insert(node, parent, anchor = null) {
parent.children ||= []
node.parent = parent
const index = parent.children.indexOf(anchor)
parent.children.splice(index < 0 ? parent.children.length : index, 0, node)
},
remove(node) {
const siblings = node.parent?.children || []
const index = siblings.indexOf(node)
if (index >= 0) siblings.splice(index, 1)
},
setText() {}, setElementText() {}, patchProp() {},
parentNode: (node) => node.parent,
nextSibling: (node) => {
const siblings = node.parent?.children || []
return siblings[siblings.indexOf(node) + 1] || null
}
})
async function mountForm({ role, mode = 'create', projectId = 'project-1', loading = false, error = '' }) {
const projectAssignment = Vue.ref(null)
const formData = Vue.ref({ source: 'research_donation', projectId })
const messages = [], requests = []
let validations = 0
const ProjectAssignmentField = {
setup(_, { expose }) {
expose({ validate() {
validations++
return projectValidation({ editing: mode === 'edit', required: true, projectId, loading, error })
} })
return () => Vue.h('div')
}
}
const Section = { setup: (_, { slots }) => () => slots.insert?.() }
const context = Vue.ref({ module: 'protocol', marketRole: role })
const app = renderer.createApp({
components: { MarketFormSection: Section, ProjectAssignmentField },
setup: () => ({
projectAssignment, context, formData, mode,
leadingSections: [{ key: 'customer' }, { key: 'protocol' }],
formOptions: {}, fieldsLocked: false, dirty: false,
sectionValue: () => ({}), searchProtocolCustomers() {}, setSectionValue() {},
uploadField() {}, handleFieldChange() {}, handleCustomerSelect() {}
}), render
})
app.mount({})
await Vue.nextTick()
const scope = {
projectAssignment, context, formData, mode: Vue.ref(mode),
submitting: Vue.ref(false), uploadPending: Vue.ref(0), isProtocolV2: Vue.ref(false),
isProtocolV1: Vue.ref(false), id: Vue.ref(mode === 'edit' ? 'record-1' : ''),
action: Vue.ref(mode), visibleSections: Vue.ref([]), dirty: Vue.ref(true),
showToast: (text) => messages.push(text), showSuccessToast: (text) => messages.push(text),
validateRequiredFields: () => '', buildMarketActionPayload: (_module, _action, data) => data,
sanitizeMarketPayload: (data) => data, buildPayload: () => formData.value,
AbortController, submitController: null, allowLeave: false,
saveMarketRecord: async (...args) => { requests.push(args); return { id: 'saved' } },
mountGuard: { isCurrent: () => true }, mountToken: 1,
resolveMarketSavedDetailId: () => 'saved', router: { replace: async () => {} },
route: { query: {} }, marketRecordNavigationQuery: () => ({}),
marketErrorMessage: (cause) => cause.message
}
const submit = vm.runInNewContext(`${submitSource}\nsubmit`, scope)
return { submit, messages, requests, app, validations: () => validations }
}
for (const role of ['specialist', 'manager']) {
for (const mode of ['create', 'edit']) {
test(`${role} ${mode}: a valid project reaches the save request`, async () => {
const form = await mountForm({ role, mode })
try {
await form.submit()
assert.equal(form.validations(), 1)
assert.equal(form.requests.length, 1)
assert.equal(form.requests[0][0].marketRole, role)
assert.deepEqual(form.messages, ['保存成功'])
} finally { form.app.unmount() }
})
}
for (const [state, message] of [
[{ projectId: '' }, '请选择所属项目'],
[{ loading: true }, '项目选项加载中,请稍后保存'],
[{ error: 'network' }, '项目选项加载失败,请重试后保存']
]) {
test(`${role}: ${message}`, async () => {
const form = await mountForm({ role, ...state })
try {
await form.submit()
assert.equal(form.validations(), 1)
assert.equal(form.requests.length, 0)
assert.deepEqual(form.messages, [message])
} finally { form.app.unmount() }
})
}
}
@@ -46,7 +46,7 @@
>
<template #insert>
<ProjectAssignmentField
ref="projectAssignment"
:ref="(instance) => (projectAssignment = instance)"
embedded
v-model="formData.projectId"
:biz-type="formData.source"