Browse Source

门店ID转名字显示

tags/小炒逻辑变更前
yangwenhua 2 years ago
parent
commit
b5e61e63e0
3 changed files with 51 additions and 11 deletions
  1. +19
    -5
      src/pages/order/cost-of-sales/index.jsx
  2. +16
    -3
      src/pages/order/gross-profit-store-sales/index.jsx
  3. +16
    -3
      src/pages/order/sales-gross-profit/index.jsx

+ 19
- 5
src/pages/order/cost-of-sales/index.jsx View File

@@ -33,6 +33,7 @@ export default function Index() {
//门店 //门店
const [storeIdArray, setStoreIdArray] = useState(""); const [storeIdArray, setStoreIdArray] = useState("");
const [storeSelect, setStoreSelect] = useState([]); const [storeSelect, setStoreSelect] = useState([]);
const [storeList, setStoreList] = useState([]);
//商品 //商品
const [goodsIdArray, setGoodsIdArray] = useState([]); const [goodsIdArray, setGoodsIdArray] = useState([]);
const [goodsIdSelect, setGoodsIdSelect] = useState([]); const [goodsIdSelect, setGoodsIdSelect] = useState([]);
@@ -52,9 +53,9 @@ export default function Index() {
dataIndex: 'storeId', dataIndex: 'storeId',
key: 'storeId', key: 'storeId',
render: (text) => { render: (text) => {
const findGoods = storeSelect.find(item => item.id === text);
const findGoods = storeList.find(item => item.key === text);
if (findGoods) { if (findGoods) {
return <span>{findGoods.name}</span>
return <span>{findGoods.title}</span>
} else { } else {
return <span>暂无门店名称</span> return <span>暂无门店名称</span>
} }
@@ -123,10 +124,11 @@ export default function Index() {
*/ */
const onQueryStoreList = async () => { const onQueryStoreList = async () => {
setShowLoading(true); setShowLoading(true);
const response = await costSalesAPI.gettree({});
const response = await costSalesAPI.gettree();
setShowLoading(false); setShowLoading(false);
if (response.statusCode === 200) { if (response.statusCode === 200) {
setStoreSelect(response.data); setStoreSelect(response.data);
setStoreList(treeArrayToFlat(response.data));
} else { } else {
message.error('查询店铺列表失败'); message.error('查询店铺列表失败');
} }
@@ -135,7 +137,7 @@ export default function Index() {
//查询商品列表 //查询商品列表
const onQueryGoodsList = async () => { const onQueryGoodsList = async () => {
setShowLoading(true); setShowLoading(true);
const response = await costSalesAPI.goodsList({});
const response = await costSalesAPI.goodsList();
setShowLoading(false); setShowLoading(false);
if (response.statusCode === 200) { if (response.statusCode === 200) {
setGoodsIdSelect(response.data); setGoodsIdSelect(response.data);
@@ -147,7 +149,7 @@ export default function Index() {
//查询商品分类类型列表 //查询商品分类类型列表
const onQueryGoodsType = async () => { const onQueryGoodsType = async () => {
setShowLoading(true); setShowLoading(true);
const response = await costSalesAPI.goodsTypeList({});
const response = await costSalesAPI.goodsTypeList();
setShowLoading(false); setShowLoading(false);
if (response.statusCode === 200) { if (response.statusCode === 200) {
setGoodsTypeSelect(response.data); setGoodsTypeSelect(response.data);
@@ -167,6 +169,18 @@ export default function Index() {
]); ]);
} }


//树形数据扁平化
const treeArrayToFlat = (tree, arr = []) => {
tree.forEach(item => {
const { children, ...props } = item;
arr.push(props);
if (children && children.length > 0) {
treeArrayToFlat(children, arr);
}
});
return arr;
}

useEffect(() => { useEffect(() => {
onQueryReportSalescost(); onQueryReportSalescost();
onQueryStoreList(); onQueryStoreList();


+ 16
- 3
src/pages/order/gross-profit-store-sales/index.jsx View File

@@ -35,6 +35,7 @@ export default function Index() {
//门店 //门店
const [storeIdArray, setStoreIdArray] = useState([]); const [storeIdArray, setStoreIdArray] = useState([]);
const [storeSelect, setStoreSelect] = useState([]); const [storeSelect, setStoreSelect] = useState([]);
const [storeList, setStoreList] = useState([]);


const columns = [ const columns = [
{ {
@@ -42,13 +43,12 @@ export default function Index() {
dataIndex: 'storeId', dataIndex: 'storeId',
key: 'storeId', key: 'storeId',
render: (text) => { render: (text) => {
const findGoods = storeSelect.find(item => item.id === text);
const findGoods = storeList.find(item => item.key === text);
if (findGoods) { if (findGoods) {
return <span>{findGoods.name}</span>
return <span>{findGoods.title}</span>
} else { } else {
return <span>暂无门店名称</span> return <span>暂无门店名称</span>
} }
}, },
}, },
{ {
@@ -92,6 +92,7 @@ export default function Index() {
setShowLoading(false); setShowLoading(false);
if (response.statusCode === 200) { if (response.statusCode === 200) {
setStoreSelect(response.data); setStoreSelect(response.data);
setStoreList(treeArrayToFlat(response.data));
} else { } else {
message.error('查询店铺列表失败'); message.error('查询店铺列表失败');
} }
@@ -106,6 +107,18 @@ export default function Index() {
]); ]);
} }


//树形数据扁平化
const treeArrayToFlat = (tree, arr = []) => {
tree.forEach(item => {
const { children, ...props } = item;
arr.push(props);
if (children && children.length > 0) {
treeArrayToFlat(children, arr);
}
});
return arr;
}

useEffect(() => { useEffect(() => {
onQueryReportSalescost(); onQueryReportSalescost();
onQueryStoreList(); onQueryStoreList();


+ 16
- 3
src/pages/order/sales-gross-profit/index.jsx View File

@@ -33,6 +33,7 @@ export default function Index() {
//门店 //门店
const [storeIdArray, setStoreIdArray] = useState(""); const [storeIdArray, setStoreIdArray] = useState("");
const [storeSelect, setStoreSelect] = useState([]); const [storeSelect, setStoreSelect] = useState([]);
const [storeList, setStoreList] = useState([]);
//商品 //商品
const [goodsIdArray, setGoodsIdArray] = useState([]); const [goodsIdArray, setGoodsIdArray] = useState([]);
const [goodsIdSelect, setGoodsIdSelect] = useState([]); const [goodsIdSelect, setGoodsIdSelect] = useState([]);
@@ -46,13 +47,12 @@ export default function Index() {
dataIndex: 'storeId', dataIndex: 'storeId',
key: 'storeId', key: 'storeId',
render: (text) => { render: (text) => {
const findGoods = storeSelect.find(item => item.id === text);
const findGoods = storeList.find(item => item.key === text);
if (findGoods) { if (findGoods) {
return <span>{findGoods.name}</span>
return <span>{findGoods.title}</span>
} else { } else {
return <span>暂无门店名称</span> return <span>暂无门店名称</span>
} }
}, },
}, },
{ {
@@ -112,6 +112,7 @@ export default function Index() {
setShowLoading(false); setShowLoading(false);
if (response.statusCode === 200) { if (response.statusCode === 200) {
setStoreSelect(response.data); setStoreSelect(response.data);
setStoreList(treeArrayToFlat(response.data));
} else { } else {
message.error('查询店铺列表失败'); message.error('查询店铺列表失败');
} }
@@ -152,6 +153,18 @@ export default function Index() {
]); ]);
} }


//树形数据扁平化
const treeArrayToFlat = (tree, arr = []) => {
tree.forEach(item => {
const { children, ...props } = item;
arr.push(props);
if (children && children.length > 0) {
treeArrayToFlat(children, arr);
}
});
return arr;
}

useEffect(() => { useEffect(() => {
onQueryReportSalescost(); onQueryReportSalescost();
onQueryStoreList(); onQueryStoreList();


Loading…
Cancel
Save