Compare commits
4 Commits
4da07ddfaa
...
294aa013e4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
294aa013e4 | ||
|
|
2acb439c9d | ||
|
|
9111a150f6 | ||
|
|
cd3c048d7f |
@ -179,8 +179,8 @@
|
|||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<el-button v-if="true || stateCode.ORDER_STATE_WAIT_PAY==row.order_state_id" v-permissions="{ permission: ['/manage/trade/orderBase/edit'] }" size="mini" type="text" @click="handleEdit(row)">{{ t('详情') }}</el-button>
|
<el-button v-if="true || stateCode.ORDER_STATE_WAIT_PAY==row.order_state_id" v-permissions="{ permission: ['/manage/trade/orderBase/edit'] }" size="mini" type="text" @click="handleEdit(row)">{{ t('详情') }}</el-button>
|
||||||
<el-button v-if="stateCode.ORDER_STATE_WAIT_PAY==row.order_state_id" v-permissions="{ permission: ['/manage/trade/orderBase/remove'] }" size="small" type="text" @click.stop="handleCancel(row.order_id)">{{ t('取消') }}</el-button>
|
<el-button v-if="stateCode.ORDER_STATE_WAIT_PAY==row.order_state_id" v-permissions="{ permission: ['/manage/trade/orderBase/remove'] }" size="small" type="text" @click.stop="handleCancel(row.order_id)">{{ t('取消') }}</el-button>
|
||||||
|
<!--店铺付款这款有问题,不符合 暂时停用-->
|
||||||
<el-button v-if="stateCode.ORDER_STATE_WAIT_PAY==row.order_state_id" v-permissions="{ permission: ['/manage/trade/orderBase/finance'] }" size="mini" type="text" @click="handlePaid(row)">{{ t('付款') }}</el-button>
|
<!-- <el-button v-if="stateCode.ORDER_STATE_WAIT_PAY==row.order_state_id" v-permissions="{ permission: ['/manage/trade/orderBase/finance'] }" size="mini" type="text" @click="handlePaid(row)">{{ t('付款') }}</el-button> -->
|
||||||
|
|
||||||
<el-button v-if="ifReview && stateCode.ORDER_STATE_WAIT_REVIEW==row.order_state_id" v-permissions="{ permission: ['/manage/trade/orderBase/review'] }" size="mini" type="text" @click="handleReview(row.order_id)">{{ t('订单审核') }}</el-button>
|
<el-button v-if="ifReview && stateCode.ORDER_STATE_WAIT_REVIEW==row.order_state_id" v-permissions="{ permission: ['/manage/trade/orderBase/review'] }" size="mini" type="text" @click="handleReview(row.order_id)">{{ t('订单审核') }}</el-button>
|
||||||
<el-button v-if="ifFinanceReview && stateCode.ORDER_STATE_WAIT_FINANCE_REVIEW==row.order_state_id" v-permissions="{ permission: ['/manage/trade/orderBase/finance'] }" size="mini" type="text" @click="handleFinanceReview(row.order_id)">{{ t('财务审核') }}</el-button>
|
<el-button v-if="ifFinanceReview && stateCode.ORDER_STATE_WAIT_FINANCE_REVIEW==row.order_state_id" v-permissions="{ permission: ['/manage/trade/orderBase/finance'] }" size="mini" type="text" @click="handleFinanceReview(row.order_id)">{{ t('财务审核') }}</el-button>
|
||||||
|
|||||||
@ -6,81 +6,79 @@
|
|||||||
:close-on-click-modal="false"
|
:close-on-click-modal="false"
|
||||||
@close="handleClose"
|
@close="handleClose"
|
||||||
>
|
>
|
||||||
<div class="edit-tip">
|
<div class="edit-tip">
|
||||||
正在编辑商品: <strong>{{ formData.name }}</strong>
|
正在编辑商品: <strong>{{ formData.name }}</strong>
|
||||||
(条码: {{ formData.barcode || '无条码' }})
|
(条码: {{ formData.barcode || '无条码' }})
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<el-form ref="editForm" :model="formData" label-width="100px" label-position="right">
|
<el-form ref="editForm" :model="formData" label-width="100px" label-position="right">
|
||||||
<!-- 主图编辑 -->
|
<!-- 主图编辑 -->
|
||||||
<!-- <el-form-item label="当前主图">
|
|
||||||
<el-image
|
|
||||||
v-if="formData.thumb"
|
|
||||||
:src="formData.thumb"
|
|
||||||
style="width: 100px; height: 100px; object-fit: cover; border: 1px solid #eee;"
|
|
||||||
:preview-src-list="[formData.thumb, ...getSubImages(formData.product_image_list)]"
|
|
||||||
/>
|
|
||||||
<span v-else class="text-gray-500">暂无主图</span>
|
|
||||||
</el-form-item> -->
|
|
||||||
|
|
||||||
<el-form-item
|
<el-form-item
|
||||||
label="上传新主图"
|
label="商品主图"
|
||||||
prop="newThumb"
|
prop="newThumb"
|
||||||
:rules="[
|
:rules="[
|
||||||
{ required: true, message: '请上传新的商品主图', trigger: 'change' }
|
{ required: true, message: '请上传商品主图', trigger: 'change' }
|
||||||
]"
|
]"
|
||||||
>
|
>
|
||||||
<upload
|
<upload
|
||||||
height="100px"
|
height="100px"
|
||||||
:image="formData.newThumb"
|
:image="formData.newThumb"
|
||||||
width="100px"
|
width="100px"
|
||||||
@upImage="handleMainImageUpload"
|
@upImage="handleMainImageUpload"
|
||||||
/>
|
/>
|
||||||
<div class="el-form-item__error" style="padding-top: 10px;">
|
<div class="el-form-item__error" style="padding-top: 10px;">
|
||||||
<span>支持 JPG, PNG 格式,建议尺寸 800x800px</span>
|
<span>支持 JPG, PNG 格式,建议尺寸 800x800px</span>
|
||||||
</div>
|
</div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<!-- 副图编辑 -->
|
<el-form-item label="商品副图">
|
||||||
<!-- <el-form-item label="商品副图">
|
|
||||||
<div class="sub-images-container">
|
<div class="sub-images-container">
|
||||||
<div v-for="(item, index) in formData.product_image_list" :key="item.id || index" class="sub-image-item">
|
<!-- 副图列表 -->
|
||||||
<upload
|
<div v-for="(item, index) in formData.product_image_list" :key="item.id || `sub_${index}`" class="sub-image-item">
|
||||||
v-if="item.uploadNew"
|
<el-image
|
||||||
height="80px"
|
:src="item.imageUrl"
|
||||||
:image="item.newImageUrl || item.imageUrl"
|
style="width: 80px; height: 80px; object-fit: cover; border: 1px solid #eee;"
|
||||||
width="80px"
|
:preview-src-list="[formData.thumb, ...getSubImages(formData.product_image_list)]"
|
||||||
@upImage="(url) => handleSubImageUpload(url, index)"
|
:preview-index="index + 1"
|
||||||
/>
|
/>
|
||||||
<el-image
|
<div class="sub-img-actions">
|
||||||
v-else
|
<el-button
|
||||||
:src="item.imageUrl"
|
size="mini"
|
||||||
style="width: 80px; height: 80px; object-fit: cover; border: 1px solid #eee;"
|
type="text"
|
||||||
:preview-src-list="[formData.thumb, ...getSubImages(formData.product_image_list)]"
|
icon="el-icon-edit"
|
||||||
:preview-index="index + 1"
|
@click="handleEditSubImage(index)"
|
||||||
/>
|
title="更换图片"
|
||||||
<div class="sub-img-actions">
|
/>
|
||||||
<el-button
|
</div>
|
||||||
size="mini"
|
<!-- 现有副图的隐藏上传组件 -->
|
||||||
type="text"
|
<upload
|
||||||
icon="el-icon-edit"
|
ref="subImageUploadRefs"
|
||||||
@click="toggleEditSubImage(index)"
|
class="sub-image-uploader"
|
||||||
/>
|
height="80px"
|
||||||
<el-button
|
width="80px"
|
||||||
size="mini"
|
:image="item.imageUrl"
|
||||||
type="text"
|
@upImage="(url) => handleSubImageUpload(url, index)"
|
||||||
icon="el-icon-delete"
|
/>
|
||||||
@click="deleteSubImage(index)"
|
</div>
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="add-sub-image" @click="addSubImage">
|
<!-- 新增副图按钮-->
|
||||||
|
<div class="add-sub-image" @click="handleAddSubImage">
|
||||||
<i class="el-icon-plus" />
|
<i class="el-icon-plus" />
|
||||||
<span>添加副图</span>
|
<span>添加副图</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- 新增副图专用的隐藏上传组件 -->
|
||||||
|
<upload
|
||||||
|
ref="newSubImageUpload"
|
||||||
|
class="sub-image-uploader"
|
||||||
|
height="80px"
|
||||||
|
width="80px"
|
||||||
|
:image="''"
|
||||||
|
@upImage="handleNewSubImageUpload"
|
||||||
|
v-show="false"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</el-form-item> -->
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
|
||||||
<template #footer>
|
<template #footer>
|
||||||
@ -106,13 +104,14 @@ export default {
|
|||||||
formData: {
|
formData: {
|
||||||
id: '',
|
id: '',
|
||||||
name: '',
|
name: '',
|
||||||
barcode: '', // 条码
|
barcode: '',
|
||||||
thumb: '',
|
thumb: '',
|
||||||
newThumb: '',
|
newThumb: '',
|
||||||
product_image_list: [],
|
product_image_list: [],
|
||||||
original_product_image_list: [], // 保存原始副图数据
|
original_product_image_list: [],
|
||||||
original_thumb: '' // 保存原始主图数据
|
original_thumb: ''
|
||||||
},
|
},
|
||||||
|
currentEditingSubImageIndex: -1 // 记录当前编辑的现有副图索引
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@ -120,41 +119,41 @@ export default {
|
|||||||
getSubImages(imageList) {
|
getSubImages(imageList) {
|
||||||
return (imageList || []).map(item => item.imageUrl).filter(url => url);
|
return (imageList || []).map(item => item.imageUrl).filter(url => url);
|
||||||
},
|
},
|
||||||
// 子组件open方法
|
|
||||||
open(row) {
|
|
||||||
if (!row || !row.id) {
|
|
||||||
this.$message.error('无效的商品数据');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 保存原始数据
|
|
||||||
const originalProductImages = JSON.parse(JSON.stringify(row.product_image_list || []));
|
|
||||||
const originalThumb = row.thumb || '';
|
|
||||||
|
|
||||||
// 初始化表单数据(添加barcode)
|
|
||||||
this.formData = {
|
|
||||||
id: row.id,
|
|
||||||
name: row.name || '未知名称',
|
|
||||||
barcode: row.barcode || '', // 新增条码字段
|
|
||||||
thumb: originalThumb,
|
|
||||||
newThumb: originalThumb,
|
|
||||||
original_thumb: originalThumb,
|
|
||||||
product_image_list: originalProductImages.map(item => ({
|
|
||||||
...item,
|
|
||||||
uploadNew: false,
|
|
||||||
newImageUrl: ''
|
|
||||||
})),
|
|
||||||
original_product_image_list: originalProductImages
|
|
||||||
};
|
|
||||||
|
|
||||||
this.visible = true;
|
|
||||||
this.$nextTick(() => {
|
|
||||||
this.$refs.editForm?.clearValidate();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
|
// 打开编辑弹窗
|
||||||
|
open(row) {
|
||||||
|
if (!row || !row.id) {
|
||||||
|
this.$message.error('无效的商品数据');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const originalProductImages = JSON.parse(JSON.stringify(row.product_image_list || []));
|
||||||
|
const originalThumb = row.thumb || '';
|
||||||
|
|
||||||
|
this.formData = {
|
||||||
|
id: row.id,
|
||||||
|
name: row.name || '未知名称',
|
||||||
|
barcode: row.barcode || '',
|
||||||
|
thumb: originalThumb,
|
||||||
|
newThumb: originalThumb,
|
||||||
|
original_thumb: originalThumb,
|
||||||
|
product_image_list: originalProductImages.map(item => {
|
||||||
|
const { id, productId, imageUrl, seq, status, createdAt, updatedAt } = item;
|
||||||
|
return { id, productId, imageUrl, seq, status, createdAt, updatedAt };
|
||||||
|
}),
|
||||||
|
original_product_image_list: originalProductImages
|
||||||
|
};
|
||||||
|
|
||||||
|
this.visible = true;
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.$refs.editForm?.clearValidate();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
// 关闭弹窗重置数据
|
||||||
handleClose() {
|
handleClose() {
|
||||||
this.visible = false;
|
this.visible = false;
|
||||||
|
this.currentEditingSubImageIndex = -1;
|
||||||
this.formData = {
|
this.formData = {
|
||||||
id: '',
|
id: '',
|
||||||
name: '',
|
name: '',
|
||||||
@ -172,80 +171,97 @@ export default {
|
|||||||
this.formData.newThumb = imageUrl;
|
this.formData.newThumb = imageUrl;
|
||||||
},
|
},
|
||||||
|
|
||||||
//副图上传
|
// 编辑现有副图 - 触发对应上传组件
|
||||||
handleSubImageUpload(imageUrl, index) {
|
handleEditSubImage(index) {
|
||||||
if (this.formData.product_image_list[index]) {
|
this.currentEditingSubImageIndex = index;
|
||||||
const item = this.formData.product_image_list[index];
|
this.$nextTick(() => {
|
||||||
item.newImageUrl = imageUrl;
|
const uploadRefs = this.$refs.subImageUploadRefs;
|
||||||
item.imageUrl = imageUrl; // 更新最终显示URL
|
const uploadComp = Array.isArray(uploadRefs) ? uploadRefs[index] : uploadRefs;
|
||||||
item.uploadNew = false; // 退出编辑状态
|
this.triggerUploadComp(uploadComp);
|
||||||
item.tmpUrl = ''; // 清空临时URL
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// 切换编辑副图状态
|
|
||||||
toggleEditSubImage(idx) {
|
|
||||||
const item = this.formData.product_image_list[idx];
|
|
||||||
if (item.uploadNew) {
|
|
||||||
// 取消编辑:恢复原始URL
|
|
||||||
if (item.tmpUrl) {
|
|
||||||
item.imageUrl = item.tmpUrl;
|
|
||||||
item.tmpUrl = ''; // 清空临时URL
|
|
||||||
}
|
|
||||||
item.newImageUrl = '';
|
|
||||||
} else {
|
|
||||||
// 进入编辑:保存当前URL到临时变量
|
|
||||||
item.tmpUrl = item.imageUrl;
|
|
||||||
}
|
|
||||||
item.uploadNew = !item.uploadNew;
|
|
||||||
},
|
|
||||||
|
|
||||||
// 删除副图
|
|
||||||
deleteSubImage(index) {
|
|
||||||
this.formData.product_image_list.splice(index, 1);
|
|
||||||
},
|
|
||||||
|
|
||||||
addSubImage() {
|
|
||||||
const max = this.formData.product_image_list.reduce((p, c) => Math.max(p, c.seq || 0), 0);
|
|
||||||
this.formData.product_image_list.push({
|
|
||||||
id: null,
|
|
||||||
productId: this.formData.id,
|
|
||||||
imageUrl: '',
|
|
||||||
newImageUrl: '',
|
|
||||||
uploadNew: true, // 默认进入编辑状态
|
|
||||||
tmpUrl: '', // 初始化临时URL
|
|
||||||
isMain: false,
|
|
||||||
seq: max + 1,
|
|
||||||
status: 1
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// 点击"添加副图" - 触发新增专用上传组件
|
||||||
|
handleAddSubImage() {
|
||||||
|
this.$nextTick(() => {
|
||||||
|
const uploadComp = this.$refs.newSubImageUpload;
|
||||||
|
this.triggerUploadComp(uploadComp);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
// 通用触发上传组件的方法(兼容不同upload组件实现)
|
||||||
|
triggerUploadComp(uploadComp) {
|
||||||
|
if (!uploadComp) return;
|
||||||
|
|
||||||
|
// 优先调用组件暴露的open方法(如果有)
|
||||||
|
if (typeof uploadComp.open === 'function') {
|
||||||
|
uploadComp.open();
|
||||||
|
}
|
||||||
|
// 兼容通过input触发
|
||||||
|
else if (uploadComp.$el) {
|
||||||
|
const fileInput = uploadComp.$el.querySelector('input[type="file"]');
|
||||||
|
if (fileInput) {
|
||||||
|
fileInput.click();
|
||||||
|
} else {
|
||||||
|
this.$message.warning('上传组件初始化中,请稍候');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// 现有副图上传完成 - 只替换URL,保留ID等信息
|
||||||
|
handleSubImageUpload(imageUrl, index) {
|
||||||
|
if (this.formData.product_image_list[index]) {
|
||||||
|
this.formData.product_image_list[index].imageUrl = imageUrl;
|
||||||
|
this.$message.success('副图更新成功');
|
||||||
|
this.currentEditingSubImageIndex = -1;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// 新增副图上传完成 - 上传成功后才创建副图条目
|
||||||
|
handleNewSubImageUpload(imageUrl) {
|
||||||
|
if (!imageUrl) {
|
||||||
|
this.$message.warning('请选择有效的图片');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 计算新的排序值
|
||||||
|
const maxSeq = this.formData.product_image_list.reduce((p, c) => Math.max(p, c.seq || 0), 0);
|
||||||
|
|
||||||
|
// 创建新的副图条目(ID为null,由后端生成)
|
||||||
|
this.formData.product_image_list.push({
|
||||||
|
id: null,
|
||||||
|
productId: this.formData.id,
|
||||||
|
imageUrl: imageUrl, // 直接用上传后的URL
|
||||||
|
seq: maxSeq + 1,
|
||||||
|
status: 1,
|
||||||
|
createdAt: new Date().toISOString(),
|
||||||
|
updatedAt: new Date().toISOString()
|
||||||
|
});
|
||||||
|
|
||||||
|
this.$message.success('新增副图成功');
|
||||||
|
},
|
||||||
|
|
||||||
|
// 提交保存
|
||||||
async handleSubmit() {
|
async handleSubmit() {
|
||||||
try {
|
try {
|
||||||
await this.$refs.editForm.validate();
|
await this.$refs.editForm.validate();
|
||||||
|
|
||||||
// 准备提交数据 - 保持不变的字段使用原始数据
|
|
||||||
const submitData = [
|
const submitData = [
|
||||||
{
|
{
|
||||||
id: this.formData.id,
|
id: this.formData.id,
|
||||||
name: this.formData.name,
|
name: this.formData.name,
|
||||||
// 主图:使用新上传的或原始的
|
barcode: this.formData.barcode,
|
||||||
thumb: this.formData.newThumb || this.formData.original_thumb,
|
thumb: this.formData.newThumb || this.formData.original_thumb,
|
||||||
// 副图:如果没有修改则使用原始数据,否则使用修改后的数据
|
product_image_list: this.formData.product_image_list
|
||||||
product_image_list: this.hasSubImagesChanged()
|
.filter(item => item.imageUrl)
|
||||||
? this.formData.product_image_list.filter(item => item.imageUrl).map((item, index) => ({
|
.map((item, index) => ({
|
||||||
id: item.id,
|
...item,
|
||||||
productId: this.formData.id,
|
seq: index + 1 // 重新排序
|
||||||
imageUrl: item.imageUrl,
|
}))
|
||||||
isMain: false,
|
|
||||||
seq: index + 1,
|
|
||||||
status: 1
|
|
||||||
}))
|
|
||||||
: this.formData.original_product_image_list
|
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
console.log('提交更新商品图片请求:', submitData);
|
console.log('提交数据:', submitData);
|
||||||
const response = await saveBatchBarcode(submitData);
|
const response = await saveBatchBarcode(submitData);
|
||||||
|
|
||||||
if (response.status === 200) {
|
if (response.status === 200) {
|
||||||
@ -256,30 +272,25 @@ export default {
|
|||||||
this.$message.error('修改失败: ' + (response.msg || '未知错误'));
|
this.$message.error('修改失败: ' + (response.msg || '未知错误'));
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('提交修改失败:', error);
|
console.error('提交失败:', error);
|
||||||
if (error.name !== 'ValidateError') {
|
if (error.name !== 'ValidateError') {
|
||||||
this.$message.error('修改失败,请稍后重试');
|
this.$message.error('修改失败,请稍后重试');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// 判断副图是否有修改
|
// 判断副图是否修改
|
||||||
hasSubImagesChanged() {
|
hasSubImagesChanged() {
|
||||||
// 如果副图数量不同,说明有修改
|
|
||||||
if (this.formData.product_image_list.length !== this.formData.original_product_image_list.length) {
|
if (this.formData.product_image_list.length !== this.formData.original_product_image_list.length) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查每张图片是否有修改
|
|
||||||
for (let i = 0; i < this.formData.product_image_list.length; i++) {
|
for (let i = 0; i < this.formData.product_image_list.length; i++) {
|
||||||
const newItem = this.formData.product_image_list[i];
|
const newItem = this.formData.product_image_list[i];
|
||||||
const originalItem = this.formData.original_product_image_list[i];
|
const originalItem = this.formData.original_product_image_list[i];
|
||||||
|
|
||||||
if (!originalItem || newItem.imageUrl !== originalItem.imageUrl) {
|
if (!originalItem || newItem.imageUrl !== originalItem.imageUrl) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -311,20 +322,17 @@ export default {
|
|||||||
.sub-img-actions {
|
.sub-img-actions {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 5px;
|
gap: 5px;
|
||||||
|
|
||||||
.el-button {
|
.el-button {
|
||||||
color: #666;
|
color: #666;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
&:hover { color: #409eff; }
|
||||||
&:hover {
|
|
||||||
color: #409eff;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.el-button:nth-child(2):hover {
|
|
||||||
color: #f56c6c;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 隐藏所有上传组件,只通过按钮触发
|
||||||
|
.sub-image-uploader {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.add-sub-image {
|
.add-sub-image {
|
||||||
|
|||||||
@ -1735,7 +1735,7 @@ export default {
|
|||||||
// this.creatCircle(obj)
|
// this.creatCircle(obj)
|
||||||
},
|
},
|
||||||
async delectRadiusItem(index, item) {
|
async delectRadiusItem(index, item) {
|
||||||
let res = await delectArea({ transport_id: item.transport_id })
|
let res = await delectArea({ transport_id: item.transport_id,store_id:this.store_id })
|
||||||
if (res && res.status == 200) {
|
if (res && res.status == 200) {
|
||||||
this.$baseMessage('删除成功', 'success')
|
this.$baseMessage('删除成功', 'success')
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
width="50%"
|
width="50%"
|
||||||
@close="close"
|
@close="close"
|
||||||
>
|
>
|
||||||
<el-form ref="form" label-width="120px" :model="form" :rules="rules">
|
<el-form ref="form" label-width="150px" :model="form" :rules="rules">
|
||||||
<el-form-item :label="__('活动名称')" prop="activity_title">
|
<el-form-item :label="__('活动名称')" prop="activity_title">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="form.activity_title"
|
v-model="form.activity_title"
|
||||||
@ -45,7 +45,7 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
<el-form-item :label="__('砍价商品')" prop="product_item_name">
|
<el-form-item :label="__('砍价商品')" prop="product_item_name">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="form.product_item_name"
|
v-model="form.product_item_name"
|
||||||
clearable
|
clearable
|
||||||
@ -80,9 +80,9 @@
|
|||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item :label="__('砍价方式')" prop="cut_down_type">
|
<el-form-item :label="__('砍价方式')" prop="cut_down_type">
|
||||||
<el-radio v-model="form.cut_down_type" :label="1">
|
<!-- <el-radio v-model="form.cut_down_type" :label="1">
|
||||||
{{ __('固定价格') }}
|
{{ __('固定价格') }}
|
||||||
</el-radio>
|
</el-radio> -->
|
||||||
<el-radio v-model="form.cut_down_type" :label="2">
|
<el-radio v-model="form.cut_down_type" :label="2">
|
||||||
{{ __('价格范围') }}
|
{{ __('价格范围') }}
|
||||||
</el-radio>
|
</el-radio>
|
||||||
@ -109,10 +109,106 @@
|
|||||||
v-model="form.cut_down_user_num"
|
v-model="form.cut_down_user_num"
|
||||||
:label="__('砍价人数')"
|
:label="__('砍价人数')"
|
||||||
:max="10000000"
|
:max="10000000"
|
||||||
:min="0"
|
:min="2"
|
||||||
/>
|
/>
|
||||||
|
<el-tooltip
|
||||||
|
content="砍价成功的人数,例如设置为3人,一共要3个人砍价才能达到底价下单(默认最少为2)"
|
||||||
|
placement="top"
|
||||||
|
effect="dark"
|
||||||
|
style="margin-left: 8px;"
|
||||||
|
>
|
||||||
|
<i class="el-icon-question" style="cursor: pointer; color: #909399; font-size: 14px;"></i>
|
||||||
|
</el-tooltip>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item
|
||||||
|
v-if="form.cut_down_type === 2"
|
||||||
|
:label="__('助力好友砍价次数')"
|
||||||
|
prop="user_cutprice_num"
|
||||||
|
>
|
||||||
|
<div style="display: flex; align-items: center;">
|
||||||
|
<el-input-number
|
||||||
|
v-model="form.user_cutprice_num"
|
||||||
|
:label="__('助力好友砍价次数')"
|
||||||
|
:max="10000000"
|
||||||
|
:min="5"
|
||||||
|
style="width: 200px;"
|
||||||
|
/>
|
||||||
|
<el-tooltip
|
||||||
|
content="在活动期间每个人一共可以助力好友的人数(默认最少为5)"
|
||||||
|
placement="top"
|
||||||
|
effect="dark"
|
||||||
|
style="margin-left: 8px;"
|
||||||
|
>
|
||||||
|
<i class="el-icon-question" style="cursor: pointer; color: #909399; font-size: 14px;"></i>
|
||||||
|
</el-tooltip>
|
||||||
|
</div>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item :label="__('砍价第一刀')" prop="cut_first_type">
|
||||||
|
<el-radio-group v-model="form.cut_first_type">
|
||||||
|
<el-radio :label="1" >
|
||||||
|
<span>{{ __('首刀比例') }}</span>
|
||||||
|
<el-tooltip
|
||||||
|
content="例如首刀比例为30%,100块钱的商品,第一刀砍30块"
|
||||||
|
placement="top"
|
||||||
|
effect="dark"
|
||||||
|
>
|
||||||
|
<i class="el-icon-question" style="margin-left: 5px; cursor: pointer;"></i>
|
||||||
|
</el-tooltip>
|
||||||
|
</el-radio>
|
||||||
|
|
||||||
|
<el-radio :label="2" style="margin-left: 20px;">
|
||||||
|
<span>{{ __('首刀金额') }}</span>
|
||||||
|
<el-tooltip
|
||||||
|
content="例如首刀金额为20,50块钱的商品,第一刀砍20块"
|
||||||
|
placement="top"
|
||||||
|
effect="dark"
|
||||||
|
>
|
||||||
|
<i class="el-icon-question" style="margin-left: 5px; cursor: pointer;"></i>
|
||||||
|
</el-tooltip>
|
||||||
|
</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label="首刀比例(单位-%)" size="normal" v-if='form.cut_first_type == 1'>
|
||||||
|
<el-input v-model="form.cut_first_percent" placeholder="请输入首刀比例" clearable />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="首刀金额(单位/块)" size="normal" v-if='form.cut_first_type == 2'>
|
||||||
|
<el-input v-model="form.cut_first_price " placeholder="请输入首刀金额" clearable />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
|
||||||
|
|
||||||
|
<el-form ref="touzi" label-width="250px" :model="touzi" :rules="touziRules">
|
||||||
|
<!-- 总标签 + 问号提示 -->
|
||||||
|
<el-form-item label="砍价后投骰子的点数(单位-%)" class="total-label-item">
|
||||||
|
<el-tooltip
|
||||||
|
content="设置骰子不同点数对应的中奖比例,6个点数比例总和不能超过100%"
|
||||||
|
placement="top"
|
||||||
|
effect="dark"
|
||||||
|
style="margin-left: 8px;"
|
||||||
|
>
|
||||||
|
<i class="el-icon-question" style="cursor: pointer; color: #909399; font-size: 14px;"></i>
|
||||||
|
</el-tooltip>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-row :gutter="20">
|
||||||
|
<el-col :span="12" v-for="(item,index) in touzi.luckyList" :key="index">
|
||||||
|
<div class="grid-content bg-purple">
|
||||||
|
<el-form-item :label="`点数${item.doubleValue}`" prop="luckyList" :error="touziErrorMsg">
|
||||||
|
<el-input
|
||||||
|
v-model="item.probability"
|
||||||
|
placeholder="请输入比例"
|
||||||
|
type="number"
|
||||||
|
clearable
|
||||||
|
@blur="checkProbabilityTotal(null, null, ()=>{})"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</div>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</el-form>
|
||||||
|
|
||||||
<div slot="footer" class="dialog-footer">
|
<div slot="footer" class="dialog-footer">
|
||||||
<el-button @click="close">{{ __('取消') }}</el-button>
|
<el-button @click="close">{{ __('取消') }}</el-button>
|
||||||
<el-button type="primary" @click="save">{{ __('确定') }}</el-button>
|
<el-button type="primary" @click="save">{{ __('确定') }}</el-button>
|
||||||
@ -135,20 +231,42 @@
|
|||||||
form: {
|
form: {
|
||||||
product_item_name: '',
|
product_item_name: '',
|
||||||
item_id: '',
|
item_id: '',
|
||||||
cut_down_type: 1,
|
cut_down_type: 2,
|
||||||
cut_down_user_num: 0,
|
cut_down_user_num: 0,
|
||||||
cut_down_fixed_price: '',
|
cut_down_fixed_price: '',
|
||||||
activity_type_id: 1124,
|
activity_type_id: 1124,
|
||||||
activity_starttime: '',
|
activity_starttime: '',
|
||||||
activity_endtime: '',
|
activity_endtime: '',
|
||||||
cut_hour:'',
|
cut_hour:'',
|
||||||
product_count:''
|
diceObj:'',
|
||||||
|
cut_first_type:1,
|
||||||
|
product_count:'',
|
||||||
|
user_cutprice_num:'',
|
||||||
|
cut_first_percent:'',
|
||||||
|
cut_first_price:'',
|
||||||
|
},
|
||||||
|
touzi:{
|
||||||
|
luckyList:[
|
||||||
|
{doubleValue:'1',probability:'45'},
|
||||||
|
{doubleValue:'2',probability:'45'},
|
||||||
|
{doubleValue:'3',probability:'2'},
|
||||||
|
{doubleValue:'4',probability:'3'},
|
||||||
|
{doubleValue:'5',probability:'2'},
|
||||||
|
{doubleValue:"6",probability:'3'},
|
||||||
|
],
|
||||||
|
lottery_num:1
|
||||||
|
},
|
||||||
|
touziErrorMsg: '', // 骰子比例总和错误提示
|
||||||
|
touziRules: {
|
||||||
|
probabilityList: [
|
||||||
|
{
|
||||||
|
validator: this.checkProbabilityTotal,
|
||||||
|
trigger: ['blur', 'submit']
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
title: '',
|
title: '',
|
||||||
dialogFormVisible: false,
|
dialogFormVisible: false,
|
||||||
mounted() {
|
|
||||||
this.$forceUpdate()
|
|
||||||
},
|
|
||||||
rules: {
|
rules: {
|
||||||
activity_title: [
|
activity_title: [
|
||||||
{ required: true, trigger: 'blur', message: this.__('活动标题') },
|
{ required: true, trigger: 'blur', message: this.__('活动标题') },
|
||||||
@ -200,6 +318,9 @@
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
mounted() {
|
||||||
|
this.$forceUpdate()
|
||||||
|
},
|
||||||
computed: {
|
computed: {
|
||||||
isReadOnly() {
|
isReadOnly() {
|
||||||
return this.form.activity_id !== undefined
|
return this.form.activity_id !== undefined
|
||||||
@ -239,22 +360,41 @@
|
|||||||
cut_down_type: row.activity_rule.cut_down_type,
|
cut_down_type: row.activity_rule.cut_down_type,
|
||||||
cut_down_user_num: row.activity_rule.cut_down_user_num,
|
cut_down_user_num: row.activity_rule.cut_down_user_num,
|
||||||
cut_hour:row.cut_hour,
|
cut_hour:row.cut_hour,
|
||||||
product_count:row.product_count
|
product_count:row.product_count,
|
||||||
|
user_cutprice_num:row.activity_rule.user_cutprice_num,
|
||||||
|
cut_first_type:row.activity_rule.cut_first_type,//空初始化
|
||||||
|
cut_first_percent:row.activity_rule.cut_first_percent,
|
||||||
|
cut_first_price:row.activity_rule.cut_first_price,
|
||||||
}
|
}
|
||||||
|
let lucky_turn=row.lucky_turn
|
||||||
|
this.tranformData(lucky_turn)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.dialogFormVisible = true
|
this.dialogFormVisible = true
|
||||||
},
|
},
|
||||||
|
tranformData(lucky_turn){
|
||||||
|
if(this.form.cut_first_percent){
|
||||||
|
this.form.cut_first_type=1
|
||||||
|
}else if(this.form.cut_first_price){
|
||||||
|
this.form.cut_first_type=2
|
||||||
|
}
|
||||||
|
this.touzi=JSON.parse(lucky_turn)
|
||||||
|
},
|
||||||
close() {
|
close() {
|
||||||
this.form = {
|
this.form = {
|
||||||
product_item_name: '',
|
product_item_name: '',
|
||||||
item_id: '',
|
item_id: '',
|
||||||
cut_down_type: 1,
|
cut_down_type: 2,
|
||||||
cut_down_fixed_price: '',
|
cut_down_fixed_price: '',
|
||||||
|
user_cutprice_num:5,
|
||||||
activity_type_id: 1124,
|
activity_type_id: 1124,
|
||||||
activity_starttime: '',
|
activity_starttime: '',
|
||||||
cut_down_user_num: '',
|
cut_down_user_num: '',
|
||||||
activity_endtime: '',
|
activity_endtime: '',
|
||||||
|
cut_first_type:1,
|
||||||
|
product_count:'',
|
||||||
|
cut_first_percent:'',
|
||||||
|
cut_first_price:'',
|
||||||
}
|
}
|
||||||
this.$refs['form'].resetFields()
|
this.$refs['form'].resetFields()
|
||||||
this.dialogFormVisible = false
|
this.dialogFormVisible = false
|
||||||
@ -262,7 +402,38 @@
|
|||||||
showItemTable() {
|
showItemTable() {
|
||||||
this.$refs['productItemTable'].showTable()
|
this.$refs['productItemTable'].showTable()
|
||||||
},
|
},
|
||||||
save() {
|
diceObjToStr(){
|
||||||
|
this.form.diceObj = JSON.stringify(this.touzi);
|
||||||
|
},
|
||||||
|
checkProbabilityTotal(rule, value, callback) {
|
||||||
|
// 计算所有输入框的数值总和
|
||||||
|
const total = this.touzi.luckyList.reduce((sum, item) => {
|
||||||
|
// 处理空值/非数字:空值按0算
|
||||||
|
const num = Number(item.probability) || 0
|
||||||
|
return sum + num
|
||||||
|
}, 0)
|
||||||
|
|
||||||
|
// 校验逻辑
|
||||||
|
if (total > 100) {
|
||||||
|
this.touziErrorMsg = '6个点数比例总和不能超过100%'
|
||||||
|
callback(new Error('6个点数比例总和不能超过100%'))
|
||||||
|
} else if (total === 0) {
|
||||||
|
this.touziErrorMsg = '请至少输入一个点数比例'
|
||||||
|
callback(new Error('请至少输入一个点数比例'))
|
||||||
|
} else {
|
||||||
|
this.touziErrorMsg = '' // 清空错误提示
|
||||||
|
callback() // 校验通过
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async save() {
|
||||||
|
let touziValid = true
|
||||||
|
try {
|
||||||
|
await this.$refs['touzi'].validate()
|
||||||
|
} catch (err) {
|
||||||
|
touziValid = false
|
||||||
|
}
|
||||||
|
if (!touziValid) return
|
||||||
|
this.diceObjToStr()
|
||||||
this.$refs['form'].validate(async (valid) => {
|
this.$refs['form'].validate(async (valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
if (this.form.activity_id && this.form.activity_id != undefined) {
|
if (this.form.activity_id && this.form.activity_id != undefined) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user