From 36b14dc5768c5e5b1478418973642f680c30d12a Mon Sep 17 00:00:00 2001 From: LKWYZ Date: Wed, 20 Jul 2022 12:58:08 +0800 Subject: [PATCH 1/2] 0720 --- src/App.js | 12 ++- src/userComponents/userLogin/UserLogin.jsx | 3 +- .../homeDocuments/DocumentsManage.js | 26 ++++--- .../userManageCenter/homeIn/AppDetailTable.js | 43 ++++++----- .../homeIn/CreateInApplication.js | 2 +- .../homeOut/CreateOutApplication.js | 58 ++++++++++++-- .../homeTrading/CreateTradingApplication.js | 76 +++++++++++++++++-- src/userPages/IntoHomePage.js | 8 +- 8 files changed, 175 insertions(+), 53 deletions(-) diff --git a/src/App.js b/src/App.js index f8c0df7..8c7ae96 100644 --- a/src/App.js +++ b/src/App.js @@ -5,6 +5,16 @@ import axios from 'axios'; axios.defaults.baseURL="http://localhost:80" +axios.interceptors.request.use((config) => { + + // console.log(config); + + config.headers.token = localStorage.getItem('token'); + + return config; + + }) + function App() { return (
@@ -17,7 +27,7 @@ function App() { } /> } /> - }/> + }/> }/> diff --git a/src/userComponents/userLogin/UserLogin.jsx b/src/userComponents/userLogin/UserLogin.jsx index b56652e..2cf947f 100644 --- a/src/userComponents/userLogin/UserLogin.jsx +++ b/src/userComponents/userLogin/UserLogin.jsx @@ -82,7 +82,8 @@ const UserInput=()=>{ console.log(response); if(response.data.message=="登录成功"){ setIsInfoRight(true); - navigate("userhome/${username}"); + localStorage.setItem("token",response.data.data.token); + navigate("userhome"); event.preventDefault(); }else if(response.data.message=="参数错误"){ alert("您的用户名或密码错误!"); diff --git a/src/userComponents/userManageCenter/homeDocuments/DocumentsManage.js b/src/userComponents/userManageCenter/homeDocuments/DocumentsManage.js index 74921fb..833725d 100644 --- a/src/userComponents/userManageCenter/homeDocuments/DocumentsManage.js +++ b/src/userComponents/userManageCenter/homeDocuments/DocumentsManage.js @@ -26,6 +26,7 @@ const DocumentsManage=()=>{ axios({ method: 'post', url: '/user/userhome/manage/orderdetail/orders', + //headers: {'Authorization': localStorage.getItem('token')}, params:{ user_ic:user_ic, } @@ -102,17 +103,17 @@ const DocumentsManage=()=>{ const showModal=()=>{ switch(detailData.orderType){ case 0: - return(); + return(); case 3: - return(); + return(); case 2: - return(); + return(); case 5: - return(); + return(); case 1: - return(); + return(); case 4: - return(); + return(); } } @@ -161,6 +162,10 @@ const DocumentsManage=()=>{ dataIndex:'orderStatus', render: (record) => orderStatus[record], }, + { + title:'单据费用', + dataIndex:'orderPrice', + }, { title:'操作', key:'action', @@ -248,13 +253,14 @@ const DocumentsManage=()=>{
- 确定]}> - {showModal()} + 确定]}> - + {showModal()} + + ) diff --git a/src/userComponents/userManageCenter/homeIn/AppDetailTable.js b/src/userComponents/userManageCenter/homeIn/AppDetailTable.js index b717390..5872b00 100644 --- a/src/userComponents/userManageCenter/homeIn/AppDetailTable.js +++ b/src/userComponents/userManageCenter/homeIn/AppDetailTable.js @@ -6,22 +6,13 @@ import { func } from 'prop-types'; import { orderType, orderStatus } from "../../../utils/userDatas"; const columns=[ - { - title:'单据类型', - dataIndex:'orderType', - - }, - { - title:'创建时间', - dataIndex:'orderCreatetime', - }, { title:'单据编号', dataIndex:'orderId', }, { - title:'单据状态', - dataIndex:'orderStatus', + title:'货物编号', + dataIndex:'productId', }, { @@ -29,32 +20,38 @@ const columns=[ dataIndex:'productName', }, { - title:'货物类型', - dataIndex:'productType', + title:'货物价格', + dataIndex:'price', }, { title:'货物数量', dataIndex:'amount', }, - { - title:'货物重量', - dataIndex:'orderWeight', - }, - { - title:'本单费用', - dataIndex:'orderPrice', - }, ] function AppDetailTable({item}){ + /* const convertItem = { ...item, key: item.id, }; + */ return (
+ +
+ + + {/**
{columns.map((item) => ( @@ -69,7 +66,11 @@ function AppDetailTable({item}){ ))}
+
*/}
+ + + ); } diff --git a/src/userComponents/userManageCenter/homeIn/CreateInApplication.js b/src/userComponents/userManageCenter/homeIn/CreateInApplication.js index b1b3861..ecf4ce0 100644 --- a/src/userComponents/userManageCenter/homeIn/CreateInApplication.js +++ b/src/userComponents/userManageCenter/homeIn/CreateInApplication.js @@ -21,7 +21,7 @@ const CreateInApplication=()=>{ console.log(productVOList); axios({ method: 'post', - url: 'http://10.128.137.205:8088/user/userhome/manage/instorage/order', + url: '/user/userhome/manage/instorage/order', data:{ //orderCreatetime: "2022-07-14T07:47:57.850Z", //orderCreatetime:time, diff --git a/src/userComponents/userManageCenter/homeOut/CreateOutApplication.js b/src/userComponents/userManageCenter/homeOut/CreateOutApplication.js index 59bd728..3fe3b14 100644 --- a/src/userComponents/userManageCenter/homeOut/CreateOutApplication.js +++ b/src/userComponents/userManageCenter/homeOut/CreateOutApplication.js @@ -17,7 +17,7 @@ const allData=[ "inventoryPosition": 3, "inventoryProduct": 148, "inventoryProductName": "冰红茶", - "inventoryNum": 0, + "inventoryNum": 30, "inventoryIn": 10, "inventoryOut": 10, "inventoryRecent": 10, @@ -43,7 +43,7 @@ const allData=[ "inventoryPosition": 3, "inventoryProduct": 149, "inventoryProductName": "荔枝", - "inventoryNum": 10, + "inventoryNum": 40, "inventoryIn": 20, "inventoryOut": 10, "inventoryRecent": 20, @@ -56,7 +56,7 @@ const allData=[ "inventoryPosition": 1, "inventoryProduct": 150, "inventoryProductName": "水", - "inventoryNum": 10, + "inventoryNum": 70, "inventoryIn": 50, "inventoryOut": 40, "inventoryRecent": 50, @@ -69,7 +69,7 @@ const allData=[ "inventoryPosition": 3, "inventoryProduct": 150, "inventoryProductName": "水", - "inventoryNum": 30, + "inventoryNum": 80, "inventoryIn": 50, "inventoryOut": 20, "inventoryRecent": 0, @@ -84,10 +84,41 @@ const CreateOutApplication=()=>{ const [productVOList, setProductVOList] = useState([]); const [userIc, setUserIc] = useState(null); + useEffect(() => { + axios({ + method: 'get', + url: '/passport/userinfo', + //headers: {'Authorization': localStorage.getItem('token')}, + params:{ + token:localStorage.getItem('token'), + } + }) + .then(response=> { + console.log(response); + }) + .catch(function (error) { + console.log(error.config); + }); + axios({ + method: 'post', + url: '/user/userhome/manage/outstorage/inventory', + //headers: {'Authorization': localStorage.getItem('token')}, + params:{ + user_ic:userIc, + } + }) + .then(response=> { + console.log(response); + }) + .catch(function (error) { + console.log(error.config); + }); + },[]); + const addGoodsItem = () => { setProductVOList([ ...productVOList, - { inventoryNum: null, inventoryId: null, inventoryProductName: null, inventoryPosition:null, inventoryRepository:null }, + { inventoryNum: null, inventoryId: null, inventoryProductName: null, inventoryPosition:null, inventoryRepository:null, inventoryOwner:"ICb4e2ad2c"}, ]); }; @@ -136,6 +167,13 @@ const CreateOutApplication=()=>{ return repository; } + const getAmount=(a,b)=>{ + let data=allData.filter(item=>item.inventoryProductName==a&&item.inventoryId==b); + console.log(data); + let amount=data[0].inventoryNum; + return amount; + } + return(
@@ -145,12 +183,13 @@ const CreateOutApplication=()=>{

- + {/** - - +

+ */} +
@@ -214,6 +253,9 @@ const CreateOutApplication=()=>{ }} placeholder="请输入货物数量" /> + {index !== 0 && (
{ - const [productVOList, setProductVOList] = useState([[]]); + const [productVOList, setProductVOList] = useState([]); const [userIc, setUserIc] = useState(null); + const [orderBuyer, setOrderBuyer] = useState(null); + + useEffect(() => { + axios({ + method: 'get', + url: '/passport/userinfo', + //headers: {'Authorization': localStorage.getItem('token')}, + params:{ + token:localStorage.getItem('token'), + } + }) + .then(response=> { + console.log(response); + }) + .catch(function (error) { + console.log(error.config); + }); + axios({ + method: 'post', + url: '/user/userhome/manage/trading/inventory', + //headers: {'Authorization': localStorage.getItem('token')}, + params:{ + user_ic:userIc, + } + }) + .then(response=> { + console.log(response); + }) + .catch(function (error) { + console.log(error.config); + }); + },[]); + const addGoodsItem = () => { setProductVOList([ ...productVOList, - { inventoryNum: null, inventoryId: null, inventoryProductName: null }, + { inventoryNum: null, inventoryId: null, inventoryProductName: null, inventoryPosition:null, inventoryRepository:null, inventoryOwner:"ICb4e2ad2c" }, ]); }; @@ -102,6 +135,9 @@ const CreateTradingApplication=()=>{ method: 'post', url: '/user/userhome/manage/trading/order', data:productVOList, + params:{ + order_buyer:orderBuyer, + } //orderCreatetime: "2022-07-14T07:47:57.850Z", //orderCreatetime:time, @@ -120,6 +156,24 @@ const CreateTradingApplication=()=>{ } + const getPosition=(a,b)=>{ + let data=allData.filter(item=>item.inventoryProductName==a&&item.inventoryId==b); + let position=data[0].inventoryPosition; + return position; + } + + const getRepository=(a,b)=>{ + let data=allData.filter(item=>item.inventoryProductName==a&&item.inventoryId==b); + let repository=data[0].inventoryRepository; + return repository; + } + + const getAmount=(a,b)=>{ + let data=allData.filter(item=>item.inventoryProductName==a&&item.inventoryId==b); + let amount=data[0].inventoryNum; + return amount; + } + return(
@@ -146,7 +200,7 @@ const CreateTradingApplication=()=>{
- {setUserIc(e.target.value)}} className='rounded-md outline outline-1 outline-gray-700 relative inset-x-1 w-44'> + {setOrderBuyer(e.target.value)}} className='rounded-md outline outline-1 outline-gray-700 relative inset-x-1 w-44'>

{productVOList.map((item, index) => (
@@ -163,11 +217,16 @@ const CreateTradingApplication=()=>{ return true } }} - value={item.inventoryProductName!=null?item.inventoryProductName+"--"+item.inventoryId+"--"+item.inventoryPosition:"名称--货物编号--仓库"} + value={item.inventoryProductName!=null? + item.inventoryProductName+"--"+item.inventoryId+"--"+item.inventoryPosition+"号库"+item.inventoryRepository+"位" + :"名称--货物编号--仓库"} onSelect={(value,key) => { + console.log(value,key); let newList = [...productVOList]; - newList[index].inventoryProductName = value; + newList[index].inventoryProductName = key.title; newList[index].inventoryId = key.key; + newList[index].inventoryPosition = getPosition(key.title,key.key) + newList[index].inventoryRepository = getRepository(key.title,key.key); setProductVOList([...newList]); }} defaultActiveFirstOption={false} @@ -179,8 +238,8 @@ const CreateTradingApplication=()=>{ > {allData?.map((item) => { return ( - ); })} @@ -197,6 +256,9 @@ const CreateTradingApplication=()=>{ }} placeholder="请输入货物数量" /> + {index !== 0 && (
{ - const {username}=useParams(); + //const {username}=useParams(); const [userName, setUserName] = useState(null); - console.log(username); + //console.log(username); useEffect(() => { - setUserName(username); - console.log(username); + //setUserName(username); + //console.log(username); },[]); -- Gitee From 7515f3c0f97f5b08b7d01ad63242b11d64fa2fa0 Mon Sep 17 00:00:00 2001 From: LKWYZ Date: Thu, 21 Jul 2022 03:14:19 +0800 Subject: [PATCH 2/2] 0721 --- package-lock.json | 12 + package.json | 1 + src/App.js | 31 ++- .../userHelpCenter/HelpCenter.js | 72 ++++- src/userComponents/userLogin/UserRegister.js | 7 +- .../homeDocuments/DocumentsManage.js | 40 ++- .../userManageCenter/homeGoods/QueryGoods.js | 262 ++++++++++++++++-- .../homeIn/CreateInApplication.js | 77 ++++- .../homeOut/CreateOutApplication.js | 144 +++++----- .../homeTrading/CreateTradingApplication.js | 90 +++--- .../userMessageCenter/MessageCenter.js | 205 +++++++++++++- .../userMessageCenter/MessageList.js | 49 +++- src/userPages/IntoHomePage.js | 15 +- 13 files changed, 838 insertions(+), 167 deletions(-) diff --git a/package-lock.json b/package-lock.json index de23d37..3189266 100644 --- a/package-lock.json +++ b/package-lock.json @@ -32,6 +32,7 @@ "eslint": "^8.3.0", "eslint-config-react-app": "^7.0.1", "eslint-webpack-plugin": "^3.1.1", + "event-source-polyfill": "^1.0.26", "file-loader": "^6.2.0", "framer-motion": "^6.3.16", "fs-extra": "^10.0.0", @@ -7691,6 +7692,12 @@ "node": ">= 0.6" } }, + "node_modules/event-source-polyfill": { + "version": "1.0.26", + "resolved": "https://registry.npmmirror.com/event-source-polyfill/-/event-source-polyfill-1.0.25.tgz", + "integrity": "sha512-hQxu6sN1Eq4JjoI7ITdQeGGUN193A2ra83qC0Ltm9I2UJVAten3OFVN6k5RX4YWeCS0BoC8xg/5czOCIHVosQg==", + "deprecated": "[WARNING] Use 1.0.25 instead of 1.0.26, reason: Undesired Behavior https://security.snyk.io/vuln/SNYK-JS-EVENTSOURCEPOLYFILL-2429580, issues: https://github.com/Yaffle/EventSource/issues/199" + }, "node_modules/eventemitter3": { "version": "4.0.7", "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz", @@ -23034,6 +23041,11 @@ "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==" }, + "event-source-polyfill": { + "version": "1.0.26", + "resolved": "https://registry.npmmirror.com/event-source-polyfill/-/event-source-polyfill-1.0.25.tgz", + "integrity": "sha512-hQxu6sN1Eq4JjoI7ITdQeGGUN193A2ra83qC0Ltm9I2UJVAten3OFVN6k5RX4YWeCS0BoC8xg/5czOCIHVosQg==" + }, "eventemitter3": { "version": "4.0.7", "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz", diff --git a/package.json b/package.json index f9bd96b..2cc8ec3 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "eslint": "^8.3.0", "eslint-config-react-app": "^7.0.1", "eslint-webpack-plugin": "^3.1.1", + "event-source-polyfill": "^1.0.26", "file-loader": "^6.2.0", "framer-motion": "^6.3.16", "fs-extra": "^10.0.0", diff --git a/src/App.js b/src/App.js index 8c7ae96..6856be1 100644 --- a/src/App.js +++ b/src/App.js @@ -1,4 +1,4 @@ -import { Navigate, Route, Routes } from "react-router-dom"; +import { Navigate, Route, Routes, router } from "react-router-dom"; import { LoginReg, NotFoundPage, Admin } from "./pages"; import { Into, Login } from "./userPages/index"; import axios from 'axios'; @@ -15,6 +15,35 @@ axios.interceptors.request.use((config) => { }) + + /* + router.beforeEach((to, form, next) => { + // to要跳转到的路径 + // from从哪个路径来 + // next往下执行的回调 + // 在localStorage中获取信息 + if (to.name !== 'login') { + store.dispatch('getLayoutConfigInfo').then(() => { + next(); + }); + } else { + next(); + } + let a = localStorage.getItem('username') + let b = ['pageConfig','indexConfig','classConfig','stationConfig'] + if (a!='admin'&&b.includes(to.name)) { + //满足条件进行判断 跳转 + ElementUI.Message.error('无权限访问此页面') + next({ + path:"/fixture" + }) + + } else { + next(); + } + }); +*/ + function App() { return (
diff --git a/src/userComponents/userHelpCenter/HelpCenter.js b/src/userComponents/userHelpCenter/HelpCenter.js index 90f43a7..4ed3add 100644 --- a/src/userComponents/userHelpCenter/HelpCenter.js +++ b/src/userComponents/userHelpCenter/HelpCenter.js @@ -1,10 +1,78 @@ //帮助中心 -import React from 'react'; +import React, { useState, useEffect } from 'react'; import ReactDOM from 'react-dom/client'; import { Navigate, Route, Routes } from "react-router-dom"; import { UserHelpSidebar } from "../index"; +import axios from 'axios'; + +const HelpCenter=()=>{ + const [userIc,setUserIc]=useState(null); + useEffect(() => { + axios({ + method: 'get', + url: '/passport/userinfo', + //headers: {'Authorization': localStorage.getItem('token')}, + params:{ + token:localStorage.getItem('token'), + } + }) + .then(response=> { + setUserIc(response.data.data.userIC); + }) + .catch(function (error) { + console.log(error.config); + }); + },[]); + + const onClick=()=>{ + axios({ + method: 'get', + url: '/sse/getIds', + //headers: {'Authorization': localStorage.getItem('token')}, + params:{ + token:localStorage.getItem('token'), + } + }) + .then(response=> { + console.log(response); + }) + .catch(function (error) { + console.log(error.config); + }); + + axios({ + method: 'post', + url: '/sse/pushOne', + //headers: {'Authorization': localStorage.getItem('token')}, + params:{ + token:localStorage.getItem('token'), + message:"123456", + userIC:userIc, + } + }) + .then(response=> { + console.log(response); + }) + .catch(function (error) { + console.log(error.config); + }); + } + + return( +
+
+ +
+
+ +
+
+ ) +} + +/* class HelpCenter extends React.Component{ render(){ return( @@ -19,5 +87,5 @@ class HelpCenter extends React.Component{ ) } } - +*/ export default HelpCenter; \ No newline at end of file diff --git a/src/userComponents/userLogin/UserRegister.js b/src/userComponents/userLogin/UserRegister.js index 74e83af..df9539a 100644 --- a/src/userComponents/userLogin/UserRegister.js +++ b/src/userComponents/userLogin/UserRegister.js @@ -97,6 +97,7 @@ class UserRegister extends React.Component{ registerBtn(event){ console.log(this.state.userName, this.state.password, this.state.userUsername); if((this.state.password==this.state.passagain)&&this.state.userName!=null&&this.state.userUsername!=null&&this.state.password!=null&&this.state.userPhonenum!=null){ + axios({ method: 'post', url: '/passport/registry', @@ -128,11 +129,11 @@ class UserRegister extends React.Component{ return(
- } className='relative inset-x-0 h-9 w-96 rounded-md' value={this.state.userName} onChange={this.nameChange} /> + } className='relative inset-x-0 h-9 w-96 rounded-md' value={this.state.userName} onChange={this.nameChange} />

- } className='relative inset-x-0 h-9 w-96 rounded-md' value={this.state.userUsername} onChange={this.usernameChange} /> + } className='relative inset-x-0 h-9 w-96 rounded-md' value={this.state.userUsername} onChange={this.usernameChange} />

- } className='relative inset-x-0 h-9 w-96 rounded-md' value={this.state.password} onChange={this.psChange} /> + } className='relative inset-x-0 h-9 w-96 rounded-md' value={this.state.password} onChange={this.psChange} />

} className='relative inset-x-0 h-9 w-96 rounded-md' value={this.state.passagain} onChange={this.psagChange} />

diff --git a/src/userComponents/userManageCenter/homeDocuments/DocumentsManage.js b/src/userComponents/userManageCenter/homeDocuments/DocumentsManage.js index 833725d..a47162b 100644 --- a/src/userComponents/userManageCenter/homeDocuments/DocumentsManage.js +++ b/src/userComponents/userManageCenter/homeDocuments/DocumentsManage.js @@ -20,26 +20,43 @@ const DocumentsManage=()=>{ const [queryId,setQueryId]=useState(null); const [queryDate,setQueryDate]=useState(null); const [showType,setShowType]=useState("all"); - const [user_ic,setUser_ic]=useState('IC00000001'); + const [userIc,setUserIc]=useState(null); useEffect(() => { axios({ - method: 'post', - url: '/user/userhome/manage/orderdetail/orders', + method: 'get', + url: '/passport/userinfo', //headers: {'Authorization': localStorage.getItem('token')}, params:{ - user_ic:user_ic, + token:localStorage.getItem('token'), } }) .then(response=> { console.log(response); - setDataSource(response.data.data.items); - setDataSource2(response.data.data.items); - setQueryData(response.data.data.items); + setUserIc(response.data.data.userIC); + return axios({ + method: 'post', + url: '/user/userhome/manage/orderdetail/orders', + //headers: {'Authorization': localStorage.getItem('token')}, + params:{ + user_ic:response.data.data.userIC, + } + }) + .then(response=> { + console.log(response); + setDataSource(response.data.data.items); + setDataSource2(response.data.data.items); + setQueryData(response.data.data.items); }) .catch(function (error) { console.log(error.config); }); + }) + .catch(function (error) { + console.log(error.config); + }); + + },[]); const idChange=(event)=>{ @@ -173,9 +190,9 @@ const DocumentsManage=()=>{ return(
- {(text.orderType=="3"||text.orderType=="5"||text.orderType=="4")&&text.orderStatus!="2"? + {/**(text.orderType=="3"||text.orderType=="5"||text.orderType=="4")&&text.orderStatus!="2"? - :} + :*/}
) @@ -233,7 +250,7 @@ const DocumentsManage=()=>{ - + @@ -257,7 +274,8 @@ const DocumentsManage=()=>{ 确定]}> - {showModal()} + {/**showModal()*/} + diff --git a/src/userComponents/userManageCenter/homeGoods/QueryGoods.js b/src/userComponents/userManageCenter/homeGoods/QueryGoods.js index 1e2b1ff..fe49416 100644 --- a/src/userComponents/userManageCenter/homeGoods/QueryGoods.js +++ b/src/userComponents/userManageCenter/homeGoods/QueryGoods.js @@ -1,10 +1,250 @@ //货物查询 -import React from 'react'; +import React, { useState, useEffect } from 'react'; import ReactDOM from 'react-dom/client'; import axios from "axios"; import { Table, Modal } from "antd"; + +const QueryGoods=()=>{ + const [isAllShow,setIsAllShow]=useState(true); + const [isModalVisible,setIsModalVisible]=useState(false); + + const [allDataSource,setAllDataSource]=useState([]); + const [storgeDataSource,setStorgeDataSource]=useState([]); + const [detailData,setDetailData]=useState([]); + const [queryData,setQueryData]=useState([]); + + const [queryName,setQueryName]=useState(null); + const [queryId,setQueryId]=useState(null); + const [userIc,setUserIc]=useState(null); + + useEffect(() => { + axios({ + method: 'get', + url: '/passport/userinfo', + //headers: {'Authorization': localStorage.getItem('token')}, + params:{ + token:localStorage.getItem('token'), + } + }) + .then(response=> { + console.log(response); + setUserIc(response.data.data.userIC); + return axios({ + method: 'post', + url: '/user/userhome/manage/querygoods/total', + params:{ + user_ic:response.data.data.userIC, + } + }) + .then(response=> { + console.log(response); + setAllDataSource(response.data.data.item); + setQueryData(response.data.data.item); + }) + .catch(function (error) { + console.log(error.config); + }); + }) + .catch(function (error) { + console.log(error.config); + }); + + /* + axios({ + method: 'post', + url: '/user/userhome/manage/querygoods/query', + params:{ + user_ic:response.data.data.userIC, + } + }) + .then(response=> { + console.log(response); + setStorgeDataSource(response.data.data.items); + }) + .catch(function (error) { + console.log(error.config); + }); + */ + + + + },[]); + + const nameChange=(event)=>{ + if(event.target.value==""){ + setQueryName(null); + }else{ + setQueryName(event.target.value); + } + } + + const idChange=(event)=>{ + if(event.target.value==""){ + setQueryId(null); + }else{ + setQueryId(event.target.value); + } + } + + const queryAll=(event)=>{ + if(queryName==null){ + setQueryData(allDataSource); + }else{ + setQueryData(allDataSource.filter(item=>item.inventoryProductName==queryName)); + } + event.preventDefault(); + } + + const queryStorge=(event)=>{ + if(queryId==null&&queryName==null){ + setQueryData(storgeDataSource); + } + else if(queryId!=null&&queryName==null){ + setQueryData(storgeDataSource.filter(item=>item.inventoryProduct==queryId)); + } + else if(queryId==null&&queryName!=null){ + setQueryData(storgeDataSource.filter(item=>item.inventoryProductName==queryName)); + } + else{ + setQueryData(storgeDataSource.filter(item=>item.inventoryProduct==queryId&&item.inventoryProductName==queryName)); + } + event.preventDefault(); + } + + const showAllGoods=(event)=>{ + setIsAllShow(true); + setQueryData(allDataSource); + } + + const showGoodsStorge=(event)=>{ + + + setIsAllShow(false); + //setQueryData(storgeDataSource); + axios({ + method: 'post', + url: '/user/userhome/manage/querygoods/query', + params:{ + user_ic:userIc, + } + }) + .then(response=> { + console.log(response); + setStorgeDataSource(response.data.data.item); + setQueryData(response.data.data.item) + }) + .catch(function (error) { + console.log(error.config); + }); + } + + const allColumns=[ + { + title:'货物名称', + dataIndex:'inventoryProductName', + }, + { + title:'货物数量', + dataIndex:'inventoryNum', + }, + + ] + + + const storageColumns=[ + { + title:'货物名称', + dataIndex:'inventoryProductName', + }, + { + title:'货物编号', + dataIndex:'inventoryProduct', + }, + { + title:'货物数量', + dataIndex:'inventoryNum', + }, + { + title:'所在仓库', + dataIndex:'inventoryPosition', + }, + + { + title:'所在仓位', + dataIndex:'inventoryRepository', + }, + + + ] + + return( +
+
+ +
+
+
+ + + + +
+ + {isAllShow? + + + + + + :
+ + + + + + +
} + +
+ + + + +
+ + + + + + ) +} + +/* class QueryGoods extends React.Component{ constructor(props){ super(props); @@ -31,7 +271,7 @@ class QueryGoods extends React.Component{ componentDidMount() { axios({ method: 'post', - url: 'http://10.128.137.205:8088/user/userhome/manage/querygoods/query', + url: '/user/userhome/manage/querygoods/query', params:{ user_ic:this.state.user_ic, } @@ -141,11 +381,6 @@ class QueryGoods extends React.Component{ title:'货物名称', dataIndex:'productName', }, - /* - { - title:'货物类型', - dataIndex:'productType', - },*/ { title:'货物数量', dataIndex:'amount', @@ -163,11 +398,6 @@ class QueryGoods extends React.Component{ title:'货物编号', dataIndex:'productId', }, - /* - { - title:'货物类型', - dataIndex:'productType', - },*/ { title:'货物数量', dataIndex:'amount', @@ -180,11 +410,7 @@ class QueryGoods extends React.Component{ { title:'仓库地址', dataIndex:'storgePosition', - },/* - { - title:'货物价格', - dataIndex:'price', - },*/ + }, ] @@ -256,4 +482,6 @@ class QueryGoods extends React.Component{ } } +*/ + export default QueryGoods; \ No newline at end of file diff --git a/src/userComponents/userManageCenter/homeIn/CreateInApplication.js b/src/userComponents/userManageCenter/homeIn/CreateInApplication.js index ecf4ce0..45a30a4 100644 --- a/src/userComponents/userManageCenter/homeIn/CreateInApplication.js +++ b/src/userComponents/userManageCenter/homeIn/CreateInApplication.js @@ -1,36 +1,82 @@ //申请入库的面板label -import React, { useState } from 'react'; +import React, { useState, useEffect } from 'react'; import ReactDOM from 'react-dom/client'; import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons'; -import { Button, Form, Input, Space } from 'antd'; +import { Button, Form, Input, Space, Modal } from 'antd'; +import { Link } from 'react-router-dom'; import axios from "axios"; -import { StorgeChosen, DateSelect } from '../../index'; const CreateInApplication=()=>{ const [productVOList,setProductVOList]=useState([]); + const [userIc,setUserIc]=useState(null); + const [isModalVisible, setIsModalVisible] = useState(false); + + useEffect(() => { + axios({ + method: 'get', + url: '/passport/userinfo', + //headers: {'Authorization': localStorage.getItem('token')}, + params:{ + token:localStorage.getItem('token'), + } + }) + .then(response=> { + setUserIc(response.data.data.userIC); + }) + .catch(function (error) { + console.log(error.config); + }); + },[]); + const onFinish=(values)=>{ setProductVOList(values.productInfo); console.log('Received values of form:', values); console.log(productVOList); + axios({ + method: 'post', + url: '/user/userhome/manage/instorage/order', + data:{ + //orderCreatetime: "2022-07-14T07:47:57.850Z", + //orderCreatetime:time, + orderOwner:userIc, + productVOList:values.productInfo, + } + }) + .then(response=> { + console.log(response); + if(response.data.message==="入库申请成功"){ + setIsModalVisible(true); + }else{ + alert(response.data.message); + } + }) + .catch(function (error) { + console.log(error.config); + console.log("2"); + }); }; const onSubmit=(event)=>{ console.log(productVOList); + console.log(userIc); axios({ method: 'post', url: '/user/userhome/manage/instorage/order', data:{ //orderCreatetime: "2022-07-14T07:47:57.850Z", //orderCreatetime:time, + orderOwner:userIc, productVOList:productVOList, } }) .then(response=> { console.log(response); - console.log("1"); + if(response.data.message==="入库申请成功"){ + setIsModalVisible(true); + } }) .catch(function (error) { console.log(error.config); @@ -40,7 +86,7 @@ const CreateInApplication=()=>{ return(
-
+ {/**


@@ -54,7 +100,8 @@ const CreateInApplication=()=>{
-
+
*/} +

@@ -99,9 +146,10 @@ const CreateInApplication=()=>{ )} - + */} + @@ -109,9 +157,20 @@ const CreateInApplication=()=>{




- + {/** */} +



+ + + 确定 +
+ + ]}> +

您已提交申请,即将返回主界面。

+
) diff --git a/src/userComponents/userManageCenter/homeOut/CreateOutApplication.js b/src/userComponents/userManageCenter/homeOut/CreateOutApplication.js index 3fe3b14..94b6465 100644 --- a/src/userComponents/userManageCenter/homeOut/CreateOutApplication.js +++ b/src/userComponents/userManageCenter/homeOut/CreateOutApplication.js @@ -2,14 +2,12 @@ //还要加仓库:仓库号+仓位;货物最大数量;信息只留IC import React, { useState, useEffect } from 'react'; import ReactDOM from 'react-dom/client'; -import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons'; -import { Button, Form, Input, Space, Typography, Select } from 'antd'; +import { Select, Modal } from 'antd'; import axios from "axios"; import { CgRemove } from "react-icons/cg"; -import { nanoid } from "nanoid"; -import { StorgeChosen, DateSelect, GoodsChosen } from '../../index'; - +import { Link } from 'react-router-dom'; +/* const allData=[ { "inventoryOwner": "ICb4e2ad2c", @@ -77,12 +75,14 @@ const allData=[ "inventoryId": 21 } ] - +*/ const { Option } = Select; const CreateOutApplication=()=>{ const [productVOList, setProductVOList] = useState([]); const [userIc, setUserIc] = useState(null); + const [allData,setAllData]=useState([]); + const [isModalVisible, setIsModalVisible] = useState(false); useEffect(() => { axios({ @@ -92,83 +92,83 @@ const CreateOutApplication=()=>{ params:{ token:localStorage.getItem('token'), } - }) - .then(response=> { - console.log(response); - }) - .catch(function (error) { - console.log(error.config); - }); - axios({ + }) + .then(response=> { + setUserIc(response.data.data.userIC); + return axios({ method: 'post', url: '/user/userhome/manage/outstorage/inventory', //headers: {'Authorization': localStorage.getItem('token')}, params:{ - user_ic:userIc, + user_ic:response.data.data.userIC, } - }) - .then(response=> { - console.log(response); + }) + .then(response=> { + console.log(response); + setAllData(response.data.data.items); + }) + .catch(function (error) { + console.log(error.config); + }); }) .catch(function (error) { - console.log(error.config); + console.log(error.config); }); - },[]); + + + },[]); const addGoodsItem = () => { - setProductVOList([ - ...productVOList, - { inventoryNum: null, inventoryId: null, inventoryProductName: null, inventoryPosition:null, inventoryRepository:null, inventoryOwner:"ICb4e2ad2c"}, - ]); - }; - - const removeGoodsItem = (e, index) => { - e.stopPropagation(); - let newList = [...productVOList]; - newList.splice(index, 1); - setProductVOList([...newList]); - }; + setProductVOList([ + ...productVOList, + { inventoryNum: null, inventoryProduct: null, inventoryProductName: null, inventoryPosition:null, inventoryRepository:null, inventoryOwner:userIc}, + ]); + }; + //inventoryPosition:null, inventoryRepository:null, + const removeGoodsItem = (e, index) => { + e.stopPropagation(); + let newList = [...productVOList]; + newList.splice(index, 1); + setProductVOList([...newList]); + }; - const onSubmit=(event)=>{ - console.log(productVOList); + const onSubmit=(event)=>{ + console.log(productVOList); - axios({ - method: 'post', - url: '/user/userhome/manage/outstorage/order', - data:productVOList, - - //orderCreatetime: "2022-07-14T07:47:57.850Z", - //orderCreatetime:time, - - //inventoryList:this.state.productVOList, - - }) - .then(response=> { - console.log(response); - console.log("1"); - }) - .catch(function (error) { - console.log(error.config); - console.log("2"); - }); + axios({ + method: 'post', + url: '/user/userhome/manage/outstorage/order', + data:productVOList, + }) + .then(response=> { + console.log(response); + if(response.data.message==="出库申请成功"){ + setIsModalVisible(true); + }else{ + alert(response.data.message); + } + }) + .catch(function (error) { + console.log(error.config); + }); } const getPosition=(a,b)=>{ - let data=allData.filter(item=>item.inventoryProductName==a&&item.inventoryId==b); + let data=allData.filter(item=>item.inventoryProductName==a&&item.inventoryProduct==b); let position=data[0].inventoryPosition; return position; } const getRepository=(a,b)=>{ - let data=allData.filter(item=>item.inventoryProductName==a&&item.inventoryId==b); + let data=allData.filter(item=>item.inventoryProductName==a&&item.inventoryProduct==b); let repository=data[0].inventoryRepository; return repository; } const getAmount=(a,b)=>{ - let data=allData.filter(item=>item.inventoryProductName==a&&item.inventoryId==b); + let data=allData.filter(item=>item.inventoryProductName==a&&item.inventoryProduct==b); console.log(data); let amount=data[0].inventoryNum; return amount; @@ -176,24 +176,24 @@ const CreateOutApplication=()=>{ return(
- - -
+ {/**


- {/** +

- */} +
-
+
*/} + +

@@ -215,13 +215,13 @@ const CreateOutApplication=()=>{ } }} value={item.inventoryProductName!=null? - item.inventoryProductName+"--"+item.inventoryId+"--"+item.inventoryPosition+"号库"+item.inventoryRepository+"位" + item.inventoryProductName+"--"+item.inventoryProduct+"--"+getPosition(item.inventoryProductName,item.inventoryProduct)+"号库"+getRepository(item.inventoryProductName,item.inventoryProduct)+"位" :"名称--货物编号--仓库"} onSelect={(value,key) => { console.log(value,key); let newList = [...productVOList]; newList[index].inventoryProductName = key.title; - newList[index].inventoryId = key.key; + newList[index].inventoryProduct = key.key; newList[index].inventoryPosition = getPosition(key.title,key.key) newList[index].inventoryRepository = getRepository(key.title,key.key); setProductVOList([...newList]); @@ -235,8 +235,8 @@ const CreateOutApplication=()=>{ > {allData?.map((item) => { return ( - ); })} @@ -254,7 +254,7 @@ const CreateOutApplication=()=>{ placeholder="请输入货物数量" /> {index !== 0 && ( @@ -289,7 +289,17 @@ const CreateOutApplication=()=>{



+ + 确定 +
+ + ]}> +

您已提交申请,即将返回主界面。

+
+ ) } diff --git a/src/userComponents/userManageCenter/homeTrading/CreateTradingApplication.js b/src/userComponents/userManageCenter/homeTrading/CreateTradingApplication.js index 6a37535..f6cec7e 100644 --- a/src/userComponents/userManageCenter/homeTrading/CreateTradingApplication.js +++ b/src/userComponents/userManageCenter/homeTrading/CreateTradingApplication.js @@ -1,13 +1,11 @@ import React, { useState, useEffect } from 'react'; import ReactDOM from 'react-dom/client'; -import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons'; -import { Button, Form, Input, Space, Typography, Select } from 'antd'; +import { Select, Modal } from 'antd'; import axios from "axios"; import { CgRemove } from "react-icons/cg"; -import { nanoid } from "nanoid"; -import { StorgeChosen, DateSelect, GoodsChosen } from '../../index'; - +import { Link } from 'react-router-dom'; +/* const allData=[ { "inventoryOwner": "ICb4e2ad2c", @@ -75,11 +73,15 @@ const allData=[ "inventoryId": 21 } ] - const { Option } = Select; + */ + +const { Option } = Select; const CreateTradingApplication=()=>{ const [productVOList, setProductVOList] = useState([]); + const [allData,setAllData]=useState([]); const [userIc, setUserIc] = useState(null); const [orderBuyer, setOrderBuyer] = useState(null); + const [isModalVisible, setIsModalVisible] = useState(false); useEffect(() => { axios({ @@ -89,34 +91,38 @@ const CreateTradingApplication=()=>{ params:{ token:localStorage.getItem('token'), } - }) - .then(response=> { - console.log(response); - }) - .catch(function (error) { - console.log(error.config); - }); - axios({ + }) + .then(response=> { + + setUserIc(response.data.data.userIC); + return axios({ method: 'post', url: '/user/userhome/manage/trading/inventory', //headers: {'Authorization': localStorage.getItem('token')}, params:{ - user_ic:userIc, + user_ic:response.data.data.userIC, } - }) - .then(response=> { - console.log(response); + }) + .then(response=> { + console.log(response.data.data.items); + setAllData(response.data.data.items); + }) + .catch(function (error) { + console.log(error.config); + }); }) .catch(function (error) { - console.log(error.config); + console.log(error.config); }); - },[]); + + + },[]); const addGoodsItem = () => { setProductVOList([ ...productVOList, - { inventoryNum: null, inventoryId: null, inventoryProductName: null, inventoryPosition:null, inventoryRepository:null, inventoryOwner:"ICb4e2ad2c" }, + { inventoryNum: null, inventoryProduct: null, inventoryProductName: null, inventoryOwner:userIc }, ]); }; @@ -147,38 +153,39 @@ const CreateTradingApplication=()=>{ }) .then(response=> { console.log(response); - console.log("1"); + if(response.data.message==="过户申请成功"){ + setIsModalVisible(true); + }else{ + alert(response.data.message); + } }) .catch(function (error) { console.log(error.config); - console.log("2"); }); } const getPosition=(a,b)=>{ - let data=allData.filter(item=>item.inventoryProductName==a&&item.inventoryId==b); + let data=allData.filter(item=>item.inventoryProductName==a&&item.inventoryProduct==b); let position=data[0].inventoryPosition; return position; } const getRepository=(a,b)=>{ - let data=allData.filter(item=>item.inventoryProductName==a&&item.inventoryId==b); + let data=allData.filter(item=>item.inventoryProductName==a&&item.inventoryProduct==b); let repository=data[0].inventoryRepository; return repository; } const getAmount=(a,b)=>{ - let data=allData.filter(item=>item.inventoryProductName==a&&item.inventoryId==b); + let data=allData.filter(item=>item.inventoryProductName==a&&item.inventoryProduct==b); let amount=data[0].inventoryNum; return amount; } return(
- - -
+ {/**


@@ -192,7 +199,9 @@ const CreateTradingApplication=()=>{
-
+
*/} + +

@@ -218,15 +227,13 @@ const CreateTradingApplication=()=>{ } }} value={item.inventoryProductName!=null? - item.inventoryProductName+"--"+item.inventoryId+"--"+item.inventoryPosition+"号库"+item.inventoryRepository+"位" + item.inventoryProductName+"--"+item.inventoryProduct+"--"+getPosition(item.inventoryProductName,item.inventoryProduct)+"号库"+getRepository(item.inventoryProductName,item.inventoryProduct)+"位" :"名称--货物编号--仓库"} onSelect={(value,key) => { console.log(value,key); let newList = [...productVOList]; newList[index].inventoryProductName = key.title; - newList[index].inventoryId = key.key; - newList[index].inventoryPosition = getPosition(key.title,key.key) - newList[index].inventoryRepository = getRepository(key.title,key.key); + newList[index].inventoryProduct = key.value; setProductVOList([...newList]); }} defaultActiveFirstOption={false} @@ -238,8 +245,8 @@ const CreateTradingApplication=()=>{ > {allData?.map((item) => { return ( - ); })} @@ -257,7 +264,7 @@ const CreateTradingApplication=()=>{ placeholder="请输入货物数量" /> {index !== 0 && ( @@ -292,6 +299,15 @@ const CreateTradingApplication=()=>{



+ + 确定 +
+ + ]}> +

您已提交申请,即将返回主界面。

+
) } diff --git a/src/userComponents/userMessageCenter/MessageCenter.js b/src/userComponents/userMessageCenter/MessageCenter.js index 26686c8..b354fad 100644 --- a/src/userComponents/userMessageCenter/MessageCenter.js +++ b/src/userComponents/userMessageCenter/MessageCenter.js @@ -1,9 +1,209 @@ -import React from 'react'; +import React, { useState, useEffect, forwardRef } from 'react'; import ReactDOM from 'react-dom/client'; -import { Navigate, Route, Routes } from "react-router-dom"; +import { Navigate, Route, Routes, Router } from "react-router-dom"; import Logo from "../../img/logo1.png"; import { UserHelpSidebar, MessageList } from "../index"; +import axios from 'axios'; +import { Modal} from 'antd'; +import { EventSourcePolyfill } from 'event-source-polyfill'; + + + +const MessageCenter=forwardRef((props, ref)=>{ + const [userIc,setUserIc]=useState(null); + //const [isok,setIsok]=useState(true); + useEffect(() => { + //console.log(evtSource.readyState); + axios({ + method: 'get', + url: '/passport/userinfo', + //headers: {'Authorization': localStorage.getItem('token')}, + params:{ + token:localStorage.getItem('token'), + } + }) + .then(response=> { + setUserIc(response.data.data.userIC); + return axios({ + method: 'get', + url: '/sse/getMessage', + //headers: {'Authorization': localStorage.getItem('token')}, + params:{ + //token:localStorage.getItem('token'), + userIC:response.data.data.userIC, + } + }) + .then(response=> { + console.log(response); + }) + .catch(function (error) { + console.log(error.config); + }); + }) + .catch(function (error) { + console.log(error.config); + }); + + + },[]); + + + + const evtSource = new EventSourcePolyfill('http://10.133.128.40:8088/sse/connect/'+userIc, { + headers: { + token:localStorage.getItem('token'), + } + }); + + //var evtSource=new EventSource('http://localhost/sse/connect'+userIc); + + if(props.isok){ + evtSource.onopen = function(event){ + console.log("ok"); + }; + + evtSource.addEventListener("msg", function(event){ + console.log(evtSource.readyState); + console.log(props.isok); + var result = document.getElementById("result").innerText; + result +='\n' + " message:" + event.data; + document.getElementById("result").innerText=result; + }) + + evtSource.onerror = function(event) { + console.log("no"); + evtSource.close(); + console.log(evtSource.readyState); + + }; + + } + + + + + + + useEffect(()=>{ + console.log('useEffect=>Index') + return ()=>{ + //setIsok(false); + console.log(evtSource.readyState); + evtSource.close(); + one(); + console.log(evtSource.readyState); + //setIsok(false); + axios({ + method: 'get', + url: '/sse/close/'+userIc, + //headers: {'Authorization': localStorage.getItem('token')}, + + params:{ + token:localStorage.getItem('token'), + } + + }) + .then(response=> { + console.log(response); + }) + .catch(function (error) { + console.log(error.config); + }); + console.log(evtSource.readyState); + + } + },[]) + + const one=()=>{ + console.log('Index页面离开'); + } + + + + const onClick=()=>{ + axios({ + method: 'get', + url: '/sse/getIds', + //headers: {'Authorization': localStorage.getItem('token')}, + params:{ + token:localStorage.getItem('token'), + } + }) + .then(response=> { + console.log(response); + }) + .catch(function (error) { + console.log(error.config); + }); + + axios({ + method: 'post', + url: '/sse/pushOne', + //headers: {'Authorization': localStorage.getItem('token')}, + params:{ + token:localStorage.getItem('token'), + message:"123456", + userIC:userIc, + } + }) + .then(response=> { + console.log(response); + }) + .catch(function (error) { + console.log(error.config); + }); + } + + /* + customConfirm = (message,callback) => { + Modal.confirm({ + title:"确定离开该页面?", + onCancel: () => { + callback(false); + }, + onOk: () => { + evtSource.close(); + callback(true); + } + }) + } +*/ + +// + return( +
+ + +
+
+
+ +
+
+

物流仓储管理系统

+
+
+
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+ ) +}) + +/* class MessageCenter extends React.Component{ render(){ @@ -28,5 +228,6 @@ class MessageCenter extends React.Component{ ) } } +*/ export default MessageCenter; \ No newline at end of file diff --git a/src/userComponents/userMessageCenter/MessageList.js b/src/userComponents/userMessageCenter/MessageList.js index f4f640e..b09f61e 100644 --- a/src/userComponents/userMessageCenter/MessageList.js +++ b/src/userComponents/userMessageCenter/MessageList.js @@ -14,9 +14,8 @@ evtSource.onmessage = function(e) { } */ -function MessageList(){ - - var evtSource=new EventSource('http://localhost:8080/sse/connect/8'); +const MessageList=()=>{ + var evtSource=new EventSource('/sse/connect/8'); evtSource.onopen = function(event){ console.log("ok"); @@ -49,21 +48,43 @@ function MessageList(){ ) } - - /* -class MessageList extends React.Component{ - constructor(props){ - super(props); - } +function MessageList(){ - render(){ - return( -
- ) - } + var evtSource=new EventSource('/sse/connect/8'); + + evtSource.onopen = function(event){ + console.log("ok"); + }; + evtSource.addEventListener("message", function(event){ + + var result = document.getElementById("result").innerText; + result +='\n' + " message:" + event.data; + document.getElementById("result").innerText=result; + }) + + evtSource.onerror = function(event) { + console.log("no"); + }; + + + return( +
+
+ +
+
+
+
+
+ +
+ + ) } */ + + export default MessageList; \ No newline at end of file diff --git a/src/userPages/IntoHomePage.js b/src/userPages/IntoHomePage.js index 5bcf08a..f4cffb0 100644 --- a/src/userPages/IntoHomePage.js +++ b/src/userPages/IntoHomePage.js @@ -11,12 +11,19 @@ const Into=()=> { //const {username}=useParams(); const [userName, setUserName] = useState(null); //console.log(username); - + const [isright,setIsright]=useState(false); + const location=useLocation(); + console.log(location); useEffect(() => { - + if(location.pathname=="/user/userhome/message"){ + setIsright(true); + }else{ + setIsright(false); + } + console.log(isright); //setUserName(username); //console.log(username); - },[]); + }); return ( @@ -30,7 +37,7 @@ const Into=()=> { } />} /> }/> }/> - }/> + } /> -- Gitee