chen.llin
2 天以前 d2dbf327d56fd6d931fff23a75f0e5a38f2aa316
增加清空缓存库位功能
1个文件已修改
397 ■■■■ 已修改文件
pages/stock/locCacheLock.vue 397 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/stock/locCacheLock.vue
@@ -7,10 +7,16 @@
                    <uni-icons type="scan" size="18" color="#667eea"></uni-icons>
                    <text class="label-text">缓存库位号</text>
                </view>
                <view class="form-input-row">
                <view class="form-input-wrap">
                    <input class="form-input" type="text" placeholder="扫码 / 输入缓存库位号" v-model="locNo" 
                        :focus="locNoFocus" @input="locNoInput()" @focus="onLocNoFocus()" @blur="onLocNoBlur()" />
                    <uni-icons v-if="locNo" type="clear" size="18" color="#c0c4cc" @click="clearLocNo"></uni-icons>
                    </view>
                    <view class="btn-reset-inline" @click="reset()">
                        <uni-icons type="refresh" size="18" color="#909399"></uni-icons>
                        <text class="btn-text">重置</text>
                    </view>
                </view>
            </view>
        </view>
@@ -54,44 +60,25 @@
            </view>
        </view>
        
        <!-- 底部操作按钮 -->
        <!-- 底部操作按钮(容易按的位置) -->
        <view class="bottom-bar">
            <view class="btn-reset" @click="reset()">
                <uni-icons type="refresh" size="18" color="#909399"></uni-icons>
                <text class="btn-text">重置</text>
            <view class="btn-group-main">
                <!-- 主要按钮(左侧) -->
                <view class="btn-unlock-main" :class="{'btn-disabled': !locCacheInfo || isSubmitting}" @click="unlockLoc()">
                    <uni-icons type="unlocked" size="20" color="#ffffff"></uni-icons>
                    <text class="btn-text-main">确认已取走当前库位</text>
            </view>
            <view class="btn-group">
                <view class="btn-unlock" :class="{'btn-disabled': !locCacheInfo || isSubmitting}" @click="unlockLoc()">
                    <uni-icons type="unlocked" size="18" color="#ffffff"></uni-icons>
                    <text class="btn-text">确认已取走当前库位</text>
                <!-- 排操作按钮(小一点,放在中间) -->
                <view class="btn-row-small" v-if="locCacheInfo">
                    <view class="btn-unlock-row-small" :class="{'btn-disabled': isSubmitting}" @click="unlockRow()">
                        <uni-icons type="unlocked" size="14" color="#ffffff"></uni-icons>
                        <text class="btn-text-small">取走当前排</text>
                </view>
                </view>
                <!-- 标记在库按钮(右侧) -->
                <view class="btn-lock" :class="{'btn-disabled': !locCacheInfo || isSubmitting}" @click="lockLoc()">
                    <uni-icons type="locked" size="18" color="#ffffff"></uni-icons>
                    <text class="btn-text">标记为在库</text>
                </view>
            </view>
        </view>
        <!-- 列操作按钮 -->
        <view class="row-bar" v-if="locCacheInfo">
            <view class="btn-group-row">
                <view class="btn-unlock-row" :class="{'btn-disabled': isSubmitting}" @click="unlockBay()">
                    <uni-icons type="unlocked" size="18" color="#ffffff"></uni-icons>
                    <text class="btn-text">确认已取走当前列</text>
                </view>
                <view class="btn-lock-row" :class="{'btn-disabled': isSubmitting}" @click="lockBay()">
                    <uni-icons type="locked" size="18" color="#ffffff"></uni-icons>
                    <text class="btn-text">标记当前列在库</text>
                </view>
            </view>
        </view>
        <!-- 排操作按钮 -->
        <view class="row-bar" v-if="locCacheInfo" style="margin-top: 10px;">
            <view class="btn-group-row">
                <view class="btn-unlock-row" :class="{'btn-disabled': isSubmitting}" @click="clearAllColumnsInRow()">
                    <uni-icons type="trash" size="18" color="#ffffff"></uni-icons>
                    <text class="btn-text">确认已取走当前排</text>
                </view>
            </view>
        </view>
@@ -130,7 +117,7 @@
                </view>
                <view class="popup-footer">
                    <view class="popup-btn cancel" @click="closeFullPltDialog">取消</view>
                    <view class="popup-btn confirm" :class="{'disabled': selectedFullPlt === null}" @click="confirmFullPlt">确认</view>
                    <view class="popup-btn confirm" @click="confirmFullPlt">确认</view>
                </view>
            </view>
        </uni-popup>
