搭建框架
parent
c2fee2b3f9
commit
8e40919f18
@ -1,12 +0,0 @@
|
||||
const path = require('path')
|
||||
const { override, addDecoratorsLegacy } = require('customize-cra')
|
||||
|
||||
function resolve(dir) {
|
||||
return path.join(__dirname, dir)
|
||||
}
|
||||
|
||||
const customize = () => (config, env) => {
|
||||
config.resolve.alias['@'] = resolve('src')
|
||||
return config
|
||||
};
|
||||
module.exports = override(addDecoratorsLegacy(), customize())
|
@ -1,3 +0,0 @@
|
||||
# 默认忽略的文件
|
||||
/shelf/
|
||||
/workspace.xml
|
@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
@ -1,6 +0,0 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<settings>
|
||||
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||
<version value="1.0" />
|
||||
</settings>
|
||||
</component>
|
@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9" project-jdk-type="Python SDK" />
|
||||
</project>
|
@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/fastapi.iml" filepath="$PROJECT_DIR$/.idea/fastapi.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
@ -1,19 +0,0 @@
|
||||
import pymssql
|
||||
from fastapi import FastAPI
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
||||
@app.get('/')
|
||||
def index():
|
||||
return {'message': '你已经正确创建 FastApi 服务!'}
|
||||
|
||||
|
||||
@app.get("/orderinfo-frontend/{data}")
|
||||
async def say(data: str, q: int = None):
|
||||
return {"data": data, "q": q}
|
||||
|
||||
|
||||
# 按间距中的绿色按钮以运行脚本。
|
||||
if __name__ == '__main__':
|
||||
print(f'Hi world')
|
@ -1 +0,0 @@
|
||||
uvicorn main:app --port 8000 --reload
|
File diff suppressed because it is too large
Load Diff
@ -1,2 +1,6 @@
|
||||
import React from "react";
|
||||
|
||||
export const stores_Context = React.createContext();
|
||||
export const DATE_FORMAT = 'YYYY-MM-DD';
|
||||
export const HT_HOST = 'https://p9axztuwd7x8a7.mycht.cn';
|
||||
//export const HT_HOST = 'https://p9axztuwd7x8a7.mycht.cn';
|
||||
export const HT_HOST = 'http://202.103.68.100:890';
|
@ -1,13 +1,14 @@
|
||||
import {observable, action} from 'mobx';
|
||||
import {makeAutoObservable} from "mobx";
|
||||
|
||||
|
||||
class DashboardStore {
|
||||
|
||||
constructor(app) {
|
||||
this.app = app;
|
||||
constructor() {
|
||||
makeAutoObservable(this);
|
||||
}
|
||||
|
||||
@observable countryList;
|
||||
}
|
||||
|
||||
export default DashboardStore;
|
||||
|
||||
export default DashboardStore;
|
||||
|
||||
|
@ -1,22 +1,20 @@
|
||||
import React from "react";
|
||||
import {observable, action} from 'mobx';
|
||||
import DashboardStore from "./DashboardStore";
|
||||
import {makeAutoObservable} from "mobx"
|
||||
import OrdersStore from "./OrdersStore";
|
||||
import DashboardStore from "./DashboardStore";
|
||||
import moment from "moment";
|
||||
|
||||
class Index {
|
||||
constructor(history) {
|
||||
this.history = history;
|
||||
this.pathname = history.location.pathname;
|
||||
this.dashboard_store = new DashboardStore();
|
||||
this.orders_store = new OrdersStore();
|
||||
constructor() {
|
||||
this.dashboard_store = new DashboardStore(this);
|
||||
this.orders_store = new OrdersStore(this);
|
||||
makeAutoObservable(this)
|
||||
}
|
||||
|
||||
@action goBack() {
|
||||
goBack() {
|
||||
this.history.goBack();
|
||||
}
|
||||
|
||||
@observable animating = false;
|
||||
|
||||
animating = false;
|
||||
}
|
||||
|
||||
export default Index;
|
@ -1,9 +1,44 @@
|
||||
import {observable, action} from 'mobx';
|
||||
import {makeAutoObservable} from "mobx"
|
||||
import * as config from "../config";
|
||||
import moment from "moment";
|
||||
|
||||
|
||||
class OrdersStore {
|
||||
|
||||
@observable countryList;
|
||||
constructor(rootStore) {
|
||||
this.rootStore = rootStore;
|
||||
makeAutoObservable(this);
|
||||
}
|
||||
|
||||
startdate = moment().subtract(7, 'days');//上周一
|
||||
enddate = moment().subtract(0, 'days');//上周日
|
||||
webcode = 'CHT';
|
||||
orderCountData = [];//订单统计数据源
|
||||
loading=false;
|
||||
|
||||
handleChange_webcode = (value) => {
|
||||
this.webcode = value;
|
||||
};
|
||||
|
||||
onChange_dataPicker = (dates) => {
|
||||
this.startdate = dates[0];
|
||||
this.enddate = dates[1];
|
||||
}
|
||||
|
||||
getOrderCount() {
|
||||
let url = '/service-web/QueryData/GetOrderCount'//?WebCode=cht&COLI_ApplyDate1=2022-08-01&COLI_ApplyDate2=2022-08-31&COLI_ApplyDateold1=2021-08-01&COLI_ApplyDateold2=2021-08-31';
|
||||
url += '?WebCode=' + this.webcode + '&COLI_ApplyDate1=' + this.startdate.format(config.DATE_FORMAT) + '&COLI_ApplyDate2=' + this.enddate.format(config.DATE_FORMAT) + '%2023:59';
|
||||
fetch(config.HT_HOST + url)
|
||||
.then((response) => response.json())
|
||||
.then((json) => {
|
||||
this.orderCountData = json;
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log('fetch data failed', error);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
export default OrdersStore;
|
@ -1,19 +1,23 @@
|
||||
import React, {Component} from 'react';
|
||||
import { observer } from 'mobx-react';
|
||||
import {stores_Context} from '../config'
|
||||
|
||||
class Home extends Component {
|
||||
static contextType = stores_Context;
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
render() {
|
||||
const {orders_store} = this.context;
|
||||
|
||||
return (
|
||||
<div>
|
||||
这就是一个主页
|
||||
这就是一个主页{orders_store.webcode}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default Home;
|
||||
export default observer(Home);
|
||||
|
@ -1,19 +1,72 @@
|
||||
import React, {Component} from 'react';
|
||||
import {Layout, Menu, Image, Row, Col, DatePicker, Space, Button} from 'antd';
|
||||
import {BrowserRouter, Route, Routes, NavLink} from "react-router-dom"
|
||||
import {
|
||||
HomeOutlined,
|
||||
TeamOutlined,
|
||||
DashboardOutlined,
|
||||
SearchOutlined,
|
||||
} from '@ant-design/icons';
|
||||
import {stores_Context} from '../config'
|
||||
import {Line} from "@ant-design/charts";
|
||||
import SiteSelect from "../charts/SiteSelect";
|
||||
import {observer} from 'mobx-react';
|
||||
|
||||
class Orders extends Component {
|
||||
|
||||
static contextType = stores_Context;
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
}
|
||||
|
||||
|
||||
render() {
|
||||
const {orders_store} = this.context;
|
||||
const data_source = orders_store.orderCountData.ordercount1 ? orders_store.orderCountData.ordercount1 : [];
|
||||
const config = {
|
||||
data: data_source,
|
||||
padding: 'auto',
|
||||
xField: 'ApplyDate',
|
||||
yField: 'orderCount',
|
||||
seriesField: 'WebCode',
|
||||
xAxis: {
|
||||
type: 'timeCat',
|
||||
},
|
||||
smooth: true,
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
Orders
|
||||
<Row>
|
||||
<Col span={12}></Col>
|
||||
<Col span={2}><SiteSelect/></Col>
|
||||
<Col span={6}>
|
||||
<DatePicker.RangePicker format={config.DATE_FORMAT}
|
||||
defaultValue={[orders_store.startdate, orders_store.enddate]}
|
||||
onChange={orders_store.onChange_dataPicker}/>
|
||||
</Col>
|
||||
<Col span={4}>
|
||||
<Button type="primary" icon={<SearchOutlined/>} loading={orders_store.loading} onClick={() => {
|
||||
orders_store.getOrderCount();
|
||||
}}>统计</Button>
|
||||
</Col>
|
||||
</Row>
|
||||
<Row gutter={[16, {xs: 8, sm: 16, md: 24, lg: 32}]}>
|
||||
|
||||
<Col className="gutter-row" span={24}>
|
||||
<Line {...config} />
|
||||
</Col>
|
||||
|
||||
<Col className="gutter-row" span={24}>
|
||||
表格
|
||||
</Col>
|
||||
|
||||
</Row>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default Orders;
|
||||
export default observer(Orders);
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue