fix(im)
This commit is contained in:
parent
4d38b3122b
commit
49e55b1e99
|
@ -79,6 +79,7 @@ export const items: ItemType<MenuItemType>[] = [
|
|||
{ label: `版本管理`, key: "/sys/version" },
|
||||
{ label: `捐赠管理`, key: "/sys/don" },
|
||||
{ label: `通告管理`, key: "/sys/notic" },
|
||||
{ label: `App管理`, key: "/sys/app" },
|
||||
],
|
||||
},
|
||||
];
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
import { FormType } from "@/components/form/interface";
|
||||
import { UserDataType } from "@/model/userModel";
|
||||
import { ColumnsType } from "antd/lib/table";
|
||||
import { Image, Tag } from "antd";
|
||||
export const defaultConfig = [
|
||||
{
|
||||
type: FormType.input,
|
||||
label: "文章标题",
|
||||
name: "title",
|
||||
value: "",
|
||||
rules: [{ required: true, message: "请输入文章标题!" }],
|
||||
},
|
||||
{
|
||||
type: FormType.textarea,
|
||||
label: "内容",
|
||||
name: "content",
|
||||
value: "",
|
||||
rules: [{ required: true, message: "请输入内容" }],
|
||||
},
|
||||
{
|
||||
type: FormType.upload,
|
||||
label: "图片介绍",
|
||||
name: "cover",
|
||||
rules: [{ required: true, message: "请上传照片" }],
|
||||
value: [],
|
||||
},
|
||||
];
|
||||
|
||||
export const columns: ColumnsType<UserDataType> = [
|
||||
{
|
||||
title: "标题",
|
||||
dataIndex: "title",
|
||||
fixed: "left",
|
||||
width:200,
|
||||
},
|
||||
{
|
||||
title: "图片介绍",
|
||||
dataIndex: "cover",
|
||||
width: 150,
|
||||
render: (cover) => {
|
||||
return <Image src={cover}></Image>;
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "内容",
|
||||
dataIndex: "content",
|
||||
width:400,
|
||||
},
|
||||
{
|
||||
title: "文章类型",
|
||||
dataIndex: "artic_type",
|
||||
render: (artic_type) => {
|
||||
return <Tag color={artic_type === 1 ? "green" : "red"}>{artic_type === 1 ? "三农" : "建议"}</Tag>;
|
||||
},
|
||||
},
|
||||
];
|
|
@ -1,8 +1,105 @@
|
|||
const Setting = ()=>{
|
||||
import BTable from "@/components/b_table";
|
||||
import SimpleForm from "@/components/form/simple_form";
|
||||
import { Button, Form, FormInstance, Modal, Select, Space } from "antd";
|
||||
import { Store } from "antd/es/form/interface";
|
||||
import { inject, observer } from "mobx-react";
|
||||
import React from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
import { columns, defaultConfig } from "./artic_config";
|
||||
const { Option } = Select;
|
||||
|
||||
const Artic = (props: Store) => {
|
||||
const { articStore } = props;
|
||||
const [isModalOpen, setIsModalOpen] = useState<boolean>(false);
|
||||
const formRef = React.useRef<FormInstance>(null);
|
||||
const [userId, setId] = useState<Number | null>(null);
|
||||
const [record, setRecord] = useState<any>(null);
|
||||
useEffect(() => {
|
||||
articStore.getlist({});
|
||||
}, [articStore]);
|
||||
return (
|
||||
<div>
|
||||
Setting
|
||||
<div className="contentBox">
|
||||
<Space direction="vertical" size="middle" style={{ display: "flex" }}>
|
||||
<Button type="default" onClick={() => setIsModalOpen(true)}>
|
||||
添加文章
|
||||
</Button>
|
||||
<BTable
|
||||
store={articStore}
|
||||
scroll={{ x: "max-content" }}
|
||||
columns={columns}
|
||||
dataSource={articStore.list}
|
||||
editCallback={(record) => {
|
||||
let obj = {
|
||||
...record,
|
||||
cover: [{ url: record.cover }],
|
||||
};
|
||||
setIsModalOpen(true);
|
||||
formRef.current?.setFieldsValue(obj);
|
||||
setRecord(obj);
|
||||
setId(obj.identity);
|
||||
}}
|
||||
/>
|
||||
|
||||
<Modal
|
||||
title={!userId ? "添加文章" : "编辑文章"}
|
||||
width={800}
|
||||
open={isModalOpen}
|
||||
afterClose={() => formRef.current?.resetFields()}
|
||||
onOk={() => formRef.current?.submit()}
|
||||
okText="确定"
|
||||
cancelText="取消"
|
||||
onCancel={() => {
|
||||
setId(null);
|
||||
setRecord(null);
|
||||
setIsModalOpen(false);
|
||||
}}
|
||||
>
|
||||
<SimpleForm
|
||||
formName={"user_form"}
|
||||
formRef={formRef}
|
||||
colProps={25}
|
||||
onFinish={() => {
|
||||
let data = formRef.current?.getFieldsValue();
|
||||
let obj = {
|
||||
...data,
|
||||
cover: data.cover[0].url,
|
||||
};
|
||||
if (userId) {
|
||||
articStore.putItem(userId, obj);
|
||||
} else {
|
||||
articStore.add(obj);
|
||||
}
|
||||
setIsModalOpen(false);
|
||||
}}
|
||||
createCallback={() => {
|
||||
formRef.current?.setFieldsValue(record);
|
||||
}}
|
||||
formDatas={defaultConfig as any}
|
||||
childrenPosi={true}
|
||||
>
|
||||
<Form.Item
|
||||
label="文章类型"
|
||||
name={"artic_type"}
|
||||
rules={[{ required: true, message: "规格" }]}
|
||||
>
|
||||
<Select placeholder="" style={{ width: "100px" }}>
|
||||
{[
|
||||
{ name: "三农", id: 1 },
|
||||
{ name: "建议", id: 2 },
|
||||
].map((v: any) => {
|
||||
return (
|
||||
<Option key={v.id} value={v.id}>
|
||||
{v.name}
|
||||
</Option>
|
||||
);
|
||||
})}
|
||||
</Select>
|
||||
</Form.Item>
|
||||
</SimpleForm>
|
||||
</Modal>
|
||||
</Space>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
export default Setting
|
||||
);
|
||||
};
|
||||
|
||||
export default inject("articStore")(observer(Artic));
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
import AliUpload from "@/components/ali_upload";
|
||||
import { Button } from "antd";
|
||||
import { Store } from "antd/es/form/interface";
|
||||
import { inject, observer } from "mobx-react";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
const Banner = (props: Store) => {
|
||||
const { sysStore } = props;
|
||||
const [files, setFiles] = useState<any[]>([]);
|
||||
useEffect(() => {
|
||||
sysStore.getBanner({ app_position: 1 }).then((_) => {
|
||||
setFiles(sysStore.banner);
|
||||
});
|
||||
}, [sysStore]);
|
||||
const save = () => {
|
||||
let objList: any = [];
|
||||
files.forEach((item, index) => {
|
||||
objList.push({
|
||||
file_name: item.fileName,
|
||||
file_url: item.url,
|
||||
city_identity: "",
|
||||
app_position: 1,
|
||||
});
|
||||
});
|
||||
sysStore.setBanner({ list: objList });
|
||||
};
|
||||
return (
|
||||
<div className="banner">
|
||||
<div className="banner-content">
|
||||
<AliUpload
|
||||
value={files}
|
||||
onChange={(v) => {
|
||||
setFiles(v);
|
||||
}}
|
||||
/>
|
||||
<Button
|
||||
onClick={() => {
|
||||
save();
|
||||
}}
|
||||
>
|
||||
保存
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default inject("sysStore")(observer(Banner));
|
|
@ -0,0 +1,48 @@
|
|||
import AliUpload from "@/components/ali_upload";
|
||||
import { Button } from "antd";
|
||||
import { Store } from "antd/es/form/interface";
|
||||
import { inject, observer } from "mobx-react";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
const HpBanner = (props: Store) => {
|
||||
const { sysStore } = props;
|
||||
const [files, setFiles] = useState<any[]>([]);
|
||||
useEffect(() => {
|
||||
sysStore.getBanner({ app_position: 2 }).then((_) => {
|
||||
setFiles(sysStore.banner);
|
||||
});
|
||||
}, [sysStore]);
|
||||
const save = () => {
|
||||
let objList: any = [];
|
||||
files.forEach((item, index) => {
|
||||
objList.push({
|
||||
file_name: item.fileName,
|
||||
file_url: item.url,
|
||||
city_identity: "",
|
||||
app_position: 2,
|
||||
});
|
||||
});
|
||||
sysStore.setBanner({ list: objList });
|
||||
};
|
||||
return (
|
||||
<div className="banner">
|
||||
<div className="banner-content">
|
||||
<AliUpload
|
||||
value={files}
|
||||
onChange={(v) => {
|
||||
setFiles(v);
|
||||
}}
|
||||
/>
|
||||
<Button
|
||||
onClick={() => {
|
||||
save();
|
||||
}}
|
||||
>
|
||||
保存
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default inject("sysStore")(observer(HpBanner));
|
|
@ -0,0 +1,27 @@
|
|||
import { Tabs } from "antd";
|
||||
import Banner from "./banner";
|
||||
import HpBanner from "./hp_banner";
|
||||
|
||||
const App = () => {
|
||||
return (
|
||||
<>
|
||||
<Tabs
|
||||
defaultActiveKey="1"
|
||||
items={[
|
||||
{
|
||||
key: "home_banner",
|
||||
label: "首页轮播图设置",
|
||||
children: <Banner />
|
||||
},
|
||||
{
|
||||
key: "banner",
|
||||
label: "家乡轮播图设置",
|
||||
children: <HpBanner />
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default App;
|
|
@ -0,0 +1,9 @@
|
|||
const DonRuleSetting = () => {
|
||||
return (
|
||||
<div>
|
||||
捐赠规则设置
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default DonRuleSetting;
|
|
@ -0,0 +1,9 @@
|
|||
const DonSetting = () => {
|
||||
return (
|
||||
<div>
|
||||
捐赠设置
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default DonSetting;
|
|
@ -1,10 +1,27 @@
|
|||
import { Tabs } from "antd";
|
||||
import DonSetting from "./don_setting";
|
||||
import DonRuleSetting from "./don_rule_setting";
|
||||
|
||||
const Don = () => {
|
||||
return (
|
||||
<div>
|
||||
cat
|
||||
</div>
|
||||
<>
|
||||
<Tabs
|
||||
defaultActiveKey="1"
|
||||
items={[
|
||||
{
|
||||
key: "don_setting",
|
||||
label: "捐赠比例",
|
||||
children: <DonSetting />,
|
||||
},
|
||||
{
|
||||
key: "banner",
|
||||
label: "捐赠规则",
|
||||
children: <DonRuleSetting />,
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default Don;
|
||||
};
|
||||
|
||||
export default Don;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const Notic = () => {
|
||||
return (
|
||||
<div>
|
||||
cat
|
||||
通告
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -34,6 +34,14 @@ export const sys = [
|
|||
}),
|
||||
},
|
||||
|
||||
{
|
||||
path: "/sys/app",
|
||||
index: true,
|
||||
lazy: async () => ({
|
||||
Component: (await import("@/pages/sys/app")).default,
|
||||
}),
|
||||
},
|
||||
|
||||
],
|
||||
},
|
||||
];
|
||||
|
|
|
@ -68,6 +68,13 @@ class SpecConfig {
|
|||
static LIST: string = "/skuSpec/list";
|
||||
static DELETE: string = "/skuSpec";
|
||||
}
|
||||
|
||||
class ArticConfig {
|
||||
static ADD: string = "/artic";
|
||||
static EDIT: string = "/artic";
|
||||
static LIST: string = "/artic/list";
|
||||
static DELETE: string = "/artic";
|
||||
}
|
||||
export {
|
||||
UserConfig,
|
||||
CityConfig,
|
||||
|
@ -78,5 +85,6 @@ export {
|
|||
SpecConfig,
|
||||
CityHistoryConfig,
|
||||
CityHumIntroConfig,
|
||||
CityLocalFoodConfig
|
||||
CityLocalFoodConfig ,
|
||||
ArticConfig
|
||||
};
|
|
@ -0,0 +1,14 @@
|
|||
|
||||
import { makeObservable } from "mobx";
|
||||
import BaseStore from "./baseStore";
|
||||
import { UserDataType } from "@/model/userModel";
|
||||
import { ArticConfig } from "@/service/config";
|
||||
|
||||
class ArticStore extends BaseStore<UserDataType> {
|
||||
constructor() {
|
||||
super(ArticConfig)
|
||||
makeObservable(this, {})
|
||||
}
|
||||
}
|
||||
const articStore = new ArticStore();
|
||||
export default articStore;
|
|
@ -30,7 +30,6 @@ class BaseStore<B> implements BaseStoreInterface<B> {
|
|||
add: action,
|
||||
listStatus: observable,
|
||||
})
|
||||
console.log(urlConfig)
|
||||
this.urlConfig = urlConfig;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,8 @@ import tagStore from './tag';
|
|||
import skuStore from './sku';
|
||||
import skuCatStore from './skuCat';
|
||||
import skuSpecStore from './skuSpec';
|
||||
import sysStore from './sysStore';
|
||||
import articStore from './artic';
|
||||
|
||||
const store = {
|
||||
usrStore,
|
||||
|
@ -16,7 +18,9 @@ const store = {
|
|||
skuSpecStore,
|
||||
cityLocalStore,
|
||||
cityhisStore,
|
||||
cityhumStore
|
||||
cityhumStore,
|
||||
sysStore,
|
||||
articStore,
|
||||
};
|
||||
|
||||
export default store;
|
|
@ -0,0 +1,41 @@
|
|||
|
||||
import { action, makeObservable, observable } from "mobx";
|
||||
import { base } from "@/service/base";
|
||||
|
||||
class SysConfig {
|
||||
static Banner: string = "/sys/banner";
|
||||
}
|
||||
class SysStore {
|
||||
banner: any = null;
|
||||
constructor() {
|
||||
makeObservable(this, {
|
||||
getBanner: action,
|
||||
banner:observable,
|
||||
})
|
||||
}
|
||||
|
||||
// 获取轮播图
|
||||
async getBanner(param) {
|
||||
let data = await base.get(SysConfig.Banner, param)
|
||||
if (data.code !== 200) {
|
||||
return false
|
||||
}
|
||||
let list: any = []
|
||||
data.data.record.forEach(element => {
|
||||
list.push({
|
||||
url: element.file_url,
|
||||
file_name: element.file_name,
|
||||
})
|
||||
});
|
||||
this.banner = list;
|
||||
}
|
||||
|
||||
async setBanner(param) {
|
||||
let data = await base.post(SysConfig.Banner, param)
|
||||
if (data.code !== 200) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
const sysStore = new SysStore();
|
||||
export default sysStore;
|
|
@ -1,5 +1,5 @@
|
|||
class Config {
|
||||
static baseUrl = "/v1";
|
||||
static baseUrl1 = "http://127.0.0.1:12215/v1";
|
||||
// static baseUrl1 = "http://127.0.0.1:12215/v1";
|
||||
}
|
||||
export default Config;
|
||||
|
|
Loading…
Reference in New Issue