detailForOut.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. <template>
  2. <div class="pushOrder-forOut-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="primary"
  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="default"
  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_dispatchDetail_salesPrice')">本次下推金额:<strong>{{ detailData&&(detailData.totalAmount || detailData.totalAmount==0) ? toThousands(detailData.totalAmount) : '--' }}</strong>;</span>
  77. <span v-if="$route.params.type!='stockOut'&&$hasPermissions('B_dispatchDetail_cityPrice')">
  78. 本次下推市级价金额:<strong>{{ detailData&&(detailData.totalCityAmount || detailData.totalCityAmount==0) ? toThousands(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.no"
  88. rowKeyName="no"
  89. :columns="($route.params.type=='stockOut' || outBizSubSn) ? outColumns : columns"
  90. :data="loadData"
  91. :scroll="{ y: 500 }"
  92. :defaultLoadData="false"
  93. bordered>
  94. <!-- 产品编码 -->
  95. <template slot="productCode" slot-scope="text, record">
  96. <span>{{ text }}</span>
  97. <a-badge count="促" v-if="record.promotionFlag.indexOf('GIFT')>=0" :number-style="{ backgroundColor: '#52c41a', zoom:'80%' }"></a-badge>
  98. <a-badge count="特" v-if="record.promotionFlag.indexOf('DISCOUNT')>=0" :number-style="{ backgroundColor: '#faad14', zoom:'80%' }"></a-badge>
  99. </template>
  100. <!-- 销售价 -->
  101. <template slot="price" slot-scope="text, record">
  102. {{ toThousands(text) }}
  103. <span v-if="record.promotionFlag.indexOf('GIFT')>=0||record.promotionFlag.indexOf('DISCOUNT')>=0" title="原价">({{ toThousands(record.origPrice) }})</span>
  104. </template>
  105. </s-table>
  106. </a-card>
  107. </a-spin>
  108. <!-- 发货分类打印 -->
  109. <sendTypeModal
  110. ref="typePrint"
  111. :hasNoPrint="hasNoPrint"
  112. :nowType="nowType"
  113. :openModal="openModal"
  114. @ok="handlePrintOk"
  115. @close="openModal=false" />
  116. <!-- 导出Excel -->
  117. <export-excel-modal :openModal="openExcelModal" :itemData="detailData" @ok="handleExcelOk" @close="openExcelModal=false" />
  118. <!-- 打印 -->
  119. <div id="print"></div>
  120. </div>
  121. </template>
  122. <script>
  123. import { commonMixin } from '@/utils/mixin'
  124. import { STable, VSelect } from '@/components'
  125. import sendTypeModal from './sendTypeModal.vue'
  126. import exportExcelModal from './exportExcelModal.vue'
  127. import { printBase64Fun, exportExcel } from '@/libs/JGPrint.js'
  128. import { dispatchDetaillListForOut, dispatchFindBySn, dispatchDetailPrint, dispatchDetailExcel } from '@/api/dispatch'
  129. export default {
  130. name: 'DetailForOut',
  131. mixins: [commonMixin],
  132. components: { STable, VSelect, sendTypeModal, exportExcelModal },
  133. props: {
  134. outBizSubSn: { // 有值则为弹框,无值则为页面
  135. type: [Number, String],
  136. default: ''
  137. },
  138. bizSn: { // 有值则为弹框,无值则为页面
  139. type: [Number, String],
  140. default: ''
  141. }
  142. },
  143. data () {
  144. return {
  145. disabled: false,
  146. spinning: false,
  147. outColumns: [
  148. { title: '序号', dataIndex: 'no', width: '6%', align: 'center' },
  149. { title: '产品编码', dataIndex: 'productCode', width: '25%', scopedSlots: { customRender: 'productCode' }, align: 'left' },
  150. { title: '产品名称', dataIndex: 'productName', width: '33%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  151. { title: '原厂编码', dataIndex: 'productOrigCode', width: '20%', align: 'left', customRender: function (text) { return text || '--' } },
  152. { title: '单位', dataIndex: 'productOrigUnit', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  153. { title: '本次出库数', dataIndex: 'qty', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  154. ],
  155. // 加载数据方法 必须为 Promise 对象
  156. loadData: parameter => {
  157. this.disabled = true
  158. return dispatchDetaillListForOut(Object.assign(parameter, { dispatchBillSn: this.outBizSubSn || this.bizSn || this.$route.params.sn })).then(res => {
  159. let data
  160. if (res.status == 200) {
  161. data = res.data
  162. const no = (data.pageNo - 1) * data.pageSize
  163. for (var i = 0; i < data.list.length; i++) {
  164. data.list[i].no = no + i + 1
  165. const productCode = (data.list[i].productEntity && data.list[i].productEntity.code) || (data.list[i].dealerProductEntity && data.list[i].dealerProductEntity.code)
  166. const productName = (data.list[i].productEntity && data.list[i].productEntity.name) || (data.list[i].dealerProductEntity && data.list[i].dealerProductEntity.name)
  167. const productOrigCode = (data.list[i].productEntity && data.list[i].productEntity.origCode) || (data.list[i].dealerProductEntity && data.list[i].dealerProductEntity.origCode)
  168. const productOrigUnit = (data.list[i].productEntity && data.list[i].productEntity.unit) || (data.list[i].dealerProductEntity && data.list[i].dealerProductEntity.unit)
  169. data.list[i].productCode = productCode || '--'
  170. data.list[i].productName = productName || '--'
  171. data.list[i].productOrigCode = productOrigCode == ' ' ? '--' : productOrigCode
  172. data.list[i].productOrigUnit = productOrigUnit || '--'
  173. }
  174. this.localDataSource = data.list
  175. this.disabled = false
  176. }
  177. return data
  178. })
  179. },
  180. detailData: null, // 详情数据
  181. openModal: false, // 发货分类打印弹框
  182. localDataSource: [], // 原始数据
  183. nowPrintType: '', // 当前打印类型
  184. openExcelModal: false, // 导出弹框
  185. fromRouter: null, // 页面来源
  186. nowType: 'print' // 操作类型
  187. }
  188. },
  189. computed: {
  190. // 是否可打印
  191. hasNoPrint () {
  192. return this.detailData && (this.detailData.printStatus == 'UNABLE_PRINT' || this.detailData.printStatus == 'CANCEL_PRINT')
  193. },
  194. columns () {
  195. const arr = [
  196. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  197. { title: '产品编码', dataIndex: 'productCode', width: '19%', scopedSlots: { customRender: 'productCode' }, align: 'left' },
  198. { title: '产品名称', dataIndex: 'productName', width: '10%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  199. { title: '原厂编码', dataIndex: 'productOrigCode', width: '19%', align: 'left', customRender: function (text) { return text || '--' } },
  200. { title: '单位', dataIndex: 'productOrigUnit', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  201. // { title: '销售价格', dataIndex: 'price', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  202. // { title: '市级销售价格', dataIndex: 'cityPrice', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  203. { title: '销售数量', dataIndex: 'salesQty', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  204. { title: '本次下推数', dataIndex: 'qty', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  205. // { title: '本次下推金额', dataIndex: 'totalAmount', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  206. ]
  207. if (this.$hasPermissions('B_dispatchDetail_salesPrice')) { // 售价权限
  208. arr.splice(5, 0, { title: '销售价格', dataIndex: 'price', width: '8%', align: 'right', scopedSlots: { customRender: 'price' } })
  209. arr.splice(9, 0, { title: '本次下推金额', dataIndex: 'totalAmount', width: '8%', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') })
  210. }
  211. if (this.$hasPermissions('B_dispatchDetail_cityPrice')) { // 市级权限
  212. arr.splice(6, 0, { title: '市级销售价格', dataIndex: 'cityPrice', width: '10%', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') })
  213. }
  214. return arr
  215. }
  216. },
  217. methods: {
  218. // 返回
  219. handleBack () {
  220. this.$router.push({ name: 'pushOrderManagementList' })
  221. },
  222. // 详情
  223. getDetail () {
  224. dispatchFindBySn({ dispatchBillSn: this.outBizSubSn || this.bizSn || this.$route.params.sn }).then(res => {
  225. if (res.status == 200) {
  226. this.detailData = res.data
  227. } else {
  228. this.detailData = null
  229. }
  230. })
  231. },
  232. // 导出Excel
  233. handleExcelOk (priceType, data, fileName) {
  234. const _this = this
  235. const params = {
  236. dispatchBillSn: this.outBizSubSn || this.bizSn || this.$route.params.sn,
  237. printType: priceType,
  238. ...data
  239. }
  240. this.spinning = true
  241. exportExcel(dispatchDetailExcel, params, fileName, function () {
  242. _this.spinning = false
  243. _this.$store.state.app.curActionPermission = ''
  244. })
  245. },
  246. // 发货分类导出
  247. handleFlExport () {
  248. this.openModal = true
  249. this.nowType = 'export'
  250. this.$refs.typePrint.setData(this.detailData, this.outBizSubSn || this.bizSn || this.$route.params.sn)
  251. },
  252. // 打印预览/快捷打印
  253. handlePrint (type) {
  254. this.nowPrintType = type
  255. if (type == 'DISPATCH_BILL') { // 发货打印
  256. const params = {
  257. dispatchBillSn: this.detailData.dispatchBillSn,
  258. dispatchBillNo: this.detailData.dispatchBillNo
  259. }
  260. this.$store.state.app.curActionPermission = 'B_dispatchPrint'
  261. this.handlePrintOk(params, '发货', 'preview')
  262. } else if (type == 'DISPATCH_BILL_TYPE') { // 发货分类打印
  263. this.openModal = true
  264. this.nowType = 'print'
  265. this.$refs.typePrint.setData(this.detailData, this.outBizSubSn || this.bizSn || this.$route.params.sn)
  266. }
  267. },
  268. // 发货分类打印,导出
  269. handlePrintOk (obj, taskName, type) {
  270. const _this = this
  271. const params = {
  272. type: this.nowPrintType,
  273. dispatchBillSn: this.outBizSubSn || this.bizSn || this.$route.params.sn
  274. }
  275. // 打印
  276. if (type != 'export') {
  277. _this.spinning = true
  278. // 货位编号
  279. if (obj.orderBy) {
  280. params.type = params.type + '_STACK_PLACE'
  281. }
  282. // 原厂编码
  283. if (obj.origCode == 1) {
  284. params.type = params.type + '_ORIG_CODE'
  285. }
  286. // 装箱号
  287. if (obj.packNo == 1) {
  288. params.type = params.type + '_PACK_NUM'
  289. }
  290. printBase64Fun(
  291. dispatchDetailPrint,
  292. Object.assign(params, obj || {}),
  293. type,
  294. taskName,
  295. () => {
  296. _this.spinning = false
  297. _this.$store.state.app.curActionPermission = ''
  298. },
  299. {
  300. billType: 'DISPATCH',
  301. billSn: obj.dispatchBillSn,
  302. billNo: obj.dispatchBillNo,
  303. printType: taskName + '打印'
  304. }, this.hasNoPrint)
  305. } else {
  306. this.handleExcelOk('DISPATCH_BILL_TYPE', obj, taskName)
  307. }
  308. }
  309. },
  310. mounted () {
  311. if (!this.$store.state.app.isNewTab || this.outBizSubSn || this.bizSn) { // 页签刷新 或 为弹框时调用
  312. this.$refs.table.refresh(true)
  313. this.getDetail()
  314. }
  315. },
  316. activated () {
  317. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  318. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  319. this.$refs.table.refresh(true)
  320. this.getDetail()
  321. }
  322. },
  323. beforeRouteEnter (to, from, next) {
  324. next(vm => {
  325. vm.fromRouter = from
  326. })
  327. }
  328. }
  329. </script>
  330. <style lang="less">
  331. .pushOrder-forOut-wrap{
  332. .ant-card-body:first-child{
  333. padding-bottom: 0;
  334. }
  335. .footer-cont{
  336. margin-top: 5px;
  337. text-align: center;
  338. }
  339. }
  340. </style>