detail.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684
  1. <template>
  2. <div class="salesDetail-wrap" :style="{paddingBottom:hideFooter?'0px':'45px'}">
  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="salesDetail-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: 0 10px;color: #666;">客户名称:{{ detailData&&detailData.buyerName }}</span>
  10. <a-button size="small" type="link" class="button-default" @click="showDetail=!showDetail">
  11. <a-icon :type="showDetail ? 'eye-invisible' : 'eye'"/> {{ showDetail?'隐藏':'查看' }}信息
  12. </a-button>
  13. </template>
  14. <template slot="extra">
  15. <a-button
  16. key="1"
  17. type="primary"
  18. class="button-info"
  19. id="salesDetail-xs-print-btn"
  20. v-if="$hasPermissions('B_salesPrint')"
  21. :disabled="hasData"
  22. @click="handlePrint('SALES_BILL','B_salesPrint')">销售打印</a-button>
  23. <a-button
  24. key="2"
  25. type="primary"
  26. class="button-info"
  27. id="salesDetail-xsfl-print-btn"
  28. v-if="$hasPermissions('B_salesTypePrint')"
  29. :disabled="hasData"
  30. @click="handlePrint('SALES_BILL_TYPE','B_salesTypePrint')">销售分类打印</a-button>
  31. <a-divider type="vertical" />
  32. <a-button
  33. key="3"
  34. type="default"
  35. class="button-info"
  36. id="salesDetail-export-btn"
  37. v-if="$hasPermissions('B_salesDetailExport')"
  38. :disabled="hasData"
  39. @click="handlePrint('export','B_salesDetailExport')">导出Excel</a-button>
  40. <a-button
  41. key="4"
  42. type="default"
  43. class="button-info"
  44. id="salesDetail-exportType-btn"
  45. v-if="$hasPermissions('B_salesTypeExport')"
  46. :disabled="hasData"
  47. @click="handlePrint('typeExport','B_salesTypeExport')">销售分类导出</a-button>
  48. </template>
  49. </a-page-header>
  50. <!-- 基础信息 -->
  51. <a-card size="small" :bordered="false" class="pages-wrap" style="margin-bottom: 6px;" v-show="showDetail">
  52. <div style="padding: 0;">
  53. <a-descriptions size="small" :column="3">
  54. <a-descriptions-item label="客户名称">{{ detailData&&detailData.buyerName || '--' }}</a-descriptions-item>
  55. <a-descriptions-item label="收货地址" :span="2">{{ shippingAddress||'--' }}</a-descriptions-item>
  56. <a-descriptions-item label="收货人">{{ detailData&&detailData.salesBillExtEntity&&detailData.salesBillExtEntity.consigneeName || '--' }}</a-descriptions-item>
  57. <a-descriptions-item label="收货电话">{{ detailData&&detailData.salesBillExtEntity&&detailData.salesBillExtEntity.consigneeTel || '--' }}</a-descriptions-item>
  58. <a-descriptions-item label="收款方式">{{ detailData&&detailData.settleStyleSnDictValue || '--' }}</a-descriptions-item>
  59. <a-descriptions-item label="审核时间">{{ detailData&&detailData.auditDate || '--' }}</a-descriptions-item>
  60. <a-descriptions-item label="业务状态">{{ detailData&&detailData.billStatusDictValue || '--' }}</a-descriptions-item>
  61. <a-descriptions-item label="财务状态">{{ detailData&&detailData.financialStatusDictValue || '--' }}</a-descriptions-item>
  62. <a-descriptions-item label="改单时间" v-if="detailData&&detailData.salesBillSource=='PURCHASE'&&detailData.submitDate">{{ detailData.submitDate }}</a-descriptions-item>
  63. <a-descriptions-item label="最新提交时间" v-if="detailData&&detailData.salesBillSource=='SALES'&&detailData.submitDate">{{ detailData.submitDate }}</a-descriptions-item>
  64. <a-descriptions-item label="备注" :span="3">{{ detailData&&detailData.remarks || '--' }}</a-descriptions-item>
  65. </a-descriptions>
  66. </div>
  67. </a-card>
  68. <a-card size="small" :bordered="false" class="pages-wrap">
  69. <!-- 统计信息 -->
  70. <a-alert type="info" style="margin-bottom: 10px;">
  71. <div slot="message">
  72. <div>
  73. 总销售数量:<strong>{{ detailData&&(detailData.totalQty || detailData.totalQty==0) ? detailData.totalQty : '--' }}</strong>;
  74. 已取消数量:<strong>{{ detailData&&(detailData.totalCancelQty || detailData.totalCancelQty==0) ? detailData.totalCancelQty : '--' }}</strong>;
  75. 已下推数量:<strong>{{ detailData&&(detailData.totalPushedQty || detailData.totalPushedQty==0) ? detailData.totalPushedQty : '--' }}</strong>;
  76. 待下推数量:<strong>{{ detailData&&(detailData.totalUnpushedQty || detailData.totalUnpushedQty==0) ? detailData.totalUnpushedQty : '--' }}</strong>;
  77. 已发货数量:<strong>{{ detailData&&(detailData.totalDispatchQty || detailData.totalDispatchQty==0) ? detailData.totalDispatchQty : '--' }}</strong>;
  78. 待发货数量:<strong>{{ detailData&&(detailData.totalUndispatchQty || detailData.totalUndispatchQty==0) ? detailData.totalUndispatchQty : '--' }}</strong>;<br/>
  79. <span v-if="$hasPermissions(authCode + '_salesPrice')">总售价:<strong>{{ detailData&&(detailData.totalAmount || detailData.totalAmount==0) ? toThousands(detailData.totalAmount) : '--' }}</strong>;</span>
  80. <span v-if="$hasPermissions(authCode + '_costPrice')">总成本:<strong>{{ detailData&&(detailData.totalCost || detailData.totalCost==0) ? toThousands(detailData.totalCost) : '--' }}</strong>;</span>
  81. <span v-if="$hasPermissions(authCode + '_costPrice')">总毛利:<strong>{{ detailData&&(detailData.grossProfit || detailData.grossProfit==0) ? toThousands(detailData.grossProfit) : '--' }}</strong>;</span>
  82. <span v-if="$hasPermissions(authCode + '_salesPrice')">已取消金额:<strong>{{ detailData&&(detailData.totalCancelAmount || detailData.totalCancelAmount==0) ? toThousands(detailData.totalCancelAmount) : '--' }}</strong>;</span>
  83. <span v-if="$hasPermissions(authCode + '_salesPrice')">已下推金额:<strong>{{ detailData&&(detailData.totalPushedAmount || detailData.totalPushedAmount==0) ? toThousands(detailData.totalPushedAmount) : '--' }}</strong>;</span>
  84. <span v-if="$hasPermissions(authCode + '_salesPrice')">待下推金额:<strong>{{ detailData&&(detailData.totalUnpushedAmount || detailData.totalUnpushedAmount==0) ? toThousands(detailData.totalUnpushedAmount) : '--' }}</strong>;</span>
  85. <span v-if="$hasPermissions(authCode + '_salesPrice')">已发货金额:<strong>{{ detailData&&(detailData.totalDispatchAmount || detailData.totalDispatchAmount==0) ? toThousands(detailData.totalDispatchAmount) : '--' }}</strong>;</span>
  86. <span v-if="$hasPermissions(authCode + '_salesPrice')">待发货金额:<strong>{{ detailData&&(detailData.totalUndispatchAmount || detailData.totalUndispatchAmount==0) ? toThousands(detailData.totalUndispatchAmount) : '--' }}</strong>;</span>
  87. <span v-if="isCityPrice">市级总售价:<strong>{{ detailData&&(detailData.totalCityAmount || detailData.totalCityAmount==0) ? toThousands(detailData.totalCityAmount) : '--' }}</strong>;</span>
  88. <span v-if="$hasPermissions(authCode + '_salesPrice')&&detailData&&detailData.totalDiscountAmount" style="color: red;">优惠金额:<strong>{{ Number(detailData.totalDiscountAmount).toFixed(2) }}</strong>;</span>
  89. <span v-if="$hasPermissions(authCode + '_salesPrice')&&detailData&&detailData.totalConvertPromoGiftsAmount" style="color: red;">促销产品转采购额金额:<strong>{{ Number(detailData.totalConvertPromoGiftsAmount).toFixed(2) }}</strong>;</span>
  90. </div>
  91. </div>
  92. </a-alert>
  93. <!-- 查询 -->
  94. <div class="table-page-search-wrapper">
  95. <div style="display: flex;justify-content: space-between;align-items: center;">
  96. <div style="flex-grow: 1;width: 60%;">
  97. <a-form layout="inline" @keyup.enter.native="searchTable">
  98. <a-row :gutter="15" type="flex">
  99. <a-col flex="300px">
  100. <a-form-item label="出库仓库">
  101. <chooseWarehouse id="salesDetail-warehouse" ref="warehouse" v-model="warehouseSn"></chooseWarehouse>
  102. </a-form-item>
  103. </a-col>
  104. <a-col flex="300px" v-if="hasPrompActive">
  105. <a-form-item label="产品类型">
  106. <a-select v-model.trim="promoFlag" id="salesDetail-promoFlag" allowClear :dropdownMatchSelectWidth="false" placeholder="请选择产品类型">
  107. <a-select-option value="0">
  108. 正常产品
  109. </a-select-option>
  110. <a-select-option value="REGULAR">
  111. 正价产品(活动)
  112. </a-select-option>
  113. <a-select-option value="DISCOUNT">
  114. 特价产品
  115. </a-select-option>
  116. <a-select-option value="GIFT">
  117. 促销产品
  118. </a-select-option>
  119. <a-select-option value="convertPromoGiftsFlag" v-if="showConvertPromoGifts">
  120. 促销产品(转采购额)
  121. </a-select-option>
  122. <a-select-option value="GATE">
  123. 门槛产品
  124. </a-select-option>
  125. </a-select>
  126. </a-form-item>
  127. </a-col>
  128. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  129. <a-button type="primary" @click="searchTable" :disabled="disabled" id="salesDetail-refresh">查询</a-button>
  130. <a-button style="margin-left: 5px" @click="resetSearchForm" id="salesDetail-reset">重置</a-button>
  131. </a-col>
  132. </a-row>
  133. </a-form>
  134. </div>
  135. <div>
  136. <a-button id="salesDetail-updateStock" type="primary" v-if="showStock" @click="getThreeStock" class="button-info">第三方库存</a-button>
  137. <a-button id="salesDetail-stockOut" v-if="detailData && (detailData.billStatus == 'WAIT_AUDIT' || detailData.billStatus == 'HQ_CHANGE')" type="link" @click="openStockOut">缺货明细</a-button>
  138. <a-checkbox id="salesDetail-cityPrice" v-model="isCityPrice" v-if="$hasPermissions(authCode + '_cityPrice')"><span style="display: inline-block;margin-top: 1px;">市级价</span></a-checkbox>
  139. </div>
  140. </div>
  141. </div>
  142. <!-- 产品列表 -->
  143. <div>
  144. <detailProductList
  145. ref="productList"
  146. :detailData="detailData"
  147. :warehouseSn="warehouseSn"
  148. :promoFlag="promoFlag"
  149. :salesBillSn="$route.params.sn || bizSn"
  150. :authCode="authCode"
  151. :maxHeight="pageHeight"
  152. :showCityPrice="isCityPrice">
  153. </detailProductList>
  154. </div>
  155. </a-card>
  156. </a-spin>
  157. <div class="affix-cont" :style="{padding:hideFooter?0:'7px 0 4px'}">
  158. <a-button
  159. style="width: 100px;"
  160. :disabled="spinning"
  161. type="primary"
  162. class="button-info"
  163. id="salesDetail-audit-btn"
  164. v-if="(detailData&&(detailData.billStatus == 'WAIT_AUDIT'||detailData.billStatus=='WAIT_UP_AUDIT_PASS'))&&$hasPermissions('B_salesAudit')"
  165. @click="handleAudit()"
  166. >
  167. 审核
  168. </a-button>
  169. <a-button
  170. type="primary"
  171. :disabled="spinning"
  172. style="width: 100px;margin: 0 20px;"
  173. id="salesDetail-edit-btn"
  174. v-if="detailData&&detailData.salesBillSource == 'SALES' && (detailData.billStatus == 'WAIT_SUBMIT' || detailData.billStatus == 'WAIT_AUDIT' || detailData.billStatus == 'AUDIT_REJECT' || detailData.billStatus == 'HQ_CHANGE')&&$hasPermissions('B_salesEdit')"
  175. @click="handleEdit()"
  176. >
  177. 编辑
  178. </a-button>
  179. <a-button
  180. style="width: 100px;margin: 0 20px;"
  181. :disabled="spinning"
  182. type="primary"
  183. id="salesDetail-edit1-btn"
  184. v-if="detailData&&detailData.salesBillSource == 'PURCHASE' && (detailData.billStatus == 'WAIT_AUDIT'||detailData.billStatus == 'HQ_CHANGE')&&$hasPermissions('B_salesEdit')"
  185. @click="handleChangeOrder()"
  186. >
  187. 改单
  188. </a-button>
  189. <a-button
  190. style="width: 100px;"
  191. :disabled="spinning"
  192. type="primary"
  193. class="button-success"
  194. id="salesDetail-batchAudit-btn"
  195. v-if="detailData&&detailData.billStatus == 'WAIT_AUDIT'&&$hasPermissions('B_salesAudit')"
  196. @click="handleAudit('batch')"
  197. >
  198. 一键审核
  199. </a-button>
  200. <a-button
  201. id="salesDetail-dispatch"
  202. style="width: 100px;"
  203. type="primary"
  204. class="button-warning"
  205. v-if="detailData&&detailData.billStatus == 'WAIT_PUSH'&&$hasPermissions('B_salesDispatch')"
  206. @click="handleDispatch(detailData)"
  207. >下推</a-button>
  208. </div>
  209. <!-- 打印导出 -->
  210. <print-modal :openModal="openModal" :itemData="detailData" :nowType="nowType" @ok="handleOk" @close="closePrint" />
  211. <!-- 审核 -->
  212. <auditModal
  213. :openModal="visibleAudit"
  214. :content="auditText"
  215. :spinning="spinningAudit"
  216. @close="visibleAudit=false"
  217. @ok="auditOrder('AUDIT_PASS')"
  218. @fail="auditOrder('AUDIT_REJECT')" />
  219. <!-- 审核加下推 -->
  220. <dsModal ref="dsModal" title="销售单一键审核" :openModal="showDsModal" @close="showDsModal=false" @ok="handleOnceAudit" />
  221. <!-- 缺货明细 -->
  222. <stockOutDetail :openModal="showStockOut" :detailData="detailData" :salesBillSn="$route.params.sn || bizSn" @close="showStockOut=false"></stockOutDetail>
  223. <!-- 改单时价格变更提示 -->
  224. <tipModal ref="tipModal" :openModal="openTipModal" :dataList="sourceData" @close="closeTipModal" @ok="openTipModalOk"></tipModal>
  225. <!-- 审核时校验销售价低于成本价提示 -->
  226. <vaildPriceModal ref="vaildPriceModal" :openModal="openVaildPriceModal" :dataObj="tempData" @close="openVaildPriceModal=false" @ok="vaildPriceOk"></vaildPriceModal>
  227. </div>
  228. </template>
  229. <script>
  230. import { printFun, exportExcel } from '@/libs/JGPrint.js'
  231. import { commonMixin } from '@/utils/mixin'
  232. import moment from 'moment'
  233. import { VSelect } from '@/components'
  234. import printModal from './printModal.vue'
  235. import auditModal from '@/views/common/auditModal.vue'
  236. import dsModal from '@/views/salesManagement/waitDispatchNew/dsModal.vue'
  237. import stockOutDetail from './stockOutDetailModal.vue'
  238. import chooseWarehouse from '@/views/common/chooseWarehouse'
  239. import detailProductList from './comps/detailProductList.vue'
  240. import tipModal from './tipModal.vue'
  241. import vaildPriceModal from './vaildPriceModal.vue'
  242. // 接口
  243. import { salesDetailBySn, salesDetailPrint, salesDetailExcel, salesDetailTypeExcel, salesWriteAuditPass, salesWriteUpAuditPass, salesWriteAuditReject, salesWriteAuditPush, getThirdStockQty, salesPromoValidaAudit, changeBillCheckUpdatePrice, changeBillCheck } from '@/api/salesNew'
  244. export default {
  245. name: 'SalesDetailNew',
  246. mixins: [commonMixin],
  247. components: { VSelect, printModal, auditModal, dsModal, stockOutDetail, chooseWarehouse, detailProductList, tipModal, vaildPriceModal },
  248. props: {
  249. bizSn: { // 有值则为弹框,无值则为页面
  250. type: [Number, String],
  251. default: ''
  252. }
  253. },
  254. data () {
  255. return {
  256. spinning: false,
  257. disabled: false,
  258. showDsModal: false, // 一键审核弹框
  259. showStockOut: false, // 缺货明细弹框
  260. authCode: '', // 权限码
  261. hasData: false, // 是否有数据
  262. showDetail: false, // 基础信息是否显示
  263. openModal: false, // 打印导出弹框
  264. detailData: null, // 详情数据
  265. nowType: null, // 打印导出类型
  266. isCityPrice: false, // 是否显示市级价
  267. visibleAudit: false, // 审核弹框
  268. spinningAudit: false, // 审核loading
  269. auditText: null, // 审核备注信息
  270. fromRouter: null, // 从那个页面打开当前页面
  271. warehouseSn: undefined, // 所在仓库
  272. promoFlag: undefined, // 产品类型
  273. openTipModal: false, // 改单弹窗
  274. sourceData: undefined, // 价格变动数据
  275. tempData: undefined, // 校验临时数据
  276. openVaildPriceModal: false // 校验价格弹框
  277. }
  278. },
  279. computed: {
  280. // 详细地址
  281. shippingAddress () {
  282. const shippingAddrProvinceName = this.detailData && this.detailData.salesBillExtEntity && this.detailData.salesBillExtEntity.shippingAddrProvinceName ? this.detailData.salesBillExtEntity.shippingAddrProvinceName : ''
  283. const shippingAddrCityName = this.detailData && this.detailData.salesBillExtEntity && this.detailData.salesBillExtEntity.shippingAddrCityName ? this.detailData.salesBillExtEntity.shippingAddrCityName : ''
  284. const shippingAddrCountyName = this.detailData && this.detailData.salesBillExtEntity && this.detailData.salesBillExtEntity.shippingAddrCountyName ? this.detailData.salesBillExtEntity.shippingAddrCountyName : ''
  285. const shippingAddr = this.detailData && this.detailData.salesBillExtEntity && this.detailData.salesBillExtEntity.shippingAddr ? this.detailData.salesBillExtEntity.shippingAddr : ''
  286. if (!shippingAddrProvinceName && !shippingAddrCityName && !shippingAddrCountyName && !shippingAddr) {
  287. return '--'
  288. } else {
  289. return shippingAddrProvinceName + shippingAddrCityName + shippingAddrCountyName + shippingAddr
  290. }
  291. },
  292. // 是否因此底部栏按钮
  293. hideFooter () {
  294. const detailData = this.detailData
  295. return detailData && (detailData.billStatus == 'HQ_CHANGE' || (detailData.salesBillSource != 'SALES' && detailData.billStatus == 'AUDIT_REJECT') || detailData.billStatus == 'FINISH' || detailData.billStatus == 'OUTING_WAREHOUSE')
  296. },
  297. // 是否有促销活动产品
  298. hasPrompActive () {
  299. return this.detailData && this.detailData.promoFlag == 1
  300. },
  301. // 是否有促销产品(转采购额)
  302. showConvertPromoGifts () {
  303. return this.$refs.productList && this.$refs.productList.showConvertPromoGifts
  304. },
  305. // 是否显示库存列
  306. showStock () {
  307. return this.detailData && (this.detailData.billStatus == 'WAIT_AUDIT' || this.detailData.billStatus == 'HQ_CHANGE') && this.$hasPermissions('B_salesAudit')
  308. },
  309. // 表格高度计算
  310. pageHeight () {
  311. return window.innerHeight - 305 + (this.hideFooter ? 45 : 0)
  312. }
  313. },
  314. methods: {
  315. // 返回
  316. handleBack () {
  317. this.$router.push({ name: 'salesQueryNewList' })
  318. },
  319. // 编辑
  320. handleEdit () {
  321. const row = this.detailData
  322. this.$router.push({ name: 'salesNewEdit', params: { sn: row.salesBillSn, wSn: row.warehouseSn } })
  323. },
  324. // 改单
  325. handleChangeOrder () {
  326. const _this = this
  327. const row = _this.detailData
  328. changeBillCheck({ salesBillSn: row.salesBillSn }).then(res => {
  329. let data
  330. if (res.status == 200) {
  331. data = res.data
  332. if (data && data.length > 0) {
  333. _this.sourceData = res.data
  334. const obj = {
  335. buyerName: row.buyerName,
  336. salesBillNo: row.salesBillNo
  337. }
  338. _this.$refs.tipModal.getShowInfo(obj)
  339. _this.openTipModal = true
  340. } else {
  341. _this.$router.push({ name: 'salesNewEdit', params: { sn: row.salesBillSn, wSn: row.warehouseSn } })
  342. }
  343. }
  344. })
  345. },
  346. // 改单成功 关闭弹窗
  347. openTipModalOk (ajaxData) {
  348. const row = this.detailData
  349. ajaxData.salesBillSn = row.salesBillSn
  350. ajaxData.detailList = this.sourceData
  351. changeBillCheckUpdatePrice(ajaxData).then(res => {
  352. if (res.status == 200) {
  353. this.$message.success(res.message)
  354. this.openTipModal = false
  355. this.$nextTick(() => {
  356. this.$router.push({ name: 'salesNewEdit', params: { sn: row.salesBillSn, wSn: row.warehouseSn } })
  357. })
  358. }
  359. })
  360. },
  361. // 取消时,跳转编辑页面
  362. closeTipModal () {
  363. this.openTipModal = false
  364. this.$router.push({ name: 'salesNewEdit', params: { sn: this.$route.params.sn } })
  365. },
  366. // 价格低于成本校验提示,继续审核
  367. vaildPriceOk (type) {
  368. // 不通过
  369. if (type == 'AUDIT_REJECT') {
  370. this.auditOrder(type)
  371. } else {
  372. // 如果时 待上级审核,调用
  373. if (this.detailData.billStatus == 'WAIT_UP_AUDIT_PASS') {
  374. this.auditOrder(type)
  375. return
  376. }
  377. this.spinning = true
  378. // 通过,业务状态变更 待上级审核
  379. salesWriteUpAuditPass({
  380. salesBillSn: this.bizSn || this.$route.params.sn,
  381. billStatus: type
  382. }).then(res => {
  383. if (res.status == 200) {
  384. this.$message.success(res.message)
  385. this.handleBack()
  386. }
  387. this.$refs.vaildPriceModal.spinning = false
  388. this.spinning = false
  389. })
  390. }
  391. },
  392. // 重置
  393. resetSearchForm () {
  394. this.warehouseSn = undefined
  395. this.promoFlag = undefined
  396. setTimeout(() => {
  397. this.searchTable()
  398. }, 100)
  399. },
  400. // 查询数据
  401. searchTable () {
  402. this.$refs.productList.searchTable()
  403. },
  404. // 查询第三方库存
  405. getThreeStock () {
  406. this.spinning = true
  407. getThirdStockQty({ salesBillSn: this.bizSn || this.$route.params.sn }).then(res => {
  408. if (res.status == 200) {
  409. this.$refs.productList.showThreeStock()
  410. this.resetSearchForm()
  411. }
  412. this.spinning = false
  413. })
  414. },
  415. // 详情
  416. getDetail () {
  417. salesDetailBySn({ salesBillSn: this.bizSn || this.$route.params.sn }).then(res => {
  418. if (res.status == 200) {
  419. this.detailData = res.data || null
  420. this.detailData.totalDiscountAmount = Number(this.detailData.totalOrigAmount || 0) - Number(this.detailData.totalAmount || 0)
  421. }
  422. this.$refs.productList.pageInit()
  423. })
  424. },
  425. // 打开缺货明细弹框
  426. openStockOut () {
  427. if (this.$refs.productList.outStockStr != '') {
  428. this.showStockOut = true
  429. } else {
  430. this.$info({
  431. title: '提示',
  432. content: '此销售单暂无缺货产品!',
  433. centered: true
  434. })
  435. }
  436. },
  437. // 下推
  438. handleDispatch (row) {
  439. this.$router.push({ name: 'waitDispatchNew', params: { salesBillSn: row.salesBillSn } })
  440. },
  441. // 打开审核/一键审核弹框
  442. async handleAudit (isBatch) {
  443. const _this = this
  444. // 校验产品是否付个促销活动规则
  445. const vaildActive = await salesPromoValidaAudit({ salesBillSn: this.bizSn || this.$route.params.sn }).then(res => res.data)
  446. if (vaildActive && vaildActive.length > 0) {
  447. const a = vaildActive.filter(item => item.type == 1) // 不可提交
  448. const b = vaildActive.filter(item => item.type == 0) // 可跳过继续提交
  449. const d = vaildActive.filter(item => item.type == 'audit') // 售价是否低于参考成本价
  450. // 弹出不符合规则弹框,不可提交
  451. if (a.length) {
  452. this.$info({
  453. title: '提示',
  454. centered: true,
  455. class: 'confirm-center',
  456. okText: '关闭',
  457. width: 600,
  458. content: <div style="padding-top:15px;">
  459. <ol>
  460. {a.map(item => (
  461. <li style="padding:3px 0;">{item.message}</li>
  462. ))}
  463. </ol>
  464. <div style="padding:10px 0;text-align:center"><strong>请按照以上提示修改后再提交</strong></div>
  465. </div>
  466. })
  467. this.spinning = false
  468. } else if (b.length) {
  469. // 弹出确认提示信息,可跳过继续提交
  470. _this.$confirm({
  471. title: '提示',
  472. centered: true,
  473. class: 'confirm-center',
  474. okText: '提交',
  475. width: 600,
  476. content: <div style="padding-top:15px;">
  477. <ol>
  478. {b.map(item => (
  479. <li style="padding:3px 0;">{item.message}</li>
  480. ))}
  481. </ol>
  482. </div>,
  483. onOk () {
  484. _this.verificationSuccess(isBatch)
  485. }
  486. })
  487. _this.spinning = false
  488. } else if (d.length) {
  489. _this.tempData = d[0]
  490. // 售价是否低于参考成本价
  491. if (isBatch) { // 一键审核
  492. const codeStr = _this.tempData.salesPromoDetailEntityList.map(item => item.productCode)
  493. // 直接提示文字信息
  494. _this.messageInfo(codeStr + '售价已低于成本价,不可一键审核!')
  495. } else {
  496. _this.openVaildPriceModal = true
  497. }
  498. } else {
  499. this.verificationSuccess(isBatch)
  500. }
  501. } else {
  502. this.verificationSuccess(isBatch)
  503. }
  504. },
  505. // 消息提示
  506. messageInfo (content) {
  507. this.$info({
  508. title: '提示',
  509. content: content,
  510. centered: true
  511. })
  512. },
  513. // 验证通过
  514. verificationSuccess (isBatch) {
  515. if (isBatch) { // 一键审核
  516. if (this.$refs.productList.hasOutStockOfActive) {
  517. this.messageInfo('参加促销活动的产品存在缺货,不可一键审核!')
  518. return
  519. }
  520. if (this.$refs.productList.showConvertPromoGifts) {
  521. this.messageInfo('该活动规则中,促销产品可转费用报销单,不可一键审核!')
  522. return
  523. }
  524. if (this.$refs.productList.hasJGtire) {
  525. this.messageInfo('销售单内有品牌是【箭冠】,且三级分类是【轮胎】的产品,不可一键审核!')
  526. return
  527. }
  528. // 一键审核成功
  529. this.showDsModal = true
  530. this.$refs.dsModal.setDetail(this.detailData)
  531. } else {
  532. this.auditText = null
  533. this.visibleAudit = true
  534. }
  535. },
  536. // 一键审核
  537. handleOnceAudit (data) {
  538. const params = {
  539. salesBillSn: this.bizSn || this.$route.params.sn,
  540. billStatus: 'AUDIT_PASS',
  541. dispatchBill: data
  542. }
  543. this.spinningAudit = true
  544. this.spinning = true
  545. salesWriteAuditPush(params).then(res => {
  546. if (res.status == 200) {
  547. this.$message.success(res.message)
  548. // 关闭详情跳列表
  549. this.handleBack()
  550. }
  551. this.spinningAudit = false
  552. this.spinning = false
  553. })
  554. },
  555. // 审核
  556. auditOrder (billStatus) {
  557. this.spinningAudit = true
  558. const auditFun = billStatus == 'AUDIT_PASS' ? salesWriteAuditPass : salesWriteAuditReject
  559. auditFun({
  560. salesBillSn: this.bizSn || this.$route.params.sn,
  561. billStatus: billStatus
  562. }).then(res => {
  563. if (res.status == 200) {
  564. this.visibleAudit = false
  565. this.$message.success(res.message)
  566. this.spinningAudit = false
  567. const _this = this
  568. this.$nextTick(() => {
  569. if (billStatus == 'AUDIT_PASS' && !_this.auditText) {
  570. _this.$router.push({ name: 'waitDispatchNew', params: { salesBillSn: _this.bizSn || _this.$route.params.sn } })
  571. } else {
  572. // 关闭详情跳列表
  573. _this.handleBack()
  574. }
  575. })
  576. } else {
  577. this.visibleAudit = false
  578. this.spinningAudit = false
  579. }
  580. })
  581. },
  582. // 打印导出弹框
  583. handlePrint (type, authCode) {
  584. const _this = this
  585. _this.$store.state.app.curActionPermission = authCode
  586. // 销售分类导出
  587. if (type == 'typeExport') {
  588. const params = {
  589. salesBillSn: this.bizSn || this.$route.params.sn
  590. }
  591. _this.spinning = true
  592. exportExcel(salesDetailTypeExcel, params, '销售分类' + moment().format('YYYYMMDDHHmmss'), () => {
  593. _this.spinning = false
  594. _this.$store.state.app.curActionPermission = ''
  595. })
  596. } else {
  597. this.detailData.authCode = authCode
  598. this.nowType = type
  599. this.openModal = true
  600. }
  601. },
  602. // 关闭打印弹框
  603. closePrint () {
  604. this.$store.state.app.curActionPermission = ''
  605. this.openModal = false
  606. },
  607. // 确定打印或预览,导出
  608. handleOk (objs) {
  609. const _this = this
  610. const params = JSON.parse(JSON.stringify(objs))
  611. _this.$store.state.app.curActionPermission = this.detailData.authCode
  612. delete params.type
  613. _this.spinning = true
  614. if (this.nowType == 'export') { // 导出
  615. exportExcel(salesDetailExcel, params, '销售' + moment().format('YYYYMMDDHHmmss'), () => {
  616. _this.spinning = false
  617. _this.$store.state.app.curActionPermission = ''
  618. })
  619. } else { // 打印
  620. const taskName = this.nowType == 'SALES_BILL' ? '销售单' : '销售分类'
  621. printFun(salesDetailPrint, params, objs.type, taskName, () => {
  622. _this.spinning = false
  623. _this.$store.state.app.curActionPermission = ''
  624. })
  625. }
  626. }
  627. },
  628. mounted () {
  629. if (!this.$store.state.app.isNewTab || this.bizSn) { // 页签刷新时调用
  630. this.getDetail()
  631. }
  632. },
  633. activated () {
  634. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  635. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  636. this.getDetail()
  637. }
  638. },
  639. beforeRouteEnter (to, from, next) {
  640. next(vm => {
  641. vm.fromRouter = from
  642. vm.authCode = to.meta.permission
  643. })
  644. }
  645. }
  646. </script>
  647. <style lang="less">
  648. .salesDetail-wrap{
  649. position: relative;
  650. height: 100%;
  651. padding-bottom: 45px;
  652. box-sizing: border-box;
  653. >.ant-spin-nested-loading{
  654. overflow-y: auto;
  655. height: 100%;
  656. }
  657. .salesDetail-cont{
  658. margin-bottom: 6px;
  659. }
  660. .active-title{
  661. display: flex;
  662. align-items: center;
  663. justify-content: space-between;
  664. padding: 10px;
  665. background: #f3f8fa;
  666. }
  667. .flexBox{
  668. display: flex;
  669. justify-content: space-between;
  670. align-items: center;
  671. }
  672. .footer-cont{
  673. margin-top: 5px;
  674. text-align: center;
  675. }
  676. .redStyle{
  677. font-weight: bold;
  678. color: red;
  679. }
  680. }
  681. </style>