id number

This commit is contained in:
caoqianming 2020-09-01 11:56:08 +08:00
parent 1086570fcc
commit 449ace26e2
6 changed files with 72 additions and 9 deletions

View File

@ -73,6 +73,7 @@ export function deleteConsumers(data) {
})
}
export function importConsumer(data) {
return request({
url: `/crm/consumer/import/`,

View File

@ -43,7 +43,7 @@
<span>{{ scope.row.create_admin_name }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="操作">
<el-table-column align="center" label="操作" fixed="right">
<template slot-scope="scope">
<el-button-group>
<el-button

View File

@ -93,6 +93,7 @@
>刷新重置</el-button>
</div>
<div style="margin-top:10px">
<el-button type="primary" @click="handleAddUser" icon="el-icon-plus">新增</el-button>
<el-popover
type="primary"
@ -127,12 +128,22 @@
@click="exportConsumer"
v-if="checkPermission(['consumer__export'])"
>导出Excel</el-button>
<el-button-group>
<el-button
type="danger"
icon="el-icon-delete"
round
@click="handleDeletes"
v-if="checkPermission(['consumer__deletes'])"
>批量删除</el-button>
<!-- <el-button
type="primary"
icon="el-icon-search"
round
@click="handleCands"
v-if="checkPermission(['consumer__candidates'])"
>批量查证</el-button> -->
</el-button-group>
<el-checkbox
v-model="showCreate"
class="filter-item"
@ -170,16 +181,16 @@
v-if="scope.row.company_name != null"
>{{ scope.row.company_name }}</template>
</el-table-column>
<el-table-column label="缴费学科">
<template slot-scope="scope">
<el-tag v-for="item in scope.row.subjects_name" :key="item">{{ item }}</el-tag>
</template>
</el-table-column>
<el-table-column label="工作类别" sortable="custom" prop="workscope">
<template slot-scope="scope">
<el-tag v-if="scope.row.workscope_name">{{ scope.row.workscope_name }}</el-tag>
</template>
</el-table-column>
<el-table-column label="证书信息">
<template slot-scope="scope">
<!-- <el-tag v-if="scope.row.workscope_name">{{ scope.row.workscope_name }}</el-tag> -->
</template>
</el-table-column>
<el-table-column label="创建信息" sortable="custom" prop="create_time" v-if="showCreate">
<template slot-scope="scope">
<span v-if="scope.row.create_admin_">{{ scope.row.create_admin_.username }}/</span>
@ -301,6 +312,9 @@
value-format="yyyy-MM-dd">
</el-date-picker>
</el-form-item>
<el-form-item label="身份证号" prop="ID_number1">
<el-input v-model="consumer.ID_number1" placeholder="身份证号" />
</el-form-item>
</el-form>
<div style="text-align:right;">
<el-button type="danger" @click="dialogVisible=false">取消</el-button>
@ -675,7 +689,7 @@ export default {
exportConsumer(this.listQuery).then((response) => {
loading.close();
window.open(response.data.path, "_blank");
});
}).catch(()=>{loading.close()});
},
changeSort(val) {
if (val.order == "ascending") {

View File

@ -0,0 +1,35 @@
# Generated by Django 3.0.4 on 2020-09-01 03:05
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
class Migration(migrations.Migration):
dependencies = [
('crm', '0023_auto_20200826_1444'),
]
operations = [
migrations.AddField(
model_name='consumer',
name='ID_number1',
field=models.CharField(blank=True, max_length=100, null=True, verbose_name='身份证号'),
),
migrations.CreateModel(
name='Candidate',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('create_time', models.DateTimeField(default=django.utils.timezone.now, help_text='创建时间', verbose_name='创建时间')),
('update_time', models.DateTimeField(auto_now=True, help_text='修改时间', verbose_name='修改时间')),
('is_delete', models.BooleanField(default=False, help_text='删除标记', verbose_name='删除标记')),
('report_number', models.TextField(verbose_name='报告单号')),
('issue_date', models.DateField(verbose_name='发证日期')),
('consumer', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='candidate_consumer', to='crm.Consumer')),
],
options={
'abstract': False,
},
),
]

View File

@ -72,6 +72,7 @@ class Consumer(CommonModel):
ID_number = models.CharField('身份证号', max_length=100, null=True, blank=True)
realname = models.CharField('真实姓名', max_length=100, null=True, blank=True)
ID_number1 = models.CharField('身份证号', max_length=100, null=True, blank=True)
create_admin = models.ForeignKey(UserProfile, on_delete=models.SET_NULL, null=True, blank=True)
exceed_date = models.DateField('账号过期', null=True, blank=True)
@ -100,4 +101,9 @@ class SendCode(CommonModel):
验证码发送记录
'''
phone = models.CharField(max_length=11, verbose_name='发送号码')
code = models.CharField(max_length=4, verbose_name= '验证码')
code = models.CharField(max_length=4, verbose_name= '验证码')
class Candidate(CommonModel):
consumer = models.ForeignKey(Consumer, on_delete=models.CASCADE, related_name='candidate_consumer')
report_number = models.TextField('报告单号')
issue_date = models.DateField('发证日期')

View File

@ -337,6 +337,8 @@ class ConsumerViewSet(ModelViewSet):
return Response({"error":"工作类别列错误!"})
if sheet['e2'].value != '角色':
return Response({"error":"角色列错误!"})
if sheet['f2'].value != '身份证号':
return Response({"error":"身份证号列错误!"})
m = 3
while sheet['B'+str(m)].value:
name = sheet['A'+str(m)].value
@ -345,6 +347,9 @@ class ConsumerViewSet(ModelViewSet):
username = sheet['B'+str(m)].value
if username:
username = str(username).replace(' ', '').replace("\n", "")
ID_number1 = sheet['F'+str(m)].value
if ID_number1:
ID_number1 = str(ID_number1).replace(' ', '').replace("\n", "")
companyname = sheet['C'+str(m)].value
if companyname:
companyname = companyname.replace(' ', '')
@ -362,6 +367,7 @@ class ConsumerViewSet(ModelViewSet):
obj.create_admin = request.user
obj.name = name
obj.company = companyobj
obj.ID_number1 = ID_number1
obj.save()
if workscope:
workscope = workscope.replace(' ', '')
@ -389,6 +395,8 @@ class ConsumerViewSet(ModelViewSet):
def export(self, request):
queryset = self.filter_queryset(self.queryset)
queryset = ConsumerSerializer.setup_eager_loading(queryset) # 性能优化
if queryset.count()>1000:
return Response({'error':'数据量超过1000,请筛选后导出'})
serializer = ConsumerSerializer(instance=queryset, many=True)
path = export_consumer(serializer.data)
return Response({'path': path})
@ -418,7 +426,6 @@ class ConsumerViewSet(ModelViewSet):
elif i.username and i.openid:
i.role = role2
i.save()
print(i.id)
return Response(status=status.HTTP_200_OK)
@action(methods=['get'], detail=False,