detail.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. <template>
  2. <div class="salesDetail-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <a-page-header :ghost="false" :backIcon="false" class="salesDetail-cont" :style="{ padding: !outBizSubSn ? '16px 24px' : '0px 24px' }">
  5. <template slot="subTitle" v-if="!outBizSubSn">
  6. <a href="javascript:;" @click="handleBack"><a-icon type="left"></a-icon> 返回列表</a>
  7. </template>
  8. <template slot="extra" v-if="$hasPermissions('B_dispatchPrint')">
  9. <a-button
  10. key="4"
  11. type="primary"
  12. class="button-error"
  13. id="salesDetail-xs-print-btn"
  14. :disabled="localDataSource.length==0"
  15. @click="handlePrint('SALES_BILL')">销售打印</a-button>
  16. <a-button
  17. key="3"
  18. type="primary"
  19. class="button-info"
  20. id="salesDetail-xsfl-print-btn"
  21. :disabled="localDataSource.length==0"
  22. @click="handlePrint('SALES_BILL_TYPE')">销售分类打印</a-button>
  23. <a-button
  24. key="2"
  25. type="primary"
  26. class="button-success"
  27. id="salesDetail-fhdy-print-btn"
  28. :disabled="localDataSource.length==0"
  29. @click="handlePrint('DISPATCH_BILL')">发货打印</a-button>
  30. <a-button
  31. key="1"
  32. type="primary"
  33. class="button-warning"
  34. id="salesDetail-fhfl-print-btn"
  35. :disabled="localDataSource.length==0"
  36. @click="handlePrint('DISPATCH_BILL_TYPE')">发货分类打印</a-button>
  37. </template>
  38. </a-page-header>
  39. <!-- 基础信息 -->
  40. <a-card size="small" :bordered="false" class="salesDetail-cont">
  41. <a-collapse :activeKey="['1']">
  42. <a-collapse-panel key="1" header="基础信息">
  43. <a-descriptions size="small" :column="3">
  44. <a-descriptions-item label="客户名称">{{ detailData&&detailData.buyerName || '--' }}</a-descriptions-item>
  45. <a-descriptions-item label="收货人" v-if="detailData&&detailData.salesBillExtEntity">{{ detailData&&detailData.salesBillExtEntity&&detailData.salesBillExtEntity.consigneeName || '--' }}</a-descriptions-item>
  46. <a-descriptions-item label="收款方式">{{ detailData&&detailData.settleStyleSnDictValue || '--' }}</a-descriptions-item>
  47. <a-descriptions-item label="收货地址" :span="3" v-if="detailData&&detailData.salesBillExtEntity">
  48. {{ detailData&&detailData.salesBillExtEntity&&detailData.salesBillExtEntity.shippingAddrProvinceName || '' }}
  49. {{ detailData&&detailData.salesBillExtEntity&&detailData.salesBillExtEntity.shippingAddrCityName || '' }}
  50. {{ detailData&&detailData.salesBillExtEntity&&detailData.salesBillExtEntity.shippingAddrCountyName || '' }}
  51. {{ detailData&&detailData.salesBillExtEntity&&detailData.salesBillExtEntity.shippingAddr || '' }}
  52. </a-descriptions-item>
  53. <a-descriptions-item label="收货电话" v-if="detailData&&detailData.salesBillExtEntity">{{ detailData&&detailData.salesBillExtEntity&&detailData.salesBillExtEntity.consigneeTel || '--' }}</a-descriptions-item>
  54. <a-descriptions-item label="备注">{{ detailData&&detailData.remarks || '--' }}</a-descriptions-item>
  55. <a-descriptions-item label="业务状态">{{ detailData&&detailData.billStatusDictValue || '--' }}</a-descriptions-item>
  56. </a-descriptions>
  57. </a-collapse-panel>
  58. </a-collapse>
  59. </a-card>
  60. <a-card size="small" :bordered="false" class="pages-wrap">
  61. <!-- alert -->
  62. <a-alert type="info" style="margin-bottom: 10px;" v-if="detailData!=null">
  63. <div slot="message">
  64. <span v-if="$route.params.type!='stockOut'">
  65. 总销售数量:<strong>{{ detailData&&(detailData.totalSalesQty || detailData.totalSalesQty==0) ? detailData.totalSalesQty : '--' }}</strong>;
  66. </span>
  67. 本次下推数量:<strong>{{ detailData&&(detailData.totalQty || detailData.totalQty==0) ? detailData.totalQty : '--' }}</strong>;
  68. </div>
  69. </a-alert>
  70. <!-- 列表 -->
  71. <s-table
  72. class="sTable"
  73. ref="table"
  74. size="small"
  75. :rowKey="(record) => record.id"
  76. :columns="($route.params.type=='stockOut' || outBizSubSn) ? outColumns : columns"
  77. :data="loadData"
  78. :scroll="{ x: 1070, y: 500 }"
  79. bordered>
  80. <!-- 产品编码 -->
  81. <template slot="productCode" slot-scope="text, record">
  82. <a-badge count="促" v-if="record.promotionFlag == 1">
  83. <div style="padding-right: 15px;">{{ text }}</div>
  84. </a-badge>
  85. <span v-else>{{ text }}</span>
  86. </template>
  87. </s-table>
  88. </a-card>
  89. </a-spin>
  90. <!-- 分类打印 -->
  91. <choose-type-modal :openModal="openModal" :outBizSubSn="outBizSubSn" @ok="handleOk" @close="openModal=false" />
  92. <!-- 打印 -->
  93. <div id="print"></div>
  94. </div>
  95. </template>
  96. <script>
  97. import { STable, VSelect } from '@/components'
  98. import chooseTypeModal from './chooseTypeModal.vue'
  99. import { dispatchDetaillList, dispatchFindBySn, dispatchDetailPrint } from '@/api/dispatch'
  100. export default {
  101. name: 'SalesDetail',
  102. components: { STable, VSelect, chooseTypeModal },
  103. props: {
  104. outBizSubSn: { // 有值则为弹框,无值则为页面
  105. type: [Number, String],
  106. default: ''
  107. }
  108. },
  109. data () {
  110. return {
  111. disabled: false,
  112. spinning: false,
  113. // 表头
  114. columns: [
  115. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  116. { title: '产品编码', dataIndex: 'productCode', width: 220, scopedSlots: { customRender: 'productCode' }, align: 'center' },
  117. { title: '产品名称', dataIndex: 'productName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  118. { title: '原厂编码', dataIndex: 'productOrigCode', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
  119. { title: '单位', dataIndex: 'productOrigUnit', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  120. { title: '销售数量', dataIndex: 'salesQty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  121. { title: '本次下推数', dataIndex: 'qty', width: 130, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  122. ],
  123. outColumns: [
  124. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  125. { title: '产品编码', dataIndex: 'productCode', width: 220, scopedSlots: { customRender: 'productCode' }, align: 'center' },
  126. { title: '产品名称', dataIndex: 'productName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  127. { title: '原厂编码', dataIndex: 'productOrigCode', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
  128. { title: '单位', dataIndex: 'productOrigUnit', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  129. { title: '本次出库数', dataIndex: 'qty', width: 130, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  130. ],
  131. // 加载数据方法 必须为 Promise 对象
  132. loadData: parameter => {
  133. this.disabled = true
  134. return dispatchDetaillList(Object.assign(parameter, { dispatchBillSn: this.outBizSubSn || this.$route.params.sn })).then(res => {
  135. const data = res.data
  136. const no = (data.pageNo - 1) * data.pageSize
  137. for (var i = 0; i < data.list.length; i++) {
  138. data.list[i].no = no + i + 1
  139. const productCode = (data.list[i].productEntity && data.list[i].productEntity.code) || (data.list[i].dealerProductEntity && data.list[i].dealerProductEntity.code)
  140. const productName = (data.list[i].productEntity && data.list[i].productEntity.name) || (data.list[i].dealerProductEntity && data.list[i].dealerProductEntity.name)
  141. const productOrigCode = (data.list[i].productEntity && data.list[i].productEntity.origCode) || (data.list[i].dealerProductEntity && data.list[i].dealerProductEntity.origCode)
  142. const productOrigUnit = (data.list[i].productEntity && data.list[i].productEntity.unit) || (data.list[i].dealerProductEntity && data.list[i].dealerProductEntity.unit)
  143. data.list[i].productCode = productCode || '--'
  144. data.list[i].productName = productName || '--'
  145. data.list[i].productOrigCode = productOrigCode == ' ' ? '--' : productOrigCode
  146. data.list[i].productOrigUnit = productOrigUnit || '--'
  147. }
  148. this.localDataSource = data.list
  149. this.disabled = false
  150. return data
  151. })
  152. },
  153. detailData: null, // 详情数据
  154. openModal: false,
  155. localDataSource: [],
  156. nowPrintType: '' // 当前打印类型
  157. }
  158. },
  159. methods: {
  160. // 返回
  161. handleBack () {
  162. this.$router.push({ path: '/salesManagement/pushOrderManagement/list', query: { closeLastOldTab: true } })
  163. },
  164. // 详情
  165. getDetail () {
  166. dispatchFindBySn({ dispatchBillSn: this.outBizSubSn || this.$route.params.sn }).then(res => {
  167. if (res.status == 200) {
  168. this.detailData = res.data
  169. } else {
  170. this.detailData = null
  171. }
  172. })
  173. },
  174. // 分类选择
  175. handleOk (obj) {
  176. this.requestFun(obj)
  177. },
  178. // 打印预览/快捷打印
  179. handlePrint (type) {
  180. this.nowPrintType = type
  181. if (type == 'SALES_BILL' || type == 'DISPATCH_BILL') { // 销售打印/发货打印
  182. this.requestFun()
  183. } else if (type == 'SALES_BILL_TYPE' || type == 'DISPATCH_BILL_TYPE') { // 销售分类打印/发货分类打印
  184. this.openModal = true
  185. }
  186. },
  187. requestFun (obj) {
  188. const _this = this
  189. const params = {
  190. type: this.nowPrintType,
  191. dispatchBillSn: this.outBizSubSn || this.$route.params.sn
  192. }
  193. _this.spinning = true
  194. dispatchDetailPrint(Object.assign(params, obj || {})).then(res => {
  195. _this.spinning = false
  196. if (res.type == 'application/json') {
  197. var reader = new FileReader()
  198. reader.addEventListener('loadend', function () {
  199. const obj = JSON.parse(reader.result)
  200. _this.$notification.error({
  201. message: '提示',
  202. description: obj.message
  203. })
  204. })
  205. reader.readAsText(res)
  206. } else {
  207. this.print(res)
  208. }
  209. })
  210. },
  211. print (data) {
  212. this.spinLoading = false
  213. if (!data) {
  214. return
  215. }
  216. const url = window.URL.createObjectURL(new Blob([data], { type: 'application/pdf' }))
  217. document.getElementById('print').innerHTML = '<iframe id="printf" name="printf" src="' + url + '" hidden></iframe>'
  218. window.frames['printf'].focus()
  219. window.frames['printf'].print()
  220. }
  221. },
  222. mounted () {
  223. this.getDetail()
  224. }
  225. }
  226. </script>
  227. <style lang="less">
  228. .salesDetail-wrap{
  229. .salesDetail-cont{
  230. margin-bottom: 10px;
  231. }
  232. .footer-cont{
  233. margin-top: 5px;
  234. text-align: center;
  235. }
  236. }
  237. </style>