detail.vue 20 KB

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