diff --git a/src/pages/order/cost-of-sales/index.jsx b/src/pages/order/cost-of-sales/index.jsx index 4cc723d..f815970 100644 --- a/src/pages/order/cost-of-sales/index.jsx +++ b/src/pages/order/cost-of-sales/index.jsx @@ -1,6 +1,6 @@ import React, { useState, useEffect } from 'react'; import { PageContainer } from '@ant-design/pro-layout'; -import { Button, Card, DatePicker, Table, Pagination, Spin, Select } from 'antd'; +import { Button, Card, DatePicker, Table, Pagination, Spin, Select, message } from 'antd'; import styles from './index.less'; const { RangePicker } = DatePicker; import costSalesAPI from "./service"; @@ -9,28 +9,28 @@ import moment from 'moment'; const columns = [ { title: '门店名称', - dataIndex: 'storeName', - key: 'storeName', + dataIndex: 'storeId', + key: 'storeId', }, { title: '商品名称', - dataIndex: 'goodsName', - key: 'storeName', + dataIndex: 'goodsId', + key: 'goodsId', }, { title: '销售收入', - dataIndex: 'salesRevenue', - key: 'salesRevenue', + dataIndex: 'salesPrice', + key: 'salesPrice', }, { title: '销售成本', - dataIndex: 'costOfSale', - key: 'costOfSale', + dataIndex: 'costPrice', + key: 'costPrice', }, { title: '销售数量', - dataIndex: 'salesVolumes', - key: 'salesVolumes', + dataIndex: 'salesNum', + key: 'salesNum', }, { title: '成本率', @@ -47,12 +47,6 @@ const LoadingCard = () => { ) } -const children = []; - -for (let i = 10; i < 36; i++) { - children.push(); -} - /** * 销售成本分析 * @returns @@ -60,7 +54,7 @@ for (let i = 10; i < 36; i++) { export default function Index() { //订单报表列表 - const [orderReportList, setOrderReportList] = useState([]); + const [costSalesData, setCostSalesData] = useState([]); const [current, setCurrent] = useState(1); const [pageSize, setPageSize] = useState(10); const [total, setTotal] = useState(0); @@ -69,6 +63,15 @@ export default function Index() { moment(moment(new Date(Date.now() - 24 * 60 * 60 * 1000 * 7)).format('YYYY-MM-DD 00:00:00')), moment(moment(new Date(Date.now())).format('YYYY-MM-DD 23:59:59')), ]); //日期选择器 + //门店 + const [storeIdArray, setStoreIdArray] = useState([]); + const [storeSelect, setStoreSelect] = useState([]); + //商品 + const [goodsIdArray, setGoodsIdArray] = useState([]); + const [goodsIdSelect, setGoodsIdSelect] = useState([]); + //商品类型 + const [goodsTypeArray, setGoodsTypeArray] = useState([]); + const [goodsTypeSelect, setGoodsTypeSelect] = useState([]); //页码变化 const onPageChange = (current, pageSize) => { @@ -77,15 +80,77 @@ export default function Index() { } //查询 - const onQueryOrderReportList = () => { + const onQueryReportSalescost = async () => { + const jsonData = { + "storeId": storeIdArray, + "goodsId": goodsIdArray, + "goodsTypeId": goodsTypeArray, + "begintime": timeRange[0], + "endtime": timeRange[1], + current, + pageSize + } + setShowLoading(true); + const response = await costSalesAPI.getReportSalescost({}); + setShowLoading(false); + if (response.statusCode === 200) { + setCostSalesData(response.data.data); + } else { + message.error(response.errors || '获取销售成本失败'); + } + } + /** + * 查询店铺列表 + */ + const onQueryStoreList = async () => { + setShowLoading(true); + const response = await costSalesAPI.gettree({}); + setShowLoading(false); + if (response.statusCode === 200) { + const storeList = []; + response.data.forEach(item => { + if (item.type === 2 || item.type === 3) { + storeList.push(item) + } + }) + setStoreSelect(storeList); + } else { + message.error('查询店铺列表失败'); + } } - //选择门店 - const handleStoreChange = () => { + //查询商品列表 + const onQueryGoodsList = async () => { + setShowLoading(true); + const response = await costSalesAPI.goodsList({}); + setShowLoading(false); + if (response.statusCode === 200) { + setGoodsIdSelect(response.data); + } else { + message.error('查询商品列表失败'); + } + } + //查询商品分类类型列表 + const onQueryGoodsType = async () => { + setShowLoading(true); + const response = await costSalesAPI.goodsTypeList({}); + setShowLoading(false); + if (response.statusCode === 200) { + setGoodsTypeSelect(response.data); + } else { + message.error('查询商品分类列表失败'); + } } + useEffect(() => { + onQueryReportSalescost(); + onQueryStoreList(); + onQueryGoodsList(); + onQueryGoodsType(); + }, []); + return ( {showLoading ? : null} @@ -98,14 +163,20 @@ export default function Index() { size="middle" allowClear placeholder="请选择门店" - onChange={handleStoreChange} + onChange={(values) => setStoreIdArray(values)} filterOption={(input, option) => option.children.toLowerCase().includes(input.toLowerCase())} style={{ width: '300px', marginRight: '50px' }} > - {children} + { + storeSelect.map( (item) => { + return ( + + ) + }) + } { let tempDate = [ @@ -147,12 +230,12 @@ export default function Index() {
- +
- +
diff --git a/src/pages/order/cost-of-sales/service.js b/src/pages/order/cost-of-sales/service.js index 11107ef..bb2fdb4 100644 --- a/src/pages/order/cost-of-sales/service.js +++ b/src/pages/order/cost-of-sales/service.js @@ -1,10 +1,40 @@ import { request } from 'umi'; export default { - getOrderReportList(data) { - return request(`/kitchen/api/report-statistics/order-report`, { + getReportSalescost(data) { + return request(`/kitchen/api/report/salescost`, { method: 'Post', data: data, }); + }, + /** + * 查询商品信息 + */ + goodsList(data) { + return request(`/kitchen/api/goodes/list`, { + method: 'Post', + data: data, + }); + }, + /** + * 查询商品类型 + */ + goodsTypeList(data) { + return request(`/kitchen/api/goodstype/list`, { + method: 'Post', + data: data, + }); + }, + + /** + * 查询门店列表 + */ + gettree(params) { + return request('​/kitchen/api​/sysOrg​/tree', { + data: { + ...params, + }, + }); } + }; diff --git a/src/pages/order/gross-profit-store-sales/index.jsx b/src/pages/order/gross-profit-store-sales/index.jsx index 6cd88e8..5d5b1f7 100644 --- a/src/pages/order/gross-profit-store-sales/index.jsx +++ b/src/pages/order/gross-profit-store-sales/index.jsx @@ -1,6 +1,6 @@ import React, { useState, useEffect } from 'react'; import { PageContainer } from '@ant-design/pro-layout'; -import { Button, Card, DatePicker, Table, Pagination, Spin, Select } from 'antd'; +import { Button, Card, DatePicker, Table, Pagination, Spin, Select, message } from 'antd'; import styles from './index.less'; const { RangePicker } = DatePicker; import costSalesAPI from "./service"; @@ -9,13 +9,13 @@ import moment from 'moment'; const columns = [ { title: '门店名称', - dataIndex: 'storeName', - key: 'storeName', + dataIndex: 'storeId', + key: 'storeId', }, { title: '毛利率', - dataIndex: 'grossProfitMargin', - key: 'salesRevenue', + dataIndex: 'marginRatio', + key: 'marginRatio', } ]; @@ -27,12 +27,6 @@ const LoadingCard = () => { ) } -const children = []; - -for (let i = 10; i < 36; i++) { - children.push(); -} - /** * 门店销售毛利分析 * @returns @@ -40,7 +34,7 @@ for (let i = 10; i < 36; i++) { export default function Index() { //订单报表列表 - const [orderReportList, setOrderReportList] = useState([]); + const [costSalesData, setCostSalesData] = useState([]); const [current, setCurrent] = useState(1); const [pageSize, setPageSize] = useState(10); const [total, setTotal] = useState(0); @@ -49,6 +43,9 @@ export default function Index() { moment(moment(new Date(Date.now() - 24 * 60 * 60 * 1000 * 7)).format('YYYY-MM-DD 00:00:00')), moment(moment(new Date(Date.now())).format('YYYY-MM-DD 23:59:59')), ]); //日期选择器 + //门店 + const [storeIdArray, setStoreIdArray] = useState([]); + const [storeSelect, setStoreSelect] = useState([]); //页码变化 const onPageChange = (current, pageSize) => { @@ -57,33 +54,75 @@ export default function Index() { } //查询 - const onQueryOrderReportList = () => { - + const onQueryReportSalescost = async () => { + const jsonData = { + "storeId": storeIdArray, + "begintime": timeRange[0], + "endtime": timeRange[1], + current, + pageSize + } + setShowLoading(true); + const response = await costSalesAPI.getReportOrgsalesmargin({}); + setShowLoading(false); + if (response.statusCode === 200) { + setCostSalesData(response.data.data); + } else { + message.error(response.errors || '获取销售成本失败'); + } } - //选择门店 - const handleStoreChange = () => { - + /** + * 查询店铺列表 + */ + const onQueryStoreList = async () => { + setShowLoading(true); + const response = await costSalesAPI.gettree({}); + setShowLoading(false); + if (response.statusCode === 200) { + const storeList = []; + response.data.forEach(item => { + if (item.type === 2 || item.type === 3) { + storeList.push(item) + } + }) + setStoreSelect(storeList); + } else { + message.error('查询店铺列表失败'); + } } + useEffect(() => { + onQueryReportSalescost(); + onQueryStoreList(); + }, []); + return ( {showLoading ? : null}
- { let tempDate = [ @@ -95,12 +134,12 @@ export default function Index() {
- +
-
+
diff --git a/src/pages/order/gross-profit-store-sales/service.js b/src/pages/order/gross-profit-store-sales/service.js index 11107ef..d25abba 100644 --- a/src/pages/order/gross-profit-store-sales/service.js +++ b/src/pages/order/gross-profit-store-sales/service.js @@ -1,10 +1,21 @@ import { request } from 'umi'; export default { - getOrderReportList(data) { - return request(`/kitchen/api/report-statistics/order-report`, { + getReportOrgsalesmargin(data) { + return request(`/kitchen/api/report/orgsalesmargin`, { method: 'Post', data: data, }); + }, + + /** + * 查询门店列表 + */ + gettree(params) { + return request('​/kitchen/api​/sysOrg​/tree', { + data: { + ...params, + }, + }); } }; diff --git a/src/pages/order/sales-gross-profit/index.jsx b/src/pages/order/sales-gross-profit/index.jsx index 7d1c768..6ef8a2a 100644 --- a/src/pages/order/sales-gross-profit/index.jsx +++ b/src/pages/order/sales-gross-profit/index.jsx @@ -1,6 +1,6 @@ import React, { useState, useEffect } from 'react'; import { PageContainer } from '@ant-design/pro-layout'; -import { Button, Card, DatePicker, Table, Pagination, Spin, Select } from 'antd'; +import { Button, Card, DatePicker, Table, Pagination, Spin, Select, message } from 'antd'; import styles from './index.less'; const { RangePicker } = DatePicker; import costSalesAPI from "./service"; @@ -9,18 +9,18 @@ import moment from 'moment'; const columns = [ { title: '门店名称', - dataIndex: 'storeName', - key: 'storeName', + dataIndex: 'storeId', + key: 'storeId', }, { title: '商品名称', - dataIndex: 'goodsName', - key: 'storeName', + dataIndex: 'goodsId', + key: 'goodsId', }, { title: '毛利率', - dataIndex: 'grossProfitMargin', - key: 'salesRevenue', + dataIndex: 'marginRatio', + key: 'marginRatio', } ]; @@ -32,12 +32,6 @@ const LoadingCard = () => { ) } -const children = []; - -for (let i = 10; i < 36; i++) { - children.push(); -} - /** * 销售毛利分析 * @returns @@ -45,7 +39,7 @@ for (let i = 10; i < 36; i++) { export default function Index() { //订单报表列表 - const [orderReportList, setOrderReportList] = useState([]); + const [costSalesData, setCostSalesData] = useState([]); const [current, setCurrent] = useState(1); const [pageSize, setPageSize] = useState(10); const [total, setTotal] = useState(0); @@ -54,6 +48,15 @@ export default function Index() { moment(moment(new Date(Date.now() - 24 * 60 * 60 * 1000 * 7)).format('YYYY-MM-DD 00:00:00')), moment(moment(new Date(Date.now())).format('YYYY-MM-DD 23:59:59')), ]); //日期选择器 + //门店 + const [storeIdArray, setStoreIdArray] = useState([]); + const [storeSelect, setStoreSelect] = useState([]); + //商品 + const [goodsIdArray, setGoodsIdArray] = useState([]); + const [goodsIdSelect, setGoodsIdSelect] = useState([]); + //商品类型 + const [goodsTypeArray, setGoodsTypeArray] = useState([]); + const [goodsTypeSelect, setGoodsTypeSelect] = useState([]); //页码变化 const onPageChange = (current, pageSize) => { @@ -62,59 +65,144 @@ export default function Index() { } //查询 - const onQueryOrderReportList = () => { + const onQueryReportSalescost = async () => { + const jsonData = { + "storeId": storeIdArray, + "goodsId": goodsIdArray, + "goodsTypeId": goodsTypeArray, + "begintime": timeRange[0], + "endtime": timeRange[1], + current, + pageSize + } + setShowLoading(true); + const response = await costSalesAPI.getReportSalesmargin({}); + setShowLoading(false); + if (response.statusCode === 200) { + setCostSalesData(response.data.data); + } else { + message.error(response.errors || '获取销售成本失败'); + } + } + /** + * 查询店铺列表 + */ + const onQueryStoreList = async () => { + setShowLoading(true); + const response = await costSalesAPI.gettree({}); + setShowLoading(false); + if (response.statusCode === 200) { + const storeList = []; + response.data.forEach(item => { + if (item.type === 2 || item.type === 3) { + storeList.push(item) + } + }) + setStoreSelect(storeList); + } else { + message.error('查询店铺列表失败'); + } } - //选择门店 - const handleStoreChange = () => { + //查询商品列表 + const onQueryGoodsList = async () => { + setShowLoading(true); + const response = await costSalesAPI.goodsList({}); + setShowLoading(false); + if (response.statusCode === 200) { + setGoodsIdSelect(response.data); + } else { + message.error('查询商品列表失败'); + } + } + //查询商品分类类型列表 + const onQueryGoodsType = async () => { + setShowLoading(true); + const response = await costSalesAPI.goodsTypeList({}); + setShowLoading(false); + if (response.statusCode === 200) { + setGoodsTypeSelect(response.data); + } else { + message.error('查询商品分类列表失败'); + } } + useEffect(() => { + onQueryReportSalescost(); + onQueryStoreList(); + onQueryGoodsList(); + onQueryGoodsType(); + }, []); return ( {showLoading ? : null}
- { let tempDate = [ @@ -126,12 +214,12 @@ export default function Index() {
- +
-
+
diff --git a/src/pages/order/sales-gross-profit/service.js b/src/pages/order/sales-gross-profit/service.js index 11107ef..7537b2e 100644 --- a/src/pages/order/sales-gross-profit/service.js +++ b/src/pages/order/sales-gross-profit/service.js @@ -1,10 +1,39 @@ import { request } from 'umi'; export default { - getOrderReportList(data) { - return request(`/kitchen/api/report-statistics/order-report`, { + getReportSalesmargin(data) { + return request(`/kitchen/api/report/salesmargin`, { method: 'Post', data: data, }); + }, + /** + * 查询商品信息 + */ + goodsList(data) { + return request(`/kitchen/api/goodes/list`, { + method: 'Post', + data: data, + }); + }, + /** + * 查询商品类型 + */ + goodsTypeList(data) { + return request(`/kitchen/api/goodstype/list`, { + method: 'Post', + data: data, + }); + }, + + /** + * 查询门店列表 + */ + gettree(params) { + return request('​/kitchen/api​/sysOrg​/tree', { + data: { + ...params, + }, + }); } };