Commit 1544be44 authored by mengwenhao's avatar mengwenhao

feature:商品编辑完成

parent 16fadde5
......@@ -95,9 +95,9 @@ exports.auditReject = async ctx => {
json: true,
body: ctx.request.body
};
console.log("审核驳回操作", ctx.request.body);
ctx.body = await req(ctx, opts);
};
// 获取门店列表
exports.getShopsList = async ctx => {
const opts = {
url: `${GOODS_URI}/shop/background/shop_list`,
......@@ -106,3 +106,23 @@ exports.getShopsList = async ctx => {
};
ctx.body = await req(ctx, opts);
};
// 添加门店
exports.addShop = async ctx => {
const opts = {
url: `${GOODS_URI}/shop/background/add_shop`,
method: "POST",
json: true,
body: ctx.request.body
};
ctx.body = await req(ctx, opts);
};
// 修改商品
exports.editGoods = async ctx => {
const opts = {
url: `${GOODS_URI}/goods/background/edit_goods`,
method: "POST",
json: true,
body: ctx.request.body
};
ctx.body = await req(ctx, opts);
}
\ No newline at end of file
......@@ -46,7 +46,9 @@ router.get(`${API_VERSION}/goods/background/get_goods_info`, goods.getGoodsInfo)
router.post(`${API_VERSION}/goods/background/audit_pass`, goods.postSuccess);
router.post(`${API_VERSION}/goods/background/check_goods_name`, goods.checkGoodsName);
router.post(`${API_VERSION}/goods/background/audit_reject`, goods.auditReject);
router.get(`${API_VERSION}/shop/background/shop_list`, goods.getShopsList)
router.get(`${API_VERSION}/shop/background/shop_list`, goods.getShopsList);
router.post(`${API_VERSION}/shop/background/add_shop`, goods.addShop);
router.post(`${API_VERSION}/goods/background/edit_goods`, goods.editGoods)
//生活号
......
......@@ -203,6 +203,7 @@
</template>
</el-table-column>
<el-table-column
v-if="$route.params.operation === 'EDIT'"
label="操作"
align="center"
fixed="right"
......@@ -217,6 +218,7 @@
</el-table-column>
</el-table>
<el-popover
v-if="$route.params.operation === 'EDIT'"
placement="bottom"
:width="600"
trigger="click"
......@@ -237,8 +239,7 @@
<el-table-column
type="selection"
width="55"
>
</el-table-column>
> </el-table-column>
<el-table-column
align="center"
prop="shop_name"
......@@ -277,15 +278,16 @@
:total="shopsCount"
>
</el-pagination>
<!-- 添加门店弹窗 -->
<el-popover
placement="bottom"
:width="600"
trigger="click"
:visible="addShopShow"
>
<template #reference>
<el-button
@click="addShopShow = true"
type="primary"
style="border-radius:20px;margin:20px 0 0 50%;transform: translate(-50%,0);"
>添加门店
......@@ -319,7 +321,10 @@
</el-form-item>
</el-form>
<section style="display:flex;justify-content:center;">
<el-button type="primary">保存</el-button>
<el-button
type="primary"
@click="addShop"
>保存</el-button>
</section>
</el-popover>
</el-popover>
......@@ -336,24 +341,30 @@
<el-form-item label="售价">
<el-input
v-if="$route.params.operation === 'EDIT'"
type="number"
v-model="goodsObj.price"
@blur="salePrice"
></el-input>
<span v-else>{{ goodsObj.price }}</span>
</el-form-item>
<el-form-item label="原价">
<el-input
v-if="$route.params.operation === 'EDIT'"
type="number"
v-model="goodsObj.original_price"
@blur="perPrice"
></el-input>
<span v-else>{{ goodsObj.original_price }}</span>
</el-form-item>
<h4 style="margin:20px 0">库存信息</h4>
<el-form-item label="剩余库存量:">
<el-input-number
v-if="$route.params.operation === 'EDIT'"
v-model="goodsObj.inventory_rest"
:min="0"
></el-input-number>
<span v-else>{{ goodsObj.inventory_rest }}</span>
</el-form-item>
<el-form-item label="已下单量:">
<span>{{ goodsObj.total_amount_sold }}</span>
......@@ -379,12 +390,15 @@
>
<el-form-item label="单人可买上限:">
<el-input-number
v-if="$route.params.operation === 'EDIT'"
:min="0"
v-model="goodsObj.rule_limit"
></el-input-number>
<span v-else>{{ goodsObj.rule_limit }}</span>
</el-form-item>
<el-form-item label="退款规则:">
<el-select
v-if="$route.params.operation === 'EDIT'"
v-model="goodsObj.rule_refund"
placeholder="请选择"
>
......@@ -396,15 +410,36 @@
>
</el-option>
</el-select>
<span v-else-if="
$route.params.operation !== 'EDIT' && goodsObj.rule_refund === 1
">到期后自动退款</span>
<span v-else-if="
$route.params.operation !== 'EDIT' && goodsObj.rule_refund === 2
">购买后不允许退款</span>
<span v-else-if="
$route.params.operation !== 'EDIT' && goodsObj.rule_refund === 3
">到期后不退款</span>
</el-form-item>
<el-form-item label="使用日期:">
<el-radio-group v-model="goodsObj.rule_date_type">
<el-radio-group
v-model="goodsObj.rule_date_type"
v-if="$route.params.operation === 'EDIT'"
>
<el-radio :label="1">周末、节假日通用</el-radio>
<el-radio :label="2">仅工作日可用</el-radio>
</el-radio-group>
<span v-else-if="
$route.params.operation !== 'EDIT' &&
goodsObj.rule_date_type === 1
">周末、节假日通用</span>
<span v-else-if="
$route.params.operation !== 'EDIT' &&
goodsObj.rule_date_type === 2
">仅工作日可用</span>
</el-form-item>
<el-form-item label="使用时间:">
<el-time-picker
v-if="$route.params.operation === 'EDIT'"
is-range
v-model="rulesForm.useTime"
range-separator="-"
......@@ -414,14 +449,29 @@
@change="pickerTime"
>
</el-time-picker>
<span v-else>{{
goodsObj.rule_start_time + "-" + goodsObj.rule_end_time
}}</span>
</el-form-item>
<el-form-item label="过期时间">
<el-date-picker
:disabledDate="disableExpirDate"
v-model="expirationTime"
type="datetime"
@change="expirDateChange"
placeholder="选择日期时间"
>
</el-date-picker>
</el-form-item>
<el-form-item label="使用规则:">
<el-input
v-if="$route.params.operation === 'EDIT'"
type="textarea"
maxlength="100"
show-word-limit
v-model="goodsObj.rule_desc"
></el-input>
<span v-else>{{ goodsObj.rule_desc }}</span>
</el-form-item>
</el-form>
</el-card>
......@@ -507,6 +557,7 @@
<el-button
v-if="$route.params.operation === 'EDIT'"
type="primary"
@click="saveDetailMessage"
>保存
</el-button>
<el-button
......@@ -537,7 +588,9 @@ import {
postSuccess,
auditReject,
checkGoodsName,
getShopsList
getShopsList,
postAddShop,
editGoods
} from "@/service/Goods/goods";
import { GOODS_URI } from "../../../../server/config.js";
......@@ -610,7 +663,6 @@ export default {
optionList: [], // 商品分类选项
optionsValue: [], // 商品分类的值
editOptionValue: "", // 商品分类的上传值
// 商品回显信息
goodsObj: {
introduce: ""
......@@ -631,14 +683,12 @@ export default {
// 使用规则表单
rulesForm: {
rule_limit: "", // 单人可买上限
rulesValue: "", // 退款规则
// 退款选项
rulesOptions: [
{ value: 1, label: "到期自动退款" },
{ value: 2, label: "购买后不允许退款" },
{ value: 3, label: "到期后不退款" }
],
useDate: "", // 使用日期
useTime: [], // 使用时间
rule_desc: "" // 使用描述
},
......@@ -675,7 +725,12 @@ export default {
activeStartTime: "", // 活动开始时间
activeEndTime: "", // 活动结束时间
uploadUrl: `${GOODS_URI}/merchant/lifeinner/upload` // 金山云上传地址
uploadUrl: `${GOODS_URI}/merchant/lifeinner/upload`, // 金山云上传地址
addShopShow: false, // 添加门店弹框显示
expirationTime: "", // 过期时间
shopIds: "" // 已选商店id
};
},
......@@ -720,7 +775,13 @@ export default {
goods_info.introduce_pic_url_list,
this.introduceUploadList
);
console.log(this.introduceUploadList);
// 渲染过期时间
this.expirationTime = goods_info.expiration_time;
// 初始化门店id
const shopId = goods_info.sub_shop.map(item => {
return item.sub_shop_id
});
this.shopIds = shopId.join(",");
} catch (error) {
console.error(error);
}
......@@ -801,8 +862,7 @@ export default {
// 获取门店列表
async getShops () {
const query = {
// this.goodsObj.life_account_id
life_account_id: "9233473057619969",
life_account_id: this.goodsObj.life_account_id,
page: this.shopCurrentPage,
page_size: 5
};
......@@ -813,10 +873,34 @@ export default {
this.shopsCount = res.count;
},
// 门店列表更改时
// 门店列表更改时操作
handleShopsChange (value) {
this.goodsObj.sub_shop = value;
console.log(value);
const shopList = value.map(item => {
return item.sub_shop_id;
});
this.shopIds = shopList.join(",");
console.log(this.shopIds);
},
// 添加新门店
async addShop () {
const deepPlace = this.shopForm.deep_place.split(",");
const longitude = deepPlace[0];
const latitude = deepPlace[1];
const query = {
life_account_id: this.goodsObj.life_account_id,
phone: this.shopForm.connect_phone,
shop_name: this.shopForm.shop_name,
longitude, // 经度
latitude, // 纬度
address: this.shopForm.address
};
const res = await postAddShop(query);
if (res.code !== 0) return this.$message.error(res.reason);
this.$message.success("添加门店成功!");
this.addShopShow = false;
console.log(res);
},
// 删除已选择门店
......@@ -834,9 +918,8 @@ export default {
// 商品分类列表变化
optionsChange (value) {
console.log("商品分类id", value);
this.editOptionValue = value.join(",");
console.log(this.editOptionValue);
this.optionsValue = value;
console.log("商品分类id", this.optionsValue);
},
// 检查商品名称是否重复
......@@ -915,6 +998,44 @@ export default {
console.log("时间节点", this.activeStartTime, this.activeEndTime);
},
// 过期时间更改
expirDateChange (time) {
console.log(time);
let YYYY = time.getFullYear();
let MM = time.getMonth() + 1;
let DD = time.getDate();
let HH = time.getHours();
let mm = time.getMinutes();
let ss = time.getSeconds();
if (MM < 10) {
MM = "0" + MM;
}
if (DD < 10) {
DD = "0" + DD;
}
if (HH < 10) {
HH = "0" + HH;
}
if (mm < 10) {
mm = "0" + mm;
}
if (ss < 10) {
ss = "0" + ss;
}
this.expirationTime = `${YYYY}-${MM}-${DD} ${HH}:${mm}:${ss}`;
console.log(this.expirationTime);
},
// 禁用时间
disableExpirDate (time) {
const nowDate = new Date();
if (time > nowDate) {
return false;
} else {
return true;
}
},
// 更改售价
salePrice () {
if (this.goodsObj.price.length === 0) return (this.goodsObj.price = 0);
......@@ -955,6 +1076,40 @@ export default {
// 返回主页面
backToDetail () {
this.$router.replace({ name: "GoodsList" });
},
// 保存修改信息
async saveDetailMessage () {
console.log(this.optionsValue);
console.log(this.shopIds);
if (!this.goodsObj.goods_name)
return this.$message.error("请填写商品名称");
if (!this.isGoodsNameRepeat)
return this.$message.error("商品名称被占用,请重新更换商品名称");
if (!this.optionsValue) return this.$message.error("请选择商品分类");
if (!this.expirationTime)
return this.$message.error("过期时间未填写,请填写后再提交");
const query = {
category_1_id: this.optionsValue[0], // 商品一级分类id
category_2_id: this.optionsValue[1], // 商品二级分类id
goods_name: this.goodsObj.goods_name, // 商品名称
desc_pic_url: this.detailUploadList, // 商品详情图片
desc: this.goodsObj.desc, // 商品详情描述
introduce: this.goodsObj.introduce, // 商品介绍
introduce_pic_url: this.introduceUploadList, // 商品介绍图片
expiration_time: this.expirationTime, // 过期时间
rule_limit: this.rulesForm.rule_limit, // 单人可购买上限
rule_desc: this.rulesForm.rule_desc, // 规则描述
rule_refund: this.goodsObj.rule_refund, // 退款规则
rule_start_time: this.activeStartTime, // 规则开始时间
rule_end_time: this.activeEndTime, // 规则结束时间
inventory_add: this.goodsObj.inventory_rest, // 库存
original_price: this.goodsObj.original_price, // 原价
price: this.goodsObj.price, // 现价
sub_shop_ids: this.shopIds // 门店id
};
const res = await editGoods(query);
if (res.code !== 0) return this.$message.error(res.reason);
}
}
};
......
......@@ -55,6 +55,16 @@ export async function checkGoodsName (params) {
}
// 获取门店表单
export async function getShopsList (params) {
const res = await axios.get("api/v1/shop/background/shop_list", { params });
const res = await axios.get("/api/v1/shop/background/shop_list", { params });
return res;
}
// 添加门店信息
export async function postAddShop (query) {
const res = await axios.post("/api/v1/shop/background/add_shop", query);
return res;
}
export async function editGoods (query) {
const res = await axios.post("/api/v1/goods/background/edit_goods", query);
return res;
}
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