detail.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  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. <span v-if="$route.params.type!='stockOut'">
  65. 本次下推市级价金额:<strong>{{ detailData&&(detailData.totalCityAmount || detailData.totalCityAmount==0) ? detailData.totalCityAmount : '--' }}</strong>;
  66. </span>
  67. </div>
  68. </a-alert>
  69. <!-- 列表 -->
  70. <s-table
  71. class="sTable"
  72. ref="table"
  73. size="small"
  74. :rowKey="(record) => record.id"
  75. :columns="($route.params.type=='stockOut' || outBizSubSn) ? outColumns : columns"
  76. :data="loadData"
  77. :scroll="{ y: 500 }"
  78. :defaultLoadData="false"
  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. <!-- 导出Excel -->
  93. <export-excel-modal :openModal="openExcelModal" :itemData="detailData" @ok="handleExcelOk" @close="openExcelModal=false" />
  94. <!-- 打印 -->
  95. <div id="print"></div>
  96. </div>
  97. </template>
  98. <script>
  99. import { STable, VSelect } from '@/components'
  100. import chooseTypeModal from './chooseTypeModal.vue'
  101. import exportExcelModal from './exportExcelModal.vue'
  102. import { hdExportExcel } from '@/libs/exportExcel'
  103. import { dispatchDetaillList, dispatchFindBySn, dispatchDetailPrint, dispatchDetailExcel } from '@/api/dispatch'
  104. export default {
  105. name: 'SalesDetail',
  106. components: { STable, VSelect, chooseTypeModal, exportExcelModal },
  107. props: {
  108. outBizSubSn: { // 有值则为弹框,无值则为页面
  109. type: [Number, String],
  110. default: ''
  111. }
  112. },
  113. data () {
  114. return {
  115. disabled: false,
  116. spinning: false,
  117. // 表头
  118. columns: [
  119. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  120. { title: '产品编码', dataIndex: 'productCode', width: '12%', scopedSlots: { customRender: 'productCode' }, align: 'center' },
  121. { title: '产品名称', dataIndex: 'productName', width: '14%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  122. { title: '原厂编码', dataIndex: 'productOrigCode', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
  123. { title: '单位', dataIndex: 'productOrigUnit', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  124. { title: '销售价格', dataIndex: 'price', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  125. { title: '市级销售价格', dataIndex: 'cityPrice', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  126. { title: '销售数量', dataIndex: 'salesQty', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  127. { title: '本次下推数', dataIndex: 'qty', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  128. { title: '本次下推金额', dataIndex: 'totalAmount', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  129. ],
  130. outColumns: [
  131. { title: '序号', dataIndex: 'no', width: '6%', align: 'center' },
  132. { title: '产品编码', dataIndex: 'productCode', width: '25%', scopedSlots: { customRender: 'productCode' }, align: 'center' },
  133. { title: '产品名称', dataIndex: 'productName', width: '33%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  134. { title: '原厂编码', dataIndex: 'productOrigCode', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
  135. { title: '单位', dataIndex: 'productOrigUnit', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  136. { title: '本次出库数', dataIndex: 'qty', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  137. ],
  138. // 加载数据方法 必须为 Promise 对象
  139. loadData: parameter => {
  140. this.disabled = true
  141. return dispatchDetaillList(Object.assign(parameter, { dispatchBillSn: this.outBizSubSn || this.$route.params.sn })).then(res => {
  142. const data = res.data
  143. const no = (data.pageNo - 1) * data.pageSize
  144. for (var i = 0; i < data.list.length; i++) {
  145. data.list[i].no = no + i + 1
  146. const productCode = (data.list[i].productEntity && data.list[i].productEntity.code) || (data.list[i].dealerProductEntity && data.list[i].dealerProductEntity.code)
  147. const productName = (data.list[i].productEntity && data.list[i].productEntity.name) || (data.list[i].dealerProductEntity && data.list[i].dealerProductEntity.name)
  148. const productOrigCode = (data.list[i].productEntity && data.list[i].productEntity.origCode) || (data.list[i].dealerProductEntity && data.list[i].dealerProductEntity.origCode)
  149. const productOrigUnit = (data.list[i].productEntity && data.list[i].productEntity.unit) || (data.list[i].dealerProductEntity && data.list[i].dealerProductEntity.unit)
  150. data.list[i].productCode = productCode || '--'
  151. data.list[i].productName = productName || '--'
  152. data.list[i].productOrigCode = productOrigCode == ' ' ? '--' : productOrigCode
  153. data.list[i].productOrigUnit = productOrigUnit || '--'
  154. }
  155. this.localDataSource = data.list
  156. this.disabled = false
  157. return data
  158. })
  159. },
  160. detailData: null, // 详情数据
  161. openModal: false,
  162. localDataSource: [],
  163. nowPrintType: '', // 当前打印类型
  164. openExcelModal: false
  165. }
  166. },
  167. methods: {
  168. // 返回
  169. handleBack () {
  170. if (this.$route.params.type == 'pushOrder') { // 下推
  171. this.$router.push({ path: '/salesManagement/pushOrderManagement/list', query: { closeLastOldTab: true } })
  172. } else if (this.$route.params.type == 'examineVerify') { // 备货审核
  173. this.$router.push({ path: '/salesManagement/examineVerify/list', query: { closeLastOldTab: true } })
  174. } else if (this.$route.params.type == 'financialCollection') { // 财务收款
  175. this.$router.push({ path: '/financialManagement/financialCollection/list', query: { closeLastOldTab: true } })
  176. }
  177. },
  178. // 详情
  179. getDetail () {
  180. dispatchFindBySn({ dispatchBillSn: this.outBizSubSn || this.$route.params.sn }).then(res => {
  181. if (res.status == 200) {
  182. this.detailData = res.data
  183. } else {
  184. this.detailData = null
  185. }
  186. })
  187. },
  188. // 导出Excel
  189. handleExcelOk (priceType) {
  190. const _this = this
  191. const params = {
  192. dispatchBillSn: this.outBizSubSn || this.$route.params.sn,
  193. printType: priceType
  194. }
  195. this.spinning = true
  196. hdExportExcel(dispatchDetailExcel, params, '下推产品', function () {
  197. _this.spinning = false
  198. })
  199. },
  200. // 分类选择
  201. handleOk (obj) {
  202. this.requestFun(obj)
  203. },
  204. // 打印预览/快捷打印
  205. handlePrint (type) {
  206. this.nowPrintType = type
  207. if (type == 'SALES_BILL' || type == 'DISPATCH_BILL') { // 销售打印/发货打印
  208. this.requestFun()
  209. } else if (type == 'SALES_BILL_TYPE' || type == 'DISPATCH_BILL_TYPE') { // 销售分类打印/发货分类打印
  210. this.openModal = true
  211. }
  212. },
  213. requestFun (obj) {
  214. const _this = this
  215. const params = {
  216. type: this.nowPrintType,
  217. dispatchBillSn: this.outBizSubSn || this.$route.params.sn
  218. }
  219. _this.spinning = true
  220. dispatchDetailPrint(Object.assign(params, obj || {})).then(res => {
  221. _this.spinning = false
  222. if (res.type == 'application/json') {
  223. var reader = new FileReader()
  224. reader.addEventListener('loadend', function () {
  225. const obj = JSON.parse(reader.result)
  226. _this.$notification.error({
  227. message: '提示',
  228. description: obj.message
  229. })
  230. })
  231. reader.readAsText(res)
  232. } else {
  233. this.print(res)
  234. }
  235. })
  236. },
  237. print (data) {
  238. this.spinLoading = false
  239. if (!data) {
  240. return
  241. }
  242. const url = window.URL.createObjectURL(new Blob([data], { type: 'application/pdf' }))
  243. document.getElementById('print').innerHTML = '<iframe id="printfpmd" name="printfpmd" src="' + url + '" hidden></iframe>'
  244. window.frames['printfpmd'].focus()
  245. window.frames['printfpmd'].print()
  246. }
  247. },
  248. mounted () {
  249. if (!this.$store.state.app.isNewTab || this.outBizSubSn) { // 页签刷新 或 为弹框时调用
  250. this.$refs.table.refresh(true)
  251. this.getDetail()
  252. }
  253. },
  254. activated () {
  255. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  256. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  257. this.$refs.table.refresh(true)
  258. this.getDetail()
  259. }
  260. },
  261. beforeRouteEnter (to, from, next) {
  262. next(vm => {})
  263. }
  264. }
  265. </script>
  266. <style lang="less">
  267. .salesDetail-wrap{
  268. .salesDetail-cont{
  269. margin-bottom: 10px;
  270. }
  271. .footer-cont{
  272. margin-top: 5px;
  273. text-align: center;
  274. }
  275. }
  276. </style>