detail.vue 13 KB

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