Commit 05493e0d by Jaxon

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

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