MaintenaceInfo add log_id model_id

FFIB 3 年 前
コミット
7a177cacc1
共有2 個のファイルを変更した34 個の追加0 個の削除を含む
  1. 25 0
      maintenance/migrations/0004_auto_20210916_1822.py
  2. 9 0
      maintenance/models.py

+ 25 - 0
maintenance/migrations/0004_auto_20210916_1822.py

@@ -0,0 +1,25 @@
1
+# -*- coding: utf-8 -*-
2
+# Generated by Django 1.11.26 on 2021-09-16 10:22
3
+from __future__ import unicode_literals
4
+
5
+from django.db import migrations, models
6
+
7
+
8
+class Migration(migrations.Migration):
9
+
10
+    dependencies = [
11
+        ('maintenance', '0003_auto_20210915_1653'),
12
+    ]
13
+
14
+    operations = [
15
+        migrations.AddField(
16
+            model_name='maintenaceinfo',
17
+            name='log_id',
18
+            field=models.CharField(blank=True, help_text='\u7528\u6237\u63d0\u4ea4\u5217\u8868\u7684\u552f\u4e00\u6807\u8bc6', max_length=255, null=True, verbose_name='log_id'),
19
+        ),
20
+        migrations.AddField(
21
+            model_name='maintenaceinfo',
22
+            name='model_id',
23
+            field=models.CharField(blank=True, db_index=True, help_text='\u578b\u53f7\u552f\u4e00\u6807\u8bc6', max_length=32, null=True, verbose_name='user_id'),
24
+        ),
25
+    ]

+ 9 - 0
maintenance/models.py

@@ -5,6 +5,8 @@ from django.utils.translation import ugettext_lazy as _
5 5
 from django_models_ext import BaseModelMixin
6 6
 from TimeConvert import TimeConvert as tc
7 7
 
8
+from mch.models import ModelInfo
9
+
8 10
 
9 11
 class MaintenacePointInfo(BaseModelMixin):
10 12
     name = models.CharField(_(u'name'), max_length=255, blank=True, null=True, help_text=u'名称')
@@ -55,6 +57,8 @@ class MaintenaceInfo(BaseModelMixin):
55 57
     phone = models.CharField(_(u'phone'), max_length=11, blank=True, null=True, help_text=u'电话')
56 58
     address = models.CharField(_(u'address'), max_length=255, blank=True, null=True, help_text=u'地址')
57 59
 
60
+    log_id = models.CharField(_(u'log_id'), max_length=255, blank=True, null=True, help_text=u'用户提交列表的唯一标识')
61
+    model_id = models.CharField(_(u'user_id'), max_length=32, blank=True, null=True, help_text=u'型号唯一标识', db_index=True)
58 62
     sn = models.CharField(_(u'sn'), max_length=32, blank=True, null=True, help_text=u'序列号', db_index=True)
59 63
     desc = models.TextField(_(u'desc'), blank=True, null=True, help_text=u'故障描述')
60 64
 
@@ -78,12 +82,17 @@ class MaintenaceInfo(BaseModelMixin):
78 82
 
79 83
     @property
80 84
     def data(self):
85
+        model = ModelInfo.objects.get(model_id=self.model_id, status=True)
81 86
         return {
82 87
             'id': self.pk,
83 88
             'user_id': self.user_id,
84 89
             'name': self.name,
85 90
             'phone': self.phone,
86 91
             'address': self.address,
92
+            'model_id': self.model_id,
93
+            'model_name': model.model_name,
94
+            'model_full_name': model.model_full_name,
95
+            'log_id': self.log_id,
87 96
             'sn': self.sn,
88 97
             'desc': self.desc,
89 98
             'point_id': self.point_id,