|
@@ -15,7 +15,7 @@
|
|
|
<!-- 搜索类型 -->
|
|
|
<el-form :inline="true" class="searchForm" v-model.trim="searchForm">
|
|
|
<el-form-item>
|
|
|
- <el-input v-model.trim="searchForm.search" placeholder="货号,商品名称,别称,备查货号"></el-input>
|
|
|
+ <el-input v-model.trim="searchForm.search" placeholder="商品编号/货号/商品名称"></el-input>
|
|
|
</el-form-item>
|
|
|
<el-form-item>
|
|
|
<el-select v-model.trim="searchForm.type" placeholder="商品类型">
|
|
@@ -28,7 +28,7 @@
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
<el-form-item>
|
|
|
- <el-select v-model.trim="searchForm.status" placeholder="是否是组合商品">
|
|
|
+ <el-select v-model.trim="searchForm.groupGoods" placeholder="是否是组合商品">
|
|
|
<el-option label="是" value="1"></el-option>
|
|
|
<el-option label="否" value="0"></el-option>
|
|
|
</el-select>
|
|
@@ -137,7 +137,7 @@
|
|
|
<el-input placeholder="请输入商品名称" type="text" :disabled="!isAdd" v-model.trim="form.name"></el-input>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="货号" prop="sn" :label-width="formLabelWidth">
|
|
|
- <el-input placeholder="请输入货号户" type="text" :disabled="!isAdd" v-model.trim="form.sn"></el-input>
|
|
|
+ <el-input placeholder="请输入货号" type="text" :disabled="!isAdd" v-model.trim="form.sn"></el-input>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="品牌" prop="brand" :label-width="formLabelWidth">
|
|
|
<el-input v-model.trim="form.brand" placeholder="请输入品牌"></el-input>
|
|
@@ -160,8 +160,8 @@
|
|
|
<div v-for="(goodsList, index) in form.goodsList" :key="index">
|
|
|
<el-form-item :label="'商品' + (index + 1)" :label-width="formLabelWidth" style="display: inline-block;" :prop="'goodsList.' + index + '.id'"
|
|
|
:rules="[{ required: true, message: '请选择商品', trigger: 'change' }]">
|
|
|
- <el-select v-model.trim="goodsList.id" :disabled="!isAdd" placeholder="请选择商品">
|
|
|
- <el-option v-for="(item,index) in goodsTree" :key="index" :label="item.name" :value="item.id"></el-option>
|
|
|
+ <el-select v-model.trim="goodsList.id" :disabled="!isAdd" @change="onGoodsChange" placeholder="请选择商品">
|
|
|
+ <el-option v-for="(item,index) in selectGoodsList" :key="index" :disabled="item.disabled" :label="item.name" :value="item.id"></el-option>
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
<el-button icon="el-icon-minus" :disabled="!isAdd" v-if="form.goodsList.length > 1" @click.prevent="removeGoodsList(goodsList)"
|
|
@@ -215,6 +215,7 @@
|
|
|
goodsUpdate,
|
|
|
goodsDelete
|
|
|
} from '@/api/businessManager'
|
|
|
+ import cleanDeep from 'clean-deep'
|
|
|
import store from '@/store'
|
|
|
import Tooltip from '@/components/Tooltip/index'
|
|
|
import {
|
|
@@ -263,7 +264,7 @@
|
|
|
orderDate: null,
|
|
|
searchForm: {
|
|
|
search: null,
|
|
|
- status: null,
|
|
|
+ groupGoods: null,
|
|
|
type: null,
|
|
|
goodsCategoryId: null,
|
|
|
startTime: null,
|
|
@@ -415,7 +416,8 @@
|
|
|
message: '请输入商品详情',
|
|
|
trigger: 'blur'
|
|
|
}]
|
|
|
- }
|
|
|
+ },
|
|
|
+ selectGoodsList: []
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
@@ -438,6 +440,7 @@
|
|
|
JSON.parse(this.$route.query.pageInfo);
|
|
|
}
|
|
|
this.getList()
|
|
|
+ this.getAllGoodsList()
|
|
|
this.getCategory()
|
|
|
},
|
|
|
getCategory() {
|
|
@@ -509,10 +512,21 @@
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
+ getAllGoodsList() { // 获取所有商品
|
|
|
+ goodsQuery({
|
|
|
+ rows: 9999,
|
|
|
+ page: 1,
|
|
|
+ status: 1
|
|
|
+ }).then(res => {
|
|
|
+ if (res.code == 200 && res.data) {
|
|
|
+ this.selectGoodsList = res.data.rows
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
onReset() { // 重置
|
|
|
this.searchForm = {
|
|
|
search: null,
|
|
|
- status: null,
|
|
|
+ groupGoods: null,
|
|
|
type: null,
|
|
|
goodsCategoryId: null,
|
|
|
startTime: null,
|
|
@@ -576,35 +590,72 @@
|
|
|
// 关闭弹窗重置验证
|
|
|
this.$refs[formName].resetFields();
|
|
|
},
|
|
|
+ onGoodsChange() {
|
|
|
+ let selectGoodsList = this.selectGoodsList
|
|
|
+ let goodsList = this.form.goodsList
|
|
|
+ let tempIds = []
|
|
|
+ goodsList.forEach(item => {
|
|
|
+ if(item.id) {
|
|
|
+ tempIds.push(item.id)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ selectGoodsList.forEach(item => {
|
|
|
+ if(tempIds.includes(item.id)) {
|
|
|
+ item.disabled = true
|
|
|
+ } else {
|
|
|
+ item.disabled = false
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ this.calcPrice()
|
|
|
+ },
|
|
|
removeGoodsList(item) {
|
|
|
+ let tempId = item.id
|
|
|
+ let selectGoodsList = this.selectGoodsList
|
|
|
+ selectGoodsList.forEach(item => {
|
|
|
+ if(item.id == tempId) {
|
|
|
+ item.disabled = false
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
const index = this.form.goodsList.indexOf(item)
|
|
|
if (index !== -1) {
|
|
|
this.form.goodsList.splice(index, 1)
|
|
|
}
|
|
|
+
|
|
|
+ this.calcPrice()
|
|
|
},
|
|
|
addGoodsList() {
|
|
|
this.form.goodsList.push({
|
|
|
- id: null,
|
|
|
- number: null
|
|
|
+ id: null
|
|
|
})
|
|
|
},
|
|
|
onShopSubmit(formName) {
|
|
|
this.$refs[formName].validate((valid) => {
|
|
|
if (valid) {
|
|
|
console.log(this.form)
|
|
|
- // if (this.pageType == 'create') {
|
|
|
- // if (this.form.id) { // 判断有没有Id,如果有则删除
|
|
|
- // delete this.form.id
|
|
|
- // }
|
|
|
- // this.form.status = 'YES' // 默认上架
|
|
|
- // goodsAdd(this.form).then(res => {
|
|
|
- // this.messageTips('添加', res)
|
|
|
- // })
|
|
|
- // } else if (this.pageType == 'update') {
|
|
|
- // goodsUpdate(this.form).then(res => {
|
|
|
- // this.messageTips('修改', res)
|
|
|
- // })
|
|
|
- // }
|
|
|
+ let form = Object.assign({}, this.form)
|
|
|
+ let tempIds = []
|
|
|
+ form.goodsList.forEach(item => {
|
|
|
+ if(item.id) {
|
|
|
+ tempIds.push(item.id)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ form.complementGoodsIdList = tempIds.join(',')
|
|
|
+ form.goodsList = null
|
|
|
+ if (this.isAdd) {
|
|
|
+ if (this.form.id) { // 判断有没有Id,如果有则删除
|
|
|
+ delete this.form.id
|
|
|
+ }
|
|
|
+ form.status = 'YES' // 默认上架
|
|
|
+ goodsAdd(cleanDeep(form)).then(res => {
|
|
|
+ this.messageTips('添加', res)
|
|
|
+ })
|
|
|
+ } else if (this.pageType == 'update') {
|
|
|
+ goodsUpdate(cleanDeep(form)).then(res => {
|
|
|
+ this.messageTips('修改', res)
|
|
|
+ })
|
|
|
+ }
|
|
|
} else {
|
|
|
return false
|
|
|
}
|
|
@@ -614,10 +665,33 @@
|
|
|
if (res.code == 200) {
|
|
|
this.$message.success(title + '成功')
|
|
|
this.getList()
|
|
|
+ this.routeShopStatus = false
|
|
|
} else {
|
|
|
this.$message.error(res.msg)
|
|
|
}
|
|
|
},
|
|
|
+ calcPrice() {
|
|
|
+ let selectGoodsList = this.selectGoodsList
|
|
|
+ let form = this.form
|
|
|
+ let goodsList = form.goodsList
|
|
|
+ let tempIds = []
|
|
|
+ goodsList.forEach(item => {
|
|
|
+ if(item.id) {
|
|
|
+ tempIds.push(item.id)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ let groupPurchasePrice = 0,
|
|
|
+ marketPrice = 0
|
|
|
+ selectGoodsList.forEach(item => {
|
|
|
+ if(tempIds.includes(item.id)) {
|
|
|
+ groupPurchasePrice += item.groupPurchasePrice
|
|
|
+ marketPrice += item.marketPrice
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ form.groupPurchasePrice = Number(groupPurchasePrice.toFixed(2))
|
|
|
+ form.marketPrice = Number(marketPrice.toFixed(2))
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
</script>
|