1
This commit is contained in:
@@ -98,8 +98,9 @@
|
||||
</div>
|
||||
|
||||
<!-- 发品操作 -->
|
||||
<div style="margin-top: 10px;">
|
||||
<div style="margin-top: 10px; display:flex; gap:8px;">
|
||||
<el-button type="primary" @click="openPublish(product, productIndex)">发品</el-button>
|
||||
<el-button @click="handleAddToFavorites(product)">加入常用</el-button>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
@@ -122,133 +123,19 @@
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
<!-- 发品对话框 -->
|
||||
<el-dialog title="发品" :visible.sync="publishDialog.visible" width="1200px" :close-on-click-modal="false" :close-on-press-escape="false" :destroy-on-close="false" append-to-body>
|
||||
<el-form :model="publishDialog.form" :rules="publishDialog.rules" ref="publishForm" label-width="110px">
|
||||
<el-form-item label="文案版本" v-if="publishDialog.wenanOptions && publishDialog.wenanOptions.length > 0">
|
||||
<el-select v-model="publishDialog.form.wenanIndex" placeholder="选择文案版本" @change="onWenanChange" style="width:100%">
|
||||
<el-option v-for="(opt, idx) in publishDialog.wenanOptions" :key="idx" :label="opt.label" :value="idx" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="闲管家账号">
|
||||
<el-select v-model="publishDialog.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-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="标题" prop="title">
|
||||
<el-input v-model="publishDialog.form.title" maxlength="60" show-word-limit />
|
||||
</el-form-item>
|
||||
<el-form-item label="文案内容" prop="content">
|
||||
<el-input type="textarea" :rows="6" v-model="publishDialog.form.content" />
|
||||
</el-form-item>
|
||||
<el-form-item label="选择图片" v-if="publishDialog.productImages && publishDialog.productImages.length">
|
||||
<div class="img-grid">
|
||||
<div class="img-item" v-for="(img, idx) in publishDialog.productImages" :key="idx">
|
||||
<img :src="img.url" :alt="`图片${idx+1}`" @click="handlePreviewImage(img.url)" />
|
||||
<div class="img-actions">
|
||||
<el-checkbox v-model="img.selected">使用</el-checkbox>
|
||||
<el-button type="text" size="mini" @click="handleCopyImageUrl(img.url)">复制</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="margin-top:8px;">
|
||||
<el-button size="mini" @click="selectAllImages(true)">全选</el-button>
|
||||
<el-button size="mini" @click="selectAllImages(false)">全不选</el-button>
|
||||
<el-button size="mini" @click="invertSelection">反选</el-button>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="额外图片链接">
|
||||
<el-input type="textarea" :rows="3" v-model="publishDialog.form.extraImagesText" placeholder="每行一条图片URL" />
|
||||
</el-form-item>
|
||||
<el-form-item label="白底图">
|
||||
<el-input v-model="publishDialog.form.whiteImages" placeholder="可选,图片URL" />
|
||||
</el-form-item>
|
||||
<el-form-item label="服务项">
|
||||
<el-select v-model="publishDialog.form.serviceSupport" multiple collapse-tags placeholder="可多选">
|
||||
<el-option v-for="opt in serviceSupportOptions" :key="opt.value" :label="opt.label" :value="opt.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="会员名" prop="userName">
|
||||
<el-select v-model="publishDialog.form.userName" filterable placeholder="选择会员名" :loading="userNameLoading">
|
||||
<el-option v-for="u in userNameOptions" :key="u.value" :label="u.label" :value="u.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="省/市/区" required>
|
||||
<div style="display:flex; gap:8px; width:100%">
|
||||
<el-select v-model.number="publishDialog.form.province" placeholder="选择省" style="flex:1" filterable @change="onProvinceChange">
|
||||
<el-option v-for="p in regionOptions.provinces" :key="p.value" :label="p.label" :value="p.value" />
|
||||
</el-select>
|
||||
<el-select v-model.number="publishDialog.form.city" placeholder="选择市" style="flex:1" filterable :disabled="!publishDialog.form.province" @change="onCityChange">
|
||||
<el-option v-for="c in regionOptions.cities" :key="c.value" :label="c.label" :value="c.value" />
|
||||
</el-select>
|
||||
<el-select v-model.number="publishDialog.form.district" placeholder="选择区" style="flex:1" filterable :disabled="!publishDialog.form.city">
|
||||
<el-option v-for="a in regionOptions.areas" :key="a.value" :label="a.label" :value="a.value" />
|
||||
</el-select>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="价格(元)" prop="price">
|
||||
<el-input v-model.number="publishDialog.form.price" type="number" min="0.01" step="0.01" />
|
||||
</el-form-item>
|
||||
<el-form-item label="原价(元)">
|
||||
<el-input v-model.number="publishDialog.form.originalPrice" type="number" min="0" step="0.01" />
|
||||
</el-form-item>
|
||||
<el-form-item label="运费(元)" prop="expressFee">
|
||||
<el-input v-model.number="publishDialog.form.expressFee" type="number" min="0" step="0.01" />
|
||||
</el-form-item>
|
||||
<el-form-item label="库存" prop="stock">
|
||||
<el-input v-model.number="publishDialog.form.stock" type="number" min="1" />
|
||||
</el-form-item>
|
||||
<el-form-item label="商家编码">
|
||||
<el-input v-model="publishDialog.form.outerId" maxlength="64" />
|
||||
</el-form-item>
|
||||
<el-form-item label="商品类型" prop="itemBizType">
|
||||
<el-select v-model.number="publishDialog.form.itemBizType" filterable @change="onItemBizTypeChange">
|
||||
<el-option v-for="opt in itemBizTypeOptions" :key="opt.value" :label="opt.label" :value="opt.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="行业类型" prop="spBizType">
|
||||
<el-select v-model.number="publishDialog.form.spBizType" filterable @change="onSpBizTypeChange">
|
||||
<el-option v-for="opt in spBizTypeOptions" :key="opt.value" :label="opt.label" :value="opt.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="类目ID" prop="channelCatId">
|
||||
<el-select v-model="publishDialog.form.channelCatId" filterable placeholder="请选择类目" :disabled="!categoryOptions.length" :loading="categoryLoading" @change="loadProperties">
|
||||
<el-option v-for="c in categoryOptions" :key="c.value" :label="c.label" :value="c.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="商品属性">
|
||||
<div v-if="pvOptions.length" style="display:flex; flex-direction:column; gap:8px;">
|
||||
<div v-for="(p, pi) in pvOptions" :key="p.propertyId" style="display:flex; gap:8px; align-items:center;">
|
||||
<span style="width:90px; text-align:right; color:#666;">{{ p.propertyName }}:</span>
|
||||
<el-select v-model="selectedPv[p.propertyId]" clearable filterable placeholder="请选择" style="flex:1" @change="onPvChange">
|
||||
<el-option v-for="v in p.values" :key="v.valueId" :label="v.valueName" :value="v.valueId" />
|
||||
</el-select>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else style="color:#999;">无属性或请选择类型和类目后加载</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="成色">
|
||||
<el-select v-model.number="publishDialog.form.stuffStatus" clearable filterable placeholder="可选">
|
||||
<el-option v-for="opt in stuffStatusOptions" :key="opt.value" :label="opt.label" :value="opt.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="属性JSON">
|
||||
<el-input type="textarea" :rows="3" v-model="publishDialog.form.channelPvJson" placeholder='示例: [{"property_id":"p","property_name":"颜色","value_id":"v","value_name":"红"}]' />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="publishDialog.visible=false">取 消</el-button>
|
||||
<el-button type="primary" :loading="publishDialog.loading" @click="submitPublish">确 认</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
<!-- 公共发品对话框组件 -->
|
||||
<PublishDialog :visible.sync="publishDialogVisible" :initial-data="publishInitialData" @success="handlePublishSuccess" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { generatePromotionContent, createProductByPromotion, getProvinces, getCities, getAreas, getCategories, getUsernames, getERPAccounts, getProperties } from "@/api/system/jdorder";
|
||||
import { generatePromotionContent } from "@/api/system/jdorder";
|
||||
import { addToFavorites } from "@/api/system/favoriteProduct";
|
||||
import PublishDialog from '@/components/PublishDialog.vue'
|
||||
|
||||
export default {
|
||||
name: "Jdorder",
|
||||
components: { PublishDialog },
|
||||
data() {
|
||||
return {
|
||||
form: {
|
||||
@@ -261,46 +148,8 @@ export default {
|
||||
activeProductTab: 0,
|
||||
// 每个商品的文案标签页状态
|
||||
activeWenanTab: {},
|
||||
publishDialog: {
|
||||
visible: false,
|
||||
loading: false,
|
||||
wenanOptions: [],
|
||||
productImages: [],
|
||||
form: {
|
||||
appid: '',
|
||||
userName: "",
|
||||
province: 440000,
|
||||
city: 440400,
|
||||
district: 440402,
|
||||
title: "",
|
||||
content: "",
|
||||
wenanIndex: 0,
|
||||
extraImagesText: "",
|
||||
whiteImages: "",
|
||||
serviceSupport: ['NFR'],
|
||||
price: null,
|
||||
originalPrice: null,
|
||||
expressFee: 0,
|
||||
stock: 999,
|
||||
outerId: "",
|
||||
itemBizType: 2,
|
||||
spBizType: 3,
|
||||
channelCatId: "",
|
||||
stuffStatus: 100,
|
||||
channelPvJson: ""
|
||||
},
|
||||
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: '请输入类目ID', trigger: 'blur' }]
|
||||
}
|
||||
},
|
||||
publishDialogVisible: false,
|
||||
publishInitialData: {},
|
||||
regionOptions: {
|
||||
provinces: [],
|
||||
cities: [],
|
||||
@@ -362,13 +211,7 @@ export default {
|
||||
]
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
// 页面加载即预拉省份与类目下拉,避免弹窗时再等待
|
||||
this.loadProvinces();
|
||||
this.loadERPAccounts();
|
||||
this.loadCategories();
|
||||
this.loadUsernames();
|
||||
},
|
||||
mounted() {},
|
||||
watch: {
|
||||
'publishDialog.form.itemBizType'(val) {
|
||||
// 冗余联动,防止@change未触发的情况
|
||||
@@ -386,6 +229,28 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async handleAddToFavorites(product) {
|
||||
try {
|
||||
const payload = {
|
||||
skuid: product.skuid || product.skuId || product.spuid || '',
|
||||
productName: product.skuName || product.title || '',
|
||||
shopName: product.shopName || '',
|
||||
productUrl: product.url || '',
|
||||
productImage: Array.isArray(product.images) && product.images.length ? product.images[0] : '',
|
||||
price: product.price != null ? String(product.price) : (product.lowestCouponPrice != null ? String(product.lowestCouponPrice) : ''),
|
||||
commissionInfo: product.commission != null ? String(product.commission) : '',
|
||||
remark: '来自一键转链'
|
||||
}
|
||||
const res = await addToFavorites(payload)
|
||||
if (res && (res.code === 200 || res.msg === '操作成功')) {
|
||||
this.$modal.msgSuccess('已加入常用');
|
||||
} else {
|
||||
this.$modal.msgError(res && res.msg ? res.msg : '加入常用失败');
|
||||
}
|
||||
} catch (e) {
|
||||
this.$modal.msgError('加入常用失败');
|
||||
}
|
||||
},
|
||||
handleGenerate() {
|
||||
if (!this.form.inputContent.trim()) {
|
||||
this.$modal.msgError("请输入需要转链的内容");
|
||||
@@ -512,43 +377,17 @@ export default {
|
||||
|
||||
openPublish(product, productIndex) {
|
||||
const wenanIndex = this.activeWenanTab[productIndex] || 0;
|
||||
const wenanContent = product && product.wenan && product.wenan[wenanIndex] ? (product.wenan[wenanIndex].content || '') : '';
|
||||
const images = Array.isArray(product.images) ? product.images : [];
|
||||
const wenanOptions = Array.isArray(product.wenan) ? product.wenan.map((w, i) => ({ label: w.type || `版本${i+1}`, content: w.content || '' })) : [];
|
||||
this.publishDialog.wenanOptions = wenanOptions;
|
||||
this.publishDialog.form = Object.assign({}, this.publishDialog.form, {
|
||||
this.publishInitialData = {
|
||||
title: product.skuName || '',
|
||||
content: wenanContent,
|
||||
wenanIndex: wenanIndex,
|
||||
extraImagesText: '',
|
||||
whiteImages: '',
|
||||
serviceSupport: this.publishDialog.form.serviceSupport,
|
||||
userName: '',
|
||||
province: this.publishDialog.form.province,
|
||||
city: this.publishDialog.form.city,
|
||||
district: this.publishDialog.form.district,
|
||||
price: null,
|
||||
originalPrice: null,
|
||||
expressFee: 0,
|
||||
stock: this.publishDialog.form.stock,
|
||||
outerId: '',
|
||||
itemBizType: this.publishDialog.form.itemBizType,
|
||||
spBizType: this.publishDialog.form.spBizType,
|
||||
channelCatId: '',
|
||||
stuffStatus: this.publishDialog.form.stuffStatus,
|
||||
channelPvJson: ''
|
||||
});
|
||||
// 预填原价(元)
|
||||
const guessed = this.guessYuanPrice(product);
|
||||
if (guessed != null) {
|
||||
this.publishDialog.form.originalPrice = Number(Number(guessed).toFixed(2));
|
||||
}
|
||||
this.publishDialog.productImages = images.map(u => ({ url: u, selected: true }));
|
||||
this.publishDialog.visible = true;
|
||||
this.$nextTick(() => this.$refs.publishForm && this.$refs.publishForm.clearValidate());
|
||||
// 载入省份
|
||||
this.loadProvinces();
|
||||
content: (product && product.wenan && product.wenan[wenanIndex] ? (product.wenan[wenanIndex].content || '') : ''),
|
||||
images: Array.isArray(product.images) ? product.images : [],
|
||||
originalPrice: this.guessYuanPrice(product),
|
||||
wenanOptions
|
||||
};
|
||||
this.publishDialogVisible = true;
|
||||
},
|
||||
handlePublishSuccess() { /* 可按需刷新列表或做其他处理 */ },
|
||||
|
||||
onWenanChange(val) {
|
||||
if (this.publishDialog.wenanOptions && this.publishDialog.wenanOptions[val]) {
|
||||
@@ -563,7 +402,7 @@ export default {
|
||||
(this.publishDialog.productImages || []).forEach(it => { it.selected = !it.selected; });
|
||||
},
|
||||
|
||||
// 从解析到的商品信息中推测原价(元) —— 后端已保证返回“元”,不再做分到元换算
|
||||
// 从解析到的商品信息中推测原价(元)
|
||||
guessYuanPrice(product) {
|
||||
// 常见字段尝试:price、oriPrice、originPrice、jdPrice、marketPrice 等(单位可能为元)
|
||||
const candidates = [
|
||||
@@ -768,7 +607,17 @@ export default {
|
||||
createProductByPromotion(payload).then(res => {
|
||||
this.publishDialog.loading = false;
|
||||
if (res.code === 200) {
|
||||
this.$modal.msgSuccess('发品提交成功');
|
||||
// 成功反馈:包含生成的outerId
|
||||
try {
|
||||
const outerId = res.data && (res.data.outerId || (res.data.data && res.data.data.outerId))
|
||||
if (outerId) {
|
||||
this.$modal.msgSuccess(`发品成功,商家编码:${outerId}`)
|
||||
} else {
|
||||
this.$modal.msgSuccess('发品提交成功')
|
||||
}
|
||||
} catch (e) {
|
||||
this.$modal.msgSuccess('发品提交成功')
|
||||
}
|
||||
this.publishDialog.visible = false;
|
||||
} else {
|
||||
this.$modal.msgError(res.msg || '发品失败');
|
||||
|
||||
Reference in New Issue
Block a user