detail.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  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">
  5. <template slot="subTitle" v-if="!bizSn">
  6. <a id="salesEdit-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
  7. <span style="margin: 0 15px;color: #666;font-weight: bold;">单号:{{ detailData&&detailData.salesBillNo }}</span>
  8. <span v-if="detailData&&detailData.salesBillNoSource">(原:{{ detailData&&detailData.salesBillNoSource || '--' }})</span>
  9. <a-button type="link" class="button-default" @click="showDetail=!showDetail">
  10. <a-icon :type="showDetail ? 'eye-invisible' : 'eye'"/> {{ showDetail?'隐藏':'查看' }}信息
  11. </a-button>
  12. </template>
  13. <template slot="extra">
  14. <a-button
  15. key="1"
  16. type="primary"
  17. class="button-info"
  18. id="salesDetail-xs-print-btn"
  19. v-if="$hasPermissions('B_salesPrint')"
  20. :disabled="hasData"
  21. @click="handlePrint('SALES_BILL','B_salesPrint')">销售打印</a-button>
  22. <a-button
  23. key="2"
  24. type="default"
  25. class="button-info"
  26. id="salesDetail-xsfl-print-btn"
  27. v-if="$hasPermissions('B_salesTypePrint')"
  28. :disabled="hasData"
  29. @click="handlePrint('SALES_BILL_TYPE','B_salesTypePrint')">销售分类打印</a-button>
  30. <a-divider type="vertical" />
  31. <a-button
  32. key="3"
  33. type="primary"
  34. class="button-info"
  35. id="salesDetail-export-btn"
  36. v-if="$hasPermissions('B_salesDetailExport')"
  37. :disabled="hasData"
  38. @click="handlePrint('export','B_salesDetailExport')">导出Excel</a-button>
  39. <a-button
  40. key="4"
  41. type="default"
  42. class="button-info"
  43. id="salesDetail-export-btn"
  44. v-if="$hasPermissions('B_salesTypeExport')"
  45. :disabled="hasData"
  46. @click="handlePrint('typeExport','B_salesTypeExport')">销售分类导出</a-button>
  47. </template>
  48. </a-page-header>
  49. <!-- 基础信息 -->
  50. <a-card size="small" :bordered="false" class="pages-wrap" style="margin-bottom: 8px;" v-show="showDetail">
  51. <div style="padding: 0;">
  52. <a-descriptions size="small" :column="3">
  53. <a-descriptions-item label="客户名称">{{ detailData&&detailData.buyerName || '--' }}</a-descriptions-item>
  54. <a-descriptions-item label="收货地址" :span="2">{{ shippingAddress||'--' }}</a-descriptions-item>
  55. <a-descriptions-item label="收货人">{{ detailData&&detailData.salesBillExtEntity&&detailData.salesBillExtEntity.consigneeName || '--' }}</a-descriptions-item>
  56. <a-descriptions-item label="收货电话">{{ detailData&&detailData.salesBillExtEntity&&detailData.salesBillExtEntity.consigneeTel || '--' }}</a-descriptions-item>
  57. <a-descriptions-item label="收款方式">{{ detailData&&detailData.settleStyleSnDictValue || '--' }}</a-descriptions-item>
  58. <a-descriptions-item label="审核时间">{{ detailData&&detailData.auditDate || '--' }}</a-descriptions-item>
  59. <a-descriptions-item label="业务状态">{{ detailData&&detailData.billStatusDictValue || '--' }}</a-descriptions-item>
  60. <a-descriptions-item label="财务状态">{{ detailData&&detailData.financialStatusDictValue || '--' }}</a-descriptions-item>
  61. <a-descriptions-item label="改单时间">{{ detailData&&detailData.submitDate || '--' }}</a-descriptions-item>
  62. <a-descriptions-item label="最新提交时间">{{ detailData&&detailData.firstSubmitDate || '--' }}</a-descriptions-item>
  63. <a-descriptions-item label="备注" :span="3">{{ detailData&&detailData.remarks || '--' }}</a-descriptions-item>
  64. </a-descriptions>
  65. </div>
  66. </a-card>
  67. <a-card size="small" :bordered="false" class="pages-wrap">
  68. <!-- alert -->
  69. <a-alert type="info" style="margin-bottom: 10px;">
  70. <div slot="message">
  71. <div>
  72. 总销售数量:<strong>{{ detailData&&(detailData.totalQty || detailData.totalQty==0) ? detailData.totalQty : '--' }}</strong>;
  73. 已取消数量:<strong>{{ detailData&&(detailData.totalCancelQty || detailData.totalCancelQty==0) ? detailData.totalCancelQty : '--' }}</strong>;
  74. 已下推数量:<strong>{{ detailData&&(detailData.totalPushedQty || detailData.totalPushedQty==0) ? detailData.totalPushedQty : '--' }}</strong>;
  75. 待下推数量:<strong>{{ detailData&&(detailData.totalUnpushedQty || detailData.totalUnpushedQty==0) ? detailData.totalUnpushedQty : '--' }}</strong>;
  76. 已发货数量:<strong>{{ detailData&&(detailData.totalDispatchQty || detailData.totalDispatchQty==0) ? detailData.totalDispatchQty : '--' }}</strong>;
  77. 待发货数量:<strong>{{ detailData&&(detailData.totalUndispatchQty || detailData.totalUndispatchQty==0) ? detailData.totalUndispatchQty : '--' }}</strong>;<br/>
  78. <span v-if="$hasPermissions(authCode + '_salesPrice')">总售价:<strong>{{ detailData&&(detailData.totalAmount || detailData.totalAmount==0) ? toThousands(detailData.totalAmount) : '--' }}</strong>;</span>
  79. <span v-if="$hasPermissions(authCode + '_costPrice')">总成本:<strong>{{ detailData&&(detailData.totalCost || detailData.totalCost==0) ? toThousands(detailData.totalCost) : '--' }}</strong>;</span>
  80. <span v-if="$hasPermissions(authCode + '_costPrice')">总毛利:<strong>{{ detailData&&(detailData.grossProfit || detailData.grossProfit==0) ? toThousands(detailData.grossProfit) : '--' }}</strong>;</span>
  81. <span v-if="$hasPermissions(authCode + '_salesPrice')">已取消金额:<strong>{{ detailData&&(detailData.totalCancelAmount || detailData.totalCancelAmount==0) ? toThousands(detailData.totalCancelAmount) : '--' }}</strong>;</span>
  82. <span v-if="$hasPermissions(authCode + '_salesPrice')">已下推金额:<strong>{{ detailData&&(detailData.totalPushedAmount || detailData.totalPushedAmount==0) ? toThousands(detailData.totalPushedAmount) : '--' }}</strong>;</span>
  83. <span v-if="$hasPermissions(authCode + '_salesPrice')">待下推金额:<strong>{{ detailData&&(detailData.totalUnpushedAmount || detailData.totalUnpushedAmount==0) ? toThousands(detailData.totalUnpushedAmount) : '--' }}</strong>;</span>
  84. <span v-if="$hasPermissions(authCode + '_salesPrice')">已发货金额:<strong>{{ detailData&&(detailData.totalDispatchAmount || detailData.totalDispatchAmount==0) ? toThousands(detailData.totalDispatchAmount) : '--' }}</strong>;</span>
  85. <span v-if="$hasPermissions(authCode + '_salesPrice')">待发货金额:<strong>{{ detailData&&(detailData.totalUndispatchAmount || detailData.totalUndispatchAmount==0) ? toThousands(detailData.totalUndispatchAmount) : '--' }}</strong>;</span>
  86. <span v-if="isCityPrice">市级总售价:<strong>{{ detailData&&(detailData.totalCityAmount || detailData.totalCityAmount==0) ? toThousands(detailData.totalCityAmount) : '--' }}</strong>;</span>
  87. <span v-if="$hasPermissions(authCode + '_salesPrice')&&detailData&&detailData.totalDiscountAmount" style="color: red;">优惠金额:<strong>{{ Number(detailData.totalDiscountAmount).toFixed(2) }}</strong>;</span>
  88. </div>
  89. </div>
  90. </a-alert>
  91. <!-- 查询 -->
  92. <div class="table-page-search-wrapper">
  93. <div style="display: flex;justify-content: space-between;align-items: center;">
  94. <div style="flex-grow: 1;width: 60%;">
  95. <a-form layout="inline" @keyup.enter.native="searchTable">
  96. <a-row :gutter="15" type="flex">
  97. <a-col flex="350px">
  98. <a-form-item label="出库仓库">
  99. <chooseWarehouse ref="warehouse" v-model="warehouseSn"></chooseWarehouse>
  100. </a-form-item>
  101. </a-col>
  102. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  103. <a-button type="primary" @click="searchTable" :disabled="disabled" id="productInfoList-refresh">查询</a-button>
  104. <a-button style="margin-left: 5px" @click="resetSearchForm" id="productInfoList-reset">重置</a-button>
  105. </a-col>
  106. </a-row>
  107. </a-form>
  108. </div>
  109. <div>
  110. <a-button v-if="detailData && (detailData.billStatus == 'WAIT_AUDIT' || detailData.billStatus == 'HQ_CHANGE')" type="link" @click="openStockOut">缺货明细</a-button>
  111. <a-checkbox v-model="isCityPrice" v-if="$hasPermissions(authCode + '_cityPrice')"><span style="display: inline-block;margin-top: 1px;">市级价</span></a-checkbox>
  112. </div>
  113. </div>
  114. </div>
  115. <!-- 产品列表 -->
  116. <div>
  117. <detailProductList
  118. ref="productList"
  119. :detailData="detailData"
  120. :warehouseSn="warehouseSn"
  121. :salesBillSn="$route.params.sn || bizSn"
  122. :authCode="authCode"
  123. :maxHeight="pageHeight"
  124. :showCityPrice="isCityPrice">
  125. </detailProductList>
  126. </div>
  127. </a-card>
  128. </a-spin>
  129. <div class="affix-cont">
  130. <a-button
  131. size="large"
  132. style="width: 100px;"
  133. :disabled="spinning"
  134. type="primary"
  135. class="button-info"
  136. id="salesDetail-audit-btn"
  137. v-if="detailData&&detailData.billStatus == 'WAIT_AUDIT'&&$hasPermissions('B_salesAudit')"
  138. @click="handleAudit()"
  139. >
  140. 审核
  141. </a-button>
  142. <a-button
  143. type="default"
  144. :disabled="spinning"
  145. class="button-info"
  146. size="large"
  147. style="width: 100px;margin: 0 20px;"
  148. id="salesDetail-edit-btn"
  149. v-if="detailData&&detailData.salesBillSource != 'PURCHASE' && (detailData.billStatus == 'WAIT_SUBMIT' || detailData.billStatus == 'WAIT_AUDIT' || detailData.billStatus == 'AUDIT_REJECT')&&$hasPermissions('B_salesEdit')"
  150. @click="handleEdit()"
  151. >
  152. 编辑
  153. </a-button>
  154. <a-button
  155. size="large"
  156. style="width: 100px;margin: 0 20px;"
  157. :disabled="spinning"
  158. type="default"
  159. class="button-info"
  160. id="salesDetail-edit-btn"
  161. v-if="detailData&&detailData.salesBillSource == 'PURCHASE' && (detailData.billStatus == 'WAIT_AUDIT'||detailData.billStatus == 'HQ_CHANGE')&&$hasPermissions('B_salesEdit')"
  162. @click="handleEdit()"
  163. >
  164. 改单
  165. </a-button>
  166. <a-button
  167. size="large"
  168. style="width: 100px;"
  169. :disabled="spinning"
  170. type="primary"
  171. class="button-success"
  172. id="salesDetail-batchAudit-btn"
  173. v-if="detailData&&detailData.billStatus == 'WAIT_AUDIT'&&$hasPermissions('B_salesAudit')"
  174. @click="handleAudit('batch')"
  175. >
  176. 一键审核
  177. </a-button>
  178. </div>
  179. <!-- 打印导出 -->
  180. <print-modal :openModal="openModal" :itemData="detailData" :nowType="nowType" @ok="handleOk" @close="closePrint" />
  181. <!-- 审核 -->
  182. <auditModal
  183. :openModal="visibleAudit"
  184. :content="auditText"
  185. :spinning="spinningAudit"
  186. @close="visibleAudit=false"
  187. @ok="auditOrder('AUDIT_PASS')"
  188. @fail="auditOrder('AUDIT_REJECT')" />
  189. <!-- 审核加下推 -->
  190. <dsModal ref="dsModal" title="销售单一键审核" :openModal="showDsModal" @close="showDsModal=false" @ok="handleOnceAudit" />
  191. <!-- 缺货明细 -->
  192. <stockOutDetail :openModal="showStockOut" :detailData="detailData" :salesBillSn="$route.params.sn || bizSn" @close="showStockOut=false"></stockOutDetail>
  193. </div>
  194. </template>
  195. <script>
  196. import { printFun, exportExcel } from '@/libs/JGPrint.js'
  197. import { commonMixin } from '@/utils/mixin'
  198. import moment from 'moment'
  199. import { VSelect } from '@/components'
  200. import printModal from './printModal.vue'
  201. import auditModal from '@/views/common/auditModal.vue'
  202. import dsModal from '@/views/salesManagement/waitDispatchNew/dsModal.vue'
  203. import stockOutDetail from './stockOutDetailModal.vue'
  204. import chooseWarehouse from '@/views/common/chooseWarehouse'
  205. import detailProductList from './comps/detailProductList.vue'
  206. // 接口
  207. import {
  208. salesDetailBySn,
  209. salesDetailPrint,
  210. salesDetailExcel,
  211. salesDetailTypeExcel,
  212. salesWriteAuditPass,
  213. salesWriteAuditReject,
  214. salesWriteAuditPush
  215. } from '@/api/salesNew'
  216. export default {
  217. name: 'SalesDetailNew',
  218. mixins: [commonMixin],
  219. components: { VSelect, printModal, auditModal, dsModal, stockOutDetail, chooseWarehouse, detailProductList },
  220. props: {
  221. bizSn: { // 有值则为弹框,无值则为页面
  222. type: [Number, String],
  223. default: ''
  224. }
  225. },
  226. data () {
  227. return {
  228. spinning: false,
  229. disabled: false,
  230. showDsModal: false,
  231. showStockOut: false,
  232. authCode: '', // 权限码
  233. hasData: false, // 是否有数据
  234. showDetail: false,
  235. openModal: false,
  236. detailData: null, // 详情数据
  237. nowType: null,
  238. isCityPrice: false, // 是否显示市级价
  239. visibleAudit: false,
  240. auditInfo: null,
  241. spinningAudit: false,
  242. auditText: null,
  243. fromRouter: null,
  244. warehouseSn: undefined
  245. }
  246. },
  247. computed: {
  248. // 地址
  249. shippingAddress () {
  250. const shippingAddrProvinceName = this.detailData && this.detailData.salesBillExtEntity && this.detailData.salesBillExtEntity.shippingAddrProvinceName ? this.detailData.salesBillExtEntity.shippingAddrProvinceName : ''
  251. const shippingAddrCityName = this.detailData && this.detailData.salesBillExtEntity && this.detailData.salesBillExtEntity.shippingAddrCityName ? this.detailData.salesBillExtEntity.shippingAddrCityName : ''
  252. const shippingAddrCountyName = this.detailData && this.detailData.salesBillExtEntity && this.detailData.salesBillExtEntity.shippingAddrCountyName ? this.detailData.salesBillExtEntity.shippingAddrCountyName : ''
  253. const shippingAddr = this.detailData && this.detailData.salesBillExtEntity && this.detailData.salesBillExtEntity.shippingAddr ? this.detailData.salesBillExtEntity.shippingAddr : ''
  254. if (!shippingAddrProvinceName && !shippingAddrCityName && !shippingAddrCountyName && !shippingAddr) {
  255. return '--'
  256. } else {
  257. return shippingAddrProvinceName + shippingAddrCityName + shippingAddrCountyName + shippingAddr
  258. }
  259. },
  260. pageHeight () {
  261. return window.innerHeight - 330
  262. }
  263. },
  264. methods: {
  265. // 返回
  266. handleBack () {
  267. this.$router.push({ name: 'salesQueryNewList' })
  268. },
  269. // 编辑
  270. handleEdit () {
  271. const row = this.detailData
  272. this.$router.push({ name: 'salesNewEdit', params: { sn: row.salesBillSn, wSn: row.warehouseSn } })
  273. },
  274. // 重置
  275. resetSearchForm () {
  276. this.warehouseSn = undefined
  277. setTimeout(() => {
  278. this.searchTable()
  279. }, 100)
  280. },
  281. // 查询数据
  282. searchTable () {
  283. this.$refs.productList.searchTable()
  284. },
  285. // 详情
  286. getDetail () {
  287. salesDetailBySn({ salesBillSn: this.bizSn || this.$route.params.sn }).then(res => {
  288. if (res.status == 200) {
  289. this.detailData = res.data || null
  290. this.detailData.totalDiscountAmount = Number(this.detailData.totalOrigAmount || 0) - Number(this.detailData.totalAmount || 0)
  291. }
  292. this.$refs.productList.pageInit()
  293. })
  294. },
  295. // 打开缺货明细
  296. openStockOut () {
  297. if (this.$refs.productList.outStockStr != '') {
  298. this.showStockOut = true
  299. } else {
  300. this.$info({
  301. title: '提示',
  302. content: '此销售单暂无缺货产品!',
  303. centered: true
  304. })
  305. }
  306. },
  307. // 打开审核/一键审核弹框
  308. handleAudit (isBatch) {
  309. if (isBatch) { // 一键审核
  310. if (this.detailData && this.detailData.promoFlag == 1 && this.$refs.productList.outStockStr != '') {
  311. this.$info({
  312. title: '提示',
  313. content: '参加促销活动的销售单,有缺货产品,不可一键审核!',
  314. centered: true
  315. })
  316. return
  317. }
  318. this.showDsModal = true
  319. this.$refs.dsModal.setDetail(this.detailData)
  320. } else {
  321. this.auditText = null
  322. this.visibleAudit = true
  323. }
  324. },
  325. // 一键审核
  326. handleOnceAudit (data) {
  327. const params = {
  328. salesBillSn: this.bizSn || this.$route.params.sn,
  329. billStatus: 'AUDIT_PASS',
  330. dispatchBill: data
  331. }
  332. this.spinningAudit = true
  333. this.spinning = true
  334. salesWriteAuditPush(params).then(res => {
  335. if (res.status == 200) {
  336. this.$message.success(res.message)
  337. // 关闭详情跳列表
  338. this.handleBack()
  339. }
  340. this.spinningAudit = false
  341. this.spinning = false
  342. })
  343. },
  344. // 审核
  345. auditOrder (billStatus) {
  346. this.spinningAudit = true
  347. const auditFun = billStatus == 'AUDIT_PASS' ? salesWriteAuditPass : salesWriteAuditReject
  348. auditFun({
  349. salesBillSn: this.bizSn || this.$route.params.sn,
  350. billStatus: billStatus
  351. }).then(res => {
  352. if (res.status == 200) {
  353. this.visibleAudit = false
  354. this.$message.success(res.message)
  355. this.spinningAudit = false
  356. const _this = this
  357. this.$nextTick(() => {
  358. if (billStatus == 'AUDIT_PASS' && !_this.auditText) {
  359. _this.$router.push({ name: 'waitDispatchNew', params: { salesBillSn: _this.bizSn || _this.$route.params.sn } })
  360. } else {
  361. // 关闭详情跳列表
  362. _this.handleBack()
  363. }
  364. })
  365. } else {
  366. this.visibleAudit = false
  367. this.spinningAudit = false
  368. }
  369. })
  370. },
  371. // 打印导出
  372. handlePrint (type, authCode) {
  373. const _this = this
  374. _this.$store.state.app.curActionPermission = authCode
  375. // 销售分类导出
  376. if (type == 'typeExport') {
  377. const params = {
  378. salesBillSn: this.bizSn || this.$route.params.sn
  379. }
  380. _this.spinning = true
  381. exportExcel(salesDetailTypeExcel, params, '销售分类' + moment().format('YYYYMMDDHHmmss'), () => {
  382. _this.spinning = false
  383. _this.$store.state.app.curActionPermission = ''
  384. })
  385. } else {
  386. this.detailData.authCode = authCode
  387. this.nowType = type
  388. this.openModal = true
  389. }
  390. },
  391. closePrint () {
  392. console.log(9)
  393. this.$store.state.app.curActionPermission = ''
  394. this.openModal = false
  395. },
  396. // 确定打印或预览,导出
  397. handleOk (objs) {
  398. const _this = this
  399. const params = JSON.parse(JSON.stringify(objs))
  400. _this.$store.state.app.curActionPermission = this.detailData.authCode
  401. delete params.type
  402. _this.spinning = true
  403. if (this.nowType == 'export') { // 导出
  404. exportExcel(salesDetailExcel, params, '销售' + moment().format('YYYYMMDDHHmmss'), () => {
  405. _this.spinning = false
  406. _this.$store.state.app.curActionPermission = ''
  407. })
  408. } else { // 打印
  409. const taskName = this.nowType == 'SALES_BILL' ? '销售单' : '销售分类'
  410. printFun(salesDetailPrint, params, objs.type, taskName, () => {
  411. _this.spinning = false
  412. _this.$store.state.app.curActionPermission = ''
  413. })
  414. }
  415. }
  416. },
  417. mounted () {
  418. if (!this.$store.state.app.isNewTab || this.bizSn) { // 页签刷新时调用
  419. this.getDetail()
  420. }
  421. },
  422. activated () {
  423. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  424. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  425. this.getDetail()
  426. }
  427. },
  428. beforeRouteEnter (to, from, next) {
  429. next(vm => {
  430. vm.fromRouter = from
  431. vm.authCode = to.meta.permission
  432. })
  433. }
  434. }
  435. </script>
  436. <style lang="less">
  437. .salesDetail-wrap{
  438. position: relative;
  439. height: 100%;
  440. padding-bottom: 51px;
  441. box-sizing: border-box;
  442. >.ant-spin-nested-loading{
  443. overflow-y: auto;
  444. height: 100%;
  445. }
  446. .salesDetail-cont{
  447. margin-bottom: 10px;
  448. }
  449. .active-title{
  450. display: flex;
  451. align-items: center;
  452. justify-content: space-between;
  453. padding: 10px;
  454. background: #f3f8fa;
  455. }
  456. .flexBox{
  457. display: flex;
  458. justify-content: space-between;
  459. align-items: center;
  460. }
  461. .footer-cont{
  462. margin-top: 5px;
  463. text-align: center;
  464. }
  465. .redStyle{
  466. font-weight: bold;
  467. color: red;
  468. }
  469. }
  470. </style>