const mongoose = require('mongoose'); const approvalSchema = new mongoose.Schema({ approvalId: { type: String, required: true, unique: true }, type: { type: String, enum: ['订单退款', '车辆报废', '押金退还', '价格修改', '其他'], required: true }, title: { type: String, required: true }, content: { type: String }, applicant: { type: String }, approver: { type: String }, status: { type: String, enum: ['待审批', '已通过', '已拒绝'], default: '待审批' }, remark: { type: String }, createdAt: { type: Date, default: Date.now }, updatedAt: { type: Date, default: Date.now } }); approvalSchema.pre('save', function(next) { if (!this.approvalId) { this.approvalId = `APPR${Date.now()}`; } this.updatedAt = new Date(); next(); }); module.exports = mongoose.model('Approval', approvalSchema);