--我的页面更新新版本
--码单管理完成
This commit is contained in:
@@ -21,7 +21,10 @@
|
||||
margin: 18px auto 0;
|
||||
border: 1px solid #ffffff;
|
||||
}
|
||||
.weight-list-list:hover{
|
||||
.weight-list-list:first-child{
|
||||
margin-top: 0;
|
||||
}
|
||||
.address-active{
|
||||
border: 1px solid #68b4ff;
|
||||
box-shadow: 0px 0px 10px 0px rgba(0,122,255,0.27);
|
||||
}
|
||||
|
||||
@@ -1,53 +1,84 @@
|
||||
|
||||
import { Button, Navigator, ScrollView, Text, View } from "@tarojs/components"
|
||||
import { memo, useState } from "react"
|
||||
import { memo, useEffect, useState } from "react"
|
||||
import {weightListApi,weightDeleteApi} from "@/api/weightList"
|
||||
import "./index.scss"
|
||||
|
||||
import Taro, { showModal } from "@tarojs/taro"
|
||||
import { alert } from "@/common/common"
|
||||
const weightListManager = ()=>{
|
||||
|
||||
return(
|
||||
<View className="weight-list-manager">
|
||||
<WeightList />
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
interface Params{
|
||||
refresherEnabled?: boolean,//是否开启刷新
|
||||
onSelect?: (item:any,index:number)=>void,//列表选择
|
||||
|
||||
}
|
||||
// 码单列表
|
||||
const WeightList = memo((props:Params)=>{
|
||||
const WeightList = (props:Params)=>{
|
||||
const {fetchData, state} = weightListApi();
|
||||
const getData = ()=>{
|
||||
fetchData();
|
||||
}
|
||||
useEffect(()=>{
|
||||
Taro.eventCenter.on("weightList:refresh", getData);
|
||||
getData();
|
||||
return ()=>{
|
||||
Taro.eventCenter.off("weightList:refresh", getData);
|
||||
}
|
||||
},[]);
|
||||
// 处理刷新
|
||||
const [refreshState, setRefreshState] = useState(false);
|
||||
const handleRefresh = ()=>{
|
||||
const handleRefresh = async ()=>{
|
||||
setRefreshState(true);
|
||||
setTimeout(()=>{
|
||||
setRefreshState(false);
|
||||
},500)
|
||||
await fetchData();
|
||||
setRefreshState(false);
|
||||
}
|
||||
const data = Array.from({length:0});
|
||||
// 删除码单
|
||||
const {fetchData: deleteFetch} = weightDeleteApi()
|
||||
const handleDelete = (item:any)=>{
|
||||
showModal(({
|
||||
title: "提示",
|
||||
content: "是否删除码单?",
|
||||
async success(ev){
|
||||
if(ev.confirm){
|
||||
const result = await deleteFetch({id:item.id});
|
||||
if(result.success){
|
||||
alert.success("删除成功");
|
||||
getData();
|
||||
}else{
|
||||
alert.success(result.msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
return (
|
||||
<View className="weight-list-scroll-view">
|
||||
<ScrollView scrollY refresherEnabled={props.refresherEnabled} enhanced refresherTriggered={refreshState} onRefresherRefresh={handleRefresh}>
|
||||
<ScrollView scrollY refresherEnabled enhanced refresherTriggered={refreshState} onRefresherRefresh={handleRefresh}>
|
||||
{
|
||||
data.length>0?
|
||||
data.map((item,index)=>{
|
||||
// data.length>0?
|
||||
state?.data?.list?.length>0?
|
||||
state?.data?.list?.map((item,index)=>{
|
||||
return(
|
||||
<View onClick={()=>props.onSelect&&props.onSelect(item,index)} className="weight-list-list">
|
||||
<View onClick={()=>props.onSelect&&props.onSelect(item,index)} onLongPress={()=>handleDelete(item)} className={`weight-list-list ${item.is_default&&'address-active'}`}>
|
||||
<View className="weight-list-user">
|
||||
XL纺织
|
||||
<Text className="weight-list-list-default">默认</Text>
|
||||
{/* <Text className="weight-list-list-phone">1656488999</Text> */}
|
||||
{item.title}
|
||||
{
|
||||
item.is_default&&<Text className="weight-list-list-default">默认</Text>
|
||||
}
|
||||
</View>
|
||||
<View className="weight-list-list-bottom">
|
||||
<View className="weight-list-list-info">
|
||||
**省**市**区**街道****仓库
|
||||
<Text className="weight-list-list-phone">181****9790</Text>
|
||||
{item.purchaser_name}
|
||||
<Text className="weight-list-list-phone">{item.phone.replace(item.phone.substring(3,7), "****")}</Text>
|
||||
</View>
|
||||
<Navigator url="/pages/weightListAdd/index?type=edit" hoverClass="none" className="weight-list-edit">
|
||||
<Navigator url={`/pages/weightListAdd/index?type=edit&id=${item.id}`} hoverClass="none" className="weight-list-edit">
|
||||
<Text className="iconfont icon-bianji"></Text>
|
||||
</Navigator>
|
||||
</View>
|
||||
@@ -63,6 +94,6 @@ const WeightList = memo((props:Params)=>{
|
||||
<Navigator url="/pages/weightListAdd/index?type=add" hoverClass="none" className="add-weight-list">添加新码单信息</Navigator>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
export default weightListManager;
|
||||
Reference in New Issue
Block a user