|
@@ -1,14 +1,14 @@
|
|
|
<template>
|
|
|
<el-dialog :title="dialogTitle" :visible.sync="dialogFormVisible" width="600px">
|
|
|
- <el-form ref="dataForm" :model="formData" size="mini" label-width="120px">
|
|
|
+ <el-form ref="dataForm" :model="formData" :rules="rules" size="mini" label-width="120px">
|
|
|
<el-form-item label="商品名称:">
|
|
|
<div class="text" v-text="productDetail.productName" />
|
|
|
</el-form-item>
|
|
|
<el-form-item label="供应商名称:">
|
|
|
<div class="text" v-text="productDetail.shopName" />
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="商品分类:" prop="classifyID" :rules="{required:true, message:'*必填', trigger:'change'}">
|
|
|
- <el-select v-model="formData.classifyID" placeholder="商品分类" :label="productDetail.productClassifyName" size="small" class="filter-item" :value="productDetail.classifyID*1">
|
|
|
+ <el-form-item label="商品分类:" prop="classifyID">
|
|
|
+ <el-select v-model="formData.classifyID" placeholder="商品分类" :label="productDetail.productClassifyName" size="small">
|
|
|
<template v-for="item in classify">
|
|
|
<el-option v-if="item.status*1 === 1" :key="item.id" :label="item.classifyName" :value="item.id" />
|
|
|
</template>
|
|
@@ -16,35 +16,35 @@
|
|
|
</el-form-item>
|
|
|
<div class="line">
|
|
|
<el-form-item label="市场价:" prop="normalPrice" :rules="{required:true, validator:checkPrice, type:'float', trigger:'blur'}">
|
|
|
- <el-input v-model.number="formData.normalPrice" size="small" />
|
|
|
+ <el-input v-model="formData.normalPrice" size="small" />
|
|
|
</el-form-item>
|
|
|
<el-form-item label="成本价:" prop="costPrice" :rules="{required:true, validator:checkPrice, type:'float', trigger:'blur'}">
|
|
|
- <el-input v-model.number="formData.costPrice" size="small" />
|
|
|
+ <el-input v-model="formData.costPrice" size="small" />
|
|
|
</el-form-item>
|
|
|
</div>
|
|
|
|
|
|
- <el-form-item label="售价:" prop="ladderPriceFlag" :rules="{required:true, message:'*必填', trigger:'change'}">
|
|
|
- <el-radio-group v-model="formData.ladderPriceFlag" size="small">
|
|
|
+ <el-form-item label="售价:" prop="ladderPriceFlag">
|
|
|
+ <el-radio-group v-model="formData.ladderPriceFlag" size="small" @change="clearValidate">
|
|
|
<el-radio :label="0">不使用阶梯价格</el-radio>
|
|
|
<el-radio :label="1">使用阶梯价格</el-radio>
|
|
|
</el-radio-group>
|
|
|
</el-form-item>
|
|
|
|
|
|
- <div v-if="formData.ladderPriceFlag === 0" class="single">
|
|
|
- <el-form-item label="" prop="retailPrice" :rules="{validator:checkPrice, type:'float', trigger:'blur'}">
|
|
|
- <el-input v-model.number="formData.retailPrice" size="small" />
|
|
|
+ <div v-show="formData.ladderPriceFlag === 0" class="single">
|
|
|
+ <el-form-item label=" " prop="retailPrice">
|
|
|
+ <el-input v-model="formData.retailPrice" size="small" />
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="起订量:" prop="minBuyNumber" :rules="{required:true, validator:checkNumbers, type:'number', trigger:'blur'}">
|
|
|
+ <el-form-item label="起订量:" prop="minBuyNumber">
|
|
|
<el-input v-model.number="formData.minBuyNumber" size="small" />
|
|
|
</el-form-item>
|
|
|
</div>
|
|
|
- <div v-if="formData.ladderPriceFlag === 1" class="multiple">
|
|
|
+ <div v-show="formData.ladderPriceFlag === 1" class="multiple">
|
|
|
<div class="group">
|
|
|
<div v-for="(item, index) in formData.ladderPriceList" :key="'ladderPrice'+index" class="line">
|
|
|
- <el-form-item label="起订量" label-width="60px" style="width:130px" :prop="'ladderPriceList.' + index + '.buyNum'" :rules="{validator:checkMultiNumber, type:'number', trigger:'blur'}">
|
|
|
+ <el-form-item label="起订量" label-width="60px" style="width:130px" :prop="'ladderPriceList.' + index + '.buyNum'" :rules="{validator:checkNumber, type:'number', trigger:'blur'}">
|
|
|
<el-input v-model.number="item.buyNum" size="small" />
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="及以上,单价为" label-width="120px" style="width:210px" :prop="'ladderPriceList.' + index + '.buyPrice'" :rules="{validator:checkMultiPrice, type:'float', trigger:'blur'}">
|
|
|
+ <el-form-item label="及以上,单价为" label-width="120px" style="width:210px" :prop="'ladderPriceList.' + index + '.buyPrice'" :rules="{validator:checkPrice, type:'float', trigger:'blur'}">
|
|
|
<el-input v-model="item.buyPrice" size="small" />
|
|
|
</el-form-item>
|
|
|
</div>
|
|
@@ -99,6 +99,7 @@ export default {
|
|
|
},
|
|
|
ladderSize: 2,
|
|
|
ladderPrice: {
|
|
|
+ delFlag: 0,
|
|
|
productId: 0, // bigint(11) DEFAULT NULL COMMENT '商品id,具体对应cm_mall_organize_products表的ID',
|
|
|
ladderNum: 3, // bigint(11) DEFAULT NULL COMMENT '第几阶梯(最多可设置3阶梯)',
|
|
|
buyNum: '', // bigint(11) DEFAULT NULL COMMENT '购买数量(起订量)',
|
|
@@ -108,7 +109,13 @@ export default {
|
|
|
price: '',
|
|
|
number: ''
|
|
|
},
|
|
|
- multiplePrice: []
|
|
|
+ multiplePrice: [],
|
|
|
+ rules: {
|
|
|
+ classifyID: [{ required: true, message: '*必填', trigger: 'change' }],
|
|
|
+ ladderPriceFlag: [{ required: true, message: '*必填', trigger: 'change' }],
|
|
|
+ retailPrice: [{ validator: this.checkPrice, type: 'float', trigger: 'blur' }],
|
|
|
+ minBuyNumber: [{ validator: this.checkNumber, type: 'number', trigger: 'blur' }]
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
@@ -124,14 +131,13 @@ export default {
|
|
|
watch: {
|
|
|
productDetail: function(val) {
|
|
|
this.postData = JSON.parse(JSON.stringify(val))
|
|
|
-
|
|
|
- this.formData.id = val.id
|
|
|
- this.formData.classifyID = val.classifyID * 1
|
|
|
- this.formData.normalPrice = val.normalPrice
|
|
|
- this.formData.costPrice = val.costPrice
|
|
|
- this.formData.ladderPriceFlag = val.ladderPriceFlag * 1
|
|
|
- this.formData.retailPrice = val.retailPrice
|
|
|
- this.formData.minBuyNumber = val.minBuyNumber
|
|
|
+ this.formData.id = this.postData.id
|
|
|
+ this.formData.classifyID = this.postData.classifyID * 1
|
|
|
+ this.formData.normalPrice = this.postData.normalPrice
|
|
|
+ this.formData.costPrice = this.postData.costPrice
|
|
|
+ this.formData.ladderPriceFlag = this.postData.ladderPriceFlag * 1
|
|
|
+ this.formData.retailPrice = this.postData.retailPrice
|
|
|
+ this.formData.minBuyNumber = this.postData.minBuyNumber * 1
|
|
|
// 初始化阶梯价格
|
|
|
this.formData.ladderPriceList = []
|
|
|
this.ladderPrice.productId = val.id
|
|
@@ -169,11 +175,20 @@ export default {
|
|
|
updateGoods() {
|
|
|
this.$refs['dataForm'].validate((valid) => {
|
|
|
if (valid) {
|
|
|
+ this.postData.classifyID = this.formData.classifyID
|
|
|
+ this.postData.normalPrice = this.formData.normalPrice
|
|
|
+ this.postData.costPrice = this.formData.costPrice
|
|
|
+ this.postData.ladderPriceFlag = this.formData.ladderPriceFlag
|
|
|
if (this.formData.ladderPriceFlag === 0) {
|
|
|
this.postData.retailPrice = this.formData.retailPrice
|
|
|
this.postData.minBuyNumber = this.formData.minBuyNumber
|
|
|
+ for (let i = 0; i < this.postData.ladderPriceList.length; i++) {
|
|
|
+ this.postData.ladderPriceList[i].delFlag = 1
|
|
|
+ }
|
|
|
} else {
|
|
|
- this.postData.ladderPriceFlag = this.formData.ladderPriceFlag
|
|
|
+ for (let i = 0; i < this.formData.ladderPriceList.length; i++) {
|
|
|
+ this.formData.ladderPriceList[i].delFlag = 0
|
|
|
+ }
|
|
|
if (!this.postData.ladderPriceList || this.postData.ladderPriceList.length === 0) {
|
|
|
this.postData.ladderPriceList = this.formData.ladderPriceList
|
|
|
} else {
|
|
@@ -197,14 +212,6 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
/** 自定义校验规则 */
|
|
|
- checkNumbers(rule, value, callback) {
|
|
|
- if (!value) {
|
|
|
- return callback(new Error('*必填'))
|
|
|
- }
|
|
|
- this.$nextTick(() => {
|
|
|
- !Number.isInteger(value) ? callback(new Error('*起订量数值填写错误')) : callback()
|
|
|
- })
|
|
|
- },
|
|
|
checkPrice(rule, value, callback) {
|
|
|
if (!value) {
|
|
|
return callback(new Error('*必填'))
|
|
@@ -221,13 +228,13 @@ export default {
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
- checkMultiNumber(rule, value, callback) {
|
|
|
+ checkNumber(rule, value, callback) {
|
|
|
if (!value) {
|
|
|
return callback(new Error('*必填'))
|
|
|
}
|
|
|
this.$nextTick(() => {
|
|
|
if (!Number.isInteger(value)) {
|
|
|
- callback(new Error('*请输入数字值'))
|
|
|
+ callback(new Error('*起订量数值填写错误'))
|
|
|
} else {
|
|
|
if ((rule.fullField.indexOf('2') > 0 && this.formData.ladderPriceList[2].buyNum <= this.formData.ladderPriceList[1].buyNum) ||
|
|
|
(rule.fullField.indexOf('1') > 0 && this.formData.ladderPriceList[1].buyNum <= this.formData.ladderPriceList[0].buyNum)) {
|
|
@@ -237,22 +244,6 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
- },
|
|
|
- checkMultiPrice(rule, value, callback) {
|
|
|
- if (!value) {
|
|
|
- return callback(new Error('*必填'))
|
|
|
- }
|
|
|
- this.$nextTick(() => {
|
|
|
- if (!Number.parseFloat(value * 1)) {
|
|
|
- callback(new Error('*请输入正确的金额'))
|
|
|
- } else {
|
|
|
- if (('' + value).split('.').length > 1 && ('' + value).split('.')[1].length > 2) {
|
|
|
- return callback(new Error('*最多保留两位小数'))
|
|
|
- } else {
|
|
|
- callback()
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
}
|
|
|
}
|
|
|
}
|