consumer perm
This commit is contained in:
parent
d2a9034c20
commit
1837f67df5
|
@ -19,6 +19,22 @@
|
|||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
<el-select
|
||||
v-model="listQuery.role"
|
||||
placeholder="用户类型"
|
||||
clearable
|
||||
filterable
|
||||
style="width: 200px"
|
||||
class="filter-item"
|
||||
@change="handleFilter"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in roleData"
|
||||
:key="item.key"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
<!-- <el-select
|
||||
v-model="listQuery.is_paid"
|
||||
placeholder="是否缴费"
|
||||
|
@ -108,8 +124,8 @@
|
|||
<el-table-column align="header-center" label="小程序OpenId">
|
||||
<template slot-scope="scope">{{ scope.row.openid }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="header-center" label="微信昵称">
|
||||
<template slot-scope="scope">{{ scope.row.nickname }}</template>
|
||||
<el-table-column align="header-center" label="用户类型">
|
||||
<template slot-scope="scope">{{ scope.row.role_name }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="header-center" label="单位" sortable="custom" prop="company">
|
||||
<template
|
||||
|
@ -221,6 +237,16 @@
|
|||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="用户类型" prop="role">
|
||||
<el-select v-model="consumer.role" placeholder="用户类型" style="width:100%" clearable>
|
||||
<el-option
|
||||
v-for="item in roleData"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div style="text-align:right;">
|
||||
<el-button type="danger" @click="dialogVisible=false">取消</el-button>
|
||||
|
@ -239,7 +265,8 @@ import {
|
|||
importConsumer,
|
||||
exportConsumer,
|
||||
deleteConsumers,
|
||||
unbindConsumer
|
||||
unbindConsumer,
|
||||
getConsumerRoleAll
|
||||
} from "@/api/crm";
|
||||
import { getSubjectAll } from "@/api/question";
|
||||
import { getWorkScopeAll } from "@/api/examtest";
|
||||
|
@ -256,7 +283,8 @@ const defaultConsumer = {
|
|||
username: "",
|
||||
company: null,
|
||||
subjects: [],
|
||||
workscope: null
|
||||
workscope: null,
|
||||
role:3
|
||||
};
|
||||
const listQuery = {
|
||||
page: 1,
|
||||
|
@ -296,25 +324,27 @@ export default {
|
|||
name: [{ required: true, message: "请输入姓名", trigger: "blur" }],
|
||||
username: [
|
||||
{ required: true, message: "请输入手机号", trigger: "change" }
|
||||
]
|
||||
// password: [
|
||||
// { required: true, message: "请输入密码", trigger: "change" }
|
||||
// ],
|
||||
],
|
||||
role: [
|
||||
{ required: true, message: "请选择", trigger: "change" }
|
||||
],
|
||||
},
|
||||
filterOrgText: "",
|
||||
treeLoding: false,
|
||||
companyData: [],
|
||||
subjectData: [],
|
||||
workscopeData: [],
|
||||
roleData:[],
|
||||
selects: []
|
||||
};
|
||||
},
|
||||
computed: {},
|
||||
created() {
|
||||
this.getList();
|
||||
this.getCompanyList();
|
||||
this.getSubjectAll();
|
||||
this.getWorkScopeAll();
|
||||
this.getList()
|
||||
this.getCompanyList()
|
||||
this.getSubjectAll()
|
||||
this.getWorkScopeAll()
|
||||
this.getConsumerRoleAll()
|
||||
},
|
||||
methods: {
|
||||
checkPermission,
|
||||
|
@ -379,6 +409,11 @@ export default {
|
|||
this.workscopeData = genTree(response.data);
|
||||
});
|
||||
},
|
||||
getConsumerRoleAll() {
|
||||
getConsumerRoleAll().then(response => {
|
||||
this.roleData = genTree(response.data);
|
||||
});
|
||||
},
|
||||
resetFilter() {
|
||||
this.listQuery = {
|
||||
page: 1,
|
||||
|
|
|
@ -57,9 +57,9 @@ App({
|
|||
globalData: {
|
||||
userInfo: {},
|
||||
userinfo: {}, // 服务器传回的消费者信息
|
||||
host: 'https://apitest.ahctc.cn',
|
||||
//host: 'https://apitest.ahctc.cn',
|
||||
mediahost: 'https://apitest.ahctc.cn',
|
||||
//host: 'http://127.0.0.1:8000',
|
||||
host: 'http://127.0.0.1:8000',
|
||||
//mediahost: 'http://127.0.0.1:8000',
|
||||
token : '',
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
"disablePlugins": [],
|
||||
"outputPath": ""
|
||||
},
|
||||
"useCompilerModule": false,
|
||||
"useCompilerModule": true,
|
||||
"userConfirmedUseCompilerModuleSwitch": false
|
||||
},
|
||||
"compileType": "miniprogram",
|
||||
|
|
|
@ -18,8 +18,12 @@ function request(url, method, data) {
|
|||
})
|
||||
}
|
||||
else {
|
||||
var msg = JSON.stringify(res.data.msg)
|
||||
if (msg.indexOf('该操作的权限')!=-1){
|
||||
msg = '权限不足,请注册登陆或联系课程顾问'
|
||||
}
|
||||
wx.showToast({
|
||||
title: JSON.stringify(res.data.msg),
|
||||
title: msg,
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
# Generated by Django 3.0.4 on 2020-06-28 01:04
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('crm', '0015_auto_20200627_1413'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='consumer',
|
||||
name='role',
|
||||
field=models.ForeignKey(blank=True, default=1, null=True, on_delete=django.db.models.deletion.SET_NULL, to='crm.ConsumerRole', verbose_name='用户角色'),
|
||||
),
|
||||
]
|
|
@ -63,7 +63,7 @@ class Consumer(SoftCommonModel):
|
|||
workscope = models.ForeignKey(WorkScope, verbose_name='工作类别', on_delete=models.SET_NULL, null=True, blank=True)
|
||||
collects = models.ManyToManyField(Question, verbose_name='收藏试题')
|
||||
remain_count = models.IntegerField('体验次数', default=3)
|
||||
role = models.ForeignKey(ConsumerRole, verbose_name='用户角色', default=ConsumerRole.objects.get(name='游客'), on_delete=models.SET_NULL, null=True, blank=True)
|
||||
role = models.ForeignKey(ConsumerRole, verbose_name='用户角色', default=1, on_delete=models.SET_NULL, null=True, blank=True)
|
||||
|
||||
|
||||
class Meta:
|
||||
|
|
|
@ -34,6 +34,7 @@ class ConsumerSerializer(serializers.ModelSerializer):
|
|||
company_name = serializers.StringRelatedField(source='company', read_only=True)
|
||||
subjects_name = serializers.StringRelatedField(source='subjects', many=True, read_only=True)
|
||||
workscope_name = serializers.StringRelatedField(source='workscope', read_only=True)
|
||||
role_name = serializers.StringRelatedField(source='role', read_only=True)
|
||||
|
||||
class Meta:
|
||||
model = Consumer
|
||||
|
|
|
@ -116,8 +116,8 @@ class ConsumerViewSet(ModelViewSet):
|
|||
ordering_fields = ('id','company','create_time', 'username', 'workscope')
|
||||
ordering = ['-create_time']
|
||||
filter_backends = [DjangoFilterBackend, SearchFilter, OrderingFilter]
|
||||
filterset_fields = ('company',)
|
||||
search_fields = ('name','username','company__name')
|
||||
filterset_fields = ['company','role']
|
||||
search_fields = ['name','username','company__name']
|
||||
|
||||
def get_queryset(self):
|
||||
queryset = self.queryset
|
||||
|
@ -216,6 +216,7 @@ class ConsumerViewSet(ModelViewSet):
|
|||
"""
|
||||
导入用户
|
||||
"""
|
||||
role1 = ConsumerRole.objects.get(name='付费学员')
|
||||
xlsxpath = request.data['path']
|
||||
fullpath = settings.BASE_DIR + xlsxpath
|
||||
wb = load_workbook(fullpath)
|
||||
|
@ -263,7 +264,7 @@ class ConsumerViewSet(ModelViewSet):
|
|||
PaySubject.objects.get_or_create(subject=workscopeobj.subject, consumer = obj)
|
||||
except:
|
||||
return Response({"error":"工作类别不存在!"})
|
||||
obj.role = ConsumerRole.objects.get(name='付费学员')
|
||||
obj.role = role1
|
||||
obj.save()
|
||||
m = m + 1
|
||||
return Response(status=status.HTTP_200_OK)
|
||||
|
@ -288,6 +289,20 @@ class ConsumerViewSet(ModelViewSet):
|
|||
return Response(status=status.HTTP_200_OK)
|
||||
else:
|
||||
return Response({"error":"不支持解绑!"})
|
||||
|
||||
@action(methods=['get'], detail=False,
|
||||
url_path='correctrole', url_name='correct_role', perms_map=[{'*':'correct_role'}])
|
||||
def correctrole(self, request):
|
||||
role1 = ConsumerRole.objects.get(name='付费学员')
|
||||
role2 = ConsumerRole.objects.get(name='注册用户')
|
||||
for i in Consumer.objects.all():
|
||||
if i.workscope and i.username:
|
||||
i.role = role1
|
||||
elif i.username and i.openid:
|
||||
i.role = role2
|
||||
i.save()
|
||||
print(i.id)
|
||||
return Response(status=status.HTTP_200_OK)
|
||||
|
||||
class ConsumerMPLoginView(APIView):
|
||||
"""
|
||||
|
@ -340,7 +355,8 @@ class ConsumerRegister(APIView):
|
|||
consumer.avatar = avatar
|
||||
consumer.nickname = nickname
|
||||
consumer.is_delete = False
|
||||
consumer.role = ConsumerRole.objects.get(name='注册用户')
|
||||
if consumer.role and consumer.role.name == '游客':
|
||||
consumer.role = ConsumerRole.objects.get(name='注册用户')
|
||||
consumer.save()
|
||||
return Response(status=status.HTTP_200_OK)
|
||||
else:
|
||||
|
@ -350,7 +366,8 @@ class ConsumerRegister(APIView):
|
|||
consumer.avatar = avatar
|
||||
consumer.nickname = nickname
|
||||
consumer.is_delete = False
|
||||
consumer.role = ConsumerRole.objects.get(name='注册用户')
|
||||
if consumer.role and consumer.role.name == '游客':
|
||||
consumer.role = ConsumerRole.objects.get(name='注册用户')
|
||||
consumer.save()
|
||||
return Response(status=status.HTTP_200_OK)
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue