| | |
| | | <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 /> |
| | | <el-table-column prop="name" label="资产名称" min-width="100" show-overflow-tooltip /> |
| | | <el-table-column prop="code" label="物料编码" min-width="100" show-overflow-tooltip /> |
| | | <el-table-column prop="name" label="物料名称" min-width="100" show-overflow-tooltip /> |
| | | <el-table-column prop="qrcode" label="条码" min-width="100" show-overflow-tooltip /> |
| | | <el-table-column prop="brand" label="品牌" min-width="100" show-overflow-tooltip /> |
| | | <el-table-column prop="attr" label="规格型号" min-width="100" show-overflow-tooltip /> |
| | |
| | | <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> |
| | | |
| | |
| | | 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, |
| | |
| | | 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) { |
| | | if (page) { |
| | | this.pagination.page = page |
| | | } |
| | | const { pagination, filters } = this |
| | | this.loading = true |
| | | fetchList({ |