Commit 16fadde5 authored by mengwenhao's avatar mengwenhao

feature:商品介绍图格式重构完成

parent 777f0c1b
...@@ -95,18 +95,18 @@ ...@@ -95,18 +95,18 @@
<section class="width50p"> <section class="width50p">
<h4 style="margin-bottom:20px">商品详情图</h4> <h4 style="margin-bottom:20px">商品详情图</h4>
<el-upload <el-upload
:disabled="$route.params.operation !== 'EDIT'" :data="{ scenario: `goods` }"
ref="detailUpload"
:action="uploadUrl" :action="uploadUrl"
:on-preview="previewImage" :on-preview="previewImage"
:auto-upload="true" :on-success="handleDetailSuccess"
:data="{ scenario: `goods` }" :on-remove="removeDetailFiles"
:file-list="descPicUrlList"
auto-upload
:disabled="$route.params.operation !== 'EDIT'"
ref="detailUpload"
:limit="9" :limit="9"
list-type="picture-card" list-type="picture-card"
multiple multiple
:on-success="handleDetailChange"
:on-remove="removeDetailFiles"
:file-list="descPicUrlList"
> >
<template #default> <template #default>
<i class="el-icon-plus"></i> <i class="el-icon-plus"></i>
...@@ -143,15 +143,16 @@ ...@@ -143,15 +143,16 @@
<section class="width50p"> <section class="width50p">
<h4 style="margin-bottom:20px">商品介绍图</h4> <h4 style="margin-bottom:20px">商品介绍图</h4>
<el-upload <el-upload
:data="{ scenario: `goods` }"
:disabled="$route.params.operation !== 'EDIT'" :disabled="$route.params.operation !== 'EDIT'"
action="#" :action="uploadUrl"
:auto-upload="false" auto-upload
:limit="9" :limit="9"
:on-preview="previewImage" :on-preview="previewImage"
list-type="picture-card" list-type="picture-card"
multiple multiple
ref="intrUpload" ref="intrUpload"
:on-change="intrChange" :on-success="introduceSuccess"
:on-remove="intrRemove" :on-remove="intrRemove"
:file-list="introducePicUrlList" :file-list="introducePicUrlList"
> >
...@@ -209,7 +210,7 @@ ...@@ -209,7 +210,7 @@
<template #default="scope"> <template #default="scope">
<el-button <el-button
type="text" type="text"
@click="deleteShops(scope.row.shop_id)" @click="deleteShops(scope.row.sub_shop_id)"
>删除 >删除
</el-button> </el-button>
</template> </template>
...@@ -229,11 +230,15 @@ ...@@ -229,11 +230,15 @@
</el-button> </el-button>
</template> </template>
<!-- 门店列表 --> <!-- 门店列表 -->
<el-table :data="shopsList.result"> <el-table
:data="shopsList"
@selection-change="handleShopsChange"
>
<el-table-column <el-table-column
type="selection" type="selection"
width="55" width="55"
> </el-table-column> >
</el-table-column>
<el-table-column <el-table-column
align="center" align="center"
prop="shop_name" prop="shop_name"
...@@ -269,7 +274,7 @@ ...@@ -269,7 +274,7 @@
v-model:currentPage="shopCurrentPage" v-model:currentPage="shopCurrentPage"
:page-size="5" :page-size="5"
layout="total, prev, pager, next" layout="total, prev, pager, next"
:total="shopsList.count" :total="shopsCount"
> >
</el-pagination> </el-pagination>
...@@ -331,14 +336,16 @@ ...@@ -331,14 +336,16 @@
<el-form-item label="售价"> <el-form-item label="售价">
<el-input <el-input
type="number"
v-model="goodsObj.price" v-model="goodsObj.price"
@input="salePrice" @blur="salePrice"
></el-input> ></el-input>
</el-form-item> </el-form-item>
<el-form-item label="原价"> <el-form-item label="原价">
<el-input <el-input
type="number"
v-model="goodsObj.original_price" v-model="goodsObj.original_price"
@input="perPrice" @blur="perPrice"
></el-input> ></el-input>
</el-form-item> </el-form-item>
<h4 style="margin:20px 0">库存信息</h4> <h4 style="margin:20px 0">库存信息</h4>
...@@ -458,7 +465,6 @@ ...@@ -458,7 +465,6 @@
></el-table-column> ></el-table-column>
</el-table> </el-table>
</el-card> </el-card>
<!-- 审核保存返回 --> <!-- 审核保存返回 -->
<section class="operationButton"> <section class="operationButton">
<el-button <el-button
...@@ -509,7 +515,6 @@ ...@@ -509,7 +515,6 @@
>返回 </el-button> >返回 </el-button>
</section> </section>
</el-card> </el-card>
<!-- 展示缩略图 --> <!-- 展示缩略图 -->
<el-dialog <el-dialog
width="40%" width="40%"
...@@ -605,17 +610,22 @@ export default { ...@@ -605,17 +610,22 @@ export default {
optionList: [], // 商品分类选项 optionList: [], // 商品分类选项
optionsValue: [], // 商品分类的值 optionsValue: [], // 商品分类的值
editOptionValue: "", // 商品分类的上传值
// 商品回显信息 // 商品回显信息
goodsObj: { goodsObj: {
introduce: "" introduce: ""
}, },
isGoodsNameRepeat: false, // 商品名称是否重复
descPicUrlList: [], // 商品详情图回显列表 descPicUrlList: [], // 商品详情图回显列表
introducePicUrlList: [], // 商品介绍图回显列表 introducePicUrlList: [], // 商品介绍图回显列表
recordList: [], // 提交记录 recordList: [], // 提交记录
detailUploadList: [], // 上传图片列表 detailUploadList: [], // 上传详情图片列表
introduceUploadList: [], // 上传详情图片列表
inventoryNumber: 0, // 库存数量 inventoryNumber: 0, // 库存数量
// 使用规则表单 // 使用规则表单
...@@ -642,6 +652,7 @@ export default { ...@@ -642,6 +652,7 @@ export default {
}, },
shopsList: [], // 门店列表 shopsList: [], // 门店列表
shopsCount: 0,
shopCurrentPage: 1, // 门店列表当前页 shopCurrentPage: 1, // 门店列表当前页
// 新增门店表单 // 新增门店表单
...@@ -661,6 +672,9 @@ export default { ...@@ -661,6 +672,9 @@ export default {
rejectVisible: false, // 驳回原因弹框展示状态 rejectVisible: false, // 驳回原因弹框展示状态
isShowPopver: false, // 是否展示图片框 isShowPopver: false, // 是否展示图片框
activeStartTime: "", // 活动开始时间
activeEndTime: "", // 活动结束时间
uploadUrl: `${GOODS_URI}/merchant/lifeinner/upload` // 金山云上传地址 uploadUrl: `${GOODS_URI}/merchant/lifeinner/upload` // 金山云上传地址
}; };
}, },
...@@ -695,13 +709,18 @@ export default { ...@@ -695,13 +709,18 @@ export default {
goods_info.introduce_pic_url_list, goods_info.introduce_pic_url_list,
this.introducePicUrlList this.introducePicUrlList
); );
console.log(this.introducePicUrlList);
// 格式化文件上传列表 // 格式化详情图片上传列表
this.formatUploadPictureList( this.formatUploadPictureList(
goods_info.desc_pic_url_list, goods_info.desc_pic_url_list,
this.detailUploadList this.detailUploadList
); );
// 格式化初始日期 // 格式化介绍图片上传列表
this.formatUploadPictureList(
goods_info.introduce_pic_url_list,
this.introduceUploadList
);
console.log(this.introduceUploadList);
} catch (error) { } catch (error) {
console.error(error); console.error(error);
} }
...@@ -715,40 +734,43 @@ export default { ...@@ -715,40 +734,43 @@ export default {
willStorage.push(obj); willStorage.push(obj);
}); });
}, },
// 格式化上传照片列表 // 格式化上传照片列表
formatUploadPictureList (willFormat, willStorage) { formatUploadPictureList (willFormat, willStorage) {
// 格式化上传文件列表
for (let i = 0; i < willFormat.length; i++) { for (let i = 0; i < willFormat.length; i++) {
if (willFormat.length === 0) { if (willFormat.length === 0) {
return (this.detailUploadList = []); return (this.detailUploadList = []);
} }
const objectUrl = new URL(willFormat[i]); const objectUrl = new URL(willFormat[i]);
console.log(objectUrl); const bucketName = objectUrl.hostname.replace(/.com$/i, "");
const bucketName = objectUrl.hostname;
const objectId = objectUrl.pathname; const objectId = objectUrl.pathname;
willStorage.push(`${bucketName}${objectId}`); willStorage.push(`${bucketName}${objectId}`);
} }
}, },
// 格式化自主上传后的图片列表
// 获取门店列表 formatListUpload (response, fileList) {
async getShops () { const newFile = `${response.result.bucket}/${response.result.object_id}`;
const query = { fileList.push(newFile);
// this.goodsObj.life_account_id console.log("上传成功了的一个小小的无所谓的bucket+objectid", fileList);
life_account_id: "9233473057619969",
page: this.shopCurrentPage,
page_size: 5
};
const res = await getShopsList(query);
if (res.code !== 0) return this.$message.error(res.reason);
this.shopsList = res;
}, },
// 商品列表换页 // 格式化删除图片后上传的数组
changeShopListPage (page) { formatDeletePhotoList (file, fileList) {
this.shopCurrentPage = page; if (!file.response) {
this.getShops(); const oldChangeNewUrl = new URL(file.url);
const oldPictureUrl =
oldChangeNewUrl.hostname.replace(/.com$/i, "") +
oldChangeNewUrl.pathname;
const oldIndex = fileList.indexOf(oldPictureUrl);
fileList.splice(oldIndex, 1);
console.log("detailUploadList", fileList);
} else {
const { bucket, object_id } = file.response.result;
const newUrl = `${bucket}/${object_id}`;
console.log(newUrl);
const newIndex = fileList.indexOf(newUrl);
fileList.splice(newIndex, 1);
console.log("detailUploadList", fileList);
}
}, },
// 格式化日期 // 格式化日期
formatDate (startTime, endTime) { formatDate (startTime, endTime) {
const nowTime = new Date(); const nowTime = new Date();
...@@ -776,9 +798,45 @@ export default { ...@@ -776,9 +798,45 @@ export default {
]; ];
}, },
// 获取门店列表
async getShops () {
const query = {
// this.goodsObj.life_account_id
life_account_id: "9233473057619969",
page: this.shopCurrentPage,
page_size: 5
};
const res = await getShopsList(query);
console.log(res);
if (res.code !== 0) return this.$message.error(res.reason);
this.shopsList = res.result;
this.shopsCount = res.count;
},
// 门店列表更改时
handleShopsChange (value) {
this.goodsObj.sub_shop = value;
console.log(value);
},
// 删除已选择门店
deleteShops (subShopId) {
this.goodsObj.sub_shop = this.goodsObj.sub_shop.filter(item => {
return item.sub_shop_id !== subShopId;
});
},
// 商品列表换页
changeShopListPage (page) {
this.shopCurrentPage = page;
this.getShops();
},
// 商品分类列表变化 // 商品分类列表变化
optionsChange (value) { optionsChange (value) {
console.log(value); console.log("商品分类id", value);
this.editOptionValue = value.join(",");
console.log(this.editOptionValue);
}, },
// 检查商品名称是否重复 // 检查商品名称是否重复
...@@ -790,32 +848,33 @@ export default { ...@@ -790,32 +848,33 @@ export default {
}); });
console.log(res); console.log(res);
if (res.code !== 0) return this.$message.error(res.reason); if (res.code !== 0) return this.$message.error(res.reason);
this.$message.success("商品名称未被占用"); if (res.result.can_use) {
this.isGoodsNameRepeat = true;
this.$message.success("名称未被占用,请继续填写表单");
} else {
this.isGoodsNameRepeat = false;
return this.$message.error("名称被占用,换个名称试试吧~~~");
}
}, },
// 商品详情图上传成功时 // 商品详情图上传成功时
handleDetailChange (res, file, fileList) { handleDetailSuccess (res) {
console.log("返回结果", res); this.formatListUpload(res, this.detailUploadList);
console.log("文件", file);
console.log("文件列表", fileList);
const newFile = `${res.result.bucket}/${res.result.object_id}`;
this.detailUploadList.push(newFile);
console.log("上传成功了的一个小小的无所谓的bucket+objectid", this.detailUploadList);
}, },
// 商品详情图删除完成后的钩子 // 商品详情图删除完成后的钩子
removeDetailFiles (file, fileList) { removeDetailFiles (file) {
console.log(fileList); this.formatDeletePhotoList(file, this.detailUploadList);
}, },
// 商品介绍图更改钩子 // 商品介绍图上传成功钩子
intrChange (file, fileList) { introduceSuccess (res) {
console.log(fileList); this.formatListUpload(res, this.introduceUploadList);
}, },
// 商品介绍图删除后的钩子 // 商品介绍图删除后的钩子
intrRemove (file, fileList) { intrRemove (file) {
console.log(fileList); this.formatDeletePhotoList(file, this.introduceUploadList);
}, },
// 展示商品大图 // 展示商品大图
...@@ -824,31 +883,51 @@ export default { ...@@ -824,31 +883,51 @@ export default {
this.isShowPopver = true; this.isShowPopver = true;
}, },
// 删除已选择门店
deleteShops (shopId) {
console.log(shopId);
},
// 选择时间 // 选择时间
pickerTime (time) { pickerTime (time) {
this.goodsObj.rule_start_time; let startHours = time[0].getHours() + "";
const dateTime1 = time[0].getHours(); let startMinutes = time[0].getMinutes() + "";
const dateTime2 = time[1].getHours(); let startSeconds = time[0].getSeconds() + "";
console.log("时间节点", dateTime1, dateTime2); let endHours = time[1].getHours() + "";
let endMinutes = time[1].getMinutes() + "";
let endSeconds = time[1].getSeconds() + "";
if (startHours < 10) {
startHours = "0" + startHours;
}
if (startMinutes < 10) {
startMinutes = "0" + startMinutes;
}
if (startSeconds < 10) {
startSeconds = "0" + startSeconds;
}
if (endHours < 10) {
endHours = "0" + endHours;
}
if (endMinutes < 10) {
endMinutes = "0" + endMinutes;
}
if (endSeconds < 10) {
endSeconds = "0" + endSeconds;
}
this.activeStartTime = `${startHours}:${startMinutes}:${startSeconds}`;
this.activeEndTime = `${endHours}:${endMinutes}:${endSeconds}`;
console.log("时间节点", this.activeStartTime, this.activeEndTime);
}, },
// 更改售价 // 更改售价
salePrice (value) { salePrice () {
if (value.length === 0) value = 0; if (this.goodsObj.price.length === 0) return (this.goodsObj.price = 0);
this.goodsObj.price = parseFloat(value).toFixed(2); this.goodsObj.price = parseFloat(this.goodsObj.price).toFixed(2);
console.log("售价", this.goodsObj.price);
}, },
// 更改原价 // 更改原价
perPrice (value) { perPrice () {
if (value.length === 0) value = 0; if (this.goodsObj.original_price === 0)
this.goodsObj.original_price = parseFloat(value).toFixed(2); return (this.goodsObj.original_price = 0);
console.log("原价", this.goodsObj.original_price); this.goodsObj.original_price = parseFloat(
this.goodsObj.original_price
).toFixed(2);
}, },
// 审核通过 // 审核通过
......
...@@ -368,6 +368,7 @@ export default { ...@@ -368,6 +368,7 @@ export default {
if (res.code !== 0) return this.$message.error(res.reason); if (res.code !== 0) return this.$message.error(res.reason);
this.$message.success("商品下架成功"); this.$message.success("商品下架成功");
} }
this.getCommodityList();
}, },
// 页码变化 // 页码变化
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment