From d41cf24764a9d01b06fab67bf8082e82fd7ea906 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8D=92?= Date: Thu, 9 Oct 2025 00:40:50 +0800 Subject: [PATCH] 1 --- src/components/PublishDialog.vue | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/components/PublishDialog.vue b/src/components/PublishDialog.vue index 717067f..d17c0a8 100644 --- a/src/components/PublishDialog.vue +++ b/src/components/PublishDialog.vue @@ -376,6 +376,9 @@ export default { else { this.$modal.msgError(res.msg || '加载属性失败'); } } catch(e) { this.$modal.msgError('加载属性失败'); } }, + onPvChange() { + // 属性值变更时的回调(可用于调试或联动逻辑) + }, submitPublish() { this.$refs.publishForm.validate(valid => { if (!valid) return; @@ -389,10 +392,26 @@ export default { try { channelPv = JSON.parse(f.channelPvJson); } catch(e) { this.$modal.msgError('属性JSON格式不正确'); return; } } else if (this.selectedPv && Object.keys(this.selectedPv).length) { - channelPv = Object.keys(this.selectedPv).map(pid => ({ - property_id: isNaN(Number(pid)) ? pid : Number(pid), - value_id: this.selectedPv[pid] - })); + // 从 pvOptions 中获取完整的属性信息(property_id, property_name, value_id, value_name) + channelPv = []; + Object.keys(this.selectedPv).forEach(pid => { + const valueId = this.selectedPv[pid]; + if (!valueId) return; // 跳过未选择的属性 + // 从 pvOptions 中找到对应的属性 + const property = this.pvOptions.find(p => String(p.propertyId) === String(pid)); + if (!property) return; + // 从属性的 values 中找到对应的值 + const value = property.values && property.values.find(v => String(v.valueId) === String(valueId)); + if (!value) return; + // 构建完整的4个字段 + channelPv.push({ + property_id: pid, + property_name: property.propertyName, + value_id: valueId, + value_name: value.valueName + }); + }); + if (channelPv.length === 0) channelPv = undefined; } const payload = { appid: f.appid || undefined,