Initial import
This commit is contained in:
165
one-ui/system/one-inject-price/modules/courier.js
Normal file
165
one-ui/system/one-inject-price/modules/courier.js
Normal file
@@ -0,0 +1,165 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/courier.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
couriers: [],
|
||||
loading: false,
|
||||
name: "",
|
||||
curr_page: 1,
|
||||
total: 0,
|
||||
error_dialog: false,
|
||||
error_message: "",
|
||||
is_courier: [],
|
||||
snackbar: false,
|
||||
snackbar_msg: ""
|
||||
// selected_courier: {},
|
||||
// current_page: 1,
|
||||
// last_id: -1,
|
||||
// x_search: "",
|
||||
// search_status: 0,
|
||||
|
||||
// // dropdown courier
|
||||
// namecouriers: [],
|
||||
// namecourier: {},
|
||||
|
||||
// autocomplete_status: 0,
|
||||
// save_status: 0,
|
||||
// error_message: "",
|
||||
// dialog_error: false,
|
||||
// alert_error: false,
|
||||
// msg_success: "",
|
||||
// alert_success: false,
|
||||
// get_data_status:0,
|
||||
// filter_branch: [],
|
||||
// selected_filter_branch: {},
|
||||
// filter_kurir: [],
|
||||
// selected_filter_kurir: {},
|
||||
// filter_status: [],
|
||||
// selected_filter_status: {},
|
||||
},
|
||||
mutations: {
|
||||
update_couriers(state, val) {
|
||||
state.couriers = val
|
||||
},
|
||||
update_total(state, val) {
|
||||
state.total = val;
|
||||
},
|
||||
update_loading(state, val) {
|
||||
state.loading = val;
|
||||
},
|
||||
update_error_message(state, val) {
|
||||
state.error_message = val;
|
||||
},
|
||||
update_name(state, val) {
|
||||
state.name = val;
|
||||
},
|
||||
update_curr_page(state, val) {
|
||||
state.curr_page = val;
|
||||
},
|
||||
update_is_courier(state, val) {
|
||||
state.is_courier = val;
|
||||
},
|
||||
update_snackbar(state, val) {
|
||||
state.snackbar = val;
|
||||
},
|
||||
update_snackbar_msg(state, val) {
|
||||
state.snackbar_msg = val;
|
||||
},
|
||||
update_error_dialog(state, val) {
|
||||
state.error_dialog = val;
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
async search(context) {
|
||||
context.commit("update_loading", true)
|
||||
try {
|
||||
// prm.token = one_token();
|
||||
var param = {
|
||||
"name": context.state.name,
|
||||
"page": context.state.curr_page,
|
||||
"token": one_token(),
|
||||
}
|
||||
let resp = await api.search(param);
|
||||
if (resp.status !== "OK") {
|
||||
context.commit("update_loading", false);
|
||||
context.commit("update_error_dialog", true);
|
||||
context.commit("update_error_message", resp);
|
||||
} else {
|
||||
context.commit("update_loading", false);
|
||||
console.log(resp.data);
|
||||
context.commit("update_couriers", resp.data.records)
|
||||
context.commit("update_total", resp.data.total);
|
||||
let isCourier = [];
|
||||
for (let i = 0; i < resp.data.records.length; i++) {
|
||||
if (resp.data.records[i].flag !== "N") {
|
||||
isCourier.push(resp.data.records[i].userID)
|
||||
}
|
||||
}
|
||||
context.commit("update_is_courier", isCourier);
|
||||
}
|
||||
} catch (error) {
|
||||
context.commit("update_loading", false);
|
||||
context.commit("update_error_dialog", true);
|
||||
context.commit("update_error_message", error);
|
||||
}
|
||||
},
|
||||
async add(context, prm) {
|
||||
context.commit("update_loading", true)
|
||||
try {
|
||||
prm.token = one_token();
|
||||
// prm.userID = one_user();
|
||||
let resp = await api.add(prm);
|
||||
if (resp.status !== "OK") {
|
||||
context.commit("update_loading", false);
|
||||
context.commit("update_error_message", resp);
|
||||
context.commit("update_error_dialog", true);
|
||||
} else {
|
||||
context.commit("update_loading", false);
|
||||
context.commit("update_snackbar", true);
|
||||
context.commit("update_snackbar_msg", "Berhasil Menambahkan Kurir");
|
||||
console.log(resp.data);
|
||||
// var tempCourrier = JSON.stringify(context.state.is_courier);
|
||||
// var arrCourier = JSON.parse(tempCourrier);
|
||||
// arrCourier.push(prm.userID);
|
||||
// context.commit("update_is_courier", arrCourier);
|
||||
context.dispatch("search");
|
||||
}
|
||||
} catch (error) {
|
||||
context.commit("update_loading", false);
|
||||
context.commit("update_error_message", error);
|
||||
context.commit("update_error_dialog", true);
|
||||
}
|
||||
},
|
||||
async deleteData(context, prm) {
|
||||
context.commit("update_loading", true)
|
||||
try {
|
||||
prm.token = one_token();
|
||||
// prm.userID = one_user();
|
||||
let resp = await api.deleteData(prm);
|
||||
if (resp.status !== "OK") {
|
||||
context.commit("update_loading", false);
|
||||
context.commit("update_error_message", resp);
|
||||
context.commit("update_error_dialog", true);
|
||||
} else {
|
||||
context.commit("update_loading", false);
|
||||
console.log(resp.data);
|
||||
context.commit("update_snackbar", true);
|
||||
context.commit("update_snackbar_msg", "Berhasil Menghapus Kurir");
|
||||
// var tempCourrier = JSON.stringify(context.state.is_courier);
|
||||
// var arrCourier = JSON.parse(tempCourrier);
|
||||
// arrCourier.filter((e) => e === prm.courierID);
|
||||
// context.commit("update_is_courier", arrCourier);
|
||||
context.dispatch("search");
|
||||
}
|
||||
} catch (error) {
|
||||
context.commit("update_loading", false);
|
||||
context.commit("update_error_message", error);
|
||||
context.commit("update_error_dialog", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
272
one-ui/system/one-inject-price/modules/holiday.js
Normal file
272
one-ui/system/one-inject-price/modules/holiday.js
Normal file
@@ -0,0 +1,272 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/holiday.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
couriers: [],
|
||||
type: [],
|
||||
selectedType: '',
|
||||
loading: false,
|
||||
date: moment(new Date()).format('YYYY-MM-DD'),
|
||||
yearFilter: moment(new Date()).format('YYYY'),
|
||||
year: moment(new Date()).format('YYYY'),
|
||||
name: "",
|
||||
curr_page: 1,
|
||||
total: 0,
|
||||
error_dialog: false,
|
||||
error_message: "",
|
||||
is_courier: [],
|
||||
snackbar: false,
|
||||
snackbar_msg: "",
|
||||
holidays: [],
|
||||
dialogForm: false,
|
||||
name: '',
|
||||
desc: '',
|
||||
selectedHoliday: {},
|
||||
dialog_delete: false
|
||||
// selected_courier: {},
|
||||
// current_page: 1,
|
||||
// last_id: -1,
|
||||
// x_search: "",
|
||||
// search_status: 0,
|
||||
|
||||
// // dropdown courier
|
||||
// namecouriers: [],
|
||||
// namecourier: {},
|
||||
|
||||
// autocomplete_status: 0,
|
||||
// save_status: 0,
|
||||
// error_message: "",
|
||||
// dialog_error: false,
|
||||
// alert_error: false,
|
||||
// msg_success: "",
|
||||
// alert_success: false,
|
||||
// get_data_status:0,
|
||||
// filter_branch: [],
|
||||
// selected_filter_branch: {},
|
||||
// filter_kurir: [],
|
||||
// selected_filter_kurir: {},
|
||||
// filter_status: [],
|
||||
// selected_filter_status: {},
|
||||
},
|
||||
mutations: {
|
||||
update_selectedHoliday(state, val) {
|
||||
state.selectedHoliday = val
|
||||
},
|
||||
update_dialog_delete(state, val) {
|
||||
state.dialog_delete = val
|
||||
},
|
||||
update_desc(state, val) {
|
||||
state.desc = val
|
||||
},
|
||||
update_dialogForm(state, val) {
|
||||
state.dialogForm = val
|
||||
},
|
||||
update_year(state, val) {
|
||||
state.year = val
|
||||
},
|
||||
update_yearFilter(state, val) {
|
||||
state.yearFilter = val
|
||||
},
|
||||
update_date(state, val) {
|
||||
state.date = val
|
||||
},
|
||||
update_type(state, val) {
|
||||
state.type = val
|
||||
},
|
||||
update_selectedType(state, val) {
|
||||
state.selectedType = val
|
||||
},
|
||||
update_couriers(state, val) {
|
||||
state.couriers = val
|
||||
},
|
||||
update_total(state, val) {
|
||||
state.total = val;
|
||||
},
|
||||
update_loading(state, val) {
|
||||
state.loading = val;
|
||||
},
|
||||
update_error_message(state, val) {
|
||||
state.error_message = val;
|
||||
},
|
||||
update_name(state, val) {
|
||||
state.name = val;
|
||||
},
|
||||
update_curr_page(state, val) {
|
||||
state.curr_page = val;
|
||||
},
|
||||
update_is_courier(state, val) {
|
||||
state.is_courier = val;
|
||||
},
|
||||
update_snackbar(state, val) {
|
||||
state.snackbar = val;
|
||||
},
|
||||
update_snackbar_msg(state, val) {
|
||||
state.snackbar_msg = val;
|
||||
},
|
||||
update_error_dialog(state, val) {
|
||||
state.error_dialog = val;
|
||||
},
|
||||
update_holidays(state, val) {
|
||||
state.holidays = val;
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
async gettype(context) {
|
||||
context.commit("update_loading", true)
|
||||
try {
|
||||
// prm.token = one_token();
|
||||
var param = {
|
||||
"token": one_token(),
|
||||
}
|
||||
let resp = await api.gettype(param);
|
||||
if (resp.status !== "OK") {
|
||||
context.commit("update_loading", false);
|
||||
context.commit("update_error_dialog", true);
|
||||
context.commit("update_error_message", resp);
|
||||
} else {
|
||||
context.commit("update_loading", false);
|
||||
console.log(resp.data);
|
||||
context.commit("update_type", resp.data)
|
||||
|
||||
|
||||
}
|
||||
} catch (error) {
|
||||
context.commit("update_loading", false);
|
||||
context.commit("update_error_dialog", true);
|
||||
context.commit("update_error_message", error);
|
||||
}
|
||||
},
|
||||
async search(context) {
|
||||
context.commit("update_loading", true)
|
||||
try {
|
||||
// prm.token = one_token();
|
||||
var param = {
|
||||
"year": context.state.yearFilter,
|
||||
"token": one_token(),
|
||||
}
|
||||
let resp = await api.search(param);
|
||||
if (resp.status !== "OK") {
|
||||
context.commit("update_loading", false);
|
||||
context.commit("update_error_dialog", true);
|
||||
context.commit("update_error_message", resp);
|
||||
} else {
|
||||
context.commit("update_loading", false);
|
||||
console.log(resp.data);
|
||||
context.commit("update_holidays", resp.data)
|
||||
|
||||
}
|
||||
} catch (error) {
|
||||
context.commit("update_loading", false);
|
||||
context.commit("update_error_dialog", true);
|
||||
context.commit("update_error_message", error);
|
||||
}
|
||||
},
|
||||
async add(context) {
|
||||
context.commit("update_loading", true)
|
||||
try {
|
||||
let prm = {};
|
||||
|
||||
prm.token = one_token();
|
||||
prm.name = context.state.name;
|
||||
prm.year = context.state.year;
|
||||
prm.date = context.state.date;
|
||||
prm.type = context.state.selectedType;
|
||||
prm.description = context.state.desc;
|
||||
|
||||
// prm.userID = one_user();
|
||||
let resp = await api.add(prm);
|
||||
if (resp.status !== "OK") {
|
||||
context.commit("update_loading", false);
|
||||
context.commit("update_error_message", resp);
|
||||
context.commit("update_error_dialog", true);
|
||||
} else {
|
||||
context.commit("update_loading", false);
|
||||
context.commit("update_snackbar", true);
|
||||
context.commit("update_dialogForm", false);
|
||||
context.commit("update_snackbar_msg", "Berhasil Menambahkan hari libur");
|
||||
console.log(resp.data);
|
||||
// var tempCourrier = JSON.stringify(context.state.is_courier);
|
||||
// var arrCourier = JSON.parse(tempCourrier);
|
||||
// arrCourier.push(prm.userID);
|
||||
// context.commit("update_is_courier", arrCourier);
|
||||
context.dispatch("search");
|
||||
}
|
||||
} catch (error) {
|
||||
context.commit("update_loading", false);
|
||||
context.commit("update_error_message", error);
|
||||
context.commit("update_error_dialog", true);
|
||||
}
|
||||
},
|
||||
async edit(context) {
|
||||
context.commit("update_loading", true)
|
||||
try {
|
||||
let prm = {};
|
||||
|
||||
prm.token = one_token();
|
||||
prm.name = context.state.name;
|
||||
prm.year = context.state.year;
|
||||
prm.date = context.state.date;
|
||||
prm.type = context.state.selectedType;
|
||||
prm.description = context.state.desc;
|
||||
prm.id = context.state.selectedHoliday.id;
|
||||
|
||||
// prm.userID = one_user();
|
||||
let resp = await api.edit(prm);
|
||||
if (resp.status !== "OK") {
|
||||
context.commit("update_loading", false);
|
||||
context.commit("update_error_message", resp);
|
||||
context.commit("update_error_dialog", true);
|
||||
} else {
|
||||
context.commit("update_loading", false);
|
||||
context.commit("update_snackbar", true);
|
||||
context.commit("update_dialogForm", false);
|
||||
context.commit("update_snackbar_msg", "Berhasil edit hari libur");
|
||||
console.log(resp.data);
|
||||
// var tempCourrier = JSON.stringify(context.state.is_courier);
|
||||
// var arrCourier = JSON.parse(tempCourrier);
|
||||
// arrCourier.push(prm.userID);
|
||||
// context.commit("update_is_courier", arrCourier);
|
||||
context.dispatch("search");
|
||||
}
|
||||
} catch (error) {
|
||||
context.commit("update_loading", false);
|
||||
context.commit("update_error_message", error);
|
||||
context.commit("update_error_dialog", true);
|
||||
}
|
||||
},
|
||||
async deleteData(context) {
|
||||
context.commit("update_loading", true)
|
||||
try {
|
||||
let prm = {}
|
||||
prm.token = one_token();
|
||||
prm.id = context.state.selectedHoliday.id;
|
||||
// prm.userID = one_user();
|
||||
let resp = await api.deleteData(prm);
|
||||
if (resp.status !== "OK") {
|
||||
context.commit("update_loading", false);
|
||||
context.commit("update_error_message", resp);
|
||||
context.commit("update_error_dialog", true);
|
||||
} else {
|
||||
context.commit("update_loading", false);
|
||||
console.log(resp.data);
|
||||
context.commit("update_snackbar", true);
|
||||
context.commit("update_dialog_delete", false);
|
||||
context.commit("update_snackbar_msg", "Berhasil Menghapus libur");
|
||||
// var tempCourrier = JSON.stringify(context.state.is_courier);
|
||||
// var arrCourier = JSON.parse(tempCourrier);
|
||||
// arrCourier.filter((e) => e === prm.courierID);
|
||||
// context.commit("update_is_courier", arrCourier);
|
||||
context.dispatch("search");
|
||||
}
|
||||
} catch (error) {
|
||||
context.commit("update_loading", false);
|
||||
context.commit("update_error_message", error);
|
||||
context.commit("update_error_dialog", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
449
one-ui/system/one-inject-price/modules/patient.js
Normal file
449
one-ui/system/one-inject-price/modules/patient.js
Normal file
@@ -0,0 +1,449 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/patient.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
couriers: [],
|
||||
type: [],
|
||||
selectedType: '',
|
||||
loading: false,
|
||||
date: moment(new Date()).format('YYYY-MM-DD'),
|
||||
yearFilter: moment(new Date()).format('YYYY'),
|
||||
year: moment(new Date()).format('YYYY'),
|
||||
name: "",
|
||||
curr_page: 1,
|
||||
TOTAL: 0,
|
||||
error_dialog: false,
|
||||
error_message: "",
|
||||
is_courier: [],
|
||||
snackbar: false,
|
||||
snackbar_msg: "",
|
||||
holidays: [],
|
||||
dialogForm: false,
|
||||
name: '',
|
||||
desc: '',
|
||||
selectedHoliday: {},
|
||||
dialog_delete: false,
|
||||
companyList: [],
|
||||
selectedCompany: null,
|
||||
searchCompany: '',
|
||||
mouList: [],
|
||||
selectedMou: null,
|
||||
searchMou: '',
|
||||
isLoading: false,
|
||||
data_csv: [],
|
||||
|
||||
// selected_courier: {},
|
||||
// current_page: 1,
|
||||
// last_id: -1,
|
||||
// x_search: "",
|
||||
// search_status: 0,
|
||||
|
||||
// // dropdown courier
|
||||
// namecouriers: [],
|
||||
// namecourier: {},
|
||||
|
||||
// autocomplete_status: 0,
|
||||
// save_status: 0,
|
||||
// error_message: "",
|
||||
// dialog_error: false,
|
||||
// alert_error: false,
|
||||
// msg_success: "",
|
||||
// alert_success: false,
|
||||
// get_data_status:0,
|
||||
// filter_branch: [],
|
||||
// selected_filter_branch: {},
|
||||
// filter_kurir: [],
|
||||
// selected_filter_kurir: {},
|
||||
// filter_status: [],
|
||||
// selected_filter_status: {},
|
||||
},
|
||||
mutations: {
|
||||
update_data_csv(state, val) {
|
||||
state.data_csv = val
|
||||
},
|
||||
update_companyList(state, val) {
|
||||
state.companyList = val
|
||||
},
|
||||
update_selectedCompany(state, val) {
|
||||
state.selectedCompany = val
|
||||
},
|
||||
update_searchCompany(state, val) {
|
||||
state.searchCompany = val
|
||||
},
|
||||
update_mouList(state, val) {
|
||||
state.mouList = val
|
||||
},
|
||||
update_selectedMou(state, val) {
|
||||
state.selectedMou = val
|
||||
},
|
||||
update_searchMou(state, val) {
|
||||
state.searchMou = val
|
||||
},
|
||||
update_isLoading(state, val) {
|
||||
state.isLoading = val
|
||||
},
|
||||
update_selectedHoliday(state, val) {
|
||||
state.selectedHoliday = val
|
||||
},
|
||||
update_dialog_delete(state, val) {
|
||||
state.dialog_delete = val
|
||||
},
|
||||
update_desc(state, val) {
|
||||
state.desc = val
|
||||
},
|
||||
update_dialogForm(state, val) {
|
||||
state.dialogForm = val
|
||||
},
|
||||
update_year(state, val) {
|
||||
state.year = val
|
||||
},
|
||||
update_yearFilter(state, val) {
|
||||
state.yearFilter = val
|
||||
},
|
||||
update_date(state, val) {
|
||||
state.date = val
|
||||
},
|
||||
update_type(state, val) {
|
||||
state.type = val
|
||||
},
|
||||
update_selectedType(state, val) {
|
||||
state.selectedType = val
|
||||
},
|
||||
update_couriers(state, val) {
|
||||
state.couriers = val
|
||||
},
|
||||
update_total(state, val) {
|
||||
state.TOTAL = val;
|
||||
},
|
||||
update_loading(state, val) {
|
||||
state.loading = val;
|
||||
},
|
||||
update_error_message(state, val) {
|
||||
state.error_message = val;
|
||||
},
|
||||
update_name(state, val) {
|
||||
state.name = val;
|
||||
},
|
||||
update_curr_page(state, val) {
|
||||
state.curr_page = val;
|
||||
},
|
||||
update_is_courier(state, val) {
|
||||
state.is_courier = val;
|
||||
},
|
||||
update_snackbar(state, val) {
|
||||
state.snackbar = val;
|
||||
},
|
||||
update_snackbar_msg(state, val) {
|
||||
state.snackbar_msg = val;
|
||||
},
|
||||
update_error_dialog(state, val) {
|
||||
state.error_dialog = val;
|
||||
},
|
||||
update_holidays(state, val) {
|
||||
state.holidays = val;
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
async getCompany(context, search) {
|
||||
context.commit("update_isLoading", true)
|
||||
try {
|
||||
// prm.token = one_token();
|
||||
var param = {
|
||||
"token": one_token(),
|
||||
"search": search
|
||||
}
|
||||
|
||||
let resp = await api.getCompany(param);
|
||||
if (resp.status !== "OK") {
|
||||
context.commit("update_isLoading", false);
|
||||
context.commit("update_error_dialog", true);
|
||||
context.commit("update_error_message", resp);
|
||||
} else {
|
||||
context.commit("update_isLoading", false);
|
||||
console.log(resp.data);
|
||||
context.commit("update_companyList", resp.data)
|
||||
}
|
||||
} catch (error) {
|
||||
context.commit("update_isLoading", false);
|
||||
context.commit("update_error_dialog", true);
|
||||
context.commit("update_error_message", error);
|
||||
}
|
||||
},
|
||||
async getMou(context, prm) {
|
||||
context.commit("update_isLoading", true)
|
||||
try {
|
||||
prm.token = one_token();
|
||||
let resp = await api.getMou(prm);
|
||||
if (resp.status !== "OK") {
|
||||
context.commit("update_isLoading", false);
|
||||
context.commit("update_error_dialog", true);
|
||||
context.commit("update_error_message", resp);
|
||||
} else {
|
||||
context.commit("update_isLoading", false);
|
||||
console.log(resp.data);
|
||||
context.commit("update_mouList", resp.data)
|
||||
}
|
||||
} catch (error) {
|
||||
context.commit("update_isLoading", false);
|
||||
context.commit("update_error_dialog", true);
|
||||
context.commit("update_error_message", error);
|
||||
}
|
||||
},
|
||||
async downloadcsv(context) {
|
||||
context.commit("update_isLoading", true)
|
||||
try {
|
||||
// param sesuai standar kamu
|
||||
const prm = {
|
||||
token: one_token()
|
||||
}
|
||||
|
||||
// call API
|
||||
let resp = await api.getTest(prm)
|
||||
|
||||
if (resp.status !== "OK") {
|
||||
context.commit("update_isLoading", false)
|
||||
context.commit("update_error_dialog", true)
|
||||
context.commit("update_error_message", resp)
|
||||
return
|
||||
}
|
||||
|
||||
const data = resp.data || []
|
||||
|
||||
// mapping ke format Excel
|
||||
let rows = data.map(item => ({
|
||||
"TEST_CODE": item.TEST_CODE || "",
|
||||
"TEST_NAME": item.TEST_NAME || "",
|
||||
"HARGA": item.HARGA || "",
|
||||
"DISKON_PERSEN": item.DISKON_PERSEN || "",
|
||||
"DISKON_RUPIAH": item.DISKON_RUPIAH || "",
|
||||
"TOTAL": item.TOTAL || ""
|
||||
}))
|
||||
|
||||
// jika kosong → tetap template
|
||||
if (rows.length === 0) {
|
||||
rows = [{
|
||||
"TEST_CODE": "",
|
||||
"TEST_NAME": "",
|
||||
"HARGA": "",
|
||||
"DISKON_PERSEN": "",
|
||||
"DISKON_RUPIAH": "",
|
||||
"TOTAL": ""
|
||||
}]
|
||||
}
|
||||
|
||||
// buat worksheet
|
||||
const ws = XLSX.utils.json_to_sheet(rows)
|
||||
|
||||
// width kolom
|
||||
ws["!cols"] = [
|
||||
{ wch: 15 },
|
||||
{ wch: 35 },
|
||||
{ wch: 15 },
|
||||
{ wch: 15 },
|
||||
{ wch: 15 },
|
||||
{ wch: 15 }
|
||||
]
|
||||
|
||||
// freeze header
|
||||
ws["!freeze"] = { ySplit: 1 }
|
||||
|
||||
// workbook
|
||||
const wb = XLSX.utils.book_new()
|
||||
XLSX.utils.book_append_sheet(wb, ws, "Template Harga")
|
||||
|
||||
// download
|
||||
XLSX.writeFile(wb, "Template_Harga.xlsx")
|
||||
|
||||
context.commit("update_isLoading", false)
|
||||
|
||||
} catch (error) {
|
||||
context.commit("update_isLoading", false)
|
||||
context.commit("update_error_dialog", true)
|
||||
context.commit("update_error_message", error)
|
||||
}
|
||||
},
|
||||
|
||||
async inject(context) {
|
||||
context.commit("update_isLoading", true)
|
||||
try {
|
||||
// prm.token = one_token();
|
||||
var param = {
|
||||
"token": one_token(),
|
||||
"company": context.state.selectedCompany,
|
||||
"mou": context.state.selectedMou,
|
||||
"data": context.state.data_csv
|
||||
}
|
||||
|
||||
let resp = await api.inject(param);
|
||||
if (resp.status !== "OK") {
|
||||
context.commit("update_isLoading", false);
|
||||
context.commit("update_error_dialog", true);
|
||||
context.commit("update_error_message", resp);
|
||||
} else {
|
||||
context.commit("update_isLoading", false);
|
||||
context.commit("update_snackbar", true);
|
||||
context.commit("update_snackbar_msg", "Berhasil Menambahkan data");
|
||||
}
|
||||
} catch (error) {
|
||||
context.commit("update_isLoading", false);
|
||||
context.commit("update_error_dialog", true);
|
||||
context.commit("update_error_message", error);
|
||||
}
|
||||
},
|
||||
async gettype(context) {
|
||||
context.commit("update_loading", true)
|
||||
try {
|
||||
// prm.token = one_token();
|
||||
var param = {
|
||||
"token": one_token(),
|
||||
}
|
||||
let resp = await api.gettype(param);
|
||||
if (resp.status !== "OK") {
|
||||
context.commit("update_loading", false);
|
||||
context.commit("update_error_dialog", true);
|
||||
context.commit("update_error_message", resp);
|
||||
} else {
|
||||
context.commit("update_loading", false);
|
||||
console.log(resp.data);
|
||||
context.commit("update_type", resp.data)
|
||||
}
|
||||
} catch (error) {
|
||||
context.commit("update_loading", false);
|
||||
context.commit("update_error_dialog", true);
|
||||
context.commit("update_error_message", error);
|
||||
}
|
||||
},
|
||||
async search(context) {
|
||||
context.commit("update_loading", true)
|
||||
try {
|
||||
// prm.token = one_token();
|
||||
var param = {
|
||||
"year": context.state.yearFilter,
|
||||
"token": one_token(),
|
||||
}
|
||||
let resp = await api.search(param);
|
||||
if (resp.status !== "OK") {
|
||||
context.commit("update_loading", false);
|
||||
context.commit("update_error_dialog", true);
|
||||
context.commit("update_error_message", resp);
|
||||
} else {
|
||||
context.commit("update_loading", false);
|
||||
console.log(resp.data);
|
||||
context.commit("update_holidays", resp.data)
|
||||
|
||||
}
|
||||
} catch (error) {
|
||||
context.commit("update_loading", false);
|
||||
context.commit("update_error_dialog", true);
|
||||
context.commit("update_error_message", error);
|
||||
}
|
||||
},
|
||||
async add(context) {
|
||||
context.commit("update_loading", true)
|
||||
try {
|
||||
let prm = {};
|
||||
|
||||
prm.token = one_token();
|
||||
prm.name = context.state.name;
|
||||
prm.year = context.state.year;
|
||||
prm.date = context.state.date;
|
||||
prm.type = context.state.selectedType;
|
||||
prm.description = context.state.desc;
|
||||
|
||||
// prm.userID = one_user();
|
||||
let resp = await api.add(prm);
|
||||
if (resp.status !== "OK") {
|
||||
context.commit("update_loading", false);
|
||||
context.commit("update_error_message", resp);
|
||||
context.commit("update_error_dialog", true);
|
||||
} else {
|
||||
context.commit("update_loading", false);
|
||||
context.commit("update_snackbar", true);
|
||||
context.commit("update_dialogForm", false);
|
||||
context.commit("update_snackbar_msg", "Berhasil Menambahkan hari libur");
|
||||
console.log(resp.data);
|
||||
// var tempCourrier = JSON.stringify(context.state.is_courier);
|
||||
// var arrCourier = JSON.parse(tempCourrier);
|
||||
// arrCourier.push(prm.userID);
|
||||
// context.commit("update_is_courier", arrCourier);
|
||||
context.dispatch("search");
|
||||
}
|
||||
} catch (error) {
|
||||
context.commit("update_loading", false);
|
||||
context.commit("update_error_message", error);
|
||||
context.commit("update_error_dialog", true);
|
||||
}
|
||||
},
|
||||
async edit(context) {
|
||||
context.commit("update_loading", true)
|
||||
try {
|
||||
let prm = {};
|
||||
|
||||
prm.token = one_token();
|
||||
prm.name = context.state.name;
|
||||
prm.year = context.state.year;
|
||||
prm.date = context.state.date;
|
||||
prm.type = context.state.selectedType;
|
||||
prm.description = context.state.desc;
|
||||
prm.id = context.state.selectedHoliday.id;
|
||||
|
||||
// prm.userID = one_user();
|
||||
let resp = await api.edit(prm);
|
||||
if (resp.status !== "OK") {
|
||||
context.commit("update_loading", false);
|
||||
context.commit("update_error_message", resp);
|
||||
context.commit("update_error_dialog", true);
|
||||
} else {
|
||||
context.commit("update_loading", false);
|
||||
context.commit("update_snackbar", true);
|
||||
context.commit("update_dialogForm", false);
|
||||
context.commit("update_snackbar_msg", "Berhasil edit hari libur");
|
||||
console.log(resp.data);
|
||||
// var tempCourrier = JSON.stringify(context.state.is_courier);
|
||||
// var arrCourier = JSON.parse(tempCourrier);
|
||||
// arrCourier.push(prm.userID);
|
||||
// context.commit("update_is_courier", arrCourier);
|
||||
context.dispatch("search");
|
||||
}
|
||||
} catch (error) {
|
||||
context.commit("update_loading", false);
|
||||
context.commit("update_error_message", error);
|
||||
context.commit("update_error_dialog", true);
|
||||
}
|
||||
},
|
||||
async deleteData(context) {
|
||||
context.commit("update_loading", true)
|
||||
try {
|
||||
let prm = {}
|
||||
prm.token = one_token();
|
||||
prm.id = context.state.selectedHoliday.id;
|
||||
// prm.userID = one_user();
|
||||
let resp = await api.deleteData(prm);
|
||||
if (resp.status !== "OK") {
|
||||
context.commit("update_loading", false);
|
||||
context.commit("update_error_message", resp);
|
||||
context.commit("update_error_dialog", true);
|
||||
} else {
|
||||
context.commit("update_loading", false);
|
||||
console.log(resp.data);
|
||||
context.commit("update_snackbar", true);
|
||||
context.commit("update_dialog_delete", false);
|
||||
context.commit("update_snackbar_msg", "Berhasil Menghapus libur");
|
||||
// var tempCourrier = JSON.stringify(context.state.is_courier);
|
||||
// var arrCourier = JSON.parse(tempCourrier);
|
||||
// arrCourier.filter((e) => e === prm.courierID);
|
||||
// context.commit("update_is_courier", arrCourier);
|
||||
context.dispatch("search");
|
||||
}
|
||||
} catch (error) {
|
||||
context.commit("update_loading", false);
|
||||
context.commit("update_error_message", error);
|
||||
context.commit("update_error_dialog", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user