You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
349 lines
13 KiB
349 lines
13 KiB
<template>
|
|
<div>
|
|
|
|
<div class="tab-header webtop">
|
|
<!-- 标题 -->
|
|
<div>商品信息</div>
|
|
<!-- start 添加修改按钮 -->
|
|
<div>
|
|
<el-button type="primary" size="small" :disabled="submitdisabled" @click="saveOrUpdate">保存</el-button>
|
|
<el-button type="info" size="small" @click="handleReturn()">关闭</el-button>
|
|
</div>
|
|
<!-- end 添加修改按钮 -->
|
|
<!-- end 详情按钮 -->
|
|
</div>
|
|
|
|
<div class="listconadd">
|
|
|
|
<el-card class="box-card">
|
|
<div class="item">
|
|
<span class="item_text">选择菜窖分类:</span>
|
|
<el-select v-model="formobj.brandId" placeholder="请选择菜窖分类" class="item_input"
|
|
@change="selectBrandChange">
|
|
<el-option v-for="item in brandList" :key="item.id" :label="item.name" :value="item.id" />
|
|
</el-select>
|
|
</div>
|
|
<div class="item">
|
|
<span class="item_text">选择商品分类:</span>
|
|
<el-select v-model="formobj.categoryId" placeholder="请选择商品分类" class="item_input"
|
|
@change="selectCateChange">
|
|
<el-option v-for="item in cateList" :key="item.id" :label="item.name" :value="item.id" />
|
|
</el-select>
|
|
</div>
|
|
<div class="item">
|
|
<span class="item_text">名称:</span>
|
|
<el-input v-model="formobj.name" placeholder="" class="item_input" clearable />
|
|
</div>
|
|
<div class="item">
|
|
<span class="item_text">编码:</span>
|
|
<el-input v-model="formobj.code" placeholder="" class="item_input" clearable
|
|
oninput="value=value.replace(/[^A-Za-z0-9]/g, '')" />
|
|
</div>
|
|
<div class="item">
|
|
<span class="item_text">条码:</span>
|
|
<el-input v-model="formobj.barcode" placeholder="" class="item_input" clearable
|
|
oninput="value=value.replace(/[^0-9]/g,'')" />
|
|
</div>
|
|
<div class="item">
|
|
<span class="item_text">包装单价:</span>
|
|
<el-input v-model="formobj.price" placeholder="" class="item_input" clearable
|
|
oninput="value=value.replace(/[^\d.]/g, '').replace(/\.{2,}/g, '.').replace('.', '$#$').replace(/\./g, '').replace('$#$', '.').replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3').replace(/^\./g, '')" />
|
|
</div>
|
|
<!-- <div class="item">
|
|
<span class="item_text">阶梯重量(斤):</span>
|
|
<el-input v-model="formobj.stepWeight" placeholder="" class="item_input" clearable
|
|
oninput="value=value.replace(/[^0-9]/g,'')" />
|
|
</div>
|
|
<div class="item">
|
|
<span class="item_text">阶梯价格 (元/斤):</span>
|
|
<el-input v-model="formobj.stepPrice" placeholder="" class="item_input" clearable
|
|
oninput="value=value.replace(/[^\d.]/g, '').replace(/\.{2,}/g, '.').replace('.', '$#$').replace(/\./g, '').replace('$#$', '.').replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3').replace(/^\./g, '')" />
|
|
</div> -->
|
|
<div class="item">
|
|
<span class="item_text">金额单位:</span>
|
|
<el-input v-model="formobj.specificationUnit" placeholder="例如:元" class="item_input" clearable />
|
|
</div>
|
|
<div class="item">
|
|
<span class="item_text">单价:</span>
|
|
<el-input v-model="formobj.weight" placeholder="例如:30" class="item_input" clearable
|
|
oninput="value=value.replace(/[^\d.]/g, '').replace(/\.{2,}/g, '.').replace('.', '$#$').replace(/\./g, '').replace('$#$', '.').replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3').replace(/^\./g, '')" />
|
|
</div>
|
|
<div class="item">
|
|
<span class="item_text">基础单位:</span>
|
|
<el-input v-model="formobj.unitName" placeholder="例如:份" class="item_input" clearable />
|
|
</div>
|
|
<div class="item">
|
|
<span class="item_text">规格描述:</span>
|
|
<el-input v-model="formobj.remarks" placeholder="例如:一份30斤" class="item_input" clearable />
|
|
</div>
|
|
<!-- <div class="item">
|
|
<span class="item_text">提货截止日:</span>
|
|
<el-date-picker v-model="formobj.periodValidity" type="date" class="item_input"
|
|
value-format="yyyy-MM-dd" placeholder="选择日期">
|
|
</el-date-picker>
|
|
</div> -->
|
|
<div class="item">
|
|
<span class="item_text">商品简介:</span>
|
|
<el-input v-model="formobj.content" placeholder="商品简介" class="item_input" clearable />
|
|
</div>
|
|
<div class="item">
|
|
<span class="item_text">商品排序:</span>
|
|
<el-input v-model="formobj.sort" placeholder="商品排序" class="item_input" clearable
|
|
oninput="value=value.replace(/[^0-9]/g,'')" />
|
|
</div>
|
|
|
|
<div class="item" style="margin-bottom: 100px;margin-top: 100px;">
|
|
<span class="item_text">图片:</span>
|
|
<upload ref="uploadImg2" v-model="imgList" style="margin-top: 20px;" class="item_input" :limit="1"
|
|
bucket="map" :class="{ hide: hideUploadBtn }" :upload-data="{ type: '0001' }"
|
|
@change="backData" />
|
|
</div>
|
|
|
|
<div>
|
|
<span class="item_text">商品详情:</span>
|
|
<editor :height="300" :min-height="100" :value="formobj.appContent" @input="editinput" />
|
|
</div>
|
|
|
|
</el-card>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import req from '@/api/commodity/commodity.js'
|
|
import upload from '@/components/uploadFile/upload_yanchejianchaTuBiao.vue'
|
|
import Editor from '@/components/Editor'
|
|
import reqMall from '@/api/adminmallapi.js'
|
|
|
|
export default {
|
|
components: {
|
|
upload,
|
|
Editor
|
|
},
|
|
data() {
|
|
return {
|
|
imgList: [
|
|
|
|
],
|
|
submitdisabled: false,
|
|
formobj: {
|
|
sid: '',
|
|
name: '',
|
|
code: '',
|
|
barcode: '',
|
|
price: '',
|
|
stepWeight: '',
|
|
stepPrice: '',
|
|
unitName: '份',
|
|
specificationUnit: '元',
|
|
weight: '',
|
|
remarks: '',
|
|
content: '',
|
|
sort: '',
|
|
picUrl: '',
|
|
brandId: '',
|
|
brandName: '',
|
|
categoryId: '',
|
|
categoryName: '',
|
|
periodValidity: "2099-12-31"
|
|
},
|
|
brandList: [],
|
|
cateList: [],
|
|
hideUploadBtn: false
|
|
}
|
|
},
|
|
created() {
|
|
this.initData()
|
|
},
|
|
methods: {
|
|
initData() {
|
|
reqMall.listAllBrand().then(resp => {
|
|
this.brandList = resp.data
|
|
})
|
|
reqMall.listAllCategory().then(resp => {
|
|
this.cateList = resp.data
|
|
})
|
|
},
|
|
backData(value) {
|
|
console.log('backData》》》》', value)
|
|
console.log('imgList', this.imgList)
|
|
|
|
if (this.imgList.length > 0) {
|
|
this.formobj.picUrl = this.imgList[0].url
|
|
} else {
|
|
this.formobj.picUrl = ''
|
|
}
|
|
|
|
this.hideUploadBtn = this.imgList.length != 0
|
|
console.log('this.hideUploadBtn', this.hideUploadBtn)
|
|
},
|
|
|
|
saveOrUpdate() {
|
|
console.log('>>>>>>>>>saveOrUpdate', this.formobj)
|
|
req.saveGoods(this.formobj)
|
|
.then(resp => {
|
|
if (resp.success) {
|
|
this.$message({
|
|
showClose: true,
|
|
type: 'success',
|
|
message: resp.msg
|
|
})
|
|
this.handleReturn('true')
|
|
} else {
|
|
// 根据resp.code进行异常情况处理
|
|
}
|
|
})
|
|
.catch(() => {})
|
|
},
|
|
handleReturn(isreload) {
|
|
if (isreload === 'true') this.$emit('reloadlist')
|
|
this.imgList = []
|
|
this.hideUploadBtn = true
|
|
this.formobj = {
|
|
sid: '',
|
|
name: '',
|
|
code: '',
|
|
barcode: '',
|
|
price: '',
|
|
stepWeight: '',
|
|
stepPrice: '',
|
|
unitName: '份',
|
|
specificationUnit: '元',
|
|
weight: '',
|
|
remarks: '',
|
|
content: '',
|
|
sort: '',
|
|
picUrl: '',
|
|
appContent: '',
|
|
periodValidity: ""
|
|
}
|
|
this.$emit('doback')
|
|
},
|
|
showAdd() {
|
|
console.log(this.imgList, 88888888)
|
|
this.hideUploadBtn = this.imgList.length != 0
|
|
},
|
|
showEdit(row) {
|
|
req.goodsInit(row.sid)
|
|
.then(resp => {
|
|
if (resp.success) {
|
|
this.formobj = resp.data
|
|
this.imgList = []
|
|
if (resp.data.picUrl != '') {
|
|
this.imgList.push({
|
|
url: resp.data.picUrl
|
|
})
|
|
}
|
|
|
|
this.hideUploadBtn = this.imgList.length != 0
|
|
console.log('this.hideUploadBtn', this.hideUploadBtn)
|
|
}
|
|
})
|
|
.catch(e => {
|
|
this.formobj = row
|
|
this.imgList = []
|
|
// if (resp.data.picUrl != '') {
|
|
// this.imgList.push({
|
|
// url: formobj.picUrl
|
|
// })
|
|
// }
|
|
|
|
// this.hideUploadBtn = this.imgList.length != 0
|
|
console.log('this.hideUploadBtn', this.hideUploadBtn)
|
|
})
|
|
},
|
|
editinput(text) {
|
|
this.formobj.appContent = text
|
|
},
|
|
selectBrandChange(val) {
|
|
for (var i = 0; i < this.brandList.length; i++) {
|
|
if (val === this.brandList[i].id) {
|
|
this.formobj.brandName = this.brandList[i].name
|
|
break
|
|
}
|
|
}
|
|
},
|
|
selectCateChange(val) {
|
|
for (var i = 0; i < this.cateList.length; i++) {
|
|
if (val === this.cateList[i].id) {
|
|
this.formobj.categoryName = this.cateList[i].name
|
|
break
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
<style lang="scss" scoped>
|
|
// 隐藏上传组件
|
|
|
|
::v-deep .hide {
|
|
.el-upload--picture-card {
|
|
display: none !important;
|
|
}
|
|
}
|
|
|
|
.box-card {
|
|
margin-left: 60px;
|
|
margin-right: 60px;
|
|
min-width: 70%;
|
|
margin-top: 20px;
|
|
|
|
.item {
|
|
display: flex;
|
|
flex-direction: row;
|
|
align-items: center;
|
|
margin-top: 15px;
|
|
height: 40px;
|
|
line-height: 40px;
|
|
|
|
.item_text {
|
|
flex: 0.8;
|
|
font-size: 18px;
|
|
text-align: right;
|
|
}
|
|
|
|
.item_input {
|
|
flex: 4;
|
|
font-size: 16px;
|
|
margin-left: 10px;
|
|
margin-right: 80px;
|
|
}
|
|
|
|
.item_left_input {
|
|
width: 20%;
|
|
}
|
|
|
|
.item_left_text {
|
|
height: 30px;
|
|
margin-left: 20px;
|
|
line-height: 30px;
|
|
color: #018AD2;
|
|
padding: 0px 15px;
|
|
border: 1.5px solid #018AD2;
|
|
border-radius: 5px;
|
|
|
|
}
|
|
|
|
.item_right {
|
|
flex: 1;
|
|
justify-items: center;
|
|
|
|
.item_right_list_text {
|
|
font-size: 16px;
|
|
}
|
|
|
|
.item_right_list_delect {
|
|
color: #5E94FF;
|
|
margin-left: 20px;
|
|
font-size: 16px;
|
|
text-decoration: underline;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
</style>
|