|
|
@@ -174,7 +174,7 @@
|
|
|
<div class="form-item-tip">A10产品名称由系统自动拼接:品牌名 + 规格型号 + 产品分类(三级分类)+ 发票规格,无需手动填写</div>
|
|
|
</el-form-item>
|
|
|
|
|
|
- <!-- 商品描述 -->
|
|
|
+ <!-- 商品描述 -->
|
|
|
<el-form-item label="商品描述:">
|
|
|
<el-input
|
|
|
v-model="productForm.productDescription"
|
|
|
@@ -233,7 +233,7 @@
|
|
|
</el-col>
|
|
|
|
|
|
<el-col :span="12">
|
|
|
- <el-form-item label="单位:">
|
|
|
+ <el-form-item label="单位:" disabled>
|
|
|
<el-select
|
|
|
v-model="productForm.unitId"
|
|
|
placeholder="请选择"
|
|
|
@@ -313,7 +313,7 @@
|
|
|
<el-input v-model="productForm.promotionTitle" type="textarea" :rows="3" placeholder="请输入促销标题" maxlength="300" show-word-limit />
|
|
|
</el-form-item>
|
|
|
|
|
|
- <!-- 商品说明 -->
|
|
|
+ <!-- 商品说明 -->
|
|
|
<el-form-item label="商品说明:">
|
|
|
<el-input
|
|
|
v-model="productForm.productExplain"
|
|
|
@@ -597,13 +597,13 @@
|
|
|
<el-form ref="detailFormRef" :model="productForm" label-width="120px" class="product-info-form">
|
|
|
<!-- 商品主图 -->
|
|
|
<el-form-item label="商品主图:" required>
|
|
|
- <upload-image v-model="productForm.productImage" :limit="1" width="178px" height="178px" imageText="" />
|
|
|
+ <image-upload v-model="productForm.productImage" :limit="1" width="178px" height="178px" imageText="" />
|
|
|
<div class="form-item-tip">从图片库选择,建议尺寸300*300px</div>
|
|
|
</el-form-item>
|
|
|
|
|
|
<!-- 商品轮播图 -->
|
|
|
<el-form-item label="商品轮播图:" required>
|
|
|
- <upload-image v-model="carouselImages" :limit="20" width="120px" height="120px" imageText="" />
|
|
|
+ <image-upload v-model="carouselImages" :limit="20" width="120px" height="120px" imageText="" />
|
|
|
<div class="form-item-tip">从图片库选择,支持多选,建议尺寸300*300px</div>
|
|
|
</el-form-item>
|
|
|
|
|
|
@@ -613,9 +613,6 @@
|
|
|
<el-tab-pane label="电脑端详情" name="pc">
|
|
|
<Editor v-model="productForm.pcDetail" :height="400" />
|
|
|
</el-tab-pane>
|
|
|
- <el-tab-pane label="移动端详情" name="mobile">
|
|
|
- <Editor v-model="productForm.mobileDetail" :height="400" />
|
|
|
- </el-tab-pane>
|
|
|
</el-tabs>
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
@@ -782,6 +779,7 @@ import { listInfo } from '@/api/customer/supplierInfo';
|
|
|
import { InfoVO } from '@/api/customer/supplierInfo/types';
|
|
|
import { listComStaff } from '@/api/system/comStaff';
|
|
|
import { ComStaffVO } from '@/api/system/comStaff/types';
|
|
|
+import { listByIds } from '@/api/system/oss';
|
|
|
|
|
|
const route = useRoute();
|
|
|
const router = useRouter();
|
|
|
@@ -985,7 +983,7 @@ const productForm = reactive<BaseForm>({
|
|
|
mediumCategoryId: undefined,
|
|
|
bottomCategoryId: undefined,
|
|
|
unitId: undefined,
|
|
|
- productImage: undefined,
|
|
|
+ productImage: '',
|
|
|
imageUrl: undefined,
|
|
|
isSelf: 0,
|
|
|
productReviewStatus: 0,
|
|
|
@@ -1149,7 +1147,7 @@ const handleLevel3Search = async (keyword: string) => {
|
|
|
}
|
|
|
level3SearchLoading.value = true;
|
|
|
try {
|
|
|
- const res = await categoryList({ classLevel: 3, categoryName: keyword, pageNum: 1, pageSize: 50 });
|
|
|
+ const res = await categoryList({ classLevel: 3, categoryName: keyword, platform: 0, pageNum: 1, pageSize: 50 });
|
|
|
level3SearchOptions.value = (res as any).data || (res as any).rows || [];
|
|
|
} catch (error) {
|
|
|
console.error('搜索三级分类失败:', error);
|
|
|
@@ -1397,13 +1395,47 @@ const handleSubmit = async () => {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ // 将主图ossId转为url(upload-image组件emit的是URL,需判断是否已是完整URL)
|
|
|
+ let productImageUrl = '';
|
|
|
+ if (productForm.productImage) {
|
|
|
+ const val = String(productForm.productImage);
|
|
|
+ if (val.startsWith('http://') || val.startsWith('https://')) {
|
|
|
+ // 已是完整URL,直接使用
|
|
|
+ productImageUrl = val;
|
|
|
+ } else {
|
|
|
+ const mainRes = await listByIds(val);
|
|
|
+ if (mainRes.data && mainRes.data.length > 0) {
|
|
|
+ productImageUrl = mainRes.data[0].url;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 将轮播图ossId转为url(upload-image组件emit的是逗号分隔的URL字符串)
|
|
|
+ let imageUrlStr = '';
|
|
|
+ if (carouselImages.value) {
|
|
|
+ const val = carouselImages.value;
|
|
|
+ const firstItem = val.split(',')[0];
|
|
|
+ if (firstItem && (firstItem.startsWith('http://') || firstItem.startsWith('https://'))) {
|
|
|
+ // 已是完整URL,直接使用
|
|
|
+ imageUrlStr = val;
|
|
|
+ } else {
|
|
|
+ const carouselRes = await listByIds(val);
|
|
|
+ if (carouselRes.data && carouselRes.data.length > 0) {
|
|
|
+ imageUrlStr = carouselRes.data.map((item) => item.url).join(',');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 准备提交数据,包含定制信息(A10产品名称由前端自动拼接,不传后端)
|
|
|
const submitProductData: any = {
|
|
|
...productForm,
|
|
|
+ // 主图存url
|
|
|
+ productImage: productImageUrl,
|
|
|
// 将服务保障ID数组转换为逗号分隔字符串
|
|
|
serviceGuarantee: serviceGuarantees.value.map((id) => String(id)).join(','),
|
|
|
- // 轮播图URL逗号分隔
|
|
|
- imageUrl: carouselImages.value.join(','),
|
|
|
+ // 轮播图存url
|
|
|
+ imageUrl: imageUrlStr,
|
|
|
// 将商品属性值转换为JSON字符串
|
|
|
attributesList: JSON.stringify(productAttributesValues.value),
|
|
|
isCustomize: customForm.isCustomize ? 1 : 0,
|
|
|
@@ -1411,7 +1443,9 @@ const handleSubmit = async () => {
|
|
|
customizedCraft: customForm.selectedCrafts.join(','),
|
|
|
customDescription: customForm.customDescription,
|
|
|
customDetailsJson: JSON.stringify(customForm.customDetails),
|
|
|
- diyAttributesList: diyAttributesList.value.filter((item) => item.attributeKey || item.attributeValue)
|
|
|
+ diyAttributesList: diyAttributesList.value.filter((item) => item.attributeKey || item.attributeValue),
|
|
|
+ // 供应到期时间:后端保存日期格式,将计算好的到期日期提交
|
|
|
+ supplyValidityPeriod: supplyExpiryDate.value || undefined
|
|
|
};
|
|
|
// A10产品名称不传后端
|
|
|
delete submitProductData.a10ProductName;
|
|
|
@@ -1565,7 +1599,7 @@ const formatRowPrice = (row: any, field: string) => {
|
|
|
// 获取分类树
|
|
|
const getCategoryTree = async () => {
|
|
|
try {
|
|
|
- const res = await categoryTree();
|
|
|
+ const res = await categoryTree({ platform: 0 });
|
|
|
categoryOptions.value = res.data || [];
|
|
|
} catch (error) {
|
|
|
console.error('获取分类树失败:', error);
|
|
|
@@ -1807,6 +1841,27 @@ const loadProductDetail = async () => {
|
|
|
productForm.afterSalesService = Number(res.data.productBaseVo.afterSalesService);
|
|
|
}
|
|
|
|
|
|
+ // 回显供应时间 - 后端返回日期格式,需计算为天数
|
|
|
+ if (res.data.productBaseVo.supplyValidityPeriod) {
|
|
|
+ const endDate = new Date(res.data.productBaseVo.supplyValidityPeriod);
|
|
|
+ const now = new Date();
|
|
|
+ // 清除时分秒,只比较日期
|
|
|
+ now.setHours(0, 0, 0, 0);
|
|
|
+ endDate.setHours(0, 0, 0, 0);
|
|
|
+ const diffDays = Math.ceil((endDate.getTime() - now.getTime()) / (1000 * 60 * 60 * 24));
|
|
|
+ productForm.supplyValidityPeriod = diffDays > 0 ? diffDays : 0;
|
|
|
+ // 回显到期时间显示
|
|
|
+ const y = endDate.getFullYear();
|
|
|
+ const m = String(endDate.getMonth() + 1).padStart(2, '0');
|
|
|
+ const d = String(endDate.getDate()).padStart(2, '0');
|
|
|
+ supplyExpiryDate.value = `${y}-${m}-${d}`;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 回显主图 - limit=1时组件内部会自动包装为数组,这里直接赋URL字符串即可
|
|
|
+ if (res.data.productBaseVo.productImage) {
|
|
|
+ productForm.productImage = res.data.productBaseVo.productImage;
|
|
|
+ }
|
|
|
+
|
|
|
// 回显轮播图
|
|
|
if (res.data.productBaseVo.imageUrl) {
|
|
|
carouselImages.value = res.data.productBaseVo.imageUrl.split(',').filter((url: string) => url.trim());
|