detail.vue 15 KB

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