detail.vue 9.1 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. <a-radio-group key="3" v-model="printerType">
  10. <a-radio value="NEEDLE">针式</a-radio>
  11. <a-radio value="INK">喷墨</a-radio>
  12. </a-radio-group>
  13. <a-button key="2" id="salesReturnDetail-preview-btn" :disabled="localDataSource.length==0" @click="handlePrint('preview')">打印预览</a-button>
  14. <a-button key="1" type="primary" id="salesReturnDetail-print-btn" :disabled="localDataSource.length==0" @click="handlePrint('print')">快捷打印</a-button>
  15. </template>
  16. </a-page-header>
  17. <!-- 基础信息 -->
  18. <a-card size="small" :bordered="false" class="salesReturnDetail-cont">
  19. <a-collapse :activeKey="['1']">
  20. <a-collapse-panel key="1" header="基础信息">
  21. <a-descriptions size="small" :column="3" v-if="detailData">
  22. <a-descriptions-item label="客户名称">{{ detailData.buyerName || '--' }}</a-descriptions-item>
  23. <a-descriptions-item label="客户地址">{{ detailData.provinceName || '--' }}{{ detailData.cityName || '--' }}{{ detailData.countyName || '--' }}{{ detailData.customerAddr || '--' }}</a-descriptions-item>
  24. <a-descriptions-item label="联系电话">{{ detailData.contactTel || '--' }}</a-descriptions-item>
  25. <a-descriptions-item label="备注">{{ detailData.remarks || '--' }}</a-descriptions-item>
  26. <a-descriptions-item label="退货单号">{{ detailData.salesReturnNo || '--' }}</a-descriptions-item>
  27. <a-descriptions-item label="业务状态">{{ detailData.stateDictValue || '--' }}</a-descriptions-item>
  28. </a-descriptions>
  29. </a-collapse-panel>
  30. </a-collapse>
  31. </a-card>
  32. <a-card size="small" :bordered="false" class="pages-wrap">
  33. <!-- alert -->
  34. <a-alert type="info" style="margin-bottom: 15px;" v-if="detailData">
  35. <div slot="message">
  36. 总款数:<strong>{{ countData.totalCategory || 0 }}</strong>;总数量:<strong>{{ countData.totalQty || 0 }}</strong>;废品数量:<strong>{{ countData.totalCelQty || 0 }}</strong>;<br/>
  37. 退货总金额:<strong>{{ countData.totalAmount || 0 }}</strong>;折扣金额:<strong>{{ countData.discountAmount || 0 }}</strong>;折扣:<strong>{{ countData.discountRate || 0 }}%</strong>;折后金额:<strong>{{ countData.discountedAmount || 0 }}</strong>;
  38. </div>
  39. </a-alert>
  40. <!-- 列表 -->
  41. <s-table
  42. class="sTable"
  43. ref="table"
  44. size="default"
  45. :rowKey="(record) => record.id"
  46. :columns="columns"
  47. :data="loadData"
  48. :scroll="{ x: 1430 }"
  49. bordered>
  50. </s-table>
  51. </a-card>
  52. </a-spin>
  53. <!-- 打印 -->
  54. <div id="print"></div>
  55. </div>
  56. </template>
  57. <script>
  58. import { getOperationalPrecision } from '@/libs/tools.js'
  59. import { STable, VSelect } from '@/components'
  60. import { salesReturnDetail, salesReturnQueryCount, salesReturnDetailList, salesReturnDetailPrint } from '@/api/salesReturn'
  61. export default {
  62. name: 'SalesReturnDetail',
  63. components: { STable, VSelect },
  64. data () {
  65. return {
  66. spinning: false,
  67. disabled: false,
  68. countData: null,
  69. // 表头
  70. columns: [
  71. { title: '序号', dataIndex: 'no', width: 80, align: 'center', fixed: 'left' },
  72. { title: '产品编码', dataIndex: 'productCode', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
  73. { title: '产品名称', dataIndex: 'productName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  74. { title: '原厂编码', dataIndex: 'productOrigCode', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
  75. { title: '售价', dataIndex: 'price', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  76. { title: '折后售价', dataIndex: 'discountedPrice', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  77. { title: '退货数量', dataIndex: 'qty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  78. { title: '废品数量', dataIndex: 'celQty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  79. { title: '入库数量', dataIndex: 'rkqty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  80. { title: '退货金额小计', dataIndex: 'saleReturnSubtotal', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  81. { title: '折扣金额', dataIndex: 'discountAmount', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  82. { title: '折后退货金额小计', dataIndex: 'discountedAmount', width: 150, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  83. ],
  84. // 加载数据方法 必须为 Promise 对象
  85. loadData: parameter => {
  86. this.disabled = true
  87. const params = Object.assign(parameter, { salesReturnBillSn: this.$route.params.sn })
  88. this.getQueryCount(params)
  89. return salesReturnDetailList(params).then(res => {
  90. const data = res.data
  91. const no = (data.pageNo - 1) * data.pageSize
  92. for (var i = 0; i < data.list.length; i++) {
  93. data.list[i].no = no + i + 1
  94. const productCode = (data.list[i].productEntity && data.list[i].productEntity.code) || (data.list[i].dealerProductEntity && data.list[i].dealerProductEntity.code)
  95. const productName = (data.list[i].productEntity && data.list[i].productEntity.name) || (data.list[i].dealerProductEntity && data.list[i].dealerProductEntity.name)
  96. const productOrigCode = (data.list[i].productEntity && data.list[i].productEntity.origCode) || (data.list[i].dealerProductEntity && data.list[i].dealerProductEntity.origCode)
  97. data.list[i].productCode = productCode || '--'
  98. data.list[i].productName = productName || '--'
  99. data.list[i].productOrigCode = productOrigCode || '--'
  100. // 退货数量和入库数量取值同一个字段,因表格使用统一字段会报错,因此重新定义
  101. data.list[i].rkqty = data.list[i].qty || 0
  102. // 折后退货金额小计 由于数据库内小数位数为4位,页面则需显示2位。因此会做小数运算精度处理
  103. data.list[i].saleReturnSubtotal = getOperationalPrecision(data.list[i].price, data.list[i].qty)
  104. }
  105. this.localDataSource = data.list
  106. this.disabled = false
  107. return data
  108. })
  109. },
  110. localDataSource: [],
  111. detailData: null, // 详情数据
  112. printerType: 'NEEDLE' // 打印机类型
  113. }
  114. },
  115. methods: {
  116. // 返回
  117. handleBack () {
  118. this.$router.push({ name: 'salesReturnList' })
  119. },
  120. // 明细统计
  121. getQueryCount (params) {
  122. salesReturnQueryCount(params).then(res => {
  123. this.countData = res.data || null
  124. })
  125. },
  126. // 详情
  127. getDetail () {
  128. salesReturnDetail({ sn: this.$route.params.sn }).then(res => {
  129. if (res.status == 200) {
  130. this.detailData = res.data
  131. } else {
  132. this.detailData = null
  133. }
  134. })
  135. },
  136. // 打印预览/快捷打印
  137. handlePrint (type) {
  138. const _this = this
  139. _this.spinning = true
  140. salesReturnDetailPrint({ sn: this.$route.params.sn, type: this.printerType }).then(res => {
  141. _this.spinning = false
  142. if (res.type == 'application/json') {
  143. var reader = new FileReader()
  144. reader.addEventListener('loadend', function () {
  145. const obj = JSON.parse(reader.result)
  146. _this.$notification.error({
  147. message: '提示',
  148. description: obj.message
  149. })
  150. })
  151. reader.readAsText(res)
  152. } else {
  153. this.print(res, type)
  154. }
  155. })
  156. },
  157. print (data, type) {
  158. if (!data) {
  159. return
  160. }
  161. const url = window.URL.createObjectURL(new Blob([data], { type: 'application/pdf' }))
  162. document.getElementById('print').innerHTML = '<iframe id="printf" name="printf" src="' + url + '" hidden></iframe>'
  163. if (type == 'preview') { // 预览
  164. window.open(url)
  165. } else if (type == 'print') { // 打印
  166. window.frames['printf'].focus()
  167. window.frames['printf'].print()
  168. }
  169. }
  170. },
  171. mounted () {
  172. this.getDetail()
  173. }
  174. }
  175. </script>
  176. <style lang="less">
  177. .salesReturnDetail-wrap{
  178. .salesReturnDetail-cont{
  179. margin-bottom: 15px;
  180. }
  181. }
  182. </style>