detail.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  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&&!bizSn">
  6. <a href="javascript:;" @click="handleBack"><a-icon type="left"></a-icon> 返回列表</a>
  7. </template>
  8. <template slot="extra">
  9. <a-button
  10. key="4"
  11. type="primary"
  12. class="button-info"
  13. id="salesDetail-fhdy-print-btn"
  14. :disabled="localDataSource.length==0"
  15. v-if="$hasPermissions('B_dispatchPrint')"
  16. @click="handlePrint('DISPATCH_BILL')">发货打印</a-button>
  17. <a-button
  18. key="3"
  19. type="default"
  20. class="button-info"
  21. id="salesDetail-fhfl-print-btn"
  22. :disabled="localDataSource.length==0"
  23. @click="handlePrint('DISPATCH_BILL_TYPE')">发货分类打印</a-button>
  24. <a-divider type="vertical" />
  25. <a-button
  26. key="2"
  27. type="primary"
  28. class="button-info"
  29. id="purchaseOrderDetail-export-btn"
  30. :disabled="localDataSource.length==0"
  31. v-if="$hasPermissions('B_dispatchExport')"
  32. @click="openExcelModal=true">导出Excel</a-button>
  33. <a-button
  34. key="1"
  35. type="default"
  36. class="button-info"
  37. id="salesDetail-fhfl-print-btn"
  38. :disabled="localDataSource.length==0"
  39. v-if="$hasPermissions('B_dispatchTypeExport')"
  40. @click="handleFlExport('DISPATCH_BILL_TYPE')">发货分类导出</a-button>
  41. </template>
  42. </a-page-header>
  43. <!-- 基础信息 -->
  44. <a-card size="small" :bordered="false" class="salesDetail-cont">
  45. <a-collapse :activeKey="['1']">
  46. <a-collapse-panel key="1" header="基础信息">
  47. <a-descriptions size="small" :column="3">
  48. <a-descriptions-item label="客户名称">{{ detailData&&detailData.buyerName || '--' }}</a-descriptions-item>
  49. <a-descriptions-item label="销售单号">{{ detailData&&detailData.salesBillNo || '--' }}</a-descriptions-item>
  50. <a-descriptions-item label="备货单号">{{ detailData&&detailData.dispatchBillNo || '--' }}</a-descriptions-item>
  51. <a-descriptions-item label="收货客户名称">{{ detailData&&detailData.receiverName || '--' }}</a-descriptions-item>
  52. <a-descriptions-item label="发货编号">{{ detailData&&detailData.sendNo || '--' }}</a-descriptions-item>
  53. <a-descriptions-item label="收款方式">{{ detailData&&detailData.settleStyleSnDictValue || '--' }}</a-descriptions-item>
  54. <a-descriptions-item label="收货人" v-if="detailData&&detailData.salesBillExtEntity">{{ detailData&&detailData.salesBillExtEntity&&detailData.salesBillExtEntity.consigneeName || '--' }}</a-descriptions-item>
  55. <a-descriptions-item label="收货电话" v-if="detailData&&detailData.salesBillExtEntity">{{ detailData&&detailData.salesBillExtEntity&&detailData.salesBillExtEntity.consigneeTel || '--' }}</a-descriptions-item>
  56. <a-descriptions-item label="收货地址" :span="2" v-if="detailData&&detailData.salesBillExtEntity">
  57. {{ detailData&&detailData.salesBillExtEntity&&detailData.salesBillExtEntity.shippingAddrProvinceName || '' }}
  58. {{ detailData&&detailData.salesBillExtEntity&&detailData.salesBillExtEntity.shippingAddrCityName || '' }}
  59. {{ detailData&&detailData.salesBillExtEntity&&detailData.salesBillExtEntity.shippingAddrCountyName || '' }}
  60. {{ detailData&&detailData.salesBillExtEntity&&detailData.salesBillExtEntity.shippingAddr || '' }}
  61. </a-descriptions-item>
  62. <a-descriptions-item label="业务状态">{{ detailData&&detailData.billStatusDictValue || '--' }}</a-descriptions-item>
  63. <a-descriptions-item label="备注">{{ detailData&&detailData.remarks || '--' }}</a-descriptions-item>
  64. </a-descriptions>
  65. </a-collapse-panel>
  66. </a-collapse>
  67. </a-card>
  68. <a-card size="small" :bordered="false" class="pages-wrap">
  69. <!-- alert -->
  70. <a-alert type="info" style="margin-bottom: 10px;" v-if="detailData!=null">
  71. <div slot="message">
  72. <span v-if="$route.params.type!='stockOut'">
  73. 总销售数量:<strong>{{ detailData&&(detailData.totalSalesQty || detailData.totalSalesQty==0) ? detailData.totalSalesQty : '--' }}</strong>;
  74. </span>
  75. 本次下推数量:<strong>{{ detailData&&(detailData.totalQty || detailData.totalQty==0) ? detailData.totalQty : '--' }}</strong>;
  76. <span v-if="$hasPermissions('B_isShowPrice')">本次下推金额:<strong>{{ detailData&&(detailData.totalAmount || detailData.totalAmount==0) ? detailData.totalAmount : '--' }}</strong>;</span>
  77. <span v-if="$route.params.type!='stockOut'">
  78. 本次下推市级价金额:<strong>{{ detailData&&(detailData.totalCityAmount || detailData.totalCityAmount==0) ? detailData.totalCityAmount : '--' }}</strong>;
  79. </span>
  80. </div>
  81. </a-alert>
  82. <!-- 列表 -->
  83. <s-table
  84. class="sTable"
  85. ref="table"
  86. size="small"
  87. :rowKey="(record) => record.id"
  88. :columns="($route.params.type=='stockOut' || outBizSubSn) ? outColumns : columns"
  89. :data="loadData"
  90. :scroll="{ y: 500 }"
  91. :defaultLoadData="false"
  92. bordered>
  93. <!-- 产品编码 -->
  94. <template slot="productCode" slot-scope="text, record">
  95. <a-badge count="促" v-if="record.promotionFlag == 1">
  96. <div style="padding-right: 15px;">{{ text }}</div>
  97. </a-badge>
  98. <span v-else>{{ text }}</span>
  99. </template>
  100. </s-table>
  101. </a-card>
  102. </a-spin>
  103. <!-- 发货分类打印 -->
  104. <sendTypeModal
  105. ref="typePrint"
  106. :hasNoPrint="hasNoPrint"
  107. :nowType="nowType"
  108. :openModal="openModal"
  109. @ok="handlePrintOk"
  110. @close="openModal=false" />
  111. <!-- 导出Excel -->
  112. <export-excel-modal :openModal="openExcelModal" :itemData="detailData" @ok="handleExcelOk" @close="openExcelModal=false" />
  113. <!-- 打印 -->
  114. <div id="print"></div>
  115. </div>
  116. </template>
  117. <script>
  118. import { commonMixin } from '@/utils/mixin'
  119. import { STable, VSelect } from '@/components'
  120. import sendTypeModal from './sendTypeModal.vue'
  121. import exportExcelModal from './exportExcelModal.vue'
  122. import { printFun, exportExcel } from '@/libs/JGPrint.js'
  123. import { dispatchDetaillList, dispatchFindBySn, dispatchDetailPrint, dispatchDetailExcel } from '@/api/dispatch'
  124. export default {
  125. name: 'PushOrderDetail',
  126. mixins: [commonMixin],
  127. components: { STable, VSelect, sendTypeModal, exportExcelModal },
  128. props: {
  129. outBizSubSn: { // 有值则为弹框,无值则为页面
  130. type: [Number, String],
  131. default: ''
  132. },
  133. bizSn: { // 有值则为弹框,无值则为页面
  134. type: [Number, String],
  135. default: ''
  136. }
  137. },
  138. data () {
  139. return {
  140. disabled: false,
  141. spinning: false,
  142. outColumns: [
  143. { title: '序号', dataIndex: 'no', width: '6%', align: 'center' },
  144. { title: '产品编码', dataIndex: 'productCode', width: '25%', scopedSlots: { customRender: 'productCode' }, align: 'center' },
  145. { title: '产品名称', dataIndex: 'productName', width: '33%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  146. { title: '原厂编码', dataIndex: 'productOrigCode', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
  147. { title: '单位', dataIndex: 'productOrigUnit', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  148. { title: '本次出库数', dataIndex: 'qty', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  149. ],
  150. // 加载数据方法 必须为 Promise 对象
  151. loadData: parameter => {
  152. this.disabled = true
  153. return dispatchDetaillList(Object.assign(parameter, { dispatchBillSn: this.outBizSubSn || this.bizSn || this.$route.params.sn })).then(res => {
  154. let data
  155. if (res.status == 200) {
  156. data = res.data
  157. const no = (data.pageNo - 1) * data.pageSize
  158. for (var i = 0; i < data.list.length; i++) {
  159. data.list[i].no = no + i + 1
  160. const productCode = (data.list[i].productEntity && data.list[i].productEntity.code) || (data.list[i].dealerProductEntity && data.list[i].dealerProductEntity.code)
  161. const productName = (data.list[i].productEntity && data.list[i].productEntity.name) || (data.list[i].dealerProductEntity && data.list[i].dealerProductEntity.name)
  162. const productOrigCode = (data.list[i].productEntity && data.list[i].productEntity.origCode) || (data.list[i].dealerProductEntity && data.list[i].dealerProductEntity.origCode)
  163. const productOrigUnit = (data.list[i].productEntity && data.list[i].productEntity.unit) || (data.list[i].dealerProductEntity && data.list[i].dealerProductEntity.unit)
  164. data.list[i].productCode = productCode || '--'
  165. data.list[i].productName = productName || '--'
  166. data.list[i].productOrigCode = productOrigCode == ' ' ? '--' : productOrigCode
  167. data.list[i].productOrigUnit = productOrigUnit || '--'
  168. }
  169. this.localDataSource = data.list
  170. this.disabled = false
  171. }
  172. return data
  173. })
  174. },
  175. detailData: null, // 详情数据
  176. openModal: false,
  177. localDataSource: [],
  178. nowPrintType: '', // 当前打印类型
  179. openExcelModal: false,
  180. fromRouter: null,
  181. nowType: 'print'
  182. }
  183. },
  184. computed: {
  185. hasNoPrint () {
  186. return this.detailData && (this.detailData.printStatus == 'UNABLE_PRINT' || this.detailData.printStatus == 'CANCEL_PRINT')
  187. },
  188. columns () {
  189. const arr = [
  190. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  191. { title: '产品编码', dataIndex: 'productCode', width: '19%', scopedSlots: { customRender: 'productCode' }, align: 'center' },
  192. { title: '产品名称', dataIndex: 'productName', width: '10%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  193. { title: '原厂编码', dataIndex: 'productOrigCode', width: '19%', align: 'center', customRender: function (text) { return text || '--' } },
  194. { title: '单位', dataIndex: 'productOrigUnit', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  195. // { title: '销售价格', dataIndex: 'price', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  196. // { title: '市级销售价格', dataIndex: 'cityPrice', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  197. { title: '销售数量', dataIndex: 'salesQty', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  198. { title: '本次下推数', dataIndex: 'qty', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  199. // { title: '本次下推金额', dataIndex: 'totalAmount', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  200. ]
  201. if (this.$hasPermissions('B_isShowPrice')) { // 售价权限
  202. arr.splice(5, 0, { title: '销售价格', dataIndex: 'price', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  203. arr.splice(6, 0, { title: '市级销售价格', dataIndex: 'cityPrice', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  204. arr.splice(9, 0, { title: '本次下推金额', dataIndex: 'totalAmount', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  205. }
  206. return arr
  207. }
  208. },
  209. methods: {
  210. // 返回
  211. handleBack () {
  212. this.$router.push({ name: 'pushOrderManagementList' })
  213. },
  214. // 详情
  215. getDetail () {
  216. dispatchFindBySn({ dispatchBillSn: this.outBizSubSn || this.bizSn || this.$route.params.sn }).then(res => {
  217. if (res.status == 200) {
  218. this.detailData = res.data
  219. } else {
  220. this.detailData = null
  221. }
  222. })
  223. },
  224. // 导出Excel
  225. handleExcelOk (priceType, data, fileName) {
  226. const _this = this
  227. const params = {
  228. dispatchBillSn: this.outBizSubSn || this.bizSn || this.$route.params.sn,
  229. printType: priceType,
  230. ...data
  231. }
  232. this.spinning = true
  233. exportExcel(dispatchDetailExcel, params, fileName, function () {
  234. _this.spinning = false
  235. })
  236. },
  237. // 发货分类导出
  238. handleFlExport () {
  239. this.openModal = true
  240. this.nowType = 'export'
  241. this.$refs.typePrint.setData(this.detailData, this.outBizSubSn || this.bizSn || this.$route.params.sn)
  242. },
  243. // 打印预览/快捷打印
  244. handlePrint (type) {
  245. this.nowPrintType = type
  246. if (type == 'DISPATCH_BILL') { // 发货打印
  247. const params = {
  248. dispatchBillSn: this.detailData.dispatchBillSn,
  249. dispatchBillNo: this.detailData.dispatchBillNo
  250. }
  251. this.handlePrintOk(params, '发货', 'preview')
  252. } else if (type == 'DISPATCH_BILL_TYPE') { // 发货分类打印
  253. this.openModal = true
  254. this.nowType = 'print'
  255. this.$refs.typePrint.setData(this.detailData, this.outBizSubSn || this.bizSn || this.$route.params.sn)
  256. }
  257. },
  258. // 发货分类打印,导出
  259. handlePrintOk (obj, taskName, type) {
  260. const _this = this
  261. const params = {
  262. type: this.nowPrintType,
  263. dispatchBillSn: this.outBizSubSn || this.bizSn || this.$route.params.sn
  264. }
  265. // 打印
  266. if (type != 'export') {
  267. _this.spinning = true
  268. // 货位编号
  269. if (obj.orderBy) {
  270. params.type = params.type + '_STACK_PLACE'
  271. }
  272. printFun(
  273. dispatchDetailPrint,
  274. Object.assign(params, obj || {}),
  275. type,
  276. taskName,
  277. (res) => {
  278. _this.$message.info(res.message)
  279. _this.spinning = false
  280. },
  281. {
  282. billType: 'DISPATCH',
  283. billSn: obj.dispatchBillSn,
  284. billNo: obj.dispatchBillNo,
  285. printType: taskName + '打印'
  286. }, this.hasNoPrint)
  287. } else {
  288. this.handleExcelOk('DISPATCH_BILL_TYPE', obj, taskName)
  289. }
  290. }
  291. },
  292. mounted () {
  293. if (!this.$store.state.app.isNewTab || this.outBizSubSn || this.bizSn) { // 页签刷新 或 为弹框时调用
  294. this.$refs.table.refresh(true)
  295. this.getDetail()
  296. }
  297. },
  298. activated () {
  299. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  300. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  301. this.$refs.table.refresh(true)
  302. this.getDetail()
  303. }
  304. },
  305. beforeRouteEnter (to, from, next) {
  306. next(vm => {
  307. vm.fromRouter = from
  308. })
  309. }
  310. }
  311. </script>
  312. <style lang="less">
  313. .salesDetail-wrap{
  314. .salesDetail-cont{
  315. margin-bottom: 10px;
  316. }
  317. .footer-cont{
  318. margin-top: 5px;
  319. text-align: center;
  320. }
  321. }
  322. </style>