detail.vue 13 KB

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