zmz 9 months ago
parent 4aaecb4fd8
commit f8a7e2b4c6

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="xiangmuguanli@localhost" uuid="b5718ae4-ec8c-472f-a042-fa252070993a">
<data-source source="LOCAL" name="xiangmuguanli@localhost" uuid="1f8390a3-d0f0-42d6-aeaf-a749ff62cab8">
<driver-ref>mysql.8</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>

@ -1,4 +1,4 @@
from django.db import models
from django.db import models
class project(models.Model):
project_leader = models.CharField(u'项目名称',max_length=10)
@ -7,7 +7,6 @@ class project(models.Model):
department_id = models.CharField(u'部门id',max_length=4)
id = models.CharField(u'项目id',max_length=4,primary_key=True)
def __str__(self):
return self.project_leader

@ -5,10 +5,15 @@ from manage import views
from manage.views import *
urlpatterns = [
path('admin/', admin.site.urls),
# path('admin/', admin.site.urls),
path('', views.ChooseLoginView.as_view()),
path('Customer_login/', views.CustomerLoginView.as_view()),
path('Employee_login/', views.EmployeeLoginView.as_view()),
path('customercenter/', views.CustomerCenterView.as_view()),
path('employeecenter/', views.EmployeeCenterView.as_view()),
path('list/', views.ListView.as_view()),
path('list2/', views.ListView2.as_view()),
path('add/', views.AddView.as_view()),
path('delete/', views.DeleteView.as_view()),
path('update/', views.UpdateView.as_view()),
]

@ -1,10 +1,7 @@
from django.shortcuts import render
from django.views import View
import datetime
import uuid
from django.http import HttpResponseRedirect
from .models import *
from manage.models import employee, administrator, project, customer, department
# 登录选择
class ChooseLoginView(View):
@ -55,30 +52,12 @@ class EmployeeLoginView(View):
return HttpResponseRedirect('/Employee_login/')
# #客户注册
# class CustomerRegisterView(View):
# def get(self,request):
# return render(request, 'Customerregister.html')
# def post(self, request, customer):#customer引用失败
# # 只能注册客户账号,不能注册员工账号,员工账号只能由管理员创建
# id = request.POST.get('id',"")
# customer_list = customer.objects.filter(id=id)
# if customer_list:
# return render(request, 'Customerregister.html'),{"err":1, "tips": "该客户账号已存在"}
# else:
# customer_name = request.POST.get('customer_name',"")
# customer_age = request.POST.get('customer_age',"")
# customer_priority = request.POST.get('customer_priority',"")
# customer = customer.objects.create(id=id,customer_name=customer_name,customer_age=customer_age,customer_priority=customer_priority)
# if customer:
# return HttpResponseRedirect('/customerlogin/')
# return HttpResponseRedirect('/customerregister/')
#客户界面
class CustomerCenterView(View):
def get(self,request):
customer = request.session.get('customer')
print(customer)
# print(customer)
return render(request, 'Customercenter.html', {"customer_id":customer})
#员工界面
@ -88,13 +67,64 @@ class EmployeeCenterView(View):
employee_image = request.session.get('employee_image','')
return render(request, 'Employeecenter.html', {"employee_id":employee, 'employee_image':employee_image})
#查看项目(客户)
class ListView(View):
def get(self, request):
project1 = project.objects.all()
# has_data = False
# for i in project1:
# if i.project_leader: # 如果project_leader非空
# print(i.project_leader)
# has_data = True
# if not has_data:
# print("No project data or all project_leaders are empty.")
return render(request, 'list.html', context={'project1': project1})
#查看项目(员工)
class ListView2(View):
def get(self, request):
project1 = project.objects.all()
return render(request, 'list2.html', context={'project1': project1})
class AddView(View):
def get(self, request):
return render(request, 'add.html')
def post(self, request):
id = request.POST.get('id', "")
project_leader = request.POST.get('project_leader', "")
project_description = request.POST.get('project_description', "")
customer_id = request.POST.get('customer_id', "")
department_id = request.POST.get('department_id', "")
project.objects.create(id=id,project_leader=project_leader,project_description=project_description,customer_id=customer_id,department_id=department_id)
return render(request, 'add.html',context={'id':id,'project_leader':project_leader,'project_description':project_description,'customer_id':customer_id,'department_id':department_id})
class DeleteView(View):
def get(self, request):
project1 = project.objects.all()
id = request.GET.get('id', "")
project.objects.filter(id=id).delete()
return render(request, 'delete.html',context={'project1': project1})
def post(self, request):
id = request.POST.get('id', "")
project.objects.filter(id=id).delete()
return render(request, 'delete.html',context={'id':id})
#管理员登录
# class AdministratorLoginView(View):
# def get(self,request):
# return render(request,'Administratorlogin.html')
# def post(self,request):
# id = request.POST.get('id',"")
# administrator_name = request.POST.get('administrator_name',"")
class UpdateView(View):
def get(self, request):
project1 = project.objects.all()
id = request.GET.get('id', "")
project_leader = request.GET.get('project_leader', "")
project_description = request.GET.get('project_description', "")
customer_id = request.GET.get('customer_id', "")
department_id = request.GET.get('department_id', "")
return render(request, 'update.html',context={'project1': project1,'id':id,'project_leader':project_leader,'project_description':project_description,'customer_id':customer_id,'department_id':department_id})
def post(self, request):
id = request.POST.get('id', "")
project_leader = request.POST.get('project_leader', "")
project_description = request.POST.get('project_description', "")
customer_id = request.POST.get('customer_id', "")
department_id = request.POST.get('department_id', "")
project.objects.filter(id=id).update(project_leader=project_leader,project_description=project_description,customer_id=customer_id,department_id=department_id)
return render(request, 'update.html',context={'id':id,'project_leader':project_leader,'project_description':project_description,'customer_id':customer_id,'department_id':department_id})

