完善保险端的前后端

This commit is contained in:
shenquanyi
2025-09-23 18:29:24 +08:00
parent e7a0cd4aa3
commit b58ed724b0
69 changed files with 9728 additions and 769 deletions

View File

@@ -0,0 +1,75 @@
'use strict';
module.exports = {
up: async (queryInterface, Sequelize) => {
// 添加参保类型字段
await queryInterface.addColumn('insurance_applications', 'insurance_category', {
type: Sequelize.STRING(50),
allowNull: true,
comment: '参保类型(如:牛、羊、猪等)',
after: 'insurance_type_id'
});
// 添加申请数量字段
await queryInterface.addColumn('insurance_applications', 'application_quantity', {
type: Sequelize.INTEGER,
allowNull: true,
defaultValue: 1,
comment: '申请数量',
validate: {
min: 1
},
after: 'insurance_category'
});
// 添加备注字段
await queryInterface.addColumn('insurance_applications', 'remarks', {
type: Sequelize.TEXT,
allowNull: true,
comment: '备注信息',
after: 'review_notes'
});
// 更新状态枚举值以匹配UI显示
await queryInterface.changeColumn('insurance_applications', 'status', {
type: Sequelize.ENUM(
'pending', // 待初审
'initial_approved', // 初审通过待复核
'under_review', // 已支付待复核
'approved', // 已支付
'rejected', // 已拒绝
'paid' // 已支付
),
allowNull: false,
defaultValue: 'pending',
comment: '申请状态'
});
// 添加索引
await queryInterface.addIndex('insurance_applications', ['insurance_category'], {
name: 'idx_insurance_applications_category'
});
await queryInterface.addIndex('insurance_applications', ['application_quantity'], {
name: 'idx_insurance_applications_quantity'
});
},
down: async (queryInterface, Sequelize) => {
// 移除索引
await queryInterface.removeIndex('insurance_applications', 'idx_insurance_applications_category');
await queryInterface.removeIndex('insurance_applications', 'idx_insurance_applications_quantity');
// 移除添加的字段
await queryInterface.removeColumn('insurance_applications', 'insurance_category');
await queryInterface.removeColumn('insurance_applications', 'application_quantity');
await queryInterface.removeColumn('insurance_applications', 'remarks');
// 恢复原始状态枚举
await queryInterface.changeColumn('insurance_applications', 'status', {
type: Sequelize.ENUM('pending', 'approved', 'rejected', 'under_review'),
allowNull: false,
defaultValue: 'pending'
});
}
};