This commit is contained in:
shilixia 2021-06-25 10:36:18 +08:00
commit dbf7c793c2
24 changed files with 439 additions and 245 deletions

View File

@ -104,3 +104,10 @@ export function confirmTaskdept(id) {
method: 'put' method: 'put'
}) })
} }
export function deleteTaskdept(id) {
return request({
url: `/supervision/taskdept/${id}/`,
method: 'delete'
})
}

View File

@ -27,16 +27,19 @@
<template slot-scope="scope">{{ scope.row.type_ }}</template> <template slot-scope="scope">{{ scope.row.type_ }}</template>
</el-table-column> </el-table-column>
<el-table-column label="排序号">
<template slot-scope="scope">{{ scope.row.sortnum }}</template>
</el-table-column>
<el-table-column align="center" label="是否可主动报送"> <el-table-column align="center" label="是否可主动报送">
<template slot-scope="scope"> <template slot-scope="scope">
<el-tag type="success" v-if="scope.row.can_doself"></el-tag> <el-tag type="success" v-if="scope.row.can_doself"></el-tag>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="模板">
<template slot-scope="scope" v-if="scope.row.template">
<el-link :href="scope.row.template" type="primary">下载</el-link>
</template>
</el-table-column>
<el-table-column label="排序号">
<template slot-scope="scope">{{ scope.row.sortnum }}</template>
</el-table-column>
<el-table-column <el-table-column
align="center" align="center"
label="操作" label="操作"

View File