@ -22,6 +22,6 @@ from manage.views import ChooseLoginView
urlpatterns = [
path('admin/', admin.site.urls),
path('',include('manage.url')),
path('user/',include('manage.url')),
# path('user/',include('manage.url')),
# path('user/', ChooseLoginView.as_view()),
]

@ -1,10 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>管理员登录</title>
</head>
<body>
</body>
</html>

@ -1,10 +1,72 @@
<!DOCTYPE html>
{% load static %}
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Django企业项目管理系统</title>
{# <link rel="stylesheet" type="text/css" href="/static/css/login_choose.css/">#}
<style> body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f5f5f5;
}
.PageFont {
text-align: center;
padding: 50px 0;
}
h1 {
color: #333;
margin-bottom: 20px;
}
.bottom {
display: flex;
justify-content: space-around;
align-items: center;
padding: 50px 0;
background-color: #fff;
}
.PageCustomer, .PageEmployee, .Administrator {
border: 1px solid #ddd;
padding: 15px;
border-radius: 5px;
text-align: center;
transition: all 0.3s;
}
.PageCustomer a, .PageEmployee a, .Administrator a {
text-decoration: none;
color: #333;
display: block;
padding: 10px;
}
.Administrator {
background-color: #f0f0f0;
}
.Administrator p {
font-weight: bold;
}
.copyright {
background-color: #333;
color: #fff;
text-align: center;
padding: 15px;
position: absolute;
bottom: 0;
width: 100%;
font-size: 14px;
}
.copyright span {
display: inline-block;
margin: 0 5px;
}
</style>
</head>
<body>
<div class="PageFont">
@ -16,7 +78,6 @@
<!-- 客户登录 -->
<div class="PageCustomer">
<a href="/Customer_login/">
{# <img src="/static/images/customer.png" alt=""/>#}
<p>客户登录</p>
</a>
</div>
@ -24,7 +85,6 @@
<!-- 员工登录 -->
<div class="PageEmployee">
<a href="/Employee_login/">
{# <img src="/static/images/employee.png" alt=""/>#}
<p>员工登录</p>
</a>
</div>
@ -32,8 +92,7 @@
<!-- 管理员登录 -->
<div class="Administrator">
<a href="/admin/">
{# <img src="/static/images/admin.png" alt=""/>#}
<p class="Administrator">管理员登录</p>
<p class="Administrator">网页管理员登录</p>
</a>
</div>
</div>

@ -3,8 +3,57 @@
<head>
<meta charset="UTF-8">
<title>客户界面</title>
<!-- 添加内联样式 -->
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f0f0f0;
}
.title {
text-align: center;
color: #333;
margin-top: 50px;
}
.bottom {
display: flex;
justify-content: center;
margin-top: 30px;
}
.PageCustomer {
background-color: white;
border: 1px solid #ddd;
padding: 20px;
border-radius: 5px;
width: 200px;
text-align: center;
}
.PageCustomer a {
text-decoration: none;
color: #007BFF;
margin: 10px 0;
display: block;
}
h3 {
text-align: center;
margin-top: 50px;
color: #666;
}
</style>
</head>
<body>
<div>
<h1 class="title">欢迎</h1>
<div class="bottom">
<div class="PageCustomer">
<a href="/list/">
<p>查看项目信息</p>
</a>
<a href="/">返回</a>
</div>
</div>
</div>
<h3>这里是客户界面</h3>
</body>
</html>
</html>

@ -3,6 +3,61 @@
<head>
<meta charset="UTF-8">
<title>客户登录</title>
<!-- 内联CSS样式 -->
<style> body {
font-family: Arial, sans-serif;
background-color: #f0f0f0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
.login_box {
background-color: white;
padding: 20px;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
width: 300px;
}
.title {
text-align: center;
color: #333;
margin-bottom: 20px;
}
.input_box {
display: block;
width: 100%;
padding: 10px;
margin-bottom: 15px;
border: 1px solid #ddd;
border-radius: 3px;
font-size: 14px;
}
.button {
width: 100%;
padding: 10px;
background-color: #007BFF;
color: white;
border: none;
border-radius: 3px;
cursor: pointer;
font-size: 14px;
}
.button:hover {
background-color: #0056b3;
}
a {
display: block;
text-align: center;
color: #007BFF;
text-decoration: none;
margin-top: 15px;
}
a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<div>
@ -15,6 +70,5 @@
<a href="/">返回</a>
</form>
</div>
<h3>这里是客户登录页面</h3>
</body>
</html>

@ -1,10 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>客户注册</title>
</head>
<body>
</body>
</html>

@ -3,8 +3,72 @@
<head>
<meta charset="UTF-8">
<title>员工界面</title>
<!-- 添加样式 -->
<style> body {
font-family: Arial, sans-serif;
line-height: 1.6;
margin: 0;
padding: 0;
background-color: #f4f4f4;
}
.title {
text-align: center;
color: #333;
margin-top: 50px;
}
.bottom {
margin: 30px auto;
max-width: 600px;
background-color: white;
padding: 20px;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
.PageCustomer {
display: flex;
flex-direction: column;
align-items: center;
}
.PageCustomer a {
text-decoration: none;
color: #007BFF;
margin-bottom: 10px;
display: inline-block;
padding: 5px 10px;
border-radius: 3px;
transition: background-color 0.3s ease;
}
.PageCustomer a:hover {
background-color: #e9ecef;
}
h3 {
text-align: center;
margin-top: 50px;
}
</style>
</head>
<body>
<div>
<h1 class="title">欢迎</h1>
<div class="bottom">
<!-- 查看项目信息 -->
<div class="PageCustomer">
<a href="/list2/">
<p>查看项目信息</p>
</a>
<a href="/add/">
<p>新增项目信息</p>
</a>
<a href="/update/">
<p>修改项目信息</p>
</a>
<a href="/delete/">
<p>删除项目信息</p>
</a>
<a href="/Employee_login/">返回</a>
</div>
</div>
</div>
<h3>这里是员工界面</h3>
</body>
</html>

@ -3,13 +3,59 @@
<head>
<meta charset="UTF-8">
<title>员工登录</title>
{# <link rel="stylesheet" type="text/css" href="/static/css/emplyeelogin.css/">#}
<style>
body {
font-family: Arial, sans-serif;
background-color: #f5f5f5;
margin: 0;
padding: 20px;
}
.login_box {
width: 300px;
margin: auto;
background-color: white;
padding: 20px;
border: 1px solid #ddd;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.title {
text-align: center;
margin-bottom: 15px;
}
.input_box {
display: block;
width: 100%;
padding: 10px;
margin-bottom: 15px;
border: 1px solid #ddd;
font-size: 14px;
}
.button {
width: 100%;
padding: 10px;
background-color: #007bff;
color: white;
border: none;
cursor: pointer;
font-size: 14px;
}
.button:hover {
background-color: #0056b3;
}
h3 {
text-align: center;
margin-top: 20px;
}
</style>
</head>
<body>
{# {% load static %}#}
{# <div class="logo_box">#}
{# <img src="/static/images/employee.png" alt=""/>#}
{# </div>#}
<!-- 原有的HTML内容保持不变 -->
<div>
<form class="login_box" method="POST" action="/Employee_login/">
<h1 class="title">欢迎登录</h1>
@ -22,4 +68,4 @@
</div>
<h3>这里是员工登录页面</h3>
</body>
</html>
</html>

@ -0,0 +1,70 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>新增项目</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f0f0f0;
margin: 0;
padding: 20px;
}
form {
max-width: 600px;
margin: 0 auto;
background-color: white;
padding: 20px;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
input {
display: block;
width: 100%;
margin-bottom: 10px;
padding: 10px;
font-size: 16px;
border: 1px solid #ccc;
border-radius: 3px;
}
input[type="submit"] {
background-color: #4CAF50;
color: white;
cursor: pointer;
padding: 10px 20px;
border: none;
border-radius: 3px;
font-size: 16px;
}
input[type="submit"]:hover {
background-color: #45a049;
}
a {
text-decoration: none;
color: #007BFF;
margin-top: 10px;
}
a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<form action="/add/", method="POST">
{% csrf_token %}
<input type="number" name="id" placeholder="项目编号">
<input type="text" name="project_leader" placeholder="项目名称">
<input type="text" name="project_description" placeholder="项目描述">
<input type="number" name="customer_id" placeholder="客户编号">
<input type="number" name="department_id" placeholder="负责部门编号">
<input type="submit" value="提交">
<a href="/employeecenter/">返回</a>
</form>
</body>
</html>

@ -0,0 +1,90 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>删除</title>
<style> body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f8f9fa;
}
h3 {
text-align: center;
padding: 20px 0;
}
table {
width: 50%;
margin: 0 auto;
border-collapse: collapse;
}
th, td {
border: 1px solid #dee2e6;
padding: 10px;
text-align: center;
}
th {
background-color: #007bff;
color: white;
}
tr:nth-child(even) {
background-color: #f2f2f2;
}
form {
display: flex;
justify-content: center;
margin: 20px 0;
}
input[type="number"], input[type="submit"] {
padding: 10px;
font-size: 14px;
}
input[type="submit"] {
background-color: #007bff;
color: white;
border: none;
cursor: pointer;
}
a {
display: block;
text-align: center;
margin-top: 20px;
color: #007bff;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<h3>项目信息</h3>
<table border="1">
<thead>
<tr>
<th>项目编号</th>
<th>项目名称</th>
<th>项目描述</th>
<th>客户编号</th>
<th>负责部门编号</th>
</tr>
</thead>
{% for project1 in project1 %}
<tr>
<td>{{ project1.id }}</td>
<td>{{ project1.project_leader }}</td>
<td>{{ project1.project_description }}</td>
<td>{{ project1.customer_id }}</td>
<td>{{ project1.department_id }}</td>
</tr>
{% endfor %}
</table>
<form action="/delete/" method="POST">
{% csrf_token %}
<input type="number" name="id" placeholder="项目编号">
<input type="submit" value="确认">
</form>
<a href="/employeecenter/">返回</a>
</body>
</html>

@ -1,10 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>index</title>
</head>
<body>
</body>
</html>

@ -0,0 +1,73 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>查看</title>
<!-- 添加内联CSS样式 -->
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
}
h3 {
color: #4CAF50;
margin-bottom: 10px;
}
table {
width: 100%;
border-collapse: collapse;
}
th, td {
padding: 15px;
text-align: left;
border-bottom: 1px solid #ddd;
}
th {
background-color: #4CAF50;
color: white;
}
tr:hover {
background-color: #f5f5f5;
}
a {
display: inline-block;
margin-top: 20px;
text-decoration: none;
padding: 10px 20px;
background-color: #4CAF50;
color: white;
border-radius: 5px;
}
a:hover {
background-color: #45a049;
}
</style>
</head>
<body>
<h3>项目信息</h3>
<table border="1">
<thead>
<tr>
<th>项目编号</th>
<th>项目名称</th>
<th>项目描述</th>
<th>客户编号</th>
<th>负责部门编号</th>
</tr>
</thead>
{% for project1 in project1 %}
<tr>
<td>{{ project1.id }}</td>
<td>{{ project1.project_leader }}</td>
<td>{{ project1.project_description }}</td>
<td>{{ project1.customer_id }}</td>
<td>{{ project1.department_id }}</td>
</tr>
{% endfor %}
</table>
<a href="/customercenter/">返回</a>
</body>
</html>

@ -0,0 +1,70 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>查看</title>
<!-- 添加内联CSS样式 -->
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
}
h3 {
color: #4CAF50;
margin-bottom: 10px;
}
table {
width: 100%;
border-collapse: collapse;
}
th, td {
padding: 15px;
text-align: left;
border-bottom: 1px solid #ddd;
}
th {
background-color: #4CAF50;
color: white;
}
tr:hover {
background-color: #f5f5f5;
}
a {
display: inline-block;
margin-top: 20px;
text-decoration: none;
padding: 10px 20px;
background-color: #4CAF50;
color: white;
border-radius: 5px;
}
a:hover {
background-color: #45a049;
}
</style>
</head>
<body>
<h3>项目信息</h3>
<table border="1">
<thead>
<tr>
<th>项目编号</th>
<th>项目名称</th>
<th>项目描述</th>
<th>客户编号</th>
<th>负责部门编号</th>
</tr>
</thead>
{% for project1 in project1 %}
<tr>
<td>{{ project1.id }}</td>
<td>{{ project1.project_leader }}</td>
<td>{{ project1.project_description }}</td>
<td>{{ project1.customer_id }}</td>
<td>{{ project1.department_id }}</td>
</tr>
{% endfor %}
</table>
<a href="/employeecenter/">返回</a>
</body>
</html>

@ -1,37 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>登录信息</title>
<style>
.my_error{
color: red;
font-size: 20px;
margin-left: 50px;
}
</style>
</head>
<body>
<h3>登录信息</h3>
<form method="post" action=“{% url 'login' %}>
{% csrf_token %}
<div>
<label for="InputText1">用户名:</label>
<input type="text" id="InputText1" name="user" placeholder="用户名">
</div>
<div>
<label for="InputPassword1">密码:</label>
<input type="password" id="InputPassword1" name="password" placeholder="密码">
</div>
<div>
<input type="submit" value="登录">
</div>
<div>
{% if error %}
<p class="my_error">{{ error }}</p>
{% endif %}
</div>
</form>
</body>
</html>

@ -0,0 +1,66 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>更新项目</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
padding-top: 20px;
}
form {
width: 300px;
margin: 0 auto;
background-color: white;
padding: 20px;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
input[type="number"],
input[type="text"] {
display: block;
width: 100%;
margin-bottom: 15px;
padding: 10px;
border: 1px solid #ddd;
border-radius: 3px;
}
input[type="submit"] {
background-color: #007BFF;
color: white;
border: none;
cursor: pointer;
padding: 10px 20px;
text-align: center;
border-radius: 5px;
font-size: 16px;
}
input[type="submit"]:hover {
background-color: #0056b3;
}
a {
display: block;
text-align: center;
margin-top: 20px;
color: #007BFF;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<form action="/update/" method="POST">
{% csrf_token %}
<input type="number" name="id" placeholder="项目编号" required>
<input type="text" name="project_leader" placeholder="项目名称" required>
<input type="text" name="project_description" placeholder="项目描述">
<input type="number" name="customer_id" placeholder="客户编号" required>
<input type="number" name="department_id" placeholder="负责部门编号" required>
<input type="submit" value="确认">
<a href="/employeecenter/">返回</a>
</form>
</body>
</html>
Loading…
Cancel
Save