1
This commit is contained in:
@@ -393,7 +393,8 @@
|
||||
import { listXbmessage, delXbmessage, getGroupNameOptions } from "@/api/system/xbmessage";
|
||||
import { parseTime } from "@/utils/ruoyi";
|
||||
import PublishDialog from '@/components/PublishDialog.vue'
|
||||
import { generatePromotionContent, createProductByPromotion, getProvinces, getCities, getAreas, getCategories, getUsernames, getERPAccounts, getProperties, createGiftCoupon, transferWithGift } from "@/api/system/jdorder";
|
||||
import { generatePromotionContent, createGiftCoupon, transferWithGift } from "@/api/system/jdorder";
|
||||
import { addToFavoritesAfterPublishFromXb } from "@/utils/publishHelper";
|
||||
import { addToFavorites, getBySkuid } from "@/api/system/favoriteProduct";
|
||||
|
||||
export default {
|
||||
@@ -449,47 +450,7 @@ export default {
|
||||
giftForm: { amount: null, quantity: 10 },
|
||||
giftLoading: false,
|
||||
giftContext: { materialUrl: '', owner: 'g', skuName: '' },
|
||||
// 发品相关
|
||||
quickLinkPublishDialog: {
|
||||
visible: false,
|
||||
loading: false,
|
||||
wenanOptions: [],
|
||||
productImages: [],
|
||||
form: {
|
||||
appid: '',
|
||||
wenanIndex: 0,
|
||||
title: '',
|
||||
content: '',
|
||||
extraImagesText: '',
|
||||
whiteImages: '',
|
||||
serviceSupport: ['NFR'],
|
||||
userName: '',
|
||||
province: 440000,
|
||||
city: 440400,
|
||||
district: 440402,
|
||||
price: null,
|
||||
originalPrice: null,
|
||||
expressFee: 0,
|
||||
stock: 999,
|
||||
outerId: '',
|
||||
itemBizType: 2,
|
||||
spBizType: 3,
|
||||
channelCatId: '',
|
||||
channelPvJson: '',
|
||||
stuffStatus: 100,
|
||||
},
|
||||
rules: {
|
||||
title: [{ required: true, message: '请输入标题', trigger: 'blur' }],
|
||||
content: [{ required: true, message: '请输入文案内容', trigger: 'blur' }],
|
||||
userName: [{ required: true, message: '请输入闲鱼会员名', trigger: 'blur' }],
|
||||
price: [{ required: true, message: '请输入价格', trigger: 'blur' }],
|
||||
expressFee: [{ required: true, message: '请输入运费', trigger: 'blur' }],
|
||||
stock: [{ required: true, message: '请输入库存', trigger: 'blur' }],
|
||||
itemBizType: [{ required: true, message: '请选择商品类型', trigger: 'change' }],
|
||||
spBizType: [{ required: true, message: '请选择行业类型', trigger: 'change' }],
|
||||
channelCatId: [{ required: true, message: '请选择类目', trigger: 'change' }]
|
||||
}
|
||||
},
|
||||
|
||||
// 地区选项
|
||||
regionOptions: {
|
||||
provinces: [],
|
||||
@@ -571,12 +532,11 @@ export default {
|
||||
// 记录当前线报项,便于发品成功后加入常用
|
||||
this.currentXbMessageItem = child;
|
||||
|
||||
// 先尝试生成转链文案,成功后带文案打开发品弹窗
|
||||
// 与转链一致:统一先调用转链接口补全字段
|
||||
const materialUrl = this.getJsonValue(child.jsonQueryResult, 'materialUrl');
|
||||
const skuName = child.skuName;
|
||||
const inputContent = materialUrl || skuName || '';
|
||||
|
||||
// 预先设置基本信息,等待文案生成后补充
|
||||
const baseInitialData = {
|
||||
title: this.decodeUnicode(child.skuName) || '',
|
||||
content: '',
|
||||
@@ -586,25 +546,18 @@ export default {
|
||||
};
|
||||
|
||||
if (!inputContent) {
|
||||
// 无法生成转链输入,直接打开(无文案)
|
||||
this.publishInitialData = baseInitialData;
|
||||
this.publishDialogVisible = true;
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
this.$modal && this.$modal.loading('正在生成转链文案,请稍候…');
|
||||
} catch(e) { /* 忽略 */ }
|
||||
try { this.$modal && this.$modal.loading('正在生成转链文案,请稍候…'); } catch(e) {}
|
||||
|
||||
generatePromotionContent({ promotionContent: inputContent }).then(res => {
|
||||
let result = res && (res.msg || res.data);
|
||||
const result = res && (res.msg || res.data);
|
||||
let arr = [];
|
||||
try {
|
||||
if (typeof result === 'string') {
|
||||
arr = JSON.parse(result);
|
||||
} else if (Array.isArray(result)) {
|
||||
arr = result;
|
||||
}
|
||||
if (typeof result === 'string') arr = JSON.parse(result); else if (Array.isArray(result)) arr = result;
|
||||
} catch (e) { arr = []; }
|
||||
|
||||
let wenanOptions = [];
|
||||
@@ -612,20 +565,19 @@ export default {
|
||||
if (Array.isArray(arr) && arr.length > 0) {
|
||||
const first = arr[0] || {};
|
||||
const wenanArr = Array.isArray(first.wenan) ? first.wenan : [];
|
||||
wenanOptions = wenanArr.map((w, i) => ({ label: w.type || `版本${i+1}`, content: w.content || '' }));
|
||||
wenanOptions = wenanArr.map((w, i) => ({ label: w.type || `版本${i+1}` , content: w.content || '' }));
|
||||
detailImages = this.extractImageUrlsFromGenerateResult(first);
|
||||
}
|
||||
|
||||
this.publishInitialData = Object.assign({}, baseInitialData, {
|
||||
content: (wenanOptions[0] && wenanOptions[0].content) || '',
|
||||
wenanOptions,
|
||||
images: (detailImages && detailImages.length) ? detailImages : baseInitialData.images
|
||||
images: (detailImages && detailImages.length) ? detailImages : baseInitialData.images,
|
||||
wenanOptions
|
||||
});
|
||||
}).catch(() => {
|
||||
// 忽略错误,仍然打开弹窗(无文案)
|
||||
this.publishInitialData = baseInitialData;
|
||||
}).finally(() => {
|
||||
try { this.$modal && this.$modal.closeLoading(); } catch(e) { /* 忽略 */ }
|
||||
try { this.$modal && this.$modal.closeLoading(); } catch(e) {}
|
||||
this.publishDialogVisible = true;
|
||||
});
|
||||
},
|
||||
@@ -1960,14 +1912,10 @@ export default {
|
||||
/** 接收通用发品弹窗成功事件:等待接口返回后自动加常用,但不关闭页面 */
|
||||
onPublishDialogSuccess(res) {
|
||||
try {
|
||||
const data = res && res.data ? res.data : {};
|
||||
const productId = data.product_id || data.productId || (data.data && (data.data.product_id || data.data.productId));
|
||||
const productStatus = data.product_status || data.productStatus || (data.data && (data.data.product_status || data.data.productStatus));
|
||||
const outerId = data.outer_id || data.outerId || (data.data && (data.data.outer_id || data.data.outerId));
|
||||
if (productId) {
|
||||
this.addToFavoritesAfterPublish(productId, productStatus, outerId);
|
||||
// 触发全局常用商品列表刷新
|
||||
this.$store.dispatch('app/triggerFavoriteProductRefresh');
|
||||
if (this.currentXbMessageItem) {
|
||||
addToFavoritesAfterPublishFromXb(this.currentXbMessageItem, res).then(() => {
|
||||
this.$store.dispatch('app/triggerFavoriteProductRefresh');
|
||||
});
|
||||
}
|
||||
} catch (e) { /* 忽略解析异常 */ }
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user