|
|
|
|
@ -22,6 +22,7 @@
|
|
|
|
|
<Button style="margin-left: 10px" type="primary" @click="select={page:1,keyword:''}">重置
|
|
|
|
|
</Button>
|
|
|
|
|
<Button style="margin-left: 10px" type="primary" @click="doSearch">查询</Button>
|
|
|
|
|
<Button style="margin-left: 10px" type="primary" @click="doExport" :loading="exportLoading">导出</Button>
|
|
|
|
|
<Button style="margin-left: 10px" type="primary" @click="doPrint">打印</Button>
|
|
|
|
|
</div>
|
|
|
|
|
</slot>
|
|
|
|
|
@ -40,10 +41,14 @@
|
|
|
|
|
<script>
|
|
|
|
|
import {
|
|
|
|
|
list as index,
|
|
|
|
|
exportList,
|
|
|
|
|
save,
|
|
|
|
|
del,
|
|
|
|
|
show
|
|
|
|
|
} from "@/api/bookStore/storeList";
|
|
|
|
|
import {
|
|
|
|
|
exportJsonToXlsx
|
|
|
|
|
} from '@/utils/exportExcel'
|
|
|
|
|
|
|
|
|
|
import putIn from '@/views/bookStore/components/putIn'
|
|
|
|
|
export default {
|
|
|
|
|
@ -72,6 +77,7 @@
|
|
|
|
|
],
|
|
|
|
|
total: 0,
|
|
|
|
|
list: [],
|
|
|
|
|
exportLoading: false,
|
|
|
|
|
table: [{
|
|
|
|
|
prop: 'no',
|
|
|
|
|
label: '库存编号',
|
|
|
|
|
@ -184,6 +190,52 @@
|
|
|
|
|
let baseUrl = process.env.VUE_APP_BASE_API + "/print";
|
|
|
|
|
window.open(baseUrl)
|
|
|
|
|
},
|
|
|
|
|
buildExportParams() {
|
|
|
|
|
const params = {
|
|
|
|
|
page: 1,
|
|
|
|
|
page_size: 99999,
|
|
|
|
|
keyword: this.select.keyword
|
|
|
|
|
}
|
|
|
|
|
if (this.select.borrow_status !== '' && this.select.borrow_status !== null && this.select.borrow_status !== undefined) {
|
|
|
|
|
params.borrow_status = this.select.borrow_status
|
|
|
|
|
}
|
|
|
|
|
return params
|
|
|
|
|
},
|
|
|
|
|
formatLocation(row) {
|
|
|
|
|
if (row.bookshelf && row.line && row.rows) {
|
|
|
|
|
return `书架:${row.bookshelf} 第${row.line}列 第${row.rows}行`
|
|
|
|
|
}
|
|
|
|
|
return ''
|
|
|
|
|
},
|
|
|
|
|
async doExport() {
|
|
|
|
|
this.exportLoading = true
|
|
|
|
|
try {
|
|
|
|
|
const res = await exportList(this.buildExportParams())
|
|
|
|
|
const rows = (res.data || []).map(item => ({
|
|
|
|
|
'库存编号': item.no || '',
|
|
|
|
|
'图书分类': item.book?.type?.name || '',
|
|
|
|
|
'图书': item.book?.name || item.book_name || '',
|
|
|
|
|
'作者': item.book?.author || '',
|
|
|
|
|
'装订方式': item.book?.bind_way || '',
|
|
|
|
|
'所在位置': this.formatLocation(item),
|
|
|
|
|
'入库日期': item.enter_date || '',
|
|
|
|
|
'借阅状态': item.borrow_status == 1 ? '借出' : '在库',
|
|
|
|
|
'备注': item.remark || '',
|
|
|
|
|
'创建时间': item.created_at || ''
|
|
|
|
|
}))
|
|
|
|
|
if (!rows.length) {
|
|
|
|
|
this.$Message.warning('暂无可导出数据')
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
const filename = `库存记录_${this.$moment().format('YYYYMMDDHHmmss')}.xlsx`
|
|
|
|
|
exportJsonToXlsx(rows, '库存记录', filename)
|
|
|
|
|
this.$Message.success(`导出成功,共 ${rows.length} 条`)
|
|
|
|
|
} catch (error) {
|
|
|
|
|
this.$Message.error('导出失败,请稍后重试')
|
|
|
|
|
} finally {
|
|
|
|
|
this.exportLoading = false
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
pageChange(e) {
|
|
|
|
|
this.select.page = e
|
|
|
|
|
this.load();
|
|
|
|
|
|