detail.vue 10 KB

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