Commit 9d9aac99 by 李伟康

提交

1 parent 582befd9
......@@ -22,8 +22,7 @@ export default {
getRedEnvelopeMerchantList (params) {
params.method = 'scrm.api.carlife.merchant.listWithPageByCurMerchant'
params.pageSize = 999999
params.currentPage = 1
params.pageSize = 50
return http({
url: '/rop-scrm-carlife/router',
data: params
......
......@@ -6,14 +6,14 @@
accept=".xlsx"
/>
<table v-if="parsedData.length > 0">
<thead>
<!-- <thead>
<tr>
<th
v-for="(header, index) in parsedData[0]"
:key="index"
>{{ header }}</th>
</tr>
</thead>
</thead> -->
<tbody>
<tr
v-for="(row, rowIndex) in parsedData"
......@@ -30,7 +30,7 @@
</template>
<script type='text/ecmascript-6'>
import XLSX from 'xlsx';
import * as XLSX from 'xlsx'
export default {
name: '',
data () {
......@@ -42,26 +42,24 @@ export default {
},
methods: {
handleFileUpload (event) {
const file = event.target.files[0];
const [file] = event.target.files
if (file) {
const reader = new FileReader();
const reader = new FileReader()
reader.onload = (e) => {
try {
const data = e.target.result;
const data = e.target.result
if (data) {
const workbook = XLSX.read(data, { type: 'array' });
const firstSheetName = workbook.SheetNames[0];
const worksheet = workbook.Sheets[firstSheetName];
this.parsedData = XLSX.utils.sheet_to_json(worksheet, { header: 1 });
} else {
console.error('File data is empty.');
}
const workbook = XLSX.read(data, { type: 'array' }),
firstSheetName = workbook.SheetNames[0],
worksheet = workbook.Sheets[firstSheetName]
this.parsedData = XLSX.utils.sheet_to_json(worksheet, { header: 1 })
console.log(this.parsedData)
} else throw 'File data is empty.'
} 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 @@
placeholder="请选择"
:disabled="disabled"
filterable
remote
:remote-method="remoteMethod"
v-reachbottom="onReachBottom"
@focus="selectFocus"
:loading="loading"
>
<el-option
v-for="item in merchantList"
......@@ -48,6 +53,9 @@
:label="item.confName"
:value="item.confId"
></el-option>
<template v-if="nothing">
<div class="nothing">到底了!</div>
</template>
</el-select>
</el-form-item>
<el-form-item
......@@ -198,11 +206,16 @@ export default {
},
merchantList: [],
fileName: '',
fileError: ''
fileError: '',
loading: false,
currentPage: 1,
total: 0,
nothing: false,
merchantName: ''
}
},
mounted () {
this.getMerchantList()
},
watch: {
'editObj' (n) {
......@@ -210,19 +223,63 @@ export default {
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: {
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) {
try {
const { configForm } = this,
res = await this.$apis.redenvelope.getRedEnvelopeActivityDetail({ id })
res = await this.$apis.redenvelope.getRedEnvelopeActivityDetail({ id }),
merchantId = String(res.merchantId)
this.configForm = {
...configForm,
activityName: res.activityName,
activityType: res.activityType,
merchantId: String(res.merchantId),
merchantId,
activityTime: [dayjs(res.activityStartTime).toDate(), dayjs(res.activityEndTime).toDate()],
id
}
this.merchantList = [{
confId: merchantId,
confName: res.merchantName
}]
this.disabled = true
this.configRules.exportUrl[0].required = false
console.log(res)
......@@ -231,8 +288,12 @@ export default {
}
},
async getMerchantList () {
const { list } = await this.$apis.redenvelope.getRedEnvelopeMerchantList({})
let merchantList = []
const { currentPage, merchantList, merchantName } = this,
{ list, total } = await this.$apis.redenvelope.getRedEnvelopeMerchantList({
currentPage,
merchantName
})
this.total = total
list && list.map(e => {
merchantList.push({
confId: e.merchantNo,
......@@ -240,12 +301,14 @@ export default {
})
})
this.merchantList = merchantList
this.loading = false
},
handleClose () {
this.configForm = this.$options.data.call(this).configForm
this.disabled = false
this.fileError = ''
this.$refs.configRef.resetFields()
this.merchantList = []
this.$emit('update:editObj', {})
},
handleConfirm () {
......@@ -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>
\ 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!