Browse Source

增加物料模版下载

master
lihua 5 years ago
parent
commit
22a42afceb
  1. 17
      src/api/material.js
  2. 10
      src/views/material/warehouse/index.vue

17
src/api/material.js

@ -126,3 +126,20 @@ export function warn(pageNum, pageSize) {
})
}
export function donwload() {
request({
url: '/template.xlsx',
method: 'get',
responseType: 'blob'
}).then(response => {
const blob = new Blob([response.data], {
type: 'application/vnd.ms-excel'
})
const fileName = 'template.xlsx'
var link = document.createElement('a')
link.href = window.URL.createObjectURL(blob)
link.download = fileName
link.click()
window.URL.revokeObjectURL(link.href)
})
}

10
src/views/material/warehouse/index.vue

@ -52,6 +52,11 @@
<el-button type="primary" style="margin-left: 10px" plain>批量出库</el-button>
</el-upload>
</el-col>
<el-col :span="1">
<el-tooltip content="物料模版下载" placement="top">
<el-button type="success" plain icon="el-icon-download" circle @click="handleDownload"/>
</el-tooltip>
</el-col>
</el-row>
<el-row>
<el-table
@ -216,7 +221,7 @@
</template>
<script>
import { add, sub, edit, del, search, exports, uploadImport, uploadExport, exportFail } from '@/api/material'
import { add, sub, edit, del, search, exports, uploadImport, uploadExport, exportFail, donwload } from '@/api/material'
import { isAdmin } from '@/api/user'
export default {
name: 'Material',
@ -439,6 +444,9 @@ export default {
},
indexMethod(index) {
return this.pageSize * (this.pageNum - 1) + index + 1
},
handleDownload() {
donwload()
}
}
}

Loading…
Cancel
Save