detail.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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. let data
  99. if (res.status == 200) {
  100. data = res.data
  101. const no = (data.pageNo - 1) * data.pageSize
  102. for (var i = 0; i < data.list.length; i++) {
  103. data.list[i].no = no + i + 1
  104. const productCode = (data.list[i].productEntity && data.list[i].productEntity.code) || (data.list[i].dealerProductEntity && data.list[i].dealerProductEntity.code)
  105. const productName = (data.list[i].productEntity && data.list[i].productEntity.name) || (data.list[i].dealerProductEntity && data.list[i].dealerProductEntity.name)
  106. const productOrigCode = (data.list[i].productEntity && data.list[i].productEntity.origCode) || (data.list[i].dealerProductEntity && data.list[i].dealerProductEntity.origCode)
  107. data.list[i].productCode = productCode || '--'
  108. data.list[i].productName = productName || '--'
  109. data.list[i].productOrigCode = productOrigCode || '--'
  110. // 退货数量和入库数量取值同一个字段,因表格使用统一字段会报错,因此重新定义
  111. data.list[i].rkqty = data.list[i].qty || 0
  112. // 折后退货金额小计 由于数据库内小数位数为4位,页面则需显示2位。因此会做小数运算精度处理
  113. data.list[i].saleReturnSubtotal = getOperationalPrecision(data.list[i].price, data.list[i].qty)
  114. }
  115. this.localDataSource = data.list
  116. this.disabled = false
  117. }
  118. return data
  119. })
  120. },
  121. localDataSource: [],
  122. detailData: null // 详情数据
  123. }
  124. },
  125. methods: {
  126. // 返回
  127. handleBack () {
  128. this.$router.push({ path: '/salesManagement/salesReturn/list', query: { closeLastOldTab: true } })
  129. },
  130. // 明细统计
  131. getQueryCount (params) {
  132. salesReturnQueryCount(params).then(res => {
  133. this.countData = res.data || null
  134. })
  135. },
  136. // 详情
  137. getDetail () {
  138. salesReturnDetail({ sn: this.$route.params.sn }).then(res => {
  139. if (res.status == 200) {
  140. this.detailData = res.data
  141. } else {
  142. this.detailData = null
  143. }
  144. })
  145. },
  146. // 打印预览/快捷打印
  147. handlePrint (type, printerType) {
  148. const _this = this
  149. _this.spinning = true
  150. let url = salesReturnDetailPrint
  151. const params = { sn: this.$route.params.sn }
  152. if (type == 'export') { // 导出
  153. url = salesDetailExport
  154. }
  155. // 打印或导出
  156. hdPrint(printerType, type, url, params, '销售退货', function () {
  157. _this.spinning = false
  158. })
  159. }
  160. },
  161. mounted () {
  162. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  163. this.$refs.table.refresh(true)
  164. this.getDetail()
  165. }
  166. },
  167. activated () {
  168. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  169. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  170. this.$refs.table.refresh(true)
  171. this.getDetail()
  172. }
  173. },
  174. beforeRouteEnter (to, from, next) {
  175. next(vm => {})
  176. }
  177. }
  178. </script>
  179. <style lang="less">
  180. .salesReturnDetail-wrap{
  181. .salesReturnDetail-cont{
  182. margin-bottom: 10px;
  183. }
  184. }
  185. </style>