Browse Source

excel模板导出

master
liuchen864 6 months ago
parent
commit
ae53790056
  1. 10
      src/api/excel.js
  2. 2
      src/permission.js
  3. 5
      src/router/index.js
  4. 62
      src/views/excel/index.vue

10
src/api/excel.js

@ -0,0 +1,10 @@
import request from '@/utils/request'
// 导出客户账单中的订单
export function exportOut(data) {
return request({
url: '/excel/export/',
method: 'post',
data
})
}

2
src/permission.js

@ -11,7 +11,7 @@ import usePermissionStore from '@/store/modules/permission'
NProgress.configure({ showSpinner: false });
const whiteList = ['/login', '/register'];
const whiteList = ['/login', '/register', '/excel'];
router.beforeEach((to, from, next) => {
NProgress.start()

5
src/router/index.js

@ -42,6 +42,11 @@ export const constantRoutes = [
component: () => import('@/views/login'),
hidden: true
},
{
path: '/excel',
component: () => import('@/views/excel/index'),
hidden: true
},
{
path: '/register',
component: () => import('@/views/register'),

62
src/views/excel/index.vue

@ -0,0 +1,62 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryRef" :inline="true" label-width="68px">
<el-form-item label="订单号" prop="orderNo">
<el-input
v-model="queryParams.orderNo"
placeholder="请输入订单号"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="Search" @click="handleExport('changchun')">导出长春</el-button>
<el-button type="primary" icon="Search" @click="handleExport('foshan')">导出佛山青岛</el-button>
<el-button type="primary" icon="Search" @click="handleExport('guowai')">导出国外</el-button>
<el-button type="info" plain icon="Refresh" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
</div>
</template>
<script setup name="Excel">
import { exportOut } from "@/api/excel";
const uploadImgUrl = ref(import.meta.env.VITE_APP_BASE_API + "/profile/upload");
const { proxy } = getCurrentInstance();
const linuxAccessList = ref([]);
const loading = ref(true);
const data = reactive({
queryParams: {
orderNo: null,
type: 'changchun'
},
});
const { queryParams } = toRefs(data);
/** 搜索按钮操作 */
function handleQuery() {
handleExport();
}
/** 重置按钮操作 */
function resetQuery() {
proxy.resetForm("queryRef");
}
/** 导出按钮操作 */
function handleExport(type) {
loading.value = true;
queryParams.value.type = type;
exportOut(queryParams.value).then(response => {
response.data.forEach(item => {
window.open(uploadImgUrl.value + '/' + item, "_blank")
});
loading.value = false;
});
}
</script>
Loading…
Cancel
Save