|
@@ -30,6 +30,14 @@
|
|
|
<a-col :md="6" :sm="24" style="margin-bottom: 10px;">
|
|
|
<a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="shortageStatisticsPList-refresh">查询</a-button>
|
|
|
<a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="shortageStatisticsPList-reset">重置</a-button>
|
|
|
+ <a-button
|
|
|
+ style="margin-left: 5px"
|
|
|
+ type="primary"
|
|
|
+ class="button-warning"
|
|
|
+ @click="handleExport"
|
|
|
+ :disabled="disabled"
|
|
|
+ :loading="exportLoading"
|
|
|
+ id="shortageStatisticsCList-export">导出</a-button>
|
|
|
<a @click="advanced=!advanced" style="margin-left: 5px">
|
|
|
{{ advanced ? '收起' : '展开' }}
|
|
|
<a-icon :type="advanced ? 'up' : 'down'"/>
|
|
@@ -68,10 +76,11 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import moment from 'moment'
|
|
|
import getDate from '@/libs/getDate.js'
|
|
|
import { STable, VSelect } from '@/components'
|
|
|
import rangeDate from '@/views/common/rangeDate.vue'
|
|
|
-import { oosProductList, oosProductDetailCount, oosProductDetailPageCount } from '@/api/oos'
|
|
|
+import { oosProductList, oosProductDetailCount, oosProductDetailPageCount, oosDetailExportByProduct } from '@/api/oos'
|
|
|
export default {
|
|
|
components: { STable, VSelect, rangeDate },
|
|
|
data () {
|
|
@@ -87,6 +96,7 @@ export default {
|
|
|
origCode: ''
|
|
|
},
|
|
|
disabled: false, // 查询、重置按钮是否可操作
|
|
|
+ exportLoading: false, // 导出loading
|
|
|
time: [
|
|
|
getDate.getCurrMonthDays().starttime,
|
|
|
getDate.getCurrMonthDays().endtime
|
|
@@ -163,6 +173,42 @@ export default {
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
+ // 导出
|
|
|
+ handleExport () {
|
|
|
+ const _this = this
|
|
|
+ const params = this.queryParam
|
|
|
+ this.exportLoading = true
|
|
|
+ _this.spinning = true
|
|
|
+ oosDetailExportByProduct(params).then(res => {
|
|
|
+ this.exportLoading = false
|
|
|
+ _this.spinning = false
|
|
|
+ if (res.type == 'application/json') {
|
|
|
+ var reader = new FileReader()
|
|
|
+ reader.addEventListener('loadend', function () {
|
|
|
+ const obj = JSON.parse(reader.result)
|
|
|
+ _this.$notification.error({
|
|
|
+ message: '提示',
|
|
|
+ description: obj.message
|
|
|
+ })
|
|
|
+ })
|
|
|
+ reader.readAsText(res)
|
|
|
+ } else {
|
|
|
+ this.download(res)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ download (data) {
|
|
|
+ if (!data) { return }
|
|
|
+ const url = window.URL.createObjectURL(new Blob([data]))
|
|
|
+ const link = document.createElement('a')
|
|
|
+ link.style.display = 'none'
|
|
|
+ link.href = url
|
|
|
+ const a = moment().format('YYYYMMDDHHmmss')
|
|
|
+ const fname = '缺货统计(按产品)' + a
|
|
|
+ link.setAttribute('download', fname + '.xlsx')
|
|
|
+ document.body.appendChild(link)
|
|
|
+ link.click()
|
|
|
+ },
|
|
|
// 重置
|
|
|
resetSearchForm () {
|
|
|
this.$refs.rangeDate.resetDate(this.time)
|