@@ -153,9 +140,9 @@
                title: '',
                content: '',
                isSubmitting: false,
                actionType: '', // 'lock', 'unlock', 'lockBay', 'unlockBay'
                actionType: '', // 'lock', 'unlock', 'lockRow', 'unlockRow'
                actionLocNo: '',
                selectedFullPlt: null // true-满托, false-空托, null-未选择
                selectedFullPlt: true // true-满托, false-空托,默认满托
            }
        },
        onLoad() {
@@ -248,7 +235,7 @@
                if (!this.locCacheInfo || this.isSubmitting) return;
                this.actionType = 'lock';
                this.actionLocNo = this.locNo;
                this.selectedFullPlt = null;
                this.selectedFullPlt = true; // 默认选中满托
                this.$refs.fullPltDialog.open();
            },
            // 确认已取走当前库位
@@ -260,56 +247,150 @@
                this.content = '确认已取走库位:' + this.locNo + '?';
                this.$refs.confirmDialog.open();
            },
            // 标记当前列在库
            lockBay() {
            // 确认已取走当前排(只处理1,2,3列)
            unlockRow() {
                if (!this.locCacheInfo || this.isSubmitting) return;
                this.actionType = 'lockBay';
                this.actionType = 'unlockRow';
                this.actionLocNo = this.locNo;
                this.selectedFullPlt = null;
                this.title = '确认操作';
                this.content = '确认已取走第' + this.locCacheInfo.row1 + '排的所有库位(1、2、3列)?';
                this.$refs.confirmDialog.open();
            },
            // 标记当前排在库(只处理1,2,3列)
            lockRow() {
                if (!this.locCacheInfo || this.isSubmitting) return;
                this.actionType = 'lockRow';
                this.actionLocNo = this.locNo;
                this.selectedFullPlt = true; // 默认选中满托
                this.$refs.fullPltDialog.open();
            },
            // 确认已取走当前列
            unlockBay() {
                if (!this.locCacheInfo || this.isSubmitting) return;
                this.actionType = 'unlockBay';
                this.actionLocNo = this.locNo;
                this.title = '确认操作';
                this.content = '确认已取走第' + this.locCacheInfo.bay1 + '列的所有库位?';
                this.$refs.confirmDialog.open();
            },
            // 确认已取走当前排
            clearAllColumnsInRow() {
                if (!this.locCacheInfo || this.isSubmitting) return;
                this.actionType = 'clearAllColumnsInRow';
                this.actionLocNo = this.locNo;
                this.title = '确认操作';
                this.content = '确认已取走第' + this.locCacheInfo.row1 + '排的所有库位(所有列)?';
                this.$refs.confirmDialog.open();
            },
            // 选择满托/空托
            selectFullPlt(fullPlt) {
                this.selectedFullPlt = fullPlt;
            },
            // 确认满托/空托选择
            // 确认满托/空托选择(直接执行,不再弹出二次确认)
            confirmFullPlt() {
                if (this.selectedFullPlt === null) return;
                // 默认选中满托,所以不需要检查null
                this.$refs.fullPltDialog.close();
                // 显示确认对话框
                if (this.actionType === 'lock') {
                    this.title = '确认标记';
                    this.content = '确认将库位:' + this.actionLocNo + ' 标记为在库(' + (this.selectedFullPlt ? '满托' : '空托') + ')?';
                } else if (this.actionType === 'lockBay') {
                    this.title = '确认标记';
                    this.content = '确认将第' + this.locCacheInfo.bay1 + '列的所有库位标记为在库(' + (this.selectedFullPlt ? '满托' : '空托') + ')?';
                }
                this.$refs.confirmDialog.open();
                // 直接执行操作,不再弹出确认对话框
                this.executeLockAction();
            },
            // 关闭满托/空托选择弹窗
            closeFullPltDialog() {
                this.$refs.fullPltDialog.close();
                this.selectedFullPlt = null;
                this.selectedFullPlt = true; // 重置为默认值(满托)
            },
            // 确认操作
            // 执行锁定操作(从满托/空托选择弹窗直接调用)
            executeLockAction() {
                if (this.isSubmitting) return;
                this.isSubmitting = true;
                let that = this;
                let url = '';
                let data = {};
                if (this.actionType === 'lock') {
                    // 锁定单个库位
                    url = that.baseUrl + '/locCache/lockOrUnlock/auth';
                    // 确保 locNo 有值,优先使用 actionLocNo,如果没有则使用 locNo
                    var locNoValue = that.actionLocNo || that.locNo;
                    if (!locNoValue) {
                        that.messageText = "库位号不能为空";
                        that.msgType = 'error';
                        that.$refs.message.open();
                        that.isSubmitting = false;
                        return;
                    }
                    data = {
                        locNo: locNoValue,
                        lock: true,
                        fullPlt: that.selectedFullPlt
                    };
                } else if (this.actionType === 'lockRow') {
                    // 锁定当前排(只处理1,2,3列)
                    url = that.baseUrl + '/locCache/lockOrUnlockRow/auth';
                    // 确保 locNo 有值,优先使用 actionLocNo,如果没有则使用 locNo
                    var locNoValue = that.actionLocNo || that.locNo;
                    if (!locNoValue) {
                        that.messageText = "库位号不能为空";
                        that.msgType = 'error';
                        that.$refs.message.open();
                        that.isSubmitting = false;
                        return;
                    }
                    data = {
                        locNo: locNoValue,
                        lock: true,
                        fullPlt: that.selectedFullPlt
                    };
                } else {
                    that.isSubmitting = false;
                    return;
                }
                // 将数据转换为表单格式(URL编码)
                let formData = '';
                for (let key in data) {
                    if (data.hasOwnProperty(key)) {
                        if (formData !== '') formData += '&';
                        formData += encodeURIComponent(key) + '=' + encodeURIComponent(data[key]);
                    }
                }
                uni.request({
                    url: url,
                    method: 'POST',
                    data: formData,
                    header: {
                        'token': uni.getStorageSync('token'),
                        'Content-Type': 'application/x-www-form-urlencoded'
                    },
                    success(result) {
                        var res = result.data;
                        if (res.code === 200) {
                            let actionDesc = '';
                            if (that.actionType === 'lock') {
                                actionDesc = '标记为在库(' + (that.selectedFullPlt ? '满托' : '空托') + ')';
                            } else if (that.actionType === 'lockRow') {
                                actionDesc = '标记当前排在库(' + (that.selectedFullPlt ? '满托' : '空托') + ')';
                            }
                            that.messageText = actionDesc + '成功';
                            that.msgType = 'success';
                            that.$refs.message.open();
                            // 操作成功后,清空文本框和库位信息,方便用户输入新的库位号
                            that.locNo = '';
                            that.locCacheInfo = null;
                            that.selectedFullPlt = true; // 重置为默认值(满托)
                            // 聚焦到输入框
                            setTimeout(() => {
                                that.locNoFocus = true;
                            }, 100);
                        } else if (res.code == 403) {
                            that.messageText = res.msg;
                            that.msgType = 'error';
                            that.$refs.message.open();
                            setTimeout(() => {
                                uni.reLaunch({
                                    url: '../login/login'
                                });
                            }, 1000);
                        } else {
                            that.messageText = res.msg || "操作失败";
                            that.msgType = 'error';
                            that.$refs.message.open();
                        }
                    },
                    fail: () => {
                        that.messageText = "网络请求超时";
                        that.msgType = 'error';
                        that.$refs.message.open();
                    },
                    complete: () => {
                        that.isSubmitting = false;
                    }
                });
            },
            // 确认操作(用于解锁操作)
            confirmAction() {
                if (this.isSubmitting) return;
                
@@ -318,68 +399,79 @@
                let url = '';
                let data = {};
                
                if (this.actionType === 'lock' || this.actionType === 'unlock') {
                    // 锁定/解锁单个库位
                if (this.actionType === 'unlock') {
                    // 解锁单个库位
                    url = that.baseUrl + '/locCache/lockOrUnlock/auth';
                    data = {
                        locNo: that.actionLocNo,
                        lock: that.actionType === 'lock'
                    };
                    // 如果是锁定操作,需要传递fullPlt参数
                    if (that.actionType === 'lock') {
                        data.fullPlt = that.selectedFullPlt;
                    // 确保 locNo 有值,优先使用 actionLocNo,如果没有则使用 locNo
                    var locNoValue = that.actionLocNo || that.locNo;
                    if (!locNoValue) {
                        that.messageText = "库位号不能为空";
                        that.msgType = 'error';
                        that.$refs.message.open();
                        that.isSubmitting = false;
                        return;
                    }
                } else if (this.actionType === 'lockBay' || this.actionType === 'unlockBay') {
                    // 锁定/解锁当前列
                    url = that.baseUrl + '/locCache/lockOrUnlockBay/auth';
                    data = {
                        locNo: that.actionLocNo,
                        lock: that.actionType === 'lockBay'
                        locNo: locNoValue,
                        lock: false
                    };
                    // 如果是锁定操作,需要传递fullPlt参数
                    if (that.actionType === 'lockBay') {
                        data.fullPlt = that.selectedFullPlt;
                } else if (this.actionType === 'unlockRow') {
                    // 解锁当前排(只处理1,2,3列)
                    url = that.baseUrl + '/locCache/lockOrUnlockRow/auth';
                    // 确保 locNo 有值,优先使用 actionLocNo,如果没有则使用 locNo
                    var locNoValue = that.actionLocNo || that.locNo;
                    if (!locNoValue) {
                        that.messageText = "库位号不能为空";
                        that.msgType = 'error';
                        that.$refs.message.open();
                        that.isSubmitting = false;
                        return;
                    }
                } else if (this.actionType === 'clearAllColumnsInRow') {
                    // 清空整排(所有列)
                    url = that.baseUrl + '/locCache/clearAllColumnsInRow/auth';
                    data = {
                        locNo: that.actionLocNo,
                        lock: false  // 清空操作,lock=false
                        locNo: locNoValue,
                        lock: false
                    };
                } else {
                    that.isSubmitting = false;
                    return;
                }
                // 将数据转换为表单格式(URL编码)
                let formData = '';
                for (let key in data) {
                    if (data.hasOwnProperty(key)) {
                        if (formData !== '') formData += '&';
                        formData += encodeURIComponent(key) + '=' + encodeURIComponent(data[key]);
                    }
                }
                
                uni.request({
                    url: url,
                    method: 'POST',
                    data: data,
                    data: formData,
                    header: {
                        'token': uni.getStorageSync('token')
                        'token': uni.getStorageSync('token'),
                        'Content-Type': 'application/x-www-form-urlencoded'
                    },
                    success(result) {
                        var res = result.data;
                        if (res.code === 200) {
                            let actionDesc = '';
                            if (that.actionType === 'lock') {
                                actionDesc = '标记为在库(' + (that.selectedFullPlt ? '满托' : '空托') + ')';
                            } else if (that.actionType === 'unlock') {
                            if (that.actionType === 'unlock') {
                                actionDesc = '确认已取走当前库位';
                            } else if (that.actionType === 'lockBay') {
                                actionDesc = '标记当前列在库(' + (that.selectedFullPlt ? '满托' : '空托') + ')';
                            } else if (that.actionType === 'unlockBay') {
                                actionDesc = '确认已取走当前列';
                            } else if (that.actionType === 'clearAllColumnsInRow') {
                            } else if (that.actionType === 'unlockRow') {
                                actionDesc = '确认已取走当前排';
                            }
                            that.messageText = actionDesc + '成功';
                            that.msgType = 'success';
                            that.$refs.message.open();
                            // 重新查询库位信息
                            // 操作成功后,清空文本框和库位信息,方便用户输入新的库位号
                            that.locNo = '';
                            that.locCacheInfo = null;
                            // 聚焦到输入框
                            setTimeout(() => {
                                that.queryLocCache();
                            }, 500);
                            // 重置选择
                            that.selectedFullPlt = null;
                                that.locNoFocus = true;
                            }, 100);
                        } else if (res.code == 403) {
                            that.messageText = res.msg;
                            that.msgType = 'error';
@@ -414,7 +506,7 @@
            reset() {
                this.locNo = '';
                this.locCacheInfo = null;
                this.selectedFullPlt = null;
                this.selectedFullPlt = true; // 重置为默认值(满托)
                this.locNoFocus = false;
                setTimeout(() => {
                    this.locNoFocus = true;
@@ -444,6 +536,36 @@
    /* 引入公共样式 */
    @import url('../../static/css/common.css');
    @import url('../../static/css/wms.css/wms.css');
    /* 表单输入行样式 */
    .form-input-row {
        display: flex;
        align-items: center;
        gap: 12rpx;
    }
    .form-input-wrap {
        flex: 1;
    }
    /* 内联重置按钮样式 */
    .btn-reset-inline {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6rpx;
        padding: 0 20rpx;
        height: 72rpx;
        background: #f5f7fa;
        border-radius: 8rpx;
        border: 1rpx solid #e4e7ed;
        flex-shrink: 0;
    }
    .btn-reset-inline .btn-text {
        font-size: 26rpx;
        color: #909399;
    }
    
    .info-section {
        padding: 20rpx;
@@ -516,6 +638,63 @@
        gap: 20rpx;
    }
    
    .btn-group-main {
        display: flex;
        flex: 1;
        align-items: center;
        gap: 12rpx;
        justify-content: space-between;
    }
    .btn-row-small {
        display: flex;
        align-items: center;
        flex-shrink: 0;
        order: 2; /* 放在中间位置 */
    }
    .btn-unlock-main {
        order: 1; /* 左侧 */
    }
    .btn-lock {
        order: 3; /* 右侧 */
    }
    .btn-unlock-row-small {
        height: 64rpx;
        padding: 0 20rpx;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 8rpx;
        gap: 8rpx;
        background: linear-gradient(135deg, #67c23a 0%, #85ce61 100%);
    }
    .btn-text-small {
        font-size: 24rpx;
        color: #ffffff;
        font-weight: 500;
    }
    .btn-unlock-main {
        flex: 1;
        height: 88rpx;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 12rpx;
        gap: 12rpx;
        background: linear-gradient(135deg, #67c23a 0%, #85ce61 100%);
    }
    .btn-text-main {
        font-size: 32rpx;
        color: #ffffff;
        font-weight: 600;
    }
    .btn-unlock, .btn-lock {
        flex: 1;
        height: 88rpx;