省市区
This commit is contained in:
parent
5838faa4b9
commit
231ff0c064
Binary file not shown.
|
@ -213,7 +213,7 @@ export default {
|
||||||
this.getList();
|
this.getList();
|
||||||
},
|
},
|
||||||
handleAdd() {
|
handleAdd() {
|
||||||
this.company = Object.assign({}, defaultCompany);
|
this.company = deepClone(defaultCompany);
|
||||||
this.dialogType = "new";
|
this.dialogType = "new";
|
||||||
this.dialogVisible = true;
|
this.dialogVisible = true;
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
|
@ -221,19 +221,25 @@ export default {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
handleEdit(scope) {
|
handleEdit(scope) {
|
||||||
this.company = Object.assign({}, scope.row); // copy obj
|
this.company = deepClone(scope.row); // copy obj
|
||||||
this.company.geo_ = ["", "", ""];
|
this.company.geo_ = ["", "", ""];
|
||||||
if (scope.row.geo) {
|
if (scope.row.geo) {
|
||||||
if (scope.row.geo.pname) {
|
if (scope.row.geo.pname) {
|
||||||
this.company.geo_[0] = TextToCode[scope.row.geo.pname].code;
|
this.company.geo_[0] = TextToCode[scope.row.geo.pname].code;
|
||||||
if (scope.row.geo.cityname) {
|
if (scope.row.geo.cityname) {
|
||||||
this.company.geo_[1] =
|
if(TextToCode[scope.row.geo.pname][scope.row.geo.cityname]){
|
||||||
TextToCode[scope.row.geo.pname][scope.row.geo.cityname].code;
|
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) {
|
if (scope.row.geo.adname) {
|
||||||
this.company.geo_[2] =
|
if(TextToCode[scope.row.geo.pname][scope.row.geo.cityname]){
|
||||||
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;
|
||||||
scope.row.geo.adname
|
}else{
|
||||||
].code;
|
this.company.geo_[2] = TextToCode[scope.row.geo.pname]['市辖区'][scope.row.geo.adname].code;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -314,12 +320,15 @@ export default {
|
||||||
this.selects = selects;
|
this.selects = selects;
|
||||||
},
|
},
|
||||||
handleRChange(val) {
|
handleRChange(val) {
|
||||||
if (val[0] != "") {
|
if (val) {
|
||||||
this.company.geo.pname = CodeToText[val[0]];
|
this.company.geo = {};
|
||||||
if (val[1] != "") {
|
if (val[0] != "") {
|
||||||
this.company.geo.cityname = CodeToText[val[1]];
|
this.company.geo.pname = CodeToText[val[0]];
|
||||||
if (val[2] != "") {
|
if (val[1] != "") {
|
||||||
this.company.geo.adname = CodeToText[val[2]];
|
this.company.geo.cityname = CodeToText[val[1]];
|
||||||
|
if (val[2] != "") {
|
||||||
|
this.company.geo.adname = CodeToText[val[2]];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -145,25 +145,14 @@ class CompanyViewSet(ModelViewSet):
|
||||||
|
|
||||||
def perform_create(self, serializer):
|
def perform_create(self, serializer):
|
||||||
instance = serializer.save(create_admin=self.request.user)
|
instance = serializer.save(create_admin=self.request.user)
|
||||||
geo = None
|
if not instance.geo:
|
||||||
try:
|
try:
|
||||||
geo = getPosition2(instance.name)
|
geo = getPosition2(instance.name)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
if geo:
|
if geo:
|
||||||
instance.geo = geo
|
instance.geo = geo
|
||||||
instance.save()
|
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()
|
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
queryset = self.queryset
|
queryset = self.queryset
|
||||||
|
|
|
@ -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='考试机会'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -19,6 +19,7 @@ class Exam(CommonModel):
|
||||||
proctor_name = models.CharField('监考人姓名', max_length=100)
|
proctor_name = models.CharField('监考人姓名', max_length=100)
|
||||||
proctor_phone = 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')
|
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):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
Loading…
Reference in New Issue