feat(product): 商品维护页表单与图片管理重构,打包优先使用最新编译产物
打包优化: - prepare.cjs 优先使用 CLI 最新编译产物 dist/build/app-plus, unpackage/resources 仅作兜底,避免旧代码打入 APK 商品图片管理重构(itemMaint/edit/detail/query/uploadImgCos): - 统一图片 URL 与 fileId 提取逻辑,支持嵌套 file 对象及 file_url/file_id 等字段,消除多处重复解析 - getImages 请求参数简化为 type + id,移除冗余的 business_id/stock_id/business_type - 商品编辑/维护页进入时拉取最新图片并记录初始快照与文件 ID, 返回时通过 ReferenceFile 回滚图片引用,避免未保存即改动图片 - 保存成功后通过事件 + storage 通知商品查询页刷新缓存 商品维护页(itemMaint): - 表单移除"有效期"快捷选择,保质期改用商品原始数据; 新增"净重 NET_WEIGHT"字段 - 新增扫描与提示语音播报,页面隐藏/卸载时自动停止播报 - 调整输入框 placeholder 颜色、保存按钮宽度、表单卡片 边框圆角阴影、字段标签宽度等样式
This commit is contained in:
parent
fd3228eac3
commit
7c6aedfa6d
@ -99,8 +99,11 @@ const wwwOverride = process.argv[2] ? path.resolve(ROOT, process.argv[2]) : ''
|
||||
const candidates = [
|
||||
...(wwwOverride ? [wwwOverride] : []),
|
||||
...(config.wwwSource ? [path.resolve(ROOT, config.wwwSource)] : []),
|
||||
path.join(ROOT, 'unpackage', 'resources', config.appId, 'www'),
|
||||
// 优先使用 CLI 最新编译产物(dist/build/app-plus)。
|
||||
// unpackage/resources 是 HBuilderX 本地打包产物,可能已过期,仅作兜底,
|
||||
// 避免把旧代码打进 APK。
|
||||
path.join(ROOT, 'dist', 'build', 'app-plus'),
|
||||
path.join(ROOT, 'unpackage', 'resources', config.appId, 'www'),
|
||||
]
|
||||
|
||||
const wwwSource = candidates.find((dir) => fs.existsSync(dir))
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
| `packageName` | Android 包名(`applicationId` 与 gradle `namespace` 都由它决定,发布后不可更改) |
|
||||
| `abis` | CPU 架构。此处与 `src/manifest.json` 的 `abiFilters` 保持一致(`armeabi-v7a`、`arm64-v8a`) |
|
||||
| `icon` / `splash` | 图标/启动图路径(相对项目根),`prepare.cjs` 会用它们覆盖 `res/` 下的同名资源 |
|
||||
| `wwwSource` | App 资源目录。留空则依次尝试 `unpackage/resources/<appId>/www`、`dist/build/app-plus` |
|
||||
| `wwwSource` | App 资源目录。留空则依次尝试 `dist/build/app-plus`(CLI 最新编译产物)、`unpackage/resources/<appId>/www`(HBuilderX 本地打包产物,仅作兜底) |
|
||||
| `runtimeVersion` | 离线 SDK 的 5+ Runtime 版本。`prepare.cjs` 会把 www 内 `manifest.json`/`app-config-service.js` 的 `compilerVersion` 对齐到该值,避免启动时弹「HBuilderX %s 编译 / 手机端 SDK %s」提示 |
|
||||
| `signing.keystore` | 签名文件路径(相对项目根),放在 `android-offline/keystore/`(该目录 git 不跟踪) |
|
||||
| `signing.storePassword` / `keyAlias` / `keyPassword` | 签名密码与别名,**自己填写,不要提交**。DCloud 下发的 keystore(PKCS12)别名固定为 `__uni__` + appid 小写,本项目即 `__uni__0b3dad3`;PKCS12 的 `storePassword` 与 `keyPassword` 必须相同 |
|
||||
|
||||
@ -243,10 +243,11 @@ export default {
|
||||
file.url
|
||||
|| file.path
|
||||
|| file.fileUrl
|
||||
|| file.file_url
|
||||
|| file.image_url
|
||||
|| file.img_url
|
||||
|| file.src
|
||||
|| (file.file && (file.file.url || file.file.path || file.file.fileUrl))
|
||||
|| (file.file && (file.file.file_url || file.file.url || file.file.path || file.file.fileUrl))
|
||||
|| ''
|
||||
);
|
||||
},
|
||||
@ -256,11 +257,8 @@ export default {
|
||||
}
|
||||
|
||||
const response = await this.$http('common.getImages', {
|
||||
id: Number(this.business_id),
|
||||
business_id: Number(this.business_id),
|
||||
stock_id: Number(this.business_id),
|
||||
type: this.business_type,
|
||||
business_type: this.business_type
|
||||
id: Number(this.business_id)
|
||||
});
|
||||
|
||||
const entries = this.extractImageListFromGetImagesResponse(response)
|
||||
|
||||
@ -441,7 +441,10 @@ export default {
|
||||
}
|
||||
|
||||
if (typeof firstImage === 'object') {
|
||||
return String(firstImage.url || firstImage.path || firstImage.successUrl || firstImage.fileUrl || firstImage.image_url || '');
|
||||
const nestedFileUrl = firstImage.file && typeof firstImage.file === 'object'
|
||||
? (firstImage.file.file_url || firstImage.file.url || firstImage.file.path || firstImage.file.fileUrl || '')
|
||||
: '';
|
||||
return String(nestedFileUrl || firstImage.url || firstImage.path || firstImage.fileUrl || firstImage.file_url || firstImage.image_url || firstImage.img_url || firstImage.src || firstImage.successUrl || '');
|
||||
}
|
||||
|
||||
return '';
|
||||
@ -470,7 +473,10 @@ export default {
|
||||
}
|
||||
|
||||
if (typeof image === 'object') {
|
||||
return image.url || image.path || image.successUrl || image.fileUrl || image.image_url || '';
|
||||
const nestedFileUrl = image.file && typeof image.file === 'object'
|
||||
? (image.file.file_url || image.file.url || image.file.path || image.file.fileUrl || '')
|
||||
: '';
|
||||
return nestedFileUrl || image.url || image.path || image.fileUrl || image.file_url || image.image_url || image.img_url || image.src || image.successUrl || '';
|
||||
}
|
||||
|
||||
return '';
|
||||
|
||||
@ -252,7 +252,7 @@ export default {
|
||||
},
|
||||
computed: {
|
||||
productImageBusinessId() {
|
||||
return this.resolveWarehouseStockId(this.rawItem || {}) || 0;
|
||||
return this.resolveImageBusinessId(this.rawItem || {}) || 0;
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
@ -610,27 +610,19 @@ export default {
|
||||
|
||||
return null;
|
||||
},
|
||||
resolveImageBusinessId(item) {
|
||||
if (!item || typeof item !== 'object') {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 与商品查询页 getImages 查询保持一致:优先商品主键 id,其次库存主键 stock_id
|
||||
return this.normalizePositiveId(item.id) || this.normalizePositiveId(item.stock_id);
|
||||
},
|
||||
extractImageListFromGetImagesResponse(response) {
|
||||
if (!response || typeof response !== 'object') {
|
||||
return [];
|
||||
}
|
||||
|
||||
const isImageLike = (item) => {
|
||||
if (!item) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (typeof item === 'string') {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (typeof item !== 'object') {
|
||||
return false;
|
||||
}
|
||||
|
||||
return Boolean(item.url || item.path || item.fileUrl || item.image_url || item.img_url || item.src);
|
||||
};
|
||||
|
||||
const candidates = [
|
||||
response.data,
|
||||
response.data && response.data.data,
|
||||
@ -654,10 +646,7 @@ export default {
|
||||
}
|
||||
|
||||
if (Array.isArray(current)) {
|
||||
if (current.length === 0 || isImageLike(current[0])) {
|
||||
return current;
|
||||
}
|
||||
continue;
|
||||
return current;
|
||||
}
|
||||
|
||||
if (typeof current === 'object') {
|
||||
@ -723,7 +712,7 @@ export default {
|
||||
return '';
|
||||
}
|
||||
|
||||
return item.file_id || item.fileId || item.id || item.image_id || '';
|
||||
return this.extractImageFileId(item);
|
||||
})
|
||||
.filter(Boolean)
|
||||
));
|
||||
@ -735,11 +724,8 @@ export default {
|
||||
}
|
||||
|
||||
const response = await this.$http('common.getImages', {
|
||||
id: Number(businessId),
|
||||
business_id: Number(businessId),
|
||||
stock_id: Number(businessId),
|
||||
type: 'stock',
|
||||
business_type: 'stock'
|
||||
id: Number(businessId)
|
||||
});
|
||||
|
||||
return this.extractImageFileIdsFromResponse(response);
|
||||
@ -760,12 +746,12 @@ export default {
|
||||
return null;
|
||||
}
|
||||
|
||||
const imageUrl = image.url || image.path || image.fileUrl || image.image_url || image.img_url || image.src || '';
|
||||
const imageUrl = this.extractImageUrl(image);
|
||||
if (!imageUrl) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const fileId = image.file_id || image.fileId || image.id || image.image_id || '';
|
||||
const fileId = this.extractImageFileId(image);
|
||||
|
||||
return {
|
||||
...image,
|
||||
@ -784,11 +770,8 @@ export default {
|
||||
|
||||
try {
|
||||
const response = await this.$http('common.getImages', {
|
||||
id: Number(businessId),
|
||||
business_id: Number(businessId),
|
||||
stock_id: Number(businessId),
|
||||
type: 'stock',
|
||||
business_type: 'stock'
|
||||
id: Number(businessId)
|
||||
});
|
||||
const remoteFileIds = this.extractImageFileIdsFromResponse(response);
|
||||
if (remoteFileIds.length) {
|
||||
@ -1073,7 +1056,7 @@ export default {
|
||||
return { url: image, status: 'success' };
|
||||
}
|
||||
if (typeof image === 'object') {
|
||||
const imageUrl = image.url || image.path || image.fileUrl || image.image_url;
|
||||
const imageUrl = this.extractImageUrl(image);
|
||||
if (!imageUrl) return null;
|
||||
return {
|
||||
...image,
|
||||
@ -1093,6 +1076,43 @@ export default {
|
||||
|
||||
return [];
|
||||
},
|
||||
extractImageUrl(img) {
|
||||
if (!img) {
|
||||
return '';
|
||||
}
|
||||
if (typeof img === 'string') {
|
||||
return img;
|
||||
}
|
||||
if (typeof img !== 'object') {
|
||||
return '';
|
||||
}
|
||||
|
||||
const nestedFileUrl = img.file && typeof img.file === 'object'
|
||||
? (img.file.file_url || img.file.url || img.file.path || img.file.fileUrl || '')
|
||||
: '';
|
||||
|
||||
return nestedFileUrl
|
||||
|| img.url
|
||||
|| img.path
|
||||
|| img.fileUrl
|
||||
|| img.file_url
|
||||
|| img.image_url
|
||||
|| img.img_url
|
||||
|| img.src
|
||||
|| img.successUrl
|
||||
|| '';
|
||||
},
|
||||
extractImageFileId(img) {
|
||||
if (!img || typeof img !== 'object') {
|
||||
return '';
|
||||
}
|
||||
|
||||
const nestedFileId = img.file && typeof img.file === 'object'
|
||||
? (img.file.file_id || img.file.fileId || img.file.id || '')
|
||||
: '';
|
||||
|
||||
return img.file_id || img.fileId || img.id || img.image_id || nestedFileId || '';
|
||||
},
|
||||
extractImageUrls(list) {
|
||||
if (!Array.isArray(list)) {
|
||||
return [];
|
||||
@ -1102,7 +1122,7 @@ export default {
|
||||
.map(image => {
|
||||
if (!image) return '';
|
||||
if (typeof image === 'string') return image;
|
||||
if (typeof image === 'object') return image.url || image.path || image.successUrl || image.fileUrl || '';
|
||||
if (typeof image === 'object') return this.extractImageUrl(image);
|
||||
return '';
|
||||
})
|
||||
.filter(Boolean);
|
||||
@ -1120,13 +1140,13 @@ export default {
|
||||
}
|
||||
|
||||
if (typeof image === 'object') {
|
||||
const imageUrl = image.url || image.path || image.successUrl || image.fileUrl || image.image_url || '';
|
||||
const imageUrl = this.extractImageUrl(image);
|
||||
if (!imageUrl) return null;
|
||||
|
||||
return {
|
||||
...image,
|
||||
url: imageUrl,
|
||||
id: image.id || image.fileId || image.file_id || '',
|
||||
id: this.extractImageFileId(image),
|
||||
status: image.status || 'success'
|
||||
};
|
||||
}
|
||||
@ -1147,7 +1167,7 @@ export default {
|
||||
return '';
|
||||
}
|
||||
|
||||
return image.id || image.fileId || image.file_id || image.image_id || '';
|
||||
return this.extractImageFileId(image);
|
||||
})
|
||||
.filter(Boolean)
|
||||
));
|
||||
|
||||
@ -8,20 +8,21 @@
|
||||
size="mini"
|
||||
type="primary"
|
||||
text="保存"
|
||||
loading-text="保存"
|
||||
:loading="saving"
|
||||
:customStyle="{ backgroundColor: '#2979ff', borderColor: '#2979ff', color: '#ffffff' }"
|
||||
@click="handleSave"
|
||||
>
|
||||
<text class="nav-save-btn__text">保存</text>
|
||||
</u-button>
|
||||
></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>
|
||||
<view class="empty-state__icon">
|
||||
<u-icon name="scan" size="72" color="#2979ff"></u-icon>
|
||||
</view>
|
||||
<text class="empty-text">请扫描商品条码</text>
|
||||
<text class="empty-hint">扫描后自动带出商品信息</text>
|
||||
<text class="empty-hint">使用 PDA 扫描枪扫描后自动带出商品信息</text>
|
||||
</view>
|
||||
|
||||
<view v-else class="form-card">
|
||||
@ -37,41 +38,28 @@
|
||||
ref="imageUploadRef"
|
||||
business_type="stock"
|
||||
:value="formData.images"
|
||||
:business_id="stockId"
|
||||
:business_id="imageBusinessId"
|
||||
:maxCount="6"
|
||||
:multiple="true"
|
||||
:disabled="!stockId"
|
||||
:disabled="!imageBusinessId"
|
||||
@change="handleImagesChange"
|
||||
></uploadImgCos>
|
||||
<text class="section-tip">最多上传6张,支持多选、删除</text>
|
||||
</view>
|
||||
|
||||
<!-- 商品重量 -->
|
||||
<!-- 重量信息 -->
|
||||
<view class="form-section">
|
||||
<view class="section-title">重量信息</view>
|
||||
<view class="field-line">
|
||||
<text class="field-label">商品重量(g)</text>
|
||||
<text class="field-label">毛重(g)</text>
|
||||
<view class="field-input-box">
|
||||
<input class="field-input" v-model="formData.WEIGHT" type="digit" placeholder="请输入重量" />
|
||||
<input class="field-input" v-model="formData.WEIGHT" type="digit" placeholder="请输入毛重" placeholder-style="color:#c0c4cc" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 商品有效天数 -->
|
||||
<view class="form-section">
|
||||
<view class="field-line">
|
||||
<text class="field-label">商品有效天数(天)</text>
|
||||
<text class="field-label">净重(g)</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>
|
||||
<input class="field-input" v-model="formData.NET_WEIGHT" type="digit" placeholder="请输入净重" placeholder-style="color:#c0c4cc" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -82,43 +70,43 @@
|
||||
<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="请输入每箱数量" />
|
||||
<input class="field-input" v-model="formData.quantity_per_box" type="number" placeholder="请输入每箱数量" placeholder-style="color:#c0c4cc" />
|
||||
</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="请输入箱毛重" />
|
||||
<input class="field-input" v-model="formData.box_gross_weight" type="digit" placeholder="请输入箱毛重" placeholder-style="color:#c0c4cc" />
|
||||
</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="请输入箱净重" />
|
||||
<input class="field-input" v-model="formData.box_net_weight" type="digit" placeholder="请输入箱净重" placeholder-style="color:#c0c4cc" />
|
||||
</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="请输入箱长" />
|
||||
<input class="field-input" v-model="formData.box_length" type="digit" placeholder="请输入箱长" placeholder-style="color:#c0c4cc" />
|
||||
</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="请输入箱宽" />
|
||||
<input class="field-input" v-model="formData.box_width" type="digit" placeholder="请输入箱宽" placeholder-style="color:#c0c4cc" />
|
||||
</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="请输入箱高" />
|
||||
<input class="field-input" v-model="formData.box_height" type="digit" placeholder="请输入箱高" placeholder-style="color:#c0c4cc" />
|
||||
</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="请输入箱体积" />
|
||||
<input class="field-input" v-model="formData.box_volume" type="digit" placeholder="请输入箱体积" placeholder-style="color:#c0c4cc" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -142,12 +130,18 @@ export default {
|
||||
saving: false,
|
||||
loaded: false,
|
||||
stockId: 0,
|
||||
imageBusinessId: 0,
|
||||
querySeq: 0,
|
||||
imgs: [],
|
||||
initialImageSnapshot: [],
|
||||
initialImageFileIds: [],
|
||||
sessionUploadedFileIds: [],
|
||||
latestImagesLoadPromise: null,
|
||||
bypassBackIntercept: false,
|
||||
keepVoiceOnExit: false,
|
||||
formData: {
|
||||
NAME: '',
|
||||
WEIGHT: '',
|
||||
YXQ: '',
|
||||
NET_WEIGHT: '',
|
||||
images: [],
|
||||
quantity_per_box: '',
|
||||
box_gross_weight: '',
|
||||
@ -156,16 +150,7 @@ export default {
|
||||
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) {
|
||||
@ -190,9 +175,29 @@ export default {
|
||||
this.safeDispatchBroadcast('resume');
|
||||
},
|
||||
onHide() {
|
||||
if (!this.keepVoiceOnExit) {
|
||||
this.stopItemMaintSpeak();
|
||||
}
|
||||
this.safeDispatchBroadcast('pause');
|
||||
},
|
||||
onBackPress() {
|
||||
if (this.bypassBackIntercept || this.saving) {
|
||||
// 已经在回退流程中,放行系统返回
|
||||
return false;
|
||||
}
|
||||
// 标记已拦截,防止多次触发
|
||||
this.bypassBackIntercept = true;
|
||||
// 只做图片回滚,不主动 navigateBack,交给系统返回
|
||||
this.rollbackImageReferences().catch(err => {
|
||||
console.warn('[ItemMaint] 返回时回滚商品图片失败:', err);
|
||||
});
|
||||
// 返回 false,让系统继续处理返回(页面会被销毁)
|
||||
return false;
|
||||
},
|
||||
onUnload() {
|
||||
if (!this.keepVoiceOnExit) {
|
||||
this.stopItemMaintSpeak();
|
||||
}
|
||||
this.safeDispatchBroadcast('stop');
|
||||
},
|
||||
methods: {
|
||||
@ -265,6 +270,14 @@ export default {
|
||||
|
||||
return null;
|
||||
},
|
||||
resolveImageBusinessId(item) {
|
||||
if (!item || typeof item !== 'object') {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 与商品查询页 getImages 查询保持一致:优先商品主键 id,其次库存主键 stock_id
|
||||
return this.normalizePositiveId(item.id) || this.normalizePositiveId(item.stock_id);
|
||||
},
|
||||
normalizeScanResult(scanResult) {
|
||||
if (!scanResult) {
|
||||
return '';
|
||||
@ -365,7 +378,7 @@ export default {
|
||||
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 || '';
|
||||
const url = this.extractImageUrl(img);
|
||||
if (url) {
|
||||
urls.push(url);
|
||||
}
|
||||
@ -376,12 +389,52 @@ export default {
|
||||
item.images.forEach(pushImage);
|
||||
}
|
||||
|
||||
if (!urls.length && item && (item.image || item.image_url)) {
|
||||
urls.push(item.image || item.image_url);
|
||||
if (!urls.length && item) {
|
||||
const singleImage = item.image || item.image_url || item.img || item.pic || item.photo || item.cover || item.cover_url;
|
||||
if (singleImage) {
|
||||
urls.push(String(singleImage));
|
||||
}
|
||||
}
|
||||
|
||||
return [...new Set(urls.filter(Boolean))].map(url => ({ url }));
|
||||
},
|
||||
extractImageUrl(img) {
|
||||
if (!img) {
|
||||
return '';
|
||||
}
|
||||
if (typeof img === 'string') {
|
||||
return img;
|
||||
}
|
||||
if (typeof img !== 'object') {
|
||||
return '';
|
||||
}
|
||||
|
||||
const nestedFileUrl = img.file && typeof img.file === 'object'
|
||||
? (img.file.file_url || img.file.url || img.file.path || img.file.fileUrl || '')
|
||||
: '';
|
||||
|
||||
return nestedFileUrl
|
||||
|| img.url
|
||||
|| img.path
|
||||
|| img.fileUrl
|
||||
|| img.file_url
|
||||
|| img.image_url
|
||||
|| img.img_url
|
||||
|| img.src
|
||||
|| img.successUrl
|
||||
|| '';
|
||||
},
|
||||
extractImageFileId(img) {
|
||||
if (!img || typeof img !== 'object') {
|
||||
return '';
|
||||
}
|
||||
|
||||
const nestedFileId = img.file && typeof img.file === 'object'
|
||||
? (img.file.file_id || img.file.fileId || img.file.id || '')
|
||||
: '';
|
||||
|
||||
return img.file_id || img.fileId || img.id || img.image_id || nestedFileId || '';
|
||||
},
|
||||
async queryByBarcode() {
|
||||
const code = this.normalizeKeyword(this.barcode);
|
||||
if (!code) {
|
||||
@ -457,13 +510,10 @@ export default {
|
||||
applyProduct(item) {
|
||||
this.rawItem = item && typeof item === 'object' ? item : {};
|
||||
this.stockId = this.resolveWarehouseStockId(item) || 0;
|
||||
this.imageBusinessId = this.resolveImageBusinessId(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.NET_WEIGHT = this.toInputValue(item.net_weight);
|
||||
|
||||
this.formData.quantity_per_box = this.toInputValue(item.quantity_per_box);
|
||||
this.formData.box_gross_weight = this.toInputValue(item.box_gross_weight);
|
||||
@ -474,56 +524,430 @@ export default {
|
||||
this.formData.box_volume = this.toInputValue(item.box_volume);
|
||||
|
||||
this.formData.images = this.normalizeImageList(item);
|
||||
this.imgs = [];
|
||||
this.initialImageSnapshot = this.buildImageListForCache(this.formData.images);
|
||||
this.initialImageFileIds = this.extractImageFileIds(this.initialImageSnapshot);
|
||||
this.sessionUploadedFileIds = [];
|
||||
this.loaded = true;
|
||||
},
|
||||
setYxq(days) {
|
||||
this.formData.YXQ = String(days);
|
||||
this.latestImagesLoadPromise = this.loadLatestImages();
|
||||
},
|
||||
handleImagesChange(fileList) {
|
||||
this.formData.images = Array.isArray(fileList) ? fileList : [];
|
||||
this.imgs = this.formData.images
|
||||
.map(file => (file && (file.successUrl || file.url || file.path)) || '')
|
||||
this.trackSessionUploadedFileIds(fileList);
|
||||
this.formData.images = Array.isArray(fileList) ? [...fileList] : [];
|
||||
},
|
||||
buildImageListForCache(list) {
|
||||
if (!Array.isArray(list)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return list
|
||||
.map(image => {
|
||||
if (!image) return null;
|
||||
if (typeof image === 'string') {
|
||||
return { url: image, status: 'success' };
|
||||
}
|
||||
|
||||
if (typeof image === 'object') {
|
||||
const imageUrl = this.extractImageUrl(image);
|
||||
if (!imageUrl) return null;
|
||||
|
||||
return {
|
||||
...image,
|
||||
url: imageUrl,
|
||||
id: this.extractImageFileId(image),
|
||||
status: image.status || 'success'
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
})
|
||||
.filter(Boolean);
|
||||
},
|
||||
extractImageFileIds(list) {
|
||||
if (!Array.isArray(list)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Array.from(new Set(
|
||||
list
|
||||
.map(image => {
|
||||
if (!image || typeof image !== 'object') {
|
||||
return '';
|
||||
}
|
||||
|
||||
return this.extractImageFileId(image);
|
||||
})
|
||||
.filter(Boolean)
|
||||
));
|
||||
},
|
||||
trackSessionUploadedFileIds(nextImages) {
|
||||
const nextIds = this.extractImageFileIds(Array.isArray(nextImages) ? nextImages : []);
|
||||
if (!nextIds.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
const initialIds = new Set(this.initialImageFileIds || []);
|
||||
const mergedIds = new Set(this.sessionUploadedFileIds || []);
|
||||
nextIds.forEach(fileId => {
|
||||
if (!initialIds.has(fileId)) {
|
||||
mergedIds.add(fileId);
|
||||
}
|
||||
});
|
||||
this.sessionUploadedFileIds = Array.from(mergedIds);
|
||||
},
|
||||
extractImageListFromGetImagesResponse(response) {
|
||||
if (!response || typeof response !== 'object') {
|
||||
return [];
|
||||
}
|
||||
|
||||
const candidates = [
|
||||
response.data,
|
||||
response.data && response.data.data,
|
||||
response.data && response.data.images,
|
||||
response.data && response.data.list,
|
||||
response.data && response.data.rows,
|
||||
response.data && response.data.records,
|
||||
response.data && response.data.result,
|
||||
response.data && response.data.result && response.data.result.images,
|
||||
response.data && response.data.result && response.data.result.list,
|
||||
response.images,
|
||||
response.list,
|
||||
response.rows,
|
||||
response.records
|
||||
];
|
||||
|
||||
for (let i = 0; i < candidates.length; i++) {
|
||||
const current = candidates[i];
|
||||
if (!current) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Array.isArray(current)) {
|
||||
return current;
|
||||
}
|
||||
|
||||
if (typeof current === 'object') {
|
||||
const objectCandidates = [current.images, current.list, current.rows, current.records, current.data];
|
||||
for (let j = 0; j < objectCandidates.length; j++) {
|
||||
if (Array.isArray(objectCandidates[j])) {
|
||||
return objectCandidates[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return [];
|
||||
},
|
||||
extractImageEntriesFromResponse(response) {
|
||||
if (!response || typeof response !== 'object') {
|
||||
return [];
|
||||
}
|
||||
|
||||
const candidates = [
|
||||
response.data,
|
||||
response.data && response.data.data,
|
||||
response.data && response.data.images,
|
||||
response.data && response.data.list,
|
||||
response.data && response.data.rows,
|
||||
response.data && response.data.records,
|
||||
response.data && response.data.result,
|
||||
response.data && response.data.result && response.data.result.images,
|
||||
response.data && response.data.result && response.data.result.list,
|
||||
response.images,
|
||||
response.list,
|
||||
response.rows,
|
||||
response.records
|
||||
];
|
||||
|
||||
for (let i = 0; i < candidates.length; i++) {
|
||||
const current = candidates[i];
|
||||
if (!current) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Array.isArray(current)) {
|
||||
return current;
|
||||
}
|
||||
|
||||
if (typeof current === 'object') {
|
||||
const nestedCandidates = [current.images, current.list, current.rows, current.records, current.data];
|
||||
for (let j = 0; j < nestedCandidates.length; j++) {
|
||||
if (Array.isArray(nestedCandidates[j])) {
|
||||
return nestedCandidates[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return [];
|
||||
},
|
||||
extractImageFileIdsFromResponse(response) {
|
||||
return Array.from(new Set(
|
||||
this.extractImageEntriesFromResponse(response)
|
||||
.map(item => {
|
||||
if (!item || typeof item !== 'object') {
|
||||
return '';
|
||||
}
|
||||
|
||||
return this.extractImageFileId(item);
|
||||
})
|
||||
.filter(Boolean)
|
||||
));
|
||||
},
|
||||
async fetchRemoteImageFileIds() {
|
||||
const businessId = this.imageBusinessId;
|
||||
if (!businessId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const response = await this.$http('common.getImages', {
|
||||
type: 'stock',
|
||||
id: Number(businessId)
|
||||
});
|
||||
|
||||
return this.extractImageFileIdsFromResponse(response);
|
||||
},
|
||||
normalizeImageRecord(image) {
|
||||
if (!image) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (typeof image === 'string') {
|
||||
return {
|
||||
url: image,
|
||||
status: 'success'
|
||||
};
|
||||
}
|
||||
|
||||
if (typeof image !== 'object') {
|
||||
return null;
|
||||
}
|
||||
|
||||
const imageUrl = this.extractImageUrl(image);
|
||||
if (!imageUrl) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const fileId = this.extractImageFileId(image);
|
||||
|
||||
return {
|
||||
...image,
|
||||
url: imageUrl,
|
||||
id: fileId,
|
||||
file_id: fileId,
|
||||
status: image.status || 'success'
|
||||
};
|
||||
},
|
||||
async loadLatestImages() {
|
||||
const businessId = this.imageBusinessId;
|
||||
if (!businessId) {
|
||||
this.latestImagesLoadPromise = null;
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await this.$http('common.getImages', {
|
||||
type: 'stock',
|
||||
id: Number(businessId)
|
||||
});
|
||||
const remoteFileIds = this.extractImageFileIdsFromResponse(response);
|
||||
if (remoteFileIds.length) {
|
||||
this.initialImageFileIds = remoteFileIds;
|
||||
}
|
||||
|
||||
const list = this.extractImageListFromGetImagesResponse(response)
|
||||
.map(image => this.normalizeImageRecord(image))
|
||||
.filter(Boolean);
|
||||
|
||||
if (!list.length) {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
console.warn('[ItemMaint] getImages未返回有效图片,保留当前图片列表', {
|
||||
businessId,
|
||||
response
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
this.formData.images = list;
|
||||
this.initialImageSnapshot = this.buildImageListForCache(list);
|
||||
this.initialImageFileIds = this.extractImageFileIds(this.initialImageSnapshot).length
|
||||
? this.extractImageFileIds(this.initialImageSnapshot)
|
||||
: this.initialImageFileIds;
|
||||
this.rawItem = {
|
||||
...(this.rawItem || {}),
|
||||
images: list,
|
||||
image: (list[0] && list[0].url) || ''
|
||||
};
|
||||
} catch (error) {
|
||||
console.warn('[ItemMaint] 获取最新商品图片失败:', error);
|
||||
} finally {
|
||||
this.latestImagesLoadPromise = null;
|
||||
}
|
||||
},
|
||||
async rollbackImageReferences() {
|
||||
const businessId = this.imageBusinessId;
|
||||
if (!businessId) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.latestImagesLoadPromise) {
|
||||
try {
|
||||
await this.latestImagesLoadPromise;
|
||||
} catch (error) {
|
||||
console.warn('[ItemMaint] 等待图片初始化完成失败:', error);
|
||||
}
|
||||
}
|
||||
|
||||
const snapshot = this.buildImageListForCache(this.initialImageSnapshot);
|
||||
const snapshotFileIds = this.extractImageFileIds(snapshot);
|
||||
let targetFileIds = Array.isArray(this.initialImageFileIds) ? [...this.initialImageFileIds] : [];
|
||||
|
||||
if (!targetFileIds.length && snapshotFileIds.length) {
|
||||
targetFileIds = snapshotFileIds;
|
||||
}
|
||||
|
||||
if (!targetFileIds.length) {
|
||||
try {
|
||||
const remoteFileIds = await this.fetchRemoteImageFileIds();
|
||||
const uploadedIds = new Set(this.sessionUploadedFileIds || []);
|
||||
targetFileIds = remoteFileIds.filter(fileId => !uploadedIds.has(fileId));
|
||||
} catch (error) {
|
||||
console.warn('[ItemMaint] 返回时获取远端图片ID失败:', error);
|
||||
}
|
||||
}
|
||||
|
||||
const requestPayload = {
|
||||
id: Number(businessId),
|
||||
type: 'stock',
|
||||
images: targetFileIds.map(fileId => ({ file_id: fileId }))
|
||||
};
|
||||
|
||||
await this.$http('common.ReferenceFile', requestPayload);
|
||||
|
||||
this.formData.images = snapshot;
|
||||
this.rawItem = {
|
||||
...(this.rawItem || {}),
|
||||
images: snapshot,
|
||||
image: (snapshot[0] && snapshot[0].url) || ''
|
||||
};
|
||||
},
|
||||
navigateBackSafely() {
|
||||
this.bypassBackIntercept = true;
|
||||
uni.navigateBack({
|
||||
delta: 1,
|
||||
complete: () => {
|
||||
setTimeout(() => {
|
||||
this.bypassBackIntercept = false;
|
||||
}, 300);
|
||||
}
|
||||
});
|
||||
},
|
||||
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);
|
||||
},
|
||||
speakItemMaintMessage(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('[ItemMaint] 语音播报失败:', error);
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn('[ItemMaint] 语音播报异常:', error);
|
||||
}
|
||||
},
|
||||
stopItemMaintSpeak() {
|
||||
const tools = this.$tools;
|
||||
if (!tools || typeof tools.stopSpeak !== 'function') {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
tools.stopSpeak();
|
||||
} catch (error) {
|
||||
console.warn('[ItemMaint] 停止语音播报异常:', error);
|
||||
}
|
||||
},
|
||||
showToastMessage(title, icon = 'none', options = {}) {
|
||||
const message = String(title || '').trim();
|
||||
if (!message) {
|
||||
return;
|
||||
}
|
||||
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon
|
||||
});
|
||||
|
||||
if (options.speak !== false) {
|
||||
this.speakItemMaintMessage(options.speakText || message, options.voiceOptions || {});
|
||||
}
|
||||
},
|
||||
async handleSave() {
|
||||
if (this.saving) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.stockId) {
|
||||
uni.showToast({
|
||||
title: '请先扫描商品',
|
||||
icon: 'none'
|
||||
});
|
||||
this.showToastMessage('请先扫描商品');
|
||||
return;
|
||||
}
|
||||
|
||||
const raw = this.rawItem || {};
|
||||
const itemCode = String(raw.item_code || raw.goods_code || '').trim();
|
||||
if (!itemCode) {
|
||||
uni.showToast({
|
||||
title: '缺少商品编码,无法保存',
|
||||
icon: 'none'
|
||||
});
|
||||
this.showToastMessage('缺少商品编码,无法保存');
|
||||
return;
|
||||
}
|
||||
|
||||
const storeId = this.resolveStoreId(raw);
|
||||
if (!storeId) {
|
||||
uni.showToast({
|
||||
title: '未获取到货主ID',
|
||||
icon: 'none'
|
||||
});
|
||||
this.showToastMessage('未获取到货主ID');
|
||||
return;
|
||||
}
|
||||
|
||||
const itemName = String(this.formData.NAME || '').trim();
|
||||
if (!itemName) {
|
||||
uni.showToast({
|
||||
title: '商品名称为空',
|
||||
icon: 'none'
|
||||
});
|
||||
this.showToastMessage('商品名称为空');
|
||||
return;
|
||||
}
|
||||
|
||||
@ -532,7 +956,6 @@ export default {
|
||||
return Number.isFinite(numeric) ? numeric : 0;
|
||||
};
|
||||
|
||||
const yxq = toNumber(this.formData.YXQ);
|
||||
const quantityPerBox = toNumber(this.formData.quantity_per_box);
|
||||
|
||||
const payload = {
|
||||
@ -552,12 +975,12 @@ export default {
|
||||
height: toNumber(raw.height),
|
||||
volume: toNumber(raw.volume),
|
||||
gross_weight: toNumber(this.formData.WEIGHT),
|
||||
net_weight: toNumber(raw.net_weight),
|
||||
net_weight: toNumber(this.formData.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_shelf_life_mgmt: raw.is_shelf_life_mgmt !== undefined ? raw.is_shelf_life_mgmt : 'N',
|
||||
shelf_life_days: toNumber(raw.shelf_life_days),
|
||||
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),
|
||||
@ -576,6 +999,7 @@ export default {
|
||||
goods_code: String(raw.goods_code || itemCode).trim()
|
||||
};
|
||||
|
||||
this.keepVoiceOnExit = false;
|
||||
this.saving = true;
|
||||
try {
|
||||
const res = await this.$http('stock.warehouse.saveWarehouseStock', payload);
|
||||
@ -583,21 +1007,44 @@ export default {
|
||||
throw new Error((res && res.message) || '保存失败');
|
||||
}
|
||||
|
||||
uni.showToast({
|
||||
title: '保存成功',
|
||||
icon: 'success'
|
||||
const normalizedImages = this.buildImageListForCache(this.formData.images);
|
||||
const imageUrls = normalizedImages
|
||||
.map(image => (image && image.url) || '')
|
||||
.filter(Boolean);
|
||||
|
||||
const nextItem = {
|
||||
...(this.rawItem || {}),
|
||||
id: this.stockId,
|
||||
stock_id: this.stockId,
|
||||
item_name: itemName,
|
||||
product_name: itemName,
|
||||
name: itemName,
|
||||
item_code: itemCode,
|
||||
goods_code: String(raw.goods_code || itemCode).trim(),
|
||||
gross_weight: toNumber(this.formData.WEIGHT),
|
||||
net_weight: toNumber(this.formData.NET_WEIGHT),
|
||||
shelf_life_days: toNumber(raw.shelf_life_days),
|
||||
is_shelf_life_mgmt: raw.is_shelf_life_mgmt !== undefined ? raw.is_shelf_life_mgmt : 'N',
|
||||
images: normalizedImages,
|
||||
image: imageUrls[0] || ''
|
||||
};
|
||||
|
||||
// 通知商品查询页:失效该商品图片/条码缓存并触发重新查询
|
||||
uni.$emit('product:query:updated', {
|
||||
item: nextItem,
|
||||
timestamp: Date.now()
|
||||
});
|
||||
uni.setStorageSync('product_query_need_refresh', Date.now());
|
||||
|
||||
this.keepVoiceOnExit = true;
|
||||
this.showToastMessage('保存成功', 'success');
|
||||
setTimeout(() => {
|
||||
uni.navigateBack({
|
||||
delta: 1
|
||||
});
|
||||
this.navigateBackSafely();
|
||||
}, 600);
|
||||
} catch (error) {
|
||||
this.keepVoiceOnExit = false;
|
||||
console.error('[ItemMaint] 保存异常:', error);
|
||||
uni.showToast({
|
||||
title: (error && error.message) || '保存失败',
|
||||
icon: 'none'
|
||||
});
|
||||
this.showToastMessage((error && error.message) || '保存失败');
|
||||
} finally {
|
||||
this.saving = false;
|
||||
}
|
||||
@ -620,8 +1067,9 @@ export default {
|
||||
}
|
||||
|
||||
::v-deep .nav-save-btn {
|
||||
min-width: 144rpx !important;
|
||||
padding: 0 32rpx !important;
|
||||
width: 176rpx !important;
|
||||
min-width: 176rpx !important;
|
||||
padding: 0 !important;
|
||||
height: 72rpx !important;
|
||||
line-height: 72rpx !important;
|
||||
margin-right: 18rpx !important;
|
||||
@ -636,15 +1084,11 @@ export default {
|
||||
border-radius: 12rpx !important;
|
||||
}
|
||||
|
||||
.nav-save-btn__text {
|
||||
font-size: 32rpx;
|
||||
font-weight: 600;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
::v-deep .nav-save-btn .u-button__text {
|
||||
::v-deep .nav-save-btn .u-button__text,
|
||||
::v-deep .nav-save-btn .u-button__loading-text {
|
||||
font-size: 32rpx !important;
|
||||
font-weight: 600 !important;
|
||||
color: #ffffff !important;
|
||||
}
|
||||
|
||||
.form-content {
|
||||
@ -660,6 +1104,16 @@ export default {
|
||||
padding-top: 160rpx;
|
||||
}
|
||||
|
||||
.empty-state__icon {
|
||||
width: 160rpx;
|
||||
height: 160rpx;
|
||||
border-radius: 50%;
|
||||
background: #eaf1ff;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.empty-text {
|
||||
margin-top: 24rpx;
|
||||
color: #909399;
|
||||
@ -673,14 +1127,16 @@ export default {
|
||||
}
|
||||
|
||||
.form-card {
|
||||
margin: 20rpx 24rpx;
|
||||
margin: 20rpx 12rpx;
|
||||
background: #ffffff;
|
||||
border-radius: 16rpx;
|
||||
border: 2rpx solid #ebedf2;
|
||||
border-radius: 20rpx;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 6rpx 20rpx rgba(31, 45, 61, 0.06);
|
||||
}
|
||||
|
||||
.form-section {
|
||||
padding: 28rpx 24rpx;
|
||||
padding: 28rpx;
|
||||
border-bottom: 2rpx solid #f0f1f3;
|
||||
}
|
||||
|
||||
@ -743,9 +1199,9 @@ export default {
|
||||
}
|
||||
|
||||
.field-label {
|
||||
width: 330rpx;
|
||||
width: 210rpx;
|
||||
flex-shrink: 0;
|
||||
margin-right: 16rpx;
|
||||
margin-right: 12rpx;
|
||||
color: #303133;
|
||||
font-size: 36rpx;
|
||||
font-weight: 600;
|
||||
@ -758,34 +1214,6 @@ export default {
|
||||
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;
|
||||
}
|
||||
|
||||
@ -946,16 +946,16 @@
|
||||
return;
|
||||
}
|
||||
|
||||
// 提取图片 URL 列表
|
||||
// 提取图片 URL 列表(统一规则:嵌套 file 对象优先,再取扁平字段)
|
||||
const imageUrls = imageData
|
||||
.map(img => {
|
||||
if (!img) return '';
|
||||
if (typeof img === 'string') return img;
|
||||
// 嵌套 file 对象: { file: { file_url, file_name } }
|
||||
if (img.file && typeof img.file === 'object') {
|
||||
return img.file.file_url || img.file.url || img.file.path || '';
|
||||
}
|
||||
return img.url || img.path || img.image_url || img.fileUrl || img.successUrl || '';
|
||||
const nestedFileUrl = img.file && typeof img.file === 'object'
|
||||
? (img.file.file_url || img.file.url || img.file.path || img.file.fileUrl || '')
|
||||
: '';
|
||||
return nestedFileUrl || img.url || img.path || img.fileUrl || img.file_url || img.image_url || img.img_url || img.src || img.successUrl || '';
|
||||
})
|
||||
.filter(Boolean);
|
||||
|
||||
@ -1520,7 +1520,10 @@
|
||||
}
|
||||
|
||||
if (typeof firstImage === 'object') {
|
||||
return String(firstImage.url || firstImage.path || firstImage.successUrl || firstImage.fileUrl || firstImage.image_url || '');
|
||||
const nestedFileUrl = firstImage.file && typeof firstImage.file === 'object'
|
||||
? (firstImage.file.file_url || firstImage.file.url || firstImage.file.path || firstImage.file.fileUrl || '')
|
||||
: '';
|
||||
return String(nestedFileUrl || firstImage.url || firstImage.path || firstImage.fileUrl || firstImage.file_url || firstImage.image_url || firstImage.img_url || firstImage.src || firstImage.successUrl || '');
|
||||
}
|
||||
|
||||
return '';
|
||||
@ -1549,7 +1552,10 @@
|
||||
}
|
||||
|
||||
if (typeof image === 'object') {
|
||||
return image.url || image.path || image.successUrl || image.fileUrl || image.image_url || '';
|
||||
const nestedFileUrl = image.file && typeof image.file === 'object'
|
||||
? (image.file.file_url || image.file.url || image.file.path || image.file.fileUrl || '')
|
||||
: '';
|
||||
return nestedFileUrl || image.url || image.path || image.fileUrl || image.file_url || image.image_url || image.img_url || image.src || image.successUrl || '';
|
||||
}
|
||||
|
||||
return '';
|
||||
@ -3384,7 +3390,6 @@
|
||||
background: #2979ff;
|
||||
border-color: #2979ff;
|
||||
color: #ffffff;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.storage-action-btn__text {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user