detail.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  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="5" v-model="printerType" v-if="$hasPermissions('B_purchasePrint')">
  15. <a-radio value="NEEDLE">针式</a-radio>
  16. <a-radio value="INK">喷墨</a-radio>
  17. </a-radio-group>
  18. <a-button key="4" v-if="$hasPermissions('B_purchasePrint')" id="purchaseOrderDetail-preview-btn" :disabled="localDataSource.length==0" @click="handlePrint('preview')">打印预览</a-button>
  19. <a-button
  20. key="3"
  21. v-if="$hasPermissions('B_purchasePrint')"
  22. type="primary"
  23. id="purchaseOrderDetail-print-btn"
  24. :disabled="localDataSource.length==0"
  25. @click="handlePrint('print')">快捷打印</a-button>
  26. <a-button
  27. key="2"
  28. v-if="$hasPermissions('B_purchasePrint')"
  29. type="primary"
  30. class="button-warning"
  31. id="purchaseOrderDetail-export-btn"
  32. :disabled="localDataSource.length==0"
  33. @click="handlePrint('export')">导出Excel</a-button>
  34. <!-- <a-button
  35. key="1"
  36. v-if="$hasPermissions('B_purchaseExportProduct') && (detail&&detail.billStatus=='FINISH')"
  37. type="primary"
  38. class="button-info"
  39. id="purchaseOrderDetail-export-btn"
  40. :disabled="localDataSource.length==0"
  41. @click="handlePrint('exportProduct')">导出产品</a-button> -->
  42. </template>
  43. </a-page-header>
  44. <!-- 基础信息 -->
  45. <a-card size="small" :bordered="false" class="purchaseOrderDetail-cont">
  46. <a-collapse :activeKey="['1']">
  47. <a-collapse-panel key="1" header="基础信息">
  48. <a-descriptions :column="3">
  49. <a-descriptions-item label="供应商">{{ (detail&&detail.purchaseTargetName) || '--' }}</a-descriptions-item>
  50. <a-descriptions-item label="支付方式">{{ (detail&&detail.settleStyleEntity&&detail.settleStyleEntity.name) || '--' }}</a-descriptions-item>
  51. <a-descriptions-item label="采购员工" v-if="detail&&detail.purchaseBillSource=='PURCHASE'">{{ detail&&detail.operatorName || '--' }}</a-descriptions-item>
  52. <a-descriptions-item label="收货人">{{ detail&&detail.consigneeName || '--' }}<span v-if="detail&&detail.consigneeTel">({{ detail&&detail.consigneeTel }})</span></a-descriptions-item>
  53. <a-descriptions-item label="收货地址">
  54. <div v-if="detail&&(detail.shippingAddressProvinceName || detail.shippingAddressCityName || detail.shippingAddressCountyName || detail.shippingAddress)">
  55. {{ detail&&detail.shippingAddressProvinceName || '' }}
  56. {{ detail&&detail.shippingAddressCityName || '' }}
  57. {{ detail&&detail.shippingAddressCountyName || '' }}
  58. {{ detail&&detail.shippingAddress || '' }}
  59. </div>
  60. <span v-else>--</span>
  61. </a-descriptions-item>
  62. </a-descriptions>
  63. </a-collapse-panel>
  64. </a-collapse>
  65. </a-card>
  66. <!-- 产品详情 -->
  67. <a-card size="small" :bordered="false" class="purchaseOrderDetail-cont">
  68. <a-collapse :activeKey="['1']">
  69. <a-collapse-panel key="1" header="产品详情">
  70. <!-- 总计 -->
  71. <a-alert type="info" style="margin-bottom:10px">
  72. <div slot="message">
  73. 产品款数:<strong>{{ detail && (detail.totalCategory || detail.totalCategory==0) ? detail.totalCategory : '--' }}</strong>,
  74. 采购数量合计:<strong>{{ detail && (detail.totalQty || detail.totalQty==0) ? detail.totalQty : '--' }}</strong>,
  75. 审核订单数量:<strong>{{ detail && (detail.totalAuthQty || detail.totalAuthQty==0) ? detail.totalAuthQty : '--' }}</strong>,
  76. 缺货数量:<strong>{{ detail && (detail.totalCancelQty || detail.totalCancelQty==0) ? detail.totalCancelQty : '--' }}</strong>,
  77. 采购金额合计:<strong>{{ detail && (detail.discountedAmount || detail.discountedAmount==0) ? '¥'+detail.discountedAmount : '--' }}</strong>,
  78. 审核订单金额:<strong>{{ detail && (detail.totalAuthAmount || detail.totalAuthAmount==0) ? '¥'+detail.totalAuthAmount : '--' }}</strong>,
  79. 缺货金额:<strong>{{ detail && (detail.totalCancelAmount || detail.totalCancelAmount==0) ? '¥'+detail.totalCancelAmount : '--' }}</strong>
  80. </div>
  81. </a-alert>
  82. <!-- 列表 -->
  83. <s-table
  84. class="sTable"
  85. ref="table"
  86. size="small"
  87. :rowKey="(record) => record.id"
  88. :columns="columns"
  89. :data="loadData"
  90. :defaultLoadData="false"
  91. bordered>
  92. <!-- 采购数量 -->
  93. <template slot="origqty" slot-scope="text, record">
  94. <div>{{ text }}</div>
  95. <div v-if="record.origqty">原采购数量:{{ record.origqty }}</div>
  96. </template>
  97. <!-- 缺货数量 -->
  98. <template slot="outOfStockNum" slot-scope="text, record">
  99. <span>{{ record.outOfStockNum }}</span>
  100. </template>
  101. </s-table>
  102. </a-collapse-panel>
  103. </a-collapse>
  104. </a-card>
  105. <!-- 促销品详情 -->
  106. <a-card size="small" v-if="false" :bordered="false" class="purchaseOrderDetail-cont">
  107. <a-collapse :activeKey="['1']">
  108. <a-collapse-panel key="1" header="促销品详情">
  109. <!-- 总计 -->
  110. <a-alert type="info" style="margin-bottom:10px">
  111. <div slot="message">产品款数 <strong>{{ detail&&(detail.totalCategory || detail.totalCategory==0) ? detail.totalCategory : '--' }}</strong> ,
  112. 采购数量合计 <strong>{{ detail&&(detail.totalQty || detail.totalQty==0) ? detail.totalQty : '--' }}</strong> ,
  113. 采购金额合计 <strong>{{ detail&&(detail.totalAmount || detail.totalAmount==0) ? '¥'+detail.totalAmount : '--' }}</strong></div>
  114. </a-alert>
  115. <!-- 列表 -->
  116. <s-table
  117. class="sTable"
  118. ref="table-1"
  119. size="small"
  120. :rowKey="(record) => record.id"
  121. :columns="columns"
  122. :data="loadData"
  123. :scroll="{ x: 1060 }"
  124. bordered>
  125. <!-- 采购数量 -->
  126. <template slot="origqty" slot-scope="text, record">
  127. <div>{{ text }}</div>
  128. <div v-if="record.origqty">原采购数量:{{ record.origqty }}</div>
  129. </template>
  130. <!-- 缺货数量 -->
  131. <template slot="outOfStockNum" slot-scope="text, record">
  132. <span>{{ record.outOfStockNum }}</span>
  133. </template>
  134. </s-table>
  135. </a-collapse-panel>
  136. </a-collapse>
  137. </a-card>
  138. <!-- 单据记录 -->
  139. <a-card size="small" v-show="false" :bordered="false" class="purchaseOrderDetail-cont">
  140. <a-collapse :activeKey="['1']">
  141. <a-collapse-panel key="1" header="单据记录">
  142. <a-timeline class="timeline-box">
  143. <a-timeline-item>2021-02-01 15:22:38 王凯 审核通过</a-timeline-item>
  144. <a-timeline-item>
  145. <p>2021-02-01 15:22:38 王凯 审核通过</p>
  146. <p class="auxiliary-txt">产品编号JA-11076P的采购数量,由【10】修改为【5】</p>
  147. <p class="auxiliary-txt">产品编号JA-11076P的采购数量,由【10】修改为【5】</p>
  148. </a-timeline-item>
  149. <a-timeline-item>Technical testing 2015-09-01</a-timeline-item>
  150. <a-timeline-item>Network problems being solved 2015-09-01</a-timeline-item>
  151. </a-timeline>
  152. </a-collapse-panel>
  153. </a-collapse>
  154. </a-card>
  155. </a-spin>
  156. <!-- 打印 -->
  157. <div id="print"></div>
  158. </div>
  159. </template>
  160. <script>
  161. import moment from 'moment'
  162. import { STable, VSelect } from '@/components'
  163. import { purchaseDetailBySn, purchaseDetailPrint, purchaseDetailExport, purchaseExportDetail } from '@/api/purchase'
  164. import { purchaseDetailList } from '@/api/purchaseDetail'
  165. export default {
  166. components: { STable, VSelect },
  167. data () {
  168. return {
  169. spinning: false,
  170. // 表头
  171. columns: [
  172. { title: '序号', dataIndex: 'no', width: '6%', align: 'center' },
  173. { title: '产品编码', dataIndex: 'dealerProductEntity.code', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  174. { title: '产品名称', dataIndex: 'dealerProductEntity.name', width: '16%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  175. { title: '原厂编码', dataIndex: 'dealerProductEntity.origCode', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  176. { title: '单位', dataIndex: 'dealerProductEntity.unit', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  177. { title: '采购单价', dataIndex: 'discountedPrice', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  178. { title: '采购金额', dataIndex: 'discountedAmount', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  179. { title: '采购数量', dataIndex: 'qty', width: '8%', align: 'center', scopedSlots: { customRender: 'origqty' } },
  180. { title: '审核订单数量', dataIndex: 'authQty', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  181. { title: '缺货数量', dataIndex: 'cancelQty', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  182. ],
  183. // 加载数据方法 必须为 Promise 对象
  184. loadData: parameter => {
  185. this.disabled = true
  186. return purchaseDetailList(Object.assign(parameter, { purchaseBillSn: this.$route.params.sn })).then(res => {
  187. const data = res.data
  188. const no = (data.pageNo - 1) * data.pageSize
  189. for (var i = 0; i < data.list.length; i++) {
  190. data.list[i].no = no + i + 1
  191. }
  192. this.localDataSource = data.list
  193. this.disabled = false
  194. return data
  195. })
  196. },
  197. detail: null, // 详情数据
  198. localDataSource: [],
  199. printerType: 'NEEDLE' // 打印机类型
  200. }
  201. },
  202. methods: {
  203. // 返回列表
  204. handleBack () {
  205. this.$router.push({ path: '/purchasingManagement/purchaseOrder/list', query: { closeLastOldTab: true } })
  206. },
  207. // 详情
  208. getDetail () {
  209. purchaseDetailBySn({ sn: this.$route.params.sn }).then(res => {
  210. if (res.status == 200) {
  211. this.detail = res.data
  212. } else {
  213. this.detail = null
  214. }
  215. })
  216. },
  217. // 打印预览/快捷打印
  218. handlePrint (type) {
  219. const _this = this
  220. _this.spinning = true
  221. let url = purchaseDetailPrint
  222. let params = { sn: this.$route.params.sn, type: this.printerType }
  223. if (type == 'export') { // 导出
  224. url = purchaseDetailExport
  225. params = { sn: this.$route.params.sn }
  226. }
  227. if (type == 'exportProduct') {
  228. url = purchaseExportDetail
  229. params = { sn: this.$route.params.sn }
  230. }
  231. url(params).then(res => {
  232. _this.spinning = false
  233. if (res.type == 'application/json') {
  234. var reader = new FileReader()
  235. reader.addEventListener('loadend', function () {
  236. const obj = JSON.parse(reader.result)
  237. _this.$notification.error({
  238. message: '提示',
  239. description: obj.message
  240. })
  241. })
  242. reader.readAsText(res)
  243. } else {
  244. if (type == 'export' || type == 'exportProduct') { // 导出
  245. this.download(res, type)
  246. } else {
  247. this.print(res, type)
  248. }
  249. }
  250. })
  251. },
  252. print (data, type) {
  253. if (!data) {
  254. return
  255. }
  256. const url = window.URL.createObjectURL(new Blob([data], { type: 'application/pdf' }))
  257. document.getElementById('print').innerHTML = '<iframe id="printfpod" name="printfpod" src="' + url + '" hidden></iframe>'
  258. if (type == 'preview') { // 预览
  259. window.open(url)
  260. } else if (type == 'print') { // 打印
  261. window.frames['printfpod'].focus()
  262. window.frames['printfpod'].print()
  263. }
  264. },
  265. download (data, type) {
  266. if (!data) { return }
  267. const url = window.URL.createObjectURL(new Blob([data]))
  268. const link = document.createElement('a')
  269. link.style.display = 'none'
  270. link.href = url
  271. const a = moment().format('YYYYMMDDHHmmss')
  272. let fname = ''
  273. if (type == 'export') {
  274. fname = '采购' + a
  275. } else if (type == 'exportProduct') {
  276. fname = '采购产品' + a
  277. }
  278. link.setAttribute('download', fname + '.xlsx')
  279. document.body.appendChild(link)
  280. link.click()
  281. }
  282. },
  283. mounted () {
  284. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  285. this.$refs.table.refresh(true)
  286. this.getDetail()
  287. }
  288. },
  289. activated () {
  290. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  291. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  292. this.$refs.table.refresh(true)
  293. this.getDetail()
  294. }
  295. },
  296. beforeRouteEnter (to, from, next) {
  297. next(vm => {})
  298. }
  299. }
  300. </script>
  301. <style lang="less">
  302. .purchaseOrderDetail-cont{
  303. margin-bottom: 10px;
  304. .timeline-box{
  305. margin-top: 30px;
  306. .auxiliary-txt{
  307. color: #808695;
  308. }
  309. }
  310. }
  311. .purchaseOrderDetail-wrap{
  312. .billno{
  313. font-size: 16px;
  314. font-weight: bold;
  315. margin: 0 15px;
  316. }
  317. }
  318. </style>