supervision 基本完成

This commit is contained in:
caoqianming 2021-03-23 15:05:49 +08:00
parent 66f68e5a34
commit 53ad1ae23f
12 changed files with 312 additions and 153 deletions

View File

@ -56,3 +56,9 @@ export function rejectRecord(id, data) {
data data
}) })
} }
export function deleteRecord(id) {
return request({
url: `/supervision/record/${id}/`,
method: 'delete',
})
}

View File

@ -61,4 +61,11 @@ export function gettaskdepts(id) {
url: `/supervision/task/${id}/depts/`, url: `/supervision/task/${id}/depts/`,
method: 'get' method: 'get'
}) })
}
export function starttask(id) {
return request({
url: `/supervision/task/${id}/start/`,
method: 'put'
})
} }

View File

@ -23,7 +23,7 @@ export default {
}, },
data() { data() {
return { return {
title: '国检集团检验检测能力共享平台', title: '检验检测能力共享和质量管理平台',
// logo: 'https://wpimg.wallstcn.com/69a1c46c-eb1c-4b46-8bd4-e9e686ef5251.png' // logo: 'https://wpimg.wallstcn.com/69a1c46c-eb1c-4b46-8bd4-e9e686ef5251.png'
logo:'http://testsearch.ctc.ac.cn:8000/media/default/avatar.png' logo:'http://testsearch.ctc.ac.cn:8000/media/default/avatar.png'
} }

View File

@ -64,7 +64,13 @@ div:focus {
.app-container { .app-container {
padding: 6px; padding: 6px;
} }
body .el-table th.gutter{
display: table-cell!important;
}
body .el-table colgroup.gutter{
display: table-cell!important;
}
.el-table--medium td,   .el-table--medium th { .el-table--medium td,   .el-table--medium th {
padding: 2px 0; padding: 2px 0;
} }

View File

@ -1,17 +1,10 @@
<template> <template>
<div class="login"> <div class="login">
<div class="login-form">
<img class="logo" src="../../assets/logo.png" />
<div class="login-form"> <h3 class="title">检验检测能力共享和质量管理平台</h3>
<el-tabs v-model="activeName" :stretch="true">
<img class="logo" src="../../assets/logo.png">
<h3 class="title">检验检测能力共享和质量管理平台</h3>
<el-tabs v-model="activeName" :stretch="true" >
<el-tab-pane label="验证码登录" name="msg"> <el-tab-pane label="验证码登录" name="msg">
<el-form <el-form
ref="loginForm2" ref="loginForm2"
@ -20,7 +13,6 @@
auto-complete="on" auto-complete="on"
label-position="left" label-position="left"
> >
<el-form-item prop="mail"> <el-form-item prop="mail">
<el-input <el-input
ref="mail" ref="mail"
@ -30,11 +22,15 @@
type="text" type="text"
tabindex="1" tabindex="1"
auto-complete="on" auto-complete="on"
> <svg-icon slot="prefix" icon-class="email" class="el-input__icon input-icon" /></el-input> >
<svg-icon
slot="prefix"
icon-class="email"
class="el-input__icon input-icon"
/></el-input>
</el-form-item> </el-form-item>
<el-form-item prop="msg"> <el-form-item prop="msg">
<el-input <el-input
ref="msg" ref="msg"
v-model="loginForm2.msg" v-model="loginForm2.msg"
@ -44,24 +40,26 @@
tabindex="2" tabindex="2"
auto-complete="on" auto-complete="on"
@keyup.enter.native="handleLogin" @keyup.enter.native="handleLogin"
> <svg-icon slot="prefix" icon-class="message" class="el-input__icon input-icon" /></el-input> >
<span class="show-pwd" @click="sendMsg" style="color:black"> <svg-icon
slot="prefix"
<template>{{buttonmsg}}</template> icon-class="message"
class="el-input__icon input-icon"
/></el-input>
<span class="show-pwd" @click="sendMsg" style="color: black">
<template>{{ buttonmsg }}</template>
<!-- <svg-icon :icon-class="passwordType === 'password' ? 'eye' : 'eye-open'" /> --> <!-- <svg-icon :icon-class="passwordType === 'password' ? 'eye' : 'eye-open'" /> -->
</span> </span>
</el-form-item> </el-form-item>
<el-button <el-button
:loading="loading2" :loading="loading2"
type="primary" type="primary"
style="width:100%;margin-bottom:30px;" style="width: 100%; margin-bottom: 30px"
@click.native.prevent="handleLogin2" @click.native.prevent="handleLogin2"
>验证登录</el-button> >验证登录</el-button
>
</el-form> </el-form>
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="密码登录" name="pwd"> <el-tab-pane label="密码登录" name="pwd">
<el-form <el-form
@ -72,7 +70,6 @@
label-position="left" label-position="left"
> >
<el-form-item prop="username"> <el-form-item prop="username">
<el-input <el-input
ref="username" ref="username"
v-model="loginForm.username" v-model="loginForm.username"
@ -81,11 +78,14 @@
type="text" type="text"
tabindex="1" tabindex="1"
auto-complete="on" auto-complete="on"
><svg-icon slot="prefix" icon-class="user" class="el-input__icon input-icon" /></el-input> ><svg-icon
slot="prefix"
icon-class="user"
class="el-input__icon input-icon"
/></el-input>
</el-form-item> </el-form-item>
<el-form-item prop="password"> <el-form-item prop="password">
<el-input <el-input
:key="passwordType" :key="passwordType"
ref="password" ref="password"
@ -96,17 +96,24 @@
tabindex="2" tabindex="2"
auto-complete="on" auto-complete="on"
@keyup.enter.native="handleLogin" @keyup.enter.native="handleLogin"
><svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon" /></el-input> ><svg-icon
slot="prefix"
icon-class="password"
class="el-input__icon input-icon"
/></el-input>
<span class="show-pwd" @click="showPwd"> <span class="show-pwd" @click="showPwd">
<svg-icon :icon-class="passwordType === 'password' ? 'eye' : 'eye-open'" /> <svg-icon
:icon-class="passwordType === 'password' ? 'eye' : 'eye-open'"
/>
</span> </span>
</el-form-item> </el-form-item>
<el-button <el-button
:loading="loading" :loading="loading"
type="primary" type="primary"
style="width:100%;margin-bottom:30px;" style="width: 100%; margin-bottom: 30px"
@click.native.prevent="handleLogin" @click.native.prevent="handleLogin"
>登录</el-button> >登录</el-button
>
</el-form> </el-form>
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
@ -116,8 +123,8 @@
<script> <script>
// import { validUsername } from '@/utils/validate' // import { validUsername } from '@/utils/validate'
import { sendMsg } from '@/api/msg' import { sendMsg } from "@/api/msg";
import { login2 } from "@/api/user" import { login2 } from "@/api/user";
export default { export default {
name: "Login", name: "Login",
data() { data() {
@ -136,10 +143,10 @@ export default {
} }
}; };
return { return {
timer:null, timer: null,
disabled:false, disabled: false,
buttonmsg:'发送验证码', buttonmsg: "发送验证码",
count:60, count: 60,
activeName: "msg", activeName: "msg",
loginForm: { loginForm: {
username: "", username: "",
@ -170,14 +177,14 @@ export default {
}, },
], ],
}, },
loading2:false, loading2: false,
loading: false, loading: false,
passwordType: "password", passwordType: "password",
redirect: undefined, redirect: undefined,
}; };
}, },
created() { created() {
this.getUP() this.getUP();
}, },
watch: { watch: {
$route: { $route: {
@ -198,40 +205,41 @@ export default {
this.$refs.password.focus(); this.$refs.password.focus();
}); });
}, },
sendMsg(){ sendMsg() {
if(this.loginForm2.mail.length&&this.buttonmsg=='发送验证码'){ if (this.loginForm2.mail.length && this.buttonmsg == "发送验证码") {
this.getTimer() this.getTimer();
sendMsg({'mail':this.loginForm2.mail}).then(res=>{ sendMsg({ mail: this.loginForm2.mail })
this.$message.success('验证码已发送至该邮箱,请注意查收') .then((res) => {
this.$message.success("验证码已发送至该邮箱,请注意查收");
}).catch(e=>{ })
this.disabled = false; .catch((e) => {
clearInterval(this.timer); this.disabled = false;
this.timer = null; clearInterval(this.timer);
this.buttonmsg = '发送验证码' this.timer = null;
}) this.buttonmsg = "发送验证码";
}else{ });
this.$message.warning('请输入邮箱号') } else {
this.$message.warning("请输入邮箱号");
} }
}, },
getTimer(){ getTimer() {
const TIME_COUNT = 60; const TIME_COUNT = 60;
if (!this.timer) { if (!this.timer) {
this.count = TIME_COUNT; this.count = TIME_COUNT;
this.disabled = true; this.disabled = true;
this.timer = setInterval(() => { this.timer = setInterval(() => {
if (this.count > 0 && this.count <= TIME_COUNT) { if (this.count > 0 && this.count <= TIME_COUNT) {
this.count--; this.count--;
this.buttonmsg = this.count + '' this.buttonmsg = this.count + "";
} else { } else {
this.disabled = false; this.disabled = false;
clearInterval(this.timer); clearInterval(this.timer);
this.timer = null; this.timer = null;
this.buttonmsg = '发送验证码' this.buttonmsg = "发送验证码";
} }
}, 1000) }, 1000);
} }
}, },
handleLogin() { handleLogin() {
this.$refs.loginForm.validate((valid) => { this.$refs.loginForm.validate((valid) => {
if (valid) { if (valid) {
@ -253,7 +261,7 @@ export default {
} }
}); });
}, },
handleLogin2() { handleLogin2() {
this.$refs.loginForm2.validate((valid) => { this.$refs.loginForm2.validate((valid) => {
if (valid) { if (valid) {
this.loading2 = true; this.loading2 = true;
@ -274,11 +282,11 @@ export default {
}); });
}, },
//读取cookie //读取cookie
getUP() { getUP() {
this.loginForm2.mail = localStorage.getItem("rem_mail") this.loginForm2.mail = localStorage.getItem("rem_mail");
this.loginForm.username = localStorage.getItem("rem_username"); this.loginForm.username = localStorage.getItem("rem_username");
this.loginForm.password = localStorage.getItem("rem_password"); this.loginForm.password = localStorage.getItem("rem_password");
}, },
}, },
}; };
</script> </script>
@ -297,9 +305,9 @@ export default {
text-align: center; text-align: center;
color: #0174d7; color: #0174d7;
} }
.logo{ .logo {
width:350px; width: 350px;
height:93px; height: 93px;
} }
.login-form { .login-form {
@ -318,13 +326,12 @@ export default {
width: 14px; width: 14px;
margin-left: 2px; margin-left: 2px;
} }
} }
.show-pwd { .show-pwd {
height: 39px; height: 39px;
margin-right: 2px; margin-right: 2px;
} }
.login-tip { .login-tip {
font-size: 13px; font-size: 13px;
text-align: center; text-align: center;
@ -340,13 +347,13 @@ export default {
} }
} }
.show-pwd { .show-pwd {
position: absolute; position: absolute;
right: 10px; right: 10px;
top: 7px; top: 7px;
font-size: 16px; font-size: 16px;
cursor: pointer; cursor: pointer;
user-select: none; user-select: none;
} }
.login-code-img { .login-code-img {
height: 38px; height: 38px;
} }

