fix custom case list view mode

This commit is contained in:
Rodrigo Quelca
2021-10-05 21:29:50 +00:00
parent fc204a41ac
commit 71b8c4263c
4 changed files with 185 additions and 230 deletions

View File

@@ -15,12 +15,12 @@
:column="column"
:headings="options.headings"
></slot>
<slot
<!-- <slot
name="send_by"
:item="item"
column="send_by"
:headings="options.headings"
></slot>
></slot> -->
</b-col>
<b-col sm="3">
<slot
@@ -55,7 +55,7 @@ export default {
};
},
mounted() {
this.filterOptions();
// this.filterOptions();
},
methods: {
classBtn(cls) {
@@ -65,6 +65,7 @@ export default {
* Filter the column send_by
*/
filterOptions() {
debugger;
this.options.columns = this.options.columns.filter(function(item) {
return item !== "send_by";
});

View File

@@ -9,7 +9,7 @@
<b-row>
<b-col sm="5">
<slot
v-for="column in options.columns"
v-for="column in chunkColumns[0]"
:name="column"
:item="item"
:column="column"
@@ -18,11 +18,19 @@
></slot>
</b-col>
<b-col sm="5">
<slot
<!-- <slot
name="send_by"
:item="item"
column="send_by"
:headings="options.headings"
></slot> -->
<slot
v-for="column in chunkColumns[1]"
:name="column"
:item="item"
:column="column"
:headings="options.headings"
ref="containerList"
></slot>
</b-col>
<b-col sm="2">
@@ -54,13 +62,23 @@ export default {
props: ["options"],
data() {
return {
loadMore: this.$t("ID_LOAD_MORE")
loadMore: this.$t("ID_LOAD_MORE"),
chunkColumns: []
};
},
mounted() {
this.filterOptions();
this.chunkColumns = this.chunkArray(this.options.columns, 2);
debugger
},
methods: {
chunkArray(array, size) {
let result = [],
arrayCopy = [...array];
while (arrayCopy.length > 0) {
result.push(arrayCopy.splice(0, size));
}
return result;
},
classBtn(cls) {
return "btn btn-slim btn-force-radius v-btn-header " + cls;
},

File diff suppressed because it is too large Load Diff

View File

@@ -91,48 +91,77 @@ export default {
*/
getCases(data) {
let that = this,
dt,
typeList = that.data.pageParent == "inbox" ? "todo" : that.data.pageParent,
start = 0,
paged,
limit = data.limit,
filters = {},
id = this.data.customListId;
filters = {
paged: paged,
limit: limit,
offset: start,
};
if (_.isEmpty(that.filters) && this.data.settings) {
_.forIn(this.data.settings.filters, function (item, key) {
if (filters && item.value) {
filters[item.filterVar] = item.value;
}
});
} else {
_.forIn(this.filters, function (item, key) {
if (filters && item.value) {
filters[item.filterVar] = item.value;
}
});
}
return new Promise((resolutionFunc, rejectionFunc) => {
api.custom[that.data.pageParent]
({
id,
filters,
})
.then((response) => {
dt = that.formatDataResponse(response.data.data);
resolutionFunc({
data: dt,
count: response.data.total,
dt,
paged,
limit = data.limit,
start = data.page === 1 ? 0 : limit * (data.page - 1),
filters = {},
sort = "",
id = this.data.customListId;
filters = {
paged: paged,
limit: limit,
offset: start,
};
if (_.isEmpty(that.filters) && this.data.settings) {
_.forIn(this.data.settings.filters, function(item, key) {
if (filters && item.value) {
filters[item.filterVar] = item.value;
}
});
} else {
_.forIn(this.filters, function(item, key) {
if (filters && item.value) {
filters[item.filterVar] = item.value;
}
});
}
sort = that.prepareSortString(data);
if (sort) {
filters["sort"] = sort;
}
return new Promise((resolutionFunc, rejectionFunc) => {
api.custom[that.data.pageParent]
({
id,
filters,
})
.then((response) => {
let tmp,
columns = [],
product,
newItems = [];
that.filterItems = [];
response.data.columns.forEach((item) => {
if (item.enableFilter) {
if (that.availableItems[that.itemMap[item.field]]) {
newItems.push(that.availableItems[that.itemMap[item.field]]);
} else {
product = this.filterItemFactory(item)
if (product) {
newItems.push(product);
}
}
}
columns.push(item.field);
});
that.filterItems = newItems;
dt = that.formatDataResponse(response.data.data);
that.cardColumns = columns;
if (that.isFistTime) {
that.filters = that.data.settings && that.data.settings.filters ? that.data.settings.filters : {};
that.columns = that.data.settings && that.data.settings.columns ? that.data.settings.columns : that.getTableColumns(columns);
that.settingOptions = that.formatColumnSettings(columns);
}
resolutionFunc({
data: dt,
count: response.data.total,
});
})
.catch((e) => {
rejectionFunc(e);
});
});
})
.catch((e) => {
rejectionFunc(e);
});
});
},
/**
* Get cases for Vue Card View