detail.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <template>
  2. <div class="purchaseOrderDetail-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <a-page-header :ghost="false" :backIcon="false" @back="handleBack" class="purchaseOrderDetail-cont" >
  5. <!-- 自定义的二级文字标题 -->
  6. <template slot="subTitle">
  7. <a id="purchaseOrderDetail-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
  8. <span class="billno">单号:{{ detail&&detail.purchaseBillNo }}</span>
  9. <a-tag color="blue">{{ detail&&detail.billStatusDictValue }}</a-tag>
  10. <a-tag color="orange">{{ detail&&detail.financialStatusDictValue }}</a-tag>
  11. </template>
  12. <!-- 操作区,位于 title 行的行尾 -->
  13. <template slot="extra">
  14. <a-radio-group key="3" v-model="printerType">
  15. <a-radio value="NEEDLE">针式</a-radio>
  16. <a-radio value="INK">喷墨</a-radio>
  17. </a-radio-group>
  18. <a-button key="2" id="purchaseOrderDetail-preview-btn" :disabled="localDataSource.length==0" @click="handlePrint('preview')">打印预览</a-button>
  19. <a-button key="1" type="primary" id="purchaseOrderDetail-print-btn" :disabled="localDataSource.length==0" @click="handlePrint('print')">快捷打印</a-button>
  20. </template>
  21. </a-page-header>
  22. <!-- 基础信息 -->
  23. <a-card size="small" :bordered="false" class="purchaseOrderDetail-cont">
  24. <a-collapse :activeKey="['1']">
  25. <a-collapse-panel key="1" header="基础信息">
  26. <a-descriptions :column="3">
  27. <a-descriptions-item label="供应商">{{ (detail&&detail.purchaseTargetName) || '--' }}</a-descriptions-item>
  28. <a-descriptions-item label="支付方式">{{ detail&&detail.settleStyleEntity.name }}</a-descriptions-item>
  29. <a-descriptions-item label="采购员工">{{ detail&&detail.operatorName }}</a-descriptions-item>
  30. <a-descriptions-item label="收货人">{{ detail&&detail.consigneeName }}<span v-if="detail&&detail.consigneeTel">({{ detail&&detail.consigneeTel }})</span></a-descriptions-item>
  31. <a-descriptions-item label="收货地址">
  32. {{ detail&&detail.shippingAddressProvinceName }}
  33. {{ detail&&detail.shippingAddressCityName }}
  34. {{ detail&&detail.shippingAddressCountyName }}
  35. {{ detail&&detail.shippingAddress }}
  36. </a-descriptions-item>
  37. </a-descriptions>
  38. </a-collapse-panel>
  39. </a-collapse>
  40. </a-card>
  41. <!-- 产品详情 -->
  42. <a-card size="small" :bordered="false" class="purchaseOrderDetail-cont">
  43. <a-collapse :activeKey="['1']">
  44. <a-collapse-panel key="1" header="产品详情">
  45. <!-- 总计 -->
  46. <a-alert type="info" showIcon style="margin-bottom:15px">
  47. <div slot="message">
  48. 产品款数:<strong>{{ detail ? ((detail.totalCategory || detail.totalCategory==0) ? detail.totalCategory : '--') : '--' }}</strong>,
  49. 采购数量合计:<strong>{{ detail ? ((detail.totalQty || detail.totalQty==0) ? detail.totalQty : '--') : '--' }}</strong>,
  50. 已收货数量:<strong>{{ detail ? ((detail.totalPutQty || detail.totalPutQty==0) ? detail.totalPutQty : '--') : '--' }}</strong>,
  51. 待收货数量:<strong>{{ detail ? ((detail.totalWaitPutQty || detail.totalWaitPutQty==0) ? detail.totalWaitPutQty : '--') : '--' }}</strong>,
  52. 取消数量:<strong>{{ detail ? ((detail.totalCancelQty || detail.totalCancelQty==0) ? detail.totalCancelQty : '--') : '--' }}</strong>,
  53. 采购金额合计:¥<strong>{{ detail ? ((detail.discountedAmount || detail.discountedAmount==0) ? detail.discountedAmount : '--') : '--' }}</strong>,
  54. 已收货金额:¥<strong>{{ detail ? ((detail.totalPutAmount || detail.totalPutAmount==0) ? detail.totalPutAmount : '--') : '--' }}</strong>,
  55. 待收货金额:¥<strong>{{ detail ? ((detail.totalWaitPutAmount || detail.totalWaitPutAmount==0) ? detail.totalWaitPutAmount : '--') : '--' }}</strong>,
  56. 取消金额:¥<strong>{{ detail ? ((detail.totalCancelAmount || detail.totalCancelAmount==0) ? detail.totalCancelAmount : '--') : '--' }}</strong>
  57. </div>
  58. </a-alert>
  59. <!-- 列表 -->
  60. <s-table
  61. class="sTable"
  62. ref="table"
  63. size="small"
  64. :rowKey="(record) => record.id"
  65. :columns="columns"
  66. :data="loadData"
  67. :scroll="{ x: 1480 }"
  68. bordered>
  69. <!-- 采购数量 -->
  70. <template slot="origqty" slot-scope="text, record">
  71. <div>{{ text }}</div>
  72. <div v-if="record.origqty">原采购数量:{{ record.origqty }}</div>
  73. </template>
  74. <!-- 缺货数量 -->
  75. <template slot="outOfStockNum" slot-scope="text, record">
  76. <span>{{ record.outOfStockNum }}</span>
  77. </template>
  78. </s-table>
  79. </a-collapse-panel>
  80. </a-collapse>
  81. </a-card>
  82. <!-- 促销品详情 -->
  83. <a-card size="small" v-if="false" :bordered="false" class="purchaseOrderDetail-cont">
  84. <a-collapse :activeKey="['1']">
  85. <a-collapse-panel key="1" header="促销品详情">
  86. <!-- 总计 -->
  87. <a-alert type="info" showIcon style="margin-bottom:15px">
  88. <div slot="message">产品款数 <strong>{{ detail&&detail.totalCategory }}</strong> ,
  89. 采购数量合计 <strong>{{ detail&&detail.totalQty }}</strong> ,
  90. 采购金额合计¥<strong>{{ detail&&detail.totalAmount }}</strong></div>
  91. </a-alert>
  92. <!-- 列表 -->
  93. <s-table
  94. class="sTable"
  95. ref="table-1"
  96. size="small"
  97. :rowKey="(record) => record.id"
  98. :columns="columns"
  99. :data="loadData"
  100. :scroll="{ x: 1060 }"
  101. bordered>
  102. <!-- 采购数量 -->
  103. <template slot="origqty" slot-scope="text, record">
  104. <div>{{ text }}</div>
  105. <div v-if="record.origqty">原采购数量:{{ record.origqty }}</div>
  106. </template>
  107. <!-- 缺货数量 -->
  108. <template slot="outOfStockNum" slot-scope="text, record">
  109. <span>{{ record.outOfStockNum }}</span>
  110. </template>
  111. </s-table>
  112. </a-collapse-panel>
  113. </a-collapse>
  114. </a-card>
  115. <!-- 单据记录 -->
  116. <a-card size="small" v-show="false" :bordered="false" class="purchaseOrderDetail-cont">
  117. <a-collapse :activeKey="['1']">
  118. <a-collapse-panel key="1" header="单据记录">
  119. <a-timeline class="timeline-box">
  120. <a-timeline-item>2021-02-01 15:22:38 王凯 审核通过</a-timeline-item>
  121. <a-timeline-item>
  122. <p>2021-02-01 15:22:38 王凯 审核通过</p>
  123. <p class="auxiliary-txt">产品编号JA-11076P的采购数量,由【10】修改为【5】</p>
  124. <p class="auxiliary-txt">产品编号JA-11076P的采购数量,由【10】修改为【5】</p>
  125. </a-timeline-item>
  126. <a-timeline-item>Technical testing 2015-09-01</a-timeline-item>
  127. <a-timeline-item>Network problems being solved 2015-09-01</a-timeline-item>
  128. </a-timeline>
  129. </a-collapse-panel>
  130. </a-collapse>
  131. </a-card>
  132. </a-spin>
  133. <!-- 打印 -->
  134. <div id="print"></div>
  135. </div>
  136. </template>
  137. <script>
  138. import { STable, VSelect } from '@/components'
  139. import { purchaseDetailBySn, purchaseDetailPrint } from '@/api/purchase'
  140. import { purchaseDetailList } from '@/api/purchaseDetail'
  141. export default {
  142. components: { STable, VSelect },
  143. data () {
  144. return {
  145. spinning: false,
  146. // 表头
  147. columns: [
  148. { title: '序号', dataIndex: 'no', width: 80, align: 'center', fixed: 'left' },
  149. { title: '产品编码', dataIndex: 'dealerProductEntity.code', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
  150. { title: '产品名称', dataIndex: 'dealerProductEntity.name', align: 'center', customRender: function (text) { return text || '--' } },
  151. { title: '原厂编码', dataIndex: 'dealerProductEntity.origCode', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
  152. { title: '单位', dataIndex: 'dealerProductEntity.unit', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  153. { title: '采购单价', dataIndex: 'discountedPrice', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  154. { title: '采购金额', dataIndex: 'discountedAmount', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? '¥' + text : '--') } },
  155. { title: '采购数量', dataIndex: 'qty', width: 100, align: 'center', scopedSlots: { customRender: 'origqty' } },
  156. { title: '取消数量', dataIndex: 'cancelQty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  157. { title: '已收货数量', dataIndex: 'putQty', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  158. { title: '待收货数量', dataIndex: 'waitPutQty', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  159. ],
  160. // 加载数据方法 必须为 Promise 对象
  161. loadData: parameter => {
  162. this.disabled = true
  163. return purchaseDetailList(Object.assign(parameter, { purchaseBillSn: this.$route.params.sn })).then(res => {
  164. const data = res.data
  165. const no = (data.pageNo - 1) * data.pageSize
  166. for (var i = 0; i < data.list.length; i++) {
  167. data.list[i].no = no + i + 1
  168. }
  169. this.localDataSource = data.list
  170. this.disabled = false
  171. return data
  172. })
  173. },
  174. detail: null, // 详情数据
  175. localDataSource: [],
  176. printerType: 'NEEDLE' // 打印机类型
  177. }
  178. },
  179. methods: {
  180. // 返回列表
  181. handleBack () {
  182. this.$router.push({ path: '/purchasingManagement/purchaseOrder/list' })
  183. },
  184. // 详情
  185. getDetail () {
  186. purchaseDetailBySn({ sn: this.$route.params.sn }).then(res => {
  187. if (res.status == 200) {
  188. this.detail = res.data
  189. } else {
  190. this.detail = null
  191. }
  192. })
  193. },
  194. // 打印预览/快捷打印
  195. handlePrint (type) {
  196. const _this = this
  197. _this.spinning = true
  198. purchaseDetailPrint({ sn: this.$route.params.sn, type: this.printerType }).then(res => {
  199. _this.spinning = false
  200. if (res.type == 'application/json') {
  201. var reader = new FileReader()
  202. reader.addEventListener('loadend', function () {
  203. const obj = JSON.parse(reader.result)
  204. _this.$notification.error({
  205. message: '提示',
  206. description: obj.message
  207. })
  208. })
  209. reader.readAsText(res)
  210. } else {
  211. this.print(res, type)
  212. }
  213. })
  214. },
  215. print (data, type) {
  216. if (!data) {
  217. return
  218. }
  219. const url = window.URL.createObjectURL(new Blob([data], { type: 'application/pdf' }))
  220. document.getElementById('print').innerHTML = '<iframe id="printf" name="printf" src="' + url + '" hidden></iframe>'
  221. if (type == 'preview') { // 预览
  222. window.open(url)
  223. } else if (type == 'print') { // 打印
  224. window.frames['printf'].focus()
  225. window.frames['printf'].print()
  226. }
  227. }
  228. },
  229. mounted () {
  230. this.getDetail()
  231. }
  232. }
  233. </script>
  234. <style lang="less">
  235. .purchaseOrderDetail-cont{
  236. margin-bottom: 15px;
  237. .timeline-box{
  238. margin-top: 30px;
  239. .auxiliary-txt{
  240. color: #808695;
  241. }
  242. }
  243. }
  244. .purchaseOrderDetail-wrap{
  245. .billno{
  246. font-size: 16px;
  247. font-weight: bold;
  248. margin: 0 15px;
  249. }
  250. }
  251. </style>