detail.vue 11 KB

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