fix(bug)
This commit is contained in:
parent
70815fe9a8
commit
992ce27014
|
@ -139,6 +139,7 @@ const BTable = (props: any) => {
|
|||
formRef={formRef}
|
||||
colProps={25}
|
||||
onFinish={() => {
|
||||
console.log(record)
|
||||
if (!record) {
|
||||
store.add(formRef.current?.getFieldsValue()).then((res) => {
|
||||
if (res) {
|
||||
|
|
|
@ -15,10 +15,15 @@ export const FormCheckBox = (v: FormDatas) => {
|
|||
}
|
||||
}, [v.selectUrl, v.selectList]);
|
||||
return (
|
||||
<Form.Item {...v} key={v.label}>
|
||||
<Form.Item
|
||||
key={v.label}
|
||||
label={v.label}
|
||||
name={v.name}
|
||||
rules={v.rules}
|
||||
>
|
||||
<Checkbox.Group>
|
||||
{list.map((item, index) => {
|
||||
return <Checkbox key={item.identity} value={item.identity}>
|
||||
return <Checkbox key={index} value={item.identity}>
|
||||
{item.data_name}
|
||||
</Checkbox>
|
||||
})}
|
||||
|
|
|
@ -24,7 +24,7 @@ export interface FormDatas {
|
|||
name: string,
|
||||
value: any,
|
||||
selectUrl?: string,
|
||||
key?: string,
|
||||
keys?: string,
|
||||
treeCheckbox:boolean,
|
||||
selectList?: Array<selectItem>
|
||||
checkboxData?: Array<any>,
|
||||
|
|
|
@ -15,14 +15,17 @@ export const FormSelect = (v: FormDatas) => {
|
|||
}
|
||||
}, [v.selectUrl, v.selectList]);
|
||||
return (
|
||||
<Form.Item key={v.label} label={v.label} name={v.name} rules={v.rules}>
|
||||
<Form.Item
|
||||
key={v.label}
|
||||
label={v.label}
|
||||
name={v.name}
|
||||
rules={v.rules}
|
||||
>
|
||||
<Select placeholder="">
|
||||
{list?.map((item: any) => {
|
||||
return (
|
||||
<Option key={item.id} value={item.id}>
|
||||
{item[v.key ?? "name"]}
|
||||
{list?.map((item: any, index) => {
|
||||
return <Option key={index} value={item.identity}>
|
||||
{item[v.keys ?? "name"]}
|
||||
</Option>
|
||||
);
|
||||
})}
|
||||
</Select>
|
||||
</Form.Item>
|
||||
|
|
|
@ -69,9 +69,9 @@ const SimpleForm = (props: SimpleFormData) => {
|
|||
</Form.Item>
|
||||
);
|
||||
case FormType.cehckbox:
|
||||
return FormCheckBox(v)
|
||||
return <FormCheckBox {...v} />
|
||||
case FormType.treeSelect:
|
||||
return FormTreeSelect(v);
|
||||
return <FormTreeSelect {...v} key={v.label} />
|
||||
case FormType.cehckboxGroup:
|
||||
return (
|
||||
<Form.Item
|
||||
|
@ -90,10 +90,11 @@ const SimpleForm = (props: SimpleFormData) => {
|
|||
);
|
||||
|
||||
case FormType.select:
|
||||
return FormSelect(v);
|
||||
return <FormSelect {...v} />
|
||||
case FormType.upload:
|
||||
return (
|
||||
<Form.Item
|
||||
{...v}
|
||||
key={v.label}
|
||||
label={v.label}
|
||||
valuePropName="fileList"
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
import { Form } from "antd";
|
||||
import { FormDatas } from "./interface";
|
||||
import { useEffect, useState } from "react";
|
||||
import { base } from "@/service/base";
|
||||
import { TreeSelect } from 'antd';
|
||||
import { Form, TreeSelect } from 'antd';
|
||||
|
||||
export const FormTreeSelect = (v: FormDatas) => {
|
||||
const [list, setList] = useState<any>([]);
|
||||
|
@ -16,7 +15,12 @@ export const FormTreeSelect = (v: FormDatas) => {
|
|||
}
|
||||
}, [v.selectUrl, v.selectList]);
|
||||
return (
|
||||
<Form.Item {...v}>
|
||||
<Form.Item
|
||||
key={v.label}
|
||||
label={v.label}
|
||||
name={v.name}
|
||||
rules={v.rules}
|
||||
>
|
||||
<TreeSelect
|
||||
key={v.name}
|
||||
fieldNames={{
|
||||
|
|
|
@ -45,7 +45,7 @@ export const defaultConfig = [
|
|||
name: "p_id",
|
||||
value: 0,
|
||||
selectUrl: CompanyConfig.LIST,
|
||||
key: "name",
|
||||
keys: "name",
|
||||
rules: [],
|
||||
},
|
||||
];
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
import { Space } from "antd";
|
||||
import { inject, observer } from "mobx-react";
|
||||
import { Store } from "antd/lib/form/interface";
|
||||
import React from "react";
|
||||
import React, { useEffect } from "react";
|
||||
import "./index.less";
|
||||
import ReactECharts from 'echarts-for-react';
|
||||
const Dashbord = (props: Store) => {
|
||||
const { usrStore } = props;
|
||||
useEffect(() => {
|
||||
usrStore.getMenu()
|
||||
}, [])
|
||||
const options = {
|
||||
grid: { top: 8, right: 8, bottom: 24, left: 36 },
|
||||
xAxis: {
|
||||
|
|
|
@ -43,8 +43,8 @@ export const defaultConfig = [
|
|||
label: "上级部门",
|
||||
name: "p_id",
|
||||
value: 0,
|
||||
selectUrl:DepConfig.LIST,
|
||||
key:"dep_name",
|
||||
selectUrl: DepConfig.LIST,
|
||||
keys: "dep_name",
|
||||
rules: [],
|
||||
},
|
||||
{
|
||||
|
@ -52,8 +52,8 @@ export const defaultConfig = [
|
|||
label: "所属企业",
|
||||
name: "company_id",
|
||||
value: 0,
|
||||
selectUrl:CompanyConfig.LIST,
|
||||
key:"name",
|
||||
selectUrl: CompanyConfig.LIST,
|
||||
keys: "name",
|
||||
rules: [],
|
||||
},
|
||||
];
|
||||
|
|
|
@ -38,7 +38,7 @@ export const defaultConfig = [
|
|||
name: "p_id",
|
||||
value: "",
|
||||
selectUrl:MenuConfig.LIST,
|
||||
key:"name",
|
||||
keys:"name",
|
||||
rules: [],
|
||||
},
|
||||
{
|
||||
|
|
|
@ -23,9 +23,9 @@ export const defaultConfig = [
|
|||
{
|
||||
type: FormType.select,
|
||||
label: "所属部门",
|
||||
name: "dep_id",
|
||||
name: "dep_identity",
|
||||
selectUrl: DepConfig.LIST,
|
||||
key: "dep_name",
|
||||
keys: "dep_name",
|
||||
value: "",
|
||||
rules: [{ required: true, message: "所属部门不能为空" }],
|
||||
},
|
||||
|
|
|
@ -25,15 +25,7 @@ const Source = (props: Store) => {
|
|||
const [selectKey, setSelectKey] = useState<Array<string>>([
|
||||
"01JM4XMY2N9KN23XSZJSQQM3HY",
|
||||
"01JM4XMY2N9KN23XSZJSWQHHKA",
|
||||
"01JM4XMY2N9KN23XSZJW02PRCF",
|
||||
"01JM4XMY2N9KN23XSZJYCKT6XQ",
|
||||
"01JM4XMY2N9KN23XSZK0AJ6QEZ",
|
||||
"01JM4XMY2N9KN23XSZK10KM59Y",
|
||||
"01JM4XMY2N9KN23XSZK479Y59M",
|
||||
"01JM4XMY2N9KN23XSZK5F8Z2J8",
|
||||
"01JM4XMY2N9KN23XSZK6W7Q25F",
|
||||
"01JM4XMY2N9KN23XSZK7ET1GEB",
|
||||
"01JM4XMY2N9KN23XSZK9DNRCZZ",
|
||||
|
||||
]);
|
||||
const [page, setPage] = useState<number>(1);
|
||||
const [editingKey, setEditingKey] = useState("");
|
||||
|
|
|
@ -3,6 +3,7 @@ import { UserDataType } from "@/model/userModel";
|
|||
import { ColumnsType } from "antd/lib/table";
|
||||
import { Image } from "antd";
|
||||
import { getBirthDateAndGender } from "@/util/util";
|
||||
import { CompanyConfig, DepConfig, RoleConfig } from "@/service/user_config";
|
||||
export const defaultConfig = [
|
||||
{
|
||||
type: FormType.input,
|
||||
|
@ -37,12 +38,40 @@ export const defaultConfig = [
|
|||
name: "email",
|
||||
value: "",
|
||||
},
|
||||
{
|
||||
type: FormType.select,
|
||||
label: "所属部门",
|
||||
name: "dep_identity",
|
||||
selectUrl: DepConfig.LIST,
|
||||
keys: "dep_name",
|
||||
value: "",
|
||||
rules: [{ required: true, message: "所属部门不能为空" }],
|
||||
},
|
||||
{
|
||||
type: FormType.treeSelect,
|
||||
label: "所属单位",
|
||||
name: "company_identity",
|
||||
treeCheckbox: false,
|
||||
selectUrl: CompanyConfig.LIST,
|
||||
value: "",
|
||||
keys: "company_id",
|
||||
rules: [{ required: true, message: "所属单位不能为空" }],
|
||||
},
|
||||
{
|
||||
type: FormType.select,
|
||||
label: "角色",
|
||||
name: "role_identity",
|
||||
selectUrl: RoleConfig.LIST,
|
||||
value: "",
|
||||
rules: [{ required: true, message: "角色不能为空" }],
|
||||
},
|
||||
{
|
||||
type: FormType.upload,
|
||||
label: "头像",
|
||||
name: "head_img",
|
||||
value: [],
|
||||
},
|
||||
|
||||
];
|
||||
|
||||
export const columns: ColumnsType<UserDataType> = [
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import store from "@/store";
|
||||
import Config from "@/util/config";
|
||||
import axios, { AxiosResponse } from "axios";
|
||||
// import { baseHttp } from '@/service/base';
|
||||
// 添加请求拦截器
|
||||
axios.defaults.headers.common["Content-Type"] = "application/json; charset=utf8";
|
||||
axios.defaults.headers.common["X-Requested-With"] = "XMLHttpRequest";
|
||||
|
@ -33,18 +32,6 @@ axios.interceptors.response.use((res: AxiosResponse) => {
|
|||
return Promise.reject(err);
|
||||
});
|
||||
class BaseHttps {
|
||||
async gets(url: string, params: any) {
|
||||
let res = await axios({
|
||||
method: 'get',
|
||||
url: url,
|
||||
headers: {
|
||||
"token": window.localStorage.getItem("video-token"),
|
||||
'Content-Type': 'application/json; charset=utf-8'
|
||||
},
|
||||
params
|
||||
});
|
||||
return res.data;
|
||||
};
|
||||
async get(url: string, params: any) {
|
||||
let res = await axios({
|
||||
method: 'get',
|
||||
|
@ -62,14 +49,6 @@ class BaseHttps {
|
|||
return res.data;
|
||||
};
|
||||
|
||||
async forms(url: string, params: any) {
|
||||
let res = await axios({
|
||||
method: 'post',
|
||||
url: url,
|
||||
params: params
|
||||
});
|
||||
return res.data;
|
||||
};
|
||||
async upload(url: string, params: any) {
|
||||
let res = await axios({
|
||||
headers: {
|
||||
|
|
|
@ -4,6 +4,7 @@ class UserConfig {
|
|||
static EDIT: string = "/user";
|
||||
static LIST: string = "/user/list";
|
||||
static DELETE: string = "/user";
|
||||
static menu: string = "/user/menu";
|
||||
}
|
||||
|
||||
class RoleConfig {
|
||||
|
|
|
@ -9,17 +9,20 @@ class UserStore extends BaseStore<UserDataType> {
|
|||
_userinfo: UserInfos = {}; // 用户信息
|
||||
userDetail = {}
|
||||
isNeedLogin: boolean = false; // 是否需要登录
|
||||
menu = []
|
||||
|
||||
constructor() {
|
||||
super(UserConfig)
|
||||
makeObservable(this, {
|
||||
logOut: action,
|
||||
login: action,
|
||||
getMenu: action,
|
||||
_userinfo: observable,
|
||||
isNeedLogin: observable,
|
||||
userDetail: observable,
|
||||
openLoginDilog: action,
|
||||
userInfo: computed,
|
||||
menu: observable,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -48,8 +51,8 @@ class UserStore extends BaseStore<UserDataType> {
|
|||
message.error(data.msg)
|
||||
return false
|
||||
}
|
||||
console.log(data.data.token)
|
||||
window.localStorage.setItem("token", data.data.token ?? "");
|
||||
this.getMenu()
|
||||
return true
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
|
@ -67,6 +70,10 @@ class UserStore extends BaseStore<UserDataType> {
|
|||
setUserDetaul(data) {
|
||||
this.userDetail = data
|
||||
}
|
||||
async getMenu() {
|
||||
let data = await base.get(UserConfig.menu, {})
|
||||
console.log(data)
|
||||
}
|
||||
}
|
||||
const userStore = new UserStore();
|
||||
export default userStore;
|
Loading…
Reference in New Issue