123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 |
- <template>
- <a-modal
- centered
- class="backorderDetail-modal"
- :footer="null"
- :maskClosable="false"
- title="详情"
- v-model="isShow"
- @cancle="isShow=false"
- :width="960">
- <a-spin :spinning="spinning" tip="Loading...">
- <div style="padding: 0 12px;text-align: right;" v-if="$hasPermissions('B_oosPrint')">
- <a-button id="backorderDetail-preview-btn" :disabled="localDataSource.length==0" @click="handlePrint('preview')" style="margin-right: 15px;">打印预览</a-button>
- <a-button type="primary" id="backorderDetail-print-btn" :disabled="localDataSource.length==0" @click="handlePrint('print')">快捷打印</a-button>
- </div>
- <!-- 基础信息 -->
- <a-card size="small" :bordered="false" class="backorderDetail-cont">
- <a-collapse :activeKey="['1']">
- <a-collapse-panel key="1" header="基础信息">
- <a-descriptions size="small" :column="2">
- <a-descriptions-item label="销售单号">{{ detailData&&detailData.salesBillNo || '--' }}</a-descriptions-item>
- </a-descriptions>
- </a-collapse-panel>
- </a-collapse>
- </a-card>
- <a-card size="small" :bordered="false" class="backorderDetail-cont">
- <!-- alert -->
- <a-alert type="info" style="margin-bottom:10px">
- <div slot="message">
- 缺货总款数:<strong>{{ detailData && (detailData.totalCategory || detailData.totalCategory==0) ? detailData.totalCategory : '--' }}</strong>,
- 缺货总数量:<strong>{{ detailData && (detailData.totalQty || detailData.totalQty==0) ? detailData.totalQty : '--' }}</strong>,
- 缺货总售价:<strong>{{ detailData && (detailData.totalAmount || detailData.totalAmount==0) ? detailData.totalAmount : '--' }}</strong>
- </div></a-alert>
- <!-- 列表 -->
- <s-table
- class="sTable"
- ref="table"
- size="small"
- :rowKey="(record) => record.id"
- :columns="columns"
- :data="loadData"
- :defaultLoadData="false"
- :scroll="{ y: 500 }"
- bordered>
- </s-table>
- </a-card>
- </a-spin>
- <!-- 打印 -->
- <div id="print"></div>
- </a-modal>
- </template>
- <script>
- import { STable } from '@/components'
- import { oosDetail, oosDetailList, oosDetailPrint } from '@/api/oos'
- export default {
- name: 'BackorderDetailModal',
- components: { STable },
- props: {
- openModal: { // 弹框显示状态
- type: Boolean,
- default: false
- },
- itemSn: {
- type: [Number, String],
- default: ''
- }
- },
- data () {
- return {
- isShow: this.openModal, // 是否打开弹框
- spinning: false,
- detailData: null, // 详情数据
- // 表头
- columns: [
- { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
- { title: '产品编码', dataIndex: 'productEntity.code', width: '24%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '产品名称', dataIndex: 'productEntity.name', width: '24%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
- { title: '原厂编码', dataIndex: 'productEntity.origCode', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '缺货数量', dataIndex: 'qty', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- { title: '单位', dataIndex: 'productEntity.unit', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '缺货金额', dataIndex: 'totalAmount', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
- ],
- // 加载数据方法 必须为 Promise 对象
- loadData: parameter => {
- this.disabled = true
- return oosDetailList(Object.assign(parameter, this.queryParam, { oosBillSn: this.itemSn })).then(res => {
- const data = res.data
- const no = (data.pageNo - 1) * data.pageSize
- for (var i = 0; i < data.list.length; i++) {
- data.list[i].no = no + i + 1
- }
- this.localDataSource = data.list
- this.disabled = false
- return data
- })
- },
- localDataSource: []
- }
- },
- methods: {
- // 获取详情
- getDetail () {
- oosDetail({ sn: this.itemSn }).then(res => {
- if (res.status == 200) {
- this.detailData = res.data
- } else {
- this.detailData = null
- }
- })
- },
- // 打印预览/快捷打印
- handlePrint (type) {
- const _this = this
- _this.spinning = true
- oosDetailPrint({ sn: this.itemSn }).then(res => {
- _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.print(res, type)
- }
- })
- },
- print (data, type) {
- if (!data) {
- return
- }
- const url = window.URL.createObjectURL(new Blob([data], { type: 'application/pdf' }))
- document.getElementById('print').innerHTML = '<iframe id="printfbod" name="printfbod" src="' + url + '" hidden></iframe>'
- if (type == 'preview') { // 预览
- window.open(url)
- } else if (type == 'print') { // 打印
- window.frames['printfbod'].focus()
- window.frames['printfbod'].print()
- }
- }
- },
- watch: {
- // 父页面传过来的弹框状态
- openModal (newValue, oldValue) {
- this.isShow = newValue
- },
- // 重定义的弹框状态
- isShow (newValue, oldValue) {
- if (!newValue) {
- this.$emit('close')
- this.detailData = null
- this.$refs.table.clearTable()
- }
- },
- itemSn (newValue, oldValue) {
- if (this.isShow && newValue) {
- const _this = this
- this.getDetail()
- setTimeout(() => {
- _this.$refs.table.refresh(true)
- }, 200)
- }
- }
- }
- }
- </script>
- <style lang="less">
- .backorderDetail-modal{
- .ant-modal-body {
- padding: 10px 10px 20px;
- }
- .btn-cont {
- text-align: center;
- margin: 35px 0 10px;
- }
- }
- </style>
|