Commit d8950303 by 李长胜
2 parents 664c9429 17f1ec4c
...@@ -150,29 +150,29 @@ export default { ...@@ -150,29 +150,29 @@ export default {
maxlength: '50' maxlength: '50'
} }
] ]
},
{
title: '新车优惠政策',
editFormData: [
{
label: '优惠政策',
name: 'police',
type: 'input',
inputType: 'textarea',
width: '320px',
maxlength: '300'
}
]
},
{
title: '在线客服',
editFormData: [
{
label: '',
addHtml: 'onlineService'
}
]
} }
// {
// title: '新车优惠政策',
// editFormData: [
// {
// label: '优惠政策',
// name: 'police',
// type: 'input',
// inputType: 'textarea',
// width: '320px',
// maxlength: '300'
// }
// ]
// },
// {
// title: '在线客服',
// editFormData: [
// {
// label: '',
// addHtml: 'onlineService'
// }
// ]
// }
] ]
} }
}, },
......
...@@ -135,16 +135,16 @@ ...@@ -135,16 +135,16 @@
<td :style="{ width: specsWidth }" v-for="(n, idx) in subItem.specsValueList" :key="idx">{{ n }}</td> <td :style="{ width: specsWidth }" v-for="(n, idx) in subItem.specsValueList" :key="idx">{{ n }}</td>
<td :style="{ width: specsWidth }"> <td :style="{ width: specsWidth }">
<div v-if="routeInfo.groupOrStore == 1"> <div v-if="routeInfo.groupOrStore == 1">
<el-input :disabled="isDisabled" :class="{ 'border-red': (!(subItem.retailPrice + '') || +editForm.supplyPrice > +subItem.retailPrice) && submitted }" placeholder="零售价" v-model="subItem.retailPrice" ng-blur="handleBlur()"> <el-input :disabled="isDisabled" :class="{ 'border-red': (!(subItem.retailPrice + '') || +editForm.supplyPrice > +subItem.retailPrice) && submitted }" placeholder="零售价" v-model="subItem.retailPrice" @input.native="e => handleRetailPriceInput(e, subIndex)">
<el-popover v-show="(!(subItem.retailPrice + '') || +editForm.supplyPrice > +subItem.retailPrice) && submitted" slot="suffix" placement="top" title="" width="90" trigger="hover" :content="!(subItem.retailPrice + '') ? '零售价是必填项' : '零售价要大于供货价'"> <el-popover v-show="(!(subItem.retailPrice + '') || +editForm.supplyPrice > +subItem.retailPrice) && submitted" slot="suffix" placement="top" title="" width="90" trigger="hover" :content="!(subItem.retailPrice + '') ? '零售价是必填项' : '零售价要大于供货价'">
<i class="el-icon-warning color-red" slot="reference"></i> <i class="el-icon-warning color-red" slot="reference"></i>
</el-popover> </el-popover>
</el-input> </el-input>
</div> </div>
<el-input :disabled="isDisabled" v-else placeholder="零售价" v-model="subItem.retailPrice" ng-blur="handleBlur()"></el-input> <el-input :disabled="isDisabled" v-else placeholder="零售价" v-model="subItem.retailPrice" @input.native="e => handleRetailPriceInput(e, subIndex)"></el-input>
</td> </td>
<td :style="{ width: specsWidth }"> <td :style="{ width: specsWidth }">
<el-input :disabled="isDisabled" placeholder="库存" v-model="subItem.stock" :class="{ 'border-red': !(subItem.stock + '') && submitted }"> <el-input :disabled="isDisabled" placeholder="库存" v-model="subItem.stock" :class="{ 'border-red': !(subItem.stock + '') && submitted }" @input.native="e => handleStockInput(e, subIndex)">
<el-popover v-show="!(subItem.stock + '') && submitted" slot="suffix" placement="top" title="" width="90" trigger="hover" content="库存是必填项"> <el-popover v-show="!(subItem.stock + '') && submitted" slot="suffix" placement="top" title="" width="90" trigger="hover" content="库存是必填项">
<i class="el-icon-warning color-red" slot="reference"></i> <i class="el-icon-warning color-red" slot="reference"></i>
</el-popover> </el-popover>
...@@ -217,6 +217,7 @@ ...@@ -217,6 +217,7 @@
</template> </template>
<script> <script>
import { limitPrice } from '@/common/constant'
export default { export default {
name: 'editProduct', name: 'editProduct',
data() { data() {
...@@ -262,6 +263,12 @@ export default { ...@@ -262,6 +263,12 @@ export default {
specificationDetailList: [], specificationDetailList: [],
nameToValSpecsList: [], nameToValSpecsList: [],
minRetailPrice: '', minRetailPrice: '',
/* eslint-disable */
reg: {
priceReg: /^\d[\d\.]*$/,
numReg: /^[1-9]\d*$/
},
/* eslint-enable */
// 添加规格弹窗 // 添加规格弹窗
isSpescVisible: false, isSpescVisible: false,
spescRules: { spescRules: {
...@@ -563,6 +570,29 @@ export default { ...@@ -563,6 +570,29 @@ export default {
} }
}, },
watch: {
// 零售价
'editForm.retailPrice'(newValue, oldValue) {
this.editForm.retailPrice = limitPrice(newValue, oldValue, 5, 2)
},
// 划线价
'editForm.originalPrice'(newValue, oldValue) {
this.editForm.originalPrice = limitPrice(newValue, oldValue, 5, 2)
},
// 供货价
'editForm.supplyPrice'(newValue, oldValue) {
this.editForm.supplyPrice = limitPrice(newValue, oldValue, 5, 2)
},
// 库存
'editForm.goodsStock'(newValue, oldValue) {
this.editForm.goodsStock = limitPrice(newValue, oldValue, 10, 0, 0, 10000000000, 'numReg')
},
// 运费
'editForm.expressFee'(newValue, oldValue) {
this.editForm.expressFee = limitPrice(newValue, oldValue, 5, 2, 0, 100000)
}
},
mounted() { mounted() {
this.userInfo = this.$globalState.session this.userInfo = this.$globalState.session
this.footerLeft = document.querySelector('.base-container-right').offsetLeft this.footerLeft = document.querySelector('.base-container-right').offsetLeft
...@@ -631,6 +661,28 @@ export default { ...@@ -631,6 +661,28 @@ export default {
this.externalFormList[1].editFormData[idx].isHide = !!this.specificationDetailList.length this.externalFormList[1].editFormData[idx].isHide = !!this.specificationDetailList.length
}) })
}, },
handleRetailPriceInput(e, idx) {
var newValue = e.target.value
if (!this.reg.priceReg.test(newValue)) {
newValue = ''
}
var oldValue = newValue
if (e.key != 'Backspace' && newValue.length > 1) {
oldValue = newValue.slice(0, newValue.length - 1)
}
this.nameToValSpecsList[idx].retailPrice = limitPrice(newValue, oldValue, 5, 2)
},
handleStockInput(e, idx) {
var newValue = e.target.value
if (!this.reg.priceReg.test(newValue)) {
newValue = ''
}
var oldValue = newValue
if (e.key != 'Backspace' && newValue.length > 1) {
oldValue = newValue.slice(0, newValue.length - 1)
}
this.nameToValSpecsList[idx].stock = limitPrice(newValue, oldValue, 10, 0, 0, 10000000000, 'numReg')
},
// 二次确认 // 二次确认
secondSimpleConfirm(title, txt, fn) { secondSimpleConfirm(title, txt, fn) {
this.$confirm(txt, title, { this.$confirm(txt, title, {
......
...@@ -170,7 +170,7 @@ export default { ...@@ -170,7 +170,7 @@ export default {
}, },
handleDetail(row) { handleDetail(row) {
this.$router.push('/takeGood/takeGoodDetail/' + row.id) this.$router.push('/takeGood/takeGoodDetail/' + row.goodsId)
}, },
handleSearch() { handleSearch() {
......
<!-- 带货详情 --> <!-- 带货详情 -->
<!-- 商品编辑 - 带货 -->
<template> <template>
<div>带货详情</div> <div class="edit-product-dh marketing">
<div class="container edit-container">
<p class="edit-title">{{ title }}</p>
<div class="flex" style="margin-top: 20px;">
<div style="width: 440px; text-align: center;">
<img class="main-img" :src="mainImgUrl" />
<div>
<div class="flex">
<p class="arrow left-arrow" @click="handleMoveImg('left')"></p>
<div class="small-block">
<div class="flex small-box">
<img class="small-img" v-for="(item, index) in editForm.goodsDetailImageList" :key="index" :src="item.content" @click="handleChangeImg(index)" />
</div>
</div>
<p class="arrow right-arrow" @click="handleMoveImg('right')"></p>
</div>
</div>
</div>
<div style="width: calc(100% - 440px);">
<p class="pro-name txt-ellipsis">{{ editForm.goodsName }}</p>
<!-- <p v-show="!specificationDetailList.length" class="supply-price txt-ellipsis">{{ editForm.retailPrice }}元</p> -->
</div>
</div>
<div v-if="specificationDetailList.length" class="flex" style="margin-top: 20px;" id="specificationDetailList">
<span class="spesc-label" :style="{ width: labelWidth }">规格明细:</span>
<div style="width: calc(100% - 100px);">
<table class="table-spesc">
<tbody>
<tr>
<td :style="{ width: specsWidth }" v-for="(subItem, subIndex) in specificationDetailList" :key="subIndex">{{ subItem.specificationName }}</td>
<!-- <td :style="{ width: specsWidth }">零售价(元)</td> -->
<td :style="{ width: specsWidth }">供货价</td>
<!-- <td :style="{ width: specsWidth }">利润</td> -->
<td :style="{ width: specsWidth }">库存</td>
</tr>
</tbody>
</table>
<table class="table-spesc" style="max-height: 400px;">
<tbody>
<tr style="border-bottom: 1px solid rgb(235, 235, 235);" v-for="(item, index) in nameToValSpecsList" :key="index">
<td :style="{ width: specsWidth }" v-for="(n, idx) in item.specsValueList" :key="idx">{{ n }}</td>
<!-- <td :style="{ width: specsWidth }">
<el-input :disabled="isDisabled" :class="{ 'border-red': (!(item.retailPrice + '') || +item.supplyPrice > +item.retailPrice) && submitted }" placeholder="零售价" v-model="item.retailPrice" @input.native="e => handleInput(e, index)">
<el-popover v-show="(!(item.retailPrice + '') || +item.supplyPrice > +item.retailPrice) && submitted" slot="suffix" placement="top" title="" width="90" trigger="hover" :content="!(item.retailPrice + '') ? '零售价是必填项' : '零售价要大于供货价'">
<i class="el-icon-warning color-red" slot="reference"></i>
</el-popover>
</el-input>
</td> -->
<td :style="{ width: specsWidth }">{{ item.supplyPrice }}元</td>
<!-- <td :style="{ width: specsWidth }">{{ (item.retailPrice - item.supplyPrice).toFixed(2) }}元</td> -->
<td :style="{ width: specsWidth }">{{ item.stock }}件</td>
</tr>
</tbody>
</table>
</div>
</div>
<glsx-combi-form v-if="!specificationDetailList.length" class="edit-form-container" ref="editFormRef" labelWidth="140px" :isBlock="true" :formRef="editChildRef" :formObj="editForm" :formData="editFormData" :formRules="editRule"></glsx-combi-form>
</div>
<div class="footer" :style="{ left: footerLeft + 'px', width: footerWidth + 'px' }">
<!-- <el-button type="primary" @click="handleConfirm">确定</el-button> -->
<el-button type="default" @click="handleCancel">取消</el-button>
</div>
</div>
</template> </template>
<script> <script>
import { limitPrice } from '@/common/constant'
export default { export default {
name: 'takeGoodDetail', name: 'takeGoodDetail',
data() { data() {
return { } return {
size: 'small',
title: '查看商品',
// titleObj: {
// 1: '创建商品',
// 2: '编辑商品',
// 3: '查看商品'
// },
footerLeft: '0',
footerWidth: '0',
editChildRef: 'editChildRef',
// submitted: false,
isDisabled: false,
mainImgUrl: '',
moveNum: 0,
curMoveNum: 0,
/* eslint-disable */
reg: {
priceReg: /^\d[\d\.]*$/,
numReg: /^[1-9]\d*$/
},
/* eslint-enable */
routeInfo: {
// 1-新增;2-编辑;3-查看
addOrEdit: 1,
id: ''
},
specificationDetailList: [],
nameToValSpecsList: [],
editForm: {
retailPrice: ''
},
editRule: {
// retailPrice: [
// { required: true, message: '请输入零售价', trigger: 'change' },
// {
// validator: (rule, value, callback) => {
// return +this.editForm.supplyPrice > +value ? callback(new Error('零售价不能小于供货价')) : callback()
// },
// trigger: 'change'
// }
// ]
},
editFormData: [
// {
// label: '零售价',
// name: 'retailPrice',
// width: '280px',
// type: 'input',
// isDisabled: false
// },
{
label: '供货价',
name: 'supplyPrice',
width: '280px',
type: 'input',
isDisabled: true
},
{
label: '库存',
name: 'goodsStock',
width: '280px',
type: 'input',
isDisabled: true
}
]
}
}, },
components: {}, mounted() {
this.footerLeft = document.querySelector('.base-container-right').offsetLeft
this.footerWidth = document.documentElement.clientWidth - this.footerLeft
this.routeInfo = this.$route.params
// this.title = this.titleObj[this.routeInfo.addOrEdit]
this.isDisabled = true
this.editFormData[0].isDisabled = true
this.getInfo()
},
methods: {
getInfo() {
this.$apis.proManage.getProInfoApi({ id: this.routeInfo.id }).then(res => {
this.editForm = {
...res,
retailPrice: '',
supplyPrice: res.supplyPrice ? (res.supplyPrice / 100).toFixed(2) : ''
}
// 规格
if (this.editForm.specificationList.length) {
this.specificationDetailList = this.$common.utils.deepClone(this.editForm.specificationList)
this.recoverySpec()
// this.findSpeceMin()
} else {
// 零售价
this.editForm.retailPrice = (res.retailPrice / 100).toFixed(2)
}
this.mainImgUrl = this.editForm.goodsDetailImageList[0].content
this.moveNum = this.editForm.goodsDetailImageList.length > 4 ? this.editForm.goodsDetailImageList.length - 4 : 0
})
},
// 规格值解构
changeSpecs(isRecovery) {
this.specsWidth = 100 / (this.specificationDetailList.length + 2) + '%'
this.nameToValSpecsList = []
var markIdx = 0
for (var i = 0; i < this.specificationDetailList.length; i++) {
markIdx = 0
for (var j = 0; j < this.specificationDetailList[i].specificationValueList.length; j++) {
if (i == 0) {
this.nameToValSpecsList.push({
specsValueList: [this.specificationDetailList[i].specificationValueList[j].specificationValue],
retailPrice: '',
stock: ''
})
} else {
var targetValLen = this.specificationDetailList[i].specificationValueList.length
var loopNum = 0
var tempMarkIdx = 0
if (j == 0 && targetValLen > 1) {
var obj = JSON.parse(JSON.stringify(this.nameToValSpecsList))
this.nameToValSpecsList = []
obj.forEach((item, index) => {
for (var k = 0; k < targetValLen; k++) {
this.nameToValSpecsList.push(JSON.parse(JSON.stringify(item)))
}
})
}
loopNum = this.nameToValSpecsList.length / targetValLen
tempMarkIdx = markIdx
for (var k = 0; k < loopNum; k++) {
this.nameToValSpecsList[tempMarkIdx].specsValueList.push(this.specificationDetailList[i].specificationValueList[j].specificationValue)
tempMarkIdx = tempMarkIdx + targetValLen
}
markIdx = markIdx + 1
}
}
}
if (isRecovery) {
this.nameToValSpecsList.forEach((item, index) => {
var specificationObj = {}
item.specsValueList.forEach((subItem, subIndex) => {
specificationObj[this.specificationDetailList[subIndex].specificationName] = subItem
})
item.specificationData = this.setLocaleCompare(specificationObj)
for (var i = 0; i < this.editForm.specificationDetailList.length; i++) {
var temp = this.editForm.specificationDetailList[i]
if (temp.specificationData == item.specificationData) {
item.retailPrice = (temp.retailPrice / 100).toFixed(2)
item.specificationKey = temp.specificationKey
item.stock = temp.stock
item.supplyPrice = this.editForm.supplyPrice
break
}
}
})
}
},
setLocaleCompare(params) {
let keys = []
let obj = []
Object.keys(params).forEach(item => {
keys.push(item)
})
keys.sort()
keys.forEach(item => {
obj.push([item, params[item]])
})
return obj.join('&').replace(/,/g, '-')
},
// 恢复规格值
recoverySpec() {
this.changeSpecs(true)
},
// 换图
handleChangeImg(idx) {
this.mainImgUrl = this.editForm.goodsDetailImageList[idx].content
},
// 移动图片
handleMoveImg(dirction) {
var el = document.getElementsByClassName('small-box')[0]
if (dirction == 'left') {
if (this.curMoveNum == 0) {
return true
}
this.curMoveNum = this.curMoveNum - 1
el.style.left = '-' + this.curMoveNum * 90 + 'px'
} else {
if (this.curMoveNum == this.moveNum) {
return true
}
this.curMoveNum = this.curMoveNum + 1
el.style.left = '-' + this.curMoveNum * 90 + 'px'
}
},
// handleInput(e, idx) {
// var newValue = e.target.value
// if (!this.reg.priceReg.test(newValue)) {
// newValue = ''
// }
// var oldValue = newValue
// if (e.key != 'Backspace' && newValue.length > 1) {
// oldValue = newValue.slice(0, newValue.length - 1)
// }
// this.nameToValSpecsList[idx].retailPrice = limitPrice(newValue, oldValue, 5, 2)
// },
// 跳转
// whereToGo(id) {
// document.getElementById(id).scrollIntoView()
// },
// checkSpeceData() {
// var flag = true
// for (var i = 0; i < this.nameToValSpecsList.length; i++) {
// var item = this.nameToValSpecsList[i]
// if (!item.retailPrice) {
// this.whereToGo('specificationDetailList')
// return false
// }
// if (+item.retailPrice < +item.supplyPrice) {
// this.whereToGo('specificationDetailList')
// return false
// }
// }
// return flag
// },
// handleConfirm() {
// this.submitted = true
// var flag = false
// var params = {}
// if (this.nameToValSpecsList.length) {
// if (!this.checkSpeceData()) {
// return
// }
// params.specificationDetailList = []
// this.nameToValSpecsList.forEach((item, index) => {
// params.specificationDetailList.push({
// specificationData: item.specificationData,
// specificationKey: item.specificationKey,
// retailPrice: (item.retailPrice * 100).toFixed(0)
// })
// })
// } else {
// this.$refs.editFormRef.$refs[this.editChildRef].validate(valid => {
// if (!valid) {
// flag = true
// } else {
// params = {
// retailPrice: (this.editForm.retailPrice * 100).toFixed(0)
// }
// }
// })
// }
// if (flag) {
// return true
// }
// params.id = this.routeInfo.id
// this.$apis.proManage.updateTakeProApi(params).then(res => {
// this.$message({
// message: res.code == '0' ? '操作成功' : '操作失败',
// type: res.code == '0' ? 'success' : 'error'
// })
// if (res.code == '0') {
// this.handleCancel()
// }
// })
// },
handleCancel() {
this.$router.push({
path: '/takeGood/index'
})
}
}
}
</script>
<style scoped>
.title {
padding: 13px 20px;
border-bottom: 1px solid #E5E5E5;
}
computed: {}, .view {
width: 375px;
height: 667px;
margin: 30px 45px 0 60px;
background: #F6F6F6;
position: relative;
}
mounted() {}, /* .control {
width: calc(100% - 480px);
} */
methods: {} .view img {
width: 100%;
vertical-align: top;
} }
</script> .edit-product-dh .main-img {
<style scoped> width: 375px;
height: 375px;
}
/* .edit-product-dh .flex {
display: flex;
} */
.edit-product-dh .arrow {
width: 0;
height: 0;
border-width: 20px;
border-style: solid;
margin-top: 20px;
cursor: pointer;
}
.edit-product-dh .left-arrow {
border-color: transparent #999999 transparent transparent;
}
.edit-product-dh .right-arrow {
border-color: transparent transparent transparent #999999;
}
.edit-product-dh .small-block {
position: relative;
overflow: hidden;
width: 344px;
height: 80px;
margin: 0 10px;
}
.edit-product-dh .small-box {
position: absolute;
left: 0;
}
.edit-product-dh .small-img {
width: 80px;
height: 80px;
margin-right: 8px;
cursor: pointer;
}
.edit-product-dh .pro-name {
width: 100%;
font-size: 20px;
color: #3A3A3A;
}
.edit-product-dh .supply-price {
font-size: 26px;
color: #FF6D00;
}
.edit-product-dh .border-red {
border: 1px solid red;
}
.txt-ellipsis {
display: -webkit-box;
overflow: hidden;
text-overflow: ellipsis;
-webkit-line-clamp: 1;
-webkit-box-orient: vertical;
}
/* 规格 */
.edit-product-dh .spesc-label {
padding: 1px 10px;
box-sizing: border-box;
width: 110px;
color: #666;
text-align: right;
padding-right: 12px;
}
.edit-product-dh .table-spesc {
width: 100%;
text-align: center;
margin-bottom: 0;
}
.edit-product-dh .table-spesc tbody tr {
border: 1px solid #e7e7e7;
}
.edit-product-dh .table-spesc tbody td {
display: inline-block;
box-sizing: border-box;
width: 20%;
border: none;
padding: 2px 6px;
vertical-align: center;
text-align: center;
}
.edit-product-dh .table-spesc .el-input--small .el-input__inner {
text-align: center !important;
}
.edit-product-dh .w-320 {
width: 320px;
}
.color-red {
color: #eb4e4e;
cursor: pointer;
}
/* 规格 */
</style> </style>
...@@ -74,11 +74,11 @@ export default { ...@@ -74,11 +74,11 @@ export default {
formatter: cellValue => { formatter: cellValue => {
return dayjs(cellValue.createdDate).format('YYYY-MM-DD HH:mm:ss') return dayjs(cellValue.createdDate).format('YYYY-MM-DD HH:mm:ss')
} }
},
{
label: '专区来源',
prop: ''
} }
// {
// label: '专区来源',
// prop: ''
// }
] ]
}, },
pageConf: { pageSize: 'pageSize', pageNum: 'currentPage', totalCount: 'total' } pageConf: { pageSize: 'pageSize', pageNum: 'currentPage', totalCount: 'total' }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!