导出当日汇总
This commit is contained in:
@@ -59,3 +59,15 @@ export function calculateReportSumByDateAndTenant(reportDate, tenantId) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function exportLbDailyUserTradeReportByDateAndTenant(reportDate, tenantId) {
|
||||||
|
return request({
|
||||||
|
url: '/lbDailyUserTradeReport/export/by-date-and-tenant',
|
||||||
|
method: 'get',
|
||||||
|
params: {
|
||||||
|
reportDate,
|
||||||
|
tenantId
|
||||||
|
},
|
||||||
|
responseType: 'blob'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -65,6 +65,13 @@ service.interceptors.request.use(
|
|||||||
// response interceptor
|
// response interceptor
|
||||||
service.interceptors.response.use(
|
service.interceptors.response.use(
|
||||||
response => {
|
response => {
|
||||||
|
// File download responses (blob/arraybuffer) should bypass JSON normalization.
|
||||||
|
// Otherwise the logic below will treat Blob as an error object and reject.
|
||||||
|
const rt = response?.config?.responseType
|
||||||
|
if (rt === 'blob' || rt === 'arraybuffer' || (typeof Blob !== 'undefined' && response?.data instanceof Blob)) {
|
||||||
|
return response.data
|
||||||
|
}
|
||||||
|
|
||||||
const loginHeaderValues = {
|
const loginHeaderValues = {
|
||||||
'X-Role-Name': pickValueFromSources(
|
'X-Role-Name': pickValueFromSources(
|
||||||
[response.headers, response.data?.data, response.data],
|
[response.headers, response.data?.data, response.data],
|
||||||
|
|||||||
@@ -44,6 +44,7 @@
|
|||||||
<el-button type="primary" icon="el-icon-plus" @click="handleAdd">新增</el-button>
|
<el-button type="primary" icon="el-icon-plus" @click="handleAdd">新增</el-button>
|
||||||
<el-button type="warning" icon="el-icon-data-analysis" :loading="reportSumLoading" @click="openReportSumDialog">汇总数据</el-button>
|
<el-button type="warning" icon="el-icon-data-analysis" :loading="reportSumLoading" @click="openReportSumDialog">汇总数据</el-button>
|
||||||
<el-button type="danger" icon="el-icon-delete" :loading="deleteByDateLoading" @click="openDeleteByDateDialog">删除报表数据</el-button>
|
<el-button type="danger" icon="el-icon-delete" :loading="deleteByDateLoading" @click="openDeleteByDateDialog">删除报表数据</el-button>
|
||||||
|
<el-button type="success" icon="el-icon-download" :loading="exportLoading" @click="openExportDialog">报表导出</el-button>
|
||||||
</div>
|
</div>
|
||||||
<div class="action-tip">
|
<div class="action-tip">
|
||||||
说明:服务费=当日买入×0.01;差额=当日卖出−当日买入;应收应付=差额−服务费(>0 应收(当前人),<0 应付(当前人))
|
说明:服务费=当日买入×0.01;差额=当日卖出−当日买入;应收应付=差额−服务费(>0 应收(当前人),<0 应付(当前人))
|
||||||
@@ -212,6 +213,24 @@
|
|||||||
<el-button type="warning" :loading="reportSumLoading" @click="submitReportSum">确定汇总</el-button>
|
<el-button type="warning" :loading="reportSumLoading" @click="submitReportSum">确定汇总</el-button>
|
||||||
</div>
|
</div>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
|
||||||
|
<el-dialog title="报表导出" :visible.sync="exportDialogVisible" width="480px" @close="resetExportForm">
|
||||||
|
<el-form ref="exportFormRef" :model="exportForm" :rules="exportRules" label-width="120px">
|
||||||
|
<el-form-item label="报表日期" prop="reportDate">
|
||||||
|
<el-date-picker
|
||||||
|
v-model="exportForm.reportDate"
|
||||||
|
type="date"
|
||||||
|
value-format="yyyy-MM-dd"
|
||||||
|
placeholder="请选择要导出的报表日期"
|
||||||
|
style="width: 100%"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<div slot="footer" class="dialog-footer">
|
||||||
|
<el-button @click="exportDialogVisible = false">取消</el-button>
|
||||||
|
<el-button type="success" :loading="exportLoading" @click="submitExport">确定导出</el-button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -221,6 +240,7 @@ import {
|
|||||||
calculateReportSumByDateAndTenant,
|
calculateReportSumByDateAndTenant,
|
||||||
deleteLbDailyUserTradeReportByDateAndTenant,
|
deleteLbDailyUserTradeReportByDateAndTenant,
|
||||||
deleteLbDailyUserTradeReport,
|
deleteLbDailyUserTradeReport,
|
||||||
|
exportLbDailyUserTradeReportByDateAndTenant,
|
||||||
getLbDailyUserTradeReportList,
|
getLbDailyUserTradeReportList,
|
||||||
updateLbDailyUserTradeReport
|
updateLbDailyUserTradeReport
|
||||||
} from '@/api/lb-daily-user-trade-report'
|
} from '@/api/lb-daily-user-trade-report'
|
||||||
@@ -259,11 +279,13 @@ export default {
|
|||||||
submitLoading: false,
|
submitLoading: false,
|
||||||
deleteByDateLoading: false,
|
deleteByDateLoading: false,
|
||||||
reportSumLoading: false,
|
reportSumLoading: false,
|
||||||
|
exportLoading: false,
|
||||||
list: [],
|
list: [],
|
||||||
total: 0,
|
total: 0,
|
||||||
dialogVisible: false,
|
dialogVisible: false,
|
||||||
deleteByDateDialogVisible: false,
|
deleteByDateDialogVisible: false,
|
||||||
reportSumDialogVisible: false,
|
reportSumDialogVisible: false,
|
||||||
|
exportDialogVisible: false,
|
||||||
dialogTitle: '',
|
dialogTitle: '',
|
||||||
isEdit: false,
|
isEdit: false,
|
||||||
queryParams: {
|
queryParams: {
|
||||||
@@ -303,6 +325,12 @@ export default {
|
|||||||
},
|
},
|
||||||
reportSumRules: {
|
reportSumRules: {
|
||||||
reportDate: [{ required: true, message: '请选择报表日期', trigger: 'change' }]
|
reportDate: [{ required: true, message: '请选择报表日期', trigger: 'change' }]
|
||||||
|
},
|
||||||
|
exportForm: {
|
||||||
|
reportDate: getLocalTodayDateString()
|
||||||
|
},
|
||||||
|
exportRules: {
|
||||||
|
reportDate: [{ required: true, message: '请选择报表日期', trigger: 'change' }]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -423,6 +451,13 @@ export default {
|
|||||||
if (this.$refs.reportSumFormRef) this.$refs.reportSumFormRef.clearValidate()
|
if (this.$refs.reportSumFormRef) this.$refs.reportSumFormRef.clearValidate()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
openExportDialog() {
|
||||||
|
this.exportForm.reportDate = getLocalTodayDateString()
|
||||||
|
this.exportDialogVisible = true
|
||||||
|
this.$nextTick(() => {
|
||||||
|
if (this.$refs.exportFormRef) this.$refs.exportFormRef.clearValidate()
|
||||||
|
})
|
||||||
|
},
|
||||||
submitDeleteByDate() {
|
submitDeleteByDate() {
|
||||||
this.$refs.deleteByDateFormRef.validate((valid) => {
|
this.$refs.deleteByDateFormRef.validate((valid) => {
|
||||||
if (!valid) return
|
if (!valid) return
|
||||||
@@ -479,6 +514,42 @@ export default {
|
|||||||
reportDate: getLocalTodayDateString()
|
reportDate: getLocalTodayDateString()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
submitExport() {
|
||||||
|
this.$refs.exportFormRef.validate((valid) => {
|
||||||
|
if (!valid) return
|
||||||
|
const tenantId = this.getTenantIdFromBusinessHeaders()
|
||||||
|
if (!tenantId) {
|
||||||
|
this.$message.error('未获取到租户ID,请先登录或切换到正确租户后重试')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.exportLoading = true
|
||||||
|
exportLbDailyUserTradeReportByDateAndTenant(this.exportForm.reportDate, tenantId)
|
||||||
|
.then((blob) => {
|
||||||
|
const safeBlob = blob instanceof Blob ? blob : new Blob([blob], {
|
||||||
|
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
||||||
|
})
|
||||||
|
const url = window.URL.createObjectURL(safeBlob)
|
||||||
|
const link = document.createElement('a')
|
||||||
|
link.href = url
|
||||||
|
link.download = `lbDailyUserTradeReport_${this.exportForm.reportDate}_${tenantId}.xlsx`
|
||||||
|
document.body.appendChild(link)
|
||||||
|
link.click()
|
||||||
|
document.body.removeChild(link)
|
||||||
|
window.URL.revokeObjectURL(url)
|
||||||
|
this.$message.success('导出成功')
|
||||||
|
this.exportDialogVisible = false
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
this.exportLoading = false
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
resetExportForm() {
|
||||||
|
if (this.$refs.exportFormRef) this.$refs.exportFormRef.resetFields()
|
||||||
|
this.exportForm = {
|
||||||
|
reportDate: getLocalTodayDateString()
|
||||||
|
}
|
||||||
|
},
|
||||||
getTenantIdFromBusinessHeaders() {
|
getTenantIdFromBusinessHeaders() {
|
||||||
const headers = getBusinessHeaders()
|
const headers = getBusinessHeaders()
|
||||||
const value = headers && headers['X-Tenant-Id']
|
const value = headers && headers['X-Tenant-Id']
|
||||||
|
|||||||
Reference in New Issue
Block a user