diff --git a/docs/省管理员和单位管理员.docx b/docs/省管理员和单位管理员.docx new file mode 100644 index 0000000..08a4322 Binary files /dev/null and b/docs/省管理员和单位管理员.docx differ diff --git a/test_client/src/views/crm/company.vue b/test_client/src/views/crm/company.vue index ba050f2..80b005f 100644 --- a/test_client/src/views/crm/company.vue +++ b/test_client/src/views/crm/company.vue @@ -213,7 +213,7 @@ export default { this.getList(); }, handleAdd() { - this.company = Object.assign({}, defaultCompany); + this.company = deepClone(defaultCompany); this.dialogType = "new"; this.dialogVisible = true; this.$nextTick(() => { @@ -221,19 +221,25 @@ export default { }); }, handleEdit(scope) { - this.company = Object.assign({}, scope.row); // copy obj + this.company = deepClone(scope.row); // copy obj this.company.geo_ = ["", "", ""]; if (scope.row.geo) { if (scope.row.geo.pname) { this.company.geo_[0] = TextToCode[scope.row.geo.pname].code; if (scope.row.geo.cityname) { - this.company.geo_[1] = - TextToCode[scope.row.geo.pname][scope.row.geo.cityname].code; + if(TextToCode[scope.row.geo.pname][scope.row.geo.cityname]){ + this.company.geo_[1] = TextToCode[scope.row.geo.pname][scope.row.geo.cityname].code; + }else{ + this.company.geo_[1] = TextToCode[scope.row.geo.pname]['市辖区'].code; + } + if (scope.row.geo.adname) { - this.company.geo_[2] = - TextToCode[scope.row.geo.pname][scope.row.geo.cityname][ - scope.row.geo.adname - ].code; + if(TextToCode[scope.row.geo.pname][scope.row.geo.cityname]){ + this.company.geo_[2] = TextToCode[scope.row.geo.pname][scope.row.geo.cityname][scope.row.geo.adname].code; + }else{ + this.company.geo_[2] = TextToCode[scope.row.geo.pname]['市辖区'][scope.row.geo.adname].code; + } + } } } @@ -314,12 +320,15 @@ export default { this.selects = selects; }, handleRChange(val) { - if (val[0] != "") { - this.company.geo.pname = CodeToText[val[0]]; - if (val[1] != "") { - this.company.geo.cityname = CodeToText[val[1]]; - if (val[2] != "") { - this.company.geo.adname = CodeToText[val[2]]; + if (val) { + this.company.geo = {}; + if (val[0] != "") { + this.company.geo.pname = CodeToText[val[0]]; + if (val[1] != "") { + this.company.geo.cityname = CodeToText[val[1]]; + if (val[2] != "") { + this.company.geo.adname = CodeToText[val[2]]; + } } } } diff --git a/test_server/crm/views.py b/test_server/crm/views.py index cba084b..038c77b 100644 --- a/test_server/crm/views.py +++ b/test_server/crm/views.py @@ -145,25 +145,14 @@ class CompanyViewSet(ModelViewSet): def perform_create(self, serializer): instance = serializer.save(create_admin=self.request.user) - geo = None - try: - geo = getPosition2(instance.name) - except: - pass - if geo: - instance.geo = geo - instance.save() - - def perform_update(self, serializer): - instance = serializer.save() - geo = None - try: - geo = getPosition2(instance.name) - except: - pass - if geo: - instance.geo = geo - instance.save() + if not instance.geo: + try: + geo = getPosition2(instance.name) + except: + pass + if geo: + instance.geo = geo + instance.save() def get_queryset(self): queryset = self.queryset diff --git a/test_server/examtest/migrations/0027_exam_chance.py b/test_server/examtest/migrations/0027_exam_chance.py new file mode 100644 index 0000000..28dbe7e --- /dev/null +++ b/test_server/examtest/migrations/0027_exam_chance.py @@ -0,0 +1,18 @@ +# Generated by Django 3.0.4 on 2021-04-05 14:56 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('examtest', '0026_auto_20210321_0940'), + ] + + operations = [ + migrations.AddField( + model_name='exam', + name='chance', + field=models.IntegerField(default=3, verbose_name='考试机会'), + ), + ] diff --git a/test_server/examtest/models.py b/test_server/examtest/models.py index 5fb0227..e632c45 100644 --- a/test_server/examtest/models.py +++ b/test_server/examtest/models.py @@ -19,6 +19,7 @@ class Exam(CommonModel): proctor_name = models.CharField('监考人姓名', max_length=100) proctor_phone = models.CharField('监考人联系方式', max_length=100) create_admin = models.ForeignKey(UserProfile, on_delete=models.SET_NULL, null=True, blank=True, related_name='exam_create_admin') + chance = models.IntegerField('考试机会', default=3) def __str__(self): return self.name