add modules folder based on s_menu
This commit is contained in:
135
test/vuex/acc-one-transfer-req/modules/np_data.js
Normal file
135
test/vuex/acc-one-transfer-req/modules/np_data.js
Normal file
@@ -0,0 +1,135 @@
|
||||
import * as api from "../api/nonpersediaan_api.js";
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
user: one_user(),
|
||||
user_level: {},
|
||||
filter_sdate: new Date().toISOString().substr(0, 10),
|
||||
filter_edate: new Date().toISOString().substr(0, 10),
|
||||
filter_cabang: {
|
||||
M_BranchID: "0",
|
||||
M_BranchCode: "All",
|
||||
M_BranchName: "Semua"
|
||||
},
|
||||
filter_status: "All",
|
||||
filter_search: "",
|
||||
listing_cabang: [],
|
||||
listing_status: [
|
||||
"All",
|
||||
"Draft",
|
||||
"Verified",
|
||||
"Process",
|
||||
"Completed"
|
||||
],
|
||||
|
||||
listing_tf_req: {
|
||||
total: 0,
|
||||
records: []
|
||||
},
|
||||
listing_tf_page: 1,
|
||||
selected_tf: {}
|
||||
},
|
||||
mutations: {
|
||||
update_filter_sdate(state, data) {
|
||||
state.filter_sdate = data
|
||||
},
|
||||
update_filter_edate(state, data) {
|
||||
state.filter_edate = data
|
||||
},
|
||||
update_filter_cabang(state, data) {
|
||||
state.filter_cabang = data
|
||||
},
|
||||
update_filter_status(state, data) {
|
||||
state.filter_status = data
|
||||
},
|
||||
update_filter_search(state, data) {
|
||||
state.filter_search = data
|
||||
},
|
||||
update_listing_cabang(state, data) {
|
||||
state.listing_cabang = data
|
||||
},
|
||||
update_listing_status(state, data) {
|
||||
state.listing_status = data
|
||||
},
|
||||
update_listing_tf_req(state, data) {
|
||||
state.listing_tf_req = data
|
||||
},
|
||||
update_listing_tf_page(state, data) {
|
||||
state.listing_tf_page = data
|
||||
},
|
||||
update_selected_tf(state, data) {
|
||||
state.selected_tf = data
|
||||
},
|
||||
update_user_level(state, data) {
|
||||
state.user_level = data
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async getBranches(context) {
|
||||
try {
|
||||
let params = {
|
||||
token: one_token(),
|
||||
S_RegionalID: context.state.user.S_RegionalID
|
||||
}
|
||||
|
||||
let resp = await api.getBranches(params);
|
||||
if (resp.status != 'OK') {
|
||||
let snac = { isOpen: true, color: "error", msg: "Gagal, " + resp.message }
|
||||
context.commit("p_data/update_snackbar", snac, { root: true })
|
||||
} else {
|
||||
let all = [
|
||||
{
|
||||
M_BranchID: "0",
|
||||
M_BranchCode: "All",
|
||||
M_BranchName: "Semua"
|
||||
}
|
||||
]
|
||||
all.concat(resp.data.records)
|
||||
context.commit("update_listing_cabang", all)
|
||||
}
|
||||
} catch (error) {
|
||||
let snac = { isOpen: true, color: "error", msg: "Gagal, " + error.message }
|
||||
context.commit("p_data/update_snackbar", snac, { root: true })
|
||||
}
|
||||
},
|
||||
async cariTF(context) {
|
||||
try {
|
||||
let params = {
|
||||
token: one_token(),
|
||||
startDate: context.state.filter_sdate,
|
||||
endDate: context.state.filter_edate,
|
||||
M_BranchCode: context.state.filter_cabang.M_BranchCode,
|
||||
StatusName: context.state.filter_status,
|
||||
currentPage: context.state.listing_tf_page,
|
||||
search: context.state.filter_search
|
||||
}
|
||||
|
||||
let resp = await api.search(params)
|
||||
if (resp.status != "OK") {
|
||||
let snac = { isOpen: true, color: "error", msg: "Gagal, " + resp.message }
|
||||
context.commit("p_data/update_snackbar", snac, { root: true })
|
||||
} else [
|
||||
context.commit("update_listing_tf_req", resp.data)
|
||||
]
|
||||
} catch (error) {
|
||||
let snac = { isOpen: true, color: "error", msg: "Gagal, " + error.message }
|
||||
context.commit("p_data/update_snackbar", snac, { root: true })
|
||||
}
|
||||
},
|
||||
async userLevel(context) {
|
||||
try {
|
||||
let resp = await api.getUserLevel({token: one_token()})
|
||||
if (resp.status != 'OK') {
|
||||
let snac = { isOpen: true, color: "error", msg: "Gagal, " + resp.message }
|
||||
context.commit("p_data/update_snackbar", snac, { root: true })
|
||||
} else {
|
||||
context.commit("update_user_level", resp.data)
|
||||
}
|
||||
} catch (error) {
|
||||
let snac = { isOpen: true, color: "error", msg: "Gagal, " + error.message }
|
||||
context.commit("p_data/update_snackbar", snac, { root: true })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
307
test/vuex/acc-one-transfer-req/modules/np_form.js
Normal file
307
test/vuex/acc-one-transfer-req/modules/np_form.js
Normal file
@@ -0,0 +1,307 @@
|
||||
import * as api from "../api/nonpersediaan_api.js";
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
user: one_user(),
|
||||
form_transfer_date: new Date().toISOString().substr(0, 10),
|
||||
form_cabang: {},
|
||||
form_divisi: {},
|
||||
form_catatan: "",
|
||||
form_detail: [],
|
||||
|
||||
dialog_detailform: false,
|
||||
list_cabangform: [],
|
||||
list_divisiform: [],
|
||||
list_detailform: {
|
||||
total: 0,
|
||||
records: []
|
||||
},
|
||||
list_detailform_page: 1,
|
||||
type_act: 'BARU',
|
||||
is_verif: 'Draft',
|
||||
|
||||
buffer_detailitem: {},
|
||||
dialog_batchitem: false,
|
||||
list_barnote: {},
|
||||
form_barnote: [],
|
||||
edit_qty: 'Eqty',
|
||||
act_verif: ''
|
||||
},
|
||||
mutations: {
|
||||
update_form_transfer_date(state, data) {
|
||||
state.form_transfer_date = data
|
||||
},
|
||||
update_form_cabang(state, data) {
|
||||
state.form_cabang = data
|
||||
},
|
||||
update_form_divisi(state, data) {
|
||||
state.form_divisi = data
|
||||
},
|
||||
update_form_catatan(state, data) {
|
||||
state.form_catatan = data
|
||||
},
|
||||
update_form_detail(state, data) {
|
||||
state.form_detail = data
|
||||
},
|
||||
update_dialog_detailform(state, data) {
|
||||
state.dialog_detailform = data
|
||||
},
|
||||
update_list_cabangform(state, data) {
|
||||
state.list_cabangform = data
|
||||
},
|
||||
update_list_divisiform(state, data) {
|
||||
state.list_divisiform = data
|
||||
},
|
||||
update_list_detailform(state, data) {
|
||||
state.list_detailform = data
|
||||
},
|
||||
update_list_detailform_page(state, data) {
|
||||
state.list_detailform_page = data
|
||||
},
|
||||
update_type_act(state, data) {
|
||||
state.type_act = data
|
||||
},
|
||||
update_is_verif(state, data) {
|
||||
state.is_verif = data
|
||||
},
|
||||
update_buffer_detailitem(state, data) {
|
||||
state.buffer_detailitem = data
|
||||
},
|
||||
update_list_barnote(state, data) {
|
||||
state.list_barnote = data
|
||||
},
|
||||
update_dialog_batchitem(state, data) {
|
||||
state.dialog_batchitem = data
|
||||
},
|
||||
update_form_barnote(state, data) {
|
||||
state.form_barnote = data
|
||||
},
|
||||
update_edit_qty(state, data) {
|
||||
state.edit_qty = data
|
||||
},
|
||||
update_act_verif(state, data) {
|
||||
state.act_verif = data
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async newForm(context) {
|
||||
try {
|
||||
let params = {
|
||||
token: one_token(),
|
||||
S_RegionalID: context.state.user.S_RegionalID
|
||||
}
|
||||
let resp = await api.getBranches(params)
|
||||
if (resp.status != "OK") {
|
||||
let snac = { isOpen: true, color: "error", msg: "Gagal, " + resp.message }
|
||||
context.commit("p_data/update_snackbar", snac, { root: true })
|
||||
} else {
|
||||
context.commit("update_type_act", "BARU")
|
||||
context.commit("update_list_cabangform", resp.data.records)
|
||||
context.dispatch("getDivisi", {})
|
||||
|
||||
context.commit("update_form_transfer_date", new Date().toISOString().substr(0, 10))
|
||||
context.commit("update_form_cabang", { })
|
||||
context.commit("update_form_divisi", { })
|
||||
context.commit("update_form_catatan", "")
|
||||
context.commit("update_list_detailform", {total: 0, records: []})
|
||||
context.commit("update_is_verif", 'Draft')
|
||||
context.commit("update_form_detail", [ ])
|
||||
context.commit("np_data/update_selected_tf", { }, { root: true })
|
||||
}
|
||||
|
||||
|
||||
} catch (error) {
|
||||
let snac = { isOpen: true, color: "error", msg: "Gagal, " + error.message }
|
||||
context.commit("p_data/update_snackbar", snac, { root: true })
|
||||
}
|
||||
},
|
||||
async getDivisi(context) {
|
||||
try {
|
||||
let params = {token: one_token()}
|
||||
|
||||
let resp = await api.getDivision(params);
|
||||
if (resp.status != 'OK') {
|
||||
let snac = { isOpen: true, color: "error", msg: "Gagal, " + resp.message }
|
||||
context.commit("p_data/update_snackbar", snac, { root: true })
|
||||
} else {
|
||||
context.commit("update_list_divisiform", resp.data)
|
||||
}
|
||||
} catch (error) {
|
||||
let snac = { isOpen: true, color: "error", msg: "Gagal, " + error.message }
|
||||
context.commit("p_data/update_snackbar", snac, { root: true })
|
||||
}
|
||||
},
|
||||
async getListItemDetail(context) {
|
||||
try {
|
||||
let params = {
|
||||
token: one_token(),
|
||||
currpage: context.state.list_detailform_page,
|
||||
regionalid: context.state.user.S_RegionalID,
|
||||
branchcodedestin: context.state.form_cabang.M_BranchCode,
|
||||
branchIDorigin: context.state.user.M_BranchID,
|
||||
divisionID: context.state.form_divisi.DivisionID
|
||||
}
|
||||
|
||||
let resp = await api.getListDetail(params)
|
||||
if (resp.status != 'OK') {
|
||||
let snac = { isOpen: true, color: "error", msg: "Gagal, " + resp.message }
|
||||
context.commit("p_data/update_snackbar", snac, { root: true })
|
||||
} else {
|
||||
const current_detail = context.state.form_detail
|
||||
if (current_detail.length == 0) {
|
||||
context.commit("update_list_detailform", resp.data)
|
||||
} else {
|
||||
const inserted = resp.data.records.filter(item => !current_detail.some(obj => obj.PurchaseRequestFlagID == item.PurchaseRequestFlagID))
|
||||
let data = {
|
||||
records: inserted,
|
||||
total: parseInt(resp.data.total)
|
||||
}
|
||||
context.commit("update_list_detailform", data)
|
||||
}
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
let snac = { isOpen: true, color: "error", msg: "Gagal, " + error.message }
|
||||
context.commit("p_data/update_snackbar", snac, { root: true })
|
||||
}
|
||||
},
|
||||
async createTFReq(context) {
|
||||
try {
|
||||
let params = {
|
||||
token: one_token(),
|
||||
S_RegionalID: context.state.user.S_RegionalID,
|
||||
M_BranchCode: context.state.form_cabang.M_BranchCode,
|
||||
DivisionID: context.state.form_divisi.DivisionID,
|
||||
GoodsTfNotes: context.state.form_catatan,
|
||||
GoodsTfDate: context.state.form_transfer_date,
|
||||
GoodsTfStatus: context.state.is_verif,
|
||||
detail: context.state.form_detail
|
||||
}
|
||||
|
||||
let resp = await api.createTfRequest(params);
|
||||
if (resp.status != 'OK') {
|
||||
let snac = { isOpen: true, color: "error", msg: "Gagal, " + resp.message }
|
||||
context.commit("p_data/update_snackbar", snac, { root: true })
|
||||
} else {
|
||||
// generate surat jalan atau nggak?
|
||||
|
||||
context.dispatch("newForm")
|
||||
context.dispatch("np_data/cariTF", { }, { root: true })
|
||||
let snac = { isOpen: true, color: "success", msg: "Success" }
|
||||
context.commit("p_data/update_snackbar", snac, { root: true })
|
||||
}
|
||||
} catch (error) {
|
||||
let snac = { isOpen: true, color: "error", msg: "Gagal, " + error.message }
|
||||
context.commit("p_data/update_snackbar", snac, { root: true })
|
||||
}
|
||||
},
|
||||
async updateTFReq(context) {
|
||||
try {
|
||||
let params = {
|
||||
token: one_token(),
|
||||
S_RegionalID: context.state.user.S_RegionalID,
|
||||
M_BranchCode: context.state.form_cabang.M_BranchCode,
|
||||
DivisionID: context.state.form_divisi.DivisionID,
|
||||
GoodsTfID: context.rootState.np_data.selected_tf.T_GoodsTransferID,
|
||||
GoodsTfNum: context.rootState.np_data.selected_tf.T_GoodsTransferNum,
|
||||
GoodsTfNotes: context.state.form_catatan,
|
||||
GoodsTfDate: context.state.form_transfer_date,
|
||||
GoodsTfStatus: context.state.is_verif,
|
||||
editqty: context.state.edit_qty,
|
||||
actverif: context.state.act_verif,
|
||||
detail: context.state.form_detail
|
||||
}
|
||||
|
||||
let resp = await api.updateTfRequest(params);
|
||||
if (resp.status != 'OK') {
|
||||
let snac = { isOpen: true, color: "error", msg: "Gagal, " + resp.message }
|
||||
context.commit("p_data/update_snackbar", snac, { root: true })
|
||||
} else {
|
||||
// generate surat jalan atau nggak?
|
||||
|
||||
context.dispatch("newForm")
|
||||
context.dispatch("np_data/cariTF", { }, { root: true })
|
||||
let snac = { isOpen: true, color: "success", msg: "Success" }
|
||||
context.commit("p_data/update_snackbar", snac, { root: true })
|
||||
}
|
||||
} catch (error) {
|
||||
let snac = { isOpen: true, color: "error", msg: "Gagal, " + error.message }
|
||||
context.commit("p_data/update_snackbar", snac, { root: true })
|
||||
}
|
||||
},
|
||||
async deleteTFReq(context, params) {
|
||||
try {
|
||||
params.token = one_token()
|
||||
let resp = await api.deleteTfRequest(params);
|
||||
if (resp.status != 'OK') {
|
||||
let snac = { isOpen: true, color: "error", msg: "Gagal, " + resp.message }
|
||||
context.commit("p_data/update_snackbar", snac, { root: true })
|
||||
} else {
|
||||
context.dispatch("newForm")
|
||||
context.dispatch("p_data/cariTF", { }, { root: true })
|
||||
|
||||
let snac = { isOpen: true, color: "success", msg: resp.data}
|
||||
context.commit("p_data/update_snackbar", snac, { root: true })
|
||||
}
|
||||
} catch (error) {
|
||||
let snac = { isOpen: true, color: "error", msg: "Gagal, " + error.message }
|
||||
context.commit("p_data/update_snackbar", snac, { root: true })
|
||||
}
|
||||
},
|
||||
async displayDetail(context) {
|
||||
try {
|
||||
let detail = context.rootState.np_data.selected_tf
|
||||
context.commit("update_form_transfer_date", detail.T_GoodsTransferDate)
|
||||
context.commit("update_form_catatan", detail.T_GoodsTransferNotes)
|
||||
context.commit("update_is_verif", detail.T_GoodsTransferStatus)
|
||||
|
||||
context.commit("update_form_cabang", {
|
||||
M_BranchID: detail.M_BranchID,
|
||||
M_BranchCode: detail.M_BranchCode,
|
||||
M_BranchName: detail.M_BranchName
|
||||
})
|
||||
|
||||
context.commit("update_form_divisi", {
|
||||
DivisionID: detail.T_GoodsTransferDivisionID,
|
||||
DivisionCode: detail.DivisionCode,
|
||||
DivisionName: detail.DivisionName
|
||||
})
|
||||
|
||||
let params = {
|
||||
token: one_token(),
|
||||
goodTfID: detail.T_GoodsTransferID
|
||||
}
|
||||
const resp = await api.getDraftDetail(params)
|
||||
if (resp.status !== 'OK') {
|
||||
let snac = { isOpen: true, color: "error", msg: "Gagal, " + resp.message }
|
||||
context.commit("p_data/update_snackbar", snac, { root: true })
|
||||
} else {
|
||||
const draft = resp.data.records
|
||||
context.commit("update_form_detail", draft);
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
let snac = { isOpen: true, color: "error", msg: "Gagal, " + error.message }
|
||||
context.commit("p_data/update_snackbar", snac, { root: true })
|
||||
}
|
||||
},
|
||||
async getListStock(context, params) {
|
||||
try {
|
||||
params.token = one_token()
|
||||
params.regionalid = context.state.user.S_RegionalID
|
||||
|
||||
const resp = await api.getListStock(params)
|
||||
if (resp.status !== 'OK') {
|
||||
let snac = { isOpen: true, color: "error", msg: "Gagal, " + resp.message }
|
||||
context.commit("p_data/update_snackbar", snac, { root: true })
|
||||
} else {
|
||||
context.commit("update_list_barnote", resp.data)
|
||||
}
|
||||
} catch (error) {
|
||||
let snac = { isOpen: true, color: "error", msg: "Gagal, " + error.message }
|
||||
context.commit("p_data/update_snackbar", snac, { root: true })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
169
test/vuex/acc-one-transfer-req/modules/p_data.js
Normal file
169
test/vuex/acc-one-transfer-req/modules/p_data.js
Normal file
@@ -0,0 +1,169 @@
|
||||
import * as api from "../api/persediaan_api.js";
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
user: one_user(),
|
||||
user_level: {},
|
||||
filter_sdate: new Date().toISOString().substr(0, 10),
|
||||
filter_edate: new Date().toISOString().substr(0, 10),
|
||||
filter_cabang: {
|
||||
M_BranchID: "0",
|
||||
M_BranchCode: "All",
|
||||
M_BranchName: "Semua"
|
||||
},
|
||||
filter_status: "All",
|
||||
filter_search: "",
|
||||
listing_cabang: [],
|
||||
listing_status: [
|
||||
"All",
|
||||
"Draft",
|
||||
"Pending",
|
||||
"Verified",
|
||||
"Approved",
|
||||
"Process",
|
||||
"Completed"
|
||||
],
|
||||
|
||||
listing_tf_req: {
|
||||
total: 0,
|
||||
records: []
|
||||
},
|
||||
listing_tf_page: 1,
|
||||
selected_tf: {},
|
||||
|
||||
snackbar: {
|
||||
isOpen: false,
|
||||
color: "error",
|
||||
msg: ""
|
||||
}
|
||||
},
|
||||
mutations: {
|
||||
update_filter_sdate(state, data) {
|
||||
state.filter_sdate = data
|
||||
},
|
||||
update_filter_edate(state, data) {
|
||||
state.filter_edate = data
|
||||
},
|
||||
update_filter_cabang(state, data) {
|
||||
state.filter_cabang = data
|
||||
},
|
||||
update_filter_status(state, data) {
|
||||
state.filter_status = data
|
||||
},
|
||||
update_filter_search(state, data) {
|
||||
state.filter_search = data
|
||||
},
|
||||
update_listing_cabang(state, data) {
|
||||
state.listing_cabang = data
|
||||
},
|
||||
update_listing_status(state, data) {
|
||||
state.listing_status = data
|
||||
},
|
||||
update_listing_tf_req(state, data) {
|
||||
state.listing_tf_req = data
|
||||
},
|
||||
update_listing_tf_page(state, data) {
|
||||
state.listing_tf_page = data
|
||||
},
|
||||
update_selected_tf(state, data) {
|
||||
state.selected_tf = data
|
||||
},
|
||||
update_snackbar(state, data) {
|
||||
state.snackbar = data
|
||||
},
|
||||
update_user_level(state, data) {
|
||||
state.user_level = data
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async getBranches(context) {
|
||||
try {
|
||||
let params = {
|
||||
token: one_token(),
|
||||
S_RegionalID: context.state.user.S_RegionalID
|
||||
}
|
||||
let resp = await api.getBranches(params)
|
||||
if (resp.status != "OK") {
|
||||
let snac = { isOpen: true, color: "error", msg: "Gagal, " + resp.message }
|
||||
context.commit("update_snackbar", snac)
|
||||
} else {
|
||||
let all = [
|
||||
{
|
||||
M_BranchID: "0",
|
||||
M_BranchCode: "All",
|
||||
M_BranchName: "Semua"
|
||||
}
|
||||
]
|
||||
|
||||
all = all.concat(resp.data.records)
|
||||
context.commit("update_listing_cabang", all)
|
||||
}
|
||||
} catch (error) {
|
||||
let snac = { isOpen: true, color: "error", msg: "Gagal, " + error.message }
|
||||
context.commit("update_snackbar", snac)
|
||||
}
|
||||
},
|
||||
async cariTF(context) {
|
||||
try {
|
||||
let params = {
|
||||
token: one_token(),
|
||||
startDate: context.state.filter_sdate,
|
||||
endDate: context.state.filter_edate,
|
||||
M_BranchCode: context.state.filter_cabang.M_BranchCode,
|
||||
StatusName: context.state.filter_status,
|
||||
currentPage: context.state.listing_tf_page,
|
||||
search: context.state.filter_search
|
||||
}
|
||||
|
||||
let resp = await api.search(params)
|
||||
if (resp.status != "OK") {
|
||||
let snac = { isOpen: true, color: "error", msg: "Gagal, " + resp.message }
|
||||
context.commit("update_snackbar", snac)
|
||||
} else {
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total: parseInt(resp.data.total)
|
||||
}
|
||||
context.commit("update_listing_tf_req", data)
|
||||
}
|
||||
} catch (error) {
|
||||
let snac = { isOpen: true, color: "error", msg: "Gagal, " + error.message }
|
||||
context.commit("update_snackbar", snac)
|
||||
}
|
||||
},
|
||||
async deleteTF(context, params) {
|
||||
try {
|
||||
params.token = one_token()
|
||||
let resp = await api.deleteTransfer(params)
|
||||
if (resp.status != "OK") {
|
||||
let snac = { isOpen: true, color: "error", msg: "Gagal, " + resp.message }
|
||||
context.commit("update_snackbar", snac)
|
||||
} else {
|
||||
context.dispatch("p_form/newForm", { },{ root: true })
|
||||
context.dispatch("cariTF")
|
||||
|
||||
let snac = { isOpen: true, color: "success", msg: "Sukses"}
|
||||
context.commit("update_snackbar", snac)
|
||||
}
|
||||
} catch (error) {
|
||||
let snac = { isOpen: true, color: "error", msg: "Gagal, " + error.message }
|
||||
context.commit("update_snackbar", snac)
|
||||
}
|
||||
},
|
||||
async userlevel(context) {
|
||||
try {
|
||||
let resp = await api.getUserLevel({token: one_token()})
|
||||
if (resp.status != 'OK') {
|
||||
let snac = { isOpen: true, color: "error", msg: "Gagal, " + resp.message }
|
||||
context.commit("update_snackbar", snac)
|
||||
} else {
|
||||
context.commit("update_user_level", resp.data);
|
||||
}
|
||||
} catch (error) {
|
||||
let snac = { isOpen: true, color: "error", msg: "Gagal, " + error.message }
|
||||
context.commit("update_snackbar", snac)
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
316
test/vuex/acc-one-transfer-req/modules/p_form.js
Normal file
316
test/vuex/acc-one-transfer-req/modules/p_form.js
Normal file
@@ -0,0 +1,316 @@
|
||||
import * as api from "../api/persediaan_api.js";
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
user: one_user(),
|
||||
form_transfer_date: new Date().toISOString().substr(0, 10),
|
||||
form_cabang: {},
|
||||
form_catatan: "",
|
||||
form_detail: [],
|
||||
|
||||
dialog_detailform: false,
|
||||
list_cabangform: [],
|
||||
list_detailform: {
|
||||
total: 0,
|
||||
records: []
|
||||
},
|
||||
list_detailform_page: 1,
|
||||
type_act: 'BARU',
|
||||
is_verif: 'Draft',
|
||||
|
||||
buffer_detailitem: {},
|
||||
list_batchitemform: {},
|
||||
dialog_batchitem: false,
|
||||
form_batchitem: [],
|
||||
|
||||
dialog_unpackform: false,
|
||||
buffer_itemrequestedunpack: {},
|
||||
list_batchitemunpack: [],
|
||||
selected_batchitemunpack: {},
|
||||
edit_qty: 'Eqty',
|
||||
act_verif: ''
|
||||
},
|
||||
mutations: {
|
||||
update_form_transfer_date(state, data) {
|
||||
state.form_transfer_date = data
|
||||
},
|
||||
update_form_cabang(state, data) {
|
||||
state.form_cabang = data
|
||||
},
|
||||
update_form_catatan(state, data) {
|
||||
state.form_catatan = data
|
||||
},
|
||||
update_form_detail(state, data) {
|
||||
state.form_detail = data
|
||||
},
|
||||
update_dialog_detailform(state, data) {
|
||||
state.dialog_detailform = data
|
||||
},
|
||||
update_list_cabangform(state, data) {
|
||||
state.list_cabangform = data
|
||||
},
|
||||
update_list_detailform(state, data) {
|
||||
state.list_detailform = data
|
||||
},
|
||||
update_list_detailform_page(state, data) {
|
||||
state.list_detailform_page = data
|
||||
},
|
||||
update_type_act(state, data) {
|
||||
state.type_act = data
|
||||
},
|
||||
update_is_verif(state, data) {
|
||||
state.is_verif = data
|
||||
},
|
||||
update_buffer_detailitem(state, data) {
|
||||
state.buffer_detailitem = data
|
||||
},
|
||||
update_list_batchitemform(state, data) {
|
||||
state.list_batchitemform = data
|
||||
},
|
||||
update_dialog_batchitem(state, data) {
|
||||
state.dialog_batchitem = data
|
||||
},
|
||||
update_form_batchitem(state, data) {
|
||||
state.form_batchitem = data
|
||||
},
|
||||
update_dialog_unpackform(state, data){
|
||||
state.dialog_unpackform = data
|
||||
},
|
||||
update_buffer_itemrequestedunpack(state, data){
|
||||
state.buffer_itemrequestedunpack = data
|
||||
},
|
||||
update_list_batchitemunpack(state, data){
|
||||
state.list_batchitemunpack = data
|
||||
},
|
||||
update_selected_batchitemunpack(state, data){
|
||||
state.selected_batchitemunpack = data
|
||||
},
|
||||
update_edit_qty(state, data) {
|
||||
state.edit_qty = data
|
||||
},
|
||||
update_act_verif(state, data) {
|
||||
state.act_verif = data
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async newForm(context) {
|
||||
try {
|
||||
let params = {
|
||||
token: one_token(),
|
||||
S_RegionalID: context.state.user.S_RegionalID
|
||||
}
|
||||
let resp = await api.getBranches(params)
|
||||
if (resp.status != "OK") {
|
||||
let snac = { isOpen: true, color: "error", msg: "Gagal, " + resp.message }
|
||||
context.commit("p_data/update_snackbar", snac, { root: true })
|
||||
} else {
|
||||
context.commit("update_type_act", "BARU")
|
||||
context.commit("update_list_cabangform", resp.data.records)
|
||||
|
||||
context.commit("update_form_cabang", { })
|
||||
context.commit("update_form_transfer_date", new Date().toISOString().substr(0, 10))
|
||||
context.commit("update_form_catatan", "")
|
||||
context.commit("update_list_detailform", {total: 0, records: [ ]})
|
||||
context.commit("update_is_verif", 'Draft')
|
||||
context.commit("update_form_detail", [ ])
|
||||
context.commit("p_data/update_selected_tf" , {}, { root: true })
|
||||
}
|
||||
} catch (error) {
|
||||
let snac = { isOpen: true, color: "error", msg: "Gagal, " + error.message }
|
||||
context.commit("p_data/update_snackbar", snac, { root: true })
|
||||
}
|
||||
},
|
||||
async displayDetail(context) {
|
||||
try {
|
||||
let detail = context.rootState.p_data.selected_tf
|
||||
context.commit("update_form_transfer_date", detail.T_GoodsTransferDate)
|
||||
context.commit("update_form_catatan", detail.T_GoodsTransferNotes)
|
||||
context.commit("update_is_verif", detail.T_GoodsTransferStatus)
|
||||
context.commit("update_form_cabang", {
|
||||
M_BranchID: detail.M_BranchID,
|
||||
M_BranchCode: detail.M_BranchCode,
|
||||
M_BranchName: detail.M_BranchName
|
||||
})
|
||||
|
||||
// get list detail item form
|
||||
let params = {
|
||||
token: one_token(),
|
||||
goodTfID: detail.T_GoodsTransferID
|
||||
}
|
||||
let resp = await api.getDraftDetail(params);
|
||||
if (resp.status !== 'OK') {
|
||||
let snac = { isOpen: true, color: "error", msg: "Gagal, " + resp.message }
|
||||
context.commit("p_data/update_snackbar", snac, { root: true })
|
||||
} else {
|
||||
let draft = resp.data.records
|
||||
context.commit("update_form_detail", draft)
|
||||
}
|
||||
} catch (error) {
|
||||
let snac = { isOpen: true, color: "error", msg: "Gagal, " + error.message }
|
||||
context.commit("p_data/update_snackbar", snac, { root: true })
|
||||
}
|
||||
},
|
||||
async getListItemDetail(context) {
|
||||
try {
|
||||
let params = {
|
||||
token: one_token(),
|
||||
currpage: context.state.list_detailform_page,
|
||||
regionalid: context.state.user.S_RegionalID,
|
||||
branchcodedestin: context.state.form_cabang.M_BranchCode,
|
||||
branchIDorigin: context.state.user.M_BranchID
|
||||
}
|
||||
|
||||
let resp = await api.getListDetail(params)
|
||||
if (resp.status != 'OK') {
|
||||
let snac = { isOpen: true, color: "error", msg: "Gagal, " + resp.message }
|
||||
context.commit("p_data/update_snackbar", snac, { root: true })
|
||||
} else {
|
||||
let current_detail = context.state.form_detail
|
||||
if (current_detail.length == 0) {
|
||||
context.commit("update_list_detailform", resp.data)
|
||||
} else {
|
||||
const inserted = resp.data.records.filter(item => !current_detail.some(obj => obj.PurchaseRequestFlagID == item.PurchaseRequestFlagID))
|
||||
let data = {
|
||||
records: inserted,
|
||||
total: parseInt(resp.data.total)
|
||||
}
|
||||
context.commit("update_list_detailform", data)
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
let snac = { isOpen: true, color: "error", msg: "Gagal, " + error.message }
|
||||
context.commit("p_data/update_snackbar", snac, { root: true })
|
||||
}
|
||||
},
|
||||
async createTFrequest(context) {
|
||||
try {
|
||||
let params = {
|
||||
token: one_token(),
|
||||
S_RegionalID: context.state.user.S_RegionalID,
|
||||
M_BranchCode: context.state.form_cabang.M_BranchCode,
|
||||
GoodsTfNotes: context.state.form_catatan,
|
||||
GoodsTfDate: context.state.form_transfer_date,
|
||||
GoodsTfStatus: context.state.is_verif,
|
||||
detail: context.state.form_detail
|
||||
}
|
||||
|
||||
let resp = await api.saveRequest(params)
|
||||
|
||||
if (resp.status !== 'OK') {
|
||||
let snac = { isOpen: true, color: "error", msg: "Gagal, " + resp.message }
|
||||
context.commit("p_data/update_snackbar", snac, { root: true })
|
||||
} else {
|
||||
if (params.GoodsTfStatus === 'Verified') {
|
||||
params.GoodsTfNum = resp.data.records.T_GoodsTransferNum
|
||||
params.GoodsTfID = resp.data.records.T_GoodsTransferID
|
||||
params.detail = resp.data.records.detail
|
||||
}
|
||||
|
||||
context.dispatch("newForm")
|
||||
context.dispatch("p_data/cariTF", { }, { root: true })
|
||||
}
|
||||
} catch (error) {
|
||||
let snac = { isOpen: true, color: "error", msg: "Gagal, " + error.message }
|
||||
context.commit("p_data/update_snackbar", snac, { root: true })
|
||||
}
|
||||
},
|
||||
async updateTFrequest(context) {
|
||||
try {
|
||||
let params = {
|
||||
token: one_token(),
|
||||
S_RegionalID: context.state.user.S_RegionalID,
|
||||
M_BranchCode: context.state.form_cabang.M_BranchCode,
|
||||
GoodsTfID: context.rootState.p_data.selected_tf.T_GoodsTransferID,
|
||||
GoodsTfNum: context.rootState.p_data.selected_tf.T_GoodsTransferNum,
|
||||
GoodsTfNotes: context.state.form_catatan,
|
||||
GoodsTfDate: context.state.form_transfer_date,
|
||||
GoodsTfStatus: context.state.is_verif,
|
||||
editqty: context.state.edit_qty,
|
||||
actverif: context.state.act_verif,
|
||||
detail: context.state.form_detail
|
||||
}
|
||||
|
||||
let resp = await api.updateTransfer(params)
|
||||
if (resp.status != 'OK') {
|
||||
let snac = { isOpen: true, color: "error", msg: "Gagal, " + resp.message }
|
||||
context.commit("p_data/update_snackbar", snac, { root: true })
|
||||
} else {
|
||||
if (params.GoodsTfStatus === 'Verified') {
|
||||
params.detail = resp.data.records.detail
|
||||
}
|
||||
|
||||
context.dispatch("newForm")
|
||||
context.dispatch("p_data/cariTF", { }, { root: true })
|
||||
|
||||
if (context.state.edit_qty == 'Eqty') {
|
||||
var snac = { isOpen: true, color: 'success', msg: 'Success update qty tf request' }
|
||||
} else {
|
||||
var snac = { isOpen: true, color: 'success', msg: 'Success update tf request' }
|
||||
}
|
||||
context.commit("p_data/update_snackbar", snac, { root: true })
|
||||
}
|
||||
} catch (error) {
|
||||
let snac = { isOpen: true, color: "error", msg: "Gagal, " + error.message }
|
||||
context.commit("p_data/update_snackbar", snac, { root: true })
|
||||
}
|
||||
},
|
||||
async getBatchItemDetail(context, params) {
|
||||
try {
|
||||
params.token = one_token()
|
||||
params.regionalid = context.state.user.S_RegionalID
|
||||
params.branchid = context.state.user.M_BranchID
|
||||
|
||||
let resp = await api.getItemBatchListing(params)
|
||||
if (resp.status != 'OK') {
|
||||
let snac = { isOpen: true, color: "error", msg: "Gagal, " + resp.message }
|
||||
context.commit("p_data/update_snackbar", snac, { root: true })
|
||||
} else {
|
||||
context.commit("update_list_batchitemform", resp.data)
|
||||
}
|
||||
} catch (error) {
|
||||
let snac = { isOpen: true, color: "error", msg: "Gagal, " + error.message }
|
||||
context.commit("p_data/update_snackbar", snac, { root: true })
|
||||
}
|
||||
},
|
||||
async getBatchItemUnpackList(context, params){
|
||||
try{
|
||||
params.token = one_token()
|
||||
params.regionalid = context.state.user.S_RegionalID
|
||||
params.branchid = context.state.user.M_BranchID
|
||||
|
||||
let resp = await api.getUnpackItemBatchListing(params)
|
||||
if (resp.status != 'OK'){
|
||||
let snac = { isOpen: true, color: "error", msg: "Gagal, " + error.message }
|
||||
context.commit("p_data/update_snackbar", snac, { root: true })
|
||||
} else {
|
||||
context.commit("update_list_batchitemunpack", resp.data.records)
|
||||
}
|
||||
} catch (error) {
|
||||
let snac = { isOpen: true, color: "error", msg: "Gagal, " + error.message }
|
||||
context.commit("p_data/update_snackbar", snac, { root: true })
|
||||
}
|
||||
},
|
||||
async unpackingStock(context, params){
|
||||
try {
|
||||
params.token = one_token()
|
||||
|
||||
let resp = await api.unpackingStock(params)
|
||||
|
||||
if (resp.status != 'OK'){
|
||||
let snac = { isOpen: true, color: "error", msg: "Gagal, " + error.message }
|
||||
context.commit("p_data/update_snackbar", snac, { root: true })
|
||||
} else {
|
||||
let snac = { isOpen: true, color: "success", msg: "Berhasil Unpack Stock"}
|
||||
context.commit("p_data/update_snackbar", snac, { root: true })
|
||||
|
||||
// Reload Item Requested List Detail
|
||||
await context.dispatch("getListItemDetail")
|
||||
}
|
||||
} catch (error) {
|
||||
let snac = { isOpen: true, color: "error", msg: "Gagal, " + error.message }
|
||||
context.commit("p_data/update_snackbar", snac, { root: true })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user