Commit d2324703 by 李伟康

提交

1 parent 89ef5ac1
......@@ -35,7 +35,7 @@
<el-button
size="small"
@click="relateStoreVisible = true"
:disabled="pageObject.disabled"
:disabled="pageObject.id"
>
<i class="el-icon-plus"></i>
选择商户
......@@ -75,13 +75,13 @@
target="_blank"
>下载模板</a>
</div>
<div class="file-info flex">
<template v-if="importObject.name">
<div class="el-icon-success"></div>
文件格式正确({{ importObject.name }})
</template>
</div>
<template v-if="importObject.detailList">
<div class="file-info flex">
<template v-if="importObject.name">
<div class="el-icon-success"></div>
文件格式正确({{ importObject.name }})
</template>
</div>
<div class="table-box">
<GLTable
:tableData="importObject.detailList"
......@@ -95,8 +95,8 @@
<template v-if="!pageObject.disabled">
<el-input
v-model.number.trim="scope.scope.cashBackValue"
:disabled="pageObject.disabled"
@blur="updateTotal(scope.scope, scope.index)"
@blur="updateTotal(scope.scope, scope.index, 'cashBackValue')"
maxLength="6"
></el-input>
</template>
<template v-else>
......@@ -110,7 +110,8 @@
<template v-if="!pageObject.disabled">
<el-input
v-model.number.trim="scope.scope.buyValue"
@blur="updateTotal(scope.scope, scope.index)"
@blur="updateTotal(scope.scope, scope.index,'buyValue')"
maxLength="6"
></el-input>
</template>
<template v-else>
......@@ -201,7 +202,10 @@
class="item flex"
>
<div class="label">{{ i.label }}:</div>
<div class="value">
<div
class="value"
:ref="`value-${index}`"
>
<template v-if="i.formatter">
{{ i.formatter(totalForm) }}
</template>
......@@ -234,7 +238,7 @@
<select-store
:dialogVisible.sync="relateStoreVisible"
:storeSelected="selectedList"
:merchantInfo="configForm.merchantId"
:merchantInfo="configForm"
@handleRelateStoreConfirm="handleRelateStoreConfirm"
@handleRelateStoreClose="handleRelateStoreClose"
/>
......@@ -320,8 +324,10 @@ export default {
name: 'passageServiceCharge',
formatter: (cell) => {
const { passageService } = cell,
{ passageServiceCharge } = chargeObject
return NP.times(passageService.reduce((acc, cur) => acc + cur, 0), passageServiceCharge).toFixed(2)
{ passageServiceCharge } = chargeObject,
passageSum = passageService.reduce((acc, cur) => acc + cur, 0),
sum = NP.times(passageSum, passageServiceCharge).toFixed(2)
return `${passageSum}*${passageServiceCharge}%=${sum}`
}
},
{
......@@ -329,8 +335,10 @@ export default {
name: 'gasCardServiceCharge',
formatter: (cell) => {
const { gasService } = cell,
{ gasCardServiceCharge } = chargeObject
return NP.times(gasService.reduce((acc, cur) => acc + cur, 0), gasCardServiceCharge).toFixed(2)
{ gasCardServiceCharge } = chargeObject,
gasCardSum = gasService.reduce((acc, cur) => acc + cur, 0),
sum = NP.times(gasCardSum, gasCardServiceCharge).toFixed(2)
return `${gasCardSum}*${gasCardServiceCharge}%=${sum}`
}
},
{
......@@ -431,6 +439,7 @@ export default {
methods: {
async getDetail (id, type) {
try {
this.loading = true
const res = await this.$apis.points.getIntegralDetail({ id }),
{ detailList } = res
detailList.map((row, index) => {
......@@ -452,7 +461,9 @@ export default {
this.importObject = {
detailList
}
this.loading = false
} catch (error) {
this.loading = false
setTimeout(() => this.$router.go(-1), 1e3)
}
},
......@@ -462,11 +473,27 @@ export default {
this.$refs.fromRef.$refs.formRef.validate(async valid => {
if (valid) {
try {
this.$loading()
this.loading = true
const { merchantId, merchantName } = this.configForm,
list = this.importObject.detailList
let detailList = []
list.map(e => {
let oilList = [], couponList = []
e.oilList?.map(o => {
oilList.push({
oilCouponId: o.oilCouponId,
amount: o.amount,
faceValue: o.faceValue,
aliasName: o.aliasName
})
})
e.couponList?.map(c => {
couponList.push({
couponId: c.couponId,
amount: c.amount,
couponName: c.couponName
})
})
detailList.push({
policyNo: e.policyNo,
customerName: e.customerName,
......@@ -474,8 +501,8 @@ export default {
idCardNo: e.idCardNo,
cashBackValue: e.cashBackValue,
buyValue: e.buyValue,
oilList: e.oilList || [],
couponList: e.couponList || []
oilList,
couponList
})
})
let params = {
......@@ -486,16 +513,16 @@ export default {
if (id) params.id = id
const res = await this.$apis.points.updateCustomerIntegral(params)
if (res) {
this.$loading().close()
this.$message({
message: id ? '编辑成功' : '创建成功',
type: 'success'
})
setTimeout(() => this.$router.go(-1), 1e3)
} else throw '创建失败'
}
this.loading = false
} catch (error) {
this.$loading().close()
if (error) this.$message.error(error)
this.loading = false
this.$message.error(error || '操作失败')
}
}
})
......@@ -570,7 +597,7 @@ export default {
chargeObject[e.name] = val
}
})
this.totalKey = Date.now()
this.updateView()
}
} catch (error) {
if (error) this.$message.error(error)
......@@ -593,7 +620,7 @@ export default {
oilList && oilList.map(i => total += NP.times((i.amount || 0), (i.faceValue || 0)))
row.total = total
this.totalForm.total[index] = total
this.totalKey = Date.now()
this.updateView()
},
changeRowConfig ({
oilList,
......@@ -612,7 +639,7 @@ export default {
const { cashBackValue, buyValue } = row,
passageService = NP.plus((cashBackValue || 0), (buyValue || 0))
this.totalForm.passageService[index] = passageService
this.totalKey = Date.now()
this.updateView()
},
setGasService (row, index) {
const { oilList } = row
......@@ -621,12 +648,32 @@ export default {
total += NP.times((i.amount || 0), (i.faceValue || 0))
})
this.totalForm.gasService[index] = total
this.totalKey = Date.now()
this.updateView()
},
updateTotal (row, index) {
updateTotal (row, index, key) {
if (key && !/^[0-9]\d*$/.test(row[key])) row[key] = ''
this.setRowTotal(row, index)
this.setPassageService(row, index)
this.setGasService(row, index)
},
updateView () {
this.totalKey = Date.now()
const REF = this.$refs,
refLength = this.totalFormData.length
this.$nextTick(() => {
let widthList = []
for (let i = 0; i < refLength; i++) {
let [item] = REF[`value-${i}`] || []
if (item) widthList.push(item.offsetWidth)
}
if (widthList.length) {
const width = Math.max.apply(null, widthList)
for (let i = 0; i < refLength; i++) {
let [item] = REF[`value-${i}`] || []
if (item) item.style.width = `${width}px`
}
}
})
}
}
......@@ -766,6 +813,7 @@ export default {
}
.value {
min-width: 90px;
color: #333333;
}
}
}
......
......@@ -159,28 +159,24 @@ export default {
},
methods: {
init () {
this.merchantId = this.merchantInfo
this.merchantId = String(this.merchantInfo.merchantId)
this.merchantName = this.merchantInfo.merchantName
this.getList()
},
getList (pageCon) {
console.log(pageCon, 'pageCon')
pageCon && (this.pageConfig = pageCon)
var params = {
merchantId: this.merchantId,
...this.searchForm,
...this.pageConfig
}
console.log(this.$apis)
this.$apis.common.getMerchantList(params).then(res => {
console.log(res)
this.storeList = res.list
this.total = res.total
let nowIndex = this.pageConfig.pageSize * (this.pageConfig.currentPage - 1)
console.log(nowIndex)
this.storeList.forEach((item, index) => {
item.idx = index + 1 + nowIndex
})
console.log(this.storeList)
})
},
getTable () {
......@@ -192,7 +188,6 @@ export default {
this.$refs.staffRef.tableHeightValues = '460px'
},
handleClick (val) {
console.log(val)
this.merchantId = val.merchantNo
this.merchantName = val.merchantName
},
......@@ -204,10 +199,12 @@ export default {
this.$emit('handleRelateStoreClose')
},
handleConfirm () {
this.$emit('handleRelateStoreConfirm', {
merchantId: this.merchantId,
merchantName: this.merchantName
const { merchantId, merchantName } = this
if (merchantId && merchantName) this.$emit('handleRelateStoreConfirm', {
merchantId,
merchantName
})
else this.handleClose()
}
}
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!