Commit 255c1e60 by wangql
2 parents a48d6900 e594ef08
......@@ -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 : ''
}
}
......@@ -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
}
}
}
......
......@@ -35,14 +35,14 @@ export default {
this.show = false
this.$event.$on('e-password-dialog', res => (this.passVisible = res))
this.getInfo()
this.$nextTick(() => {
this.show = true
})
},
methods: {
...mapActions('d2admin/user', ['load']),
async getInfo() {
this.info = await this.load()
this.$nextTick(() => {
this.show = true
})
}
}
}
......
......@@ -95,7 +95,8 @@
title="关联门店信息"
:className="storeDetail"
:isVisible.sync="detailVisible"
@closeDialog="handleDetailClose"
noCancel="true"
@confirmDialog="handleDetailClose"
>
<store-detail
v-if="detailVisible"
......@@ -133,6 +134,9 @@ export default {
listName: 'list',
tableOption: true,
tableColumns: [{
label: '序号',
prop: 'index'
}, {
label: '商品ID',
prop: 'goodsCode'
}, {
......
......@@ -10,16 +10,17 @@
:addOrEdit="addOrEdit"
:originData="editData"
:formList="editForm"
:formRef="comFormRef"
:headImg="headImg"
@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',
......@@ -38,9 +39,14 @@ export default {
upgradeGoods: [],
linkMerchantIds: []
},
markOldVal: {
retailPrice: '',
shopPrice: '',
maxRetailDiscount: ''
},
formItemWidth: '200px',
rules: {
goodsCode: [{ required: true, message: '请选择商品名称', trigger: 'blur' }],
goodsCode: [{ required: true, message: '请选择商品名称', trigger: 'change' }],
shopPrice: [{ required: true, message: '请输入到店价', trigger: 'blur' }],
linkMerchantIds: [{ required: true, message: '请选择关联门店', trigger: 'change' }]
},
......@@ -48,6 +54,7 @@ export default {
isHas: true,
attr: 'thumbUrl'
},
comFormRef: 'com',
editForm: [{
title: '商品基本信息',
formBlock: [{
......@@ -84,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: '关联升级商品信息',
......@@ -103,7 +122,8 @@ export default {
name: 'upgradeGoods',
label: '关联升级商品',
type: 'relatePro',
optionValue: 'goodsCode'
optionValue: 'goodsCode',
relateAttr: 'goodsCode'
}]
}, {
title: '关联门店信息',
......@@ -125,6 +145,7 @@ export default {
// console.log(this.editData)
// add - 新增;edit - 编辑
this.addOrEdit = this.$route.params.addOrEdit
this.getGoodsList()
if (this.addOrEdit === 'edit') {
getGoodsInfoById({ id: this.$route.params.row.id }).then(res => {
// console.log(res)
......@@ -140,6 +161,7 @@ export default {
shopPrice: res.shopPrice,
maxRetailDiscount: res.maxRetailDiscount,
upgradeGoods: res.upgradeGoodsList.map(item => {
item['goodsName'] = item.goodsInfo.goodsName
item['thumbUrl'] = item.goodsInfo.thumbUrl
return item
}),
......@@ -152,7 +174,6 @@ export default {
})
} else {
this.editForm[0].formBlock[0].isDisabled = false
this.getGoodsListNoBase()
this.$nextTick(() => {
this.show = true
})
......@@ -162,10 +183,9 @@ export default {
methods: {
...mapActions({ close: 'd2admin/page/close' }),
// ...mapActions('d2admin/page', ['close']),
getGoodsListNoBase() {
getGoodsList({
exceptBase: true
}).then(res => {
getGoodsList() {
// var params = this.addOrEdit === 'edit' ? {} : { exceptBase: true }
getGoodsList({}).then(res => {
// console.log(res)
this.editForm[0].formBlock[0].optionList = res
})
......
......@@ -9,6 +9,7 @@
addOrEdit="add"
:originData="editData"
:formList="editForm"
:formRef="proFormRef"
@handleAddConfirm="handleAddConfirm"
@handleClose="handleAddClose"
></d2-form>
......@@ -27,8 +28,8 @@ export default {
show: false,
addOrEdit: 'add',
rules: {
goodsName: [{ required: true, message: '请输入产品名称', trigger: 'blur' }],
goodsType: [{ required: true, message: '请选择分类', trigger: 'blur' }],
goodsName: [{ required: true, message: '请输入产品名称', trigger: 'change' }],
goodsType: [{ required: true, message: '请选择分类', trigger: 'change' }],
// thumbUrl: [{ required: true, message: '请选择缩略图', trigger: 'change' }],
thumbUrlList: [{ required: true, message: '请选择缩略图', trigger: 'blur' }],
goodsImgList: [{ required: true, message: '请选择产品主图', trigger: 'blur' }]
......@@ -49,6 +50,7 @@ export default {
content: ''
}]
},
proFormRef: 'pro',
editForm: [{
title: '产品基本信息',
formBlock: [{
......
......@@ -10,6 +10,7 @@
<el-form-item label="产品名称">
<el-input
v-model="searchForm.goodsName"
placeholder="请输入产品名称"
clearable
></el-input>
</el-form-item>
......@@ -163,11 +164,12 @@ export default {
resolve()
})
},
handleSearch() {
console.log(this.searchForm)
},
handleReset() {
this.$refs.productTable.refreshTable()
this.searchForm = {
goodsName: '',
goodsType: '',
brandMerchantCode: ''
}
},
handleAdd(form) {
// console.log(form)
......
......@@ -50,7 +50,6 @@
v-model="formLogin.userName"
placeholder="用户名"
clearable
maxlength="10"
v-focus
>
<!-- <d2-el-icon
......@@ -65,7 +64,6 @@
v-model="formLogin.password"
v-on:keyup.native.13="submit"
clearable
maxlength="12"
placeholder="密码"
>
<!-- <d2-el-icon
......@@ -141,8 +139,7 @@ export default {
required: true,
message: '请输入密码',
trigger: 'submit'
}
]
}]
})
}
},
......
......@@ -57,7 +57,7 @@ export default {
label: '登录账户'
}, {
name: 'loginPhone',
label: '登陆手机号'
label: '登录手机号'
}, {
name: 'merchantId',
label: '商户号'
......
......@@ -7,9 +7,10 @@
label-width="85px"
slot="header"
>
<el-form-item label="商品名称">
<el-form-item label="商户名称">
<el-input
v-model="searchForm.merchantName"
placeholder="请输入商户名称"
clearable
></el-input>
</el-form-item>
......@@ -192,7 +193,12 @@ export default {
handleRelateStoreConfirm(selectedData) {
console.log(selectedData)
if (!selectedData.length) {
this.notice.warningTips('请选择关联门店')
// this.notice.warningTips('请选择关联门店')
this.$message({
message: '请选择关联门店',
type: 'warning',
showClose: true
})
return true
}
addServiceMerchant({ list: selectedData }).then(res => {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!