diff --git a/src/components/PublishDialog.vue b/src/components/PublishDialog.vue index 59df189..d912b8a 100644 --- a/src/components/PublishDialog.vue +++ b/src/components/PublishDialog.vue @@ -6,7 +6,7 @@ - + @@ -149,7 +149,8 @@ export default { name: 'PublishDialog', props: { visible: { type: Boolean, default: false }, - initialData: { type: Object, default: () => ({}) } + initialData: { type: Object, default: () => ({}) }, + hideAppid: { type: Boolean, default: false } }, data() { return { @@ -162,9 +163,9 @@ export default { form: { appid: '', userName: '', - province: 440000, - city: 440400, - district: 440402, + province: null, + city: null, + district: null, title: '', content: '', wenanIndex: 0, @@ -291,6 +292,11 @@ export default { if (typeof d.originalPrice === 'number') { this.form.originalPrice = d.originalPrice; } + // 预设:会员名、省市区 + if (d.userName) this.form.userName = d.userName; + if (d.province) this.form.province = d.province; + if (d.city) this.form.city = d.city; + if (d.district) this.form.district = d.district; await this.loadProvinces(); await this.loadERPAccounts(); await this.loadUsernames(); @@ -307,25 +313,45 @@ export default { handleCopyImageUrl(imageUrl) { if (navigator.clipboard) { navigator.clipboard.writeText(imageUrl).then(() => { this.$modal.msgSuccess('图片链接复制成功'); }).catch(() => { this.$message.error('复制失败'); }); } }, handlePreviewImage(imageUrl) { window.open(imageUrl, '_blank'); }, async loadProvinces(echo = true) { - try { const res = await getProvinces(); if (res.code === 200) this.regionOptions.provinces = res.data || []; else this.$modal.msgError(res.msg || '加载省份失败'); } catch(e){ this.$modal.msgError('加载省份失败'); } - if (echo && this.form.province) { await this.loadCities(this.form.province, true); } else { this.regionOptions.cities = []; this.regionOptions.areas = []; this.form.city = null; this.form.district = null; } + try { + const res = await getProvinces(); + if (res.code === 200) this.regionOptions.provinces = res.data || []; else this.$modal.msgError(res.msg || '加载省份失败'); + } catch(e){ this.$modal.msgError('加载省份失败'); } + if (!this.form.province && this.regionOptions.provinces.length) { + this.form.province = this.regionOptions.provinces[0].value; + } + if (this.form.province) { await this.loadCities(this.form.province, true); } else { this.regionOptions.cities = []; this.regionOptions.areas = []; this.form.city = null; this.form.district = null; } }, async onProvinceChange() { await this.loadCities(this.form.province, false); }, async onCityChange() { await this.loadAreas(this.form.province, this.form.city, false); }, async loadCities(provId, echo = false) { if (!provId) { this.regionOptions.cities = []; this.regionOptions.areas = []; this.form.city = null; this.form.district = null; return; } try { const res = await getCities(provId); if (res.code === 200) this.regionOptions.cities = res.data || []; else this.$modal.msgError(res.msg || '加载城市失败'); } catch(e){ this.$modal.msgError('加载城市失败'); } - if (echo && this.form.city) { await this.loadAreas(provId, this.form.city, true); } else { this.regionOptions.areas = []; this.form.district = null; } + if (!this.form.city && this.regionOptions.cities.length) { + this.form.city = this.regionOptions.cities[0].value; + } + if (this.form.city) { await this.loadAreas(provId, this.form.city, true); } else { this.regionOptions.areas = []; this.form.district = null; } }, async loadAreas(provId, cityId, echo = false) { if (!provId || !cityId) { this.regionOptions.areas = []; this.form.district = null; return; } try { const res = await getAreas(provId, cityId); if (res.code === 200) this.regionOptions.areas = res.data || []; else this.$modal.msgError(res.msg || '加载区县失败'); } catch(e){ this.$modal.msgError('加载区县失败'); } - if (!echo) { this.form.district = null; } + if (!this.form.district && this.regionOptions.areas.length) { + this.form.district = this.regionOptions.areas[0].value; + } else if (!echo) { + this.form.district = null; + } }, async loadERPAccounts() { this.erpAccountLoading = true; - try { const res = await getERPAccounts(); if (res.code === 200) this.erpAccountsOptions = res.data || []; else this.$modal.msgError(res.msg || '加载应用失败'); } catch(e){ this.$modal.msgError('加载应用失败'); } - this.erpAccountLoading = false; if (!this.form.appid && this.erpAccountsOptions.length) { this.form.appid = this.erpAccountsOptions[0].value; } + try { + const res = await getERPAccounts(); + if (res.code === 200) this.erpAccountsOptions = res.data || []; else this.$modal.msgError(res.msg || '加载应用失败'); + } catch(e){ this.$modal.msgError('加载应用失败'); } + this.erpAccountLoading = false; + // 如果隐藏appid选择,则不强制赋值给表单,由后端使用默认账号 + if (!this.hideAppid && !this.form.appid && this.erpAccountsOptions.length) { + this.form.appid = this.erpAccountsOptions[0].value; + } }, onAppidChange() { this.form.userName = ''; this.loadUsernames(); this.loadCategories(); this.loadProperties(); }, async loadUsernames() { diff --git a/src/views/system/favoriteProduct/index.vue b/src/views/system/favoriteProduct/index.vue index 37af1f5..35d84a9 100644 --- a/src/views/system/favoriteProduct/index.vue +++ b/src/views/system/favoriteProduct/index.vue @@ -362,15 +362,21 @@ 确 定 + + +