Commit 8645acc9 by 李伟康

commit 查询导出增加日期限制

1 parent c5021191
......@@ -161,6 +161,7 @@
import { Util, deepClone } from '@/common/util'
import url from '@/assets/empty.png'
import ElInputRange from './el-input-range'
import dayjs from "dayjs"
export default {
components: {
ElInputRange
......@@ -455,10 +456,10 @@ export default {
}
return data
},
beforeSearchFn () {
return new Promise(resolve => {
beforeSearchFn (type) {
return new Promise((resolve, reject) => {
this.searchFormSearch = deepClone(this.searchForm)
if (this.searchForm.searchdate.length) {
if (this.searchForm?.searchdate?.length) {
let [searchStartDate, searchEndDate] = this.searchForm.searchdate
this.searchFormSearch.searchStartDate = Util.dateFormate(
searchStartDate,
......@@ -468,6 +469,10 @@ export default {
searchEndDate,
"YYYY-MM-DD"
)
const date1 = dayjs(searchStartDate),
date2 = dayjs(searchEndDate),
day = date2.diff(date1, 'day') + 1
if (day > 31) reject(`${type == 1 ? '查询' : '导出'}的时间跨度最大为31天,请重新选择日期范围`)
}
delete this.searchFormSearch.searchdate
this.searchFormSearch.serviceMerchantNo = this.$globalState.session.merchantId
......@@ -514,19 +519,24 @@ export default {
this.refreshTable()
},
async refreshTable (pageCon) {
if (pageCon) this.pageConfig = pageCon
else this.pageConfig = {
pageSize: 10,
pageNum: 1,
try {
if (pageCon) this.pageConfig = pageCon
else this.pageConfig = {
pageSize: 10,
pageNum: 1,
}
await this.beforeSearchFn(1)
const { total, list } = await this.$apis.quality.getReclistWithPage({
...this.pageConfig,
...this.searchFormSearch
})
this.$refs.qualityTable.page = this.pageConfig
this.restructureData(list)
this.tableTotal = total
} catch (error) {
console.log(error)
if (error) this.$message.error(error)
}
await this.beforeSearchFn()
const { total, list } = await this.$apis.quality.getReclistWithPage({
...this.pageConfig,
...this.searchFormSearch
})
this.$refs.qualityTable.page = this.pageConfig
this.restructureData(list)
this.tableTotal = total
},
restructureData (data) {
this.tableList = []
......@@ -655,13 +665,17 @@ export default {
}
},
async exportTable () {
await this.beforeSearchFn()
const res = await this.$apis.quality.exportReclistList({
...this.searchFormSearch,
pageNum: 1,
pageSize: 1000
})
if (res) window.open(res)
try {
await this.beforeSearchFn()
const res = await this.$apis.quality.exportReclistList({
...this.searchFormSearch,
pageNum: 1,
pageSize: 1000
})
if (res) window.open(res)
} catch (error) {
if (error) this.$message.error(error)
}
}
}
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!