detailModal.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <template>
  2. <a-modal
  3. centered
  4. class="backorderDetail-modal"
  5. :footer="null"
  6. :maskClosable="false"
  7. title="详情"
  8. v-model="isShow"
  9. @cancle="isShow=false"
  10. :width="960">
  11. <a-spin :spinning="spinning" tip="Loading...">
  12. <div style="padding: 0 12px;text-align: right;" v-if="$hasPermissions('B_oosPrint')">
  13. <a-button id="backorderDetail-preview-btn" :disabled="localDataSource.length==0" @click="handlePrint('preview')" style="margin-right: 15px;">打印预览</a-button>
  14. <a-button type="primary" id="backorderDetail-print-btn" :disabled="localDataSource.length==0" @click="handlePrint('print')">快捷打印</a-button>
  15. </div>
  16. <!-- 基础信息 -->
  17. <a-card size="small" :bordered="false" class="backorderDetail-cont">
  18. <a-collapse :activeKey="['1']">
  19. <a-collapse-panel key="1" header="基础信息">
  20. <a-descriptions size="small" :column="2">
  21. <a-descriptions-item label="销售单号">{{ detailData&&detailData.salesBillNo || '--' }}</a-descriptions-item>
  22. </a-descriptions>
  23. </a-collapse-panel>
  24. </a-collapse>
  25. </a-card>
  26. <a-card size="small" :bordered="false" class="backorderDetail-cont">
  27. <!-- alert -->
  28. <a-alert type="info" style="margin-bottom:10px">
  29. <div slot="message">
  30. 缺货总款数:<strong>{{ detailData && (detailData.totalCategory || detailData.totalCategory==0) ? detailData.totalCategory : '--' }}</strong>,
  31. 缺货总数量:<strong>{{ detailData && (detailData.totalQty || detailData.totalQty==0) ? detailData.totalQty : '--' }}</strong>,
  32. 缺货总售价:<strong>{{ detailData && (detailData.totalAmount || detailData.totalAmount==0) ? detailData.totalAmount : '--' }}</strong>
  33. </div></a-alert>
  34. <!-- 列表 -->
  35. <s-table
  36. class="sTable"
  37. ref="table"
  38. size="small"
  39. :rowKey="(record) => record.id"
  40. :columns="columns"
  41. :data="loadData"
  42. :defaultLoadData="false"
  43. :scroll="{ y: 500 }"
  44. bordered>
  45. </s-table>
  46. </a-card>
  47. </a-spin>
  48. <!-- 打印 -->
  49. <div id="print"></div>
  50. </a-modal>
  51. </template>
  52. <script>
  53. import { STable } from '@/components'
  54. import { oosDetail, oosDetailList, oosDetailPrint } from '@/api/oos'
  55. export default {
  56. name: 'BackorderDetailModal',
  57. components: { STable },
  58. props: {
  59. openModal: { // 弹框显示状态
  60. type: Boolean,
  61. default: false
  62. },
  63. itemSn: {
  64. type: [Number, String],
  65. default: ''
  66. }
  67. },
  68. data () {
  69. return {
  70. isShow: this.openModal, // 是否打开弹框
  71. spinning: false,
  72. detailData: null, // 详情数据
  73. // 表头
  74. columns: [
  75. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  76. { title: '产品编码', dataIndex: 'productEntity.code', width: '24%', align: 'center', customRender: function (text) { return text || '--' } },
  77. { title: '产品名称', dataIndex: 'productEntity.name', width: '24%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  78. { title: '原厂编码', dataIndex: 'productEntity.origCode', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
  79. { title: '缺货数量', dataIndex: 'qty', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  80. { title: '单位', dataIndex: 'productEntity.unit', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  81. { title: '缺货金额', dataIndex: 'totalAmount', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  82. ],
  83. // 加载数据方法 必须为 Promise 对象
  84. loadData: parameter => {
  85. this.disabled = true
  86. return oosDetailList(Object.assign(parameter, this.queryParam, { oosBillSn: this.itemSn })).then(res => {
  87. const data = res.data
  88. const no = (data.pageNo - 1) * data.pageSize
  89. for (var i = 0; i < data.list.length; i++) {
  90. data.list[i].no = no + i + 1
  91. }
  92. this.localDataSource = data.list
  93. this.disabled = false
  94. return data
  95. })
  96. },
  97. localDataSource: []
  98. }
  99. },
  100. methods: {
  101. // 获取详情
  102. getDetail () {
  103. oosDetail({ sn: this.itemSn }).then(res => {
  104. if (res.status == 200) {
  105. this.detailData = res.data
  106. } else {
  107. this.detailData = null
  108. }
  109. })
  110. },
  111. // 打印预览/快捷打印
  112. handlePrint (type) {
  113. const _this = this
  114. _this.spinning = true
  115. oosDetailPrint({ sn: this.itemSn }).then(res => {
  116. _this.spinning = false
  117. if (res.type == 'application/json') {
  118. var reader = new FileReader()
  119. reader.addEventListener('loadend', function () {
  120. const obj = JSON.parse(reader.result)
  121. _this.$notification.error({
  122. message: '提示',
  123. description: obj.message
  124. })
  125. })
  126. reader.readAsText(res)
  127. } else {
  128. this.print(res, type)
  129. }
  130. })
  131. },
  132. print (data, type) {
  133. if (!data) {
  134. return
  135. }
  136. const url = window.URL.createObjectURL(new Blob([data], { type: 'application/pdf' }))
  137. document.getElementById('print').innerHTML = '<iframe id="printfbod" name="printfbod" src="' + url + '" hidden></iframe>'
  138. if (type == 'preview') { // 预览
  139. window.open(url)
  140. } else if (type == 'print') { // 打印
  141. window.frames['printfbod'].focus()
  142. window.frames['printfbod'].print()
  143. }
  144. }
  145. },
  146. watch: {
  147. // 父页面传过来的弹框状态
  148. openModal (newValue, oldValue) {
  149. this.isShow = newValue
  150. },
  151. // 重定义的弹框状态
  152. isShow (newValue, oldValue) {
  153. if (!newValue) {
  154. this.$emit('close')
  155. this.detailData = null
  156. this.$refs.table.clearTable()
  157. }
  158. },
  159. itemSn (newValue, oldValue) {
  160. if (this.isShow && newValue) {
  161. const _this = this
  162. this.getDetail()
  163. setTimeout(() => {
  164. _this.$refs.table.refresh(true)
  165. }, 200)
  166. }
  167. }
  168. }
  169. }
  170. </script>
  171. <style lang="less">
  172. .backorderDetail-modal{
  173. .ant-modal-body {
  174. padding: 10px 10px 20px;
  175. }
  176. .btn-cont {
  177. text-align: center;
  178. margin: 35px 0 10px;
  179. }
  180. }
  181. </style>