Commit e594ef08 by cwq0219

验证

1 parent 2b401072
......@@ -2,7 +2,7 @@
* @Author: limin
* @Date: 2019-09-01 19:06:01
* @Last Modified by: chenwq
* @Last Modified time: 2020-11-15 11:24:23
* @Last Modified time: 2020-11-18 15:19:52
*/
// import { LOGIN_URL, REG_URL, ROLE_LIST_URL } from '@/api/sys.account'
......@@ -106,3 +106,30 @@ export const brandMerchantList = [{
confId: '10',
confValue: '嘀嘀虎'
}]
// 新值,旧值,整数部分位数,小数部分位数,最小值,最大值,规则
export function limitPrice(newValue, oldValue, intergerDigit, pointDigit, minValue, maxValue, regRule) {
var reg = {
priceReg: /^\d[\d\.]*$/,
numReg: /^[1-9]\d*$/
}
regRule = regRule || 'priceReg'
if (newValue && (minValue && (newValue < minValue)) || (maxValue && (newValue > maxValue))) {
return oldValue || ''
}
if (newValue && reg[regRule].test(newValue + '')) {
if ((/\./).test(newValue)) {
newValue = newValue + ''
var interger = newValue.split('.')[0]
var point = newValue.split('.')[1]
var intergerNum = interger.length > intergerDigit ? oldValue.split('.')[0] : interger
var pointNum = point.length > pointDigit ? point.slice(0, pointDigit) : point
newValue = pointDigit ? intergerNum + '.' + pointNum : newValue.split('.')[0]
} else {
newValue = newValue.length > intergerDigit ? oldValue.slice(0, intergerDigit) : newValue
}
return newValue
} else {
return newValue ? oldValue : ''
}
}
......@@ -35,6 +35,7 @@
:style="{'width': item.width || formItemWidth}"
:disabled="item.isDisabled"
clearable
@input="item.handleInput"
></el-input>
<!-- 选择框 -->
<el-select
......@@ -239,13 +240,19 @@
class="activity-img muti-imgs img-w-h"
v-else-if="subItem.resType === 1"
>
<div v-show="!subItem.content" class="add">+</div>
<div
v-show="!subItem.content"
class="add"
>+</div>
<img
v-show="subItem.content"
class="img-w-h"
:src="subItem.content"
/>
<span class="img-btns" v-show="subItem.content">
<span
class="img-btns"
v-show="subItem.content"
>
<span class="btn-item">
<i
@click='handleImgDelete(item, subIndex)'
......@@ -462,12 +469,16 @@ export default {
},
handleRelateProConfirm(proInfo) {
// this.relateProVisible = false
proInfo.profitType = 1
// this.originProInfo = {}
if (this.proIndex !== -1) {
this.formData.upgradeGoods[this.proIndex] = proInfo
} else {
proInfo = {
...proInfo,
profitType: 1
}
this.formData.upgradeGoods.push(proInfo)
console.log(this.formData.upgradeGoods[this.proIndex])
this.judgeIsDisable()
}
this.handleRelateProClose()
......
......@@ -49,6 +49,7 @@
v-model="proInfo.upgradePrice"
placeholder="请输入建议升级价"
class="dis-in-block"
@input="handleUpgradePrice"
></el-input>
<span>元</span>
</el-form-item>
......@@ -60,6 +61,7 @@
v-model="proInfo.shopPrice"
placeholder="请输入建议到店价"
class="dis-in-block"
@input="handleShopPrice"
></el-input>
<span>元</span>
</el-form-item>
......@@ -69,6 +71,7 @@
placeholder="请输入升级最大折扣"
clearable
class="dis-in-block"
@input="handleMaxUpgradeDiscount"
></el-input>
<span>折</span>
</el-form-item>
......@@ -78,6 +81,8 @@
</template>
<script>
import _ from 'lodash'
import { limitPrice } from '@/common/constants'
export default {
name: 'relateProDialog',
data() {
......@@ -97,10 +102,27 @@ export default {
goodsCode: [{ required: true, message: '请选择关联升级商品', trigger: 'blur' }],
upgradePrice: [{ required: true, message: '请输入建议升级价', trigger: 'blur' }],
shopPrice: [{ required: true, message: '请输入到店价', trigger: 'blur' }]
},
oldVal: {
upgradePrice: '',
shopPrice: '',
maxUpgradeDiscount: ''
}
}
},
// watch: {
// 'proInfo.upgradePrice'(val, oldVal) {
// this.proInfo.upgradePrice = limitPrice(val, oldVal, 8, 2)
// },
// 'proInfo.shopPrice'(val, oldVal) {
// this.proInfo.shopPrice = limitPrice(val, oldVal, 6, 2)
// },
// 'proInfo.maxUpgradeDiscount'(val, oldVal) {
// this.proInfo.maxUpgradeDiscount = limitPrice(val, oldVal, 1, 1, 1)
// }
// },
props: {
relateProVisible: {
type: Boolean,
......@@ -117,9 +139,9 @@ export default {
},
mounted() {
this.proInfo = this.originProInfo || this.proInfo
console.log(this.proInfo)
console.log(this.proList)
this.proInfo = _.cloneDeep(this.originProInfo) || _.cloneDeep(this.proInfo)
// console.log(this.proInfo)
// console.log(this.proList)
},
methods: {
......@@ -140,6 +162,18 @@ export default {
},
handleRelateProClose() {
this.$emit('handleRelateProClose')
},
handleUpgradePrice(newVal) {
this.proInfo.upgradePrice = limitPrice(newVal, this.oldVal.upgradePrice, 8, 2)
this.oldVal.upgradePrice = this.proInfo.upgradePrice
},
handleShopPrice(newVal) {
this.proInfo.shopPrice = limitPrice(newVal, this.oldVal.shopPrice, 6, 2)
this.oldVal.shopPrice = this.proInfo.shopPrice
},
handleMaxUpgradeDiscount(newVal) {
this.proInfo.maxUpgradeDiscount = limitPrice(newVal, this.oldVal.maxUpgradeDiscount, 1, 1, 1)
this.oldVal.maxUpgradeDiscount = this.proInfo.maxUpgradeDiscount
}
}
}
......
......@@ -15,12 +15,12 @@
@handleAddConfirm="handleAddConfirm"
@handleClose="handleAddClose"
></d2-form>
</d2-container>
</template>
<script>
import { mapActions } from 'vuex'
import { limitPrice } from '@/common/constants'
import { commodityAddSeviceMerchant, getGoodsList, baseGoodsAdd, baseGoodsUpdate, getGoodsInfoById } from '@/api/commodity'
export default {
name: 'editCommodity',
......@@ -39,6 +39,11 @@ export default {
upgradeGoods: [],
linkMerchantIds: []
},
markOldVal: {
retailPrice: '',
shopPrice: '',
maxRetailDiscount: ''
},
formItemWidth: '200px',
rules: {
goodsCode: [{ required: true, message: '请选择商品名称', trigger: 'change' }],
......@@ -86,18 +91,30 @@ export default {
label: '商品零售价',
type: 'input',
unit: '元',
tips: '(前端展示给车主)'
tips: '(前端展示给车主)',
handleInput: (newVal) => {
this.$refs.d2Form.formData.retailPrice = limitPrice(newVal, this.markOldVal.retailPrice, 6, 2)
this.markOldVal.retailPrice = this.$refs.d2Form.formData.retailPrice
}
}, {
name: 'shopPrice',
label: '到店价',
type: 'input',
unit: '元',
tips: '(商品最终交易价格)'
tips: '(商品最终交易价格)',
handleInput: (newVal) => {
this.$refs.d2Form.formData.shopPrice = limitPrice(newVal, this.markOldVal.shopPrice, 6, 2)
this.markOldVal.shopPrice = this.$refs.d2Form.formData.shopPrice
}
}, {
name: 'maxRetailDiscount',
label: '到店零售折扣',
type: 'input',
unit: '折'
unit: '折',
handleInput: (newVal) => {
this.$refs.d2Form.formData.maxRetailDiscount = limitPrice(newVal, this.markOldVal.maxRetailDiscount, 1, 1, 1)
this.markOldVal.maxRetailDiscount = this.$refs.d2Form.formData.maxRetailDiscount
}
}]
}, {
title: '关联升级商品信息',
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!