View File

@ -125,21 +125,18 @@
</el-tag> </el-tag>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="材料名称"> <el-table-column label="任务截止时间">
<template slot-scope="scope">{{ scope.row.content_.name }}</template>
</el-table-column>
<el-table-column label="上报时间">
<template slot-scope="scope">{{ scope.row.up_date }}</template>
</el-table-column>
<el-table-column label="上报人">
<template slot-scope="scope" v-if="scope.row.up_user">{{
scope.row.up_user_.name
}}</template>
</el-table-column>
<el-table-column label="截止时间">
<template slot-scope="scope">{{ scope.row.end_date }}</template> <template slot-scope="scope">{{ scope.row.end_date }}</template>
</el-table-column> </el-table-column>
<el-table-column label="材料名称">
<template slot-scope="scope">{{ scope.row.content_.name }}</template>
</el-table-column>
<el-table-column label="上报情况">
<template slot-scope="scope" v-if="scope.row.up_user_"
>{{ scope.row.up_user_.name }}/{{ scope.row.up_date }}</template
>
</el-table-column>
<el-table-column label="上报备注"> <el-table-column label="上报备注">
<template slot-scope="scope">{{ scope.row.note }}</template> <template slot-scope="scope">{{ scope.row.note }}</template>
</el-table-column> </el-table-column>
@ -157,7 +154,7 @@
<el-tag type="danger" v-if="scope.row.state == '待上报'">{{ <el-tag type="danger" v-if="scope.row.state == '待上报'">{{
scope.row.state scope.row.state
}}</el-tag> }}</el-tag>
<el-tag type="warning" v-else-if="scope.row.state == '待整改'">{{ <el-tag type="warning" v-else-if="scope.row.state == '待整改' || scope.row.state == '待发布'">{{
scope.row.state scope.row.state
}}</el-tag> }}</el-tag>
<el-tag type="success" v-else-if="scope.row.state == '已确认'">{{ <el-tag type="success" v-else-if="scope.row.state == '已确认'">{{
@ -191,17 +188,17 @@
fixed="right" fixed="right"
> >
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-link
v-if=" v-if="
scope.row.state == '待上报' && (scope.row.state == '待上报'||scope.row.state=='待发布' )&&
checkPermission(['record_update']) checkPermission(['record_update'])
" "
type="primary" type="warning"
size="small" size="small"
@click="handleRecord({ action: 'update', record: scope.row })" @click="handleRecord({ action: 'update', record: scope.row })"
>编辑</el-button >编辑</el-link
> >
<el-button <el-link
v-if=" v-if="
(scope.row.state == '待上报' || scope.row.state == '待整改') && (scope.row.state == '待上报' || scope.row.state == '待整改') &&
checkPermission(['record_up']) checkPermission(['record_up'])
@ -209,19 +206,19 @@
type="primary" type="primary"
size="small" size="small"
@click="handleRecord({ action: 'up', record: scope.row })" @click="handleRecord({ action: 'up', record: scope.row })"
>上报</el-button >上报</el-link
> >
<el-button <el-link
v-if=" v-if="
scope.row.state == '已上报' && scope.row.state == '已上报' &&
checkPermission(['record_confirm']) checkPermission(['record_confirm'])
" "
type="primary" type="success"
size="small" size="small"
@click="handleRecord({ action: 'confirm', record: scope.row })" @click="handleRecord({ action: 'confirm', record: scope.row })"
>确认</el-button >确认</el-link
> >
<el-button <el-link
v-if=" v-if="
scope.row.state == '已上报' && scope.row.state == '已上报' &&
checkPermission(['record_reject']) checkPermission(['record_reject'])
@ -229,14 +226,23 @@
type="danger" type="danger"
size="small" size="small"
@click="handleRecord({ action: 'reject', record: scope.row })" @click="handleRecord({ action: 'reject', record: scope.row })"
>驳回</el-button >驳回</el-link
> >
<el-button <el-link
v-if="checkPermission(['record_view'])" v-if="checkPermission(['record_view'])"
size="small" size="small"
@click="handleRecord({ action: 'view', record: scope.row })" @click="handleRecord({ action: 'view', record: scope.row })"
>查看</el-button >查看</el-link
> >
<el-link
v-if="checkPermission(['record_delete'])"
type="danger"
size="small"
@click="
handleRecord({ action: 'delete', record: scope.row })
"
>删除</el-link
>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>

View File

@ -81,11 +81,17 @@
<el-divider></el-divider> <el-divider></el-divider>
<div style="text-align: right"> <div style="text-align: right">
<el-button <el-button
type="primary"
@click="confirm()" @click="confirm()"
type="danger"
v-if="this.data.action == 'reject'" v-if="this.data.action == 'reject'"
>驳回</el-button >驳回</el-button
> >
<el-button
type="danger"
@click="confirm()"
v-else-if="this.data.action == 'delete'"
>删除</el-button
>
<el-button type="primary" @click="confirm()" v-else>确认</el-button> <el-button type="primary" @click="confirm()" v-else>确认</el-button>
</div> </div>
</div> </div>
@ -117,6 +123,7 @@ import {
upRecord, upRecord,
rejectRecord, rejectRecord,
confirmRecord, confirmRecord,
deleteRecord
} from "@/api/record"; } from "@/api/record";
export default { export default {
name: "recorddo", name: "recorddo",
@ -205,7 +212,20 @@ export default {
}); });
} else if (this.data.action == "view") { } else if (this.data.action == "view") {
this.$emit("handleDo"); this.$emit("handleDo");
} else if (this.data.action == "delete") {
this.$confirm("确认删除?", "警告", {
type: "error",
})
.then(async () => {
await deleteRecord(this.record.id);
this.$message.success("成功");
this.$emit("handleDo");
})
.catch((err) => {
console.error(err);
});
} }
}, },
}, },
}; };

