system-copyright-react/src/store/index.ts

88 lines
2.2 KiB
TypeScript
Raw Normal View History

2024-08-12 14:43:58 +08:00
import { createStore } from "redux"
2024-07-31 16:00:30 +08:00
// 设置数据
const baseState = {
2024-08-12 14:43:58 +08:00
// msg: '嘻嘻嘻嘻嘻嘻',
// num: 10,
// shuju: {
// name: '小白',
// hobby: '吃饭',
// val: ''
// },
2024-08-23 11:16:52 +08:00
belongArray: [],
refunArray:[],
2024-08-26 18:03:35 +08:00
correctionArray:[],
2024-11-29 17:52:17 +08:00
contractArray:[],
contractTotal:0,
2024-08-26 18:03:35 +08:00
refunTotal:0,
2024-09-02 16:41:02 +08:00
correctionTotal:0,
couponModal:false,
projName:'',
2024-09-11 16:45:19 +08:00
projStatus:'',
newRefun:false,
2025-03-07 08:45:05 +08:00
newCorrection:false,
packNum:{
ALL:0,
MATERIAL:0,
2025-04-14 17:38:30 +08:00
},
phoneModal:false,
2024-07-31 16:00:30 +08:00
}
// 创建仓库
2024-08-12 14:43:58 +08:00
const reducer = (state = baseState, action: any) => {
const nstate: any = JSON.parse(JSON.stringify(state))
// if (action.type == "numadd") {
// nstate.num++
// // console.log('123');
// }
// if (action.type == 'new') {
// nstate.shuju.val = action.val
// console.log(nstate.shuju.val);
// }
2024-07-31 16:00:30 +08:00
// redux 要求 state必须深拷贝一次 才能返回
2024-08-12 14:43:58 +08:00
if (action.type == 'uparray') {
2024-07-31 16:00:30 +08:00
nstate.belongArray = action.val
}
2024-08-23 11:16:52 +08:00
if (action.type == 'upRefunArray') {
nstate.refunArray = action.val
}
if (action.type == 'upRefunTotal') {
nstate.refunTotal = action.val
}
2024-08-26 18:03:35 +08:00
if (action.type == 'upCorrectionArray') {
nstate.correctionArray = action.val
}
2024-11-29 17:52:17 +08:00
if (action.type == 'upContractArray') {
nstate.contractArray = action.val
}
if (action.type == 'upContractTotal') {
nstate.contractTotal = action.val
}
2024-08-26 18:03:35 +08:00
if (action.type == 'upCorrectionTotal') {
nstate.correctionTotal = action.val
}
2024-09-02 16:41:02 +08:00
if (action.type == 'changeCouponModal') {
nstate.couponModal = action.val
}
if (action.type == 'upProjName') {
nstate.projName = action.val
}
if (action.type == 'upProjStatus') {
nstate.projStatus = action.val
}
2024-09-11 16:45:19 +08:00
if (action.type == 'newRefun') {
nstate.newRefun = action.val
}
if (action.type == 'newCorrection') {
nstate.newCorrection = action.val
}
2025-03-07 08:45:05 +08:00
if (action.type == 'upPackNum') {
nstate.packNum = action.val
}
2025-04-14 17:38:30 +08:00
if(action.type == 'changePhoneModal'){
nstate.phoneModal = action.val
}
2024-07-31 16:00:30 +08:00
return nstate
}
const store = createStore(reducer)
export default store