diff --git a/src/api/synthesize-query/payment-fail.js b/src/api/synthesize-query/payment-fail.js
index d109aed..8f9012a 100644
--- a/src/api/synthesize-query/payment-fail.js
+++ b/src/api/synthesize-query/payment-fail.js
@@ -3,53 +3,74 @@ import requestFormData from '@/utils/request_formdata'
// 获取支付失败人员列表
export function getPaymentFailListAPI(data) {
- return request({
- url: '/bmw/paymentFail/list',
- method: 'GET',
- params: data,
- })
+ return request({
+ url: '/bmw/payFail/getPageList',
+ method: 'GET',
+ params: data,
+ })
}
// 新增支付失败人员
export function addPaymentFailAPI(data) {
- return requestFormData({
- url: '/bmw/paymentFail/add',
- method: 'POST',
- data,
- })
+ return requestFormData({
+ url: '/bmw/payFail/addData',
+ method: 'POST',
+ data,
+ })
}
// 修改支付失败人员
export function updatePaymentFailAPI(data) {
- return requestFormData({
- url: '/bmw/paymentFail/update',
- method: 'POST',
- data,
- })
+ return requestFormData({
+ url: '/bmw/payFail/updateData',
+ method: 'POST',
+ data,
+ })
}
// 删除支付失败人员
export function deletePaymentFailAPI(data) {
- return request({
- url: '/bmw/paymentFail/delete',
- method: 'POST',
- data,
- })
+ return request({
+ url: '/bmw/payFail/delData',
+ method: 'POST',
+ data,
+ })
}
// 获取支付失败人员详情
export function getPaymentFailDetailAPI(id) {
- return request({
- url: `/bmw/paymentFail/detail/${id}`,
- method: 'GET',
- })
+ return request({
+ url: `/bmw/payFail/detail/${id}`,
+ method: 'GET',
+ })
}
// 导入支付失败数据
export function importPaymentFailAPI(data) {
- return requestFormData({
- url: '/bmw/paymentFail/import',
- method: 'POST',
- data,
- })
+ return requestFormData({
+ url: '/bmw/payFail/importFile',
+ method: 'POST',
+ data,
+ })
+}
+
+// 模板下载
+export function downloadTemplateAPI() {
+ return request({
+ url: '/bmw/payFail/downloadFile',
+ method: 'GET',
+ responseType: 'blob', // 核心:指定响应类型为二进制流,必须!
+ headers: {
+ 'Accept': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
+ }
+ })
+}
+
+// 判断人员的工资是否支付
+export function isPaymentFailAPI(data) {
+ return request({
+ url: '/bmw/payFail/getHistoryPay',
+ method: 'POST',
+ data,
+ })
}
diff --git a/src/views/construction-person/entry-and-exit-manage/entry-file/index.vue b/src/views/construction-person/entry-and-exit-manage/entry-file/index.vue
index 4c2c71f..4ff0703 100644
--- a/src/views/construction-person/entry-and-exit-manage/entry-file/index.vue
+++ b/src/views/construction-person/entry-and-exit-manage/entry-file/index.vue
@@ -216,8 +216,6 @@ export default {
// 下拉选的change事件
async handleSelChange(e, val) {
- console.log(e, val, '996')
- console.log(['proId', 'subId', 'teamId'].includes(val), '996')
if (['proId', 'subId', 'teamId'].includes(val)) {
this.queryDownloadTask[val] = e
}
@@ -227,7 +225,7 @@ export default {
proId: e,
})
- this.formLabel[1].f_selList = subList.map((item) => {
+ this.formLabel[1].f_selList = subList.rows?.map((item) => {
return {
value: item.id,
label: item.subName,
@@ -239,7 +237,7 @@ export default {
subId: e,
})
- this.formLabel[2].f_selList = teamList.map((item) => {
+ this.formLabel[2].f_selList = teamList.rows?.map((item) => {
return {
value: item.id,
label: item.teamName,
@@ -273,11 +271,12 @@ export default {
}
})
- const subList = await getSubSelectListCommonFun({
+ const subList = await getSubSelectListAPI({
proId: this.sendParams.proId,
})
- this.formLabel[1].f_selList = subList.map((item) => {
+ this.formLabel[1].f_selList = []
+ this.formLabel[1].f_selList = subList.rows?.map((item) => {
return {
value: item.id,
label: item.subName,
diff --git a/src/views/construction-person/entry-and-exit-manage/person-entry/add-or-edit-form.vue b/src/views/construction-person/entry-and-exit-manage/person-entry/add-or-edit-form.vue
index a76c42e..204a35b 100644
--- a/src/views/construction-person/entry-and-exit-manage/person-entry/add-or-edit-form.vue
+++ b/src/views/construction-person/entry-and-exit-manage/person-entry/add-or-edit-form.vue
@@ -623,6 +623,7 @@ import {
getLotProjectSelectListByConditionAPI,
} from '@/api/common'
import { getPostTypeSelectListCommonFun } from '@/utils/getCommonData'
+import { isPaymentFailAPI } from '@/api/synthesize-query/payment-fail'
export default {
name: 'AddOrEditForm',
dicts: ['salary'],
@@ -1660,7 +1661,7 @@ export default {
},
// 身份证号失去焦点
- onBlurIdNumber() {
+ async onBlurIdNumber() {
// if (!this.idCardInfoForm.idNumber) return
// 根据身份证号码计算出生日期和性别
const birthday = this.idCardInfoForm.idNumber.slice(6, 14)
@@ -1677,7 +1678,21 @@ export default {
const age = new Date().getFullYear() - birthday.slice(0, 4)
this.idCardInfoForm.age = age
- this.checkShanghaiPro()
+ // 判断该人员有没有工资未发放问题
+ const res = await isPaymentFailAPI({
+ idCard: this.idCardInfoForm.idNumber,
+ })
+ if (res.data && res.code == 200) {
+ // this.$modal.msgError('该人员有工资未发放问题,请先处理!')
+ this.$message({
+ message: res.data,
+ type: 'warning',
+ duration: 5000,
+ })
+ setTimeout(() => {
+ this.checkShanghaiPro()
+ }, 2000)
+ }
},
// 判断当前身份证人员是否有入场工程
diff --git a/src/views/construction-person/entry-and-exit-manage/person-entry/index.vue b/src/views/construction-person/entry-and-exit-manage/person-entry/index.vue
index 74a9b9c..0d5282b 100644
--- a/src/views/construction-person/entry-and-exit-manage/person-entry/index.vue
+++ b/src/views/construction-person/entry-and-exit-manage/person-entry/index.vue
@@ -578,7 +578,7 @@ export default {
proId: e,
})
- this.formLabel[4].f_selList = subList.map((item) => {
+ this.formLabel[4].f_selList = subList.rows?.map((item) => {
return {
value: item.id,
label: item.subName,
@@ -589,7 +589,11 @@ export default {
const teamList = await getTeamSelectListAPI({
subId: e,
})
- this.formLabel[5].f_selList = teamList.map((item) => {
+
+ console.log(teamList, 'teamList')
+
+ this.formLabel[5].f_selList = []
+ this.formLabel[5].f_selList = teamList.rows?.map((item) => {
return {
value: item.id,
label: item.teamName,
diff --git a/src/views/construction-person/entry-and-exit-manage/person-entry/shanghai-pro-setting.vue b/src/views/construction-person/entry-and-exit-manage/person-entry/shanghai-pro-setting.vue
index 2cff6a3..bfea480 100644
--- a/src/views/construction-person/entry-and-exit-manage/person-entry/shanghai-pro-setting.vue
+++ b/src/views/construction-person/entry-and-exit-manage/person-entry/shanghai-pro-setting.vue
@@ -12,6 +12,7 @@
@@ -396,6 +397,8 @@ import {
getTeamSelectListByConditionAPI,
getLotProjectSelectListByConditionAPI,
} from '@/api/common'
+
+import { isPaymentFailAPI } from '@/api/synthesize-query/payment-fail'
export default {
name: 'ShanghaiProSetting',
dicts: ['salary'],
@@ -636,6 +639,24 @@ export default {
this.$emit('closeDialogOuter')
},
+ // 身份证号失去焦点
+ async onBlurIdNumber() {
+ // 判断该人员有没有工资未发放问题
+ const res = await isPaymentFailAPI({
+ idCard: this.idNumberForm.idNumber,
+ })
+
+ if (res.data && res.code == 200) {
+ // this.$modal.msgError('该人员有工资未发放问题,请先处理!')
+ this.$message({
+ message: res.data,
+ type: 'warning',
+ showClose: true,
+ duration: 0,
+ })
+ }
+ },
+
// 下一步
onHandleNextStep() {
// this.currentStep = 2
@@ -648,14 +669,20 @@ export default {
})
if (!res) {
- this.$modal.msgError('当前人员不存在,请先新增人员!')
+ // this.$modal.msgError('当前人员不存在,请先新增人员!')
+ this.$message({
+ message: '当前人员不存在,请先新增人员!',
+ type: 'danger',
+ })
return
}
if (res?.isShanghai == 0) {
- this.$modal.msgError(
- '该人员当前所在公司不允许同时入场多个工程!',
- )
+ this.$message({
+ message:
+ '该人员当前所在公司不允许同时入场多个工程!',
+ type: 'danger',
+ })
return
}
this.currentStep = 2
diff --git a/src/views/synthesize-query/payment-fail/addAndEditForm.vue b/src/views/synthesize-query/payment-fail/addAndEditForm.vue
index 1177e46..cb102f6 100644
--- a/src/views/synthesize-query/payment-fail/addAndEditForm.vue
+++ b/src/views/synthesize-query/payment-fail/addAndEditForm.vue
@@ -9,24 +9,24 @@
>
-
+
-
+
@@ -34,62 +34,47 @@
-
-
+
-
-
+ maxlength="50"
+ show-word-limit
+ placeholder="请输入工程名称"
+ v-model="paymentFailForm.proName"
+ />
-
-
+
-
-
+ maxlength="50"
+ show-word-limit
+ placeholder="请输入分包名称"
+ v-model="paymentFailForm.subName"
+ />
-
+
-
+
元
@@ -102,6 +87,8 @@
-
-
+
+
未处理
已处理
@@ -168,10 +155,6 @@ import {
addPaymentFailAPI,
updatePaymentFailAPI,
} from '@/api/synthesize-query/payment-fail'
-import {
- getLotProjectSelectListCommonFun,
- getSubSelectListCommonFun,
-} from '@/utils/getCommonData'
import { getSubSelectListAPI } from '@/api/common'
export default {
@@ -190,32 +173,38 @@ export default {
type: String,
default: '',
},
+ editFormData: {
+ type: Object,
+ default: () => null,
+ },
},
data() {
return {
// 表单数据
paymentFailForm: {
- name: '',
- idNumber: '',
- proId: '',
- subId: '',
- payMonth: '',
- payAmount: '',
- failReason: '',
- status: '0', // 默认未处理
- fileList: [],
- remark: '',
+ userName: '', // 姓名
+ idCard: '', // 身份证
+ proName: '', // 工程名称
+ subName: '', // 分包名称
+ failMonth: '', // 应发放月份
+ money: '', // 应发金额
+ failReason: '', // 支付失败原因
+ failStatus: '0', // 状态(使用中文) 0-未处理 1-已处理
+ fileSiz: 0, // 附件数量
+ fileList: [], // 附件列表
+ remark: '', // 备注
},
+ allFileList: [], // 修改时的全部文件列表
// 表单校验规则
paymentFailFormRules: {
- name: [
+ userName: [
{
required: true,
message: '姓名不能为空',
trigger: 'blur',
},
],
- idNumber: [
+ idCard: [
{
required: true,
message: '身份证号不能为空',
@@ -228,28 +217,14 @@ export default {
trigger: 'blur',
},
],
- proId: [
- {
- required: true,
- message: '请选择工程名称',
- trigger: 'change',
- },
- ],
- subId: [
- {
- required: true,
- message: '请选择分包单位',
- trigger: 'change',
- },
- ],
- payMonth: [
+ failMonth: [
{
required: true,
message: '请选择应发放月份',
trigger: 'change',
},
],
- payAmount: [
+ money: [
{
required: true,
message: '应发放金额不能为空',
@@ -267,7 +242,7 @@ export default {
trigger: 'blur',
},
],
- status: [
+ failStatus: [
{
required: true,
message: '请选择记录状态',
@@ -281,24 +256,7 @@ export default {
subcontractOptions: [],
}
},
- watch: {
- editId: {
- handler(newVal) {
- if (newVal && this.formType === 2) {
- this.getDetail()
- } else {
- this.resetForm()
- }
- },
- immediate: true,
- },
- },
- async created() {
- await this.initProjectOptions()
- if (this.formType === 2 && this.editId) {
- await this.getDetail()
- }
- },
+
methods: {
// 金额校验
validatePayAmount(rule, value, callback) {
@@ -326,20 +284,17 @@ export default {
callback()
},
- // 初始化工程下拉选项
- async initProjectOptions() {
- const lotProjectList = await getLotProjectSelectListCommonFun()
- this.projectOptions = lotProjectList.map((item) => {
- return {
- label: item.proName,
- value: item.id,
- }
- })
- },
-
// 工程选择变化时,更新分包下拉选项
async handleProChange(proId) {
if (proId) {
+ // 设置工程名称
+ const selectedProject = this.projectOptions.find(
+ (item) => item.value === proId,
+ )
+ if (selectedProject) {
+ this.paymentFailForm.proName = selectedProject.label
+ }
+
const subList = await getSubSelectListAPI({
proId: proId,
})
@@ -351,55 +306,41 @@ export default {
})
// 清空分包选择
this.paymentFailForm.subId = ''
+ this.paymentFailForm.subName = ''
} else {
this.subcontractOptions = []
this.paymentFailForm.subId = ''
+ this.paymentFailForm.proName = ''
+ this.paymentFailForm.subName = ''
}
},
- // 获取详情
- async getDetail() {
- if (!this.editId) return
- try {
- const res = await getPaymentFailDetailAPI(this.editId)
- if (res.code === 200 && res.data) {
- const data = res.data
- this.paymentFailForm = {
- name: data.name || '',
- idNumber: data.idNumber || '',
- proId: data.proId || '',
- subId: data.subId || '',
- payMonth: data.payMonth || '',
- payAmount: data.payAmount || '',
- failReason: data.failReason || '',
- status:
- data.status !== undefined
- ? String(data.status)
- : '0',
- fileList: data.fileList || [],
- remark: data.remark || '',
- }
- // 如果有工程ID,加载对应的分包列表
- if (data.proId) {
- await this.handleProChange(data.proId)
- }
+ // 分包选择变化时,更新分包名称
+ handleSubChange(subId) {
+ if (subId) {
+ const selectedSub = this.subcontractOptions.find(
+ (item) => item.value === subId,
+ )
+ if (selectedSub) {
+ this.paymentFailForm.subName = selectedSub.label
}
- } catch (error) {
- console.error('获取详情失败', error)
+ } else {
+ this.paymentFailForm.subName = ''
}
},
// 重置表单
resetForm() {
this.paymentFailForm = {
- name: '',
- idNumber: '',
- proId: '',
- subId: '',
- payMonth: '',
- payAmount: '',
+ userName: '',
+ idCard: '',
+ proName: '',
+ subName: '',
+ failMonth: '',
+ money: '',
failReason: '',
- status: '0',
+ failStatus: '0',
+ fileSiz: 0,
fileList: [],
remark: '',
}
@@ -426,27 +367,27 @@ export default {
// 组装FormData
const formData = new FormData()
- // 添加表单字段
- formData.append('name', this.paymentFailForm.name)
+ // 添加表单字段(同步config.js中的字段名)
formData.append(
- 'idNumber',
- this.paymentFailForm.idNumber,
+ 'userName',
+ this.paymentFailForm.userName,
)
- formData.append('proId', this.paymentFailForm.proId)
- formData.append('subId', this.paymentFailForm.subId)
+ formData.append('idCard', this.paymentFailForm.idCard)
+ formData.append('proName', this.paymentFailForm.proName)
+ formData.append('subName', this.paymentFailForm.subName)
formData.append(
- 'payMonth',
- this.paymentFailForm.payMonth,
- )
- formData.append(
- 'payAmount',
- this.paymentFailForm.payAmount,
+ 'failMonth',
+ this.paymentFailForm.failMonth,
)
+ formData.append('money', this.paymentFailForm.money)
formData.append(
'failReason',
this.paymentFailForm.failReason,
)
- formData.append('status', this.paymentFailForm.status)
+ formData.append(
+ 'failStatus',
+ this.paymentFailForm.failStatus,
+ )
formData.append(
'remark',
this.paymentFailForm.remark || '',
@@ -455,6 +396,23 @@ export default {
// 如果是修改,添加id
if (this.formType === 2 && this.editId) {
formData.append('id', this.editId)
+
+ // 找出被删除的文件id集合
+ const delFileList = this.allFileList.filter(
+ (item) => {
+ return !this.paymentFailForm.fileList.some(
+ (file) => file.id === item.id,
+ )
+ },
+ )
+ if (delFileList.length > 0) {
+ formData.append(
+ 'delFileId',
+ delFileList
+ .map((item) => item.id)
+ .join(','),
+ )
+ }
}
// 添加文件
@@ -463,7 +421,7 @@ export default {
this.paymentFailForm.fileList.length > 0
) {
this.paymentFailForm.fileList.forEach((file) => {
- if (file.raw) {
+ if (file.raw && !file.id) {
formData.append('file', file.raw)
}
})
@@ -494,6 +452,49 @@ export default {
})
},
},
+
+ watch: {
+ editFormData: {
+ handler(newVal) {
+ if (Object.keys(newVal).length > 0) {
+ // Object.assign(this.paymentFailForm, newVal)
+ const {
+ userName,
+ idCard,
+ proName,
+ subName,
+ failMonth,
+ money,
+ failReason,
+ fileList,
+ remark,
+ failStatusString,
+ } = newVal
+ this.paymentFailForm = {
+ userName,
+ idCard,
+ proName,
+ subName,
+ failMonth,
+ money,
+ remark,
+ failReason,
+ }
+ this.paymentFailForm.failStatus = failStatusString
+ this.allFileList = fileList
+ this.paymentFailForm.fileList = fileList.map((item) => {
+ return {
+ id: item.id,
+ url: item.lsUrl,
+ name: item.originFileName,
+ }
+ })
+ }
+ },
+
+ immediate: true,
+ },
+ },
}
diff --git a/src/views/synthesize-query/payment-fail/config.js b/src/views/synthesize-query/payment-fail/config.js
index a2c5fb5..01c0217 100644
--- a/src/views/synthesize-query/payment-fail/config.js
+++ b/src/views/synthesize-query/payment-fail/config.js
@@ -1,70 +1,70 @@
export const formLabel = [
- {
- f_label: '姓名',
- f_model: 'name',
- f_type: 'ipt',
- f_width: '180px',
- isShow: false, // 是否展示label
- },
- {
- f_label: '身份证',
- f_model: 'idNumber',
- f_type: 'ipt',
- f_width: '180px',
- isShow: false, // 是否展示label
- },
- {
- f_label: '工程',
- f_model: 'proId',
- f_type: 'sel',
- f_width: '180px',
- isShow: false, // 是否展示label
- f_selList: [], // 工程列表
- },
- {
- f_label: '分包',
- f_model: 'subId',
- f_type: 'sel',
- f_width: '180px',
- isShow: false, // 是否展示label
- f_selList: [], // 分包列表
- },
- {
- f_label: '状态',
- f_model: 'status',
- f_type: 'sel',
- f_width: '180px',
- isShow: false, // 是否展示label
- f_selList: [
- {
- label: '未处理',
- value: '0',
- },
- {
- label: '已处理',
- value: '1',
- },
- ], // 状态列表
- },
+ {
+ f_label: '姓名',
+ f_model: 'userName',
+ f_type: 'ipt',
+ f_width: '180px',
+ isShow: false, // 是否展示label
+ },
+ {
+ f_label: '身份证',
+ f_model: 'idCard',
+ f_type: 'ipt',
+ f_width: '180px',
+ isShow: false, // 是否展示label
+ },
+ {
+ f_label: '工程',
+ f_model: 'proName',
+ f_type: 'ipt',
+ f_width: '180px',
+ isShow: false, // 是否展示label
+
+ },
+ {
+ f_label: '分包',
+ f_model: 'subName',
+ f_type: 'ipt',
+ f_width: '180px',
+ isShow: false, // 是否展示label
+
+ },
+ {
+ f_label: '状态',
+ f_model: 'failStatus',
+ f_type: 'sel',
+ f_width: '180px',
+ isShow: false, // 是否展示label
+ f_selList: [
+ {
+ label: '未处理',
+ value: '0',
+ },
+ {
+ label: '已处理',
+ value: '1',
+ },
+ ],
+ },
]
export const columnsList = [
- { t_props: 'name', t_label: '姓名' },
- { t_props: 'idNumber', t_label: '身份证' },
- { t_props: 'proName', t_label: '工程名称' },
- { t_props: 'subName', t_label: '分包名称' },
- { t_props: 'payMonth', t_label: '应发放月份' },
- { t_props: 'payAmount', t_label: '应发金额' },
- { t_props: 'failReason', t_label: '支付失败原因' },
- { t_label: '状态', t_slot: 'status' },
- { t_label: '附件', t_slot: 'attachment' },
- { t_props: 'remark', t_label: '备注' },
+ { t_props: 'userName', t_label: '姓名' },
+ { t_props: 'idCard', t_label: '身份证' },
+ { t_props: 'proName', t_label: '工程名称' },
+ { t_props: 'subName', t_label: '分包名称' },
+ { t_props: 'failMonth', t_label: '应发放月份' },
+ { t_props: 'money', t_label: '应发金额' },
+ { t_props: 'failReason', t_label: '支付失败原因' },
+ { t_label: '状态', t_slot: 'failStatus' },
+ { t_label: '附件', t_slot: 'fileSiz' },
+ { t_props: 'remark', t_label: '备注' },
]
export const dialogConfig = {
- outerVisible: false,
- outerTitle: '',
- outerWidth: '60%',
- minHeight: 'auto',
- maxHeight: '90vh',
+ outerVisible: false,
+ outerTitle: '',
+ outerWidth: '60%',
+ minHeight: 'auto',
+ maxHeight: '90vh',
}
diff --git a/src/views/synthesize-query/payment-fail/index.vue b/src/views/synthesize-query/payment-fail/index.vue
index 6c3ecc6..44a8790 100644
--- a/src/views/synthesize-query/payment-fail/index.vue
+++ b/src/views/synthesize-query/payment-fail/index.vue
@@ -10,20 +10,27 @@
:requestApi="getPaymentFailListAPI"
@sel-change="handleSelChange"
>
-
-
+
+
未处理
-
+
已处理
-
-
- {{ data.attachmentCount }}
+
+
+ {{ data.fileSiz }}
- 0
@@ -100,6 +107,7 @@
@@ -160,6 +168,7 @@ import {
getPaymentFailListAPI,
deletePaymentFailAPI,
importPaymentFailAPI,
+ downloadTemplateAPI,
} from '@/api/synthesize-query/payment-fail'
import {
getLotProjectSelectListCommonFun,
@@ -186,6 +195,7 @@ export default {
editId: '', // 编辑的id
importFileList: [], // 导入文件列表
getPaymentFailListAPI,
+ editFormData: null, // 编辑时回显的数据
}
},
methods: {
@@ -193,7 +203,7 @@ export default {
onHandleExport(queryParams) {
console.log(queryParams, '导出参数')
this.download(
- '/bmw/paymentFail/export',
+ '/bmw/payFail/export',
{
...queryParams,
},
@@ -211,9 +221,37 @@ export default {
this.formType = type
if (type === 2) {
this.editId = data.id
+ const {
+ userName,
+ idCard,
+ proName,
+ subName,
+ failMonth,
+ money,
+ failReason,
+ fileList,
+ remark,
+ id,
+ failStatusString,
+ } = data
+
+ this.editFormData = {
+ userName,
+ idCard,
+ proName,
+ subName,
+ failMonth,
+ money,
+ failReason,
+ fileList,
+ remark,
+ id,
+ failStatusString,
+ }
this.dialogConfig.outerVisible = true
} else {
this.editId = ''
+ this.editFormData = null
this.dialogConfig.outerVisible = true
}
},
@@ -276,13 +314,29 @@ export default {
// 下载模板
async onHandleDownloadTemplate() {
- // 判断是否为测试环境
- if (process.env.VUE_APP_ENV === 'production') {
- window.open(
- window.origin + '/hd-realname' + '/支付失败人员-模版.xlsx',
- )
- } else {
- window.open(window.origin + '/支付失败人员-模版.xlsx')
+ try {
+ const res = await downloadTemplateAPI()
+ // 1. 校验响应是否为有效blob
+ if (!res || !(res instanceof Blob)) {
+ alert('模板下载失败,文件格式异常')
+ return
+ }
+ // 2. 创建Blob,指定正确的MIME类型
+ const blob = new Blob([res], {
+ type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
+ })
+ // 3. 创建下载链接并触发下载
+ const link = document.createElement('a')
+ link.href = URL.createObjectURL(blob)
+ link.download = '支付失败人员-模版.xlsx' // 下载文件名
+ document.body.appendChild(link)
+ link.click()
+ // 4. 清理资源,避免内存泄漏
+ document.body.removeChild(link)
+ URL.revokeObjectURL(link.href)
+ } catch (error) {
+ console.error('模板下载失败:', error)
+ alert('模板下载失败,请重试!')
}
},