Files
luos/resources/assets/js/home/Inbox/defaultMixins.js

166 lines
4.2 KiB
JavaScript
Raw Normal View History

2021-07-08 20:20:05 +00:00
import api from "../../api/index";
2021-07-08 15:00:07 +00:00
export default {
data() {
let that = this;
return {
typeView: "GRID",
dataMultiviewHeader: {
actions: [
{
id: "view-grid",
title: "Grid",
onClick(action) {
that.typeView = "GRID";
},
icon: "fas fa-table",
},
{
id: "view-list",
title: "List",
onClick(action) {
that.typeView = "LIST";
},
icon: "fas fa-list",
},
{
id: "view-card",
title: "Card",
onClick(action) {
that.typeView = "CARD";
},
icon: "fas fa-th",
},
],
2021-07-08 20:20:05 +00:00
},
optionsVueCardView: {
limit: 10,
headings: {
detail: "",
case_number: this.$i18n.t("ID_MYCASE_NUMBER"),
case_title: this.$i18n.t("ID_CASE_TITLE"),
process_name: this.$i18n.t("ID_PROCESS_NAME"),
task: this.$i18n.t("ID_TASK"),
current_user: this.$i18n.t("ID_CURRENT_USER"),
due_date: this.$i18n.t("ID_DUE_DATE"),
delegation_date: this.$i18n.t("ID_DELEGATION_DATE"),
2021-07-13 15:10:59 +00:00
priority: this.$i18n.t("ID_PRIORITY")
2021-07-08 20:20:05 +00:00
},
columns: [
"detail",
"case_number",
"case_title",
"process_name",
"due_date",
"delegation_date",
"priority",
2021-07-13 15:10:59 +00:00
"task"
2021-07-08 20:20:05 +00:00
],
2021-07-13 15:10:59 +00:00
requestFunction(data) {
return that.getCasesVueCard(data);
},
requestFunctionViewMore(data) {
return that.getCasesVueCardViewMore(data);
}
},
optionsVueListView: {
limit: 10,
headings: {
detail: "",
case_number: this.$i18n.t("ID_MYCASE_NUMBER"),
case_title: this.$i18n.t("ID_CASE_TITLE"),
process_name: this.$i18n.t("ID_PROCESS_NAME"),
task: this.$i18n.t("ID_TASK"),
current_user: this.$i18n.t("ID_CURRENT_USER"),
due_date: this.$i18n.t("ID_DUE_DATE"),
delegation_date: this.$i18n.t("ID_DELEGATION_DATE"),
priority: this.$i18n.t("ID_PRIORITY")
},
columns: [
"detail",
"case_number",
"case_title",
"process_name",
"due_date",
"delegation_date",
"priority",
"task"
],
requestFunction(data) {
return that.getCasesVueCard(data);
},
requestFunctionViewMore(data) {
return that.getCasesVueCardViewMore(data);
2021-07-08 20:20:05 +00:00
}
2021-07-08 15:00:07 +00:00
}
}
},
created: function () {
},
methods: {
2021-07-08 20:20:05 +00:00
/**
* Get cases for Vue Card View
*/
2021-07-13 15:10:59 +00:00
getCasesVueCard(data) {
2021-07-08 20:20:05 +00:00
let that = this,
dt,
start = 0,
limit = data.limit,
filters = {};
filters = {
paged: "0," + limit,
};
2021-07-08 15:00:07 +00:00
2021-07-08 20:20:05 +00:00
_.forIn(this.filters, function (item, key) {
filters[item.filterVar] = item.value;
});
return new Promise((resolutionFunc, rejectionFunc) => {
api.cases
.todo(filters)
.then((response) => {
dt = that.formatDataResponse(response.data.data);
resolutionFunc({
data: dt,
count: response.data.total,
});
})
.catch((e) => {
rejectionFunc(e);
});
});
},
2021-07-13 15:10:59 +00:00
/**
* Get cases for Vue Card View
*/
getCasesVueCardViewMore(data) {
let that = this,
dt,
paged,
limit = data.limit,
start = data.page === 1 ? 0 : limit * (data.page - 1),
filters = {};
paged = start + "," + limit;
filters = {
paged: paged,
};
_.forIn(this.filters, function (item, key) {
filters[item.filterVar] = item.value;
});
return new Promise((resolutionFunc, rejectionFunc) => {
api.cases
.todo(filters)
.then((response) => {
dt = that.formatDataResponse(response.data.data);
resolutionFunc({
data: dt,
count: response.data.total,
});
})
.catch((e) => {
rejectionFunc(e);
});
});
},
2021-07-08 15:00:07 +00:00
}
2021-07-13 15:17:06 +00:00
}