role导入

This commit is contained in:
caoqianming 2020-07-23 22:23:18 +08:00
parent 99bf3e5b4b
commit 323c4189e9
5 changed files with 16 additions and 5 deletions

View File

@ -24,7 +24,7 @@ App({
// var currentPage = pages[pages.length - 1] //获取当前页面的对象 // var currentPage = pages[pages.length - 1] //获取当前页面的对象
// currentPage.showExp() // currentPage.showExp()
if(res.data.userinfo.username == null){ if(res.data.userinfo.role_name == '游客'){
//匿名用户 //匿名用户
wx.reLaunch({ wx.reLaunch({
url: '/pages/login/login', url: '/pages/login/login',
@ -57,9 +57,9 @@ App({
globalData: { globalData: {
userInfo: {}, userInfo: {},
userinfo: {}, // 服务器传回的消费者信息 userinfo: {}, // 服务器传回的消费者信息
//host: 'https://apitest.ahctc.cn', host: 'https://apitest.ahctc.cn',
mediahost: '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', //mediahost: 'http://127.0.0.1:8000',
token : '', token : '',
} }

View File

@ -73,7 +73,7 @@ Page({
}, },
register: function() { register: function() {
var that = this var that = this
if (!that.data.userinfo.username){ if (that.data.userinfo.role_name=='游客'){
wx.reLaunch({ wx.reLaunch({
url: '/pages/login/login', url: '/pages/login/login',
}) })

View File

@ -23,7 +23,8 @@
"disablePlugins": [], "disablePlugins": [],
"outputPath": "" "outputPath": ""
}, },
"useCompilerModule": true, "useIsolateContext": true,
"useCompilerModule": false,
"userConfirmedUseCompilerModuleSwitch": false "userConfirmedUseCompilerModuleSwitch": false
}, },
"compileType": "miniprogram", "compileType": "miniprogram",

View File

@ -230,6 +230,8 @@ class ConsumerViewSet(ModelViewSet):
return Response({"error":"单位列错误!"}) return Response({"error":"单位列错误!"})
if sheet['d2'].value != '工作类别': if sheet['d2'].value != '工作类别':
return Response({"error":"工作类别列错误!"}) return Response({"error":"工作类别列错误!"})
if sheet['e2'].value != '角色':
return Response({"error":"角色列错误!"})
companydict = {} companydict = {}
companys = Company.objects.filter(is_delete=0) companys = Company.objects.filter(is_delete=0)
for i in companys: for i in companys:
@ -247,6 +249,7 @@ class ConsumerViewSet(ModelViewSet):
companyname = companyname.replace(' ', '') companyname = companyname.replace(' ', '')
companyobj = Company.objects.get_or_create(name=companyname)[0] companyobj = Company.objects.get_or_create(name=companyname)[0]
workscope = sheet['d'+str(m)].value workscope = sheet['d'+str(m)].value
role = sheet['e'+str(m)].value
if Consumer.objects.filter(username = username).exists(): if Consumer.objects.filter(username = username).exists():
obj = Consumer.objects.filter(username = username).first() obj = Consumer.objects.filter(username = username).first()
else: else:
@ -264,6 +267,13 @@ class ConsumerViewSet(ModelViewSet):
except: except:
return Response({"error":"工作类别不存在!"}) return Response({"error":"工作类别不存在!"})
obj.role = role1 obj.role = role1
if role:
role = role.replace(' ', '')
try:
roleobj = ConsumerRole.objects.get(name=role)
obj.role = roleobj
except:
pass
obj.save() obj.save()
m = m + 1 m = m + 1
return Response(status=status.HTTP_200_OK) return Response(status=status.HTTP_200_OK)

Binary file not shown.