feat: 新增手动进仓并统一PDA字号标准
This commit is contained in:
@@ -0,0 +1,551 @@
|
||||
<template>
|
||||
<view class="manual-in">
|
||||
<common-navbar title="手动进仓">
|
||||
<template #right>
|
||||
<view class="manual-in__setting" @click="navToSetting">
|
||||
<u-icon name="setting" color="#333333" size="34"></u-icon>
|
||||
<text>设置</text>
|
||||
</view>
|
||||
</template>
|
||||
</common-navbar>
|
||||
|
||||
<view class="manual-in__scan">
|
||||
<input
|
||||
class="manual-in__scan-input"
|
||||
type="text"
|
||||
confirm-type="done"
|
||||
:focus="scanFocus"
|
||||
v-model="scanCode"
|
||||
placeholder="请点击扫描/输入布票编码"
|
||||
placeholder-class="manual-in__placeholder"
|
||||
@confirm="onScanConfirm"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<view class="manual-in__panel">
|
||||
<view class="manual-in__row">
|
||||
<text class="manual-in__label">布票编码</text>
|
||||
<text class="manual-in__value">{{ detail.fabric_piece_code || '-' }}</text>
|
||||
</view>
|
||||
<view class="manual-in__row">
|
||||
<text class="manual-in__label">生产单号</text>
|
||||
<text class="manual-in__value">{{ detail.production_order_no || '-' }}</text>
|
||||
</view>
|
||||
<view class="manual-in__row">
|
||||
<text class="manual-in__label">机台</text>
|
||||
<text class="manual-in__value">{{ detail.machine_number || '-' }}</text>
|
||||
</view>
|
||||
<view class="manual-in__row">
|
||||
<text class="manual-in__label">布种名称</text>
|
||||
<text class="manual-in__value">{{ detail.grey_fabric_name || '-' }}</text>
|
||||
</view>
|
||||
<view class="manual-in__row">
|
||||
<text class="manual-in__label">坯布编号</text>
|
||||
<text class="manual-in__value">{{ detail.grey_fabric_code || '-' }}</text>
|
||||
</view>
|
||||
<view class="manual-in__row manual-in__row--input">
|
||||
<text class="manual-in__label">重量</text>
|
||||
<view class="manual-in__right">
|
||||
<input
|
||||
class="manual-in__field"
|
||||
type="digit"
|
||||
v-model="weightKg"
|
||||
placeholder="请输入"
|
||||
placeholder-class="manual-in__placeholder"
|
||||
/>
|
||||
<text class="manual-in__unit">KG</text>
|
||||
<text class="manual-in__action" @click="clearWeight">取消</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="manual-in__row manual-in__row--input" @click="openLevelPicker">
|
||||
<text class="manual-in__label">等级</text>
|
||||
<view class="manual-in__right">
|
||||
<text :class="levelDisplayName ? 'manual-in__field-text' : 'manual-in__placeholder'">
|
||||
{{ levelDisplayName || '请选择等级' }}
|
||||
</text>
|
||||
<text class="manual-in__action" @click.stop="clearLevel">取消</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="manual-in__row manual-in__row--input" @click="openInspectorPicker">
|
||||
<text class="manual-in__label">查布工</text>
|
||||
<view class="manual-in__right">
|
||||
<text :class="detail.inspector_name ? 'manual-in__field-text' : 'manual-in__placeholder'">
|
||||
{{ detail.inspector_name || '请选择查布工' }}
|
||||
</text>
|
||||
<text class="manual-in__action" @click.stop="clearInspector">取消</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="manual-in__row manual-in__row--input">
|
||||
<text class="manual-in__label">存放仓位</text>
|
||||
<view class="manual-in__right">
|
||||
<input
|
||||
class="manual-in__field"
|
||||
type="text"
|
||||
v-model="warehouseBinName"
|
||||
placeholder="/"
|
||||
placeholder-class="manual-in__placeholder"
|
||||
/>
|
||||
<text class="manual-in__action" @click="editWarehouseBin">修改</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="manual-in__row" v-if="detail.volume_number != null && detail.volume_number !== ''">
|
||||
<text class="manual-in__label">卷号</text>
|
||||
<text class="manual-in__value">{{ detail.volume_number }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="manual-in__footer">
|
||||
<u-button
|
||||
type="primary"
|
||||
shape="circle"
|
||||
:loading="submitting"
|
||||
:disabled="submitting || loadingDetail"
|
||||
@click="submitInWarehouse"
|
||||
>确定进仓</u-button>
|
||||
</view>
|
||||
|
||||
<SearchSelectPopup
|
||||
:show.sync="levelPickerShow"
|
||||
title="选择等级"
|
||||
placeholder="请输入等级名称"
|
||||
:list="levelOptions"
|
||||
@confirm="onLevelConfirm"
|
||||
/>
|
||||
<SearchSelectPopup
|
||||
:show.sync="inspectorPickerShow"
|
||||
title="选择查布工"
|
||||
placeholder="请输入查布工姓名"
|
||||
:list="inspectorOptions"
|
||||
@confirm="onInspectorConfirm"
|
||||
/>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import CommonNavbar from '@/components/common-navbar/index';
|
||||
import SearchSelectPopup from '@/components/storefabric/SearchSelectPopup.vue';
|
||||
import scanMixin from '@/common/scanMixin.js';
|
||||
import { formatWeightKg } from '@/common/storeFabricBusinessOut.js';
|
||||
|
||||
// 坯布等级字典 id(与后台字典配置一致)
|
||||
const DICTIONARY_TYPE_GREY_FABRIC_LEVEL = 10025;
|
||||
// 查布工岗位 duty(验布/查布相关)
|
||||
const INSPECTOR_DUTY = '20004,20011';
|
||||
const WEIGHT_SCALE = 10000;
|
||||
|
||||
function emptyDetail() {
|
||||
return {
|
||||
fabric_piece_code: '',
|
||||
production_order_no: '',
|
||||
machine_number: '',
|
||||
grey_fabric_name: '',
|
||||
grey_fabric_code: '',
|
||||
inspection_weight: null,
|
||||
grey_fabric_level_id: [],
|
||||
grey_fabric_level_name: '',
|
||||
inspector_id: null,
|
||||
inspector_name: '',
|
||||
volume_number: '',
|
||||
grey_fabric_id: '',
|
||||
id: '',
|
||||
};
|
||||
}
|
||||
|
||||
function toWeightInt(kg) {
|
||||
const n = Number(kg);
|
||||
if (!Number.isFinite(n) || n < 0) return null;
|
||||
return Math.round(n * WEIGHT_SCALE);
|
||||
}
|
||||
|
||||
function normalizeLevelIds(value) {
|
||||
if (Array.isArray(value)) {
|
||||
return value.map((item) => Number(item)).filter((item) => Number.isFinite(item));
|
||||
}
|
||||
if (value == null || value === '') return [];
|
||||
const n = Number(value);
|
||||
return Number.isFinite(n) ? [n] : [];
|
||||
}
|
||||
|
||||
export default {
|
||||
components: { CommonNavbar, SearchSelectPopup },
|
||||
mixins: [scanMixin],
|
||||
data() {
|
||||
return {
|
||||
scanCode: '',
|
||||
scanFocus: true,
|
||||
submitting: false,
|
||||
loadingDetail: false,
|
||||
warehouseBinId: null,
|
||||
warehouseBinName: '',
|
||||
weightKg: '',
|
||||
detail: emptyDetail(),
|
||||
levelPickerShow: false,
|
||||
levelOptions: [],
|
||||
levelOptionsLoaded: false,
|
||||
inspectorPickerShow: false,
|
||||
inspectorOptions: [],
|
||||
inspectorOptionsLoaded: false,
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
levelDisplayName() {
|
||||
return this.detail.grey_fabric_level_name || '';
|
||||
},
|
||||
},
|
||||
onLoad() {
|
||||
this.registerScanBroadcast(this.handleScanCode);
|
||||
this.loadLevelOptions();
|
||||
this.loadInspectorOptions();
|
||||
},
|
||||
onShow() {
|
||||
this.scanFocus = false;
|
||||
this.$nextTick(() => {
|
||||
this.scanFocus = true;
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
navToSetting() {
|
||||
uni.navigateTo({ url: '/pages/sys/user/scan-settings' });
|
||||
},
|
||||
clearWeight() {
|
||||
this.weightKg = '';
|
||||
this.detail.inspection_weight = null;
|
||||
},
|
||||
clearLevel() {
|
||||
this.detail.grey_fabric_level_id = [];
|
||||
this.detail.grey_fabric_level_name = '';
|
||||
},
|
||||
clearInspector() {
|
||||
this.detail.inspector_id = null;
|
||||
this.detail.inspector_name = '';
|
||||
},
|
||||
editWarehouseBin() {
|
||||
uni.showModal({
|
||||
title: '存放仓位',
|
||||
editable: true,
|
||||
placeholderText: '请输入仓位名称',
|
||||
content: this.warehouseBinName || '',
|
||||
success: (res) => {
|
||||
if (!res.confirm) return;
|
||||
this.warehouseBinName = (res.content || '').trim();
|
||||
this.warehouseBinId = null;
|
||||
},
|
||||
});
|
||||
},
|
||||
async loadLevelOptions() {
|
||||
try {
|
||||
const res = await this.$u.api.dictionary.getDetailEnumList({
|
||||
dictionary_id: DICTIONARY_TYPE_GREY_FABRIC_LEVEL,
|
||||
status: 1,
|
||||
size: 200,
|
||||
});
|
||||
const list = Array.isArray(res) ? res : (Array.isArray(res && res.list) ? res.list : []);
|
||||
this.levelOptions = list
|
||||
.map((item) => ({
|
||||
value: item.id,
|
||||
label: item.name || item.code || String(item.id),
|
||||
}))
|
||||
.filter((item) => item.value != null);
|
||||
this.levelOptionsLoaded = true;
|
||||
} catch (error) {
|
||||
console.log('加载坯布等级枚举失败', error);
|
||||
this.levelOptions = [];
|
||||
}
|
||||
},
|
||||
async openLevelPicker() {
|
||||
if (!this.levelOptionsLoaded || !this.levelOptions.length) {
|
||||
await this.loadLevelOptions();
|
||||
}
|
||||
if (!this.levelOptions.length) {
|
||||
this.$u.toast('暂无等级可选,请检查等级字典配置');
|
||||
return;
|
||||
}
|
||||
this.levelPickerShow = true;
|
||||
},
|
||||
onLevelConfirm(item) {
|
||||
if (!item) return;
|
||||
this.detail.grey_fabric_level_id = [Number(item.value)];
|
||||
this.detail.grey_fabric_level_name = item.label || '';
|
||||
},
|
||||
async loadInspectorOptions() {
|
||||
try {
|
||||
const res = await this.$u.api.employee.listEnum({
|
||||
size: 50,
|
||||
duty: INSPECTOR_DUTY,
|
||||
});
|
||||
const list = Array.isArray(res) ? res : (Array.isArray(res && res.list) ? res.list : []);
|
||||
this.inspectorOptions = list
|
||||
.map((item) => ({
|
||||
value: item.id,
|
||||
label: item.name || item.employee_name || item.real_name || item.code || String(item.id),
|
||||
}))
|
||||
.filter((item) => item.value != null);
|
||||
this.inspectorOptionsLoaded = true;
|
||||
} catch (error) {
|
||||
console.log('加载查布工枚举失败', error);
|
||||
this.inspectorOptions = [];
|
||||
}
|
||||
},
|
||||
async openInspectorPicker() {
|
||||
if (!this.inspectorOptionsLoaded || !this.inspectorOptions.length) {
|
||||
await this.loadInspectorOptions();
|
||||
}
|
||||
if (!this.inspectorOptions.length) {
|
||||
this.$u.toast('暂无查布工可选');
|
||||
return;
|
||||
}
|
||||
this.inspectorPickerShow = true;
|
||||
},
|
||||
onInspectorConfirm(item) {
|
||||
if (!item) return;
|
||||
this.detail.inspector_id = Number(item.value);
|
||||
this.detail.inspector_name = item.label || '';
|
||||
},
|
||||
handleScanCode(scanResult) {
|
||||
const code = String(scanResult || '').trim().replace(/[\r\n]/g, '');
|
||||
if (!code) return;
|
||||
this.fetchScanDetail(code);
|
||||
},
|
||||
onScanConfirm() {
|
||||
const code = String(this.scanCode || '').trim();
|
||||
if (!code) {
|
||||
this.$u.toast('请扫描或输入布票编码');
|
||||
return;
|
||||
}
|
||||
this.fetchScanDetail(code);
|
||||
},
|
||||
async fetchScanDetail(code) {
|
||||
if (this.loadingDetail) return;
|
||||
this.loadingDetail = true;
|
||||
this.scanCode = code;
|
||||
try {
|
||||
const res = await this.$u.api.productionScheduleOrder.getScanFineCodeDetail({
|
||||
fabric_piece_code: code,
|
||||
});
|
||||
this.applyScanDetail(res, code);
|
||||
} catch (error) {
|
||||
console.log('扫码获取细码失败', error);
|
||||
this.detail = {
|
||||
...emptyDetail(),
|
||||
fabric_piece_code: code,
|
||||
};
|
||||
this.weightKg = '';
|
||||
} finally {
|
||||
this.loadingDetail = false;
|
||||
}
|
||||
},
|
||||
applyScanDetail(res, fallbackCode) {
|
||||
const data = res || {};
|
||||
const levelIds = normalizeLevelIds(data.grey_fabric_level_id);
|
||||
this.detail = {
|
||||
...emptyDetail(),
|
||||
fabric_piece_code: data.fabric_piece_code || fallbackCode || '',
|
||||
production_order_no: data.production_order_no || '',
|
||||
machine_number: data.machine_number || '',
|
||||
grey_fabric_name: data.grey_fabric_name || '',
|
||||
grey_fabric_code: data.grey_fabric_code || '',
|
||||
inspection_weight: data.inspection_weight != null ? data.inspection_weight : null,
|
||||
grey_fabric_level_id: levelIds,
|
||||
grey_fabric_level_name: data.grey_fabric_level_name || '',
|
||||
inspector_id: data.inspector_id != null ? data.inspector_id : null,
|
||||
inspector_name: data.inspector_name || '',
|
||||
};
|
||||
this.weightKg = data.inspection_weight != null
|
||||
? String(formatWeightKg(data.inspection_weight))
|
||||
: '';
|
||||
this.scanCode = this.detail.fabric_piece_code;
|
||||
},
|
||||
async submitInWarehouse() {
|
||||
const fabricPieceCode = String(this.detail.fabric_piece_code || this.scanCode || '').trim();
|
||||
if (!fabricPieceCode) {
|
||||
this.$u.toast('请先扫描或输入布票编码');
|
||||
return;
|
||||
}
|
||||
const actualWeight = toWeightInt(this.weightKg);
|
||||
if (actualWeight == null) {
|
||||
this.$u.toast('请输入有效重量');
|
||||
return;
|
||||
}
|
||||
const levelIds = normalizeLevelIds(this.detail.grey_fabric_level_id);
|
||||
if (!levelIds.length) {
|
||||
this.$u.toast('请选择等级');
|
||||
return;
|
||||
}
|
||||
if (this.submitting) return;
|
||||
this.submitting = true;
|
||||
try {
|
||||
const payload = {
|
||||
fabric_piece_code: fabricPieceCode,
|
||||
actual_weight: actualWeight,
|
||||
electronic_scale_weight: actualWeight,
|
||||
grey_fabric_level_id: levelIds,
|
||||
};
|
||||
const inspectorName = String(this.detail.inspector_name || '').trim();
|
||||
if (inspectorName) {
|
||||
payload.inspector_name = inspectorName;
|
||||
}
|
||||
if (this.detail.inspector_id != null && this.detail.inspector_id !== '') {
|
||||
payload.inspector_id = Number(this.detail.inspector_id);
|
||||
}
|
||||
const binName = String(this.warehouseBinName || '').trim();
|
||||
if (binName && binName !== '/') {
|
||||
payload.warehouse_bin_name = binName;
|
||||
}
|
||||
if (this.warehouseBinId != null && this.warehouseBinId !== '') {
|
||||
payload.warehouse_bin_id = Number(this.warehouseBinId);
|
||||
}
|
||||
const res = await this.$u.api.productionScheduleOrder.scanInWarehouseFineCode(payload);
|
||||
if (res) {
|
||||
this.detail.volume_number = res.volume_number != null ? res.volume_number : this.detail.volume_number;
|
||||
this.detail.grey_fabric_id = res.grey_fabric_id != null ? res.grey_fabric_id : this.detail.grey_fabric_id;
|
||||
this.detail.id = res.id != null ? res.id : this.detail.id;
|
||||
if (res.fabric_piece_code) {
|
||||
this.detail.fabric_piece_code = res.fabric_piece_code;
|
||||
}
|
||||
}
|
||||
const volumeText = res && res.volume_number != null ? `,卷号 ${res.volume_number}` : '';
|
||||
this.$u.toast(`进仓成功${volumeText}`);
|
||||
this.resetForNextScan();
|
||||
} catch (error) {
|
||||
console.log('手动进仓失败', error);
|
||||
} finally {
|
||||
this.submitting = false;
|
||||
}
|
||||
},
|
||||
resetForNextScan() {
|
||||
this.scanCode = '';
|
||||
this.detail = emptyDetail();
|
||||
this.weightKg = '';
|
||||
this.warehouseBinId = null;
|
||||
this.warehouseBinName = '';
|
||||
this.$nextTick(() => {
|
||||
this.scanFocus = false;
|
||||
this.$nextTick(() => {
|
||||
this.scanFocus = true;
|
||||
});
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import '@/common/pda-typography.scss';
|
||||
|
||||
.manual-in {
|
||||
min-height: 100vh;
|
||||
background: #f5f6f8;
|
||||
padding-bottom: 180rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.manual-in__setting {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8rpx;
|
||||
font-size: $pda-font-nav-sub;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.manual-in__scan {
|
||||
margin: 16rpx 0;
|
||||
padding: 0 28rpx;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.manual-in__scan-input {
|
||||
height: $pda-scan-input-height;
|
||||
font-size: $pda-font-body;
|
||||
color: #202328;
|
||||
}
|
||||
|
||||
.manual-in__placeholder {
|
||||
color: #b0b4bb;
|
||||
font-size: $pda-font-placeholder;
|
||||
}
|
||||
|
||||
.manual-in__panel {
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.manual-in__row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
min-height: $pda-row-min-height;
|
||||
padding: 12rpx 28rpx;
|
||||
border-bottom: 1rpx solid #eceff3;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.manual-in__row--input {
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.manual-in__label {
|
||||
width: $pda-label-width;
|
||||
flex-shrink: 0;
|
||||
font-size: $pda-font-body;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.manual-in__value {
|
||||
flex: 1;
|
||||
font-size: $pda-font-body;
|
||||
color: #202328;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.manual-in__right {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
gap: 18rpx;
|
||||
}
|
||||
|
||||
.manual-in__field {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
text-align: right;
|
||||
font-size: $pda-font-body;
|
||||
color: #202328;
|
||||
}
|
||||
|
||||
.manual-in__field-text {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
text-align: right;
|
||||
font-size: $pda-font-body;
|
||||
color: #202328;
|
||||
}
|
||||
|
||||
.manual-in__unit {
|
||||
font-size: $pda-font-unit;
|
||||
color: #666;
|
||||
padding: 6rpx 14rpx;
|
||||
border: 1rpx solid #d7dbe3;
|
||||
border-radius: 8rpx;
|
||||
}
|
||||
|
||||
.manual-in__action {
|
||||
font-size: $pda-font-action;
|
||||
color: #2f78e6;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.manual-in__footer {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
padding: 24rpx 40rpx calc(24rpx + env(safe-area-inset-bottom));
|
||||
background: #fff;
|
||||
box-shadow: 0 -4rpx 16rpx rgba(0, 0, 0, 0.04);
|
||||
}
|
||||
|
||||
::v-deep .manual-in__footer .u-btn {
|
||||
height: $pda-button-height !important;
|
||||
line-height: $pda-button-height !important;
|
||||
font-size: $pda-font-button !important;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user