|
@@ -0,0 +1,53 @@
|
|
|
|
+'use strict';
|
|
|
|
+const Schema = require('mongoose').Schema;
|
|
|
|
+const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
|
|
|
|
+// 合同
|
|
|
|
+const item = {
|
|
|
|
+ treaty: {
|
|
|
|
+ type: String,
|
|
|
|
+ required: true,
|
|
|
|
+ maxLength: 200,
|
|
|
|
+ field: { label: '合同', required: true },
|
|
|
|
+ },
|
|
|
|
+ name: {
|
|
|
|
+ type: String,
|
|
|
|
+ required: true,
|
|
|
|
+ maxLength: 200,
|
|
|
|
+ field: { label: '项目名', filter: true, required: true },
|
|
|
|
+ },
|
|
|
|
+ taxes: {
|
|
|
|
+ type: String,
|
|
|
|
+ required: true,
|
|
|
|
+ maxLength: 200,
|
|
|
|
+ field: { label: '税率', filter: true, required: true },
|
|
|
|
+ },
|
|
|
|
+ status: {
|
|
|
|
+ type: String,
|
|
|
|
+ maxLength: 200,
|
|
|
|
+ default: '0',
|
|
|
|
+ field: {
|
|
|
|
+ label: '状态',
|
|
|
|
+ filter: 'select',
|
|
|
|
+ type: 'select',
|
|
|
|
+ format: (i => (i === '0' ? '使用' : '禁用')).toString(),
|
|
|
|
+ list: [
|
|
|
|
+ { label: '使用', value: '0' },
|
|
|
|
+ { label: '禁用', value: '1' },
|
|
|
|
+ ],
|
|
|
|
+ },
|
|
|
|
+ }, // 状态:0=>使用;1禁用
|
|
|
|
+ owner: { type: String, required: true }, // 创建人
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+const schema = new Schema(item, { toJSON: { virtuals: true } });
|
|
|
|
+schema.index({ id: 1 });
|
|
|
|
+schema.index({ name: 1 });
|
|
|
|
+schema.index({ status: 1 });
|
|
|
|
+schema.index({ owner: 1 });
|
|
|
|
+
|
|
|
|
+schema.plugin(metaPlugin);
|
|
|
|
+
|
|
|
|
+module.exports = app => {
|
|
|
|
+ const { mongoose } = app;
|
|
|
|
+ return mongoose.model('Item', schema, 'item');
|
|
|
|
+};
|