diff --git a/doc/软件设计规格说明书.doc b/doc/软件设计规格说明书.doc
new file mode 100644
index 0000000..228a667
Binary files /dev/null and b/doc/软件设计规格说明书.doc differ
diff --git a/doc/软件需求构思及描述.docx b/doc/软件需求构思及描述.docx
new file mode 100644
index 0000000..91c37f0
Binary files /dev/null and b/doc/软件需求构思及描述.docx differ
diff --git a/doc/软件需求规格说明书.docx b/doc/软件需求规格说明书.docx
new file mode 100644
index 0000000..b566bd0
Binary files /dev/null and b/doc/软件需求规格说明书.docx differ
diff --git a/model/基于HTML和JavaScript的药品管理系统的分析和设计UML模型.docx b/model/基于HTML和JavaScript的药品管理系统的分析和设计UML模型.docx
new file mode 100644
index 0000000..d62f133
Binary files /dev/null and b/model/基于HTML和JavaScript的药品管理系统的分析和设计UML模型.docx differ
diff --git a/src/主界面.css b/src/主界面.css
new file mode 100644
index 0000000..b21b1ff
--- /dev/null
+++ b/src/主界面.css
@@ -0,0 +1,48 @@
+body{
+ background-image: url(海琴烟.jpg);
+ background-size: cover;
+ background-repeat: no-repeat;
+ background-position: center;
+ height: 100vh;
+ width: 100%;
+}
+/* 样式化表格 */
+table {
+ border-collapse: collapse; /* 合并边框 */
+ width: 90%; /* 表格宽度 */
+ margin: auto; /* 居中显示 */
+}
+th, td {
+ border: 1px solid #dddddd; /* 单元格边框 */
+ text-align: center; /* 文本居中 */
+ padding: 8px; /* 内边距 */
+}
+th {
+ background-color: #6f9775; /* 表头背景色 */
+}
+
+tr:nth-child(even) {
+ background-color: #887070; /* 斑马线条纹效果 */
+}
+
+tr:nth-child(odd) {
+ background-color: #5c61a8;
+}
+.a{
+ background-color: #4126a5; /* 设置按钮的背景颜色 */
+ color: white; /* 设置文本颜色 */
+ padding: 10px 20px; /* 设置内边距 */
+ border: none; /* 移除边框 */
+ border-radius: 5px; /* 设置边框圆角 */
+ cursor: pointer; /* 设置鼠标光标为指针形状 */
+ font-size: 16px; /* 设置字体大小 */
+}
+input.b{
+ border: 1px solid #041100;
+ border-radius: 5px;
+ text-align: center;
+ background-color: #c5d1cf;
+ color: #140000;
+ width: 150px;
+ height: 40px;
+}
\ No newline at end of file
diff --git a/src/主界面.html b/src/主界面.html
new file mode 100644
index 0000000..5906915
--- /dev/null
+++ b/src/主界面.html
@@ -0,0 +1,270 @@
+
+
+
+
+
+ Document
+
+ 主页面
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 序号 |
+ 类型 |
+ 药名 |
+ 价格 |
+ 库存 |
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/后端服务器.js b/src/后端服务器.js
new file mode 100644
index 0000000..cfa2eec
--- /dev/null
+++ b/src/后端服务器.js
@@ -0,0 +1,427 @@
+const express = require('express');
+const app = express();
+const mysql = require('mysql');
+
+const http = require('http');
+const querystring = require('querystring');
+
+function dj(){
+
+}
+// 创建连接对象
+const connection = mysql.createConnection({
+ host: 'localhost', // 数据库服务器地址
+ user: 'root', // 数据库用户名
+ password: 'CYH123456', // 数据库密码
+ database: 'cyh1' // 要连接的数据库名
+});
+
+// 开启连接
+connection.connect();
+
+var asd=' ';
+// 执行查询
+connection.query('Select * from 账户;', (error, results, fields) => {
+ if (error) throw error;
+ // 处理查询结果
+ asd = results;
+ console.log(results);
+});
+
+// 关闭连接
+connection.end();
+
+app.use((req, res, next) => {
+ res.setHeader('Access-Control-Allow-Origin', 'http://127.0.0.1:5500'); // 替换为您的前端应用域名
+ res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
+ res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization');
+ res.setHeader("Content-Security-Policy", "default-src *; style-src 'self' http://* 'unsafe-inline'; script-src 'self' http://* 'unsafe-inline' 'unsafe-eval'")
+
+ res.setHeader('Access-Control-Allow-Credentials', true);
+ next();
+});
+
+app.get('/', (req, res) => {
+ if (req.method === 'POST'){
+ console.log("ssssssssss");
+ let body = '';
+ req.on('data', chunk => {
+ body += chunk.toString(); // 转换为字符串
+ });
+ req.on('end', () => {
+ // 解析POST参数
+ const postParams = querystring.parse(body);
+ // 处理POST参数
+ console.log('POST parameters:', postParams);
+
+ // res.writeHead(OK, {'Content-Type': 'application/json'});
+ const responseData = { message: 'POST request received' };
+ // 发送响应数据
+ res.end(JSON.stringify(responseData));
+ });
+ }else{
+ res.send(asd);
+ console.log(req.method);
+ console.log("hello");
+ console.log(req.method);
+
+ }
+
+ // res.send(asd);
+
+ // console.log("hello")
+});
+const server = http.createServer((req,res) =>{
+ if (req.method === 'GET'){
+ res.end(asd);
+ console.log(req.method);
+ console.log("hello");
+ console.log(req.method);
+ }
+});
+
+
+
+
+app.post('/', (req, res) => {
+ if (req.method === 'POST'){
+ console.log("ssssssssss");
+ let body = '';
+ req.on('data', chunk => {
+
+ body += chunk.toString(); // 转换为字符串
+ });
+ req.on('end', () => {
+ // 解析POST参数
+
+ console.log(body);
+
+ const postParams = JSON.parse(body);
+ // 处理POST参数
+ console.log('POST parameters:', postParams);
+ var abc = ' ';
+ if (postParams.wenti == 1){
+ console.log("查询药库。");
+ console.log(postParams);
+
+ const connection = mysql.createConnection({
+ host: 'localhost', // 数据库服务器地址
+ user: 'root', // 数据库用户名
+ password: 'CYH123456', // 数据库密码
+ database: 'cyh1' // 要连接的数据库名
+ });
+ connection.connect();
+
+
+ connection.query('Select * from 主页面 '+';', (error, results, fields) => {
+ if (error) throw error;
+ // 处理查询结果
+ abc = results;
+ res.writeHead(200, {'Content-Type': 'application/json'});
+ const responseData = abc ;
+ // 发送响应数据
+ res.end(JSON.stringify(responseData));
+ console.log(JSON.stringify(responseData));
+ });
+ connection.end();
+ }
+ if (postParams.wenti ==2){
+ console.log("查找药品。");
+ // console.log(postParams);
+ // var as = String(postParams.id);
+ // console.log(as);
+ const connection = mysql.createConnection({
+ host: 'localhost', // 数据库服务器地址
+ user: 'root', // 数据库用户名
+ password: 'CYH123456', // 数据库密码
+ database: 'cyh1' // 要连接的数据库名
+ });
+ var sortnum = 0;
+ findid1='';
+ if (postParams.id!=null){
+ console.log(postParams.id);
+ findid1+=' where id = ';
+ findid1+=String(postParams.id);
+ sortnum++;
+ }
+ findtype1='';
+ if (postParams.type!=null){
+ console.log(postParams.type);
+ if (sortnum!=0){
+ findtype1+=' and ';
+ findtype1+=' type like ';
+ findtype1+='"%'+String(postParams.type)+'%"';
+ sortnum++;
+ console.log(findtype1);
+ }
+ else{
+ findtype1+=' where type like ';
+ findtype1+='"%'+String(postParams.type)+'%"';
+ sortnum++;
+ }
+ }
+ findname1='';
+ if(postParams.name!=null){
+ console.log(postParams.name);
+ if (sortnum!=0){
+ findname1+=' and ';
+ findname1+=' name like ';
+ findname1+='"%'+String(postParams.name)+'%"';
+ sortnum++;
+ }
+ else{
+ findname1+=' where name like ';
+ findtype1+='"%'+String(postParams.name)+'%"';
+ sortnum++;
+ }
+
+ }
+ findprice1='';
+ if (postParams.price!=null){
+ console.log(postParams.price);
+ if (sortnum!=0){
+ findprice1+=' and ';
+ findprice1+=' price = ';
+ findprice1+=String(postParams.price);
+ sortnum++;
+ }
+ else{
+ findprice1+=' where price = ';
+ findprice1+=String(postParams.price);
+ sortnum++;
+ }
+ }
+ findamount1='';
+ if (postParams.amount!=null){
+ if (sortnum!=0){
+ findamount1+=' and ';
+ findamount1+=' amount =';
+ findamount1+=String(postParams.amount);
+ sortnum++;
+ }
+ else{
+ findamount1+=' where amount = ';
+ findamount1+=String(postParams.amount);
+ sortnum++;
+ }
+ }
+ connection.connect();
+ connection.query('Select * from 主页面'+findid1+findtype1+findname1+findprice1+findamount1+';', (error, results, fields) => {
+ if (error) throw error;
+ // 处理查询结果
+ abc = results;
+ res.writeHead(200, {'Content-Type': 'application/json'});
+ const responseData = abc ;
+ // 发送响应数据
+ res.end(JSON.stringify(responseData));
+ console.log(JSON.stringify(responseData));
+ });
+ connection.end();
+
+ }
+ if (postParams.wenti ==3){
+ console.log("修改药品信息。");
+ console.log(postParams);
+ const connection = mysql.createConnection({
+ host: 'localhost', // 数据库服务器地址
+ user: 'root', // 数据库用户名
+ password: 'CYH123456', // 数据库密码
+ database: 'cyh1' // 要连接的数据库名
+ });
+
+
+ // connection.query('Select * from 主页面 '+';', (error, results, fields) => {
+ // if (error) throw error;
+ // console.log(results);
+ // // 处理查询结果
+ // });
+
+ if (postParams.type==null && postParams.name==null && postParams.price==null && postParams.amount==null ){
+ console.log('没有说明要修改的字段');
+ }
+ else{
+ sortnum2=0;
+ findid2 = '';
+ findid2 = String(postParams.id);
+ findtype2 = '';
+ if (postParams.type != null){
+ findtype2 += ' type = ';
+ findtype2 += ' "'+String(postParams.type)+'" ';
+ sortnum2++;
+ }
+ findname2 = '';
+ if (postParams.name != null){
+ if (sortnum2 == 0){
+ findname2 += 'name =';
+ findname2 += ' "'+String(postParams.name)+'" ';
+ sortnum2++;
+ }
+ else{
+ findname2 += ' , ';
+ findname2 += 'name =';
+ findname2 += ' "'+String(postParams.name)+'" ';
+ sortnum2++;
+ }
+ }
+ findprice2 = '';
+ if (postParams.price != null){
+ if (sortnum2 == 0){
+ findprice2 += 'price = ';
+ findprice2 += ' "'+String(postParams.price)+'" ';
+ sortnum2++;
+ }
+ else{
+ findprice2 += ' , ';
+ findprice2 += 'price = ';
+ findprice2 += ' "'+String(postParams.price)+'" ';
+ sortnum2++;
+ }
+ }
+ findamount2 = '';
+ if (postParams.amount != null){
+ if (sortnum2 == 0){
+ findamount2 += 'amount = ';
+ findamount2 += ' "'+String(postParams.amount)+'" ';
+ sortnum2++;
+ }
+ else{
+ findamount2 += ' , ';
+ findamount2 += 'amount = ';
+ findamount2 += ' "'+String(postParams.amount)+'" ';
+ sortnum2++;
+ }
+ }
+ if (sortnum2 != 0){
+ connection.query(' update 主页面 set ' + findtype2 + findname2 + findprice2 + findamount2 +' where id = '+findid2+';', (error, results, fields) => {
+ if (error) throw error;
+ console.log(results);
+ // 处理查询结果
+ });
+ }
+
+ }
+ connection.query('Select * from 主页面 '+';', (error, results, fields) => {
+ if (error) throw error;
+ // 处理查询结果
+ abc = results;
+ res.writeHead(200, {'Content-Type': 'application/json'});
+ const responseData = abc ;
+ // 发送响应数据
+ res.end(JSON.stringify(responseData));
+ console.log(JSON.stringify(responseData));
+ console.log(results.length)
+ });
+ connection.end();
+ }
+ if (postParams.wenti ==4){
+ console.log("删除药品。");
+ console.log(postParams);
+ const connection = mysql.createConnection({
+ host: 'localhost', // 数据库服务器地址
+ user: 'root', // 数据库用户名
+ password: 'CYH123456', // 数据库密码
+ database: 'cyh1' // 要连接的数据库名
+ });
+
+ sortnum3 = 0;
+
+ if (postParams.id == null){
+ console.log('没有待删除的药品的序号');
+ }
+ else{
+ findid3 = ' where id = ';
+ if (postParams.id != null){
+ findid3 += String(postParams.id);
+ findid3 += ' ';
+ sortnum3++;
+ }
+ findname3 = '';
+ if (postParams.name != null){
+ if (sortnum3 != 0){
+ findname3 += ' and ';
+ findname3 += ' name = ';
+ findname3 += ' "';
+ findname3 += String(postParams.name);
+ findname3 += '" ';
+ }
+ }
+
+ connection.query(' delete from 主页面 ' + findid3 + findname3+';', (error, results, fields) => {
+ if (error) throw error;
+ console.log(results);
+ // 处理查询结果
+ });
+
+
+ }
+
+ connection.query('Select * from 主页面 '+';', (error, results, fields) => {
+ if (error) throw error;
+ // 处理查询结果
+ abc = results;
+ res.writeHead(200, {'Content-Type': 'application/json'});
+ const responseData = abc ;
+ // 发送响应数据
+ res.end(JSON.stringify(responseData));
+ console.log(JSON.stringify(responseData));
+ console.log(results.length)
+ });
+ connection.end();
+ }
+
+ if (postParams.wenti == 5){
+
+ console.log("添加药品。");
+ console.log(postParams);
+ const connection = mysql.createConnection({
+ host: 'localhost', // 数据库服务器地址
+ user: 'root', // 数据库用户名
+ password: 'CYH123456', // 数据库密码
+ database: 'cyh1' // 要连接的数据库名
+ });
+
+ findid4 = String(postParams.id);
+ findtype4 = '"' + String(postParams.type)+ '"';
+ findname4 = '"' + String(postParams.name)+ '"';
+ findprice4 = String(postParams.price);
+ findamount4 = String(postParams.amount);
+
+ console.log(' insert into 主页面 values ('+ findid4 + ',' + findtype4 + ',' + findname4 + ',' + findprice4 + ',' + findamount4 +');');
+
+ connection.query(' insert into 主页面 values ('+ findid4 + ',' + findtype4 + ',' + findname4 + ',' + findprice4 + ',' + findamount4 +');', (error, results, fields) => {
+ if (error) throw error;
+ console.log(results);
+ // 处理查询结果
+ });
+
+
+
+ connection.query('Select * from 主页面 '+';', (error, results, fields) => {
+ if (error) throw error;
+ // 处理查询结果
+ abc = results;
+ res.writeHead(200, {'Content-Type': 'application/json'});
+ const responseData = abc ;
+ // 发送响应数据
+ res.end(JSON.stringify(responseData));
+ console.log(JSON.stringify(responseData));
+ });
+ connection.end();
+
+ }
+
+ // res.writeHead(200, {'Content-Type': 'application/json'});
+ // const responseData = {name:'POST request received'} ;
+ // // 发送响应数据
+ // res.end(JSON.stringify(responseData));
+ // console.log(JSON.stringify(responseData));
+ });
+ }
+});
+
+
+const PORT = 3000;
+app.listen(PORT, () => {
+ console.log(`Server is running on port ${PORT}`);
+});
+
diff --git a/src/海琴烟.jpg b/src/海琴烟.jpg
new file mode 100644
index 0000000..ef7b38c
Binary files /dev/null and b/src/海琴烟.jpg differ
diff --git a/src/登录界面.css b/src/登录界面.css
new file mode 100644
index 0000000..4a5b25b
--- /dev/null
+++ b/src/登录界面.css
@@ -0,0 +1,66 @@
+h1{
+ font-family: "Arial", sans-serif;
+ text-align:center;
+ color: #0c1c3be7;
+
+}
+
+body{
+ background-image: url(海琴烟.jpg);
+ background-size: cover;
+ background-repeat: no-repeat;
+ background-position: center;
+ height: 100vh;
+ width: 100%;
+}
+
+/* input[type='text'] {
+ display:block;
+ margin: 0 auto;
+ text-align:center;
+} */
+
+
+.a{
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ height:100%
+}
+
+input.custom-name-box {
+ width: 400px;
+ height: 40px;
+ text-align: center;
+ box-sizing: border-box;
+ border: 1px solid #dcdfe6;
+ border-radius: 4px;
+ outline: none;
+ padding: 0 15px;
+ color: #606266;
+}
+input.custom-name-box:focus {
+ border-color: #409eff;
+}
+input.custom-mima-box {
+ width: 400px;
+ height: 40px;
+ text-align: center;
+ box-sizing: border-box;
+ border: 1px solid #dcdfe6;
+ border-radius: 4px;
+ outline: none;
+ padding: 0 15px;
+ color: #010c0c;
+}
+input.custom-mima-box:focus {
+ border-color: #409eff;
+}
+::-webkit-input-placeholder {
+ color: #141518;
+}
+.button{
+ position: absolute;
+ top: 70%;
+ left: 49%;
+}
diff --git a/src/登录界面.js b/src/登录界面.js
new file mode 100644
index 0000000..11607d9
--- /dev/null
+++ b/src/登录界面.js
@@ -0,0 +1,27 @@
+
+
+const button = document.getElementById('3');
+button.addEventListener('click',function(){
+ const name = document.getElementById("1").value;
+ const mima = document.getElementById("2").value;
+ if (name != "" && mima != ""){
+ const zhanghao=confirm("确认密码:" + name + "\n" +
+ "确认密码:" + mima);
+ if (zhanghao){
+ console.log(name);
+ console.log(mima);
+
+ }else{
+ document.getElementById("1").value = null;
+ document.getElementById("2").value = null;
+ }
+ }
+ if (name == "" || mima == ""){
+ alert("请完整输入用户名和密码!!!");
+ }
+
+})
+
+function ID(name,mima){
+
+}
\ No newline at end of file
diff --git a/src/登录页面.html b/src/登录页面.html
new file mode 100644
index 0000000..caf0c60
--- /dev/null
+++ b/src/登录页面.html
@@ -0,0 +1,202 @@
+
+
+
+
+
+ 登录界面
+
+ 请登录您的账号
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file