login msg

This commit is contained in:
caoqianming 2020-09-24 14:09:01 +08:00
parent 2f39a1882b
commit 592dcfcbe8
6 changed files with 322 additions and 270 deletions

View File

@ -1,27 +1,32 @@
<template>
<div class="app-container">
<div>
<el-row :gutter="6">
<el-col :xs="24" :md="16">
<el-input
v-model="listQuery.search"
placeholder="项目/标准/编号/中心"
style="width: 600px;"
style="width: 100%"
class="filter-item"
@keyup.enter.native="handleFilter"
/>
</el-col>
<el-col :xs="24" :md="8" >
<el-button
class="filter-item"
type="primary"
icon="el-icon-search"
@click="handleFilter"
>搜索</el-button>
>搜索</el-button
>
<el-button
class="filter-item"
style="margin-left: 10px;"
type="primary"
icon="el-icon-refresh-left"
@click="resetFilter"
>刷新重置</el-button>
</div>
>刷新重置</el-button
>
</el-col>
</el-row>
<div style="margin-top: 10px">
<!-- <el-button type="primary" icon="el-icon-plus" @click="handleAdd" v-if="checkPermission(['cma_create'])">新增</el-button> -->
<el-popover
@ -31,7 +36,7 @@
v-model="popovervisible"
>
<p>导入能力列表压缩包.</p>
<div style="text-align: left; margin: 0;">
<div style="text-align: left; margin: 0">
<el-upload
:action="upUrl"
:on-success="handleUploadSuccess"
@ -39,7 +44,12 @@
:headers="upHeaders"
:show-file-list="false"
>
<el-button size="small" type="primary" @click="popovervisible = false">上传导入</el-button>
<el-button
size="small"
type="primary"
@click="popovervisible = false"
>上传导入</el-button
>
</el-upload>
</div>
@ -52,7 +62,7 @@
v-model="popovervisible2"
>
<p>导入能力列表压缩包.</p>
<div style="text-align: left; margin: 0;">
<div style="text-align: left; margin: 0">
<el-upload
:action="upUrl"
:on-success="handleUploadSuccess2"
@ -60,22 +70,28 @@
:headers="upHeaders"
:show-file-list="false"
>
<el-button size="small" type="primary" @click="popovervisible2 = false">上传导入</el-button>
<el-button
size="small"
type="primary"
@click="popovervisible2 = false"
>上传导入</el-button
>
</el-upload>
</div>
<el-button slot="reference">导入CNAS能力</el-button>
</el-popover>
</div>
<el-card style="margin-top: 6px">
<el-table
v-loading="listLoading"
:data="cmaList.results"
style="width: 100%;margin-top:10px;"
style="width: 100%; "
border
fit
stripe
highlight-current-row
max-height="300"
max-height="320"
ref="filterTable"
@filter-change="filterChange"
>
@ -98,7 +114,9 @@
<el-table-column align="header-center" label="标准编号">
<template slot-scope="scope">{{ scope.row.bzbh }}</template>
</el-table-column>
<el-table-column align="header-center" label="所属中心"
<el-table-column
align="header-center"
label="所属中心"
prop="sszx"
column-key="sszx"
:filters="groupBy.sszx"
@ -133,17 +151,17 @@
:limit.sync="listQuery.page_size"
@pagination="getList"
/>
</el-card>
<el-card style="margin-top:6px">
<el-table
v-loading="listLoading2"
:data="cnasList.results"
style="width: 100%;margin-top:10px;"
style="width: 100%;"
border
fit
stripe
highlight-current-row
max-height="300"
max-height="320"
>
<el-table-column type="index" width="50" />
<el-table-column align="header-center" label="类别名称">
@ -161,8 +179,7 @@
<el-table-column align="header-center" label="标准条款">
<template slot-scope="scope">{{ scope.row.bztk }}</template>
</el-table-column>
<el-table-column align="header-center" label="所属中心"
>
<el-table-column align="header-center" label="所属中心">
<template slot-scope="scope">{{ scope.row.sszx }}</template>
</el-table-column>
<!-- <el-table-column align="center" label="操作">
@ -192,9 +209,17 @@
:limit.sync="listQuery2.page_size"
@pagination="getList2"
/>
<el-dialog :visible.sync="dialogVisible" :title="dialogType==='edit'?'编辑':'新增'">
<el-form ref="Form" :model="cma" label-width="80px" label-position="right" >
</el-card>
<el-dialog
:visible.sync="dialogVisible"
:title="dialogType === 'edit' ? '编辑' : '新增'"
>
<el-form
ref="Form"
:model="cma"
label-width="80px"
label-position="right"
>
<el-form-item label="姓名" prop="name">
<el-input v-model="cma.name" placeholder="姓名" />
</el-form-item>
@ -202,7 +227,7 @@
<el-input v-model="cma.username" placeholder="账户" />
</el-form-item>
</el-form>
<div style="text-align:right;">
<div style="text-align: right">
<el-button type="danger" @click="dialogVisible = false">取消</el-button>
<el-button type="primary" @click="confirm('Form')">确认</el-button>
</div>
@ -217,21 +242,29 @@
}
</style>
<script>
import { getCMAList, createCMA, deleteCMA, updateCMA, importCMA, getCNASList, importCNAS, getCMAGroup } from "@/api/cma";
import checkPermission from "@/utils/permission"
import { upUrl, upHeaders } from "@/api/file"
import Pagination from "@/components/Pagination" // secondary package based on el-pagination
import {
getCMAList,
createCMA,
deleteCMA,
updateCMA,
importCMA,
getCNASList,
importCNAS,
getCMAGroup,
} from "@/api/cma";
import checkPermission from "@/utils/permission";
import { upUrl, upHeaders } from "@/api/file";
import Pagination from "@/components/Pagination"; // secondary package based on el-pagination
const defaultCMA = {
id: "",
dlxh: null,
dlmc: null,
};
const dflistQuery = {
page: 1,
page_size: 20,
type:'center'
}
type: "center",
};
export default {
components: { Pagination },
data() {
@ -247,11 +280,11 @@ export default {
listQuery: Object.assign({}, dflistQuery),
listQuery2: {
page: 1,
page_size: 20
page_size: 20,
},
enabledOptions: [
{ key: "true", display_name: "激活" },
{ key: "false", display_name: "禁用" }
{ key: "false", display_name: "禁用" },
],
dialogVisible: false,
dialogType: "new",
@ -260,131 +293,138 @@ export default {
};
},
computed: {},
watch: {
},
watch: {},
created() {
this.getList()
this.getGroup()
this.getList2()
this.getList();
this.getGroup();
this.getList2();
},
methods: {
checkPermission,
handleUploadSuccess(res, file) {
const loading = this.openLoading()
let data = {path:res.data.path}
importCMA(data).then(res=>{
const loading = this.openLoading();
let data = { path: res.data.path };
importCMA(data)
.then((res) => {
this.$message({
message: '导入成功',
type: 'success'
message: "导入成功",
type: "success",
});
loading.close();
this.resetFilter();
})
loading.close()
this.resetFilter()
}).catch(error=>{loading.close()})
.catch((error) => {
loading.close();
});
},
handleUploadSuccess2(res, file) {
const loading = this.openLoading()
let data = {path:res.data.path}
importCNAS(data).then(res=>{
const loading = this.openLoading();
let data = { path: res.data.path };
importCNAS(data)
.then((res) => {
this.$message({
message: '导入成功',
type: 'success'
message: "导入成功",
type: "success",
});
loading.close();
this.resetFilter();
})
loading.close()
this.resetFilter()
}).catch(error=>{loading.close()})
.catch((error) => {
loading.close();
});
},
getList() {
this.listLoading = true;
getCMAList(this.listQuery).then(response => {
getCMAList(this.listQuery).then((response) => {
if (response.data) {
this.cmaList = response.data
this.cmaList = response.data;
}
this.listLoading = false
})
this.listLoading = false;
});
},
getGroup() {
for (let key in this.groupBy) {
let data = Object.assign({}, this.listQuery)
data.group_by = key
getCMAGroup(data).then(response => {
this.groupBy[key] = response.data
})
let data = Object.assign({}, this.listQuery);
data.group_by = key;
getCMAGroup(data).then((response) => {
this.groupBy[key] = response.data;
});
}
},
getList2() {
this.listLoading2 = true;
getCNASList(this.listQuery2).then(response => {
getCNASList(this.listQuery2).then((response) => {
if (response.data) {
this.cnasList = response.data
this.cnasList = response.data;
}
this.listLoading2 = false
})
this.listLoading2 = false;
});
},
resetFilter() {
this.listQuery = Object.assign({}, dflistQuery),
this.listQuery2 = {
(this.listQuery = Object.assign({}, dflistQuery)),
(this.listQuery2 = {
page: 1,
page_size: 20
}
this.getList()
this.getList2()
this.getGroup()
page_size: 20,
});
this.getList();
this.getList2();
this.getGroup();
},
handleFilter() {
this.listQuery.page = 1
this.getList()
this.listQuery2.page = 1
this.listQuery2.search = this.listQuery.search
this.getList2()
this.getGroup()
this.listQuery.page = 1;
this.getList();
this.listQuery2.page = 1;
this.listQuery2.search = this.listQuery.search;
this.getList2();
this.getGroup();
},
handleAdd() {
this.cma = Object.assign({}, defaultCMA)
this.dialogType = "new"
this.dialogVisible = true
this.cma = Object.assign({}, defaultCMA);
this.dialogType = "new";
this.dialogVisible = true;
this.$nextTick(() => {
this.$refs["Form"].clearValidate()
})
this.$refs["Form"].clearValidate();
});
},
handleEdit(scope) {
this.cma = Object.assign({}, scope.row) // copy obj
this.dialogType = "edit"
this.dialogVisible = true
this.cma = Object.assign({}, scope.row); // copy obj
this.dialogType = "edit";
this.dialogVisible = true;
this.$nextTick(() => {
this.$refs["Form"].clearValidate()
})
this.$refs["Form"].clearValidate();
});
},
handleDelete(scope) {
this.$confirm("确认删除?", "警告", {
confirmButtonText: "确认",
cancelButtonText: "取消",
type: "error"
type: "error",
})
.then(async () => {
await deleteCMA(scope.row.id);
this.cmaList.splice(scope.row.index, 1);
this.$message({
type: "success",
message: "成功删除!"
message: "成功删除!",
});
})
.catch(err => {
.catch((err) => {
console.error(err);
});
},
filterChange(obj) {
for (let key in obj) {
this.listQuery[key] = obj[key][0]
this.listQuery[key] = obj[key][0];
}
this.listQuery.page=1
this.getList()
this.listQuery.page = 1;
this.getList();
},
async confirm(form) {
this.$refs[form].validate(valid => {
this.$refs[form].validate((valid) => {
if (valid) {
const isEdit = this.dialogType === "edit";
if (isEdit) {
updateCMA(this.cma.id, this.cma).then(res => {
updateCMA(this.cma.id, this.cma).then((res) => {
if (res.code >= 200) {
this.getList();
this.dialogVisible = false;
@ -392,12 +432,12 @@ this.getList()
title: "成功",
message: "编辑成功",
type: "success",
duration: 2000
duration: 2000,
});
}
});
} else {
createCMA(this.cma).then(res => {
createCMA(this.cma).then((res) => {
if (res.code >= 200) {
this.getList();
this.dialogVisible = false;
@ -405,7 +445,7 @@ this.getList()
title: "成功",
message: "新增成功",
type: "success",
duration: 2000
duration: 2000,
});
}
});
@ -414,7 +454,7 @@ this.getList()
return false;
}
});
}
}
},
},
};
</script>

View File

@ -1,7 +1,8 @@
<template>
<div class="app-container">
<div>
<el-select v-model="listQuery.sszx" placeholder="所属中心" @change="handleFilter2" clearable>
<el-row :gutter="6">
<el-col :xs="24" :md="4">
<el-select v-model="listQuery.sszx" placeholder="所属中心" @change="handleFilter2" clearable style="width: 100%;">
<el-option
v-for="item in groupBy.sszx"
:key="item.value"
@ -9,13 +10,18 @@
:value="item.value">
</el-option>
</el-select>
</el-col>
<el-col :xs="24" :md="8">
<el-input
v-model="listQuery.search"
placeholder="项目/标准/编号/中心"
style="width: 600px;"
style="width: 100%;"
class="filter-item"
@keyup.enter.native="handleFilter"
/>
</el-col>
<el-col :xs="24" :md="6">
<el-button
class="filter-item"
type="primary"
@ -24,12 +30,12 @@
>搜索</el-button>
<el-button
class="filter-item"
style="margin-left: 10px;"
type="primary"
icon="el-icon-refresh-left"
@click="resetFilter"
>刷新重置</el-button>
</div>
</el-col>
</el-row>
<div style="margin-top:10px">
<!-- <el-button type="primary" icon="el-icon-plus" @click="handleAdd" v-if="checkPermission(['cma_create'])">新增</el-button> -->
<el-popover
@ -62,7 +68,7 @@
fit
stripe
highlight-current-row
max-height="600"
max-height="700"
ref="filterTable"
@filter-change="filterChange"
>

View File

@ -1,7 +1,8 @@
<template>
<div class="app-container">
<div>
<el-select v-model="listQuery.sszx" placeholder="所属单位" @change="handleFilter2" clearable>
<el-row :gutter="6">
<el-col :xs="24" :md="4">
<el-select v-model="listQuery.sszx" placeholder="所属单位" @change="handleFilter2" clearable style="width: 100%;">
<el-option
v-for="item in groupBy.sszx"
:key="item.value"
@ -9,13 +10,17 @@
:value="item.value">
</el-option>
</el-select>
</el-col>
<el-col :xs="24" :md="8">
<el-input
v-model="listQuery.search"
placeholder="资质/服务"
style="width: 40%;"
style="width: 100%;"
class="filter-item"
@keyup.enter.native="handleFilter"
/>
</el-col>
<el-col :xs="24" :md="6">
<el-button
class="filter-item"
type="primary"
@ -24,12 +29,12 @@
>搜索</el-button>
<el-button
class="filter-item"
style="margin-left: 10px;"
type="primary"
icon="el-icon-refresh-left"
@click="resetFilter"
>刷新</el-button>
</div>
</el-col>
</el-row>
<div style="margin-top:10px">
<el-button type="primary" icon="el-icon-plus" @click="handleAdd" v-if="checkPermission(['qualification_create'])">新增</el-button>
<!-- <el-popover
@ -62,7 +67,7 @@
fit
stripe
highlight-current-row
max-height="600"
max-height="700"
ref="filterTable"
@filter-change="filterChange"
>

View File

@ -140,7 +140,7 @@ export default {
disabled:false,
buttonmsg:'发送验证码',
count:20,
activeName: "pwd",
activeName: "msg",
loginForm: {
username: "",
password: "",

View File

@ -65,7 +65,7 @@ class Login2View(APIView):
msg = request.data['msg']
if not User.objects.filter(username=mail).exists():
return Response('账户不存在', status=status.HTTP_400_BAD_REQUEST)
if Message.objects.filter(mail=mail).last().msg == msg:
if Message.objects.filter(mail=mail).exists() and Message.objects.filter(mail=mail).last().msg == msg:
user = User.objects.get(username=mail)
return Response(get_tokens_for_user(user), status=status.HTTP_200_OK)
return Response('验证码错误', status=status.HTTP_400_BAD_REQUEST)
@ -75,7 +75,7 @@ class sendMsg(APIView):
permission_classes = []
def post(self, request):
code = random.randint(1000,9999)
code = random.randint(10000,99999)
my_sender = 'caoqianming@ctc.ac.cn'
my_user = request.data['mail']
my_pass = '9093QQww'
@ -101,6 +101,7 @@ class sendMsg(APIView):
server.sendmail(my_sender,[my_user,],msg.as_string())
# 关闭连接
server.quit()
Message.objects.filter(mail=my_user).delete()
Message.objects.create(mail=my_user, msg=code)
except:
return Response('验证码发送失败', status=status.HTTP_400_BAD_REQUEST)

Binary file not shown.