Commit 05493e0d by Jaxon

feat(datePicker, supervisorTab): 优化日期选择器格式配置,添加列表无限滚动功能

- 日期选择器:移除拼写错误的formate属性,新增三个可配置分隔符属性,封装统一格式处理方法,调整展示分隔逻辑
- 绩效监管标签页:使用van-list实现无限滚动,优化分页查询与数据加载流程,修复搜索状态下的列表结束判断
1 parent 4cd6274f
......@@ -58,10 +58,6 @@ let weekColumnsPromiseKey = "";
export default {
name: "DatePicker",
props: {
formate: {
type: String,
default: "YYYY-MM-DD",
},
value: {
type: Object,
default() {
......@@ -95,6 +91,18 @@ export default {
return dayjs().valueOf();
},
},
separator: {
type: String,
default: "/",
},
valueSeparator: {
type: String,
default: "-",
},
weekSeparator: {
type: String,
default: "/",
},
},
data() {
return {
......@@ -184,8 +192,14 @@ export default {
}
},
methods: {
getFormat({
type = ["YYYY", "MM", "DD"],
isValue = false,
} = {}) {
return type.join(isValue ? this.valueSeparator : this.separator);
},
async getWeeklyData() {
const cacheKey = `${this.formate}|${dayjs(this.minDate).valueOf()}|${dayjs(this.maxDate).valueOf()}`;
const cacheKey = `${dayjs(this.minDate).valueOf()}|${dayjs(this.maxDate).valueOf()}`;
if (weekColumnsCache.length && weekColumnsCacheKey === cacheKey) {
this.asyncWeekColumns = weekColumnsCache;
return;
......@@ -203,9 +217,9 @@ export default {
const weekStart = cursor.subtract(weekday === 0 ? 6 : weekday - 1, "day").startOf("day");
const weekEnd = weekStart.add(6, "day").startOf("day");
cols.push({
label: `${weekStart.format(this.formate)}-${weekEnd.format(this.formate)}`,
startDate: weekStart.format(this.formate),
endDate: weekEnd.format(this.formate),
label: `${weekStart.format(this.getFormat())}${this.weekSeparator}${weekEnd.format(this.getFormat())}`,
startDate: weekStart.format(this.getFormat()),
endDate: weekEnd.format(this.getFormat()),
index: cols.length,
});
cursor = weekStart.subtract(1, "day");
......@@ -253,7 +267,7 @@ export default {
this.currentWeek = target;
this.defaultIndex = target ? target.index : 0;
if (target) {
this.date = `${target.startDate}-${target.endDate}`;
this.date = `${target.startDate}${this.weekSeparator}${target.endDate}`;
this.currentDate = this.normalizeDayjs(target.startDate).toDate();
this.rightCurrent = target.index === 0;
this.leftCurrent = target.index === this.innerWeekColumns.length - 1;
......@@ -274,8 +288,8 @@ export default {
this.currentWeek = null;
this.currentDate = normalizedDate.toDate();
this.date = type === "year-month"
? normalizedDate.format(this.formate)
: normalizedDate.format(this.formate);
? normalizedDate.format(this.getFormat({ type: ["YYYY", "MM"] }))
: normalizedDate.format(this.getFormat());
this.updateBoundaryStatusByDate(normalizedDate);
},
handleTypeChange(newType, oldType) {
......@@ -300,7 +314,7 @@ export default {
return null;
},
formatValueDate(input) {
return this.normalizeDayjs(input).format(this.formate);
return this.normalizeDayjs(input).format(this.getFormat({ isValue: true }));
},
normalizeValueByType(value, type = this.type, oldType = this.type) {
const anchorDayjs = this.getAnchorDayjs(value, oldType);
......
......@@ -30,17 +30,21 @@
</div>
<div :key="list.query.statDimension" class="container-wrapper">
<template v-if="list.data && list.data.length">
<StatisticsItem v-for="(item, index) in list.data"
:key="index"
class="statistics-item"
:data="item"
:schema="list.query.statDimension === '1' ? options.supervisorSchemaList : options.supervisorCommonSchemaList"
:sub-title="item.merchantName"
:title="item.supervisorName"
@tap="handleTapItem(item)" />
<div class="last-tips">
到底了~
</div>
<van-list v-model="list.loading"
finished-text="到底了~"
:finished="listFinished"
:immediate-check="false"
:offset="120"
@load="loadMoreList">
<StatisticsItem v-for="(item, index) in list.data"
:key="index"
class="statistics-item"
:data="item"
:schema="list.query.statDimension === '1' ? options.supervisorSchemaList : options.supervisorCommonSchemaList"
:sub-title="item.merchantName"
:title="item.supervisorName"
@tap="handleTapItem(item)" />
</van-list>
</template>
<template v-else>
<Empty v-if="list.data.length === 0 && !list.loading && !list.refreshing"
......@@ -104,9 +108,11 @@ export default {
list: {
loading: false,
refreshing: false,
finished: false,
originData: [],
data: [],
query: {
page: 0,
dateType: 0,
statDimension: "1",
searchKeyword: "",
......@@ -117,6 +123,11 @@ export default {
},
};
},
computed: {
listFinished() {
return this.list.query.searchKeyword || this.list.finished;
},
},
created() {
this.throttledFilterSearchKeyword = throttle(() => {
this.list.data = this.filterSearchKeyword();
......@@ -132,6 +143,12 @@ export default {
getItemSubTitle(rows) {
return rows?.storeList?.map(i => i.merchantName).join("、");
},
resetPageQuery() {
this.list.data = [];
this.list.originData = [];
this.list.query.page = 0;
this.list.finished = false;
},
getQuery() {
return {
...this.list.query,
......@@ -140,19 +157,30 @@ export default {
date: undefined,
};
},
async loadMoreList() {
this.list.query.page += 1;
await this.getData();
},
async getData() {
if (!this.getPageActive()) {
return;
}
if (this.list.refreshing) {
this.resetPageQuery();
}
this.list.loading = true;
this.$loading.show();
try {
this.list.data = [];
this.list.originData = [];
await this.$nextTick();
const list = await getSupervisorPerformance(this.getQuery());
this.list.originData = cloneDeep(list);
this.list.data = this.afterGetData(list);
const query = this.getQuery();
console.log(query);
const list = await getSupervisorPerformance(query);
this.list.originData.push(...list.supervisorList);
this.list.data = cloneDeep(this.list.originData);
if (list.currentPage === (list.totalPages - 1)) {
this.list.finished = true;
}
} finally {
this.$loading.hide();
this.list.loading = false;
......@@ -170,11 +198,11 @@ export default {
return this.list.originData.filter(item => item?.supervisorName?.includes(keyword));
},
async handleDatePickerChange(e) {
console.log("handleDatePickerChange", e);
this.resetPageQuery();
await this.getData();
},
async handleBrandTabsChange(e) {
console.log("handleBrandTabsChange", e);
this.resetPageQuery();
await this.getData();
},
handleTapItem(row) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!