1
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
<el-option v-for="(opt, idx) in wenanOptions" :key="idx" :label="opt.label" :value="idx" />
|
<el-option v-for="(opt, idx) in wenanOptions" :key="idx" :label="opt.label" :value="idx" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="闲管家账号">
|
<el-form-item label="闲管家账号" v-if="!hideAppid">
|
||||||
<el-select v-model="form.appid" filterable placeholder="选择ERP应用" :loading="erpAccountLoading" @change="onAppidChange">
|
<el-select v-model="form.appid" filterable placeholder="选择ERP应用" :loading="erpAccountLoading" @change="onAppidChange">
|
||||||
<el-option v-for="a in erpAccountsOptions" :key="a.value" :label="a.label" :value="a.value" />
|
<el-option v-for="a in erpAccountsOptions" :key="a.value" :label="a.label" :value="a.value" />
|
||||||
</el-select>
|
</el-select>
|
||||||
@@ -149,7 +149,8 @@ export default {
|
|||||||
name: 'PublishDialog',
|
name: 'PublishDialog',
|
||||||
props: {
|
props: {
|
||||||
visible: { type: Boolean, default: false },
|
visible: { type: Boolean, default: false },
|
||||||
initialData: { type: Object, default: () => ({}) }
|
initialData: { type: Object, default: () => ({}) },
|
||||||
|
hideAppid: { type: Boolean, default: false }
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -162,9 +163,9 @@ export default {
|
|||||||
form: {
|
form: {
|
||||||
appid: '',
|
appid: '',
|
||||||
userName: '',
|
userName: '',
|
||||||
province: 440000,
|
province: null,
|
||||||
city: 440400,
|
city: null,
|
||||||
district: 440402,
|
district: null,
|
||||||
title: '',
|
title: '',
|
||||||
content: '',
|
content: '',
|
||||||
wenanIndex: 0,
|
wenanIndex: 0,
|
||||||
@@ -291,6 +292,11 @@ export default {
|
|||||||
if (typeof d.originalPrice === 'number') {
|
if (typeof d.originalPrice === 'number') {
|
||||||
this.form.originalPrice = d.originalPrice;
|
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.loadProvinces();
|
||||||
await this.loadERPAccounts();
|
await this.loadERPAccounts();
|
||||||
await this.loadUsernames();
|
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('复制失败'); }); } },
|
handleCopyImageUrl(imageUrl) { if (navigator.clipboard) { navigator.clipboard.writeText(imageUrl).then(() => { this.$modal.msgSuccess('图片链接复制成功'); }).catch(() => { this.$message.error('复制失败'); }); } },
|
||||||
handlePreviewImage(imageUrl) { window.open(imageUrl, '_blank'); },
|
handlePreviewImage(imageUrl) { window.open(imageUrl, '_blank'); },
|
||||||
async loadProvinces(echo = true) {
|
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('加载省份失败'); }
|
try {
|
||||||
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; }
|
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 onProvinceChange() { await this.loadCities(this.form.province, false); },
|
||||||
async onCityChange() { await this.loadAreas(this.form.province, this.form.city, false); },
|
async onCityChange() { await this.loadAreas(this.form.province, this.form.city, false); },
|
||||||
async loadCities(provId, echo = false) {
|
async loadCities(provId, echo = false) {
|
||||||
if (!provId) { this.regionOptions.cities = []; this.regionOptions.areas = []; this.form.city = null; this.form.district = null; return; }
|
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('加载城市失败'); }
|
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) {
|
async loadAreas(provId, cityId, echo = false) {
|
||||||
if (!provId || !cityId) { this.regionOptions.areas = []; this.form.district = null; return; }
|
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('加载区县失败'); }
|
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() {
|
async loadERPAccounts() {
|
||||||
this.erpAccountLoading = true;
|
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('加载应用失败'); }
|
try {
|
||||||
this.erpAccountLoading = false; if (!this.form.appid && this.erpAccountsOptions.length) { this.form.appid = this.erpAccountsOptions[0].value; }
|
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(); },
|
onAppidChange() { this.form.userName = ''; this.loadUsernames(); this.loadCategories(); this.loadProperties(); },
|
||||||
async loadUsernames() {
|
async loadUsernames() {
|
||||||
|
|||||||
@@ -362,15 +362,21 @@
|
|||||||
<el-button type="primary" @click="submitQuickPublish" :loading="quickPublishLoading">确 定</el-button>
|
<el-button type="primary" @click="submitQuickPublish" :loading="quickPublishLoading">确 定</el-button>
|
||||||
</div>
|
</div>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
|
||||||
|
<!-- 通用发品对话框:从常用商品直接进入,不显示ERP应用选择 -->
|
||||||
|
<PublishDialog :visible.sync="publishDialogVisible" :initial-data="publishInitialData" :hideAppid="true" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { listFavoriteProduct, getFavoriteProduct, delFavoriteProduct, addFavoriteProduct, updateFavoriteProduct, updateTopStatus, quickPublishFromFavorite } from "@/api/system/favoriteProduct";
|
import { listFavoriteProduct, getFavoriteProduct, delFavoriteProduct, addFavoriteProduct, updateFavoriteProduct, updateTopStatus, quickPublishFromFavorite } from "@/api/system/favoriteProduct";
|
||||||
|
import { generatePromotionContent } from "@/api/system/jdorder";
|
||||||
import { mapGetters, mapActions } from 'vuex'
|
import { mapGetters, mapActions } from 'vuex'
|
||||||
|
import PublishDialog from '@/components/PublishDialog.vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "FavoriteProduct",
|
name: "FavoriteProduct",
|
||||||
|
components: { PublishDialog },
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters(['favoriteProductRefreshKey'])
|
...mapGetters(['favoriteProductRefreshKey'])
|
||||||
},
|
},
|
||||||
@@ -437,7 +443,10 @@ export default {
|
|||||||
{ label: '闲鱼', value: 'xianyu' },
|
{ label: '闲鱼', value: 'xianyu' },
|
||||||
{ label: '淘宝', value: 'taobao' },
|
{ label: '淘宝', value: 'taobao' },
|
||||||
{ label: '京东', value: 'jd' }
|
{ label: '京东', value: 'jd' }
|
||||||
]
|
],
|
||||||
|
// 通用发品弹窗
|
||||||
|
publishDialogVisible: false,
|
||||||
|
publishInitialData: {}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
@@ -603,9 +612,44 @@ export default {
|
|||||||
},
|
},
|
||||||
/** 快速发品 */
|
/** 快速发品 */
|
||||||
handleQuickPublish(row) {
|
handleQuickPublish(row) {
|
||||||
this.selectedProduct = row;
|
// 先用商品链接生成完整商品信息,再打开通用发品弹窗
|
||||||
this.quickPublishForm.appid = '';
|
const id = row.id || this.ids;
|
||||||
this.quickPublishVisible = true;
|
getFavoriteProduct(id).then(async res => {
|
||||||
|
const p = res && res.data ? res.data : (row || {});
|
||||||
|
try {
|
||||||
|
let detail = null;
|
||||||
|
if (p.productUrl) {
|
||||||
|
const r = await generatePromotionContent({ promotionContent: p.productUrl });
|
||||||
|
const resultStr = (r && (r.msg || r.data)) || '';
|
||||||
|
try { const arr = typeof resultStr === 'string' ? JSON.parse(resultStr) : resultStr; if (Array.isArray(arr) && arr.length) detail = arr[0]; } catch(e) {}
|
||||||
|
}
|
||||||
|
const images = Array.isArray(detail && detail.images) && detail.images.length ? detail.images : (p.productImage ? [p.productImage] : []);
|
||||||
|
const wenanArr = Array.isArray(detail && detail.wenan) ? detail.wenan : [];
|
||||||
|
const wenanOptions = wenanArr.map((w, i) => ({ label: w.type || `版本${i+1}` , content: w.content || '' }));
|
||||||
|
this.publishInitialData = {
|
||||||
|
title: (detail && (detail.skuName || detail.title)) || p.productName || '',
|
||||||
|
content: (wenanOptions[0] && wenanOptions[0].content) || '',
|
||||||
|
images: images,
|
||||||
|
originalPrice: detail && detail.price ? Number(detail.price) : (p.price ? Number(p.price) : undefined),
|
||||||
|
wenanOptions: wenanOptions,
|
||||||
|
// 预设:同一用户经常固定账号与地区,优先从常用商品扩展字段取值(如有)
|
||||||
|
userName: p.userName || '',
|
||||||
|
province: p.province || null,
|
||||||
|
city: p.city || null,
|
||||||
|
district: p.district || null
|
||||||
|
};
|
||||||
|
this.publishDialogVisible = true;
|
||||||
|
} catch (e) {
|
||||||
|
const imagesFallback = p.productImage ? [p.productImage] : [];
|
||||||
|
this.publishInitialData = { title: p.productName || '', images: imagesFallback, content: '' };
|
||||||
|
this.publishDialogVisible = true;
|
||||||
|
}
|
||||||
|
}).catch(() => {
|
||||||
|
// 失败也尽量用行数据打开
|
||||||
|
const images = row && row.productImage ? [row.productImage] : [];
|
||||||
|
this.publishInitialData = { title: row.productName || '', images, content: '' };
|
||||||
|
this.publishDialogVisible = true;
|
||||||
|
});
|
||||||
},
|
},
|
||||||
/** 提交快速发品 */
|
/** 提交快速发品 */
|
||||||
submitQuickPublish() {
|
submitQuickPublish() {
|
||||||
|
|||||||
Reference in New Issue
Block a user