|
@@ -1,13 +1,13 @@
|
|
|
<template>
|
|
|
<div class="wrapper">
|
|
|
- <div class="title">新增商品</div>
|
|
|
+ <div class="title">{{title}}</div>
|
|
|
<el-form class="form" ref="form" :model="form" label-width="80px" :rules="rules">
|
|
|
- <el-form-item class="single" label="商品名:" label-width="100px" prop="title">
|
|
|
+ <el-form-item class="single" label="商品名:" label-width="120px" prop="title">
|
|
|
<el-input class="pr-50" placeholder="请输入" v-model="form.title" maxlength="60" :disabled="isdisable"
|
|
|
show-word-limit>
|
|
|
</el-input>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="类目:" label-width="100px" prop="third_cat_id">
|
|
|
+ <el-form-item label="类目:" label-width="120px" prop="third_cat_id">
|
|
|
<el-select v-model="form.third_cat_id" placeholder="请选择" :disabled="isdisable" clearable filterable>
|
|
|
<el-option v-for="item in categoryList" :key="item.level3" :label="item.level3_name"
|
|
|
:value="item.level3">
|
|
@@ -19,7 +19,7 @@
|
|
|
<el-input placeholder="请输入" :disabled="isdisable" type='number' v-model="form.out_product_id" maxlength="25">
|
|
|
</el-input>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="品牌:" label-width="100px" prop="brand_id">
|
|
|
+ <el-form-item label="品牌:" label-width="120px" prop="brand_id">
|
|
|
<el-select v-model="form.brand_id" :disabled="isdisable" placeholder="请选择" clearable filterable>
|
|
|
<el-option v-for="item in brandList" :key="item.brand_info_id" :label="item.trademark_registrant"
|
|
|
:value="item.brand_info_id">
|
|
@@ -31,17 +31,17 @@
|
|
|
<el-input placeholder="请输入" :disabled="isdisable" type='number' maxlength="25" v-model="form.stock_num">
|
|
|
</el-input>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="售卖价格:" label-width="100px" prop="sale_price">
|
|
|
+ <el-form-item label="售卖价格(分):" label-width="120px" prop="sale_price">
|
|
|
<el-input placeholder="请输入" :disabled="isdisable" type='number' maxlength="25"
|
|
|
v-model="form.sale_price">
|
|
|
</el-input>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="市场价格:" label-width="100px" prop="market_price">
|
|
|
+ <el-form-item label="市场价格(分):" label-width="120px" prop="market_price">
|
|
|
<el-input placeholder="请输入" :disabled="isdisable" type='number' maxlength="25"
|
|
|
v-model="form.market_price">
|
|
|
</el-input>
|
|
|
</el-form-item>
|
|
|
- <el-form-item class="single" label="小程序链接:" label-width="100px" prop="path">
|
|
|
+ <el-form-item class="single" label="小程序链接:" label-width="120px" prop="path">
|
|
|
<el-input class="pr-50" :disabled="isdisable" placeholder="请输入" v-model="form.path" maxlength="100">
|
|
|
</el-input>
|
|
|
</el-form-item>
|
|
@@ -53,24 +53,23 @@
|
|
|
<el-input placeholder="请输入" :disabled="isdisable" maxlength="25">
|
|
|
</el-input>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="三级类目:" v-if="form.third_cat_id=='-1'" label-width="100px"
|
|
|
+ <el-form-item label="三级类目:" v-if="form.third_cat_id=='-1'" label-width="120px"
|
|
|
:rules="[{ required: form.third_cat_id=='-1', message: '请输入必填项', trigger: 'blur' }]">
|
|
|
<el-input placeholder="请输入" :disabled="isdisable" type='number' maxlength="25" v-model="form.third">
|
|
|
</el-input>
|
|
|
</el-form-item>
|
|
|
- <el-form-item class="single" label="商品图片:" label-width="100px" required>
|
|
|
- <upload v-if="updatePic" :disabled="isdisable" ref="upload_goods" :file="goodsList" limitNum="1">
|
|
|
+ <el-form-item class="single" label="商品图片:" label-width="120px" required>
|
|
|
+ <upload v-if="updatePic" acceptType='.jpg, .jpeg, .png' :disabled="isdisable" ref="upload_goods" :file="goodsList" limitNum="1">
|
|
|
</upload>
|
|
|
</el-form-item>
|
|
|
- <el-form-item class="single" label="商品类目图片:" label-width="100px">
|
|
|
- <upload v-if="updatePic" :disabled="isdisable" ref="upload_zizhi" :file="goodszizhiList" limitNum="10">
|
|
|
+ <el-form-item class="single" label="商品资质图片:" label-width="120px">
|
|
|
+ <upload v-if="updatePic" acceptType='.jpg, .jpeg, .png' :disabled="isdisable" ref="upload_zizhi" :file="goodszizhiList" limitNum="10">
|
|
|
</upload>
|
|
|
</el-form-item>
|
|
|
<el-form-item class="commit" v-if="!isdisable">
|
|
|
<el-button class="blackbtn" :loading="loading" @click.native.prevent="commit">提交
|
|
|
</el-button>
|
|
|
</el-form-item>
|
|
|
-
|
|
|
</el-form>
|
|
|
</div>
|
|
|
</template>
|
|
@@ -102,6 +101,7 @@
|
|
|
props: {},
|
|
|
data() {
|
|
|
return {
|
|
|
+ title:'新增商品',
|
|
|
categoryList: [],
|
|
|
brandList: [],
|
|
|
goodsList: [],
|
|
@@ -201,7 +201,7 @@
|
|
|
if (this.outProductId == 0) { //新增
|
|
|
add(params).then(() => {
|
|
|
this.$message.success('添加成功');
|
|
|
- store.commit('REMOVETAB', '新增商品')
|
|
|
+ store.commit('REMOVETAB', '商品信息')
|
|
|
this.$router.go(-1)
|
|
|
}).catch(() => {
|
|
|
this.loading = false
|
|
@@ -210,7 +210,7 @@
|
|
|
params.commodity_id = this.commodity_id
|
|
|
edit(params).then(() => {
|
|
|
this.$message.success('修改成功');
|
|
|
- store.commit('REMOVETAB', '新增商品')
|
|
|
+ store.commit('REMOVETAB', '商品信息')
|
|
|
store.commit('REMOVETAB', '商品详情')
|
|
|
this.$router.push('/goods')
|
|
|
}).catch(() => {
|
|
@@ -220,7 +220,6 @@
|
|
|
|
|
|
}
|
|
|
})
|
|
|
-
|
|
|
},
|
|
|
getDetail() {
|
|
|
if (this.outProductId != 0) {
|
|
@@ -228,21 +227,20 @@
|
|
|
outProductId: this.outProductId
|
|
|
}).then(res => {
|
|
|
this.form.title = res.data.title
|
|
|
- this.form.third_cat_audit = res.data.third_cat_audit==0?-1:1
|
|
|
this.form.out_product_id = res.data.out_product_id
|
|
|
- this.form.has_brand = res.data.has_brand==0?-1:1
|
|
|
this.form.stock_num = res.data.stock_num
|
|
|
this.form.sale_price = res.data.sale_price
|
|
|
this.form.market_price = res.data.market_price
|
|
|
this.form.path = res.data.path
|
|
|
+ this.form.brand_id=res.data.has_brand==0?'-1':res.data.has_brand
|
|
|
this.form.third=res.data.third_cat_audit==0?res.data.third_cat_id:''
|
|
|
- this.form.third_cat_id =res.data.third_cat_id
|
|
|
+ this.form.third_cat_id =res.data.third_cat_audit==0?'-1':res.data.third_cat_id
|
|
|
this.commodity_id = res.data.commodity_id
|
|
|
this.goodsList = [{
|
|
|
url: res.data.thumb_img
|
|
|
}]
|
|
|
this.goodszizhiList = []
|
|
|
- if (res.data.qualificationImgs.length > 0) {
|
|
|
+ if (res.data?.qualificationImgs?.length > 0) {
|
|
|
res.data.qualificationImgs.forEach(element => {
|
|
|
this.goodszizhiList.push({
|
|
|
url: element
|
|
@@ -274,28 +272,46 @@
|
|
|
this.$refs.form.clearValidate()
|
|
|
if (this.$route.params.outProductId) { //新增获取详情
|
|
|
this.outProductId = this.$route.params.outProductId
|
|
|
+ this.title='修改商品'
|
|
|
this.getDetail()
|
|
|
if (this.$route.params.isDisable) {
|
|
|
+ this.title='商品详情'
|
|
|
this.isdisable = true
|
|
|
}
|
|
|
}
|
|
|
if (this.$route.params.isNew) { //新增清空
|
|
|
+ this.title='新增商品'
|
|
|
this.outProductId = 0
|
|
|
- this.form = {
|
|
|
- title: '',
|
|
|
- third_cat_audit: '',
|
|
|
- out_product_id: '',
|
|
|
- has_brand: '',
|
|
|
- stock_num: '',
|
|
|
- sale_price: '',
|
|
|
- market_price: '',
|
|
|
- path: '',
|
|
|
- third_cat_id: '',
|
|
|
- third: '',
|
|
|
- brand_id: '',
|
|
|
+ if(this.$route.params.data){
|
|
|
+ let data=JSON.parse(this.$route.params.data)
|
|
|
+ this.form.title=data.title
|
|
|
+ this.form.out_product_id=data.out_product_id
|
|
|
+ this.form.stock_num=data.stock_num
|
|
|
+ this.form.sale_price=data.sale_price
|
|
|
+ this.form.market_price=data.market_price
|
|
|
+ this.form.path=data.path
|
|
|
+ this.form.third_cat_id=data.third_cat_id
|
|
|
+ this.form.third=data.third
|
|
|
+ this.form.brand_id=data.brand_id
|
|
|
+ this.goodsList=data.goodsList
|
|
|
+ this.goodszizhiList=data.goodszizhiList
|
|
|
+ }else{
|
|
|
+ this.form = {
|
|
|
+ title: '',
|
|
|
+ third_cat_audit: '',
|
|
|
+ out_product_id: '',
|
|
|
+ has_brand: '',
|
|
|
+ stock_num: '',
|
|
|
+ sale_price: '',
|
|
|
+ market_price: '',
|
|
|
+ path: '',
|
|
|
+ third_cat_id: '',
|
|
|
+ third: '',
|
|
|
+ brand_id: '',
|
|
|
+ }
|
|
|
+ this.goodsList = []
|
|
|
+ this.goodszizhiList = []
|
|
|
}
|
|
|
- this.goodsList = []
|
|
|
- this.goodszizhiList = []
|
|
|
//刷新子组件
|
|
|
this.updatePic = false
|
|
|
this.$nextTick(() => {
|
|
@@ -348,11 +364,11 @@
|
|
|
width: 100%;
|
|
|
|
|
|
.el-input {
|
|
|
- width: 875px;
|
|
|
+ width: 855px;
|
|
|
}
|
|
|
|
|
|
.el-select {
|
|
|
- width: 875px;
|
|
|
+ width: 855px;
|
|
|
}
|
|
|
}
|
|
|
|