add modules folder based on s_menu
This commit is contained in:
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