Merge pull request 'yyw提交' (#21) from yyw into master

Reviewed-on: #21
This commit is contained in:
vivanlina 2025-10-31 06:49:02 +00:00
commit 609d31b5f5

View File

@ -59,6 +59,7 @@
<div class="opaBox">
<el-button type="primary" @click="handleAdd"><el-icon><Plus /></el-icon>&nbsp;新增</el-button>
<el-button type="primary" v-if="role" :disabled="!chooseList.length" @click="lte_stock = 0, showStock = true">设置预警库存</el-button>
<el-button type="warning" @click="handleExport" :loading="exportLoading"><span class="iconfont icon-daochu"></span>&nbsp;导出</el-button>
</div>
<el-table :data="tableList" style="width: 100%" border v-loading="loading" @select="select"
ref="multipleTable" @select-all="selectAll">
@ -279,7 +280,8 @@ export default {
chooseList: [],
lte_stock: 0,
showStock: false,
showUpdate: false
showUpdate: false,
exportLoading: false
})
function handleSearch() {
@ -306,6 +308,44 @@ export default {
})
}
const handleExport = () => {
data.exportLoading = true
let params = {
page: data.page,
pageSize: data.pageSize,
service_id: data.service_id,
...data.filter,
brand_ids: data.brandIds.join(','),
goods_ids: data.goodsIds.join(','),
export: 1
}
get(`/api/goods-skus`, params, 'blob').then((res) => {
downLoadXls(res)
ElMessage({ type: "success", message: "导出成功!" })
data.exportLoading = false
}).catch(() => {
data.exportLoading = false
})
}
function downLoadXls(response) {
const content = response
const blob = new Blob([content])
const fileName = `商品规格.xlsx`
if ('download' in document.createElement('a')) {
const elink = document.createElement('a')
elink.download = fileName
elink.style.display = 'none'
elink.href = URL.createObjectURL(blob)
document.body.appendChild(elink)
elink.click()
URL.revokeObjectURL(elink.href)
document.body.removeChild(elink)
} else {
navigator.msSaveBlob(blob, fileName)
}
}
function handleCurrentChange(e) {
data.page = e
fetchData()
@ -459,6 +499,7 @@ export default {
handleSearch,
handleCurrentChange,
handleSizeChange,
handleExport,
fetchData,
handleAdd,
handleEdit,