增加计费列表收货时间查询
This commit is contained in:
@@ -123,11 +123,13 @@ function taskDone(task, options) {
|
||||
* @param {string} [options.filePrefix='export']
|
||||
* @param {string} [options.loadingText]
|
||||
* @param {(task: object) => void} [options.onProgress]
|
||||
* @param {number} [options.pollIntervalMs=800]
|
||||
* @param {boolean} [options.showLoading=true] full-screen ElLoading; set false when page shows its own float progress
|
||||
* @param {number} [options.pollIntervalMs=1000]
|
||||
* @param {number} [options.maxWaitMs]
|
||||
* @param {string[]} [options.successStatus]
|
||||
* @param {string[]} [options.failStatus]
|
||||
* @param {boolean} [options.showSuccessMessage=true]
|
||||
* @param {boolean} [options.showErrorMessage=true]
|
||||
*/
|
||||
export async function exportAsync(options = {}) {
|
||||
const { submitUrl, taskUrlPrefix, downloadUrlPrefix } = resolveAsyncUrls(options)
|
||||
@@ -152,11 +154,15 @@ export async function exportAsync(options = {}) {
|
||||
|
||||
const filePrefix = options.filePrefix || 'export'
|
||||
const loadingText = options.loadingText || '\u6b63\u5728\u5bfc\u51fa\uff0c\u8bf7\u7a0d\u5019'
|
||||
const pollIntervalMs = options.pollIntervalMs || 800
|
||||
const pollIntervalMs = options.pollIntervalMs || 1000
|
||||
const maxWaitMs = options.maxWaitMs || 30 * 60 * 1000
|
||||
const showSuccessMessage = options.showSuccessMessage !== false
|
||||
const showErrorMessage = options.showErrorMessage !== false
|
||||
const useLoading = options.showLoading !== false
|
||||
|
||||
const loading = ElLoading.service({ text: loadingText, background: 'rgba(0, 0, 0, 0.7)' })
|
||||
const loading = useLoading
|
||||
? ElLoading.service({ text: loadingText, background: 'rgba(0, 0, 0, 0.7)' })
|
||||
: null
|
||||
try {
|
||||
const submitRes = await request({
|
||||
url: submitUrl,
|
||||
@@ -167,15 +173,23 @@ export async function exportAsync(options = {}) {
|
||||
})
|
||||
const taskId = pickTaskId(submitRes && submitRes.data)
|
||||
if (!taskId) throw new Error('missing export taskId')
|
||||
if (typeof options.onTaskId === 'function') options.onTaskId(String(taskId))
|
||||
|
||||
const started = Date.now()
|
||||
let task = null
|
||||
let lastSig = ''
|
||||
while (Date.now() - started < maxWaitMs) {
|
||||
const hidden = typeof document !== 'undefined' && document.visibilityState === 'hidden'
|
||||
const res = await request({ url: taskUrlPrefix + String(taskId), method: 'get' })
|
||||
task = res.data || {}
|
||||
if (typeof options.onProgress === 'function') options.onProgress(task)
|
||||
const pct = Number(task.percent)
|
||||
if (!Number.isNaN(pct) && pct >= 0) {
|
||||
const st = String(task.status || task.exportStatus || '').toUpperCase()
|
||||
const sig = [st, pct, task.message, task.rowCount].join('|')
|
||||
if (typeof options.onProgress === 'function' && sig !== lastSig) {
|
||||
lastSig = sig
|
||||
options.onProgress(task)
|
||||
}
|
||||
if (loading && !Number.isNaN(pct) && pct >= 0) {
|
||||
loading.setText(loadingText + ' ' + Math.min(100, pct) + '%')
|
||||
}
|
||||
const state = taskDone(task, options)
|
||||
@@ -183,7 +197,7 @@ export async function exportAsync(options = {}) {
|
||||
if (state === 'FAIL') {
|
||||
throw new Error(task.error || task.remark || task.message || 'export failed')
|
||||
}
|
||||
await sleep(pollIntervalMs)
|
||||
await sleep(hidden ? 2500 : pollIntervalMs)
|
||||
}
|
||||
if (!task || taskDone(task, options) !== 'SUCCESS') {
|
||||
throw new Error('export timeout')
|
||||
@@ -204,10 +218,10 @@ export async function exportAsync(options = {}) {
|
||||
if (showSuccessMessage) ElMessage.success('\u5bfc\u51fa\u6210\u529f')
|
||||
return { task, taskId }
|
||||
} catch (e) {
|
||||
ElMessage.error((e && e.message) || '\u5bfc\u51fa\u5931\u8d25')
|
||||
if (showErrorMessage) ElMessage.error((e && e.message) || '\u5bfc\u51fa\u5931\u8d25')
|
||||
return null
|
||||
} finally {
|
||||
loading.close()
|
||||
if (loading) loading.close()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ export const BILLING_BILL_EXPORT_FIELDS = [
|
||||
{ prop: 'customerActiveStatusLabel', label: '客户状态' },
|
||||
{ prop: 'creditArrearsStatusLabel', label: '额度欠费' },
|
||||
{ prop: 'bizDate', label: '计费时间' },
|
||||
{ prop: 'pickupDate', label: '提货时间' },
|
||||
{ prop: 'pickupDate', label: '收货时间' },
|
||||
{ prop: 'belongSaler', label: '销售员' },
|
||||
{ prop: 'settlementMan', label: '结算员' },
|
||||
{ prop: 'serviceMan', label: '客服员' }
|
||||
|
||||
Reference in New Issue
Block a user