detail.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <template>
  2. <div class="salesReturnDetail-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <a-page-header :ghost="false" :backIcon="false" class="salesReturnDetail-cont">
  5. <template slot="subTitle">
  6. <a href="javascript:;" @click="handleBack"><a-icon type="left"></a-icon> 返回列表</a>
  7. </template>
  8. <template slot="extra" v-if="$hasPermissions('B_salesReturnPrint')">
  9. <Print :disabled="localDataSource.length==0" @handlePrint="handlePrint"></Print>
  10. </template>
  11. </a-page-header>
  12. <!-- 基础信息 -->
  13. <a-card size="small" :bordered="false" class="salesReturnDetail-cont">
  14. <a-collapse :activeKey="['1']">
  15. <a-collapse-panel key="1" header="基础信息">
  16. <a-descriptions size="small" :column="3">
  17. <a-descriptions-item label="客户名称">{{ detailData&&detailData.buyerName || '--' }}</a-descriptions-item>
  18. <a-descriptions-item label="客户地址">
  19. <div v-if="detailData&&(detailData.provinceName || detailData.cityName || detailData.countyName || detailData.customerAddr)">
  20. {{ detailData&&detailData.provinceName || '' }}
  21. {{ detailData&&detailData.cityName || '' }}
  22. {{ detailData&&detailData.countyName || '' }}
  23. {{ detailData&&detailData.customerAddr || '' }}
  24. </div>
  25. <span v-else>--</span>
  26. </a-descriptions-item>
  27. <a-descriptions-item label="联系电话">{{ detailData&&detailData.contactTel || '--' }}</a-descriptions-item>
  28. <a-descriptions-item label="备注">{{ detailData&&detailData.remarks || '--' }}</a-descriptions-item>
  29. <a-descriptions-item label="退货单号">{{ detailData&&detailData.salesReturnNo || '--' }}</a-descriptions-item>
  30. <a-descriptions-item label="业务状态">{{ detailData&&detailData.stateDictValue || '--' }}</a-descriptions-item>
  31. </a-descriptions>
  32. </a-collapse-panel>
  33. </a-collapse>
  34. </a-card>
  35. <a-card size="small" :bordered="false" class="pages-wrap">
  36. <!-- alert -->
  37. <a-alert type="info" style="margin-bottom: 10px;" v-if="detailData">
  38. <div slot="message">
  39. 总款数:<strong>{{ countData&&(countData.totalCategory || countData.totalCategory==0) ? countData.totalCategory : '--' }}</strong>;
  40. 总数量:<strong>{{ countData&&(countData.totalQty || countData.totalQty==0) ? countData.totalQty : '--' }}</strong>;
  41. 废品数量:<strong>{{ countData&&(countData.totalCelQty || countData.totalCelQty==0) ? countData.totalCelQty : '--' }}</strong>;<br/>
  42. 退货总金额:<strong>{{ countData&&(countData.totalAmount || countData.totalAmount==0) ? countData.totalAmount : '--' }}</strong>;
  43. 折扣金额:<strong>{{ countData&&(countData.discountAmount || countData.discountAmount==0) ? countData.discountAmount : '--' }}</strong>;
  44. 折扣:<strong>{{ countData&&(countData.discountRate || countData.discountRate==0) ? countData.discountRate+'%' : '--' }}</strong>;
  45. 折后金额:<strong>{{ countData&&(countData.discountedAmount || countData.discountedAmount==0) ? countData.discountedAmount : '--' }}</strong>;
  46. </div>
  47. </a-alert>
  48. <!-- 列表 -->
  49. <s-table
  50. class="sTable"
  51. ref="table"
  52. size="small"
  53. :rowKey="(record) => record.id"
  54. :columns="columns"
  55. :data="loadData"
  56. :defaultLoadData="false"
  57. bordered>
  58. </s-table>
  59. </a-card>
  60. </a-spin>
  61. </div>
  62. </template>
  63. <script>
  64. import { getOperationalPrecision } from '@/libs/tools.js'
  65. import { STable, VSelect } from '@/components'
  66. import { salesReturnDetail, salesReturnQueryCount, salesReturnDetailList, salesReturnDetailPrint, salesDetailExport } from '@/api/salesReturn'
  67. import Print from '@/views/common/print.vue'
  68. import { hdPrint } from '@/libs/JGPrint'
  69. export default {
  70. name: 'SalesReturnDetail',
  71. components: { STable, VSelect, Print },
  72. data () {
  73. return {
  74. spinning: false,
  75. disabled: false,
  76. countData: null,
  77. // 表头
  78. columns: [
  79. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  80. { title: '产品编码', dataIndex: 'productCode', width: '13%', align: 'center', customRender: function (text) { return text || '--' } },
  81. { title: '产品名称', dataIndex: 'productName', width: '13%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  82. { title: '原厂编码', dataIndex: 'productOrigCode', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
  83. { title: '售价', dataIndex: 'price', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  84. { title: '折后售价', dataIndex: 'discountedPrice', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  85. { title: '退货数量', dataIndex: 'qty', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  86. { title: '废品数量', dataIndex: 'celQty', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  87. { title: '入库数量', dataIndex: 'rkqty', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  88. { title: '退货金额小计', dataIndex: 'saleReturnSubtotal', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  89. { title: '折扣金额', dataIndex: 'discountAmount', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  90. { title: '折后退货金额小计', dataIndex: 'discountedAmount', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  91. ],
  92. // 加载数据方法 必须为 Promise 对象
  93. loadData: parameter => {
  94. this.disabled = true
  95. const params = Object.assign(parameter, { salesReturnBillSn: this.$route.params.sn })
  96. this.getQueryCount(params)
  97. return salesReturnDetailList(params).then(res => {
  98. const data = res.data
  99. const no = (data.pageNo - 1) * data.pageSize
  100. for (var i = 0; i < data.list.length; i++) {
  101. data.list[i].no = no + i + 1
  102. const productCode = (data.list[i].productEntity && data.list[i].productEntity.code) || (data.list[i].dealerProductEntity && data.list[i].dealerProductEntity.code)
  103. const productName = (data.list[i].productEntity && data.list[i].productEntity.name) || (data.list[i].dealerProductEntity && data.list[i].dealerProductEntity.name)
  104. const productOrigCode = (data.list[i].productEntity && data.list[i].productEntity.origCode) || (data.list[i].dealerProductEntity && data.list[i].dealerProductEntity.origCode)
  105. data.list[i].productCode = productCode || '--'
  106. data.list[i].productName = productName || '--'
  107. data.list[i].productOrigCode = productOrigCode || '--'
  108. // 退货数量和入库数量取值同一个字段,因表格使用统一字段会报错,因此重新定义
  109. data.list[i].rkqty = data.list[i].qty || 0
  110. // 折后退货金额小计 由于数据库内小数位数为4位,页面则需显示2位。因此会做小数运算精度处理
  111. data.list[i].saleReturnSubtotal = getOperationalPrecision(data.list[i].price, data.list[i].qty)
  112. }
  113. this.localDataSource = data.list
  114. this.disabled = false
  115. return data
  116. })
  117. },
  118. localDataSource: [],
  119. detailData: null // 详情数据
  120. }
  121. },
  122. methods: {
  123. // 返回
  124. handleBack () {
  125. this.$router.push({ path: '/salesManagement/salesReturn/list', query: { closeLastOldTab: true } })
  126. },
  127. // 明细统计
  128. getQueryCount (params) {
  129. salesReturnQueryCount(params).then(res => {
  130. this.countData = res.data || null
  131. })
  132. },
  133. // 详情
  134. getDetail () {
  135. salesReturnDetail({ sn: this.$route.params.sn }).then(res => {
  136. if (res.status == 200) {
  137. this.detailData = res.data
  138. } else {
  139. this.detailData = null
  140. }
  141. })
  142. },
  143. // 打印预览/快捷打印
  144. handlePrint (type, printerType) {
  145. const _this = this
  146. _this.spinning = true
  147. let url = salesReturnDetailPrint
  148. const params = { sn: this.$route.params.sn }
  149. if (type == 'export') { // 导出
  150. url = salesDetailExport
  151. }
  152. // 打印或导出
  153. hdPrint(printerType, type, url, params, '销售退货', function () {
  154. _this.spinning = false
  155. })
  156. }
  157. },
  158. mounted () {
  159. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  160. this.$refs.table.refresh(true)
  161. this.getDetail()
  162. }
  163. },
  164. activated () {
  165. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  166. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  167. this.$refs.table.refresh(true)
  168. this.getDetail()
  169. }
  170. },
  171. beforeRouteEnter (to, from, next) {
  172. next(vm => {})
  173. }
  174. }
  175. </script>
  176. <style lang="less">
  177. .salesReturnDetail-wrap{
  178. .salesReturnDetail-cont{
  179. margin-bottom: 10px;
  180. }
  181. }
  182. </style>