detail.vue 13 KB

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