|
@@ -0,0 +1,92 @@
|
|
|
+'use strict';
|
|
|
+const Schema = require('mongoose').Schema;
|
|
|
+const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
|
|
|
+// 字典
|
|
|
+const mode = {
|
|
|
+ name: {
|
|
|
+ type: String,
|
|
|
+ required: true,
|
|
|
+ maxLength: 200,
|
|
|
+ field: { label: '方式名称', filter: true, required: true },
|
|
|
+ },
|
|
|
+ route: {
|
|
|
+ type: String,
|
|
|
+ required: true,
|
|
|
+ maxLength: 200,
|
|
|
+ field: { label: '线路', required: true },
|
|
|
+ },
|
|
|
+ price: {
|
|
|
+ type: String,
|
|
|
+ required: true,
|
|
|
+ maxLength: 200,
|
|
|
+ field: { label: '价格', filter: true, required: true },
|
|
|
+ },
|
|
|
+ is_lf: {
|
|
|
+ type: Boolean,
|
|
|
+ required: true,
|
|
|
+ field: {
|
|
|
+ label: '是否量份收费',
|
|
|
+ required: true,
|
|
|
+ format: (i => (i ? '是' : '否')).toString(),
|
|
|
+ type: 'radio',
|
|
|
+ list: [
|
|
|
+ { label: '是', value: true },
|
|
|
+ { label: '否', value: false },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ },
|
|
|
+ send_type: {
|
|
|
+ type: String,
|
|
|
+ maxLength: 200,
|
|
|
+ field: {
|
|
|
+ label: '发货方式',
|
|
|
+ type: 'radio',
|
|
|
+ list: [
|
|
|
+ { label: '整车', value: '整车' },
|
|
|
+ { label: '零担', value: '零担' },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ },
|
|
|
+ computed_type: {
|
|
|
+ type: String,
|
|
|
+ maxLength: 200,
|
|
|
+ field: {
|
|
|
+ label: '计费方式',
|
|
|
+ type: 'radio',
|
|
|
+ list: [
|
|
|
+ { label: '按体积', value: '按体积' },
|
|
|
+ { label: '按重量', value: '按重量' },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ },
|
|
|
+ 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(mode, { toJSON: { virtuals: true } });
|
|
|
+schema.index({ id: 1 });
|
|
|
+schema.index({ name: 1 });
|
|
|
+schema.index({ route: 1 });
|
|
|
+schema.index({ price: 1 });
|
|
|
+schema.index({ owner: 1 });
|
|
|
+
|
|
|
+schema.plugin(metaPlugin);
|
|
|
+
|
|
|
+module.exports = app => {
|
|
|
+ const { mongoose } = app;
|
|
|
+ return mongoose.model('Mode', schema, 'mode');
|
|
|
+};
|