"use strict";
|
|
const common_vendor = require("../../common/vendor.js");
|
|
const pages_mixins_pullRefreshMixin = require("../mixins/pullRefreshMixin.js");
|
|
const _sfc_main = {
|
|
mixins: [pages_mixins_pullRefreshMixin.pullRefreshMixin],
|
|
data() {
|
|
return {
|
|
// 状态标签配置
|
|
statusTabs: [
|
|
{ label: "全部", value: "all" },
|
|
{ label: "已预约", value: "appointed" },
|
|
{ label: "待质检", value: "pending" },
|
|
{ label: "待结款", value: "waiting" },
|
|
{ label: "已驳回", value: "rejected" }
|
|
],
|
|
currentStatus: "all",
|
|
selectedTime: "",
|
|
searchActive: false,
|
|
searchKey: "",
|
|
showTimePickerModal: false,
|
|
timePickerStyle: {
|
|
top: 0
|
|
},
|
|
activeTimeType: "start",
|
|
startDate: {
|
|
year: "",
|
|
month: "",
|
|
day: ""
|
|
},
|
|
endDate: {
|
|
year: "",
|
|
month: "",
|
|
day: ""
|
|
},
|
|
orderList: [
|
|
{
|
|
orderId: "RE827381278615224",
|
|
userName: "周小艺",
|
|
phone: "138****1234",
|
|
time: "周四 11:00~13:00",
|
|
status: "appointed"
|
|
},
|
|
{
|
|
orderId: "RE827381278615226",
|
|
userName: "周小艺",
|
|
phone: "138****1234",
|
|
time: "2025-03-20 11:00",
|
|
status: "pending"
|
|
},
|
|
{
|
|
orderId: "RE827381278615225",
|
|
userName: "周小艺",
|
|
phone: "138****1234",
|
|
time: "2025-03-20 12:00",
|
|
status: "rejected"
|
|
},
|
|
{
|
|
orderId: "RE827381278615226",
|
|
userName: "周小艺",
|
|
phone: "138****1234",
|
|
time: "2025-03-20 12:00",
|
|
status: "waiting"
|
|
}
|
|
],
|
|
currentDateIndexes: [0, 0, 0],
|
|
// 当前选中的年月日索引
|
|
// 添加时间范围
|
|
timeRange: {
|
|
start: "",
|
|
end: ""
|
|
}
|
|
};
|
|
},
|
|
computed: {
|
|
// 年份选项
|
|
yearOptions() {
|
|
const years = [];
|
|
const currentYear = (/* @__PURE__ */ new Date()).getFullYear();
|
|
for (let i = 0; i < 6; i++) {
|
|
years.push(currentYear + i);
|
|
}
|
|
return years;
|
|
},
|
|
// 月份选项
|
|
monthOptions() {
|
|
return Array.from({ length: 12 }, (_, i) => i + 1);
|
|
},
|
|
// 日期选项
|
|
dayOptions() {
|
|
return Array.from({ length: 31 }, (_, i) => i + 1);
|
|
},
|
|
// 过滤后的订单列表
|
|
filteredOrders() {
|
|
let result = this.orderList;
|
|
if (this.searchKey) {
|
|
const keyword = this.searchKey.toLowerCase();
|
|
result = result.filter((order) => {
|
|
return order.orderId.toLowerCase().includes(keyword) || order.userName.toLowerCase().includes(keyword);
|
|
});
|
|
}
|
|
if (this.currentStatus !== "all") {
|
|
result = result.filter((order) => order.status === this.currentStatus);
|
|
}
|
|
if (this.timeRange.start && this.timeRange.end) {
|
|
const startTime = new Date(this.timeRange.start).getTime();
|
|
const endTime = new Date(this.timeRange.end).getTime();
|
|
result = result.filter((order) => {
|
|
const orderTime = this.parseOrderTime(order.time);
|
|
return orderTime >= startTime && orderTime <= endTime;
|
|
});
|
|
}
|
|
return result;
|
|
}
|
|
},
|
|
methods: {
|
|
async onRefresh() {
|
|
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
common_vendor.index.stopPullRefresh();
|
|
},
|
|
navigateBack() {
|
|
common_vendor.index.navigateBack();
|
|
},
|
|
// 切换状态
|
|
switchStatus(status) {
|
|
this.currentStatus = status;
|
|
},
|
|
// 显示时间选择器
|
|
showTimePicker() {
|
|
const query = common_vendor.index.createSelectorQuery().in(this);
|
|
query.select(".filter-item").boundingClientRect((rect) => {
|
|
if (rect) {
|
|
this.timePickerStyle = {
|
|
top: rect.bottom
|
|
};
|
|
}
|
|
this.showTimePickerModal = true;
|
|
this.activeTimeType = "start";
|
|
}).exec();
|
|
},
|
|
// 关闭时间选择器
|
|
closeTimePicker() {
|
|
this.showTimePickerModal = false;
|
|
},
|
|
// 切换时间类型
|
|
switchTimeType(type) {
|
|
this.activeTimeType = type;
|
|
const target = type === "start" ? this.startDate : this.endDate;
|
|
this.currentDateIndexes = [
|
|
this.yearOptions.indexOf(target.year) || 0,
|
|
this.monthOptions.indexOf(target.month) || 0,
|
|
this.dayOptions.indexOf(target.day) || 0
|
|
];
|
|
},
|
|
// 处理选择器变化
|
|
handlePickerChange(e) {
|
|
const values = e.detail.value;
|
|
const target = this.activeTimeType === "start" ? this.startDate : this.endDate;
|
|
target.year = this.yearOptions[values[0]];
|
|
target.month = this.monthOptions[values[1]];
|
|
target.day = this.dayOptions[values[2]];
|
|
this.currentDateIndexes = values;
|
|
},
|
|
// 重置时间选择
|
|
resetTimePicker() {
|
|
this.startDate = {
|
|
year: "",
|
|
month: "",
|
|
day: ""
|
|
};
|
|
this.endDate = {
|
|
year: "",
|
|
month: "",
|
|
day: ""
|
|
};
|
|
this.currentDateIndexes = [0, 0, 0];
|
|
this.activeTimeType = "start";
|
|
this.timeRange = {
|
|
start: "",
|
|
end: ""
|
|
};
|
|
this.selectedTime = "";
|
|
},
|
|
// 确认时间选择
|
|
confirmTimePicker() {
|
|
if (!this.startDate.year || !this.startDate.month || !this.startDate.day) {
|
|
common_vendor.index.showToast({
|
|
title: "请选择完整的开始时间",
|
|
icon: "none"
|
|
});
|
|
return;
|
|
}
|
|
if (!this.endDate.year || !this.endDate.month || !this.endDate.day) {
|
|
common_vendor.index.showToast({
|
|
title: "请选择完整的结束时间",
|
|
icon: "none"
|
|
});
|
|
return;
|
|
}
|
|
const startTime = new Date(this.startDate.year, this.startDate.month - 1, this.startDate.day);
|
|
const endTime = new Date(this.endDate.year, this.endDate.month - 1, this.endDate.day);
|
|
if (startTime > endTime) {
|
|
common_vendor.index.showToast({
|
|
title: "开始时间不能大于结束时间",
|
|
icon: "none"
|
|
});
|
|
return;
|
|
}
|
|
const start = `${this.startDate.year}年${this.startDate.month}月${this.startDate.day}日`;
|
|
const end = `${this.endDate.year}年${this.endDate.month}月${this.endDate.day}日`;
|
|
this.selectedTime = `${start} - ${end}`;
|
|
this.timeRange = {
|
|
start: `${this.startDate.year}-${this.startDate.month}-${this.startDate.day}`,
|
|
end: `${this.endDate.year}-${this.endDate.month}-${this.endDate.day}`
|
|
};
|
|
this.showTimePickerModal = false;
|
|
},
|
|
// 搜索处理
|
|
handleSearch() {
|
|
},
|
|
// 加载更多
|
|
loadMore() {
|
|
},
|
|
// 获取状态文本
|
|
getStatusText(status) {
|
|
const statusMap = {
|
|
appointed: "已预约",
|
|
pending: "待质检",
|
|
waiting: "待结款",
|
|
rejected: "已驳回"
|
|
};
|
|
return statusMap[status] || status;
|
|
},
|
|
// 处理驳回
|
|
handleReject(order) {
|
|
common_vendor.index.showModal({
|
|
title: "提示",
|
|
content: "确定要驳回该订单吗?",
|
|
success: (res) => {
|
|
if (res.confirm)
|
|
;
|
|
}
|
|
});
|
|
},
|
|
// 处理审批
|
|
handleApprove(order) {
|
|
common_vendor.index.showModal({
|
|
title: "提示",
|
|
content: "确定要审批通过该订单吗?",
|
|
success: (res) => {
|
|
if (res.confirm)
|
|
;
|
|
}
|
|
});
|
|
},
|
|
// 解析订单时间字符串为时间戳
|
|
parseOrderTime(timeStr) {
|
|
if (timeStr.includes("周")) {
|
|
return (/* @__PURE__ */ new Date()).getTime();
|
|
}
|
|
return new Date(timeStr).getTime();
|
|
}
|
|
}
|
|
};
|
|
if (!Array) {
|
|
const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons");
|
|
_easycom_uni_icons2();
|
|
}
|
|
const _easycom_uni_icons = () => "../../uni_modules/uni-icons/components/uni-icons/uni-icons.js";
|
|
if (!Math) {
|
|
_easycom_uni_icons();
|
|
}
|
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
return common_vendor.e({
|
|
a: common_vendor.p({
|
|
type: "left",
|
|
size: "20"
|
|
}),
|
|
b: common_vendor.o((...args) => $options.navigateBack && $options.navigateBack(...args)),
|
|
c: common_vendor.f($data.statusTabs, (tab, index, i0) => {
|
|
return {
|
|
a: common_vendor.t(tab.label),
|
|
b: index,
|
|
c: $data.currentStatus === tab.value ? 1 : "",
|
|
d: common_vendor.o(($event) => $options.switchStatus(tab.value), index)
|
|
};
|
|
}),
|
|
d: common_vendor.t($data.selectedTime || "处理时间"),
|
|
e: $data.showTimePickerModal || $data.selectedTime ? 1 : "",
|
|
f: common_vendor.p({
|
|
type: $data.showTimePickerModal ? "up" : "down",
|
|
size: "14",
|
|
color: $data.showTimePickerModal || $data.selectedTime ? "#00C853" : "#666"
|
|
}),
|
|
g: common_vendor.o((...args) => $options.showTimePicker && $options.showTimePicker(...args)),
|
|
h: $data.searchActive
|
|
}, $data.searchActive ? common_vendor.e({
|
|
i: common_vendor.p({
|
|
type: "search",
|
|
size: "16",
|
|
color: "#999"
|
|
}),
|
|
j: $data.searchKey,
|
|
k: common_vendor.o(($event) => $data.searchKey = $event.detail.value),
|
|
l: $data.searchKey
|
|
}, $data.searchKey ? {
|
|
m: common_vendor.o(($event) => $data.searchKey = ""),
|
|
n: common_vendor.p({
|
|
type: "clear",
|
|
size: "16",
|
|
color: "#bbb"
|
|
})
|
|
} : {}, {
|
|
o: common_vendor.o(($event) => {
|
|
$data.searchActive = false;
|
|
$data.searchKey = "";
|
|
}),
|
|
p: $data.searchActive ? 1 : ""
|
|
}) : {
|
|
q: common_vendor.p({
|
|
type: "search",
|
|
size: "20",
|
|
color: "#999"
|
|
}),
|
|
r: common_vendor.o(($event) => $data.searchActive = true)
|
|
}, {
|
|
s: $data.showTimePickerModal
|
|
}, $data.showTimePickerModal ? common_vendor.e({
|
|
t: $data.activeTimeType === "start"
|
|
}, $data.activeTimeType === "start" ? {} : {}, {
|
|
v: $data.activeTimeType === "start" ? 1 : "",
|
|
w: common_vendor.o(($event) => $options.switchTimeType("start")),
|
|
x: $data.activeTimeType === "end"
|
|
}, $data.activeTimeType === "end" ? {} : {}, {
|
|
y: $data.activeTimeType === "end" ? 1 : "",
|
|
z: common_vendor.o(($event) => $options.switchTimeType("end")),
|
|
A: common_vendor.f($options.yearOptions, (year, k0, i0) => {
|
|
return {
|
|
a: common_vendor.t(year),
|
|
b: year
|
|
};
|
|
}),
|
|
B: common_vendor.f($options.monthOptions, (month, k0, i0) => {
|
|
return {
|
|
a: common_vendor.t(month),
|
|
b: month
|
|
};
|
|
}),
|
|
C: common_vendor.f($options.dayOptions, (day, k0, i0) => {
|
|
return {
|
|
a: common_vendor.t(day),
|
|
b: day
|
|
};
|
|
}),
|
|
D: $data.currentDateIndexes,
|
|
E: common_vendor.o((...args) => $options.handlePickerChange && $options.handlePickerChange(...args)),
|
|
F: common_vendor.o((...args) => $options.resetTimePicker && $options.resetTimePicker(...args)),
|
|
G: common_vendor.o((...args) => $options.confirmTimePicker && $options.confirmTimePicker(...args)),
|
|
H: $data.timePickerStyle.top + "px",
|
|
I: common_vendor.o(() => {
|
|
}),
|
|
J: common_vendor.o((...args) => $options.closeTimePicker && $options.closeTimePicker(...args)),
|
|
K: common_vendor.o(() => {
|
|
})
|
|
}) : {}, {
|
|
L: common_vendor.f($options.filteredOrders, (order, index, i0) => {
|
|
return common_vendor.e({
|
|
a: common_vendor.t(order.orderId),
|
|
b: common_vendor.t($options.getStatusText(order.status)),
|
|
c: common_vendor.n(order.status),
|
|
d: common_vendor.t(order.userName),
|
|
e: common_vendor.t(order.phone),
|
|
f: common_vendor.t(order.status === "appointed" ? "预约时间:" : "取件时间:"),
|
|
g: common_vendor.t(order.time),
|
|
h: order.status === "pending"
|
|
}, order.status === "pending" ? {
|
|
i: "b419a402-5-" + i0,
|
|
j: common_vendor.p({
|
|
type: "undo",
|
|
size: "16",
|
|
color: "#666"
|
|
}),
|
|
k: common_vendor.o(($event) => $options.handleReject(order), index)
|
|
} : {}, {
|
|
l: order.status === "pending"
|
|
}, order.status === "pending" ? {
|
|
m: "b419a402-6-" + i0,
|
|
n: common_vendor.p({
|
|
type: "checkmarkempty",
|
|
size: "16",
|
|
color: "#00C853"
|
|
}),
|
|
o: common_vendor.o(($event) => $options.handleApprove(order), index)
|
|
} : {}, {
|
|
p: index
|
|
});
|
|
}),
|
|
M: common_vendor.o((...args) => $options.loadMore && $options.loadMore(...args))
|
|
});
|
|
}
|
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-b419a402"]]);
|
|
wx.createPage(MiniProgramPage);
|
|
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/subcomponent/orders.js.map
|