detail.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <template>
  2. <div class="purchaseReturnDetail-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <a-page-header :ghost="false" :backIcon="false" class="purchaseReturnDetail-cont" :style="{ padding: !outBizSn ? '16px 24px' : '0px 24px' }" >
  5. <!-- 自定义的二级文字标题 -->
  6. <template slot="subTitle" v-if="!outBizSn">
  7. <a id="purchaseReturnDetail-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
  8. <a-button
  9. v-if="isEdit"
  10. type="primary"
  11. size="small"
  12. style="background-color: #1890ff;margin-left: 20px;border: #1890ff;"
  13. id="purchaseReturnDetail-edit-btn"
  14. @click.stop="handleEdit">编辑</a-button>
  15. </template>
  16. <!-- 操作区,位于 title 行的行尾 -->
  17. <template slot="extra" v-if="$hasPermissions('B_purchaseReturnPrint')">
  18. <Print :disabled="dataSource.length==0" @handlePrint="handlePrint"></Print>
  19. </template>
  20. </a-page-header>
  21. <!-- 基础信息 -->
  22. <a-card size="small" :bordered="false" class="purchaseReturnDetail-cont">
  23. <a-collapse :activeKey="['1']">
  24. <a-collapse-panel key="1" header="基础信息">
  25. <a-descriptions :column="3">
  26. <a-descriptions-item label="客户名称">{{ basicInfoData&&basicInfoData.returnTargetName || '--' }}</a-descriptions-item>
  27. <a-descriptions-item label="采退单号">{{ basicInfoData&&basicInfoData.purchaseReturnNo || '--' }}</a-descriptions-item>
  28. <a-descriptions-item label="创建时间">{{ basicInfoData&&basicInfoData.createDate || '--' }}</a-descriptions-item>
  29. <a-descriptions-item label="退货数量">{{ basicInfoData&&(basicInfoData.totalQty || basicInfoData.totalQty==0) ? basicInfoData.totalQty : '--' }}</a-descriptions-item>
  30. <a-descriptions-item label="坏件数量">{{ basicInfoData&&(basicInfoData.totalBadQty || basicInfoData.totalBadQty == 0) ? basicInfoData.totalBadQty : '--' }}</a-descriptions-item>
  31. <a-descriptions-item label="返库数量">{{ basicInfoData&&(basicInfoData.totalBackStockQty || basicInfoData.totalBackStockQty == 0) ? basicInfoData.totalBackStockQty : '--' }}</a-descriptions-item>
  32. <a-descriptions-item label="退货金额">{{ basicInfoData&&(basicInfoData.totalAmount || basicInfoData.totalAmount == 0) ? basicInfoData.totalAmount : '--' }}</a-descriptions-item>
  33. </a-descriptions>
  34. </a-collapse-panel>
  35. </a-collapse>
  36. </a-card>
  37. <!-- 产品详情 -->
  38. <a-card size="small" :bordered="false" class="purchaseReturnDetail-cont">
  39. <a-collapse :activeKey="['1']">
  40. <a-collapse-panel key="1" header="产品详情">
  41. <!-- 列表 -->
  42. <s-table
  43. class="sTable"
  44. ref="table"
  45. size="small"
  46. :rowKey="(record) => record.id"
  47. :columns="columns"
  48. :data="loadData"
  49. :defaultLoadData="false"
  50. bordered>
  51. </s-table>
  52. </a-collapse-panel>
  53. </a-collapse>
  54. </a-card>
  55. </a-spin>
  56. </div>
  57. </template>
  58. <script>
  59. import { STable, VSelect } from '@/components'
  60. import Print from '@/views/common/print.vue'
  61. import { hdPrint } from '@/libs/JGPrint'
  62. import { getOperationalPrecision } from '@/libs/tools.js'
  63. import { purchaseReturnDetailSn, purchaseReturnDetailList, purchaseReturnDetailPrint, purchaseReturnDetailExport } from '@/api/purchaseReturn'
  64. export default {
  65. components: { STable, VSelect, Print },
  66. props: {
  67. outBizSn: { // 有值则为弹框,无值则为页面
  68. type: [Number, String],
  69. default: ''
  70. }
  71. },
  72. data () {
  73. return {
  74. spinning: false,
  75. // 表头
  76. columns: [
  77. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  78. { title: '采购单号', dataIndex: 'purchaseBillNo', width: '17%', align: 'center', customRender: function (text) { return text || '--' } },
  79. { title: '产品编码', dataIndex: 'dealerProductEntity.code', width: '14%', align: 'center', customRender: function (text) { return text || '--' } },
  80. { title: '产品名称', dataIndex: 'dealerProductEntity.name', width: '14%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  81. { title: '售价', dataIndex: 'cost', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  82. { title: '退货数量', dataIndex: 'qty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  83. { title: '坏件数量', dataIndex: 'badQty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  84. { title: '返库数量', dataIndex: 'backStockQty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  85. { title: '单位', dataIndex: 'dealerProductEntity.unit', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  86. { title: '退货金额小计', dataIndex: 'purchaseReturnAmount', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  87. { title: '退货原因', dataIndex: 'remarks', width: '12%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true }
  88. ],
  89. dataSource: [],
  90. // 加载数据方法 必须为 Promise 对象
  91. loadData: parameter => {
  92. this.disabled = true
  93. return purchaseReturnDetailList(Object.assign(parameter, { purchaseReturnSn: this.outBizSn || this.$route.params.sn })).then(res => {
  94. let data
  95. if (res.status == 200) {
  96. data = res.data
  97. const no = (data.pageNo - 1) * data.pageSize
  98. for (var i = 0; i < data.list.length; i++) {
  99. data.list[i].no = no + i + 1
  100. // 采购金额 由于数据库内小数位数为4位,页面则需显示2位。因此会做小数运算精度处理
  101. data.list[i].purchaseReturnAmount = getOperationalPrecision(data.list[i].cost, data.list[i].qty)
  102. }
  103. this.disabled = false
  104. this.dataSource = data.list
  105. }
  106. return data
  107. })
  108. },
  109. basicInfoData: null // 基本信息
  110. }
  111. },
  112. computed: {
  113. isEdit () {
  114. return ((this.basicInfoData && this.basicInfoData.state == 'WAIT_SUBMIT') || (this.basicInfoData && this.basicInfoData.state == 'AUDIT_REJECT')) && this.$hasPermissions('B_purchaseReturnEdit')
  115. }
  116. },
  117. methods: {
  118. // 打印预览/快捷打印
  119. handlePrint (type, printerType) {
  120. const _this = this
  121. _this.spinning = true
  122. let url = purchaseReturnDetailPrint
  123. const params = { sn: this.$route.params.sn }
  124. if (type == 'export') { // 导出
  125. url = purchaseReturnDetailExport
  126. }
  127. // 打印或导出
  128. hdPrint(printerType, type, url, params, '采购退货单', function () {
  129. _this.spinning = false
  130. })
  131. },
  132. // 返回列表
  133. handleBack () {
  134. this.$router.push({ path: '/purchasingManagement/purchaseReturn/list' })
  135. },
  136. // 基本信息
  137. getDetail () {
  138. purchaseReturnDetailSn({ sn: this.outBizSn || this.$route.params.sn }).then(res => {
  139. if (res.status == 200) {
  140. this.basicInfoData = res.data
  141. } else {
  142. this.basicInfoData = null
  143. }
  144. })
  145. },
  146. // 编辑
  147. handleEdit () {
  148. this.$router.push({ path: `/purchasingManagement/purchaseReturn/edit/${this.basicInfoData.id}/${this.basicInfoData.purchaseReturnSn}/${this.basicInfoData.returnTargetName}` })
  149. }
  150. },
  151. mounted () {
  152. if (!this.$store.state.app.isNewTab || this.outBizSn) { // 页签刷新 或 为弹框时调用
  153. this.$refs.table.refresh(true)
  154. this.getDetail()
  155. }
  156. },
  157. activated () {
  158. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  159. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  160. this.$refs.table.refresh(true)
  161. this.getDetail()
  162. }
  163. },
  164. beforeRouteEnter (to, from, next) {
  165. next(vm => {})
  166. }
  167. }
  168. </script>
  169. <style lang="less">
  170. .purchaseReturnDetail-cont{
  171. margin-bottom: 10px;
  172. .timeline-box{
  173. margin-top: 30px;
  174. .auxiliary-txt{
  175. color: #808695;
  176. }
  177. }
  178. }
  179. </style>