1254 lines
30 KiB
Vue
1254 lines
30 KiB
Vue
<template>
|
|
<view class="receiving-list">
|
|
<view class="normar_container">
|
|
<page-nav :title="title"></page-nav>
|
|
<!-- 搜索和筛选区域 -->
|
|
<view class="search-filter">
|
|
<!-- 搜索框 -->
|
|
<view class="search-box">
|
|
<view class="search-box-inner">
|
|
<u-search v-model="searchKeyword" placeholder="搜索运单号、货主、商品条码、车牌" bg-color="#f5f5f5" shape="round"
|
|
:show-action="false" @search="handleSearch" @clear="handleSearch"></u-search>
|
|
<view class="search-actions">
|
|
<view class="scan-btn" @click="handleManualScan">
|
|
<u-icon name="scan" size="38rpx" color="#2979ff"></u-icon>
|
|
</view>
|
|
<view class="search-divider"></view>
|
|
<view class="search-btn" @click="handleSearch">
|
|
<text class="search-btn__text">搜索</text>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
|
|
|
|
<!-- 筛选按钮 -->
|
|
<view class="filter-actions">
|
|
<view class="filter-buttons">
|
|
<u-button size="mini" type="primary" plain @click="showFilterPopup">
|
|
筛选
|
|
</u-button>
|
|
|
|
<u-button size="mini" type="success" @click="createReceiving">
|
|
<u-icon name="plus" size="16"></u-icon>
|
|
新建收货
|
|
</u-button>
|
|
</view>
|
|
</view>
|
|
|
|
<!-- 状态标签 -->
|
|
<scroll-view class="status-tags" scroll-x :show-scrollbar="false">
|
|
<view class="status-tag" v-for="status in statusList" :key="status.value"
|
|
:class="{ active: activeStatus === status.value }" @click="changeStatus(status.value)">
|
|
<text class="tag-name">{{ status.label }}</text>
|
|
<u-badge :value="status.count" size="mini"></u-badge>
|
|
</view>
|
|
</scroll-view>
|
|
</view>
|
|
|
|
<!-- 收货列表 -->
|
|
<scroll-view class="receiving-list-content" scroll-y>
|
|
<!-- 列表为空提示 -->
|
|
<view class="empty-state" v-if="!loading && receivingList.length === 0">
|
|
<u-icon name="list-dot" size="100" color="#ccc"></u-icon>
|
|
<text class="empty-text">暂无收货任务</text>
|
|
<text class="empty-hint">点击"新建收货"开始创建收货单</text>
|
|
</view>
|
|
|
|
<!-- 收货单列表 -->
|
|
<view class="receiving-items">
|
|
<view class="receiving-item" v-for="item in receivingList" :key="item.id"
|
|
@click="viewReceivingDetail(item)">
|
|
<!-- 单号区域 -->
|
|
<view class="item-header">
|
|
<text class="order-no">{{ item.receiving_number }}</text>
|
|
<u-tag :text="getStatusText(item.status)" :type="getStatusType(item.status)"
|
|
size="mini"></u-tag>
|
|
</view>
|
|
|
|
<!-- 基本信息 -->
|
|
<view class="item-info">
|
|
<view class="info-row">
|
|
<u-icon name="home" size="16" color="#999"></u-icon>
|
|
<text class="info-label">货主:</text>
|
|
<text class="info-value">{{ item['store.store_remask'] || '--' }}</text>
|
|
</view>
|
|
|
|
<view class="info-row">
|
|
<u-icon name="car" size="16" color="#999"></u-icon>
|
|
<text class="info-label">车牌/运单:</text>
|
|
<text class="info-value">{{ item.license_plate || item.tracking_number || '--' }}</text>
|
|
</view>
|
|
<view class="info-row">
|
|
<u-icon name="account" size="16" color="#999"></u-icon>
|
|
<text class="info-label">创建人:</text>
|
|
<text class="info-value">{{ item['creator.real_name'] || '--' }}</text>
|
|
</view>
|
|
|
|
<view class="info-row" v-if="item.images && item.images.length>0">
|
|
<u-icon name="photo" size="16" color="#999"></u-icon>
|
|
<text class="info-label">照片:</text>
|
|
<span class="info-value" @click.stop="showImgs(item.images)">
|
|
<image class="miniImg" v-for="(url, index) in item.images" :key="index" :src="url"></image>
|
|
</span>
|
|
</view>
|
|
</view>
|
|
|
|
<!-- 操作按钮 -->
|
|
<view class="item-actions">
|
|
<view class="action-left">
|
|
<text class="create-time">创建:{{ formatRelativeTime(item.created_at) }}</text>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
|
|
<!-- 底部安全区域 -->
|
|
<view class="safe-area-bottom"></view>
|
|
</scroll-view>
|
|
<pagination :pageNum.sync="currentPage" :pageSize="pageSize" :total="totalItems" :showTotal="true"
|
|
:prevText="'上一页'" :nextText="'下一页'" :showFirstLast="true" :firstText="'首页'" :lastText="'末页'"
|
|
@change="handlePageChange" />
|
|
</view>
|
|
|
|
<!-- 筛选弹出层 -->
|
|
<u-popup :show="filterVisible" mode="bottom" :closeable="true" border-radius="20" @close="filterVisible = false">
|
|
<view class="filter-popup">
|
|
<view class="popup-header">
|
|
<text class="popup-title">筛选条件</text>
|
|
</view>
|
|
<u--form class="filter-content" labelWidth="auto" labelPosition="left" :model="where" ref="uForm">
|
|
<u-form-item label="货主" prop="store" borderBottom @click="handleShowStore">
|
|
<view>{{storeName}}</view>
|
|
</u-form-item>
|
|
|
|
<u-form-item label="创建时间" borderBottom>
|
|
<view class="date-range" @click="openDateFilter">
|
|
<text>{{where.startDate}} - {{where.endDate}}</text>
|
|
</view>
|
|
</u-form-item>
|
|
|
|
<u-form-item label="" borderBottom>
|
|
<view class="quick-date-buttons">
|
|
<view class="quick-date-buttons__item" :class="{ 'is-active': dateModel === 'today' }">
|
|
<u-button size="mini" :type="dateModel === 'today' ? 'primary' : 'default'" @click="setDateRange('today')">今日</u-button>
|
|
</view>
|
|
<view class="quick-date-buttons__item" :class="{ 'is-active': dateModel === 'yesterday' }">
|
|
<u-button size="mini" :type="dateModel === 'yesterday' ? 'primary' : 'default'" @click="setDateRange('yesterday')">昨日</u-button>
|
|
</view>
|
|
<view class="quick-date-buttons__item" :class="{ 'is-active': dateModel === 'beforeYesterday' }">
|
|
<u-button size="mini" :type="dateModel === 'beforeYesterday' ? 'primary' : 'default'" @click="setDateRange('beforeYesterday')">前日</u-button>
|
|
</view>
|
|
<view class="quick-date-buttons__item" :class="{ 'is-active': dateModel === 'last3days' }">
|
|
<u-button size="mini" :type="dateModel === 'last3days' ? 'primary' : 'default'" @click="setDateRange('last3days')">3天内</u-button>
|
|
</view>
|
|
<view class="quick-date-buttons__item" :class="{ 'is-active': dateModel === 'week' }">
|
|
<u-button size="mini" :type="dateModel === 'week' ? 'primary' : 'default'" @click="setDateRange('week')">本周</u-button>
|
|
</view>
|
|
<view class="quick-date-buttons__item" :class="{ 'is-active': dateModel === 'month' }">
|
|
<u-button size="mini" :type="dateModel === 'month' ? 'primary' : 'default'" @click="setDateRange('month')">本月</u-button>
|
|
</view>
|
|
</view>
|
|
</u-form-item>
|
|
</u--form>
|
|
<view class="popup-actions">
|
|
<u-button type="default" shape="circle" @click="resetFilter">
|
|
重置
|
|
</u-button>
|
|
|
|
<u-button type="primary" shape="circle" @click="applyFilter">
|
|
确定
|
|
</u-button>
|
|
</view>
|
|
</view>
|
|
</u-popup>
|
|
|
|
<!-- 货主选择组件 -->
|
|
<inputAndSelect title="选择货主" :list="stores" :show="showStore" :value="storeId"
|
|
searchBorder="none" @change="handleStoreChange" @close="showStore=false"></inputAndSelect>
|
|
|
|
<!-- 时间选择器 -->
|
|
<u-calendar :show="showSelectDate" mode="range" @confirm="handleDateConfirm" @close="showSelectDate=false" :minDate="minDate" :maxDate="maxDate" :monthNum="calendarMonthNum"></u-calendar>
|
|
|
|
<!-- 加载遮罩 -->
|
|
<u-loading-page :loading="loading" bg-color="rgba(255,255,255,0.9)"></u-loading-page>
|
|
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
data() {
|
|
return {
|
|
title: "收货列表",
|
|
// 搜索和筛选
|
|
searchKeyword: '',
|
|
activeStatus: 'all',
|
|
filterVisible: false,
|
|
storeName: "全部",
|
|
|
|
// 日期模式
|
|
dateModel: 'today',
|
|
minDate:(() => {
|
|
const now = new Date();
|
|
const sixMonthsAgo = new Date(now);
|
|
sixMonthsAgo.setMonth(now.getMonth() - 3);
|
|
return this.formatDate(sixMonthsAgo);
|
|
})(),
|
|
maxDate:this.formatDate(new Date()),
|
|
// 筛选条件
|
|
showSelectDate: false,
|
|
showStore: false,
|
|
|
|
// 列表数据
|
|
receivingList: [],
|
|
loading: false,
|
|
storeId:null,
|
|
refreshing: false,
|
|
pageChangeSilentVoice: true,
|
|
nextListVoiceDelay: 0,
|
|
pageSize: 20,
|
|
currentPage: 1,
|
|
totalItems: 0,
|
|
|
|
// 筛选条件
|
|
where: {
|
|
startDate: this.formatDate(new Date()),
|
|
endDate: this.formatDate(new Date()),
|
|
},
|
|
|
|
// 状态列表
|
|
statusList: [
|
|
{
|
|
label: '全部',
|
|
value: 'all',
|
|
count: 0
|
|
},
|
|
{
|
|
label: '收货中',
|
|
value: 'receiving',
|
|
count: 0
|
|
},
|
|
{
|
|
label: '已完成',
|
|
value: 'completed',
|
|
count: 0
|
|
},
|
|
{
|
|
label: '已取消',
|
|
value: 'cancelled',
|
|
count: 0
|
|
}
|
|
],
|
|
|
|
// 货主列表
|
|
stores: [],
|
|
}
|
|
},
|
|
computed: {
|
|
calendarMonthNum() {
|
|
const min = new Date(this.minDate);
|
|
const max = new Date(this.maxDate);
|
|
return (max.getFullYear() - min.getFullYear()) * 12 + (max.getMonth() - min.getMonth()) + 1;
|
|
}
|
|
},
|
|
onLoad() {
|
|
this.$store.dispatch('broadcast/setCallbacks', {
|
|
onResult: this.scan
|
|
});
|
|
this.$store.dispatch('broadcast/start');
|
|
},
|
|
|
|
onShow() {
|
|
this.$store.dispatch('broadcast/resume');
|
|
this.loadReceivingList({
|
|
silentVoice: true
|
|
});
|
|
},
|
|
|
|
onHide() {
|
|
this.$store.dispatch('broadcast/stop');
|
|
this.stopReceivingSpeak();
|
|
},
|
|
|
|
onUnload() {
|
|
this.$store.dispatch('broadcast/stop');
|
|
this.stopReceivingSpeak();
|
|
},
|
|
|
|
onPullDownRefresh() {
|
|
this.onRefresh();
|
|
},
|
|
|
|
watch: {
|
|
currentPage(newval) {
|
|
console.log('页码变化:', newval);
|
|
const silentVoice = this.pageChangeSilentVoice;
|
|
const voiceDelay = Number(this.nextListVoiceDelay || 0);
|
|
this.pageChangeSilentVoice = true;
|
|
this.nextListVoiceDelay = 0;
|
|
this.loadReceivingList({
|
|
silentVoice,
|
|
voiceDelay
|
|
});
|
|
}
|
|
},
|
|
|
|
methods: {
|
|
normalizeSpeechText(message) {
|
|
const rawText = String(message || '').trim();
|
|
if (!rawText) {
|
|
return '';
|
|
}
|
|
|
|
const digitMap = {
|
|
'0': '零',
|
|
'1': '一',
|
|
'2': '二',
|
|
'3': '三',
|
|
'4': '四',
|
|
'5': '五',
|
|
'6': '六',
|
|
'7': '七',
|
|
'8': '八',
|
|
'9': '九'
|
|
};
|
|
|
|
const normalizeCodeSegment = (segment) => {
|
|
return segment
|
|
.split('-')
|
|
.map(part => String(part || '')
|
|
.split('')
|
|
.map(char => (digitMap[char] || char))
|
|
.join(''))
|
|
.join('的');
|
|
};
|
|
|
|
return rawText.replace(/([A-Za-z0-9]+(?:-[A-Za-z0-9]+)+)/g, normalizeCodeSegment);
|
|
},
|
|
speakReceivingMessage(message, options = {}) {
|
|
const text = this.normalizeSpeechText(message);
|
|
if (!text) {
|
|
return;
|
|
}
|
|
|
|
const tools = this.$tools;
|
|
if (!tools || typeof tools.speakText !== 'function') {
|
|
return;
|
|
}
|
|
|
|
try {
|
|
const task = tools.speakText(text, options);
|
|
if (task && typeof task.catch === 'function') {
|
|
task.catch(error => {
|
|
console.warn('[ReceivingList] 语音播报失败:', error);
|
|
});
|
|
}
|
|
} catch (error) {
|
|
console.warn('[ReceivingList] 语音播报异常:', error);
|
|
}
|
|
},
|
|
stopReceivingSpeak() {
|
|
const tools = this.$tools;
|
|
if (!tools || typeof tools.stopSpeak !== 'function') {
|
|
return;
|
|
}
|
|
|
|
try {
|
|
tools.stopSpeak();
|
|
} catch (error) {
|
|
console.warn('[ReceivingList] 停止语音播报异常:', error);
|
|
}
|
|
},
|
|
getReceivingListVoiceText() {
|
|
const modeText = this.activeStatus === 'all'
|
|
? '全部状态'
|
|
: this.getStatusText(this.activeStatus);
|
|
const count = Number(this.totalItems || 0);
|
|
if (count > 0) {
|
|
return `${modeText},查询到${count}条收货任务`;
|
|
}
|
|
return `${modeText},未查询到收货任务`;
|
|
},
|
|
// 日期格式化函数
|
|
formatDate(date) {
|
|
const d = new Date(date);
|
|
const year = d.getFullYear();
|
|
const month = String(d.getMonth() + 1).padStart(2, '0');
|
|
const day = String(d.getDate()).padStart(2, '0');
|
|
return `${year}-${month}-${day}`;
|
|
},
|
|
|
|
// 获取日期范围
|
|
getDateRange(type) {
|
|
const now = new Date();
|
|
let startDate, endDate;
|
|
|
|
switch(type) {
|
|
case 'today':
|
|
startDate = endDate = now;
|
|
break;
|
|
case 'yesterday':
|
|
startDate = new Date(now);
|
|
startDate.setDate(now.getDate() - 1);
|
|
endDate = new Date(startDate);
|
|
break;
|
|
case 'beforeYesterday':
|
|
startDate = new Date(now);
|
|
startDate.setDate(now.getDate() - 2);
|
|
endDate = new Date(startDate);
|
|
break;
|
|
case 'last3days':
|
|
startDate = new Date(now);
|
|
startDate.setDate(now.getDate() - 2);
|
|
endDate = now;
|
|
break;
|
|
case 'week':
|
|
// 本周一
|
|
const monday = new Date(now);
|
|
monday.setDate(now.getDate() - now.getDay() + 1);
|
|
startDate = monday;
|
|
endDate = now;
|
|
break;
|
|
case 'month':
|
|
// 本月第一天
|
|
const firstDay = new Date(now.getFullYear(), now.getMonth(), 1);
|
|
startDate = firstDay;
|
|
endDate = now;
|
|
break;
|
|
default:
|
|
startDate = endDate = now;
|
|
}
|
|
|
|
return {
|
|
startDate: this.formatDate(startDate),
|
|
endDate: this.formatDate(endDate)
|
|
};
|
|
},
|
|
|
|
// 设置日期范围
|
|
setDateRange(type) {
|
|
this.dateModel = type;
|
|
const dateRange = this.getDateRange(type);
|
|
this.where.startDate = dateRange.startDate;
|
|
this.where.endDate = dateRange.endDate;
|
|
},
|
|
|
|
// 时间选择确认
|
|
handleDateConfirm(data) {
|
|
console.log('选择的时间范围:', data);
|
|
const { startDate, endDate } = this.parseCalendarRange(data);
|
|
if (startDate) {
|
|
this.where.startDate = startDate;
|
|
}
|
|
if (endDate) {
|
|
this.where.endDate = endDate;
|
|
}
|
|
this.dateModel = 'custom';
|
|
this.showSelectDate = false;
|
|
},
|
|
parseCalendarRange(data) {
|
|
let startDate = '';
|
|
let endDate = '';
|
|
|
|
if (Array.isArray(data)) {
|
|
startDate = data[0];
|
|
endDate = data[1];
|
|
} else if (data && typeof data === 'object') {
|
|
startDate = data.startDate || data.start || data.beginDate || '';
|
|
endDate = data.endDate || data.end || '';
|
|
|
|
if ((!startDate || !endDate) && Array.isArray(data.result)) {
|
|
startDate = startDate || data.result[0];
|
|
endDate = endDate || data.result[1];
|
|
}
|
|
|
|
if ((!startDate || !endDate) && typeof data.result === 'string') {
|
|
const parts = this.extractCalendarDateTokens(data.result);
|
|
startDate = startDate || parts[0] || '';
|
|
endDate = endDate || parts[1] || '';
|
|
}
|
|
} else if (typeof data === 'string') {
|
|
const parts = this.extractCalendarDateTokens(data);
|
|
startDate = parts[0] || '';
|
|
endDate = parts[1] || '';
|
|
}
|
|
|
|
const extractedDates = this.extractCalendarDatesFromPayload(data);
|
|
if (extractedDates.length >= 2) {
|
|
startDate = extractedDates[0];
|
|
endDate = extractedDates[extractedDates.length - 1];
|
|
}
|
|
|
|
startDate = this.normalizeCalendarDate(startDate);
|
|
endDate = this.normalizeCalendarDate(endDate);
|
|
|
|
if (startDate && !endDate) {
|
|
endDate = startDate;
|
|
}
|
|
if (!startDate && endDate) {
|
|
startDate = endDate;
|
|
}
|
|
|
|
return {
|
|
startDate,
|
|
endDate
|
|
};
|
|
},
|
|
extractCalendarDatesFromPayload(payload) {
|
|
let text = '';
|
|
if (typeof payload === 'string') {
|
|
text = payload;
|
|
} else {
|
|
try {
|
|
text = JSON.stringify(payload || '');
|
|
} catch (error) {
|
|
text = String(payload || '');
|
|
}
|
|
}
|
|
|
|
const matched = String(text || '').match(/\d{4}-\d{2}-\d{2}/g) || [];
|
|
const normalized = matched
|
|
.map(item => this.normalizeCalendarDate(item))
|
|
.filter(Boolean);
|
|
|
|
return Array.from(new Set(normalized)).sort();
|
|
},
|
|
extractCalendarDateTokens(value) {
|
|
const text = String(value || '').trim();
|
|
if (!text) {
|
|
return [];
|
|
}
|
|
|
|
const matched = text.match(/\d{4}-\d{2}-\d{2}/g);
|
|
if (matched && matched.length) {
|
|
return matched;
|
|
}
|
|
|
|
return text.split(/[~至]/).map(item => String(item || '').trim()).filter(Boolean);
|
|
},
|
|
normalizeCalendarDate(value) {
|
|
if (value === null || value === undefined || value === '') {
|
|
return '';
|
|
}
|
|
|
|
if (typeof value === 'number') {
|
|
return this.formatDate(new Date(value));
|
|
}
|
|
|
|
const text = String(value).trim();
|
|
if (!text) {
|
|
return '';
|
|
}
|
|
|
|
if (/^\d{4}-\d{2}-\d{2}$/.test(text)) {
|
|
return text;
|
|
}
|
|
|
|
const date = new Date(text);
|
|
if (!Number.isNaN(date.getTime())) {
|
|
return this.formatDate(date);
|
|
}
|
|
|
|
return '';
|
|
},
|
|
|
|
// 货主选择
|
|
handleStoreChange(option) {
|
|
if(!option){
|
|
this.storeName = "全部";
|
|
this.storeId = null;
|
|
}else{
|
|
this.storeName = option.label;
|
|
this.storeId = option.value;
|
|
}
|
|
this.showStore = false;
|
|
},
|
|
|
|
async scan(data) {
|
|
console.log("扫描数据:", data.data);
|
|
this.searchKeyword = data.data;
|
|
this.handleSearch();
|
|
},
|
|
normalizeUniScanResult(scanResult) {
|
|
if (!scanResult) {
|
|
return '';
|
|
}
|
|
|
|
if (typeof scanResult === 'string') {
|
|
return scanResult.trim();
|
|
}
|
|
|
|
if (typeof scanResult.result === 'string') {
|
|
return scanResult.result.trim();
|
|
}
|
|
|
|
if (Array.isArray(scanResult.result)) {
|
|
const firstResult = scanResult.result.find(item => item);
|
|
if (typeof firstResult === 'string') {
|
|
return firstResult.trim();
|
|
}
|
|
if (firstResult && typeof firstResult.data === 'string') {
|
|
return firstResult.data.trim();
|
|
}
|
|
}
|
|
|
|
if (typeof scanResult.data === 'string') {
|
|
return scanResult.data.trim();
|
|
}
|
|
|
|
return '';
|
|
},
|
|
handleManualScan() {
|
|
uni.scanCode({
|
|
onlyFromCamera: false,
|
|
scanType: ['qrCode', 'barCode', 'datamatrix', 'pdf417'],
|
|
success: (res) => {
|
|
const rawCode = this.normalizeUniScanResult(res);
|
|
if (!rawCode) {
|
|
uni.showToast({
|
|
title: '未识别到有效内容',
|
|
icon: 'none'
|
|
});
|
|
return;
|
|
}
|
|
|
|
this.scan({
|
|
data: rawCode,
|
|
source: 'uni.scanCode'
|
|
});
|
|
},
|
|
fail: (error) => {
|
|
const errMsg = String(error?.errMsg || '').toLowerCase();
|
|
if (errMsg.includes('cancel')) {
|
|
return;
|
|
}
|
|
|
|
uni.showToast({
|
|
title: '扫码失败,请重试',
|
|
icon: 'none'
|
|
});
|
|
}
|
|
});
|
|
},
|
|
|
|
async loadStore() {
|
|
try {
|
|
const res = await this.$http("common.store", {});
|
|
console.log("货主数据:", res);
|
|
if (res.stores) {
|
|
// 添加全部选项
|
|
this.stores = res.stores;
|
|
}
|
|
} catch (error) {
|
|
console.error('加载货主失败:', error);
|
|
}
|
|
},
|
|
|
|
// 加载收货列表
|
|
async loadReceivingList(options = {}) {
|
|
const silentVoice = !!(options && options.silentVoice);
|
|
const voiceDelay = Number((options && options.voiceDelay) || 0);
|
|
if (this.loading) return;
|
|
|
|
this.loading = true;
|
|
try {
|
|
// 构建查询条件
|
|
const queryWhere = {};
|
|
this.loadStore();
|
|
// 添加基础筛选条件
|
|
if (this.storeId) {
|
|
queryWhere.store_id = {field:'store_id',operator:'eq',type:'number',value:this.storeId};
|
|
}
|
|
|
|
// 添加日期范围条件
|
|
if (this.where.startDate && this.where.endDate) {
|
|
queryWhere.created_at = {
|
|
field: "created_at",
|
|
type: "daterange",
|
|
operator: "between",
|
|
value: [this.where.startDate, this.where.endDate]
|
|
};
|
|
}
|
|
|
|
// 添加状态筛选
|
|
if (this.activeStatus !== 'all') {
|
|
queryWhere.status = {field:'status',operator:'eq',type:'string',value:this.activeStatus};
|
|
}
|
|
|
|
// 添加搜索条件
|
|
if (this.searchKeyword) {
|
|
queryWhere.quickWhere = {
|
|
value: this.searchKeyword
|
|
};
|
|
delete queryWhere.created_at;
|
|
delete queryWhere.store_id;
|
|
}
|
|
|
|
console.log('查询条件:', queryWhere);
|
|
|
|
const res = await this.$http("storage.receiving.getReceivingList", {
|
|
pagination: {
|
|
page: this.currentPage,
|
|
pageSize: this.pageSize,
|
|
},
|
|
where: queryWhere
|
|
});
|
|
|
|
if (res.code == "200") {
|
|
const {
|
|
list,
|
|
pagination,
|
|
summary
|
|
} = res.data;
|
|
const {
|
|
total,
|
|
page
|
|
} = pagination;
|
|
|
|
this.totalItems = total;
|
|
this.currentPage = page;
|
|
this.receivingList = list || [];
|
|
|
|
// 更新状态统计
|
|
if (summary) {
|
|
this.updateStatusCount(summary);
|
|
}
|
|
|
|
|
|
}
|
|
} catch (error) {
|
|
console.error('加载收货列表失败:', error);
|
|
uni.showToast({
|
|
title: '加载失败',
|
|
icon: 'error'
|
|
});
|
|
if (!silentVoice) {
|
|
if (voiceDelay > 0) {
|
|
setTimeout(() => {
|
|
this.speakReceivingMessage('加载收货列表失败,请重试');
|
|
}, voiceDelay);
|
|
} else {
|
|
this.speakReceivingMessage('加载收货列表失败,请重试');
|
|
}
|
|
}
|
|
} finally {
|
|
this.loading = false;
|
|
this.refreshing = false;
|
|
uni.stopPullDownRefresh();
|
|
}
|
|
},
|
|
|
|
// 更新状态统计
|
|
updateStatusCount(summary) {
|
|
this.statusList = this.statusList.map(status => {
|
|
const count = summary[status.value] || 0;
|
|
return { ...status, count };
|
|
});
|
|
},
|
|
|
|
// 获取状态文本
|
|
getStatusText(status) {
|
|
const statusMap = {
|
|
'receiving': '收货中',
|
|
'completed': '已完成',
|
|
'cancelled': '已取消'
|
|
};
|
|
return statusMap[status] || '未知状态';
|
|
},
|
|
|
|
// 获取状态类型
|
|
getStatusType(status) {
|
|
const typeMap = {
|
|
'cancelled': 'warning',
|
|
'receiving': 'primary',
|
|
'completed': 'success',
|
|
};
|
|
return typeMap[status] || 'info';
|
|
},
|
|
handleShowStore(){
|
|
this.showStore = true;
|
|
console.log("显示选择货主")
|
|
},
|
|
// 搜索处理
|
|
handleSearch() {
|
|
if (this.currentPage !== 1) {
|
|
this.pageChangeSilentVoice = false;
|
|
this.currentPage = 1;
|
|
return;
|
|
}
|
|
this.loadReceivingList({
|
|
silentVoice: false
|
|
});
|
|
},
|
|
|
|
// 状态切换
|
|
changeStatus(status) {
|
|
this.activeStatus = status;
|
|
if (this.currentPage !== 1) {
|
|
this.pageChangeSilentVoice = false;
|
|
this.currentPage = 1;
|
|
return;
|
|
}
|
|
this.loadReceivingList({
|
|
silentVoice: false
|
|
});
|
|
},
|
|
|
|
// 下拉刷新
|
|
onRefresh() {
|
|
this.refreshing = true;
|
|
if (this.currentPage !== 1) {
|
|
this.pageChangeSilentVoice = false;
|
|
this.currentPage = 1;
|
|
return;
|
|
}
|
|
this.loadReceivingList({
|
|
silentVoice: false
|
|
});
|
|
},
|
|
|
|
// 显示筛选弹窗
|
|
showFilterPopup() {
|
|
this.filterVisible = true;
|
|
},
|
|
openDateFilter() {
|
|
this.showSelectDate = true;
|
|
},
|
|
|
|
// 重置筛选
|
|
resetFilter() {
|
|
this.where = {
|
|
store: 0,
|
|
startDate: this.formatDate(new Date()),
|
|
endDate: this.formatDate(new Date()),
|
|
};
|
|
this.storeName = "全部";
|
|
this.dateModel = 'today';
|
|
this.activeStatus = 'all';
|
|
this.searchKeyword = '';
|
|
},
|
|
|
|
// 应用筛选
|
|
applyFilter() {
|
|
this.filterVisible = false;
|
|
this.nextListVoiceDelay = 700;
|
|
if (this.currentPage !== 1) {
|
|
this.pageChangeSilentVoice = false;
|
|
this.currentPage = 1;
|
|
return;
|
|
}
|
|
this.loadReceivingList({
|
|
silentVoice: false,
|
|
voiceDelay: 700
|
|
});
|
|
},
|
|
|
|
// 新建收货
|
|
createReceiving() {
|
|
this.$store.dispatch('broadcast/stop');
|
|
uni.navigateTo({
|
|
url: './receivingCreate',
|
|
animationType: 'slide-in-right'
|
|
});
|
|
},
|
|
|
|
// 查看收货详情
|
|
viewReceivingDetail(item) {
|
|
this.$store.dispatch('broadcast/stop');
|
|
uni.navigateTo({
|
|
url: `./receivingDetail?id=${item.id}`,
|
|
animationType: 'slide-in-right'
|
|
});
|
|
},
|
|
|
|
// 格式化相对时间
|
|
formatRelativeTime(timestamp) {
|
|
if (!timestamp) return '--';
|
|
|
|
const date = new Date(timestamp);
|
|
const now = new Date();
|
|
const diff = now - date;
|
|
|
|
if (diff < 60 * 1000) {
|
|
return '刚刚';
|
|
} else if (diff < 60 * 60 * 1000) {
|
|
const minutes = Math.floor(diff / (60 * 1000));
|
|
return `${minutes}分钟前`;
|
|
} else if (diff < 24 * 60 * 60 * 1000) {
|
|
const hours = Math.floor(diff / (60 * 60 * 1000));
|
|
return `${hours}小时前`;
|
|
} else if (diff < 30 * 24 * 60 * 60 * 1000) {
|
|
const days = Math.floor(diff / (24 * 60 * 60 * 1000));
|
|
return `${days}天前`;
|
|
} else {
|
|
return this.formatDate(date);
|
|
}
|
|
},
|
|
|
|
// 显示图片预览
|
|
showImgs(urls) {
|
|
if (!urls || urls.length === 0) return;
|
|
|
|
uni.previewImage({
|
|
urls: urls
|
|
});
|
|
},
|
|
|
|
handlePageChange(page) {
|
|
this.pageChangeSilentVoice = true;
|
|
this.currentPage = page;
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.receiving-list {
|
|
min-height: 100vh;
|
|
background-color: #f8f8f8;
|
|
|
|
// 搜索和筛选区域
|
|
.search-filter {
|
|
background: white;
|
|
padding: 20rpx 30rpx;
|
|
border-bottom: 1rpx solid #f0f0f0;
|
|
|
|
.search-box {
|
|
margin-bottom: 20rpx;
|
|
|
|
.search-box-inner {
|
|
position: relative;
|
|
|
|
::v-deep .u-search {
|
|
width: 100%;
|
|
}
|
|
|
|
::v-deep .u-search__content {
|
|
padding-right: 200rpx;
|
|
}
|
|
|
|
::v-deep .u-search__content__close {
|
|
margin-right: 12rpx;
|
|
}
|
|
|
|
.search-actions {
|
|
position: absolute;
|
|
right: 24rpx;
|
|
top: 50%;
|
|
transform: translateY(-50%);
|
|
height: 68rpx;
|
|
display: flex;
|
|
align-items: center;
|
|
}
|
|
|
|
.scan-btn {
|
|
height: 68rpx;
|
|
padding: 0 8rpx 0 4rpx;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
|
|
&:active {
|
|
opacity: 0.88;
|
|
}
|
|
}
|
|
|
|
.search-divider {
|
|
width: 1rpx;
|
|
height: 28rpx;
|
|
background: #dcdfe6;
|
|
margin: 0 16rpx 0 10rpx;
|
|
}
|
|
|
|
.search-btn {
|
|
height: 68rpx;
|
|
padding: 0 8rpx;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
flex-shrink: 0;
|
|
|
|
&__text {
|
|
font-size: 30rpx;
|
|
font-weight: 500;
|
|
color: #2979ff;
|
|
line-height: 1;
|
|
}
|
|
|
|
&:active {
|
|
opacity: 0.88;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
.filter-actions {
|
|
margin-bottom: 20rpx;
|
|
|
|
.filter-buttons {
|
|
display: flex;
|
|
gap: 20rpx;
|
|
|
|
::v-deep .u-btn {
|
|
flex: 1;
|
|
}
|
|
}
|
|
}
|
|
|
|
.status-tags {
|
|
white-space: nowrap;
|
|
height: 70rpx;
|
|
|
|
.status-tag {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
padding: 10rpx 30rpx;
|
|
margin-right: 20rpx;
|
|
background: #f5f5f5;
|
|
border-radius: 30rpx;
|
|
position: relative;
|
|
|
|
&.active {
|
|
background: #007aff;
|
|
|
|
.tag-name {
|
|
color: white;
|
|
}
|
|
}
|
|
|
|
.tag-name {
|
|
font-size: 30rpx;
|
|
color: #666;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// 收货列表内容
|
|
.receiving-list-content {
|
|
height: 100rpx;
|
|
flex: 1;
|
|
|
|
.empty-state {
|
|
padding: 100rpx 0;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
justify-content: center;
|
|
|
|
.empty-text {
|
|
display: block;
|
|
font-size: 40rpx;
|
|
color: #999;
|
|
margin-top: 30rpx;
|
|
margin-bottom: 15rpx;
|
|
}
|
|
|
|
.empty-hint {
|
|
display: block;
|
|
font-size: 30rpx;
|
|
color: #ccc;
|
|
}
|
|
}
|
|
|
|
.receiving-items {
|
|
padding: 20rpx;
|
|
|
|
.receiving-item {
|
|
background: white;
|
|
border-radius: 16rpx;
|
|
padding: 30rpx;
|
|
margin-bottom: 20rpx;
|
|
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.05);
|
|
|
|
.item-header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
margin-bottom: 25rpx;
|
|
padding-bottom: 15rpx;
|
|
border-bottom: 1rpx solid #f0f0f0;
|
|
|
|
.order-no {
|
|
font-size: 42rpx;
|
|
font-weight: 600;
|
|
color: #333;
|
|
}
|
|
}
|
|
|
|
.item-info {
|
|
margin-bottom: 25rpx;
|
|
|
|
.info-row {
|
|
display: flex;
|
|
align-items: center;
|
|
margin-bottom: 15rpx;
|
|
|
|
&:last-child {
|
|
margin-bottom: 0;
|
|
}
|
|
|
|
.info-label {
|
|
font-size: 32rpx;
|
|
color: #666;
|
|
margin-left: 10rpx;
|
|
margin-right: 15rpx;
|
|
min-width: 180rpx;
|
|
}
|
|
|
|
.info-value {
|
|
font-size: 30rpx;
|
|
color: #333;
|
|
flex: 1;
|
|
display: flex;
|
|
align-items: center;
|
|
flex-wrap: wrap;
|
|
|
|
.miniImg {
|
|
width: 60rpx;
|
|
height: 60rpx;
|
|
border-radius: 8rpx;
|
|
margin-right: 10rpx;
|
|
border: 1rpx solid #eee;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
.item-actions {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
padding-top: 20rpx;
|
|
border-top: 1rpx solid #f0f0f0;
|
|
|
|
.create-time {
|
|
font-size: 32rpx;
|
|
color: #999;
|
|
}
|
|
|
|
.action-right {
|
|
display: flex;
|
|
gap: 15rpx;
|
|
|
|
::v-deep .u-btn {
|
|
height: 60rpx;
|
|
font-size: 30rpx;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
.safe-area-bottom {
|
|
height: env(safe-area-inset-bottom);
|
|
}
|
|
}
|
|
|
|
// 筛选弹窗
|
|
.filter-popup {
|
|
padding-bottom: env(safe-area-inset-bottom);
|
|
|
|
.popup-header {
|
|
padding: 40rpx 30rpx 20rpx;
|
|
border-bottom: 1rpx solid #f0f0f0;
|
|
|
|
.popup-title {
|
|
font-size: 36rpx;
|
|
font-weight: 600;
|
|
color: #333;
|
|
}
|
|
}
|
|
|
|
.filter-content {
|
|
max-height: 800rpx;
|
|
padding: 30rpx;
|
|
|
|
.date-range {
|
|
font-size: 28rpx;
|
|
color: #333;
|
|
padding: 10rpx 0;
|
|
}
|
|
|
|
.quick-date-buttons {
|
|
display: grid;
|
|
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
gap: 24rpx 12rpx;
|
|
width: 100%;
|
|
padding: 0 12rpx;
|
|
box-sizing: border-box;
|
|
align-items: stretch;
|
|
justify-content: center;
|
|
margin: 0 auto;
|
|
|
|
&__item {
|
|
width: 100%;
|
|
display: flex;
|
|
|
|
&:not(.is-active) {
|
|
::v-deep .u-btn,
|
|
::v-deep .u-button {
|
|
background: #f3f4f6 !important;
|
|
border-color: #e5e7eb !important;
|
|
box-shadow: none !important;
|
|
}
|
|
|
|
::v-deep .u-btn-text,
|
|
::v-deep .u-button__text {
|
|
color: #666 !important;
|
|
}
|
|
}
|
|
}
|
|
|
|
::v-deep .u-btn {
|
|
width: 100%;
|
|
min-width: 100%;
|
|
height: 76rpx;
|
|
padding: 0 12rpx;
|
|
margin: 0;
|
|
box-sizing: border-box;
|
|
font-size: 32rpx;
|
|
}
|
|
|
|
::v-deep .u-btn-text {
|
|
font-size: 32rpx !important;
|
|
font-weight: 500;
|
|
}
|
|
|
|
::v-deep .u-button {
|
|
width: 100%;
|
|
min-width: 100%;
|
|
height: 76rpx;
|
|
padding: 0 12rpx;
|
|
margin: 0;
|
|
box-sizing: border-box;
|
|
font-size: 32rpx;
|
|
}
|
|
|
|
::v-deep .u-button__text {
|
|
font-size: 32rpx !important;
|
|
font-weight: 500;
|
|
}
|
|
}
|
|
}
|
|
|
|
.popup-actions {
|
|
padding: 30rpx;
|
|
border-top: 1rpx solid #f0f0f0;
|
|
display: flex;
|
|
gap: 20rpx;
|
|
|
|
::v-deep .u-btn {
|
|
flex: 1;
|
|
height: 90rpx;
|
|
font-size: 32rpx;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
.u-form-item__body__left {
|
|
width: 30%;
|
|
}
|
|
</style> |