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

商品详情回显和编辑

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