Commit 9d9aac99 by 李伟康

提交

1 parent 582befd9
...@@ -22,8 +22,7 @@ export default { ...@@ -22,8 +22,7 @@ export default {
getRedEnvelopeMerchantList (params) { getRedEnvelopeMerchantList (params) {
params.method = 'scrm.api.carlife.merchant.listWithPageByCurMerchant' params.method = 'scrm.api.carlife.merchant.listWithPageByCurMerchant'
params.pageSize = 999999 params.pageSize = 50
params.currentPage = 1
return http({ return http({
url: '/rop-scrm-carlife/router', url: '/rop-scrm-carlife/router',
data: params data: params
......
...@@ -6,14 +6,14 @@ ...@@ -6,14 +6,14 @@
accept=".xlsx" accept=".xlsx"
/> />
<table v-if="parsedData.length > 0"> <table v-if="parsedData.length > 0">
<thead> <!-- <thead>
<tr> <tr>
<th <th
v-for="(header, index) in parsedData[0]" v-for="(header, index) in parsedData[0]"
:key="index" :key="index"
>{{ header }}</th> >{{ header }}</th>
</tr> </tr>
</thead> </thead> -->
<tbody> <tbody>
<tr <tr
v-for="(row, rowIndex) in parsedData" v-for="(row, rowIndex) in parsedData"
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
</template> </template>
<script type='text/ecmascript-6'> <script type='text/ecmascript-6'>
import XLSX from 'xlsx'; import * as XLSX from 'xlsx'
export default { export default {
name: '', name: '',
data () { data () {
...@@ -42,26 +42,24 @@ export default { ...@@ -42,26 +42,24 @@ export default {
}, },
methods: { methods: {
handleFileUpload (event) { handleFileUpload (event) {
const file = event.target.files[0]; const [file] = event.target.files
if (file) { if (file) {
const reader = new FileReader(); const reader = new FileReader()
reader.onload = (e) => { reader.onload = (e) => {
try { try {
const data = e.target.result; const data = e.target.result
if (data) { if (data) {
const workbook = XLSX.read(data, { type: 'array' }); const workbook = XLSX.read(data, { type: 'array' }),
const firstSheetName = workbook.SheetNames[0]; firstSheetName = workbook.SheetNames[0],
const worksheet = workbook.Sheets[firstSheetName]; worksheet = workbook.Sheets[firstSheetName]
this.parsedData = XLSX.utils.sheet_to_json(worksheet, { header: 1 }); this.parsedData = XLSX.utils.sheet_to_json(worksheet, { header: 1 })
} else { console.log(this.parsedData)
console.error('File data is empty.'); } else throw 'File data is empty.'
}
} catch (error) { } catch (error) {
console.error('Error reading the file:', error); this.$message.error(error || 'Error reading the file')
} }
}; }
reader.readAsArrayBuffer(file)
reader.readAsArrayBuffer(file);
} }
}, },
} }
......
...@@ -41,6 +41,11 @@ ...@@ -41,6 +41,11 @@
placeholder="请选择" placeholder="请选择"
:disabled="disabled" :disabled="disabled"
filterable filterable
remote
:remote-method="remoteMethod"
v-reachbottom="onReachBottom"
@focus="selectFocus"
:loading="loading"
> >
<el-option <el-option
v-for="item in merchantList" v-for="item in merchantList"
...@@ -48,6 +53,9 @@ ...@@ -48,6 +53,9 @@
:label="item.confName" :label="item.confName"
:value="item.confId" :value="item.confId"
></el-option> ></el-option>
<template v-if="nothing">
<div class="nothing">到底了!</div>
</template>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item <el-form-item
...@@ -198,11 +206,16 @@ export default { ...@@ -198,11 +206,16 @@ export default {
}, },
merchantList: [], merchantList: [],
fileName: '', fileName: '',
fileError: '' fileError: '',
loading: false,
currentPage: 1,
total: 0,
nothing: false,
merchantName: ''
} }
}, },
mounted () { mounted () {
this.getMerchantList()
}, },
watch: { watch: {
'editObj' (n) { 'editObj' (n) {
...@@ -210,19 +223,63 @@ export default { ...@@ -210,19 +223,63 @@ export default {
if (n.id) this.getRedEnvelopeActivityDetail(n.id) if (n.id) this.getRedEnvelopeActivityDetail(n.id)
} }
}, },
directives: {
'reachbottom': {
inserted (el, binding) {
const SELECTWRAP_DOM = el.querySelector('.el-select-dropdown .el-select-dropdown__wrap')
SELECTWRAP_DOM.addEventListener('scroll', function () {
const condition = this.scrollHeight - this.scrollTop <= this.clientHeight
if (condition) binding.value()
})
}
}
},
methods: { methods: {
selectFocus () {
const { configForm } = this
if (!configForm.merchantId) {
this.merchantList = []
this.merchantName = ''
this.currentPage = 1
this.getMerchantList()
}
},
onReachBottom () {
const { total, currentPage } = this
if (Math.ceil(total / 50) > currentPage) {
this.currentPage += 1
this.getMerchantList()
} else this.nothing = true
},
remoteMethod (val) {
this.merchantName = val
if (val) {
this.loading = true
this.configForm.merchantId = ''
this.nothing = false
this.merchantList = []
this.currentPage = 1
this.getMerchantList(val)
}
},
async getRedEnvelopeActivityDetail (id) { async getRedEnvelopeActivityDetail (id) {
try { try {
const { configForm } = this, const { configForm } = this,
res = await this.$apis.redenvelope.getRedEnvelopeActivityDetail({ id }) res = await this.$apis.redenvelope.getRedEnvelopeActivityDetail({ id }),
merchantId = String(res.merchantId)
this.configForm = { this.configForm = {
...configForm, ...configForm,
activityName: res.activityName, activityName: res.activityName,
activityType: res.activityType, activityType: res.activityType,
merchantId: String(res.merchantId), merchantId,
activityTime: [dayjs(res.activityStartTime).toDate(), dayjs(res.activityEndTime).toDate()], activityTime: [dayjs(res.activityStartTime).toDate(), dayjs(res.activityEndTime).toDate()],
id id
} }
this.merchantList = [{
confId: merchantId,
confName: res.merchantName
}]
this.disabled = true this.disabled = true
this.configRules.exportUrl[0].required = false this.configRules.exportUrl[0].required = false
console.log(res) console.log(res)
...@@ -231,8 +288,12 @@ export default { ...@@ -231,8 +288,12 @@ export default {
} }
}, },
async getMerchantList () { async getMerchantList () {
const { list } = await this.$apis.redenvelope.getRedEnvelopeMerchantList({}) const { currentPage, merchantList, merchantName } = this,
let merchantList = [] { list, total } = await this.$apis.redenvelope.getRedEnvelopeMerchantList({
currentPage,
merchantName
})
this.total = total
list && list.map(e => { list && list.map(e => {
merchantList.push({ merchantList.push({
confId: e.merchantNo, confId: e.merchantNo,
...@@ -240,12 +301,14 @@ export default { ...@@ -240,12 +301,14 @@ export default {
}) })
}) })
this.merchantList = merchantList this.merchantList = merchantList
this.loading = false
}, },
handleClose () { handleClose () {
this.configForm = this.$options.data.call(this).configForm this.configForm = this.$options.data.call(this).configForm
this.disabled = false this.disabled = false
this.fileError = '' this.fileError = ''
this.$refs.configRef.resetFields() this.$refs.configRef.resetFields()
this.merchantList = []
this.$emit('update:editObj', {}) this.$emit('update:editObj', {})
}, },
handleConfirm () { handleConfirm () {
...@@ -352,4 +415,13 @@ export default { ...@@ -352,4 +415,13 @@ export default {
} }
} }
} }
.nothing {
font-size: 14px;
padding: 0 20px;
white-space: nowrap;
color: #606266;
height: 34px;
line-height: 34px;
text-align: center;
}
</style> </style>
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!