@ -141,6 +141,15 @@
@click="handleConfirmDept(scope)" @click="handleConfirmDept(scope)"
>确认</el-link >确认</el-link
> >
<el-link
v-if="
checkPermission(['task_update'])
"
type="danger"
size="small"
@click="handleDeleteDept(scope)"
>删除</el-link
>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -328,7 +337,7 @@
} }
</style> </style>
<script> <script>
import { gettask, inittask, gettaskdeptall, starttask, appendtask, confirmTaskdept } from "@/api/task"; import { gettask, inittask, gettaskdeptall, starttask, appendtask, confirmTaskdept, deleteTaskdept } from "@/api/task";
import { getRecordList, updateRecords } from "@/api/record"; import { getRecordList, updateRecords } from "@/api/record";
import Pagination from "@/components/Pagination"; import Pagination from "@/components/Pagination";
import taskinit from "@/views/supervision/taskinit"; import taskinit from "@/views/supervision/taskinit";
@ -467,6 +476,11 @@ export default {
this.gettaskdeptall() this.gettaskdeptall()
}) })
}, },
handleDeleteDept(scope){
deleteTaskdept(scope.row.id).then(res=>{
this.gettaskdeptall()
})
},
handleUp2(){ handleUp2(){
if (this.selectRecords.length) { if (this.selectRecords.length) {
this.$prompt('请输入备注内容', '提示').then(({ value }) => { this.$prompt('请输入备注内容', '提示').then(({ value }) => {

View File

@ -22,7 +22,9 @@
uni.login({ uni.login({
provider: 'weixin', provider: 'weixin',
success: (loginRes) => { success: (loginRes) => {
this.$u.api.wxmplogin({code:loginRes.code}).then(res=>{ this.$u.api.wxmplogin({
code: loginRes.code
}).then(res => {
this.$u.vuex('vuex_token', res.data.access) this.$u.vuex('vuex_token', res.data.access)
this.$u.api.getUserInfo().then(res => { this.$u.api.getUserInfo().then(res => {
uni.hideLoading() uni.hideLoading()
@ -34,16 +36,20 @@
url: "/pages/home/home" url: "/pages/home/home"
}) })
this.$u.vuex('vuex_user', res.data) this.$u.vuex('vuex_user', res.data)
// 修改资源请求地址
this.$u.vuex('vuex_user.avatar', this.vuex_user.avatar +
'?token=' + this.vuex_token)
}) })
}).catch(e => { }).catch(e => {
uni.hideLoading() uni.hideLoading()
uni.showToast({ // uni.showToast({
title:"暂未绑定微信!", // title: "暂未绑定微信!",
icon:"none" // icon: "none"
}) // })
uni.reLaunch({ uni.reLaunch({
url: '/pages/login/login' url: '/pages/login/login'
})}) })
})
} }
}); });

View File

@ -23,6 +23,8 @@ const install = (Vue, vm) => {
let bindmp = (params = {}) => vm.$u.post('/system/user/bindwxmp/', params); //微信绑定 let bindmp = (params = {}) => vm.$u.post('/system/user/bindwxmp/', params); //微信绑定
let unbindmp = (params = {}) => vm.$u.post('/system/user/unbindwxmp/', params); //微信绑定
let getMyInspectTaskList = (params = {}) => vm.$u.get('/quality/subinspecttask/self/', params); let getMyInspectTaskList = (params = {}) => vm.$u.get('/quality/subinspecttask/self/', params);
let getSubinspectTask = (id, params)=> vm.$u.get(`/quality/subinspecttask/${id}/`, params); let getSubinspectTask = (id, params)=> vm.$u.get(`/quality/subinspecttask/${id}/`, params);
@ -49,6 +51,7 @@ const install = (Vue, vm) => {
login, login,
wxmplogin, wxmplogin,
bindmp, bindmp,
unbindmp,
getMyInspectTaskList, getMyInspectTaskList,
getSubinspectTask, getSubinspectTask,
getSubtaskDepts, getSubtaskDepts,

View File

@ -45,22 +45,20 @@ const install = (Vue, vm) => {
return res; return res;
} }
else if(res.code === 401){ else if(res.code === 401){
vm.$u.toast('验证失败,请重新登录'); uni.showToast({
title: "验证失败,请重新登录!",
icon: "none"
})
uni.reLaunch({ uni.reLaunch({
url:'/pages/login/login' url:'/pages/login/login'
}) })
return false; return false;
} }
else{ else{
if(typeof(res.msg)=='string'){ uni.showToast({
vm.$u.toast(res.msg) title: res.msg,
}else{ icon: "none"
let msg = JSON.stringify(res.msg) })
vm.$u.toast(res.msg)
}
return false; return false;
} }
} }

View File

@ -77,10 +77,11 @@
for (var i = 0; i < res.data.imgs_.length; i++) { for (var i = 0; i < res.data.imgs_.length; i++) {
fileList.push({ fileList.push({
id: res.data.imgs_[i].id, id: res.data.imgs_[i].id,
url: res.data.imgs_[i].file url: res.data.imgs_[i].file + '?token='+ this.vuex_token
}) })
} }
this.fileList = fileList this.fileList = fileList
console.log(this.fileList)
}) })
}, },
submit() { submit() {

View File

@ -24,7 +24,9 @@
</view> </view>
<u-verification-code seconds="30" ref="uCode" @change="codeChange"></u-verification-code> <u-verification-code seconds="30" ref="uCode" @change="codeChange"></u-verification-code>
<view style="text-align: center;"> <view style="text-align: center;">
<view class="icon"><u-icon size="70" name="weixin-fill" color="rgb(83,194,64)" @click="mpLogin"></u-icon></view> <view class="icon">
<u-icon size="70" name="weixin-fill" color="rgb(83,194,64)" @click="mpLogin"></u-icon>
</view>
微信登录 微信登录
</view> </view>
<!-- <view class="buttom"> <!-- <view class="buttom">
@ -53,8 +55,7 @@ export default {
}, },
codeTips: "获取验证码", codeTips: "获取验证码",
rules: { rules: {
mail:[ mail: [{
{
required: true, required: true,
message: '请输入邮箱号', message: '请输入邮箱号',
trigger: ['change', 'blur'], trigger: ['change', 'blur'],
@ -76,13 +77,11 @@ export default {
// trigger: ['change','blur'], // trigger: ['change','blur'],
// } // }
], ],
msg:[ msg: [{
{
required: true, required: true,
message: '请输入验证码', message: '请输入验证码',
trigger: ['change', 'blur'], trigger: ['change', 'blur'],
}, }, ]
]
}, },
errorType: ['message'], errorType: ['message'],
} }
@ -111,18 +110,22 @@ export default {
submit() { submit() {
this.$refs.uForm.validate(valid => { this.$refs.uForm.validate(valid => {
if (valid) { if (valid) {
uni.showLoading({ uni.showLoading({})
})
this.$u.api.codeLogin(this.loginForm).then(res => { this.$u.api.codeLogin(this.loginForm).then(res => {
this.$u.vuex('vuex_token', res.data.access) this.$u.vuex('vuex_token', res.data.access)
this.$u.api.getUserInfo().then(res => { this.$u.api.getUserInfo().then(res => {
this.$u.vuex('vuex_user', res.data) this.$u.vuex('vuex_user', res.data)
// 修改资源请求地址
this.$u.vuex('vuex_user.avatar', this.vuex_user.avatar +
'?token=' + this.vuex_token)
uni.hideLoading() uni.hideLoading()
}) })
uni.reLaunch({ uni.reLaunch({
url: '/pages/home/home' url: '/pages/home/home'
}) })
}).catch(e=>{uni.hideLoading()}) }).catch(e => {
uni.hideLoading()
})
} }
}); });
}, },
@ -157,7 +160,9 @@ export default {
uni.login({ uni.login({
provider: 'weixin', provider: 'weixin',
success: (loginRes) => { success: (loginRes) => {
this.$u.api.wxmplogin({code:loginRes.code}).then(res=>{ this.$u.api.wxmplogin({
code: loginRes.code
}).then(res => {
this.$u.vuex('vuex_token', res.data.access) this.$u.vuex('vuex_token', res.data.access)
this.$u.api.getUserInfo().then(res => { this.$u.api.getUserInfo().then(res => {
uni.hideLoading() uni.hideLoading()
@ -169,6 +174,9 @@ export default {
url: "/pages/home/home" url: "/pages/home/home"
}) })
this.$u.vuex('vuex_user', res.data) this.$u.vuex('vuex_user', res.data)
// 修改资源请求地址
this.$u.vuex('vuex_user.avatar', this.vuex_user.avatar +
'?token=' + this.vuex_token)
}) })
}).catch(e => { }).catch(e => {
uni.hideLoading() uni.hideLoading()
@ -176,9 +184,7 @@ export default {
title: "暂未绑定微信!", title: "暂未绑定微信!",
icon: "none" icon: "none"
}) })
uni.reLaunch({ })
url:'/pages/login/login'
})})
} }
}); });
} }
@ -189,6 +195,7 @@ export default {
<style lang="scss" scoped> <style lang="scss" scoped>
.wrap { .wrap {
font-size: 28rpx; font-size: 28rpx;
.content { .content {
width: 90%; width: 90%;
margin: 40rpx auto 0; margin: 40rpx auto 0;
@ -199,16 +206,19 @@ export default {
font-weight: 500; font-weight: 500;
margin-bottom: 100rpx; margin-bottom: 100rpx;
} }
input { input {
text-align: left; text-align: left;
margin-bottom: 10rpx; margin-bottom: 10rpx;
padding-bottom: 6rpx; padding-bottom: 6rpx;
} }
.tips { .tips {
color: $u-type-info; color: $u-type-info;
margin-bottom: 60rpx; margin-bottom: 60rpx;
margin-top: 8rpx; margin-top: 8rpx;
} }
.getCaptcha { .getCaptcha {
background-color: rgb(253, 243, 208); background-color: rgb(253, 243, 208);
color: $u-tips-color; color: $u-tips-color;
@ -221,6 +231,7 @@ export default {
border: none; border: none;
} }
} }
.alternative { .alternative {
color: $u-tips-color; color: $u-tips-color;
display: flex; display: flex;
@ -228,6 +239,7 @@ export default {
margin-top: 30rpx; margin-top: 30rpx;
} }
} }
.buttom { .buttom {
.loginType { .loginType {
display: flex; display: flex;

View File

@ -81,6 +81,10 @@ export default {
this.$u.vuex('vuex_token', res.data.access) this.$u.vuex('vuex_token', res.data.access)
this.$u.api.getUserInfo().then(res=>{ this.$u.api.getUserInfo().then(res=>{
this.$u.vuex('vuex_user', res.data) this.$u.vuex('vuex_user', res.data)
// 修改资源请求地址
this.$u.vuex('vuex_user.avatar', this.vuex_user.avatar +
'?token=' + this.vuex_token)
console.log(this.vuex_user)
}) })
uni.reLaunch({ uni.reLaunch({
url:'/pages/home/home' url:'/pages/home/home'

View File

@ -61,10 +61,14 @@
}, },
methods: { methods: {
Logout(){ Logout(){
this.$u.api.unbindmp().then(res=>{
this.$u.vuex('vuex_token', '') this.$u.vuex('vuex_token', '')
uni.redirectTo({ uni.redirectTo({
url: '/pages/login/login' url: '/pages/login/login'
}); });
}
)
}, },
bindMP(){ bindMP(){
uni.login({ uni.login({

View File

@ -354,3 +354,12 @@ class TaskDeptViewSet(ModelViewSet):
obj.save() obj.save()
return Response(status=status.HTTP_200_OK) return Response(status=status.HTTP_200_OK)
return Response('报送未完成', status=status.HTTP_400_BAD_REQUEST) return Response('报送未完成', status=status.HTTP_400_BAD_REQUEST)
def destroy(self, request, *args, **kwargs):
"""
删除
"""
obj = self.get_object()
Record.objects.filter(task=obj.task, belong_dept=obj.dept).delete() # 删除相应上报记录
obj.delete()
return Response()

View File

@ -352,6 +352,13 @@ class UserViewSet(PageOrNot, ModelViewSet):
UserThird.objects.get_or_create(openid=openid, type='wx_mp', user=request.user, defaults={'openid':openid, 'user':request.user, 'type':'wx_mp'}) UserThird.objects.get_or_create(openid=openid, type='wx_mp', user=request.user, defaults={'openid':openid, 'user':request.user, 'type':'wx_mp'})
return Response({'wxmp_openid':openid},status=status.HTTP_200_OK) return Response({'wxmp_openid':openid},status=status.HTTP_200_OK)
@action(methods=['post'], detail=False, permission_classes=[IsAuthenticated])
def unbindwxmp(self, request, pk=None):
"""
解除微信绑定
"""
UserThird.objects.filter(user=request.user, type='wx_mp').delete()
return Response()
class WXMPlogin(APIView): class WXMPlogin(APIView):
authentication_classes=[] authentication_classes=[]

View File

3
server/apps/vod/admin.py Normal file
View File

@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

5
server/apps/vod/apps.py Normal file
View File

@ -0,0 +1,5 @@
from django.apps import AppConfig
class VodConfig(AppConfig):
name = 'vod'

View File

24
server/apps/vod/models.py Normal file
View File

@ -0,0 +1,24 @@
from django.db import models
from utils.model import BaseModel
from apps.system.models import User, CommonAModel
# Create your models here.
class Video(CommonAModel):
pass
class WatchRecord(BaseModel):
# 观看记录
user = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name='观看人')
num = models.IntegerField(verbose_name='观看次数', default=0)
total = models.IntegerField(verbose_name='观看总时长', default=0)
current = models.IntegerField(verbose_name='当前观看进度', default=0)
vod_id = models.CharField(verbose_name='视频id', max_length=100)
vod_title = models.CharField(verbose_name='视频标题', max_length=100)
vod_cover = models.CharField(verbose_name='视频封面地址', max_length=200)
class Meta:
verbose_name = '点播观看记录'
verbose_name_plural = verbose_name

3
server/apps/vod/tests.py Normal file
View File

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

9
server/apps/vod/urls.py Normal file
View File

@ -0,0 +1,9 @@
from django.urls import path, include
from .views import ClassView, VideoView
from rest_framework import routers
urlpatterns = [
path('class/', ClassView.as_view()),
path('video/', VideoView.as_view())
]

32
server/apps/vod/views.py Normal file
View File

@ -0,0 +1,32 @@
from django.shortcuts import render
from .vodclient import getAllClass, searchMedia
from rest_framework.views import APIView
from rest_framework.response import Response
from rest_framework.viewsets import ModelViewSet
# Create your views here.
class ClassView(APIView):
perms_map={'get':'*'}
def get(self, request, format=None):
"""
查询分类
"""
return getAllClass()
class VideoView(APIView):
perms_map={'get':'video_view'}
def get(self, request, format=None):
"""
查询视频
"""
params={'Filters':['basicInfo', 'metaData']}
params['Offset'] = request.query_params.get('Offset', 0)
params['Limit'] = request.query_params.get('Limit', 20)
params['Names'] = request.query_params.getlist('name') if request.query_params.get('name') else []
params['ClassIds']= request.query_params.getlist('classid') if request.query_params.get('classid') else []
return searchMedia(params)
class RecordViewSet(ModelViewSet):
pass

View File

@ -0,0 +1,48 @@
import json
from tencentcloud.common import credential
from tencentcloud.common.profile.client_profile import ClientProfile
from tencentcloud.common.profile.http_profile import HttpProfile
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.vod.v20180717 import vod_client, models
from rest_framework.response import Response
from rest_framework.status import HTTP_400_BAD_REQUEST
SecretId = 'AKIDhDTaV9WeXAXcQxEH4buwg9LGvJQHr9Au'
SecretKey = 'VjfKjrhGYrte8MIxMUMxHL9h39zYqrc6'
# 初始化点播client
def initClient():
cred = credential.Credential(SecretId, SecretKey)
httpProfile = HttpProfile()
httpProfile.endpoint = "vod.tencentcloudapi.com"
clientProfile = ClientProfile()
clientProfile.httpProfile = httpProfile
client = vod_client.VodClient(cred, "", clientProfile)
return client
def doResponse(res):
# 处理返回结果
# 转变为常用返回Response
if hasattr(res, 'Error'):
return Response(res._serialize(allow_none=True), status=HTTP_400_BAD_REQUEST)
return Response(res._serialize(allow_none=True))
def getAllClass(params={}):
# 获取所有分类
try:
client = initClient()
req = models.DescribeAllClassRequest()
req.from_json_string(json.dumps(params))
resp = client.DescribeAllClass(req)
return doResponse(resp)
except TencentCloudSDKException as err:
print(err)
def searchMedia(params={}):
try:
client = initClient()
req = models.SearchMediaRequest()
req.from_json_string(json.dumps(params))
resp = client.SearchMedia(req)
return doResponse(resp)
except TencentCloudSDKException as err:
print(err)

View File

@ -45,7 +45,8 @@ INSTALLED_APPS = [
'apps.crm', 'apps.crm',
'apps.ability', 'apps.ability',
'apps.supervision', 'apps.supervision',
'apps.quality' 'apps.quality',
'apps.vod'
] ]
MIDDLEWARE = [ MIDDLEWARE = [

View File

@ -5,7 +5,7 @@ DATABASES = {
'ENGINE': 'django.db.backends.postgresql', 'ENGINE': 'django.db.backends.postgresql',
'NAME': 'cma', 'NAME': 'cma',
'USER': 'postgres', 'USER': 'postgres',
'PASSWORD': 'postgres', 'PASSWORD': 'zctest1234',
'HOST': '47.95.0.242', 'HOST': '47.95.0.242',
'PORT': '5432', 'PORT': '5432',
} }

View File

@ -47,6 +47,7 @@ urlpatterns = [
path('api/ability/', include('apps.ability.urls')), path('api/ability/', include('apps.ability.urls')),
path('api/supervision/', include('apps.supervision.urls')), path('api/supervision/', include('apps.supervision.urls')),
path('api/quality/', include('apps.quality.urls')), path('api/quality/', include('apps.quality.urls')),
path('api/vod/', include('apps.vod.urls')),
path('api/docs/', include_docs_urls(title="接口文档",authentication_classes=[], permission_classes=[])), path('api/docs/', include_docs_urls(title="接口文档",authentication_classes=[], permission_classes=[])),
path('api/', include(router.urls)), path('api/', include(router.urls)),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)