diff --git a/src/mock/Login.js b/src/mock/Login.js index 299b4410e48efa168ca9b2a711b9563e3b559859..a24668347fa948f08a1a082530c395979a552464 100644 --- a/src/mock/Login.js +++ b/src/mock/Login.js @@ -8,11 +8,11 @@ if (localStorage.getItem("user_info")) { } else { // 生成数据 data = Mock.mock({ - "list|1": [ + "list|2": [ { "id": '@increment()', - // 'phone|13000000000-19000000000': 1, - phone: 'admin', + 'phone|13000000000-19000000000': 1, + // phone: 'admin', name: '@name', pass: 123456, roles: [] @@ -34,7 +34,13 @@ Mock.mock('/api/user/login', "post", (req) => { var { phone, pass } = JSON.parse(req.body); console.log(phone, pass); if (phone != undefined && pass != undefined) { - if (data.list.pass == pass) { + console.log("data.list", data.list); + let index = data.list.findIndex((item) => { + return item.phone == phone + }) + console.log(index); + if (data.list[index].pass == pass) { + tokendata = Mock.mock({ 'tokenarr': [ { @@ -42,29 +48,29 @@ Mock.mock('/api/user/login', "post", (req) => { } ] }) - return { code: 200, msg: "登录成功", token: tokendata.tokenarr[0].token, name: data.list.name }; + return { code: 200, msg: "登录成功", token: tokendata.tokenarr[0].token }; + + } else { return { code: 500, msg: "用户名或密码错误" }; } + } else { - return { code: 500, msg: "用户名或密码错误" }; + return { code: 500, msg: "用户名或密码没有输入" }; } }); // 添加管理员 Mock.mock('/api/user/add', "post", (req) => { - var { phone, pass } = JSON.parse(req.body); + var { phone, pass, name } = JSON.parse(req.body); var index = data.list.findIndex((item) => { return item.phone == phone; }); if (index == -1) { - data.list.unshift({ id: data.list.length + 1, phone, pass, }); + data.list.unshift({ id: data.list.length + 1, phone, pass, name }); localStorage.setItem("user_info", JSON.stringify(data)); - phone = ""; - pass = ""; - return { code: 200, msg: "注册成功", list: data.list }; - } else { - return { code: 500, msg: "该账号已被注册", list: data.list }; + + return { code: 200, msg: "添加成功", list: data.list }; } }) diff --git a/src/views/SystemSettings/RoleManagement/AddMan.tsx b/src/views/SystemSettings/RoleManagement/AddMan.tsx index 8960b79c3cf9db83f438c22ea1fcf02b13bec5d7..85d4b6a81ee4d6f1affcb9e76446ae4bcdd007da 100644 --- a/src/views/SystemSettings/RoleManagement/AddMan.tsx +++ b/src/views/SystemSettings/RoleManagement/AddMan.tsx @@ -17,7 +17,7 @@ interface Props { const PubText: React.FC = () => { const [form] = Form.useForm() const push = useNavigate() - const [data, setData] = useState([]) + const [data, setData] = useState() //接受路由跳转传递过来的值search var [params, setParams] = useSearchParams() var val = params.get('data') @@ -55,9 +55,9 @@ const PubText: React.FC = () => { onFinish={onFinish} style={{ maxWidth: 600, paddingTop: 20 }} > - + {/* - + */} diff --git a/src/views/SystemSettings/RoleManagement/ManTable.tsx b/src/views/SystemSettings/RoleManagement/ManTable.tsx index 4f6c9411e0ea9cd83630d4f617ab9addd2d6da31..73d608ad674713903064260b67fcc7dbd1b4ba95 100644 --- a/src/views/SystemSettings/RoleManagement/ManTable.tsx +++ b/src/views/SystemSettings/RoleManagement/ManTable.tsx @@ -22,11 +22,8 @@ const ManTable: React.FC = () => { // 将获取写在外面方便后面调用 const manlist = () => { User_list().then((res) => { - console.log(res.data) - var arr: any = [] - arr.push(res.data.list) - console.log(arr); - setData(arr) + console.log(res.data.list); + setData(res.data.list) }) // var list = JSON.parse(localStorage.getItem('user_info')!) } @@ -42,6 +39,11 @@ const ManTable: React.FC = () => { if (value) { User_search({ id: value }).then((res) => { + // console.log(res.data) + // var arrsearch: any = [] + // arrsearch.push() + console.log(res.data.list); + setData(res.data.list) }) } else { @@ -90,11 +92,11 @@ const ManTable: React.FC = () => { dataIndex: 'phone', key: 'phone', }, - { - title: '角色', - dataIndex: 'roles', - key: 'roles', - }, + // { + // title: '角色', + // dataIndex: 'roles', + // key: 'roles', + // }, { title: '操作', key: 'action',