|
@@ -146,7 +146,7 @@
|
|
placeholder="请选择单位">
|
|
placeholder="请选择单位">
|
|
<el-option
|
|
<el-option
|
|
:label="item.name"
|
|
:label="item.name"
|
|
- :value="item.value"
|
|
|
|
|
|
+ :value="item.name"
|
|
v-for="item in arrProductUnit"
|
|
v-for="item in arrProductUnit"
|
|
:key="item.value"></el-option>
|
|
:key="item.value"></el-option>
|
|
</el-select>
|
|
</el-select>
|
|
@@ -191,7 +191,8 @@
|
|
label="1">现售
|
|
label="1">现售
|
|
</el-radio>
|
|
</el-radio>
|
|
<el-date-picker
|
|
<el-date-picker
|
|
- v-model="value1"
|
|
|
|
|
|
+ :disabled="form.product_sale_at === '0'"
|
|
|
|
+ v-model="product_sale_at"
|
|
type="datetime"
|
|
type="datetime"
|
|
placeholder="选择预售日期时间">
|
|
placeholder="选择预售日期时间">
|
|
</el-date-picker>
|
|
</el-date-picker>
|
|
@@ -209,24 +210,7 @@
|
|
<el-option
|
|
<el-option
|
|
:label="item.name"
|
|
:label="item.name"
|
|
:value="item.value"
|
|
:value="item.value"
|
|
- v-for="item in []"
|
|
|
|
- :key="item.value"></el-option>
|
|
|
|
- </el-select>
|
|
|
|
- </el-form-item>
|
|
|
|
- <el-form-item
|
|
|
|
- prop="product_is_recommend"
|
|
|
|
- :rules="formRules.select"
|
|
|
|
- label="是否推荐:">
|
|
|
|
- <el-select
|
|
|
|
- style="width: 100%;"
|
|
|
|
- v-model="form.product_is_recommend"
|
|
|
|
- filterable
|
|
|
|
- clearable
|
|
|
|
- placeholder="请选择是否推荐">
|
|
|
|
- <el-option
|
|
|
|
- :label="item.name"
|
|
|
|
- :value="item.value"
|
|
|
|
- v-for="item in arrProductIsRecommend"
|
|
|
|
|
|
+ v-for="item in arrProductStatus"
|
|
:key="item.value"></el-option>
|
|
:key="item.value"></el-option>
|
|
</el-select>
|
|
</el-select>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
@@ -269,42 +253,43 @@ export default {
|
|
default: function () {
|
|
default: function () {
|
|
return []
|
|
return []
|
|
}
|
|
}
|
|
|
|
+ },
|
|
|
|
+ arrProductStatus: {
|
|
|
|
+ type: Array,
|
|
|
|
+ default: function () {
|
|
|
|
+ return []
|
|
|
|
+ }
|
|
}
|
|
}
|
|
},
|
|
},
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
dialog: !!this.value,
|
|
dialog: !!this.value,
|
|
form: {
|
|
form: {
|
|
- 'product_title': '测试商品', // 标题
|
|
|
|
|
|
+ 'product_title': '', // 标题
|
|
'product_desc': '', // 商品描述
|
|
'product_desc': '', // 商品描述
|
|
'product_img_url': [], // 商品主图
|
|
'product_img_url': [], // 商品主图
|
|
'product_rotation_img_list': [], // 商品轮播图
|
|
'product_rotation_img_list': [], // 商品轮播图
|
|
'product_detail_img_list': [], // 商品详情图
|
|
'product_detail_img_list': [], // 商品详情图
|
|
'product_category_id': 1,
|
|
'product_category_id': 1,
|
|
- 'product_category_name': '水果', // 分类名称
|
|
|
|
- 'product_brand_id': 1,
|
|
|
|
- 'product_brand_name': '大众', // 品牌名称
|
|
|
|
- 'product_spec': 'xl', // 规格
|
|
|
|
- 'product_unit': '个', // 单位
|
|
|
|
- 'product_all_price': 10000, // 批发价
|
|
|
|
- 'product_price': 9000, // 零售价
|
|
|
|
- 'product_count': 1000, // 库存
|
|
|
|
- 'product_sale_at': '0', // 发售时间(0代表非预售 时间戳代表预售时间)
|
|
|
|
- 'product_status': 0, // 商品状态(0未上架1已上架2审核中3审核未通过)
|
|
|
|
- 'product_is_recommend': 0 // 是否推荐(0否1是)
|
|
|
|
|
|
+ 'product_category_name': '', // 分类名称
|
|
|
|
+ 'product_brand_id': '',
|
|
|
|
+ 'product_brand_name': '', // 品牌名称
|
|
|
|
+ 'product_spec': '', // 规格
|
|
|
|
+ 'product_unit': '', // 单位
|
|
|
|
+ 'product_all_price': '', // 批发价
|
|
|
|
+ 'product_price': '', // 零售价
|
|
|
|
+ 'product_count': '', // 库存
|
|
|
|
+ 'product_sale_at': '0', // 发售时间(0代表非预售 时间戳代表预售时间) todo 现售时间
|
|
|
|
+ 'product_status': '0' // 商品状态 0下架 1上架
|
|
},
|
|
},
|
|
product_img_url: [],
|
|
product_img_url: [],
|
|
product_rotation_img_list: [],
|
|
product_rotation_img_list: [],
|
|
product_detail_img_list: [],
|
|
product_detail_img_list: [],
|
|
- booLock: false,
|
|
|
|
- radio: '1',
|
|
|
|
- value1: ''
|
|
|
|
|
|
+ product_sale_at: '',
|
|
|
|
+ booLock: false
|
|
}
|
|
}
|
|
},
|
|
},
|
|
computed: {
|
|
computed: {
|
|
- arrProductIsRecommend() {
|
|
|
|
- return this.$store.state.common.arrProductIsRecommend
|
|
|
|
- },
|
|
|
|
arrCategoryList() {
|
|
arrCategoryList() {
|
|
return this.$store.state.common.arrCategoryList
|
|
return this.$store.state.common.arrCategoryList
|
|
},
|
|
},
|
|
@@ -349,11 +334,17 @@ export default {
|
|
this.$refs.form.validate(async valid => {
|
|
this.$refs.form.validate(async valid => {
|
|
if (valid) {
|
|
if (valid) {
|
|
const formData = JSON.parse(JSON.stringify(this.form))
|
|
const formData = JSON.parse(JSON.stringify(this.form))
|
|
|
|
+ const productCategoryNameIndex = this.arrCategoryList.findIndex(item => item.value === formData.product_category_id)
|
|
|
|
+ const productBrandNamedIndex = this.arrBrandList.findIndex(item => item.value === formData.product_brand_id)
|
|
const postData = {
|
|
const postData = {
|
|
...formData,
|
|
...formData,
|
|
product_img_url: formData.product_img_url[0],
|
|
product_img_url: formData.product_img_url[0],
|
|
- product_rotation_img_list: JSON.stringify(formData.product_rotation_img_list),
|
|
|
|
- product_detail_img_list: JSON.stringify(formData.product_detail_img_list)
|
|
|
|
|
|
+ product_rotation_img_list: formData.product_rotation_img_list,
|
|
|
|
+ product_detail_img_list: formData.product_detail_img_list,
|
|
|
|
+ product_category_name: productCategoryNameIndex > -1 ? this.arrCategoryList[productCategoryNameIndex].name : '',
|
|
|
|
+ product_brand_name: productBrandNamedIndex > -1 ? this.arrBrandList[productBrandNamedIndex].name : '',
|
|
|
|
+ product_all_price: yuan2Fen(formData.product_all_price),
|
|
|
|
+ product_price: yuan2Fen(formData.product_price)
|
|
}
|
|
}
|
|
this.booLock = true
|
|
this.booLock = true
|
|
const data = await this.$fetch(url, postData)
|
|
const data = await this.$fetch(url, postData)
|
|
@@ -382,28 +373,38 @@ export default {
|
|
url: this.exData.product_img_url
|
|
url: this.exData.product_img_url
|
|
}
|
|
}
|
|
]
|
|
]
|
|
- this.product_rotation_img_list = [
|
|
|
|
- {
|
|
|
|
|
|
+ this.product_rotation_img_list = this.exData.product_rotation_img_list.map(item => {
|
|
|
|
+ return {
|
|
name: '',
|
|
name: '',
|
|
- url: this.exData.product_rotation_img_list
|
|
|
|
|
|
+ url: item
|
|
}
|
|
}
|
|
- ]
|
|
|
|
- this.product_detail_img_list = [
|
|
|
|
- {
|
|
|
|
|
|
+ })
|
|
|
|
+ this.product_detail_img_list = this.exData.product_detail_img_list.map(item => {
|
|
|
|
+ return {
|
|
name: '',
|
|
name: '',
|
|
- url: this.exData.product_detail_img_list
|
|
|
|
|
|
+ url: item
|
|
}
|
|
}
|
|
- ]
|
|
|
|
|
|
+ })
|
|
for (const key in this.exData) {
|
|
for (const key in this.exData) {
|
|
if (this.form.hasOwnProperty(key)) {
|
|
if (this.form.hasOwnProperty(key)) {
|
|
let value = this.exData[key]
|
|
let value = this.exData[key]
|
|
if ((Array.isArray(value) && value.length >= 1) || (Object.prototype.toString.call(value) === '[object Object]') || (typeof value === 'string' && value) || typeof value === 'number') {
|
|
if ((Array.isArray(value) && value.length >= 1) || (Object.prototype.toString.call(value) === '[object Object]') || (typeof value === 'string' && value) || typeof value === 'number') {
|
|
- if (key === 'product_img_url' || key === 'product_rotation_img_list' || key === 'product_detail_img_list') {
|
|
|
|
|
|
+ if (key === 'product_img_url') {
|
|
value = [value]
|
|
value = [value]
|
|
}
|
|
}
|
|
if (key === 'product_all_price' || key === 'product_price') {
|
|
if (key === 'product_all_price' || key === 'product_price') {
|
|
value = fen2Yuan(value)
|
|
value = fen2Yuan(value)
|
|
}
|
|
}
|
|
|
|
+ if (key === 'product_status' || key === 'product_count') {
|
|
|
|
+ value = value + ''
|
|
|
|
+ }
|
|
|
|
+ if (key === 'product_sale_at') {
|
|
|
|
+ if (value === 0) {
|
|
|
|
+ value = value + ''
|
|
|
|
+ } else {
|
|
|
|
+ value = '1'
|
|
|
|
+ }
|
|
|
|
+ }
|
|
this.$set(this.form, key, value)
|
|
this.$set(this.form, key, value)
|
|
}
|
|
}
|
|
}
|
|
}
|