feat: 新增商品信息维护页及作业要求(打包/拣货/复核)字段
- 新增 pages/work/product/itemMaint 维护页并在 pages.json 注册 - 商品查询页新增「维护信息」入口,扫码带出商品后跳转 - edit/detail 页新增拣货、复核要求字段,支持要求合并/拆分切换 - 首页与快捷操作拦截「商品信息维护」,仅限商品查询页使用
This commit is contained in:
parent
4d33fc3241
commit
8318b3a688
@ -194,6 +194,13 @@
|
||||
"titleNView": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"path" : "pages/work/product/itemMaint",
|
||||
"style" :
|
||||
{
|
||||
"titleNView": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"path" : "pages/work/order/picking",
|
||||
"style" :
|
||||
|
||||
@ -327,6 +327,7 @@
|
||||
const normalizedPath = rawPath ? (rawPath.startsWith('/') ? rawPath : `/${rawPath}`) : '';
|
||||
const isRandomStorage = menuName === '随机入库' || (menuName.includes('随机') && menuName.includes('入库'));
|
||||
const isRelocation = menuName === '移库作业' || normalizedPath === '/pages/work/storage/relocation';
|
||||
const isItemMaint = menuName === '商品信息维护' || normalizedPath === '/pages/work/product/itemMaint';
|
||||
if (isRelocation) {
|
||||
uni.showToast({
|
||||
title: '该功能只支持在商品查询页面使用!',
|
||||
@ -335,6 +336,14 @@
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (isItemMaint) {
|
||||
uni.showToast({
|
||||
title: '该功能只支持在商品查询页面使用!',
|
||||
icon: 'none',
|
||||
duration: 2500
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (isRandomStorage) {
|
||||
this.$tools.routerTo('/pages/work/storage/random-storage');
|
||||
return;
|
||||
|
||||
@ -1367,6 +1367,7 @@
|
||||
const normalizedPath = rawPath ? (rawPath.startsWith('/') ? rawPath : `/${rawPath}`) : '';
|
||||
const isRandomStorage = menuName === '随机入库' || (menuName.includes('随机') && menuName.includes('入库'));
|
||||
const isRelocation = menuName === '移库作业' || normalizedPath === '/pages/work/storage/relocation';
|
||||
const isItemMaint = menuName === '商品信息维护' || normalizedPath === '/pages/work/product/itemMaint';
|
||||
if (isRelocation) {
|
||||
uni.showToast({
|
||||
title: '该功能只支持在商品查询页面使用!',
|
||||
@ -1375,6 +1376,14 @@
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (isItemMaint) {
|
||||
uni.showToast({
|
||||
title: '该功能只支持在商品查询页面使用!',
|
||||
icon: 'none',
|
||||
duration: 2500
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (isRandomStorage) {
|
||||
this.$tools.routerTo('/pages/work/storage/random-storage');
|
||||
return;
|
||||
|
||||
@ -235,11 +235,20 @@
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<!-- 打包要求 -->
|
||||
<!-- 作业要求 -->
|
||||
<view class="detail-section-title">作业要求</view>
|
||||
<view class="info-row info-row--multiline">
|
||||
<text class="label">打包要求:</text>
|
||||
<text class="value value--multiline">{{ getValue(item, ['packing_requirements', 'package_requirement', 'packing_requirement', 'package_requirements']) }}</text>
|
||||
</view>
|
||||
<view class="info-row info-row--multiline">
|
||||
<text class="label">拣货要求:</text>
|
||||
<text class="value value--multiline">{{ getValue(item, ['pick_requirements', 'pick_requirement']) }}</text>
|
||||
</view>
|
||||
<view class="info-row info-row--multiline">
|
||||
<text class="label">复核要求:</text>
|
||||
<text class="value value--multiline">{{ getValue(item, ['recheck_requirements', 'recheck_requirement']) }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="label">创建时间:</text>
|
||||
<text class="value">{{ item.create_at_display || '--' }}</text>
|
||||
|
||||
@ -116,9 +116,25 @@
|
||||
<u-input v-model="formData.box_volume" type="digit" placeholder="请输入箱体积" clearable></u-input>
|
||||
</u-form-item>
|
||||
</view>
|
||||
<!-- 打包要求 -->
|
||||
<u-form-item label="打包要求">
|
||||
<u-textarea v-model="formData.packing_requirements" placeholder="请输入打包要求" height="140" border="surround"></u-textarea>
|
||||
<!-- 作业要求 -->
|
||||
<view class="form-section-title form-section-title--row">
|
||||
<text>作业要求</text>
|
||||
<view class="merge-toggle">
|
||||
<text class="merge-toggle__text">要求合并</text>
|
||||
<u-switch v-model="mergeRequirements" active-color="#2979ff" @change="handleMergeRequirementsChange"></u-switch>
|
||||
</view>
|
||||
</view>
|
||||
<u-form-item v-show="mergeRequirements" label-width="0">
|
||||
<u-textarea v-model="formData.packing_requirements" placeholder="请输入作业要求" height="140" border="surround"></u-textarea>
|
||||
</u-form-item>
|
||||
<u-form-item v-show="!mergeRequirements" label="打包要求">
|
||||
<u-textarea v-model="formData.packing_requirements" placeholder="请输入打包要求" height="120" border="surround"></u-textarea>
|
||||
</u-form-item>
|
||||
<u-form-item v-show="!mergeRequirements" label="拣货要求">
|
||||
<u-textarea v-model="formData.pick_requirements" placeholder="请输入拣货要求" height="120" border="surround"></u-textarea>
|
||||
</u-form-item>
|
||||
<u-form-item v-show="!mergeRequirements" label="复核要求">
|
||||
<u-textarea v-model="formData.recheck_requirements" placeholder="请输入复核要求" height="120" border="surround"></u-textarea>
|
||||
</u-form-item>
|
||||
<u-form-item label="商品图片">
|
||||
<view class="product-image-upload-wrap">
|
||||
@ -190,6 +206,7 @@ export default {
|
||||
latestImagesLoadPromise: null,
|
||||
showProhibitedPicker: false,
|
||||
showStockUnitPicker: false,
|
||||
mergeRequirements: true,
|
||||
prohibitedTypeList: [],
|
||||
stockUnitList: [],
|
||||
formData: {
|
||||
@ -222,6 +239,8 @@ export default {
|
||||
box_width: '',
|
||||
box_height: '',
|
||||
box_volume: '',
|
||||
pick_requirements: '',
|
||||
recheck_requirements: '',
|
||||
packing_requirements: '',
|
||||
images: [],
|
||||
stock_unit_value: '',
|
||||
@ -288,7 +307,10 @@ export default {
|
||||
this.formData.box_width = this.normalizeInputValue(cached.box_width);
|
||||
this.formData.box_height = this.normalizeInputValue(cached.box_height);
|
||||
this.formData.box_volume = this.normalizeInputValue(cached.box_volume);
|
||||
this.formData.pick_requirements = String(cached.pick_requirements || cached.pick_requirement || '');
|
||||
this.formData.recheck_requirements = String(cached.recheck_requirements || cached.recheck_requirement || '');
|
||||
this.formData.packing_requirements = String(cached.packing_requirements || '');
|
||||
this.mergeRequirements = this.loadMergeRequirementsPreference();
|
||||
this.formData.images = this.normalizeImageListForUpload(cached);
|
||||
this.formData.stock_unit = String(cached.stock_unit || '');
|
||||
this.formData.stock_unit_value = String(cached.stock_unit || '');
|
||||
@ -525,6 +547,27 @@ export default {
|
||||
this.speakProductEditMessage(options.speakText || message, options.voiceOptions || {});
|
||||
}
|
||||
},
|
||||
loadMergeRequirementsPreference() {
|
||||
try {
|
||||
const saved = uni.getStorageSync('product_edit_merge_requirements');
|
||||
if (saved === '' || saved === null || saved === undefined) {
|
||||
return true;
|
||||
}
|
||||
if (typeof saved === 'boolean') {
|
||||
return saved;
|
||||
}
|
||||
return String(saved) === 'true' || String(saved) === '1';
|
||||
} catch (error) {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
handleMergeRequirementsChange(value) {
|
||||
try {
|
||||
uni.setStorageSync('product_edit_merge_requirements', !!value);
|
||||
} catch (error) {
|
||||
console.warn('[ProductEdit] 保存要求合并偏好失败:', error);
|
||||
}
|
||||
},
|
||||
resolveStoreId(item) {
|
||||
if (!item || typeof item !== 'object') {
|
||||
return null;
|
||||
@ -1338,6 +1381,8 @@ export default {
|
||||
sku_property: String(this.formData.sku_property || '').trim(),
|
||||
stock_unit: stockUnit,
|
||||
packing_requirements: String(this.formData.packing_requirements || '').trim(),
|
||||
pick_requirements: String(this.formData.pick_requirements || '').trim(),
|
||||
recheck_requirements: String(this.formData.recheck_requirements || '').trim(),
|
||||
length: Number(this.formData.length) || 0,
|
||||
width: Number(this.formData.width) || 0,
|
||||
height: Number(this.formData.height) || 0,
|
||||
@ -1446,6 +1491,8 @@ export default {
|
||||
box_height: String(this.formData.box_height || ''),
|
||||
box_volume: String(this.formData.box_volume || ''),
|
||||
packing_requirements: String(this.formData.packing_requirements || '').trim(),
|
||||
pick_requirements: String(this.formData.pick_requirements || '').trim(),
|
||||
recheck_requirements: String(this.formData.recheck_requirements || '').trim(),
|
||||
images: normalizedImages,
|
||||
image: normalizedImageUrls[0] || '',
|
||||
stock_unit: stockUnit,
|
||||
@ -1522,6 +1569,29 @@ export default {
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
.form-section-title--row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.merge-toggle {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.merge-toggle__text {
|
||||
margin-right: 12rpx;
|
||||
font-size: 26rpx;
|
||||
font-weight: normal;
|
||||
color: #606266;
|
||||
}
|
||||
|
||||
/* 作业要求(打包/拣货/复核)文本域内容颜色改为黑色 */
|
||||
::v-deep .u-textarea__field {
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
.shelf-life-block {
|
||||
margin: 12rpx 0 16rpx;
|
||||
padding: 8rpx 20rpx 20rpx;
|
||||
|
||||
792
pages/work/product/itemMaint.vue
Normal file
792
pages/work/product/itemMaint.vue
Normal file
@ -0,0 +1,792 @@
|
||||
<template>
|
||||
<view class="item-maint-page">
|
||||
<view class="normar_container">
|
||||
<page-nav title="商品信息维护">
|
||||
<template #right>
|
||||
<u-button
|
||||
class="nav-save-btn"
|
||||
size="mini"
|
||||
type="primary"
|
||||
text="保存"
|
||||
:loading="saving"
|
||||
:customStyle="{ backgroundColor: '#2979ff', borderColor: '#2979ff', color: '#ffffff' }"
|
||||
@click="handleSave"
|
||||
>
|
||||
<text class="nav-save-btn__text">保存</text>
|
||||
</u-button>
|
||||
</template>
|
||||
</page-nav>
|
||||
|
||||
<scroll-view class="form-content" scroll-y>
|
||||
<view v-if="!loaded && !loading" class="empty-state">
|
||||
<u-icon name="scan" size="88" color="#c0c4cc"></u-icon>
|
||||
<text class="empty-text">请扫描商品条码</text>
|
||||
<text class="empty-hint">扫描后自动带出商品信息</text>
|
||||
</view>
|
||||
|
||||
<view v-else class="form-card">
|
||||
<!-- 商品名称 -->
|
||||
<view class="form-section form-section--name">
|
||||
<view class="goods-name-display">{{ formData.NAME || '--' }}</view>
|
||||
</view>
|
||||
|
||||
<!-- 商品图片 -->
|
||||
<view class="form-section">
|
||||
<view class="section-title">商品图片</view>
|
||||
<uploadImgCos
|
||||
ref="imageUploadRef"
|
||||
business_type="stock"
|
||||
:value="formData.images"
|
||||
:business_id="stockId"
|
||||
:maxCount="6"
|
||||
:multiple="true"
|
||||
:disabled="!stockId"
|
||||
@change="handleImagesChange"
|
||||
></uploadImgCos>
|
||||
<text class="section-tip">最多上传6张,支持多选、删除</text>
|
||||
</view>
|
||||
|
||||
<!-- 商品重量 -->
|
||||
<view class="form-section">
|
||||
<view class="field-line">
|
||||
<text class="field-label">商品重量(g)</text>
|
||||
<view class="field-input-box">
|
||||
<input class="field-input" v-model="formData.WEIGHT" type="digit" placeholder="请输入重量" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 商品有效天数 -->
|
||||
<view class="form-section">
|
||||
<view class="field-line">
|
||||
<text class="field-label">商品有效天数(天)</text>
|
||||
<view class="field-input-box">
|
||||
<input class="field-input" v-model="formData.YXQ" type="number" placeholder="请输入有效天数" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="quick-buttons">
|
||||
<view
|
||||
class="quick-btn"
|
||||
v-for="option in yxqOptions"
|
||||
:key="option.days"
|
||||
@click="setYxq(option.days)"
|
||||
>
|
||||
<text class="quick-btn__text">{{ option.label }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 箱规 -->
|
||||
<view class="form-section">
|
||||
<view class="section-title">箱规</view>
|
||||
<view class="field-line">
|
||||
<text class="field-label">每箱数量</text>
|
||||
<view class="field-input-box">
|
||||
<input class="field-input" v-model="formData.quantity_per_box" type="number" placeholder="请输入每箱数量" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="field-line">
|
||||
<text class="field-label">箱毛重(g)</text>
|
||||
<view class="field-input-box">
|
||||
<input class="field-input" v-model="formData.box_gross_weight" type="digit" placeholder="请输入箱毛重" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="field-line">
|
||||
<text class="field-label">箱净重(g)</text>
|
||||
<view class="field-input-box">
|
||||
<input class="field-input" v-model="formData.box_net_weight" type="digit" placeholder="请输入箱净重" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="field-line">
|
||||
<text class="field-label">箱长(cm)</text>
|
||||
<view class="field-input-box">
|
||||
<input class="field-input" v-model="formData.box_length" type="digit" placeholder="请输入箱长" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="field-line">
|
||||
<text class="field-label">箱宽(cm)</text>
|
||||
<view class="field-input-box">
|
||||
<input class="field-input" v-model="formData.box_width" type="digit" placeholder="请输入箱宽" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="field-line">
|
||||
<text class="field-label">箱高(cm)</text>
|
||||
<view class="field-input-box">
|
||||
<input class="field-input" v-model="formData.box_height" type="digit" placeholder="请输入箱高" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="field-line">
|
||||
<text class="field-label">箱体积(m³)</text>
|
||||
<view class="field-input-box">
|
||||
<input class="field-input" v-model="formData.box_volume" type="digit" placeholder="请输入箱体积" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="safe-padding-bottom"></view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
|
||||
<u-loading-page :loading="loading" bg-color="rgba(255,255,255,0.9)"></u-loading-page>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
barcode: '',
|
||||
rawItem: null,
|
||||
loading: false,
|
||||
saving: false,
|
||||
loaded: false,
|
||||
stockId: 0,
|
||||
querySeq: 0,
|
||||
imgs: [],
|
||||
formData: {
|
||||
NAME: '',
|
||||
WEIGHT: '',
|
||||
YXQ: '',
|
||||
images: [],
|
||||
quantity_per_box: '',
|
||||
box_gross_weight: '',
|
||||
box_net_weight: '',
|
||||
box_length: '',
|
||||
box_width: '',
|
||||
box_height: '',
|
||||
box_volume: ''
|
||||
},
|
||||
yxqOptions: [
|
||||
{ label: '3个月', days: 90 },
|
||||
{ label: '6个月', days: 180 },
|
||||
{ label: '12个月', days: 365 },
|
||||
{ label: '18个月', days: 540 },
|
||||
{ label: '2年', days: 730 },
|
||||
{ label: '2年半', days: 912 },
|
||||
{ label: '3年', days: 1095 }
|
||||
]
|
||||
};
|
||||
},
|
||||
onLoad(options) {
|
||||
this.safeDispatchBroadcast('setCallbacks', {
|
||||
onResult: this.handleBroadcastResult
|
||||
});
|
||||
this.safeDispatchBroadcast('start');
|
||||
|
||||
// 从商品查询页跳转时带 barcode,自动带出商品信息
|
||||
const routeBarcode = this.normalizeKeyword(
|
||||
(options && (options.barcode || options.code || options.keyword)) || ''
|
||||
);
|
||||
if (routeBarcode) {
|
||||
this.barcode = routeBarcode;
|
||||
this.queryByBarcode();
|
||||
}
|
||||
},
|
||||
onShow() {
|
||||
this.safeDispatchBroadcast('setCallbacks', {
|
||||
onResult: this.handleBroadcastResult
|
||||
});
|
||||
this.safeDispatchBroadcast('resume');
|
||||
},
|
||||
onHide() {
|
||||
this.safeDispatchBroadcast('pause');
|
||||
},
|
||||
onUnload() {
|
||||
this.safeDispatchBroadcast('stop');
|
||||
},
|
||||
methods: {
|
||||
safeDispatchBroadcast(action, payload) {
|
||||
try {
|
||||
const task = this.$store.dispatch(`broadcast/${action}`, payload);
|
||||
if (task && typeof task.catch === 'function') {
|
||||
task.catch(error => {
|
||||
console.warn(`[ItemMaint] broadcast/${action} 调用失败:`, error);
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn(`[ItemMaint] broadcast/${action} 调用异常:`, error);
|
||||
}
|
||||
},
|
||||
normalizeKeyword(value) {
|
||||
return String(value || '').replace(/\s+/g, '');
|
||||
},
|
||||
normalizePositiveId(value) {
|
||||
if (value === null || value === undefined || value === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
const numeric = Number(value);
|
||||
if (Number.isFinite(numeric) && numeric > 0) {
|
||||
return numeric;
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
resolveStoreId(item) {
|
||||
if (!item || typeof item !== 'object') {
|
||||
return null;
|
||||
}
|
||||
|
||||
const candidates = [
|
||||
item.store_id,
|
||||
item.owner_id,
|
||||
item.store && item.store.id,
|
||||
item.store_stock && item.store_stock.store_id
|
||||
];
|
||||
|
||||
for (let i = 0; i < candidates.length; i++) {
|
||||
const normalized = this.normalizePositiveId(candidates[i]);
|
||||
if (normalized) {
|
||||
return normalized;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
resolveWarehouseStockId(item) {
|
||||
if (!item || typeof item !== 'object') {
|
||||
return null;
|
||||
}
|
||||
|
||||
const candidates = [
|
||||
item.stock_id,
|
||||
item.warehouse_stock_id,
|
||||
item.storage_id,
|
||||
item.id
|
||||
];
|
||||
|
||||
for (let i = 0; i < candidates.length; i++) {
|
||||
const normalized = this.normalizePositiveId(candidates[i]);
|
||||
if (normalized) {
|
||||
return normalized;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
normalizeScanResult(scanResult) {
|
||||
if (!scanResult) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (typeof scanResult === 'string') {
|
||||
return this.normalizeKeyword(scanResult);
|
||||
}
|
||||
|
||||
if (typeof scanResult.result === 'string') {
|
||||
return this.normalizeKeyword(scanResult.result);
|
||||
}
|
||||
|
||||
if (Array.isArray(scanResult.result)) {
|
||||
const firstResult = scanResult.result.find(item => item);
|
||||
if (typeof firstResult === 'string') {
|
||||
return this.normalizeKeyword(firstResult);
|
||||
}
|
||||
if (firstResult && typeof firstResult.data === 'string') {
|
||||
return this.normalizeKeyword(firstResult.data);
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof scanResult.data === 'string') {
|
||||
return this.normalizeKeyword(scanResult.data);
|
||||
}
|
||||
|
||||
return '';
|
||||
},
|
||||
handleBroadcastResult(result) {
|
||||
const code = this.normalizeScanResult(result);
|
||||
if (!code) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.barcode = code;
|
||||
this.queryByBarcode();
|
||||
},
|
||||
toInputValue(value) {
|
||||
return value === null || value === undefined || value === '' ? '' : String(value);
|
||||
},
|
||||
extractListFromResponse(response) {
|
||||
if (!response || typeof response !== 'object') {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (Array.isArray(response.list)) {
|
||||
return response.list;
|
||||
}
|
||||
if (Array.isArray(response.rows)) {
|
||||
return response.rows;
|
||||
}
|
||||
|
||||
const responseData = response.data;
|
||||
if (Array.isArray(responseData)) {
|
||||
return responseData;
|
||||
}
|
||||
if (responseData && Array.isArray(responseData.list)) {
|
||||
return responseData.list;
|
||||
}
|
||||
if (responseData && Array.isArray(responseData.rows)) {
|
||||
return responseData.rows;
|
||||
}
|
||||
if (responseData && Array.isArray(responseData.data)) {
|
||||
return responseData.data;
|
||||
}
|
||||
|
||||
return [];
|
||||
},
|
||||
getItemName(item) {
|
||||
return String((item && (item.item_name || item.product_name || item.name)) || '').trim();
|
||||
},
|
||||
extractBarcodes(item) {
|
||||
if (!item || typeof item !== 'object') {
|
||||
return [];
|
||||
}
|
||||
|
||||
let values = [];
|
||||
if (Array.isArray(item.barcodes)) {
|
||||
values = values.concat(item.barcodes);
|
||||
} else if (typeof item.barcodes === 'string' && item.barcodes.trim()) {
|
||||
values = values.concat(item.barcodes.split(/[;,,\s]+/));
|
||||
}
|
||||
|
||||
values = values.concat([item.barcode, item.code, item.item_barcode, item.bar_code]);
|
||||
|
||||
return [...new Set(values
|
||||
.map(code => this.normalizeKeyword(code))
|
||||
.filter(Boolean)
|
||||
)];
|
||||
},
|
||||
normalizeImageList(item) {
|
||||
const urls = [];
|
||||
const pushImage = (img) => {
|
||||
if (!img) {
|
||||
return;
|
||||
}
|
||||
if (typeof img === 'string') {
|
||||
urls.push(img);
|
||||
} else if (typeof img === 'object') {
|
||||
const url = img.url || img.path || img.successUrl || img.fileUrl || img.image_url || '';
|
||||
if (url) {
|
||||
urls.push(url);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (item && Array.isArray(item.images) && item.images.length) {
|
||||
item.images.forEach(pushImage);
|
||||
}
|
||||
|
||||
if (!urls.length && item && (item.image || item.image_url)) {
|
||||
urls.push(item.image || item.image_url);
|
||||
}
|
||||
|
||||
return [...new Set(urls.filter(Boolean))].map(url => ({ url }));
|
||||
},
|
||||
async queryByBarcode() {
|
||||
const code = this.normalizeKeyword(this.barcode);
|
||||
if (!code) {
|
||||
uni.showToast({
|
||||
title: '请输入商品条码',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const querySeq = ++this.querySeq;
|
||||
this.loading = true;
|
||||
try {
|
||||
const [searchRes, listRes] = await Promise.all([
|
||||
this.$http('stock.warehouse.search', {
|
||||
keyword: code,
|
||||
with_stock: true
|
||||
}),
|
||||
this.$http('stock.warehouse.list', {
|
||||
with_stock: true,
|
||||
where: {
|
||||
barcode: {
|
||||
operator: 'eq',
|
||||
value: code,
|
||||
type: 'string'
|
||||
}
|
||||
},
|
||||
pagination: {
|
||||
page: 1,
|
||||
pageSize: 1
|
||||
}
|
||||
})
|
||||
]);
|
||||
|
||||
if (querySeq !== this.querySeq) {
|
||||
return;
|
||||
}
|
||||
|
||||
const searchOk = searchRes && Number(searchRes.code) === 200;
|
||||
const listOk = listRes && Number(listRes.code) === 200;
|
||||
const searchList = searchOk ? this.extractListFromResponse(searchRes) : [];
|
||||
const listList = listOk ? this.extractListFromResponse(listRes) : [];
|
||||
|
||||
const exactMatch = list =>
|
||||
(list || []).find(item => this.extractBarcodes(item).includes(code));
|
||||
|
||||
const item = exactMatch(listList) || (listList && listList[0]) || exactMatch(searchList) || (searchList && searchList[0]);
|
||||
if (!item) {
|
||||
this.loaded = false;
|
||||
uni.showToast({
|
||||
title: '未查询到该商品',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
this.applyProduct(item);
|
||||
} catch (error) {
|
||||
if (querySeq !== this.querySeq) {
|
||||
return;
|
||||
}
|
||||
console.error('[ItemMaint] 查询异常:', error);
|
||||
uni.showToast({
|
||||
title: (error && error.message) || '查询失败',
|
||||
icon: 'none'
|
||||
});
|
||||
} finally {
|
||||
if (querySeq === this.querySeq) {
|
||||
this.loading = false;
|
||||
}
|
||||
}
|
||||
},
|
||||
applyProduct(item) {
|
||||
this.rawItem = item && typeof item === 'object' ? item : {};
|
||||
this.stockId = this.resolveWarehouseStockId(item) || 0;
|
||||
this.formData.NAME = this.getItemName(item);
|
||||
this.formData.WEIGHT = this.toInputValue(item.gross_weight !== undefined ? item.gross_weight : item.weight);
|
||||
this.formData.YXQ = this.toInputValue(
|
||||
item.shelf_life_days !== undefined
|
||||
? item.shelf_life_days
|
||||
: (item.validity_days !== undefined ? item.validity_days : item.yxq)
|
||||
);
|
||||
|
||||
this.formData.quantity_per_box = this.toInputValue(item.quantity_per_box);
|
||||
this.formData.box_gross_weight = this.toInputValue(item.box_gross_weight);
|
||||
this.formData.box_net_weight = this.toInputValue(item.box_net_weight);
|
||||
this.formData.box_length = this.toInputValue(item.box_length);
|
||||
this.formData.box_width = this.toInputValue(item.box_width);
|
||||
this.formData.box_height = this.toInputValue(item.box_height);
|
||||
this.formData.box_volume = this.toInputValue(item.box_volume);
|
||||
|
||||
this.formData.images = this.normalizeImageList(item);
|
||||
this.imgs = [];
|
||||
this.loaded = true;
|
||||
},
|
||||
setYxq(days) {
|
||||
this.formData.YXQ = String(days);
|
||||
},
|
||||
handleImagesChange(fileList) {
|
||||
this.formData.images = Array.isArray(fileList) ? fileList : [];
|
||||
this.imgs = this.formData.images
|
||||
.map(file => (file && (file.successUrl || file.url || file.path)) || '')
|
||||
.filter(Boolean);
|
||||
},
|
||||
async handleSave() {
|
||||
if (this.saving) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.stockId) {
|
||||
uni.showToast({
|
||||
title: '请先扫描商品',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const raw = this.rawItem || {};
|
||||
const itemCode = String(raw.item_code || raw.goods_code || '').trim();
|
||||
if (!itemCode) {
|
||||
uni.showToast({
|
||||
title: '缺少商品编码,无法保存',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const storeId = this.resolveStoreId(raw);
|
||||
if (!storeId) {
|
||||
uni.showToast({
|
||||
title: '未获取到货主ID',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const itemName = String(this.formData.NAME || '').trim();
|
||||
if (!itemName) {
|
||||
uni.showToast({
|
||||
title: '商品名称为空',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const toNumber = (value) => {
|
||||
const numeric = Number(value);
|
||||
return Number.isFinite(numeric) ? numeric : 0;
|
||||
};
|
||||
|
||||
const yxq = toNumber(this.formData.YXQ);
|
||||
const quantityPerBox = toNumber(this.formData.quantity_per_box);
|
||||
|
||||
const payload = {
|
||||
id: this.stockId,
|
||||
item_code: itemCode,
|
||||
store_id: Number(storeId),
|
||||
store_name: String(raw.store_name || '').trim(),
|
||||
barcode: String(raw.barcode || raw.bar_code || '').trim(),
|
||||
item_name: itemName,
|
||||
sku_property: String(raw.sku_property || '').trim(),
|
||||
stock_unit: String(raw.stock_unit || '').trim(),
|
||||
packing_requirements: String(raw.packing_requirements || '').trim(),
|
||||
pick_requirements: String(raw.pick_requirements || '').trim(),
|
||||
recheck_requirements: String(raw.recheck_requirements || '').trim(),
|
||||
length: toNumber(raw.length),
|
||||
width: toNumber(raw.width),
|
||||
height: toNumber(raw.height),
|
||||
volume: toNumber(raw.volume),
|
||||
gross_weight: toNumber(this.formData.WEIGHT),
|
||||
net_weight: toNumber(raw.net_weight),
|
||||
tag_price: toNumber(raw.tag_price),
|
||||
retail_price: toNumber(raw.retail_price),
|
||||
is_sn_mgmt: raw.is_sn_mgmt !== undefined ? raw.is_sn_mgmt : 'N',
|
||||
is_shelf_life_mgmt: yxq > 0 ? 'Y' : 'N',
|
||||
shelf_life_days: yxq,
|
||||
is_batch_mgmt: raw.is_batch_mgmt !== undefined ? raw.is_batch_mgmt : 'N',
|
||||
inbound_min_days: toNumber(raw.inbound_min_days),
|
||||
outbound_min_days: toNumber(raw.outbound_min_days),
|
||||
remaining_threshold_days: toNumber(raw.remaining_threshold_days),
|
||||
brand_name: String(raw.brand_name || '').trim(),
|
||||
managementFlags: [],
|
||||
enable_box_spec: quantityPerBox > 0,
|
||||
quantity_per_box: quantityPerBox,
|
||||
box_gross_weight: toNumber(this.formData.box_gross_weight),
|
||||
box_net_weight: toNumber(this.formData.box_net_weight),
|
||||
box_length: toNumber(this.formData.box_length),
|
||||
box_width: toNumber(this.formData.box_width),
|
||||
box_height: toNumber(this.formData.box_height),
|
||||
box_volume: toNumber(this.formData.box_volume),
|
||||
box_unit: String(raw.box_unit || ''),
|
||||
goods_code: String(raw.goods_code || itemCode).trim()
|
||||
};
|
||||
|
||||
this.saving = true;
|
||||
try {
|
||||
const res = await this.$http('stock.warehouse.saveWarehouseStock', payload);
|
||||
if (!res || Number(res.code) !== 200) {
|
||||
throw new Error((res && res.message) || '保存失败');
|
||||
}
|
||||
|
||||
uni.showToast({
|
||||
title: '保存成功',
|
||||
icon: 'success'
|
||||
});
|
||||
setTimeout(() => {
|
||||
uni.navigateBack({
|
||||
delta: 1
|
||||
});
|
||||
}, 600);
|
||||
} catch (error) {
|
||||
console.error('[ItemMaint] 保存异常:', error);
|
||||
uni.showToast({
|
||||
title: (error && error.message) || '保存失败',
|
||||
icon: 'none'
|
||||
});
|
||||
} finally {
|
||||
this.saving = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.item-maint-page {
|
||||
width: 100%;
|
||||
min-height: 100vh;
|
||||
background: #f5f6f7;
|
||||
}
|
||||
|
||||
.normar_container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
::v-deep .nav-save-btn {
|
||||
min-width: 144rpx !important;
|
||||
padding: 0 32rpx !important;
|
||||
height: 72rpx !important;
|
||||
line-height: 72rpx !important;
|
||||
margin-right: 18rpx !important;
|
||||
border-radius: 12rpx !important;
|
||||
box-shadow: 0 4rpx 12rpx rgba(41, 121, 255, 0.22);
|
||||
}
|
||||
|
||||
::v-deep .nav-save-btn .u-button {
|
||||
background-color: #2979ff !important;
|
||||
border-color: #2979ff !important;
|
||||
color: #ffffff !important;
|
||||
border-radius: 12rpx !important;
|
||||
}
|
||||
|
||||
.nav-save-btn__text {
|
||||
font-size: 32rpx;
|
||||
font-weight: 600;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
::v-deep .nav-save-btn .u-button__text {
|
||||
font-size: 32rpx !important;
|
||||
font-weight: 600 !important;
|
||||
}
|
||||
|
||||
.form-content {
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding-top: 160rpx;
|
||||
}
|
||||
|
||||
.empty-text {
|
||||
margin-top: 24rpx;
|
||||
color: #909399;
|
||||
font-size: 36rpx;
|
||||
}
|
||||
|
||||
.empty-hint {
|
||||
margin-top: 12rpx;
|
||||
color: #c0c4cc;
|
||||
font-size: 30rpx;
|
||||
}
|
||||
|
||||
.form-card {
|
||||
margin: 20rpx 24rpx;
|
||||
background: #ffffff;
|
||||
border-radius: 16rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.form-section {
|
||||
padding: 28rpx 24rpx;
|
||||
border-bottom: 2rpx solid #f0f1f3;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
color: #303133;
|
||||
font-size: 36rpx;
|
||||
font-weight: 600;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.section-value {
|
||||
color: #606266;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.goods-name-display {
|
||||
color: #303133;
|
||||
font-size: 44rpx;
|
||||
font-weight: 600;
|
||||
line-height: 1.4;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.section-tip {
|
||||
display: block;
|
||||
margin-top: 12rpx;
|
||||
color: #c0c4cc;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.field-row {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
height: 80rpx;
|
||||
padding: 0 20rpx;
|
||||
border: 2rpx solid #e4e7ed;
|
||||
border-radius: 12rpx;
|
||||
}
|
||||
|
||||
.field-line {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.field-line + .field-line {
|
||||
margin-top: 24rpx;
|
||||
}
|
||||
|
||||
.field-input-box {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
height: 88rpx;
|
||||
padding: 0 20rpx;
|
||||
border: 2rpx solid #e4e7ed;
|
||||
border-radius: 12rpx;
|
||||
}
|
||||
|
||||
.field-label {
|
||||
width: 330rpx;
|
||||
flex-shrink: 0;
|
||||
margin-right: 16rpx;
|
||||
color: #303133;
|
||||
font-size: 36rpx;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.field-input {
|
||||
flex: 1;
|
||||
height: 88rpx;
|
||||
font-size: 36rpx;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
.quick-buttons {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
margin-top: 16rpx;
|
||||
// 老机型 WebView 不支持 flex gap,改用按钮外边距实现实际间隔
|
||||
margin-bottom: -30rpx;
|
||||
}
|
||||
|
||||
.quick-btn {
|
||||
padding: 14rpx 32rpx;
|
||||
border: 1rpx solid #d9e4f5;
|
||||
border-radius: 10rpx;
|
||||
background: #f5f8ff;
|
||||
font-size: 34rpx;
|
||||
color: #2979ff;
|
||||
margin-right: 30rpx;
|
||||
margin-bottom: 30rpx;
|
||||
}
|
||||
|
||||
.quick-btn:active {
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.quick-btn__text {
|
||||
color: #2979ff;
|
||||
font-size: 34rpx;
|
||||
}
|
||||
|
||||
.safe-padding-bottom {
|
||||
height: 40rpx;
|
||||
}
|
||||
</style>
|
||||
@ -236,6 +236,14 @@
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
<view class="storage-action-bar">
|
||||
<view class="storage-action-btn storage-action-btn--primary" @click="goItemMaint(item)">
|
||||
<text class="storage-action-btn__text">维护信息</text>
|
||||
</view>
|
||||
<view class="storage-action-btn" @click="goTransferRecord(item)">
|
||||
<text class="storage-action-btn__text">移库记录</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@ -2225,6 +2233,28 @@
|
||||
url: `/pages/warehouse/inventoryTransfer${query}`
|
||||
});
|
||||
},
|
||||
goItemMaint(item) {
|
||||
if (!item || typeof item !== 'object') {
|
||||
return;
|
||||
}
|
||||
|
||||
// 优先条码,其次编码,跳转到商品信息维护页并自动带出商品
|
||||
const barcodeList = Array.isArray(item.barcodes) ? item.barcodes.filter(code => code) : [];
|
||||
const keyword = String(
|
||||
barcodeList[0]
|
||||
|| item.barcode
|
||||
|| item.bar_code
|
||||
|| item.item_barcode
|
||||
|| item.code
|
||||
|| item.item_code
|
||||
|| item.goods_code
|
||||
|| ''
|
||||
).trim();
|
||||
const query = keyword ? `?barcode=${encodeURIComponent(keyword)}` : '';
|
||||
uni.navigateTo({
|
||||
url: `/pages/work/product/itemMaint${query}`
|
||||
});
|
||||
},
|
||||
async goProductDetail(item) {
|
||||
if (!item || typeof item !== 'object') {
|
||||
return;
|
||||
@ -3322,6 +3352,45 @@
|
||||
padding-bottom: 4rpx;
|
||||
}
|
||||
|
||||
.storage-action-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
|
||||
.storage-action-btn {
|
||||
flex: 1;
|
||||
height: 72rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: 1rpx solid #d9e4f5;
|
||||
border-radius: 10rpx;
|
||||
background: #f5f8ff;
|
||||
font-size: 32rpx;
|
||||
color: #606266;
|
||||
|
||||
// 老机型 WebView 不支持 flex gap,改用外边距实现按钮间隔
|
||||
& + & {
|
||||
margin-left: 20rpx;
|
||||
}
|
||||
|
||||
&:active {
|
||||
opacity: 0.7;
|
||||
}
|
||||
}
|
||||
|
||||
.storage-action-btn--primary {
|
||||
background: #2979ff;
|
||||
border-color: #2979ff;
|
||||
color: #ffffff;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.storage-action-btn__text {
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.label {
|
||||
width: auto;
|
||||
margin-right: 6rpx;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user