From 7de835dea145fe8229f5f0100e2a90094e6d5b22 Mon Sep 17 00:00:00 2001 From: MrShi <1878285526@qq.com> Date: 星期五, 07 二月 2025 18:49:38 +0800 Subject: [PATCH] 改bug --- admin/src/views/stock/assetList.vue | 48 +++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 45 insertions(+), 3 deletions(-) diff --git a/admin/src/views/stock/assetList.vue b/admin/src/views/stock/assetList.vue index 90214cc..02bbe42 100644 --- a/admin/src/views/stock/assetList.vue +++ b/admin/src/views/stock/assetList.vue @@ -3,8 +3,16 @@ <QueryForm v-model="filters" :query-form-config="queryFormConfig" @handleQuery="getList(1)" @clear="clear" /> <div class="mt20"> <el-button type="primary" @click="$refs.newMaterial.open('鏂板缓鐗╂枡')">娣诲姞</el-button> - <el-button>瀵煎嚭</el-button> - <el-button>瀵煎叆</el-button> + <el-button @click="exportExcel">瀵煎嚭</el-button> + <el-popover + placement="right" + trigger="click"> + <div style="display: flex; align-items: center; justify-content: center;"> + <el-button type="primary" @click="$refs.uploadFile.click()">瀵煎叆妯℃澘</el-button> + <el-button type="text" @click="exportTemplate">鐐瑰嚮涓嬭浇妯$増.EXCEL</el-button> + </div> + <el-button style="margin-left: 10px;" slot="reference">瀵煎叆</el-button> + </el-popover> </div> <el-table v-loading="loading" :data="list" stripe> <el-table-column prop="code" label="鐗╂枡缂栫爜" min-width="100" show-overflow-tooltip /> @@ -38,6 +46,7 @@ <Pagination @size-change="handleSizeChange" @current-change="getList" :pagination="pagination" /> </div> <newMaterial ref="newMaterial" @success="getList" /> + <input type="file" ref="uploadFile" @change="importTemplate" accept=".xlsx" style="position: fixed; top: -100px;" /> </div> </template> @@ -48,7 +57,7 @@ import dayjs from 'dayjs' import duration from 'dayjs/plugin/duration' dayjs.extend(duration) -import { fetchList, updateStatus, deleteById } from '@/api/ywMaterial' +import { fetchList, updateStatus, deleteById, exportExcel, importMaterialBatch } from '@/api/ywMaterial' export default { components: { Pagination, @@ -87,6 +96,39 @@ this.getList() }, methods: { + // 瀵煎嚭妯℃澘 + exportTemplate () { + window.open('/template/material.xlsx') + }, + // 瀵煎叆妯℃澘 + importTemplate(e) { + const FormDate = new FormData() + FormDate.append('file', e.target.files[0]) + importMaterialBatch(FormDate) + .then(res => { + this.getList() + }) + .finally(() => { + this.$refs.uploadFile.value = null + }) + }, + exportExcel () { + this.$dialog.exportConfirm('纭瀵煎嚭鍚楋紵') + .then(() => { + exportExcel({ + page: this.pagination.page, + capacity: 1000000, + model: this.filters + }) + .then(response => { + this.download(response) + }) + .catch(e => { + this.$tip.apiFailed(e) + }) + }) + .catch(() => {}) + }, getList(page) { const { pagination, filters } = this this.loading = true -- Gitblit v1.9.3