提交 d7bb2b7b authored 作者: huaxinzhu's avatar huaxinzhu

商品详情回显和编辑

上级 d6d9012e
......@@ -75,6 +75,24 @@ export function addGoods(data) {
})
}
// 查询商品详情
export function getGoodsNew(data) {
return request({
url: '/system/goodsNew/info',
method: 'post',
data: data
})
}
// 商品编辑 new
export function updateGoodsNew(data) {
return request({
url: '/system/goodsNew/goodsEdit',
method: 'post',
data: data
})
}
// 修改goods
export function updateGoods(data) {
return request({
......
......@@ -79,6 +79,8 @@
},
mounted() {
this.getFreightData();
console.log('售后数据:',this.goodsaftersale);
this.goodsAfterSaleForm = this.goodsaftersale;
},
methods: {
// 运费模板
......
......@@ -76,6 +76,9 @@
},
components: {},
mounted() {
this.goodsDeForm = this.imgdata;
console.log("详情:",this.imgdata);
},
watch: {},
methods: {
......
......@@ -139,6 +139,7 @@
areaOptions: [], // 地址 省
brandOptions: [], // 商品品牌
goodsInfoForm: {
goods_id: 0,
categoryStr: '', // 商品分类 地址拼接
categoryList: [], // 商品分类 id集合的数组
goods_des: '', // 关键词
......@@ -210,22 +211,25 @@
// },
},
created() {
},
mounted() {
//深拷贝一份最开始的数据,为初始化准备
this.goodsInfoDataClone = this.deepClone(this.goodsinfodata);
this.goodsInfoForm.categoryStr = this.goodsinfodata.categoryStr;
this.goodsInfoForm.categoryList = this.goodsinfodata.categoryList;
// console.log("父组件传过来的",this.goodsinfodata)
// console.log("1111",this.goodsInfoForm)
//this.goodsInfoDataClone = this.deepClone(this.goodsinfodata);
this.goodsInfoForm = this.goodsinfodata;
if( this.goodsInfoForm.imgs.length > 0 ) {
this.goodsInfoForm.imgs.forEach( (item )=> {
let objImg = { 'url': '' }
objImg.url = item;
this.goodsImgFileList.push(objImg);
})
}
//console.log("tup",this.goodsImgFileList)
// 获取 省
this.getArea();
// 获取 商品品牌
this.getBrands();
},
mounted() {
// this.getCategory();
// this.getFreight();
// this.getBrands();
},
methods: {
// 获取 省
......
......@@ -113,11 +113,15 @@ export default {
this.$set(this.specsGroup.spec_value,this.specsGroup.spec_value.length,this.speParamName);
this.speData = [];
this.$set(this.speData,this.speData.length,this.specsGroup);
//console.log(71,this.specsGroup.spec_value);
},
mounted() {
/** 先获取 本地存储的localStorage **/
this.getLocalSpecNameOption();
// this.speData = [];
// this.$set(this.speData,this.speData.length,this.specsGroup);
// console.log(123,this.specificationsdata)
this.speData = this.specificationsdata;
this.$forceUpdate()
},
watch:{
// "speData.specsGroup": {
......
<template>
<div class="app-container">
<div class="goods-all">
<!-- 选择商品类目 start -->
<el-card class="box-card" v-if="!isShowGoodsDetails">
<el-card class="good-all-type" v-if="!isShowGoodsDetails">
<div slot="header" class="clearfix">
<p class="card-header-title"><span class="blue-block-goods"></span>确认商品所在目录</p>
</div>
......@@ -77,7 +77,7 @@
<script>
import { getAreaList } from '@/api/module/retreat/address';
import { NewGetCategory,addGoods } from '@/api/module/goods';
import { NewGetCategory,addGoods,getGoodsNew,updateGoodsNew } from '@/api/module/goods';
import Goodsinfomation from './components/goodsinfomation';
import GoodsSpecifications from './components/goodsspecifications';
import GoodsParameter from './components/goodsparameter';
......@@ -93,6 +93,12 @@
Goodsimg,
Goodsaftersale,
},
props: {
option: {
type: Number,
required: true
}
},
data() {
return {
loading: false,
......@@ -119,19 +125,26 @@
],
/* 商品信息 */
goodsinfodata: {
orgGoodsInfoForm: {},
// orgGoodsInfoForm: {},
categoryList: [],
categoryStr: ''
},
/* 商品规格 */
specificationsdata: [],
/* 商品售价 */
parameterdata: {},
parameterdata: {
},
/* 商品详情 */
imgdata: {},
imgdata: {
description: ''
},
/* 售后及服务 */
goodsaftersale: {
stags: [],
freight_id: 310,
delay_compensate: 24,
aftersale_time: 7
},
goodsAllData: {
submit: 0,
......@@ -141,7 +154,68 @@
},
created() {
// option 商品的id
if( this.option && this.option !== 0 ) {
let data = { goodsId: this.option};
getGoodsNew(data).then(res => {
console.log("编辑接口返回", res);
if(res.data) {
this.isShowGoodsDetails = true;
// 商品信息
this.goodsinfodata = {
goods_id: res.data.goods_id,
categoryStr: '', // 商品分类 地址拼接
categoryList: [], // 商品分类 id集合的数组
goods_des: res.data.goods_des, // 关键词
goods_name: res.data.goods_name, // 商品标题
category_id: res.data.category_id,
producing_area: res.data.producing_area, // 产地
deliver_area: res.data.deliver_area, // 发货地
unit: res.data.unit, // 单位
goods_brand: res.data.goods_brand, // 品牌
web_url: res.data.web_url, // 外部链接
out_goods_id: res.data.out_goods_id, // 商品编码
imgs: res.data.imgs // 商品图片
}
this.goodsinfodata.categoryStr = res.data.category_first_name + '/' + res.data.category_first_name + '/' + res.data.category_three_name;
let arr = [];
arr[0] = res.data.category_first_id;
arr[0] = res.data.category_second_id;
arr[0] = res.data.category_three_id;
this.goodsinfodata.categoryList = arr;
// 商品规格, 售价由规格决定
if(res.data.specs && res.data.specs.length > 0) {
this.specificationsdata = res.data.specs;
}
// 商品详情
this.imgdata.description = res.data.description;
//this.goodsinfodata = res.data;
//this.imgdata = res.data.description;
//this.goodsaftersale = res.data;
// 售后服务
// stags: [],
// freight_id: 310,
// delay_compensate: 24,
// aftersale_time: 7
this.goodsaftersale.freight_id = res.data.freight_id;
this.goodsaftersale.delay_compensate = res.data.delay_compensate;
this.goodsaftersale.aftersale_time = res.data.aftersale_time;
let stagArr = [];
if( res.data.stags.indexOf(',') > -1 ) {
stagArr = res.data.stags.split(',');
stagArr.forEach(item => {
if (item) {
this.goodsaftersale.stags.push(Number(item));
}
})
}
}
});
}
},
mounted() {
......@@ -257,7 +331,6 @@
},
// 添加商品后,下一步 操作
nextStep() {
// debugger
// 注意数据格式 [1,2,3] 数组,且里面是数字类型
let ssqLabelList = this.$refs['ssqCascader'].getCheckedNodes()[0].pathLabels;
this.goodsinfodata.categoryList = this.SSQList;
......@@ -273,6 +346,14 @@
// },
//
save() {
// let spxxDataId = this.$refs.goodsInfo.goodsInfoForm.goods_id;
//
// if(!spxxDataId) {
//
// }
// 此处变量 有顺序 校验时,电梯至某处
// 商品信息 是否填写完整
let isGoodsInfoMsg = this.$refs['goodsInfo'].validateGoodsInfoForm();
......@@ -395,9 +476,17 @@
console.log('最终数据:',this.goodsAllData);
addGoods( this.goodsAllData ).then( res=> {
console.log("返回结果",res);
});
if(this.goodsAllData.goods_id) {
updateGoodsNew(this.goodsAllData).then(res=> {
console.log("修改结果:",res);
});
}else {
addGoods( this.goodsAllData ).then( res=> {
console.log("返回结果",res);
});
}
},
......@@ -485,6 +574,21 @@
</script>
<style scoped lang="scss" type="text/css">
.goods-all {
height: 100%;
padding: 20px;
}
/deep/.goods-all .good-all-type {
height: 100%;
}
/deep/.goods-all .el-card .el-card__body{
height:100%;
overflow: auto;
}
p {
margin: 0;
padding: 0;
......
......@@ -113,7 +113,7 @@
</template>
</el-table-column>
<el-table-column label="商品编号" align="center" prop="goods_id"/>
<el-table-column label="商品名称" align="center" prop="goods_brand"/>
<el-table-column label="商品名称" align="center" prop="goods_name"/>
<el-table-column label="协议价" align="center" prop="">
<template slot-scope="scope">
{{scope.row.js_price/100}}
......@@ -217,7 +217,7 @@
/>
<!-- 商品编辑-->
<el-dialog title="编辑商品" :visible.sync="editisOpen" v-if="editisOpen" width="70%" class="freightTemplate-add">
<editGood :option="form" @closeIndexbtn="closeDialog" ></editGood>
<editGood :option="goodsid" @closeIndexbtn="closeDialog" ></editGood>
</el-dialog>
<el-dialog title="商品详情" :visible.sync="isOpen" center v-if="isOpen" width="70%" class="freightTemplate-add" :close-on-click-modal="false">
<goodDetail :goods-id="goodDetails" @closeIndexbtn="closeDialog" ></goodDetail>
......@@ -289,7 +289,7 @@
modified: null,
},
// 表单参数
form: {},
goodsid: 0,
// 表单校验
rules: {
name: [
......@@ -408,7 +408,7 @@
delgoodsStatus(data).then(res=>{
if(res.code==1){
done()
this.$message({
type: 'success',
message: '操作成功!'
......@@ -421,7 +421,7 @@
message: res.message
});
}
})
} else {
done();
......@@ -493,8 +493,9 @@
});
},
editgoods(){//商品编辑
editgoods(row){//商品编辑
this.editisOpen = true
this.goodsid = Number(row.goods_id);
},
lookdetail(row){//预览商品详情
this.isOpen = true
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论