导出纳新

This commit is contained in:
zhonghua.li
2026-05-16 21:23:07 +08:00
parent baddbb9369
commit 4c61fc8828
2 changed files with 134 additions and 0 deletions

View File

@@ -65,6 +65,20 @@ export function syncHxrAdminUserVip(params) {
})
}
/** 按租户ID与申请日期范围导出进货申请 Excel */
export function exportLbPurchaseApply(params) {
return request({
url: '/lbPurchaseApply/export',
method: 'get',
params: {
applyDateStart: params.applyDateStart,
applyDateEnd: params.applyDateEnd,
tenantId: params.tenantId
},
responseType: 'blob'
})
}
/** 按申请日期区间与租户同步同事 hxrd 用户 VIP可能较慢依赖外部管理端 */
export function syncHxrAdminColleagueVip(params) {
return request({

View File

@@ -51,6 +51,14 @@
<el-button type="success" icon="el-icon-present" style="margin-left: 12px" @click="openColleagueVipDialog">
开通同事特权
</el-button>
<el-button
type="success"
icon="el-icon-download"
style="margin-left: 12px"
@click="openExportNewcomerPrivilegeDialog"
>
导出新人特权
</el-button>
</el-card>
<el-card class="table-container" shadow="never">
@@ -271,6 +279,41 @@
</div>
</el-dialog>
<el-dialog
title="导出新人特权"
:visible.sync="exportNewcomerPrivilegeDialogVisible"
width="520px"
@close="resetExportNewcomerPrivilegeForm"
>
<el-form
ref="exportNewcomerPrivilegeFormRef"
:model="exportNewcomerPrivilegeForm"
:rules="exportNewcomerPrivilegeRules"
label-width="120px"
>
<el-form-item label="申请日期" prop="applyDateRange">
<el-date-picker
v-model="exportNewcomerPrivilegeForm.applyDateRange"
type="daterange"
range-separator=""
start-placeholder="开始日期"
end-placeholder="结束日期"
value-format="yyyy-MM-dd"
style="width: 100%"
/>
</el-form-item>
<el-form-item label="租户ID">
<el-input :value="exportNewcomerPrivilegeTenantIdDisplay" disabled placeholder="未获取到租户ID" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="exportNewcomerPrivilegeDialogVisible = false">取消</el-button>
<el-button type="primary" :loading="exportNewcomerPrivilegeLoading" @click="submitExportNewcomerPrivilege">
确定
</el-button>
</div>
</el-dialog>
<el-dialog title="特权推荐人列表" :visible.sync="privilegeDialogVisible" width="760px" @close="resetPrivilegeDialog">
<el-table v-loading="privilegeLoading" :data="privilegeList" style="width: 100%">
<el-table-column type="index" label="#" width="60" />
@@ -293,6 +336,7 @@
import {
addLbPurchaseApply,
deleteLbPurchaseApply,
exportLbPurchaseApply,
getLbPurchaseApplyList,
needPrivilegeRecommenders,
parseLbPurchaseApplyFromOrderInfo,
@@ -328,6 +372,15 @@ export default {
dialogTitle: '',
isEdit: false,
privilegeLoading: false,
exportNewcomerPrivilegeDialogVisible: false,
exportNewcomerPrivilegeLoading: false,
exportNewcomerPrivilegeTenantIdDisplay: '',
exportNewcomerPrivilegeForm: {
applyDateRange: []
},
exportNewcomerPrivilegeRules: {
applyDateRange: [{ required: true, message: '请选择申请日期范围', trigger: 'change' }]
},
privilegeDateRange: [today, today],
privilegeList: [],
queryParams: {
@@ -509,6 +562,73 @@ export default {
this.$refs.dataForm && this.$refs.dataForm.clearValidate()
})
},
openExportNewcomerPrivilegeDialog() {
const today = this.getCurrentDate()
this.exportNewcomerPrivilegeTenantIdDisplay = this.getTenantIdFromBusinessHeaders()
if (
Array.isArray(this.privilegeDateRange) &&
this.privilegeDateRange.length === 2 &&
this.privilegeDateRange[0] &&
this.privilegeDateRange[1]
) {
this.exportNewcomerPrivilegeForm.applyDateRange = [...this.privilegeDateRange]
} else {
this.exportNewcomerPrivilegeForm.applyDateRange = [today, today]
}
this.exportNewcomerPrivilegeDialogVisible = true
this.$nextTick(() => {
if (this.$refs.exportNewcomerPrivilegeFormRef) {
this.$refs.exportNewcomerPrivilegeFormRef.clearValidate()
}
})
},
submitExportNewcomerPrivilege() {
this.$refs.exportNewcomerPrivilegeFormRef.validate((valid) => {
if (!valid) return
const tenantId = this.getTenantIdFromBusinessHeaders()
if (!tenantId) {
this.$message.error('未获取到租户ID请先登录或配置业务请求头中的租户')
return
}
const range = this.exportNewcomerPrivilegeForm.applyDateRange || []
const applyDateStart = range[0]
const applyDateEnd = range[1]
if (!applyDateStart || !applyDateEnd) {
this.$message.warning('请选择申请日期范围')
return
}
this.exportNewcomerPrivilegeLoading = true
exportLbPurchaseApply({ applyDateStart, applyDateEnd, 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 = `lbPurchaseApply_${applyDateStart}_${applyDateEnd}_${tenantId}.xlsx`
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
window.URL.revokeObjectURL(url)
this.$message.success('导出成功')
this.exportNewcomerPrivilegeDialogVisible = false
})
.finally(() => {
this.exportNewcomerPrivilegeLoading = false
})
})
},
resetExportNewcomerPrivilegeForm() {
if (this.$refs.exportNewcomerPrivilegeFormRef) {
this.$refs.exportNewcomerPrivilegeFormRef.resetFields()
}
this.exportNewcomerPrivilegeForm = {
applyDateRange: []
}
this.exportNewcomerPrivilegeTenantIdDisplay = ''
this.exportNewcomerPrivilegeLoading = false
},
handleViewPrivilege() {
if (!Array.isArray(this.privilegeDateRange) || this.privilegeDateRange.length !== 2) {
this.$message.warning('请选择开始日期和结束日期')