Flatten nested repos
This commit is contained in:
128
test/vuex/one-fo-registration-dev/modules/company.js
Normal file
128
test/vuex/one-fo-registration-dev/modules/company.js
Normal file
@@ -0,0 +1,128 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/company.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
search: '',
|
||||
search_status:0,
|
||||
search_error_message:'',
|
||||
companies: [],
|
||||
total_company: 0,
|
||||
selected_company: {},
|
||||
selected_mou: {},
|
||||
|
||||
selected_px_tab: 'px'
|
||||
},
|
||||
mutations: {
|
||||
update_selected_px_tab(state,tab) {
|
||||
state.selected_px_tab = tab
|
||||
},
|
||||
|
||||
|
||||
update_search_error_message(state,status) {
|
||||
state.search_error_message = status
|
||||
},
|
||||
update_selected_mou(state,val) {
|
||||
state.selected_mou = val
|
||||
},
|
||||
update_search(state,val) {
|
||||
state.search=val
|
||||
},
|
||||
update_search_status(state,status) {
|
||||
state.search_status = status
|
||||
},
|
||||
update_companies(state,data) {
|
||||
state.companies= data.records
|
||||
state.total_company= data.total
|
||||
},
|
||||
update_selected_company(state,val) {
|
||||
state.selected_company=val
|
||||
},
|
||||
|
||||
reset_company(state) {
|
||||
state.companies = []
|
||||
state.total_company = 0
|
||||
state.search = ""
|
||||
state.selected_company = {}
|
||||
state.selected_mou = {}
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async search(context, prm) {
|
||||
context.commit("update_search_status",1)
|
||||
try {
|
||||
let resp= await api.search(context.state.search)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",resp.message)
|
||||
} else {
|
||||
context.commit("update_search_status",2)
|
||||
context.commit("update_search_error_message","")
|
||||
let data = {
|
||||
records : resp.data.records,
|
||||
total: resp.data.total
|
||||
}
|
||||
context.commit("update_companies",data)
|
||||
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
},
|
||||
|
||||
async search_default(context) {
|
||||
context.commit("update_search_status",1)
|
||||
try {
|
||||
let resp= await api.search_default()
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message", resp.message)
|
||||
} else {
|
||||
context.commit("update_search_status",2)
|
||||
context.commit("update_search_error_message","")
|
||||
let data = {
|
||||
records : resp.data.records,
|
||||
total: resp.data.total
|
||||
}
|
||||
context.commit("update_companies", data)
|
||||
context.commit("update_selected_company", data.records[0])
|
||||
|
||||
for(let i in data.records[0].mou) {
|
||||
let cmou = data.records[0].mou[i]
|
||||
if (cmou.M_MouIsDefault == "Y") {
|
||||
context.commit("update_selected_mou", cmou)
|
||||
|
||||
if (cmou.M_MouEmail != "" && cmou.M_MouEmailIsDefault == "Y") {
|
||||
let dlv = context.rootState.delivery.checked_id
|
||||
// if (dlv == undefined) dlv = []
|
||||
|
||||
if (dlv.indexOf(cmou.delivery_email_code) < 0) {
|
||||
|
||||
// console.log(cid)
|
||||
dlv.push(cmou.delivery_email_code)
|
||||
console.log(dlv)
|
||||
context.commit('delivery/update_checked_id', dlv, {root:true})
|
||||
}
|
||||
}
|
||||
|
||||
context.commit("delivery/update_params", {m_id:cmou.M_MouID}, {root:true})
|
||||
context.dispatch("delivery/search", null, {root:true})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// search px
|
||||
context.dispatch('px/search', null, {root:true})
|
||||
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user