detail.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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. </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.salesReturnNo || '--' }}</a-descriptions-item>
  29. <a-descriptions-item label="业务状态">{{ detailData&&detailData.stateDictValue || '--' }}</a-descriptions-item>
  30. <a-descriptions-item label="是否抓单">{{ detailData&&detailData.grabFlag==1?'抓单':'不抓单' }}</a-descriptions-item>
  31. <a-descriptions-item label="备注">{{ detailData&&detailData.remarks || '--' }}</a-descriptions-item>
  32. </a-descriptions>
  33. </a-collapse-panel>
  34. </a-collapse>
  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. // 表头
  88. columns: [
  89. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  90. { title: '产品编码', dataIndex: 'productCode', width: '13%', align: 'center', customRender: function (text) { return text || '--' } },
  91. { title: '产品名称', dataIndex: 'productName', width: '13%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  92. { title: '原厂编码', dataIndex: 'productOrigCode', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
  93. { title: '售价', dataIndex: 'price', width: '5%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  94. { title: '折后售价', dataIndex: 'discountedPrice', width: '7%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  95. { title: '退货数量', dataIndex: 'qty', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  96. { title: '废品数量', dataIndex: 'celQty', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  97. { title: '入库数量', dataIndex: 'rkqty', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  98. { title: '退货金额小计', dataIndex: 'saleReturnSubtotal', width: '8%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  99. { title: '折扣金额', dataIndex: 'discountAmount', width: '7%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  100. { title: '折后退货金额小计', dataIndex: 'discountedAmount', width: '10%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } }
  101. ],
  102. // 加载数据方法 必须为 Promise 对象
  103. loadData: parameter => {
  104. this.disabled = true
  105. const params = Object.assign(parameter, { salesReturnBillSn: this.outBizSn || this.$route.params.sn })
  106. this.getQueryCount(params)
  107. return salesReturnDetailList(params).then(res => {
  108. let data
  109. if (res.status == 200) {
  110. data = res.data
  111. const no = (data.pageNo - 1) * data.pageSize
  112. for (var i = 0; i < data.list.length; i++) {
  113. data.list[i].no = no + i + 1
  114. const productCode = (data.list[i].productEntity && data.list[i].productEntity.code) || (data.list[i].dealerProductEntity && data.list[i].dealerProductEntity.code)
  115. const productName = (data.list[i].productEntity && data.list[i].productEntity.name) || (data.list[i].dealerProductEntity && data.list[i].dealerProductEntity.name)
  116. const productOrigCode = (data.list[i].productEntity && data.list[i].productEntity.origCode) || (data.list[i].dealerProductEntity && data.list[i].dealerProductEntity.origCode)
  117. data.list[i].productCode = productCode || '--'
  118. data.list[i].productName = productName || '--'
  119. data.list[i].productOrigCode = productOrigCode || '--'
  120. // 退货数量和入库数量取值同一个字段,因表格使用统一字段会报错,因此重新定义
  121. data.list[i].rkqty = data.list[i].qty || 0
  122. // 折后退货金额小计 由于数据库内小数位数为4位,页面则需显示2位。因此会做小数运算精度处理
  123. data.list[i].saleReturnSubtotal = getOperationalPrecision(data.list[i].price, data.list[i].qty)
  124. }
  125. this.localDataSource = data.list
  126. this.disabled = false
  127. }
  128. return data
  129. })
  130. },
  131. localDataSource: [],
  132. detailData: null // 详情数据
  133. }
  134. },
  135. methods: {
  136. // 返回
  137. handleBack () {
  138. this.$router.push({ path: '/salesManagement/salesReturn/list' })
  139. },
  140. // 明细统计
  141. getQueryCount (params) {
  142. salesReturnQueryCount(params).then(res => {
  143. this.countData = res.data || null
  144. })
  145. },
  146. // 详情
  147. getDetail () {
  148. salesReturnDetail({ sn: this.outBizSn || this.$route.params.sn }).then(res => {
  149. if (res.status == 200) {
  150. this.detailData = res.data
  151. if (res.data.grabFlag == '1') {
  152. this.columns.splice(1, 0, { title: '销售单号', dataIndex: 'salesBillNo', width: '10%', align: 'center', customRender: function (text) { return text || '--' } })
  153. }
  154. } else {
  155. this.detailData = null
  156. }
  157. })
  158. },
  159. // 打印预览/快捷打印
  160. handlePrint (type, printerType) {
  161. const _this = this
  162. _this.spinning = true
  163. let url = salesReturnDetailPrint
  164. const params = { sn: this.outBizSn || this.$route.params.sn }
  165. if (type == 'export') { // 导出
  166. url = salesDetailExport
  167. }
  168. // 打印或导出
  169. hdPrint(printerType, type, url, params, '销售退货', function () {
  170. _this.spinning = false
  171. })
  172. }
  173. },
  174. mounted () {
  175. if (!this.$store.state.app.isNewTab || this.outBizSn) { // 页签刷新时调用
  176. this.$refs.table.refresh(true)
  177. this.getDetail()
  178. }
  179. },
  180. activated () {
  181. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  182. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  183. this.$refs.table.refresh(true)
  184. this.getDetail()
  185. }
  186. },
  187. beforeRouteEnter (to, from, next) {
  188. next(vm => {})
  189. }
  190. }
  191. </script>
  192. <style lang="less">
  193. .salesReturnDetail-wrap{
  194. .salesReturnDetail-cont{
  195. margin-bottom: 10px;
  196. }
  197. }
  198. </style>