detail.vue 20 KB

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