feat: improve quick actions and receiving scan
This commit is contained in:
parent
ebee728cd2
commit
9c92291bd0
@ -75,14 +75,14 @@
|
|||||||
<view
|
<view
|
||||||
class="grid-item-touch-layer"
|
class="grid-item-touch-layer"
|
||||||
@longpress.stop.prevent="handleQuickActionLongPress($event, slot.action, currentPage - 1, slot.index)"
|
@longpress.stop.prevent="handleQuickActionLongPress($event, slot.action, currentPage - 1, slot.index)"
|
||||||
@click="handleGridItemClick(slot.action)"
|
@click.stop.prevent="handleGridItemClick(slot.action)"
|
||||||
></view>
|
></view>
|
||||||
<view
|
<view
|
||||||
v-if="quickActionRemoveMode"
|
v-if="quickActionRemoveMode"
|
||||||
class="remove-action-btn"
|
class="remove-action-btn"
|
||||||
@click.stop="removeQuickAction(slot.action)"
|
@click.stop="removeQuickAction(slot.action)"
|
||||||
>
|
>
|
||||||
<u-icon name="minus-circle-fill" size="22" color="#ff4d4f"></u-icon>
|
<text class="remove-action-icon">{{ removeActionIconGlyph }}</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="grid-item-content">
|
<view class="grid-item-content">
|
||||||
<view class="item-icon-box" :style="{ background: (slot.action.color || '#2979ff') + '15', color: slot.action.color || '#2979ff' }">
|
<view class="item-icon-box" :style="{ background: (slot.action.color || '#2979ff') + '15', color: slot.action.color || '#2979ff' }">
|
||||||
@ -108,6 +108,7 @@
|
|||||||
class="drag-preview"
|
class="drag-preview"
|
||||||
:style="dragPreviewStyle"
|
:style="dragPreviewStyle"
|
||||||
>
|
>
|
||||||
|
<text v-if="quickActionRemoveMode" class="preview-remove-action-icon">{{ removeActionIconGlyph }}</text>
|
||||||
<view class="item-icon-box" :style="{ background: (dragPreviewSnapshot.color || '#2979ff') + '15', color: dragPreviewSnapshot.color || '#2979ff' }">
|
<view class="item-icon-box" :style="{ background: (dragPreviewSnapshot.color || '#2979ff') + '15', color: dragPreviewSnapshot.color || '#2979ff' }">
|
||||||
<u-icon name="grid" size="26" :color="dragPreviewSnapshot.color || '#2979ff'"></u-icon>
|
<u-icon name="grid" size="26" :color="dragPreviewSnapshot.color || '#2979ff'"></u-icon>
|
||||||
</view>
|
</view>
|
||||||
@ -257,6 +258,10 @@
|
|||||||
return uviewIcons['uicon-grid'] || '\ue673';
|
return uviewIcons['uicon-grid'] || '\ue673';
|
||||||
},
|
},
|
||||||
|
|
||||||
|
removeActionIconGlyph() {
|
||||||
|
return uviewIcons['uicon-minus-circle-fill'] || '\ue652';
|
||||||
|
},
|
||||||
|
|
||||||
totalPages() {
|
totalPages() {
|
||||||
return Math.ceil(this.displayQuickActions.length / this.pageSize) || 1;
|
return Math.ceil(this.displayQuickActions.length / this.pageSize) || 1;
|
||||||
},
|
},
|
||||||
@ -461,7 +466,7 @@
|
|||||||
const latestActions = this.processMenus(userMenus, null);
|
const latestActions = this.processMenus(userMenus, null);
|
||||||
|
|
||||||
// 2. 从Vuex获取已固定的菜单
|
// 2. 从Vuex获取已固定的菜单
|
||||||
const savedFixedMenus = await this.$store.dispatch('setting/getValue', this.FIXED_MENU_KEY) || [];
|
const savedFixedMenus = await this.$store.dispatch('setting/getValue', this.FIXED_MENU_KEY);
|
||||||
const hasSavedConfig = Array.isArray(savedFixedMenus);
|
const hasSavedConfig = Array.isArray(savedFixedMenus);
|
||||||
|
|
||||||
// 3. 如果存在已保存的常用配置(包括空数组),优先按配置展示
|
// 3. 如果存在已保存的常用配置(包括空数组),优先按配置展示
|
||||||
@ -476,8 +481,10 @@
|
|||||||
// 4. 如果没有有效的固定菜单,检查用户菜单
|
// 4. 如果没有有效的固定菜单,检查用户菜单
|
||||||
if (userMenus && userMenus.length > 0) {
|
if (userMenus && userMenus.length > 0) {
|
||||||
console.log('从用户菜单生成快捷入口:', userMenus);
|
console.log('从用户菜单生成快捷入口:', userMenus);
|
||||||
// 根据用户菜单生成快捷入口
|
// 首次登录默认带出前12个菜单,并将收货作业、商品查询前置
|
||||||
this.quickActions = this.processMenus(userMenus, 24).map(item => this.normalizeAction(item)).filter(Boolean);
|
const defaultQuickActions = this.prioritizeDefaultQuickActions(latestActions, 12);
|
||||||
|
this.quickActions = defaultQuickActions.map(item => this.normalizeAction(item)).filter(Boolean);
|
||||||
|
await this.saveQuickActionsOrder();
|
||||||
} else {
|
} else {
|
||||||
// 5. 如果还是没有菜单,返回空数组
|
// 5. 如果还是没有菜单,返回空数组
|
||||||
console.log('用户没有可用菜单');
|
console.log('用户没有可用菜单');
|
||||||
@ -494,6 +501,42 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
prioritizeDefaultQuickActions(actions, limit = 12) {
|
||||||
|
const source = Array.isArray(actions) ? actions.filter(Boolean) : [];
|
||||||
|
if (!source.length) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
const priorities = [
|
||||||
|
(menuName) => menuName === '收货作业' || (menuName.includes('收货') && menuName.includes('作业')),
|
||||||
|
(menuName) => menuName === '商品查询' || (menuName.includes('商品') && menuName.includes('查询'))
|
||||||
|
];
|
||||||
|
|
||||||
|
const selectedKeys = new Set();
|
||||||
|
const prioritized = [];
|
||||||
|
|
||||||
|
priorities.forEach((matcher) => {
|
||||||
|
const matched = source.find((item) => {
|
||||||
|
const menuName = this.sanitizeText(item?.name || item?.meta?.title);
|
||||||
|
const key = this.getMenuKey(item);
|
||||||
|
return key && !selectedKeys.has(key) && matcher(menuName);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (matched) {
|
||||||
|
const key = this.getMenuKey(matched);
|
||||||
|
selectedKeys.add(key);
|
||||||
|
prioritized.push(matched);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const remaining = source.filter((item) => {
|
||||||
|
const key = this.getMenuKey(item);
|
||||||
|
return key && !selectedKeys.has(key);
|
||||||
|
});
|
||||||
|
|
||||||
|
return [...prioritized, ...remaining].slice(0, limit);
|
||||||
|
},
|
||||||
|
|
||||||
// 辅助方法:验证和过滤菜单权限
|
// 辅助方法:验证和过滤菜单权限
|
||||||
validateAndFilterMenus(fixedMenus, latestActions) {
|
validateAndFilterMenus(fixedMenus, latestActions) {
|
||||||
if (!Array.isArray(fixedMenus) || !Array.isArray(latestActions)) return [];
|
if (!Array.isArray(fixedMenus) || !Array.isArray(latestActions)) return [];
|
||||||
@ -1376,6 +1419,16 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
|
||||||
|
.remove-action-icon {
|
||||||
|
font-family: 'uicon-iconfont' !important;
|
||||||
|
font-size: 44rpx;
|
||||||
|
line-height: 1;
|
||||||
|
font-style: normal;
|
||||||
|
font-weight: normal;
|
||||||
|
color: #ff4d4f;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.grid-item-content {
|
.grid-item-content {
|
||||||
@ -1387,6 +1440,7 @@
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.item-icon-box {
|
.item-icon-box {
|
||||||
@ -1480,6 +1534,19 @@
|
|||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
transform: scale(1.05);
|
transform: scale(1.05);
|
||||||
|
|
||||||
|
.preview-remove-action-icon {
|
||||||
|
position: absolute;
|
||||||
|
top: 8rpx;
|
||||||
|
right: 8rpx;
|
||||||
|
font-family: 'uicon-iconfont' !important;
|
||||||
|
font-size: 44rpx;
|
||||||
|
line-height: 1;
|
||||||
|
font-style: normal;
|
||||||
|
font-weight: normal;
|
||||||
|
color: #ff4d4f;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
.item-icon-box {
|
.item-icon-box {
|
||||||
width: 100rpx;
|
width: 100rpx;
|
||||||
height: 100rpx;
|
height: 100rpx;
|
||||||
|
|||||||
@ -29,7 +29,12 @@
|
|||||||
<!-- 物流单号(非货车时显示) -->
|
<!-- 物流单号(非货车时显示) -->
|
||||||
<u-form-item v-if="formData.delivery_method !== 'truck' && formData.delivery_method !== 'other'"
|
<u-form-item v-if="formData.delivery_method !== 'truck' && formData.delivery_method !== 'other'"
|
||||||
label="物流单号" prop="tracking_number">
|
label="物流单号" prop="tracking_number">
|
||||||
<u-input v-model="formData.tracking_number" placeholder="请输入快递/物流单号" maxlength="100" />
|
<view class="tracking-input-wrap">
|
||||||
|
<u-input v-model="formData.tracking_number" placeholder="请输入快递/物流单号" maxlength="100" />
|
||||||
|
<view class="scan-camera-btn" @click="handleTrackingScan">
|
||||||
|
<u-icon name="camera" size="34rpx" color="#2979ff"></u-icon>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
</u-form-item>
|
</u-form-item>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
@ -180,6 +185,64 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
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 '';
|
||||||
|
},
|
||||||
|
handleTrackingScan() {
|
||||||
|
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.formData.tracking_number = rawCode;
|
||||||
|
},
|
||||||
|
fail: (error) => {
|
||||||
|
const errMsg = String(error?.errMsg || '').toLowerCase();
|
||||||
|
if (errMsg.includes('cancel')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
uni.showToast({
|
||||||
|
title: '扫码失败,请重试',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
async loadStore() {
|
async loadStore() {
|
||||||
try {
|
try {
|
||||||
const res = await this.$http("common.store", {});
|
const res = await this.$http("common.store", {});
|
||||||
@ -224,8 +287,12 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
// 如果没有提取到设备编号,也直接忽略,不提示用户
|
// 如果没有提取到设备编号,也直接忽略,不提示用户
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.formData.delivery_method === 'express') {
|
||||||
|
this.formData.tracking_number = scanText;
|
||||||
}
|
}
|
||||||
// 如果不是REC开头的扫描,直接忽略
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async handleSubmit() {
|
async handleSubmit() {
|
||||||
@ -335,6 +402,33 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.tracking-input-wrap {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 16rpx;
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
::v-deep .u-input {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.scan-camera-btn {
|
||||||
|
width: 76rpx;
|
||||||
|
height: 76rpx;
|
||||||
|
border-radius: 38rpx;
|
||||||
|
background: #eef4ff;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
flex-shrink: 0;
|
||||||
|
box-shadow: 0 4rpx 12rpx rgba(41, 121, 255, 0.12);
|
||||||
|
|
||||||
|
&:active {
|
||||||
|
opacity: 0.85;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.submit-area {
|
.submit-area {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user