Commit 2486e431 authored by mengwenhao's avatar mengwenhao

fix:商品后台-新增了详情页和返回,部分字段修改

parent 1b729564
...@@ -78,16 +78,16 @@ ...@@ -78,16 +78,16 @@
clearable clearable
></el-cascader> ></el-cascader>
</el-form-item> </el-form-item>
<el-form-item label="描述:"> <el-form-item label="说明:">
<el-input <el-input
v-if="$route.params.operation === 'EDIT'" v-if="$route.params.operation === 'EDIT'"
type="textarea" type="textarea"
maxlength="50" maxlength="50"
show-word-limit show-word-limit
:autosize="{ minRows: 4 }" :autosize="{ minRows: 4 }"
v-model="goodsObj.desc" v-model="goodsObj.introduce"
></el-input> ></el-input>
<span v-else>{{ goodsObj.desc }}</span> <span v-else>{{ goodsObj.introduce }}</span>
</el-form-item> </el-form-item>
</el-form> </el-form>
</section> </section>
...@@ -160,14 +160,16 @@ ...@@ -160,14 +160,16 @@
<i class="el-icon-plus"></i> <i class="el-icon-plus"></i>
</template> </template>
</el-upload> </el-upload>
<h4 style="margin-top:20px">商品介绍:</h4> <!-- <h4 style="margin-top:20px">商品介绍:</h4>
<el-input <el-input
v-if="$route.params.operation === 'EDIT'" v-if="$route.params.operation === 'EDIT'"
type="textarea" type="textarea"
:autosize="{ minRows: 4 }" :autosize="{ minRows: 4 }"
v-model="goodsObj.introduce" v-model="goodsObj.introduce"
:maxlength="500"
show-word-limit
></el-input> ></el-input>
<span v-else>{{ goodsObj.introduce }}</span> <span v-else>{{ goodsObj.introduce }}</span> -->
</section> </section>
</section> </section>
</el-card> </el-card>
...@@ -351,28 +353,29 @@ ...@@ -351,28 +353,29 @@
<el-form-item label="售价"> <el-form-item label="售价">
<el-input <el-input
v-if="$route.params.operation === 'EDIT'" v-if="$route.params.operation === 'EDIT'"
type="number"
v-model="goodsObj.price" v-model="goodsObj.price"
@blur="salePrice" @change="salePrice"
></el-input> ></el-input>
<span v-else>{{ goodsObj.price }}</span> <span v-else>{{ goodsObj.price }}</span>
</el-form-item> </el-form-item>
<el-form-item label="原价"> <el-form-item label="原价">
<el-input <el-input
v-if="$route.params.operation === 'EDIT'" v-if="$route.params.operation === 'EDIT'"
type="number"
v-model="goodsObj.original_price" v-model="goodsObj.original_price"
@blur="perPrice" @change="perPrice"
></el-input> ></el-input>
<span v-else>{{ goodsObj.original_price }}</span> <span v-else>{{ goodsObj.original_price }}</span>
</el-form-item> </el-form-item>
<h4 style="margin:20px 0">库存信息</h4> <h4 style="margin:20px 0">库存信息</h4>
<el-form-item label="剩余库存量:"> <el-form-item label="剩余库存量:">
<span>{{ goodsObj.inventory_rest }}</span>
</el-form-item>
<el-form-item label="库存增减:">
<el-input-number <el-input-number
v-if="$route.params.operation === 'EDIT'" v-if="$route.params.operation === 'EDIT'"
v-model="goodsObj.inventory_rest" v-model="inventoryAdd"
:min="0" @change="hasNumberChange"
@blur="hasNumber" @blur="hasNumberChange"
></el-input-number> ></el-input-number>
<span v-else>{{ goodsObj.inventory_rest }}</span> <span v-else>{{ goodsObj.inventory_rest }}</span>
</el-form-item> </el-form-item>
...@@ -404,6 +407,8 @@ ...@@ -404,6 +407,8 @@
:min="0" :min="0"
:precision="0" :precision="0"
v-model="goodsObj.rule_limit" v-model="goodsObj.rule_limit"
@change="handleLimitChange"
@blur="handleLimitChange"
></el-input-number> ></el-input-number>
<span v-else>{{ goodsObj.rule_limit }}</span> <span v-else>{{ goodsObj.rule_limit }}</span>
</el-form-item> </el-form-item>
...@@ -448,16 +453,24 @@ ...@@ -448,16 +453,24 @@
goodsObj.rule_date_type === 2 goodsObj.rule_date_type === 2
">仅工作日可用</span> ">仅工作日可用</span>
</el-form-item> </el-form-item>
<el-form-item label="使用时间:"> <el-form-item label="使用开始时间:">
<el-time-picker <el-time-picker
arrow-control
v-if="$route.params.operation === 'EDIT'" v-if="$route.params.operation === 'EDIT'"
is-range v-model="rulesForm.useStartTime"
v-model="rulesForm.useTime" @change="pickerStartTime"
range-separator="-" >
start-placeholder="开始时间" </el-time-picker>
end-placeholder="结束时间" <span v-else>{{
placeholder="选择时间范围" goodsObj.rule_start_time + "-" + goodsObj.rule_end_time
@change="pickerTime" }}</span>
</el-form-item>
<el-form-item label="使用结束时间:">
<el-time-picker
arrow-control
v-if="$route.params.operation === 'EDIT'"
v-model="rulesForm.useEndTime"
@change="pickerEndTime"
> >
</el-time-picker> </el-time-picker>
<span v-else>{{ <span v-else>{{
...@@ -621,7 +634,7 @@ export default { ...@@ -621,7 +634,7 @@ export default {
} }
}, },
created () { mounted () {
this.getOptions(); this.getOptions();
this.getGoodsDetailList(this.$route.params.spuId); this.getGoodsDetailList(this.$route.params.spuId);
}, },
...@@ -653,10 +666,8 @@ export default { ...@@ -653,10 +666,8 @@ export default {
watch: { watch: {
goodsObj (val) { goodsObj (val) {
this.optionsValue = [val.category_1_id, val.category_2_id]; this.optionsValue = [val.category_1_id, val.category_2_id];
this.rulesForm.useTime = this.formatDate( this.rulesForm.useStartTime = this.formatDate(val.rule_start_time);
val.rule_start_time, this.rulesForm.useEndTime = this.formatDate(val.rule_end_time);
val.rule_end_time
);
}, },
rejectVisible (val) { rejectVisible (val) {
if (!val) { if (!val) {
...@@ -685,6 +696,7 @@ export default { ...@@ -685,6 +696,7 @@ export default {
goodsObj: { goodsObj: {
introduce: "" // 商品介绍 introduce: "" // 商品介绍
}, },
inventoryAdd: 0, // 库存增减
originalGoodsName: "", // 原商品名 originalGoodsName: "", // 原商品名
isGoodsNameRepeat: false, // 商品名称是否重复 isGoodsNameRepeat: false, // 商品名称是否重复
...@@ -707,7 +719,8 @@ export default { ...@@ -707,7 +719,8 @@ export default {
{ value: 2, label: "购买后不允许退款" }, { value: 2, label: "购买后不允许退款" },
{ value: 3, label: "到期后不退款" } { value: 3, label: "到期后不退款" }
], ],
useTime: [], // 使用时间 useStartTime: "", // 使用开始时间
useEndTime: "", // 使用结束时间
rule_desc: "" // 使用描述 rule_desc: "" // 使用描述
}, },
...@@ -829,30 +842,16 @@ export default { ...@@ -829,30 +842,16 @@ export default {
}, },
// 格式化日期 // 格式化日期
formatDate (startTime, endTime) { formatDate (time) {
const nowTime = new Date(); const nowTime = new Date();
const nowYear = nowTime.getFullYear(); const nowYear = nowTime.getFullYear();
const nowMonth = nowTime.getMonth() + 1; const nowMonth = nowTime.getMonth() + 1;
const nowDate = nowTime.getDate(); const nowDate = nowTime.getDate();
const startTimeArray = startTime.split(":"); const timeArray = time.split(":");
const endTimeArray = endTime.split(":"); const Hour = parseInt(timeArray[0]);
const startHour = parseInt(startTimeArray[0]); const Minute = parseInt(timeArray[1]);
const startMinute = parseInt(startTimeArray[1]); const Second = parseInt(timeArray[2]);
const startSecond = parseInt(startTimeArray[2]); return new Date(nowYear, nowMonth, nowDate, Hour, Minute, Second);
const endHour = parseInt(endTimeArray[0]);
const endMinute = parseInt(endTimeArray[1]);
const endSecond = parseInt(endTimeArray[2]);
return [
new Date(
nowYear,
nowMonth,
nowDate,
startHour,
startMinute,
startSecond
),
new Date(nowYear, nowMonth, nowDate, endHour, endMinute, endSecond)
];
}, },
// 获取门店列表 // 获取门店列表
...@@ -870,7 +869,8 @@ export default { ...@@ -870,7 +869,8 @@ export default {
// 门店列表更改时操作 // 门店列表更改时操作
handleShopsChange (value) { handleShopsChange (value) {
this.goodsObj.sub_shop = value; console.log(value);
this.goodsObj.sub_shop = this.goodsObj.sub_shop.concat(value);
const shopList = value.map(item => { const shopList = value.map(item => {
return item.sub_shop_id; return item.sub_shop_id;
}); });
...@@ -954,7 +954,6 @@ export default { ...@@ -954,7 +954,6 @@ export default {
goods_name: this.goodsObj.goods_name, goods_name: this.goodsObj.goods_name,
goods_spu_id: this.goodsObj.goods_spu_id goods_spu_id: this.goodsObj.goods_spu_id
}); });
console.log(res);
if (res.code !== 0) return this.$message.error(res.reason); if (res.code !== 0) return this.$message.error(res.reason);
if (res.result.can_use) { if (res.result.can_use) {
this.isGoodsNameRepeat = true; this.isGoodsNameRepeat = true;
...@@ -963,7 +962,6 @@ export default { ...@@ -963,7 +962,6 @@ export default {
} else { } else {
this.isGoodsNameRepeat = false; this.isGoodsNameRepeat = false;
} }
console.log("商品名称是否可用", this.isGoodsNameRepeat);
}, },
// 商品详情图上传成功时 // 商品详情图上传成功时
...@@ -989,48 +987,58 @@ export default { ...@@ -989,48 +987,58 @@ export default {
this.isShowPopver = true; this.isShowPopver = true;
}, },
// 剩余库存量更改 // 库存增减更改
hasNumber () { hasNumberChange () {
if (!this.goodsObj.inventory_rest || this.goodsObj.inventory_rest < 0) { if (!this.inventoryAdd) {
this.goodsObj.inventory_rest = 0; this.$nextTick(() => {
this.inventoryAdd = 0;
})
}
if (this.inventoryAdd + this.goodsObj.inventory_rest < 0) {
this.$nextTick(() => {
this.inventoryAdd = 0;
});
this.$message.error("库存增减不得超出剩余库存范围");
} }
console.log(this.inventoryAdd);
}, },
// 选择时间 // 单人可购买上限的修改
pickerTime (time) { handleLimitChange () {
let startHours = time[0].getHours() + ""; if (!this.goodsObj.rule_limit) {
let startMinutes = time[0].getMinutes() + ""; this.$nextTick(() => {
let startSeconds = time[0].getSeconds() + ""; this.goodsObj.rule_limit = 0;
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;
// 时间校验器
timePicker (time) {
let Hours = time.getHours() + "";
let Minutes = time.getMinutes() + "";
let Seconds = time.getSeconds() + "";
if (Hours < 10) {
Hours = "0" + Hours;
} }
if (endMinutes < 10) { if (Minutes < 10) {
endMinutes = "0" + endMinutes; Minutes = "0" + Minutes;
} }
if (endSeconds < 10) { if (Seconds < 10) {
endSeconds = "0" + endSeconds; Seconds = "0" + Seconds;
} }
this.activeStartTime = `${startHours}:${startMinutes}:${startSeconds}`; return `${Hours}:${Minutes}:${Seconds}`;
this.activeEndTime = `${endHours}:${endMinutes}:${endSeconds}`; },
// 选择规则开始时间
console.log("时间节点", this.activeStartTime, this.activeEndTime); pickerStartTime (time) {
this.activeStartTime = this.timePicker(time);
},
// 选择规则结束时间
pickerEndTime (time) {
this.activeEndTime = this.timePicker(time);
}, },
// 过期时间更改 // 过期时间更改
expirDateChange (time) { expirDateChange (time) {
console.log(time);
let YYYY = time.getFullYear(); let YYYY = time.getFullYear();
let MM = time.getMonth() + 1; let MM = time.getMonth() + 1;
let DD = time.getDate(); let DD = time.getDate();
...@@ -1053,7 +1061,6 @@ export default { ...@@ -1053,7 +1061,6 @@ export default {
ss = "0" + ss; ss = "0" + ss;
} }
this.expirationTime = `${YYYY}-${MM}-${DD} ${HH}:${mm}:${ss}`; this.expirationTime = `${YYYY}-${MM}-${DD} ${HH}:${mm}:${ss}`;
console.log(this.expirationTime);
}, },
// 禁用时间 // 禁用时间
...@@ -1068,30 +1075,36 @@ export default { ...@@ -1068,30 +1075,36 @@ export default {
// 更改售价 // 更改售价
salePrice () { salePrice () {
const parsePrice = parseFloat(this.goodsObj.price).toFixed(2);
if (this.goodsObj.price.length === 0) { if (this.goodsObj.price.length === 0) {
this.goodsObj.price = 0; this.goodsObj.price = 0;
} }
if (typeof parsePrice !== "number") { const parseFloatValue = Number(this.goodsObj.price).toFixed(2);
this.goodsObj.price = Number(parseFloatValue);
if (
typeof this.goodsObj.price === "number" &&
isNaN(this.goodsObj.price)
) {
this.goodsObj.price = 0; this.goodsObj.price = 0;
return this.$message.error("售价为数字"); return this.$message.error("售价价格必须为数字");
} }
this.goodsObj.price = parsePrice;
}, },
// 更改原价 // 更改原价
perPrice () { perPrice () {
const parseOriginalPrice = parseFloat(
this.goodsObj.original_price
).toFixed(2);
if (this.goodsObj.original_price.length === 0) { if (this.goodsObj.original_price.length === 0) {
this.goodsObj.original_price = 0; this.goodsObj.original_price = 0;
} }
if (typeof parseOriginalPrice !== "number") { const parseOriginalPrice = Number(this.goodsObj.original_price).toFixed(
2
);
this.goodsObj.original_price = Number(parseOriginalPrice);
if (
typeof this.goodsObj.original_price === "number" &&
isNaN(this.goodsObj.original_price)
) {
this.goodsObj.original_price = 0; this.goodsObj.original_price = 0;
return this.$message.error("原价必为数字"); return this.$message.error("原价价格必为数字");
} }
this.goodsObj.original_price = parseOriginalPrice;
}, },
// 审核通过 // 审核通过
...@@ -1104,8 +1117,9 @@ export default { ...@@ -1104,8 +1117,9 @@ export default {
// 审核拒绝 // 审核拒绝
async onDefault () { async onDefault () {
if (!this.rejectReason.reason) if (this.rejectReason.reason != "0" || this.rejectReason.reason === "") {
return this.$message.error("审核驳回时,驳回原因不能为空"); return this.$message.error("审核驳回时,驳回原因不能为空");
}
const query = { const query = {
goods_spu_id: this.goodsObj.goods_spu_id, goods_spu_id: this.goodsObj.goods_spu_id,
rejected_reason: this.rejectReason.reason rejected_reason: this.rejectReason.reason
...@@ -1124,6 +1138,9 @@ export default { ...@@ -1124,6 +1138,9 @@ export default {
// 保存修改信息 // 保存修改信息
async saveDetailMessage () { async saveDetailMessage () {
await this.checkSameName(); // 检验商品名称是否可用 await this.checkSameName(); // 检验商品名称是否可用
if (!this.optionsValue) {
return this.$message.error("请选择商品分类");
}
const query = { const query = {
goods_spu_id: this.goodsObj.goods_spu_id, // 商品id goods_spu_id: this.goodsObj.goods_spu_id, // 商品id
category_1_id: this.optionsValue[0], // 商品一级分类id category_1_id: this.optionsValue[0], // 商品一级分类id
...@@ -1139,20 +1156,17 @@ export default { ...@@ -1139,20 +1156,17 @@ export default {
rule_refund: this.goodsObj.rule_refund, // 退款规则 rule_refund: this.goodsObj.rule_refund, // 退款规则
rule_start_time: this.activeStartTime, // 规则开始时间 rule_start_time: this.activeStartTime, // 规则开始时间
rule_end_time: this.activeEndTime, // 规则结束时间 rule_end_time: this.activeEndTime, // 规则结束时间
inventory_add: this.goodsObj.inventory_rest, // 库存 inventory_add: this.inventoryAdd, // 库存增减
original_price: this.goodsObj.original_price, // 原价 original_price: this.goodsObj.original_price, // 原价
price: this.goodsObj.price, // 现价 price: this.goodsObj.price, // 现价
sub_shop_ids: this.shopIds // 门店id sub_shop_ids: this.shopIds // 门店id
}; };
console.log(query);
// 必填校验 // 必填校验
if (!this.goodsObj.goods_spu_id) { if (!this.goodsObj.goods_spu_id) {
return this.$message.error("未传入商品id"); return this.$message.error("未传入商品id");
} }
if (!query.category_1_id || !query.category_2_id) {
return this.$message.error("请选择商品分类");
}
if (!query.goods_name) { if (!query.goods_name) {
return this.$message.error("请填写商品名称"); return this.$message.error("请填写商品名称");
} }
...@@ -1171,15 +1185,9 @@ export default { ...@@ -1171,15 +1185,9 @@ export default {
if (typeof query.rule_limit !== "number") { if (typeof query.rule_limit !== "number") {
return this.$message.error("单人可购上线只可为数值"); return this.$message.error("单人可购上线只可为数值");
} }
if (!query.rule_desc) {
return this.$message.error("请填写使用规则描述");
}
if (!query.rule_refund) { if (!query.rule_refund) {
return this.$message.error("请填写退款规则"); return this.$message.error("请填写退款规则");
} }
if (query.inventory_add.length === 0) {
return this.$message.error("请填写库存剩余量");
}
if (query.original_price.length === 0) { if (query.original_price.length === 0) {
return this.$message.error("请填写原价(保留两位小数)"); return this.$message.error("请填写原价(保留两位小数)");
} }
......
...@@ -200,6 +200,11 @@ ...@@ -200,6 +200,11 @@
<el-button type="text">下架</el-button> <el-button type="text">下架</el-button>
</template> </template>
</el-popconfirm> </el-popconfirm>
<el-button
@click="goDetail(`DETAIL`,scope.row.goods_spu_id)"
type="text"
>详情</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
......
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