导出删除数据

This commit is contained in:
2025-08-08 14:38:06 +08:00
parent 9af9f1f166
commit fd9cf29780
8 changed files with 288 additions and 45 deletions

View File

@@ -75,13 +75,20 @@
/>
</el-form-item> -->
<el-form-item :label="t('newHosts.hostsCountry')" prop="country">
<el-select v-model="queryParams.country" :placeholder="t('newHosts.placeHostsCountry')" clearable
class="!w-240px">
<el-form-item :label="t('newHosts.hostsCountry')" prop="region">
<el-select v-model="queryParams.region" :placeholder="t('newHosts.placeHostsCountry')" clearable
class="!w-240px" @change="changeCountry(queryParams.region)">
<el-option v-for="dict in getStrDictOptions(DICT_TYPE.COUNTRY_GROUP)" :key="dict.value"
:label="$t(dict.label)" :value="dict.value" />
</el-select>
</el-form-item>
<el-form-item :label="t('newHosts.hostsCountryinfo')" prop="country">
<el-select v-model="queryParams.country" :placeholder="t('newHosts.placeHostsCountry')" clearable
class="!w-240px">
<el-option v-for="dict in countryinfoList" :key="dict.id" :label="dict.countryName"
:value="dict.countryName" />
</el-select>
</el-form-item>
<el-form-item :label="t('newHosts.hostsKind')" prop="hostsKind">
<el-input v-model="queryParams.hostsKind" :placeholder="t('newHosts.placeHostsKind')" clearable
@keyup.enter="handleQuery" class="!w-240px" />
@@ -230,10 +237,11 @@ import { getIntDictOptions, DICT_TYPE, getStrDictOptions } from '@/utils/dict'
import { dateFormatter } from '@/utils/formatTime'
import download from '@/utils/download'
import { NewHostsApi, NewHostsVO } from '@/api/server/newhosts'
import { getAllocation, getSimpleUserList, getSimpleUserListPage } from '@/api/system/user'
import { getAllocation, getSimpleUserList, getSimpleUserListPage, getCountry } from '@/api/system/user'
import NewHostsForm from './NewHostsForm.vue'
import { useCache } from '@/hooks/web/useCache'
import * as DeptApi from '@/api/system/dept'
import { ElMessageBox } from 'element-plus'
import { func } from 'vue-types'
const { wsCache } = useCache()
@@ -262,11 +270,13 @@ const queryParams = reactive({
fllowernumMax: undefined,
invitationType: undefined,
yesterdayCoins: undefined,
region: undefined,
country: undefined,
hostsKind: undefined,
isAssigned: undefined,
createTime: new Date().toISOString().split('T')[0] + ' 00:00:00',
userId: undefined,
deleteFlag: false //导出 是否删除
})
const queryFormRef = ref() // 搜索的表单
const exportLoading = ref(false) // 导出的加载中
@@ -286,7 +296,7 @@ let allocationdeptList = ref([
id: 1
}
]) //选中的分配部门
let countryinfoList = ref([])
/** 查询列表 */
const getList = async () => {
loading.value = true
@@ -407,13 +417,40 @@ const handleDeleteBatch = async () => {
/** 导出按钮操作 */
const handleExport = async () => {
try {
// 导出的二次确认
await message.exportConfirm()
// 先确认是否删除导出的数据
await ElMessageBox.confirm(
'导出后是否删除导出的数据?',
'删除确认',
{
distinguishCancelAndClose: true,
confirmButtonText: '删除并导出',
cancelButtonText: '仅导出',
type: 'warning',
}
).then(async () => {
queryParams.deleteFlag = true
exportLoading.value = true
const data = await NewHostsApi.exportNewHosts(queryParams)
download.excel(data, '主播数据管理.xls')
}).catch(async (err) => {
if (err === 'cancel' || err?.action === 'cancel') {
exportLoading.value = true
const data = await NewHostsApi.exportNewHosts(queryParams)
download.excel(data, '主播数据管理.xls')
}
});
// 原本的导出二次确认
// await message.exportConfirm()
// 发起导出
exportLoading.value = true
const data = await NewHostsApi.exportNewHosts(queryParams)
download.excel(data, '主播数据管理.xls')
// 这里可以根据需求执行删除逻辑
// await NewHostsApi.deleteExportedData()
} catch {
// 用户取消任意一个确认都会走这里
} finally {
exportLoading.value = false
}
@@ -468,6 +505,14 @@ function handleCopy(text) {
}
}
function changeCountry(region) {
console.log(region)
getCountry(region).then((res) => {
countryinfoList.value = res
})
}
/** 初始化 **/
onMounted(() => {
getList()