system-copyright-react/src/store/index.ts
2025-05-27 10:47:05 +08:00

92 lines
2.4 KiB
TypeScript

import { createStore } from "redux"
// 设置数据
const baseState = {
// msg: '嘻嘻嘻嘻嘻嘻',
// num: 10,
// shuju: {
// name: '小白',
// hobby: '吃饭',
// val: ''
// },
belongArray: [],
refunArray: [],
correctionArray: [],
contractArray: [],
contractTotal: 0,
refunTotal: 0,
correctionTotal: 0,
couponModal: false,
projName: '',
projStatus: '',
newRefun: false,
newCorrection: false,
packNum: {
ALL: 0,
MATERIAL: 0,
},
phoneModal: false,
appGoodsListData: {},
}
// 创建仓库
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);
// }
// redux 要求 state必须深拷贝一次 才能返回
if (action.type == 'uparray') {
nstate.belongArray = action.val
}
if (action.type == 'upRefunArray') {
nstate.refunArray = action.val
}
if (action.type == 'upRefunTotal') {
nstate.refunTotal = action.val
}
if (action.type == 'upCorrectionArray') {
nstate.correctionArray = action.val
}
if (action.type == 'upContractArray') {
nstate.contractArray = action.val
}
if (action.type == 'upContractTotal') {
nstate.contractTotal = action.val
}
if (action.type == 'upCorrectionTotal') {
nstate.correctionTotal = action.val
}
if (action.type == 'changeCouponModal') {
nstate.couponModal = action.val
}
if (action.type == 'upProjName') {
nstate.projName = action.val
}
if (action.type == 'upProjStatus') {
nstate.projStatus = action.val
}
if (action.type == 'newRefun') {
nstate.newRefun = action.val
}
if (action.type == 'newCorrection') {
nstate.newCorrection = action.val
}
if (action.type == 'upPackNum') {
nstate.packNum = action.val
}
if (action.type == 'changePhoneModal') {
nstate.phoneModal = action.val
}
if (action.type == 'upAppGoodsListData') {
nstate.appGoodsListData = action.val
}
return nstate
}
const store = createStore(reducer)
export default store