|
@@ -5,15 +5,13 @@ const initialState = {
|
|
linesUpdate: [],
|
|
linesUpdate: [],
|
|
showStatementLine: false
|
|
showStatementLine: false
|
|
}
|
|
}
|
|
-
|
|
|
|
const state = {
|
|
const state = {
|
|
lines: initialState.lines,
|
|
lines: initialState.lines,
|
|
lineSelected: initialState.lineSelected,
|
|
lineSelected: initialState.lineSelected,
|
|
linesDeleted: initialState.linesDeleted,
|
|
linesDeleted: initialState.linesDeleted,
|
|
linesUpdate: initialState.linesUpdate,
|
|
linesUpdate: initialState.linesUpdate,
|
|
- showStatementLine: initialState.showStatementLine
|
|
|
|
|
|
+ showStatementLine: initialState.showStatementLine,
|
|
}
|
|
}
|
|
-
|
|
|
|
const getters = {
|
|
const getters = {
|
|
statementLines(state) {
|
|
statementLines(state) {
|
|
return state.lines
|
|
return state.lines
|
|
@@ -31,7 +29,6 @@ const getters = {
|
|
return state.lineSelected;
|
|
return state.lineSelected;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
const mutations = {
|
|
const mutations = {
|
|
setLines(state, payload) {
|
|
setLines(state, payload) {
|
|
let data = []
|
|
let data = []
|
|
@@ -52,7 +49,7 @@ const mutations = {
|
|
},
|
|
},
|
|
/*Show Modal Modify Line */
|
|
/*Show Modal Modify Line */
|
|
setShowStatementLine( state, payload){
|
|
setShowStatementLine( state, payload){
|
|
- state.showStatementLine = !!payload
|
|
|
|
|
|
+ state.showStatementLine = payload
|
|
},
|
|
},
|
|
/* */
|
|
/* */
|
|
setLinesDeleted (state, payload) {
|
|
setLinesDeleted (state, payload) {
|
|
@@ -73,60 +70,80 @@ const mutations = {
|
|
state.linesDeleted.splice(linesDeletedFound, 1)
|
|
state.linesDeleted.splice(linesDeletedFound, 1)
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- /* */
|
|
|
|
|
|
+ /* Add Update */
|
|
setLinesUpdate (state, payload) {
|
|
setLinesUpdate (state, payload) {
|
|
- // state.lines.forEach(item => {
|
|
|
|
- // if (item.id === payload {
|
|
|
|
- // item.linesUpdate = payload
|
|
|
|
- // }
|
|
|
|
- // })
|
|
|
|
|
|
+ if (!payload) {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ let updateLine = state.lines.find(item => item.id === payload.id)
|
|
|
|
+ if (updateLine){
|
|
|
|
+ updateLine.amount = payload.amount
|
|
|
|
+ updateLine.date = payload.date
|
|
|
|
+ updateLine.name = payload.name
|
|
|
|
+ updateLine.isUpdate = true
|
|
|
|
+ updateLine.partnerId = payload.partnerId
|
|
|
|
+ updateLine.partnerName = payload.partnerName
|
|
|
|
+ updateLine.ref = payload.ref
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ let linesUpdateFound = state.linesUpdate.find(item => item.id === payload.id)
|
|
|
|
+ if (!!linesUpdateFound) {
|
|
|
|
+ let linesIndex = state.linesUpdate.findIndex(item => item.id === payload.id)
|
|
|
|
+ state.linesUpdate.splice(linesIndex, 1)
|
|
|
|
+ }
|
|
|
|
|
|
- if (!!payload) {
|
|
|
|
- let linesUpdateFound = state.linesUpdate.find(item => item === payload)
|
|
|
|
- if (!!linesUpdateFound) return
|
|
|
|
- state.linesUpdate = [payload, ...state.linesUpdate]
|
|
|
|
|
|
+ let statementLine = {
|
|
|
|
+ 'amount': payload.amount,
|
|
|
|
+ 'date': payload.date,
|
|
|
|
+ 'id': payload.id,
|
|
|
|
+ 'isDelete': payload.isDelete,
|
|
|
|
+ 'isUpdate': true,
|
|
|
|
+ 'name': payload.name,
|
|
|
|
+ 'partnerId': payload.partnerId,
|
|
|
|
+ 'partnerName': payload.partnerName,
|
|
|
|
+ 'ref':payload.ref,
|
|
}
|
|
}
|
|
|
|
|
|
- // if (!payload.state) {
|
|
|
|
- // let linesDeletedFound = state.linesDeleted.findIndex(item => item === payload.id)
|
|
|
|
- // state.linesDeleted.splice(linesDeletedFound, 1)
|
|
|
|
- // }
|
|
|
|
|
|
+ state.linesUpdate = [statementLine, ...state.linesUpdate]
|
|
},
|
|
},
|
|
- /* */
|
|
|
|
|
|
+ /* Selected */
|
|
setLineSelected(state, payload) {
|
|
setLineSelected(state, payload) {
|
|
let selected = state.lines.find(item => item.id === payload)
|
|
let selected = state.lines.find(item => item.id === payload)
|
|
state.lineSelected = !!selected ? selected : null
|
|
state.lineSelected = !!selected ? selected : null
|
|
},
|
|
},
|
|
|
|
+ /* Reset */
|
|
|
|
+ setResetLines(state){
|
|
|
|
+ state.lines = []
|
|
|
|
+ state.lineSelected = null
|
|
|
|
+ state.linesDeleted = []
|
|
|
|
+ state.linesUpdate = []
|
|
|
|
+ state.showStatementLine = false
|
|
|
|
+ },
|
|
}
|
|
}
|
|
-
|
|
|
|
const actions = {
|
|
const actions = {
|
|
initLines({ commit, getters }) {
|
|
initLines({ commit, getters }) {
|
|
if (!!getters.selectedStatement) {
|
|
if (!!getters.selectedStatement) {
|
|
commit('setLines', getters.selectedStatement.line)
|
|
commit('setLines', getters.selectedStatement.line)
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- resetLines({ commit }){
|
|
|
|
- commit('setLines', [])
|
|
|
|
- },
|
|
|
|
- selectLineSelected({ commit, dispatch },payload){
|
|
|
|
|
|
+ selectLineSelected({ commit },payload) {
|
|
commit('setLineSelected', payload)
|
|
commit('setLineSelected', payload)
|
|
- // dispatch('showStatementLineModify', payload)
|
|
|
|
|
|
+ commit('setShowStatementLine', payload)
|
|
},
|
|
},
|
|
addDeletedLine({ commit }, payload) {
|
|
addDeletedLine({ commit }, payload) {
|
|
commit('setLinesDeleted', payload)
|
|
commit('setLinesDeleted', payload)
|
|
},
|
|
},
|
|
- addUpdateLine({ commit }, payload){
|
|
|
|
|
|
+ addUpdateLine({ commit }, payload) {
|
|
commit('setLinesUpdate', payload)
|
|
commit('setLinesUpdate', payload)
|
|
|
|
+ commit('setShowStatementLine', false)
|
|
|
|
+ commit('setLineSelected', null)
|
|
},
|
|
},
|
|
showStatementLineModify({ commit }, payload) {
|
|
showStatementLineModify({ commit }, payload) {
|
|
commit('setShowStatementLine', payload)
|
|
commit('setShowStatementLine', payload)
|
|
},
|
|
},
|
|
resetStatementLine({ commit }) {
|
|
resetStatementLine({ commit }) {
|
|
- commit('setLines', [])
|
|
|
|
- commit('setLineSelected', null)
|
|
|
|
- commit('setLinesDeleted', [])
|
|
|
|
- commit('setLinesUpdate', [])
|
|
|
|
- commit('setShowStatementLine', [])
|
|
|
|
|
|
+ commit('setResetLines')
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|