driver.js 2.0 KB

1234567891011121314151617181920212223242526
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  4. // 司机表
  5. const Driverchema = {
  6. name: { type: String, required: true, maxLength: 200, field: { required: true, label: '姓名', filter: true } }, // 姓名
  7. tel: { type: String, required: true, maxLength: 200, field: { required: true, label: '联系电话', filter: true } }, // 电话/固定电话
  8. id_card: { type: String, required: true, maxLength: 200, field: { required: true, label: '身份证', filter: true, options: { maxLength: 18, minLength: 18 } } }, // 身份证
  9. drive_card: { type: String, required: true, maxLength: 200, field: { required: true, label: '驾驶证号' } }, // 驾驶证号
  10. fhc_time: { type: String, required: false, maxLength: 200, field: { label: '初次领证时间', type: 'date', notable: true } }, // 初次领证时间=年月日
  11. car_type: { type: String, required: false, maxLength: 200, field: { label: '准驾车型', notable: true } }, // 准驾车型
  12. ccu_time: { type: String, required: false, maxLength: 200, field: { required: true, label: '驾驶证有效日期', notable: true, type: 'date' } }, // 驾驶证有效日期
  13. cc_time: { type: String, required: false, maxLength: 200, field: { required: true, label: '驾驶证年检日期', notable: true, type: 'date' } }, // 驾驶证年检日期
  14. qc_time: { type: String, required: false, maxLength: 200, field: { required: true, label: '资格证年检日期', notable: true, type: 'date' } }, // 资格证年检日期
  15. status: { type: String, required: false, maxLength: 200, default: '在籍', field: { label: '状态', type: 'radio', filter: 'select', list: [{ label: '在籍', value: '在籍' }, { label: '注销', value: '注销' }] } },
  16. };
  17. const schema = new Schema(Driverchema, { toJSON: { virtuals: true } });
  18. schema.index({ id: 1 });
  19. schema.plugin(metaPlugin);
  20. module.exports = app => {
  21. const { mongoose } = app;
  22. return mongoose.model('Diver', schema, 'driver');
  23. };