Commit d0dfde16 by chenwq

格式化

1 parent 2a3a0053
<template>
<div
class="layout"
v-loading="loading"
>
<div class="layout" v-loading="loading">
<div class="content">
<div class="title">积分充值</div>
<el-scrollbar class="box">
......@@ -21,59 +18,30 @@
</div>
</div>
</template>
<glsx-combi-form
ref="fromRef"
:isEdit="true"
:isBlock="true"
:formObj="configForm"
:formData="formData"
:formRules="rule"
>
<glsx-combi-form ref="fromRef" :isEdit="true" :isBlock="true" :formObj="configForm" :formData="formData" :formRules="rule">
<template #merchantId>
<div class="upload">
<div class="upload-btn">
<el-button
size="small"
@click="relateStoreVisible = true"
:disabled="pageObject.id"
>
<el-button size="small" @click="relateStoreVisible = true" :disabled="pageObject.id">
<i class="el-icon-plus"></i>
选择商户
</el-button>
</div>
</div>
<template v-if="configForm.merchantId">
<GLTable
:tableData="[configForm]"
:tableParams="merchantParams"
:hasPage="false"
class="merchant-box"
></GLTable>
<GLTable :tableData="[configForm]" :tableParams="merchantParams" :hasPage="false" class="merchant-box"></GLTable>
</template>
</template>
<template #table>
<div class="upload">
<div class="upload-btn">
<el-button
size="small"
:disabled="pageObject.disabled"
>
<el-button size="small" :disabled="pageObject.disabled">
<i class="el-icon-plus"></i>
上传名单
</el-button>
<input
type="file"
ref="file"
accept=".xlsx, .xlc, .xlm, .xls"
@change="uploadFile"
:disabled="pageObject.disabled"
:class="['input',{'is-disabled':pageObject.disabled}]"
/>
<input type="file" ref="file" accept=".xlsx, .xlc, .xlm, .xls" @change="uploadFile" :disabled="pageObject.disabled" :class="['input',{'is-disabled':pageObject.disabled}]" />
</div>
<a
href="https://img01.glsx.com.cn/weapp/resource/saas/scrm/xlsx/客户积分导入模板.xlsx"
target="_blank"
>下载模板</a>
<a href="https://img01.glsx.com.cn/weapp/resource/saas/scrm/xlsx/客户积分导入模板.xlsx" target="_blank">下载模板</a>
</div>
<template v-if="importObject.detailList">
<template v-if="importObject.name">
......@@ -84,125 +52,65 @@
</template>
<div class="table-box">
<div class="table">
<GLTable
:tableData="importObject.detailList[pageNum - 1]"
:tableParams="tableParams"
ref="listRef"
:pageConf="pageConf"
:tableTotal="totalForm.customerTotal"
:pageSizes="[50]"
@refreshTable="refreshTable"
>
<template
slot="cashBackValue"
slot-scope="scope"
>
<GLTable :tableData="importObject.detailList[pageNum - 1]" :tableParams="tableParams" ref="listRef" :pageConf="pageConf" :tableTotal="totalForm.customerTotal" :pageSizes="[50]" @refreshTable="refreshTable">
<template slot="cashBackValue" slot-scope="scope">
<template v-if="!pageObject.disabled">
<el-input
v-model.number.trim="scope.scope.cashBackValue"
@blur="updateTotal(scope.scope, scope.index, 'cashBackValue')"
maxLength="6"
></el-input>
<el-input v-model.number.trim="scope.scope.cashBackValue" @blur="updateTotal(scope.scope, scope.index, 'cashBackValue')" maxLength="6"></el-input>
</template>
<template v-else>
{{scope.scope.cashBackValue || '-'}}
</template>
</template>
<template
slot="buyValue"
slot-scope="scope"
>
<template slot="buyValue" slot-scope="scope">
<template v-if="!pageObject.disabled">
<el-input
v-model.number.trim="scope.scope.buyValue"
@blur="updateTotal(scope.scope, scope.index,'buyValue')"
maxLength="6"
></el-input>
<el-input v-model.number.trim="scope.scope.buyValue" @blur="updateTotal(scope.scope, scope.index,'buyValue')" maxLength="6"></el-input>
</template>
<template v-else>
{{scope.scope.buyValue || '-'}}
</template>
</template>
<template
slot="oilList"
slot-scope="scope"
>
<template slot="oilList" slot-scope="scope">
<template v-if="scope.scope.oilList && scope.scope.oilList.length">
<div class="flex">
<span>{{ filterData(scope.scope.oilList,'oilList').slice(0, 1).join('、') }}</span>
<el-popover
placement="top"
width="fit-content"
trigger="hover"
>
<div
v-for="(item,index) in filterData(scope.scope.oilList,'oilList')"
:key="index"
>
<el-popover placement="top" width="fit-content" trigger="hover">
<div v-for="(item,index) in filterData(scope.scope.oilList,'oilList')" :key="index">
{{item}}
</div>
<span
class="more-info"
slot="reference"
>...({{ scope.scope.oilList.length }})</span>
<span class="more-info" slot="reference">...({{ scope.scope.oilList.length }})</span>
</el-popover>
<template v-if="!pageObject.disabled">
<el-button
type="text"
@click="showConfig(scope.scope, scope.index)"
>编辑</el-button>
<el-button type="text" @click="showConfig(scope.scope, scope.index)">编辑</el-button>
</template>
</div>
</template>
<template v-else>
<template v-if="!pageObject.disabled">
<el-button
type="text"
@click="showConfig(scope.scope, scope.index)"
>配置</el-button>
<el-button type="text" @click="showConfig(scope.scope, scope.index)">配置</el-button>
</template>
<template v-else>
无
</template>
</template>
</template>
<template
slot="couponList"
slot-scope="scope"
>
<template slot="couponList" slot-scope="scope">
<template v-if="scope.scope.couponList && scope.scope.couponList.length">
<div class="flex">
<span>{{ filterData(scope.scope.couponList,'couponList').slice(0, 1).join('、') }}</span>
<el-popover
placement="top"
width="fit-content"
trigger="hover"
>
<div
v-for="(item,index) in filterData(scope.scope.couponList,'couponList')"
:key="index"
>
<el-popover placement="top" width="fit-content" trigger="hover">
<div v-for="(item,index) in filterData(scope.scope.couponList,'couponList')" :key="index">
{{item}}
</div>
<span
class="more-info"
slot="reference"
>...({{ scope.scope.couponList.length }})</span>
<span class="more-info" slot="reference">...({{ scope.scope.couponList.length }})</span>
</el-popover>
<template v-if="!pageObject.disabled">
<el-button
type="text"
@click="showConfig(scope.scope, scope.index, 1)"
>编辑</el-button>
<el-button type="text" @click="showConfig(scope.scope, scope.index, 1)">编辑</el-button>
</template>
</div>
</template>
<template v-else>
<template v-if="!pageObject.disabled">
<el-button
type="text"
@click="showConfig(scope.scope, scope.index, 1)"
>配置</el-button>
<el-button type="text" @click="showConfig(scope.scope, scope.index, 1)">配置</el-button>
</template>
<template v-else>
无
......@@ -211,21 +119,12 @@
</template>
</GLTable>
</div>
<div
class="total"
:key="totalKey"
>
<div class="total" :key="totalKey">
<template v-for="(i, index) in totalFormData">
<template>
<div
:key="index"
class="item flex"
>
<div :key="index" class="item flex">
<div class="label">{{ i.label }}:</div>
<div
class="value"
:ref="`value-${index}`"
>
<div class="value" :ref="`value-${index}`">
<template v-if="i.formatter">
{{ i.formatter(totalForm) }}
</template>
......@@ -244,30 +143,12 @@
</el-scrollbar>
</div>
<GLFooter class="footer">
<el-button
@click="$router.go(-1)"
size="medium"
>取消</el-button>
<el-button
v-if="!isWatchPage"
type="primary"
@click="handleConfirm"
size="medium"
>确定</el-button>
<el-button @click="$router.go(-1)" size="medium">取消</el-button>
<el-button v-if="!isWatchPage" type="primary" @click="handleConfirm" size="medium">确定</el-button>
</GLFooter>
<select-store
:dialogVisible.sync="relateStoreVisible"
:storeSelected="selectedList"
:merchantInfo="configForm"
@handleRelateStoreConfirm="handleRelateStoreConfirm"
@handleRelateStoreClose="handleRelateStoreClose"
/>
<points-config
:configParams.sync="configParams"
:merchantId="configForm.merchantId"
@confirm="changeRowConfig"
/>
<select-store :dialogVisible.sync="relateStoreVisible" :storeSelected="selectedList" :merchantInfo="configForm" @handleRelateStoreConfirm="handleRelateStoreConfirm" @handleRelateStoreClose="handleRelateStoreClose" />
<points-config :configParams.sync="configParams" :merchantId="configForm.merchantId" @confirm="changeRowConfig" />
<import-err-dialog :importObj.sync="importObj" />
</div>
......@@ -292,7 +173,7 @@ export default {
importErrDialog
},
name: '',
data () {
data() {
return {
NP,
loading: false,
......@@ -461,19 +342,19 @@ export default {
passageServiceCharge: 0
},
pageNum: 1,
isWatchPage:false
isWatchPage: false
}
},
mounted () {
mounted() {
const { id, type } = this.$route.query
if (id) this.getDetail(id, type)
this.isWatchPage = !type
},
methods: {
refreshTable ({ pageNum }) {
refreshTable({ pageNum }) {
this.pageNum = pageNum
},
async getDetail (id, type) {
async getDetail(id, type) {
try {
this.loading = true
const res = await this.$apis.points.getIntegralDetail({ id }),
......@@ -509,7 +390,7 @@ export default {
setTimeout(() => this.$router.go(-1), 1e3)
}
},
handleConfirm () {
handleConfirm() {
const { disabled, id } = this.pageObject
if (disabled) return this.$router.go(-1)
this.$refs.fromRef.$refs.formRef.validate(async valid => {
......@@ -571,7 +452,7 @@ export default {
}
})
},
async uploadFile (e) {
async uploadFile(e) {
try {
const [file] = e.srcElement.files
if (!file) return
......@@ -625,7 +506,7 @@ export default {
if (error) this.$message.error(error)
}
},
setTableHeight (detailList = []) {
setTableHeight(detailList = []) {
const { listRef } = this.$refs
if (listRef) {
let length = detailList.length
......@@ -636,13 +517,13 @@ export default {
},
// 选择门店
handleRelateStoreClose () {
handleRelateStoreClose() {
this.relateStoreVisible = false
},
validateField (id) {
validateField(id) {
this.$refs.fromRef.$refs.formRef.validateField(id)
},
async handleRelateStoreConfirm (selectedData, isEdit) {
async handleRelateStoreConfirm(selectedData, isEdit) {
selectedData.merchantId && (this.$set(this.configForm, 'merchantId', selectedData.merchantId))
selectedData.merchantName && (this.$set(this.configForm, 'merchantName', selectedData.merchantName))
this.validateField('merchantId')
......@@ -665,7 +546,7 @@ export default {
}
},
showConfig (row, index, type = 0) {
showConfig(row, index, type = 0) {
this.configParams = {
show: true,
row,
......@@ -675,7 +556,7 @@ export default {
couponList: JSON.parse(JSON.stringify(row.couponList || [])),
}
},
setRowTotal (row, index) {
setRowTotal(row, index) {
const { oilList, cashBackValue, buyValue } = row
let total = NP.plus((cashBackValue || 0), (buyValue || 0))
oilList && oilList.map(i => total += NP.times((i.amount || 0), (i.salesPrice || 0), 0.01))
......@@ -683,7 +564,7 @@ export default {
this.totalForm.total[index] = total
this.updateView()
},
changeRowConfig ({
changeRowConfig({
oilList,
couponList
}) {
......@@ -696,13 +577,13 @@ export default {
this.setGasService(row, index)
}
},
setPassageService (row, index) {
setPassageService(row, index) {
const { cashBackValue, buyValue } = row,
passageService = NP.plus((cashBackValue || 0), (buyValue || 0))
this.totalForm.passageService[index] = passageService
this.updateView()
},
setGasService (row, index) {
setGasService(row, index) {
const { oilList } = row
let total = 0
if (oilList && oilList.length) oilList.map(i => {
......@@ -711,13 +592,13 @@ export default {
this.totalForm.gasService[index] = total
this.updateView()
},
updateTotal (row, index, key) {
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 () {
updateView() {
this.totalKey = Date.now()
const REF = this.$refs,
refLength = this.totalFormData.length
......@@ -736,12 +617,12 @@ export default {
}
})
},
filterData (list, name) {
filterData(list, name) {
return list?.map(i => {
return name == 'oilList' ? `${i.aliasName}*${i.amount} (${NP.times(i.amount, i.salesPrice, 0.01)}积分)` : `${i.couponName}*${i.amount}`
}) || []
},
splitArray (arr, size) {
splitArray(arr, size) {
let result = [],
newArr = JSON.parse(JSON.stringify(arr))
for (let i = 0; i < newArr.length; i += size) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!