detail.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. <template>
  2. <div class="purchaseOrderDetail-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <a-page-header :ghost="false" :backIcon="false" class="purchaseOrderDetail-cont" :style="{ padding: !outBizSn ? '16px 24px' : '0px 24px' }">
  5. <!-- 自定义的二级文字标题 -->
  6. <template slot="subTitle">
  7. <span class="billno">单号:{{ detail&&detail.purchaseBillNo }}</span>
  8. <a-tag color="blue" v-if="detail&&detail.billStatusDictValue">{{ detail&&detail.billStatusDictValue }}</a-tag>
  9. <a-tag color="orange" v-if="detail&&detail.financialStatusDictValue">{{ detail&&detail.financialStatusDictValue }}</a-tag>
  10. <span v-if="detail&&detail.purchaseBillNoSource" style="font-size: 14px;margin: 0 10px;">(原:{{ detail&&detail.purchaseBillNoSource }})</span>
  11. <a-button type="link" class="button-default" @click="isShowBisiceInfo=!isShowBisiceInfo" style="margin-left:10px;vertical-align:middle;">
  12. <a-icon :type="isShowBisiceInfo ? 'eye-invisible' : 'eye'"/>
  13. 查看信息
  14. </a-button>
  15. <a-button id="purchaseNewOrderEdit-back-btn" type="link" @click="handleBack" class="button-default"> <a-icon type="rollback" /> 返回列表</a-button>
  16. </template>
  17. <!-- 操作区,位于 title 行的行尾 -->
  18. <template slot="extra">
  19. <div style="margin-top: 5px;">
  20. <PrintPanel position="bottomRight" v-if="$hasPermissions('B_purchasePrint')" :disabled="localDataSource.length==0" @handlePrint="handlePrint">
  21. <a-button
  22. slot="extendButtons"
  23. key="4"
  24. v-if="$hasPermissions('B_purchaseExportProduct') && (detail&&(detail.billStatus=='AUDIT_PASS' || detail.billStatus=='CANCEL' || detail.billStatus=='WAIT_PUT_WAREHOUSE' || detail.billStatus=='WAIT_PUT_WAREHOUSE_AUDIT' || detail.billStatus=='FINISH'))"
  25. type="primary"
  26. class="button-info"
  27. id="purchaseOrderDetail-export-btn"
  28. :disabled="localDataSource.length==0"
  29. @click="handleExportProduct()">导出审核订单产品</a-button>
  30. </PrintPanel>
  31. </div>
  32. </template>
  33. </a-page-header>
  34. <!-- 基础信息 -->
  35. <a-card size="small" :bordered="false" class="purchaseOrderDetail-cont" v-show="isShowBisiceInfo">
  36. <a-descriptions :column="3" size="small">
  37. <div slot="title">基础信息</div>
  38. <a-descriptions-item label="供应商">{{ (detail&&detail.purchaseTargetName) || '--' }}</a-descriptions-item>
  39. <a-descriptions-item label="支付方式">{{ (detail&&detail.settleStyleSnDictValue) || '--' }}</a-descriptions-item>
  40. <a-descriptions-item label="采购员工" v-if="detail&&detail.purchaseBillSource=='PURCHASE'">{{ detail&&detail.operatorName || '--' }}</a-descriptions-item>
  41. <a-descriptions-item label="收货人">{{ detail&&detail.consigneeName || '--' }}<span v-if="detail&&detail.consigneeTel">({{ detail&&detail.consigneeTel }})</span></a-descriptions-item>
  42. <a-descriptions-item label="收货地址">
  43. <div v-if="detail&&(detail.shippingAddressProvinceName || detail.shippingAddressCityName || detail.shippingAddressCountyName || detail.shippingAddress)">
  44. {{ detail&&detail.shippingAddressProvinceName || '' }}
  45. {{ detail&&detail.shippingAddressCityName || '' }}
  46. {{ detail&&detail.shippingAddressCountyName || '' }}
  47. {{ detail&&detail.shippingAddress || '' }}
  48. </div>
  49. <span v-else>--</span>
  50. </a-descriptions-item>
  51. <a-descriptions-item label="备注">{{ (detail&&detail.remarks) || '--' }}</a-descriptions-item>
  52. </a-descriptions>
  53. </a-card>
  54. <!-- 产品详情 -->
  55. <a-card size="small" :bordered="false" class="purchaseOrderDetail-cont">
  56. <!-- <div slot="title" style="font-size:14px;"><strong>产品详情</strong></div> -->
  57. <!-- 总计 -->
  58. <div class="alert-message">
  59. 产品款数:<strong>{{ detail && (detail.totalCategory || detail.totalCategory==0) ? detail.totalCategory : '--' }}</strong>,
  60. 采购数量合计:<strong>{{ detail && (detail.totalQty || detail.totalQty==0) ? detail.totalQty : '--' }}</strong>,
  61. 审核订单数量:<strong>{{ detail && (detail.totalPushedQty || detail.totalPushedQty==0) ? detail.totalPushedQty : '--' }}</strong>,
  62. 已取消数量:<strong>{{ detail && (detail.totalCancelQty || detail.totalCancelQty==0) ? detail.totalCancelQty : '--' }}</strong>,
  63. <div style="display: inline-block;" v-if="$hasPermissions('M_ShowAllCost')">
  64. 采购金额合计:<strong>{{ detail && (detail.discountedAmount || detail.discountedAmount==0) ? toThousands(detail.discountedAmount,2) : '--' }}</strong>,
  65. 审核订单金额:<strong>{{ detail && (detail.totalPushedAmount || detail.totalPushedAmount==0) ? toThousands(detail.totalPushedAmount,2) : '--' }}</strong>,
  66. 已取消金额:<strong>{{ detail && (detail.totalCancelAmount || detail.totalCancelAmount==0) ? toThousands(detail.totalCancelAmount,2) : '--' }}</strong>
  67. </div>
  68. </div>
  69. <!-- 列表 -->
  70. <s-table
  71. class="sTable"
  72. ref="table"
  73. size="small"
  74. :rowKey="(record) => record.id"
  75. :columns="columns"
  76. :data="loadData"
  77. :defaultLoadData="false"
  78. bordered>
  79. <!-- 采购数量 -->
  80. <template slot="origqty" slot-scope="text, record">
  81. <div>{{ text }}</div>
  82. <div v-if="record.origqty">原采购数量:{{ record.origqty }}</div>
  83. </template>
  84. <!-- 已取消数量 -->
  85. <template slot="outOfStockNum" slot-scope="text, record">
  86. <span>{{ record.outOfStockNum }}</span>
  87. </template>
  88. </s-table>
  89. </a-card>
  90. </a-spin>
  91. </div>
  92. </template>
  93. <script>
  94. import { commonMixin } from '@/utils/mixin'
  95. import { STable, VSelect } from '@/components'
  96. import { purchaseDetailBySn, purchaseDetailPrint, purchaseDetailExport, purchaseExportDetail } from '@/api/purchase'
  97. import { purchaseDetailList } from '@/api/purchaseDetail'
  98. import PrintPanel from '@/views/common/printPanel.vue'
  99. import { hdPrint, downloadExcel } from '@/libs/JGPrint'
  100. export default {
  101. name: 'PurchaseDetail',
  102. components: { STable, VSelect, PrintPanel },
  103. mixins: [commonMixin],
  104. props: {
  105. outBizSn: { // 有值则为弹框,无值则为页面
  106. type: [Number, String],
  107. default: ''
  108. }
  109. },
  110. data () {
  111. return {
  112. spinning: false,
  113. isShowBisiceInfo: false,
  114. // 加载数据方法 必须为 Promise 对象
  115. loadData: parameter => {
  116. this.disabled = true
  117. return purchaseDetailList(Object.assign(parameter, { purchaseBillSn: this.outBizSn || this.$route.params.sn, orderBy: 'product_type.FIRST_CHAR,dealer_product.CODE' })).then(res => {
  118. let data
  119. if (res.status == 200) {
  120. data = res.data
  121. const no = (data.pageNo - 1) * data.pageSize
  122. for (var i = 0; i < data.list.length; i++) {
  123. data.list[i].no = no + i + 1
  124. }
  125. this.localDataSource = data.list
  126. this.disabled = false
  127. }
  128. return data
  129. })
  130. },
  131. detail: null, // 详情数据
  132. localDataSource: [],
  133. printerType: 'NEEDLE' // 打印机类型
  134. }
  135. },
  136. computed: {
  137. columns () {
  138. let _this=this
  139. const arr = [
  140. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  141. { title: '产品编码', dataIndex: 'dealerProductEntity.code', width: '16%', align: 'center', customRender: function (text) { return text || '--' } },
  142. { title: '产品名称', dataIndex: 'dealerProductEntity.name', width: '16%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  143. { title: '原厂编码', dataIndex: 'dealerProductEntity.origCode', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  144. { title: '单位', dataIndex: 'dealerProductEntity.unit', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  145. // { title: '采购单价', dataIndex: 'discountedPrice', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  146. // { title: '采购金额', dataIndex: 'discountedAmount', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  147. { title: '采购数量', dataIndex: 'qty', width: '7%', align: 'center', scopedSlots: { customRender: 'origqty' } },
  148. // { title: '审核订单金额', dataIndex: 'pushedAmount', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  149. { title: '审核订单数量', dataIndex: 'pushedQty', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  150. { title: '已取消数量', dataIndex: 'cancelQty', width: '7%', align: 'center', customRender: function (text) { return text || '--' } }
  151. ]
  152. if (this.$hasPermissions('M_ShowAllCost')) {
  153. arr.splice(5, 0, { title: '采购单价', dataIndex: 'discountedPrice', width: '7%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text,2) : '--') } })
  154. arr.splice(6, 0, { title: '采购金额', dataIndex: 'discountedAmount', width: '7%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text,2) : '--') } })
  155. arr.splice(8, 0, { title: '审核订单金额', dataIndex: 'pushedAmount', width: '8%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text,2) : '--') } })
  156. }
  157. return arr
  158. }
  159. },
  160. methods: {
  161. // 返回列表
  162. handleBack () {
  163. if (this.$route.query.pageType) {
  164. this.$router.push({ name: this.$route.query.pageType })
  165. } else {
  166. this.$router.push({ name: 'purchaseOrderNewList' })
  167. }
  168. },
  169. // 详情
  170. getDetail () {
  171. purchaseDetailBySn({ sn: this.outBizSn || this.$route.params.sn }).then(res => {
  172. if (res.status == 200) {
  173. this.detail = res.data
  174. } else {
  175. this.detail = null
  176. }
  177. })
  178. },
  179. // 打印预览/快捷打印
  180. handlePrint (type, printerType) {
  181. const _this = this
  182. _this.spinning = true
  183. let url = purchaseDetailPrint
  184. let params = { sn: this.outBizSn || this.$route.params.sn, type: printerType }
  185. if (type == 'export') { // 导出
  186. url = purchaseDetailExport
  187. params = { sn: this.outBizSn || this.$route.params.sn }
  188. }
  189. // 打印或导出
  190. hdPrint(printerType, type, url, params, '采购单', function () {
  191. _this.spinning = false
  192. })
  193. },
  194. // 导出产品
  195. handleExportProduct () {
  196. const _this = this
  197. _this.spinning = true
  198. purchaseExportDetail({ sn: this.outBizSn || this.$route.params.sn }).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. downloadExcel(res, '采购产品')
  212. }
  213. })
  214. }
  215. },
  216. mounted () {
  217. if (!this.$store.state.app.isNewTab || this.outBizSn) { // 页签刷新时调用
  218. this.$refs.table.refresh(true)
  219. this.getDetail()
  220. }
  221. },
  222. activated () {
  223. console.log(this.$store.state.app.isNewTab, !this.$store.state.app.isNewSubTab)
  224. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  225. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  226. this.$refs.table.refresh(true)
  227. this.getDetail()
  228. }
  229. },
  230. beforeRouteEnter (to, from, next) {
  231. next(vm => {})
  232. }
  233. }
  234. </script>
  235. <style lang="less">
  236. .purchaseOrderDetail-wrap{
  237. .billno{
  238. margin: 0 10px 0 0;
  239. font-size: 16px;
  240. font-weight: 600;
  241. display: inline-block;
  242. vertical-align: middle;
  243. color: #333;
  244. }
  245. .purchaseOrderDetail-cont{
  246. margin-bottom: 10px;
  247. .timeline-box{
  248. margin-top: 30px;
  249. .auxiliary-txt{
  250. color: #808695;
  251. }
  252. }
  253. }
  254. .alert-message{
  255. margin-bottom: 10px;
  256. strong{
  257. color: #f12929;
  258. }
  259. }
  260. }
  261. </style>