123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695 |
- import { createAction, NavigationActions } from '../../utils'
- import * as authService from '../../services/auth'
- import Theme from '../../containers/common/theme/config'
- import deviceStorage from '../../utils/storage'
- import utils from '../../utils/utils'
- export default {
- namespace: 'mine',
- state: {
- // 地址
- addressData: [],
- addressDefault: {},
- // 供应商
- // supplierData: [],
- // supplierDefault: {},
- // 运输方式
- transportData: [],
- transportDefault: {},
- // 结算方式
- billwayData: [],
- billwayDefault: {},
- // 收款业务类型
- payTypesData: [],
- payTypesDefault: {},
- // 选择发票
- invoiceData: [],
- invoiceDefault: {},
- // 要货单支付方式
- orderPayStatus: [],
- // 财务组织参照
- FinancialOrg: [],
- SaleOrg: [],
- // 产品线参照
- productRefs: [],
- // 兑付方式
- OffsetMod: [],
- // 状态
- StateMod: [],
- // 基础信息
- BasicInfo: {},
- // 银行账户
- BankInfo: [],
- // 联系人
- ContactInfo: [],
- // 客户收货地址
- AddressInfo: [],
- // 客户供应商列表
- SupplierInfo: [],
- financeBankAcc: [],
- },
- reducers: {
- adressReducer(state, { payload }) {
- return { ...state, ...payload }
- },
- supplierReducer(state, { payload }) {
- return { ...state, ...payload }
- },
- transportReducer(state, { payload }) {
- return { ...state, ...payload }
- },
- billwayReducer(state, { payload }) {
- return { ...state, ...payload }
- },
- invoiceReducer(state, { payload }) {
- return { ...state, ...payload }
- },
- organReducer(state, { payload }) {
- return { ...state, ...payload }
- },
- DocReducer(state, { payload }) {
- return { ...state, ...payload }
- },
- BasicReducer(state, { payload }) {
- return { ...state, ...payload }
- },
- FinanceReducer(state, { payload }) {
- return { ...state, ...payload }
- },
- SaleOrgReducer(state, { payload }) {
- return { ...state, ...payload }
- },
- productRefsReducer(state, { payload }) {
- return { ...state, ...payload }
- },
- payTyepsReducer(state, { payload }) {
- return { ...state, ...payload }
- },
- BankAccountByFinanceReducer(state, { payload }) {
- return { ...state, ...payload }
- },
- PaymentModeReducer(state, { payload }) {
- return { ...state, ...payload }
- },
- },
- effects: {
- //收货地址参照
- *getAdress(action, { call, put }) {
- try {
- const hotdata = yield call(() =>
- authService.getadress({ customer: action.payload.customer })
- )
- let addressDefault = {}
- if (
- action.payload.comefrom &&
- action.payload.comefrom.comefrom &&
- action.payload.comefrom.comefrom == 'temporarily'
- ) {
- addressDefault = action.payload.comefrom.reqOrderReceiveAddress
- } else {
- for (let i = 0; i < hotdata.data.length; i++) {
- if (hotdata && hotdata.data && hotdata.data[i].isDefault == 1) {
- addressDefault = hotdata.data[i]
- }
- if (
- hotdata &&
- hotdata.data &&
- Object.keys(addressDefault).length == 0
- ) {
- addressDefault = hotdata.data[0]
- }
- }
- }
- if (hotdata.data) {
- yield put(
- createAction('adressReducer')({
- addressData: hotdata.data,
- addressDefault: addressDefault,
- })
- )
- }
- } catch (error) {
- console.log(
- error,
- '-----error的完整信息' + '\n' + error.response.data.message,
- '-----相关错误信息'
- )
- }
- if (action.payload && action.payload.transform) {
- yield put(createAction('getTransport')(action.payload))
- }
- if (action.payload && action.payload.billway) {
- yield put(createAction('getBillWay')(action.payload))
- }
- if (action.payload && action.payload.invoice) {
- yield put(createAction('getInvoice')(action.payload))
- }
- },
- // 更新选中地址
- *AdressSetstate(action, { call, put }) {
- if (action && action.payload) {
- yield put(
- createAction('adressReducer')({
- addressDefault: action.payload,
- })
- )
- }
- },
- //运输方式参照
- *getTransport(action, { call, put }) {
- try {
- const transportdata = yield call(authService.gettransport)
- if (transportdata.data) {
- yield put(
- createAction('transportReducer')({
- transportData: transportdata.data,
- transportDefault:
- action.payload.comefrom.comefrom == 'temporarily'
- ? action.payload.comefrom.transportDefault
- : transportdata.data[0],
- })
- )
- }
- } catch (error) {
- console.log(
- error,
- '-----error的完整信息' + '\n' + error.response.data.message,
- '-----相关错误信息'
- )
- }
- },
- // 选中运输参照
- *TransportSetstate(action, { call, put }) {
- if (action && action.payload) {
- yield put(
- createAction('transportReducer')({
- transportDefault: action.payload,
- })
- )
- }
- },
- //结算方式
- *getBillWay(action, { call, put }) {
- try {
- const billwaydata = yield call(authService.getbillway)
- if (billwaydata.data) {
- yield put(
- createAction('billwayReducer')({
- billwayData: billwaydata.data,
- billwayDefault:
- action.payload &&
- action.payload.comefrom.comefrom == 'temporarily'
- ? action.payload.comefrom.billwayDefault
- : billwaydata.data[0],
- })
- )
- }
- } catch (error) {
- console.log(
- error,
- '-----error的完整信息' + '\n' + error.response.data.message,
- '-----相关错误信息'
- )
- }
- },
- // 选中运输参照
- *BillwaySetstate(action, { call, put }) {
- if (action && action.payload) {
- yield put(
- createAction('billwayReducer')({
- billwayDefault: action.payload,
- })
- )
- }
- },
- //收款业务类型参照getPayTypes
- *getPayTypes(action, { call, put }) {
- try {
- const getValue = yield call(() =>
- authService.getPayTypes({ search_EQ_isEnable: 1, page: 0, size: 100 })
- )
- if (getValue.data && getValue.data.content) {
- yield put(
- createAction('payTyepsReducer')({
- payTypesData: getValue.data.content,
- payTypesDefault:
- action.payload &&
- action.payload.comefrom.comefrom == 'temporarily'
- ? action.payload.comefrom.payTypesDefault
- : getValue.data.content[0],
- })
- )
- }
- } catch (error) {
- console.log(
- error,
- '-----error的完整信息' + '\n' + error.response.data.message,
- '-----相关错误信息'
- )
- }
- },
- // 选中收款业务类型参照
- *payTypeSetstate(action, { call, put }) {
- if (action && action.payload) {
- yield put(
- createAction('payTyepsReducer')({
- payTypesDefault: action.payload,
- })
- )
- }
- },
- //发票
- *getInvoice(action, { call, put }) {
- try {
- const invoicedata = yield call(() =>
- authService.getinvoice({ customer: action.payload.customer })
- )
- let invoDef = {},
- invoDefFlag = true
- if (invoicedata.data && invoicedata.data.length > 0) {
- if (
- action.payload.comefrom &&
- action.payload.comefrom.comefrom &&
- action.payload.comefrom.comefrom == 'temporarily'
- ) {
- invoDef = action.payload.comefrom.reqOrderInvoice
- } else {
- for (let val of invoicedata.data) {
- if (val.isDefault == 1) {
- invoDef = val
- invoDefFlag = false
- }
- }
- if (invoDefFlag) {
- invoDef = invoicedata.data[0]
- }
- }
- yield put(
- createAction('invoiceReducer')({
- invoiceData: invoicedata.data,
- invoiceDefault: invoDef,
- })
- )
- }
- } catch (error) {
- console.log(
- error,
- '-----error的完整信息' + '\n' + error.response.data.message,
- '-----相关错误信息'
- )
- }
- },
- // 选中运输参照
- *InvoiceSetstate(action, { call, put }) {
- if (action && action.payload) {
- yield put(
- createAction('invoiceReducer')({
- invoiceDefault: action.payload,
- })
- )
- }
- },
- //组织参照
- *getOrgans(action, { call, put }) {
- try {
- if (!action.payload.searchMore) {
- // 兑付方式
- yield put(
- createAction('getCastDoc')({
- inFo: {
- 'search_EQ_custDoc.id': '7ddbcd90-8080-4be9-a6f2-df143e62b083',
- size: 100,
- page: 0,
- },
- useFor: 'duifu',
- })
- )
- // 单据状态
- yield put(
- createAction('getCastDoc')({
- inFo: {
- 'search_EQ_custDoc.id': '63cabe5c-1184-4e42-b506-a8c8806bccbd',
- size: 100,
- page: 0,
- },
- useFor: 'state',
- })
- )
- }
- if (action.payload.forUse == 'tiaozhuan') {
- yield put(NavigationActions.navigate({ routeName: 'Cost' }))
- }
- } catch (error) {
- console.log(
- error,
- '-----error的完整信息' + '\n' + error.response.data.message,
- '-----相关错误信息'
- )
- }
- },
- //兑付方式/单据状态参照
- *getCastDoc(action, { call, put }) {
- try {
- CastDocData = []
- const docData = yield call(() =>
- authService.getCastDoc(action.payload.inFo)
- )
- if (
- docData &&
- docData.data &&
- docData.data.content &&
- docData.data.content.length > 0
- ) {
- CastDocData = docData.data.content.filter(item => item.isEnable == 1)
- CastDocData.unshift({
- name: '全部',
- id: '',
- })
- if (action.payload.useFor == 'duifu') {
- yield put(
- createAction('DocReducer')({
- OffsetMod: CastDocData,
- })
- )
- } else {
- yield put(
- createAction('DocReducer')({
- StateMod: CastDocData,
- })
- )
- }
- }
- } catch (error) {
- console.log(
- error,
- '-----error的完整信息' + '\n' + error.response.data.message,
- '-----相关错误信息'
- )
- }
- },
- //基础信息
- *getBasic(action, { call, put }) {
- try {
- const basicData = yield call(() =>
- authService.getBasicInfo(action.payload.customerId)
- )
- const bankCountData = yield call(() =>
- authService.getBasicBankInfo(action.payload.customerId)
- )
- if (basicData.data) {
- yield put(
- createAction('BasicReducer')({
- BasicInfo: basicData.data,
- BankInfo: bankCountData.data.content,
- })
- )
- yield put(NavigationActions.navigate({ routeName: 'BasicInfo' }))
- }
- } catch (error) {
- console.log(
- error,
- '-----error的完整信息' + '\n' + error.response.data.message,
- '-----相关错误信息'
- )
- }
- },
- //联系人
- *getContacts(action, { call, put }) {
- try {
- const contactData = yield call(() =>
- authService.getContacts(action.payload)
- )
- if (contactData.data) {
- yield put(
- createAction('BasicReducer')({
- ContactInfo: contactData.data,
- })
- )
- yield put(
- NavigationActions.navigate({ routeName: 'CustomerContact' })
- )
- }
- } catch (error) {
- console.log(
- error,
- '-----error的完整信息' + '\n' + error.response.data.message,
- '-----相关错误信息'
- )
- }
- },
- //收货地址
- *getCusAdd(action, { call, put }) {
- try {
- const addressData = yield call(() =>
- authService.getCusAdd(action.payload)
- )
- if (addressData.data) {
- yield put(
- createAction('BasicReducer')({
- AddressInfo: addressData.data,
- })
- )
- yield put(
- NavigationActions.navigate({ routeName: 'CustomerAddress' })
- )
- }
- } catch (error) {
- console.log(
- error,
- '-----error的完整信息' + '\n' + error.response.data.message,
- '-----相关错误信息'
- )
- }
- },
- //通过财务组织 找所有下属销售组织
- *findSaleOrgByFinance(action, { call, put }) {
- try {
- const saleorg = yield call(() =>
- authService.findSaleOrgByFinance(action.payload)
- )
- if (saleorg.data && saleorg.data.content) {
- yield put(
- createAction('SaleOrgReducer')({
- SaleOrg: saleorg.data.content,
- })
- )
- }
- } catch (error) {
- console.log(
- error,
- '-----error的完整信息' + '\n' + error.response.data.message,
- '-----相关错误信息'
- )
- }
- },
- //销售组织找财务组织
- *findFinanceBySaleOrg(action, { call, put }) {
- try {
- const FinanData = yield call(() =>
- authService.getFinanceRef(action.payload.saleOrgIds)
- )
- if (FinanData && FinanData.status == 200) {
- yield put(
- createAction('FinanceReducer')({
- FinancialOrg: FinanData.data ? FinanData.data : [],
- financeBankAcc: [],
- })
- )
- if (action.payload.forUse == 'CostReconciliation') {
- yield put(
- NavigationActions.navigate({
- routeName: 'CostReconciliation',
- })
- )
- }
- }
- } catch (error) {
- yield put(
- createAction('FinanceReducer')({
- FinancialOrg: [],
- financeBankAcc: [],
- })
- )
- console.log(
- error,
- '-----error的完整信息' + '\n' + error.response.data.message,
- '-----相关错误信息'
- )
- }
- },
- //通过销售组织找收款信息
- *findAccountByFinanceSaga(action, { call, put }) {
- try {
- const accountSarch = {
- 'search_EQ_financeOrganization.id': action.payload.finanOrgId,
- search_EQ_isEnable: 1,
- size: 100,
- page: 0,
- }
- const accountByFinace = yield call(() =>
- authService.getAccountByFinance(accountSarch)
- )
- if (accountByFinace && accountByFinace.data) {
- yield put(
- createAction('BankAccountByFinanceReducer')({
- financeBankAcc: accountByFinace.data.content,
- })
- )
- }
- } catch (error) {
- yield put(
- createAction('BankAccountByFinanceReducer')({
- financeBankAcc: [],
- })
- )
- console.log(
- error,
- '-----error的完整信息' + '\n' + error.response.data.message,
- '-----相关错误信息'
- )
- }
- },
- //客户供应商
- *getCusSup(action, { call, put }) {
- try {
- let Brand = {},
- saleOrgIds = [],
- productRefs = []
- if (action.payload.customerRankCode == 1) {
- Brand = yield call(() =>
- authService.getBarndOne({ customerIds: action.payload.customerId })
- )
- } else {
- Brand = yield call(() =>
- authService.getBarndSec({
- purchaseCustomerId: action.payload.customerId,
- })
- )
- }
- if (Brand && Brand.data && Brand.data.length > 0) {
- if (
- !(action.payload.comeFrom && action.payload.comeFrom == 'supplier')
- ) {
- Brand.data.map(item => {
- if (item.saleOrganizationId) {
- saleOrgIds.push(item.saleOrganizationId)
- }
- })
- yield put(
- createAction('findFinanceBySaleOrg')({
- saleOrgIds: saleOrgIds,
- ...action.payload,
- })
- )
- // const FinanData = yield call(() =>
- // authService.getFinanceRef(saleOrgIds)
- // );
- // if (FinanData && FinanData.data) {
- // yield put(
- // createAction("FinanceReducer")({
- // FinancialOrg: FinanData.data
- // })
- // );
- // if (action.payload.forUse == "CostReconciliation") {
- // yield put(
- // NavigationActions.navigate({
- // routeName: "CostReconciliation"
- // })
- // );
- // }
- // }
- }
- if (
- action.payload.addDefaultData &&
- action.payload.addDefaultData == 'productLine'
- ) {
- Brand.data.map(item => {
- if (item.productLineName && item.productLineId) {
- productRefs.push(item)
- }
- })
- productRefs.unshift({
- productLineName: '全部产品线',
- productLineId: '',
- })
- yield put(
- createAction('productRefsReducer')({
- productRefs: productRefs,
- })
- )
- Brand.data.unshift({
- saleOrganizationName: '全部供应商',
- saleOrganizationId: '',
- })
- }
- // 费用余额用
- if (action.payload.comeFrom == 'castBalance') {
- Brand.data.unshift({
- saleOrganizationName: '全部供应商',
- saleOrganizationId: '',
- })
- }
- yield put(
- createAction('BasicReducer')({
- SupplierInfo: Brand.data,
- })
- )
- if (
- action.payload.comeFrom &&
- action.payload.comeFrom == 'supplier' &&
- action.payload.toOthers
- ) {
- yield put(NavigationActions.navigate({ routeName: 'Supplier' }))
- }
- }
- } catch (error) {
- console.log(
- error,
- '-----error的完整信息' + '\n' + error.response.data.message,
- '-----相关错误信息'
- )
- }
- },
- //要货单支付方式
- *payMentMode(action, { call, put }) {
- try {
- const data = yield call(() => authService.getPayStatus())
- if (data && data.data) {
- yield put(
- createAction('PaymentModeReducer')({
- orderPayStatus: data.data,
- })
- )
- }
- } catch (error) {
- console.log(
- error,
- '-----error的完整信息' + '\n' + error.response.data.message,
- '-----相关错误信息'
- )
- }
- },
- },
- }
|