Commit 8645acc9 by 李伟康

commit 查询导出增加日期限制

1 parent c5021191
...@@ -161,6 +161,7 @@ ...@@ -161,6 +161,7 @@
import { Util, deepClone } from '@/common/util' import { Util, deepClone } from '@/common/util'
import url from '@/assets/empty.png' import url from '@/assets/empty.png'
import ElInputRange from './el-input-range' import ElInputRange from './el-input-range'
import dayjs from "dayjs"
export default { export default {
components: { components: {
ElInputRange ElInputRange
...@@ -455,10 +456,10 @@ export default { ...@@ -455,10 +456,10 @@ export default {
} }
return data return data
}, },
beforeSearchFn () { beforeSearchFn (type) {
return new Promise(resolve => { return new Promise((resolve, reject) => {
this.searchFormSearch = deepClone(this.searchForm) this.searchFormSearch = deepClone(this.searchForm)
if (this.searchForm.searchdate.length) { if (this.searchForm?.searchdate?.length) {
let [searchStartDate, searchEndDate] = this.searchForm.searchdate let [searchStartDate, searchEndDate] = this.searchForm.searchdate
this.searchFormSearch.searchStartDate = Util.dateFormate( this.searchFormSearch.searchStartDate = Util.dateFormate(
searchStartDate, searchStartDate,
...@@ -468,6 +469,10 @@ export default { ...@@ -468,6 +469,10 @@ export default {
searchEndDate, searchEndDate,
"YYYY-MM-DD" "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 delete this.searchFormSearch.searchdate
this.searchFormSearch.serviceMerchantNo = this.$globalState.session.merchantId this.searchFormSearch.serviceMerchantNo = this.$globalState.session.merchantId
...@@ -514,12 +519,13 @@ export default { ...@@ -514,12 +519,13 @@ export default {
this.refreshTable() this.refreshTable()
}, },
async refreshTable (pageCon) { async refreshTable (pageCon) {
try {
if (pageCon) this.pageConfig = pageCon if (pageCon) this.pageConfig = pageCon
else this.pageConfig = { else this.pageConfig = {
pageSize: 10, pageSize: 10,
pageNum: 1, pageNum: 1,
} }
await this.beforeSearchFn() await this.beforeSearchFn(1)
const { total, list } = await this.$apis.quality.getReclistWithPage({ const { total, list } = await this.$apis.quality.getReclistWithPage({
...this.pageConfig, ...this.pageConfig,
...this.searchFormSearch ...this.searchFormSearch
...@@ -527,6 +533,10 @@ export default { ...@@ -527,6 +533,10 @@ export default {
this.$refs.qualityTable.page = this.pageConfig this.$refs.qualityTable.page = this.pageConfig
this.restructureData(list) this.restructureData(list)
this.tableTotal = total this.tableTotal = total
} catch (error) {
console.log(error)
if (error) this.$message.error(error)
}
}, },
restructureData (data) { restructureData (data) {
this.tableList = [] this.tableList = []
...@@ -655,6 +665,7 @@ export default { ...@@ -655,6 +665,7 @@ export default {
} }
}, },
async exportTable () { async exportTable () {
try {
await this.beforeSearchFn() await this.beforeSearchFn()
const res = await this.$apis.quality.exportReclistList({ const res = await this.$apis.quality.exportReclistList({
...this.searchFormSearch, ...this.searchFormSearch,
...@@ -662,6 +673,9 @@ export default { ...@@ -662,6 +673,9 @@ export default {
pageSize: 1000 pageSize: 1000
}) })
if (res) window.open(res) 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!