|
@@ -0,0 +1,77 @@
|
|
|
+'use strict';
|
|
|
+const moment = require('moment');
|
|
|
+const Schema = require('mongoose').Schema;
|
|
|
+const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
|
|
|
+// 车辆日常维护
|
|
|
+const daily = {
|
|
|
+ car_no: {
|
|
|
+ type: String,
|
|
|
+ required: true,
|
|
|
+ maxLength: 200,
|
|
|
+ field: { label: '车牌号', filter: 'select', required: true, type: 'select', format: true },
|
|
|
+ row: 1,
|
|
|
+ },
|
|
|
+ money: {
|
|
|
+ type: Number,
|
|
|
+ required: true,
|
|
|
+ maxLength: 200,
|
|
|
+ field: { label: '金额', filter: true, required: true, type: 'number' },
|
|
|
+ row: 2,
|
|
|
+ },
|
|
|
+ item: {
|
|
|
+ type: String,
|
|
|
+ required: true,
|
|
|
+ maxLength: 200,
|
|
|
+ field: { label: '项目', filter: true, required: true },
|
|
|
+ row: 3,
|
|
|
+ },
|
|
|
+ date: {
|
|
|
+ type: String,
|
|
|
+ maxLength: 200,
|
|
|
+ default: moment().format('YYYY-MM-DD'),
|
|
|
+ field: { label: '维护时间', type: 'date', required: true, filter: 'date' },
|
|
|
+ row: 4,
|
|
|
+ },
|
|
|
+ remark: {
|
|
|
+ type: String,
|
|
|
+ required: false,
|
|
|
+ maxLength: 200,
|
|
|
+ field: {
|
|
|
+ label: '备注',
|
|
|
+ type: 'textarea',
|
|
|
+ options: { autosize: { minRows: 3, maxRows: 5 } },
|
|
|
+ },
|
|
|
+ row: 5,
|
|
|
+ },
|
|
|
+ status: {
|
|
|
+ type: String,
|
|
|
+ maxLength: 200,
|
|
|
+ default: '0',
|
|
|
+ field: {
|
|
|
+ label: '状态',
|
|
|
+ filter: 'select',
|
|
|
+ type: 'radio',
|
|
|
+ format: (i => (i === '0' ? '未结算' : '已结算')).toString(),
|
|
|
+ list: [
|
|
|
+ { label: '未结算', value: '0' },
|
|
|
+ { label: '已结算', value: '1' },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ row: 6,
|
|
|
+ },
|
|
|
+};
|
|
|
+
|
|
|
+const schema = new Schema(daily, { toJSON: { virtuals: true } });
|
|
|
+schema.index({ id: 1 });
|
|
|
+schema.index({ car_no: 1 });
|
|
|
+schema.index({ money: 1 });
|
|
|
+schema.index({ item: 1 });
|
|
|
+schema.index({ date: 1 });
|
|
|
+schema.index({ status: 1 });
|
|
|
+
|
|
|
+schema.plugin(metaPlugin);
|
|
|
+
|
|
|
+module.exports = app => {
|
|
|
+ const { mongoose } = app;
|
|
|
+ return mongoose.model('Daily', schema, 'daily');
|
|
|
+};
|