View File

@ -46,7 +46,7 @@
</el-table-column> </el-table-column>
<el-table-column label="状态"> <el-table-column label="状态">
<template slot-scope="scope"> <template slot-scope="scope">
<el-tag v-if="scope.row.state=='创建中'" type="warning">{{scope.row.state}}</el-tag> <el-tag v-if="scope.row.state=='创建中'||scope.row.state=='待发布'" type="warning">{{scope.row.state}}</el-tag>
<el-tag v-else-if="scope.row.state=='执行中'" type="primary">{{scope.row.state}}</el-tag> <el-tag v-else-if="scope.row.state=='执行中'" type="primary">{{scope.row.state}}</el-tag>
<el-tag v-else type="success">{{scope.row.state}}</el-tag> <el-tag v-else type="success">{{scope.row.state}}</el-tag>
</template> </template>

View File

@ -66,6 +66,13 @@
size="small" size="small"
>初始化任务</el-button >初始化任务</el-button
> >
<el-button
type="primary"
@click="starttask()"
v-if="task.state == '待发布'"
size="small"
>发布任务</el-button
>
</div> </div>
</div> </div>
</el-card> </el-card>
@ -127,7 +134,7 @@
> >
<el-tag <el-tag
type="warning" type="warning"
v-else-if="scope.row.state == '待整改'" v-else-if="scope.row.state == '待整改' || scope.row.state == '待发布'"
>{{ scope.row.state }}</el-tag >{{ scope.row.state }}</el-tag
> >
<el-tag <el-tag
@ -147,6 +154,9 @@
}}</template }}</template
> >
</el-table-column> </el-table-column>
<el-table-column label="上报备注">
<template slot-scope="scope">{{ scope.row.note }}</template>
</el-table-column>
<el-table-column label="文件"> <el-table-column label="文件">
<template slot-scope="scope" v-if="scope.row.files"> <template slot-scope="scope" v-if="scope.row.files">
<el-link <el-link
@ -177,23 +187,23 @@
<el-table-column <el-table-column
align="center" align="center"
label="操作" label="操作"
width="220px" width="240px"
fixed="right" fixed="right"
> >
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-link
v-if=" v-if="
scope.row.state == '待上报' && (scope.row.state == '待上报'||scope.row.state=='待发布' )&&
checkPermission(['record_update']) checkPermission(['record_update'])
" "
type="primary" type="warning"
size="small" size="small"
@click=" @click="
handleRecord({ action: 'update', record: scope.row }) handleRecord({ action: 'update', record: scope.row })
" "
>编辑</el-button >编辑</el-link
> >
<el-button <el-link
v-if=" v-if="
(scope.row.state == '待上报' || (scope.row.state == '待上报' ||
scope.row.state == '待整改') && scope.row.state == '待整改') &&
@ -204,21 +214,21 @@
@click=" @click="
handleRecord({ action: 'up', record: scope.row }) handleRecord({ action: 'up', record: scope.row })
" "
>上报</el-button >上报</el-link
> >
<el-button <el-link
v-if=" v-if="
scope.row.state == '已上报' && scope.row.state == '已上报' &&
checkPermission(['record_confirm']) checkPermission(['record_confirm'])
" "
type="primary" type="success"
size="small" size="small"
@click=" @click="
handleRecord({ action: 'confirm', record: scope.row }) handleRecord({ action: 'confirm', record: scope.row })
" "
>确认</el-button >确认</el-link
> >
<el-button <el-link
v-if=" v-if="
scope.row.state == '已上报' && scope.row.state == '已上报' &&
checkPermission(['record_reject']) checkPermission(['record_reject'])
@ -228,15 +238,24 @@
@click=" @click="
handleRecord({ action: 'reject', record: scope.row }) handleRecord({ action: 'reject', record: scope.row })
" "
>驳回</el-button >驳回</el-link
> >
<el-button <el-link
v-if="checkPermission(['record_view'])" v-if="checkPermission(['record_view'])"
size="small" size="small"
@click=" @click="
handleRecord({ action: 'view', record: scope.row }) handleRecord({ action: 'view', record: scope.row })
" "
>查看</el-button >查看</el-link
>
<el-link
v-if="checkPermission(['record_delete'])"
type="danger"
size="small"
@click="
handleRecord({ action: 'delete', record: scope.row })
"
>删除</el-link
> >
</template> </template>
</el-table-column> </el-table-column>
@ -297,7 +316,7 @@
> >
<el-tag <el-tag
type="warning" type="warning"
v-else-if="scope.row.state == '待整改'" v-else-if="scope.row.state == '待整改' || scope.row.state == '待发布'"
>{{ scope.row.state }}</el-tag >{{ scope.row.state }}</el-tag
> >
<el-tag <el-tag
@ -315,29 +334,56 @@
>{{ scope.row.up_user_.name }}/{{ scope.row.up_date }}</template >{{ scope.row.up_user_.name }}/{{ scope.row.up_date }}</template
> >
</el-table-column> </el-table-column>
<el-table-column label="上报备注">
<template slot-scope="scope">{{ scope.row.note }}</template>
</el-table-column>
<el-table-column label="文件"> <el-table-column label="文件">
<template slot-scope="scope"> </template> <template slot-scope="scope" v-if="scope.row.files">
<el-link
v-if="scope.row.files.length > 1"
@click="
handleRecord({ action: 'view', record: scope.row })
"
>
<span style="color: red">{{
scope.row.files.length
}}</span>
个文件</el-link
>
<div
v-else
v-for="item in scope.row.files_"
v-bind:key="item.id"
>
<el-link
:href="item.path"
target="_blank"
type="primary"
>{{ item.name }}</el-link
>
</div>
</template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
align="center" align="center"
label="操作" label="操作"
width="220px" width="240px"
fixed="right" fixed="right"
> >
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-link
v-if=" v-if="
scope.row.state == '待上报' && (scope.row.state == '待上报'||scope.row.state=='待发布' )&&
checkPermission(['record_update']) checkPermission(['record_update'])
" "
type="primary" type="warning"
size="small" size="small"
@click=" @click="
handleRecord({ action: 'update', record: scope.row }) handleRecord({ action: 'update', record: scope.row })
" "
>编辑</el-button >编辑</el-link
> >
<el-button <el-link
v-if=" v-if="
(scope.row.state == '待上报' || (scope.row.state == '待上报' ||
scope.row.state == '待整改') && scope.row.state == '待整改') &&
@ -348,21 +394,21 @@
@click=" @click="
handleRecord({ action: 'up', record: scope.row }) handleRecord({ action: 'up', record: scope.row })
" "
>上报</el-button >上报</el-link
> >
<el-button <el-link
v-if=" v-if="
scope.row.state == '已上报' && scope.row.state == '已上报' &&
checkPermission(['record_confirm']) checkPermission(['record_confirm'])
" "
type="primary" type="success"
size="small" size="small"
@click=" @click="
handleRecord({ action: 'confirm', record: scope.row }) handleRecord({ action: 'confirm', record: scope.row })
" "
>确认</el-button >确认</el-link
> >
<el-button <el-link
v-if=" v-if="
scope.row.state == '已上报' && scope.row.state == '已上报' &&
checkPermission(['record_reject']) checkPermission(['record_reject'])
@ -372,15 +418,24 @@
@click=" @click="
handleRecord({ action: 'reject', record: scope.row }) handleRecord({ action: 'reject', record: scope.row })
" "
>驳回</el-button >驳回</el-link
> >
<el-button <el-link
v-if="checkPermission(['record_view'])" v-if="checkPermission(['record_view'])"
size="small" size="small"
@click=" @click="
handleRecord({ action: 'view', record: scope.row }) handleRecord({ action: 'view', record: scope.row })
" "
>查看</el-button >查看</el-link
>
<el-link
v-if="checkPermission(['record_delete'])"
type="danger"
size="small"
@click="
handleRecord({ action: 'delete', record: scope.row })
"
>删除</el-link
> >
</template> </template>
</el-table-column> </el-table-column>
@ -433,7 +488,7 @@
} }
</style> </style>
<script> <script>
import { gettask, inittask, gettaskcontents, gettaskdepts } from "@/api/task"; import { gettask, inittask, gettaskcontents, gettaskdepts, starttask } from "@/api/task";
import { getRecordList } from "@/api/record"; import { getRecordList } 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";
@ -503,6 +558,18 @@ export default {
}); });
}); });
}, },
starttask(){
this.$confirm("确认发布任务吗?", "提示")
.then(async () => {
await starttask(this.task.id);
this.$message.success("成功");
location.reload();
})
.catch((err) => {
console.error(err);
});
},
gettaskdepts() { gettaskdepts() {
gettaskdepts(this.task.id).then((res) => { gettaskdepts(this.task.id).then((res) => {
this.depts = res.data; this.depts = res.data;

View File

@ -0,0 +1,23 @@
# Generated by Django 3.0.5 on 2021-03-23 06:25
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('supervision', '0009_auto_20210317_0922'),
]
operations = [
migrations.AlterField(
model_name='record',
name='state',
field=models.CharField(choices=[('待发布', '待发布'), ('待上报', '待上报'), ('已上报', '已上报'), ('已确认', '已确认'), ('待整改', '待整改')], default='待上报', max_length=50, verbose_name='记录状态'),
),
migrations.AlterField(
model_name='task',
name='state',
field=models.CharField(choices=[('创建中', '创建中'), ('待发布', '待发布'), ('执行中', '执行中'), ('已完成', '已完成')], default='创建中', max_length=50, verbose_name='任务状态'),
),
]

View File

@ -23,6 +23,7 @@ class Task(CommonBModel):
""" """
state_choices = ( state_choices = (
('创建中', '创建中'), ('创建中', '创建中'),
('待发布', '待发布'),
('执行中', '执行中'), ('执行中', '执行中'),
('已完成', '已完成'), ('已完成', '已完成'),
) )
@ -44,6 +45,7 @@ class Record(CommonBModel):
上报记录 上报记录
""" """
state_choices = ( state_choices = (
('待发布', '待发布'),
('待上报', '待上报'), ('待上报', '待上报'),
('已上报', '已上报'), ('已上报', '已上报'),
('已确认', '已确认'), ('已确认', '已确认'),

View File

@ -17,6 +17,7 @@ from .filters import RecordFilter
from django.db.models.query import QuerySet from django.db.models.query import QuerySet
from django.core.cache import cache from django.core.cache import cache
from apps.system.permission import get_permission_list, has_permission from apps.system.permission import get_permission_list, has_permission
from django.db.models import Q
# Create your views here. # Create your views here.
class ContentViewSet(CreateUpdateCustomMixin, ModelViewSet): class ContentViewSet(CreateUpdateCustomMixin, ModelViewSet):
@ -70,9 +71,10 @@ class TaskViewSet(CreateUpdateCustomMixin, ModelViewSet):
data['task'] = obj data['task'] = obj
data['end_date'] = obj.end_date data['end_date'] = obj.end_date
data['create_by'] = request.user data['create_by'] = request.user
data['state'] = '待发布'
record_list.append(Record(**data)) record_list.append(Record(**data))
Record.objects.bulk_create(record_list) Record.objects.bulk_create(record_list)
obj.state = '执行中' obj.state = '待发布'
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)
@ -95,6 +97,19 @@ class TaskViewSet(CreateUpdateCustomMixin, ModelViewSet):
serializer = OrganizationSimpleSerializer(obj.depts.distinct(), many=True) serializer = OrganizationSimpleSerializer(obj.depts.distinct(), many=True)
return Response(serializer.data) return Response(serializer.data)
@action(methods=['put'], detail=True, perms_map = {'put':'task_start'})
def start(self, request, *args, **kwargs):
"""
发布任务
"""
obj = self.get_object()
if obj.state == '待发布':
obj.state = '执行中'
obj.save()
Record.objects.filter(task=obj).update(state='待上报')
return Response(status=status.HTTP_200_OK)
return Response('任务状态错误', status=status.HTTP_400_BAD_REQUEST)
def cal_task_rate(task): def cal_task_rate(task):
""" """
计算任务上报率, 确认率 计算任务上报率, 确认率