detail.vue 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755
  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" style="margin-bottom: 6px;" >
  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. :maxHeight="pageHeight"
  147. :detailData="detailData"
  148. :warehouseSn="warehouseSn"
  149. :promoFlag="promoFlag"
  150. :salesBillSn="$route.params.sn || bizSn"
  151. :authCode="authCode"
  152. :showCityPrice="isCityPrice">
  153. </detailProductList>
  154. </div>
  155. </a-card>
  156. <!-- 活动产品列表 -->
  157. <a-card
  158. size="small"
  159. :bordered="false"
  160. title="活动产品"
  161. class="salesEdit-cont"
  162. v-if="activeList.length"
  163. >
  164. <activeStatisticsList
  165. ref="activeTjList"
  166. type="view"
  167. :activeList="activeList"
  168. :warehouseSn="warehouseSn"
  169. :salesBillSn="$route.params.sn || bizSn"
  170. ></activeStatisticsList>
  171. <detailProductList
  172. ref="productActiveList"
  173. type="active"
  174. :detailData="detailData"
  175. :warehouseSn="warehouseSn"
  176. :promoFlag="promoFlag"
  177. :salesBillSn="$route.params.sn || bizSn"
  178. :authCode="authCode"
  179. :showCityPrice="isCityPrice">
  180. </detailProductList>
  181. </a-card>
  182. </a-spin>
  183. <div class="affix-cont" :style="{padding:hideFooter?0:'7px 0 4px'}">
  184. <a-button
  185. style="width: 100px;"
  186. :disabled="spinning"
  187. type="primary"
  188. class="button-info"
  189. id="salesDetail-audit-btn"
  190. v-if="(detailData&&(detailData.billStatus == 'WAIT_AUDIT'||detailData.billStatus=='WAIT_UP_AUDIT_PASS'))&&$hasPermissions('B_salesAudit')"
  191. @click="handleAudit()"
  192. >
  193. 审核
  194. </a-button>
  195. <a-button
  196. type="primary"
  197. :disabled="spinning"
  198. style="width: 100px;margin: 0 20px;"
  199. id="salesDetail-edit-btn"
  200. 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')"
  201. @click="handleEdit()"
  202. >
  203. 编辑
  204. </a-button>
  205. <a-button
  206. style="width: 100px;margin: 0 20px;"
  207. :disabled="spinning"
  208. type="primary"
  209. id="salesDetail-edit1-btn"
  210. v-if="detailData&&detailData.salesBillSource == 'PURCHASE' && (detailData.billStatus == 'WAIT_AUDIT'||detailData.billStatus == 'HQ_CHANGE')&&$hasPermissions('B_salesEdit')"
  211. @click="handleChangeOrder()"
  212. >
  213. 改单
  214. </a-button>
  215. <a-button
  216. style="width: 100px;"
  217. :disabled="spinning"
  218. type="primary"
  219. class="button-success"
  220. id="salesDetail-batchAudit-btn"
  221. v-if="detailData&&detailData.billStatus == 'WAIT_AUDIT'&&$hasPermissions('B_salesAudit')"
  222. @click="handleAudit('batch')"
  223. >
  224. 一键审核
  225. </a-button>
  226. <a-button
  227. id="salesDetail-dispatch"
  228. style="width: 100px;"
  229. type="primary"
  230. class="button-warning"
  231. v-if="detailData&&detailData.billStatus == 'WAIT_PUSH'&&$hasPermissions('B_salesDispatch')"
  232. @click="handleDispatch(detailData)"
  233. >下推</a-button>
  234. </div>
  235. <!-- 打印导出 -->
  236. <print-modal :openModal="openModal" :itemData="detailData" :nowType="nowType" @ok="handleOk" @close="closePrint" />
  237. <!-- 审核 -->
  238. <auditModal
  239. :openModal="visibleAudit"
  240. :content="auditText"
  241. :spinning="spinningAudit"
  242. @close="visibleAudit=false"
  243. @ok="auditOrder('AUDIT_PASS')"
  244. @fail="auditOrder('AUDIT_REJECT')" />
  245. <!-- 审核加下推 -->
  246. <dsModal ref="dsModal" title="销售单一键审核" :openModal="showDsModal" @close="showDsModal=false" @ok="handleOnceAudit" />
  247. <!-- 缺货明细 -->
  248. <stockOutDetail :openModal="showStockOut" :detailData="detailData" :salesBillSn="$route.params.sn || bizSn" @close="showStockOut=false"></stockOutDetail>
  249. <!-- 改单时价格变更提示 -->
  250. <tipModal ref="tipModal" :openModal="openTipModal" :dataList="sourceData" @close="closeTipModal" @ok="openTipModalOk"></tipModal>
  251. <!-- 审核时校验销售价低于成本价提示 -->
  252. <vaildPriceModal
  253. ref="vaildPriceModal"
  254. modalType="0"
  255. :openModal="openVaildPriceModal"
  256. :dataObj="tempData"
  257. @close="openVaildPriceModal=false"
  258. @ok="vaildPriceOk"></vaildPriceModal>
  259. </div>
  260. </template>
  261. <script>
  262. import { printFun, exportExcel } from '@/libs/JGPrint.js'
  263. import { commonMixin } from '@/utils/mixin'
  264. import moment from 'moment'
  265. import { VSelect } from '@/components'
  266. import printModal from './printModal.vue'
  267. import auditModal from '@/views/common/auditModal.vue'
  268. import dsModal from '@/views/salesManagement/waitDispatchNew/dsModal.vue'
  269. import stockOutDetail from './stockOutDetailModal.vue'
  270. import chooseWarehouse from '@/views/common/chooseWarehouse'
  271. import detailProductList from './comps/detailProductList.vue'
  272. import activeStatisticsList from './comps/activeStatisticsList.vue'
  273. import tipModal from './tipModal.vue'
  274. import vaildPriceModal from './vaildPriceModal.vue'
  275. // 接口
  276. import {
  277. salesPromoQueryList,
  278. salesDetailBySn,
  279. salesDetailPrint,
  280. salesDetailExcel,
  281. salesDetailTypeExcel,
  282. salesWriteAuditPass,
  283. salesWriteUpAuditPass,
  284. salesWriteAuditReject,
  285. salesWriteAuditPush,
  286. getThirdStockQty,
  287. salesPromoValidaAudit,
  288. changeBillCheckUpdatePrice,
  289. changeBillCheck } from '@/api/salesNew'
  290. export default {
  291. name: 'SalesDetailNew',
  292. mixins: [commonMixin],
  293. components: { VSelect, printModal, auditModal, dsModal, stockOutDetail, chooseWarehouse, detailProductList, activeStatisticsList, tipModal, vaildPriceModal },
  294. props: {
  295. bizSn: { // 有值则为弹框,无值则为页面
  296. type: [Number, String],
  297. default: ''
  298. }
  299. },
  300. data () {
  301. return {
  302. spinning: false,
  303. disabled: false,
  304. showDsModal: false, // 一键审核弹框
  305. showStockOut: false, // 缺货明细弹框
  306. activeList: [], // 参与活动列表
  307. authCode: '', // 权限码
  308. hasData: false, // 是否有数据
  309. showDetail: false, // 基础信息是否显示
  310. openModal: false, // 打印导出弹框
  311. detailData: null, // 详情数据
  312. nowType: null, // 打印导出类型
  313. isCityPrice: false, // 是否显示市级价
  314. visibleAudit: false, // 审核弹框
  315. spinningAudit: false, // 审核loading
  316. auditText: null, // 审核备注信息
  317. fromRouter: null, // 从那个页面打开当前页面
  318. warehouseSn: undefined, // 所在仓库
  319. promoFlag: undefined, // 产品类型
  320. openTipModal: false, // 改单弹窗
  321. sourceData: undefined, // 价格变动数据
  322. tempData: undefined, // 校验临时数据
  323. openVaildPriceModal: false // 校验价格弹框
  324. }
  325. },
  326. computed: {
  327. // 详细地址
  328. shippingAddress () {
  329. const shippingAddrProvinceName = this.detailData && this.detailData.salesBillExtEntity && this.detailData.salesBillExtEntity.shippingAddrProvinceName ? this.detailData.salesBillExtEntity.shippingAddrProvinceName : ''
  330. const shippingAddrCityName = this.detailData && this.detailData.salesBillExtEntity && this.detailData.salesBillExtEntity.shippingAddrCityName ? this.detailData.salesBillExtEntity.shippingAddrCityName : ''
  331. const shippingAddrCountyName = this.detailData && this.detailData.salesBillExtEntity && this.detailData.salesBillExtEntity.shippingAddrCountyName ? this.detailData.salesBillExtEntity.shippingAddrCountyName : ''
  332. const shippingAddr = this.detailData && this.detailData.salesBillExtEntity && this.detailData.salesBillExtEntity.shippingAddr ? this.detailData.salesBillExtEntity.shippingAddr : ''
  333. if (!shippingAddrProvinceName && !shippingAddrCityName && !shippingAddrCountyName && !shippingAddr) {
  334. return '--'
  335. } else {
  336. return shippingAddrProvinceName + shippingAddrCityName + shippingAddrCountyName + shippingAddr
  337. }
  338. },
  339. // 是否隐藏底部栏按钮
  340. hideFooter () {
  341. const detailData = this.detailData
  342. return detailData && (detailData.billStatus == 'HQ_CHANGE' || (detailData.salesBillSource != 'SALES' && detailData.billStatus == 'AUDIT_REJECT') || detailData.billStatus == 'FINISH' || detailData.billStatus == 'OUTING_WAREHOUSE')
  343. },
  344. // 是否有促销活动产品
  345. hasPrompActive () {
  346. return this.detailData && this.detailData.promoFlag == 1
  347. },
  348. // 是否有可转采购额
  349. hasConvertPromoGifts () {
  350. return this.detailData && this.detailData.totalConvertPromoGiftsQty
  351. },
  352. // 是否有促销产品(转采购额)
  353. showConvertPromoGifts () {
  354. return this.activeList && this.activeList.filter(item => item.enabledFlag == 1).find(item => item.promotionRule && item.promotionRule.convertExpenseFlag == 1 && item.promotionRule.promotionRuleType == 'BUY_PROD_GIVE_PROD')
  355. },
  356. // 是否显示库存列
  357. showStock () {
  358. return this.detailData && (this.detailData.billStatus == 'WAIT_AUDIT' || this.detailData.billStatus == 'HQ_CHANGE') && this.$hasPermissions('B_salesAudit')
  359. },
  360. // 表格高度计算
  361. pageHeight () {
  362. return this.activeList.length == 0 ? window.innerHeight - 315 + (this.hideFooter ? 45 : 0) : 302
  363. }
  364. },
  365. methods: {
  366. // 返回
  367. handleBack () {
  368. this.$router.push({ name: 'salesQueryNewList' })
  369. },
  370. // 编辑
  371. handleEdit () {
  372. const row = this.detailData
  373. this.$router.push({ name: 'salesNewEdit', params: { sn: row.salesBillSn, wSn: row.warehouseSn } })
  374. },
  375. // 改单
  376. handleChangeOrder () {
  377. const _this = this
  378. const row = _this.detailData
  379. changeBillCheck({ salesBillSn: row.salesBillSn }).then(res => {
  380. let data
  381. if (res.status == 200) {
  382. data = res.data
  383. if (data && data.length > 0) {
  384. _this.sourceData = res.data
  385. const obj = {
  386. buyerName: row.buyerName,
  387. salesBillNo: row.salesBillNo
  388. }
  389. _this.$refs.tipModal.getShowInfo(obj)
  390. _this.openTipModal = true
  391. } else {
  392. _this.$router.push({ name: 'salesNewEdit', params: { sn: row.salesBillSn, wSn: row.warehouseSn } })
  393. }
  394. }
  395. })
  396. },
  397. // 改单成功 关闭弹窗
  398. openTipModalOk (ajaxData) {
  399. const row = this.detailData
  400. ajaxData.salesBillSn = row.salesBillSn
  401. ajaxData.detailList = this.sourceData
  402. changeBillCheckUpdatePrice(ajaxData).then(res => {
  403. if (res.status == 200) {
  404. this.$message.success(res.message)
  405. this.openTipModal = false
  406. this.$nextTick(() => {
  407. this.$router.push({ name: 'salesNewEdit', params: { sn: row.salesBillSn, wSn: row.warehouseSn } })
  408. })
  409. }
  410. })
  411. },
  412. // 取消时,跳转编辑页面
  413. closeTipModal () {
  414. this.openTipModal = false
  415. this.$router.push({ name: 'salesNewEdit', params: { sn: this.$route.params.sn || this.bizSn } })
  416. },
  417. // 价格低于成本校验提示,继续审核
  418. vaildPriceOk (type) {
  419. // 不通过
  420. if (type == 'AUDIT_REJECT') {
  421. this.auditOrder(type)
  422. } else {
  423. // 如果时 待上级审核,调用
  424. if (this.detailData.billStatus == 'WAIT_UP_AUDIT_PASS') {
  425. this.auditOrder(type)
  426. return
  427. }
  428. this.spinning = true
  429. // 通过,业务状态变更 待上级审核
  430. salesWriteUpAuditPass({
  431. salesBillSn: this.bizSn || this.$route.params.sn,
  432. billStatus: type
  433. }).then(res => {
  434. if (res.status == 200) {
  435. this.$message.success(res.message)
  436. this.handleBack()
  437. }
  438. this.$refs.vaildPriceModal.spinning = false
  439. this.spinning = false
  440. })
  441. }
  442. },
  443. // 查询第三方库存
  444. getThreeStock () {
  445. this.spinning = true
  446. getThirdStockQty({ salesBillSn: this.bizSn || this.$route.params.sn }).then(res => {
  447. if (res.status == 200) {
  448. this.$refs.productList.showThreeStock()
  449. this.resetSearchForm()
  450. }
  451. this.spinning = false
  452. })
  453. },
  454. // 重置
  455. resetSearchForm () {
  456. this.warehouseSn = undefined
  457. this.promoFlag = undefined
  458. setTimeout(() => {
  459. this.searchTable()
  460. }, 100)
  461. },
  462. // 查询数据
  463. searchTable () {
  464. this.$refs.productList.searchTable()
  465. if (this.activeList.length) this.$refs.productActiveList.searchTable()
  466. },
  467. // 详情
  468. getDetail () {
  469. salesDetailBySn({ salesBillSn: this.bizSn || this.$route.params.sn }).then(res => {
  470. if (res.status == 200) {
  471. this.detailData = res.data || null
  472. this.detailData.totalDiscountAmount = Number(this.detailData.totalOrigAmount || 0) - Number(this.detailData.totalAmount || 0)
  473. }
  474. this.getActiveList()
  475. })
  476. },
  477. // 获取销售单参与的活动列表
  478. async getActiveList () {
  479. // 已参与活动列表
  480. const list = await salesPromoQueryList({ salesBillSn: this.$route.params.sn || this.bizSn }).then(res => res.data || [])
  481. this.activeList = list.filter(item => item.promotion && item.promotionRule)
  482. // 触发活动统计查询变量
  483. this.$nextTick(() => {
  484. if (this.activeList.length) {
  485. this.$refs.activeTjList.hasInit = false
  486. }
  487. })
  488. setTimeout(() => {
  489. this.resetSearchForm()
  490. }, 500)
  491. },
  492. // 打开缺货明细弹框
  493. openStockOut () {
  494. if (this.$refs.productList.outStockStr != '') {
  495. this.showStockOut = true
  496. } else {
  497. this.$info({
  498. title: '提示',
  499. content: '此销售单暂无缺货产品!',
  500. centered: true
  501. })
  502. }
  503. },
  504. // 下推
  505. handleDispatch (row) {
  506. this.$router.push({ name: 'waitDispatchNew', params: { salesBillSn: row.salesBillSn } })
  507. },
  508. // 打开审核/一键审核弹框
  509. async handleAudit (isBatch) {
  510. const _this = this
  511. // 校验产品是否付个促销活动规则
  512. const vaildActive = await salesPromoValidaAudit({ salesBillSn: this.bizSn || this.$route.params.sn }).then(res => res.data)
  513. if (vaildActive && vaildActive.length > 0) {
  514. const a = vaildActive.filter(item => item.type == 1) // 不可提交
  515. const b = vaildActive.filter(item => item.type == 0) // 可跳过继续提交
  516. const d = vaildActive.filter(item => item.type == 'audit') // 售价是否低于参考成本价
  517. // 弹出不符合规则弹框,不可提交
  518. if (a.length) {
  519. this.$info({
  520. title: '提示',
  521. centered: true,
  522. class: 'confirm-center',
  523. okText: '关闭',
  524. width: 600,
  525. content: <div style="padding-top:15px;">
  526. <ol>
  527. {a.map(item => (
  528. <li style="padding:3px 0;">{item.message}</li>
  529. ))}
  530. </ol>
  531. <div style="padding:10px 0;text-align:center"><strong>请按照以上提示修改后再提交</strong></div>
  532. </div>
  533. })
  534. this.spinning = false
  535. } else if (b.length) {
  536. // 弹出确认提示信息,可跳过继续提交
  537. _this.$confirm({
  538. title: '提示',
  539. centered: true,
  540. class: 'confirm-center',
  541. okText: '提交',
  542. width: 600,
  543. content: <div style="padding-top:15px;">
  544. <ol>
  545. {b.map(item => (
  546. <li style="padding:3px 0;">{item.message}</li>
  547. ))}
  548. </ol>
  549. </div>,
  550. onOk () {
  551. _this.verificationSuccess(isBatch)
  552. }
  553. })
  554. _this.spinning = false
  555. } else if (d.length) {
  556. // 售价是否低于参考成本价
  557. if (isBatch) { // 一键审核
  558. _this.tempData = { vaildPriceList: d[0].salesPromoDetailEntityList.map(item => item.productCode) }
  559. this.verificationSuccess(isBatch)
  560. } else {
  561. // 审核
  562. _this.tempData = d[0]
  563. _this.openVaildPriceModal = true
  564. }
  565. } else {
  566. this.verificationSuccess(isBatch)
  567. }
  568. } else {
  569. this.verificationSuccess(isBatch)
  570. }
  571. },
  572. // 消息提示
  573. messageInfo (content) {
  574. this.$info({
  575. title: '提示',
  576. content: content,
  577. centered: true
  578. })
  579. },
  580. // 验证通过
  581. verificationSuccess (isBatch) {
  582. if (isBatch) { // 一键审核
  583. if (this.$refs.productList.hasOutStockOfActive) {
  584. this.messageInfo('参加促销活动的产品存在缺货,不可一键审核!')
  585. return
  586. }
  587. if (this.$refs.productList.showConvertPromoGifts) {
  588. this.messageInfo('该活动规则中,促销产品可转费用报销单,不可一键审核!')
  589. return
  590. }
  591. if (this.$refs.productList.hasJGtire) {
  592. this.messageInfo('销售单内有品牌是【箭冠】,且三级分类是【轮胎】的产品,不可一键审核!')
  593. return
  594. }
  595. if (this.tempData && this.tempData.vaildPriceList) {
  596. this.messageInfo(this.tempData.vaildPriceList + '售价已低于成本价,不可一键审核!')
  597. return
  598. }
  599. // 一键审核成功
  600. this.showDsModal = true
  601. this.$refs.dsModal.setDetail(this.detailData)
  602. } else {
  603. this.auditText = null
  604. this.visibleAudit = true
  605. }
  606. },
  607. // 一键审核
  608. handleOnceAudit (data) {
  609. const params = {
  610. salesBillSn: this.bizSn || this.$route.params.sn,
  611. billStatus: 'AUDIT_PASS',
  612. dispatchBill: data
  613. }
  614. this.spinningAudit = true
  615. this.spinning = true
  616. salesWriteAuditPush(params).then(res => {
  617. if (res.status == 200) {
  618. this.$message.success(res.message)
  619. // 关闭详情跳列表
  620. this.handleBack()
  621. }
  622. this.spinningAudit = false
  623. this.spinning = false
  624. })
  625. },
  626. // 审核
  627. auditOrder (billStatus) {
  628. this.spinningAudit = true
  629. const auditFun = billStatus == 'AUDIT_PASS' ? salesWriteAuditPass : salesWriteAuditReject
  630. auditFun({
  631. salesBillSn: this.bizSn || this.$route.params.sn,
  632. billStatus: billStatus
  633. }).then(res => {
  634. if (res.status == 200) {
  635. this.visibleAudit = false
  636. this.$message.success(res.message)
  637. this.spinningAudit = false
  638. const _this = this
  639. this.$nextTick(() => {
  640. if (billStatus == 'AUDIT_PASS' && !_this.auditText) {
  641. _this.$router.push({ name: 'waitDispatchNew', params: { salesBillSn: _this.bizSn || _this.$route.params.sn } })
  642. } else {
  643. // 关闭详情跳列表
  644. _this.handleBack()
  645. }
  646. })
  647. } else {
  648. this.visibleAudit = false
  649. this.spinningAudit = false
  650. }
  651. })
  652. },
  653. // 打印导出弹框
  654. handlePrint (type, authCode) {
  655. const _this = this
  656. _this.$store.state.app.curActionPermission = authCode
  657. // 销售分类导出
  658. if (type == 'typeExport') {
  659. const params = {
  660. salesBillSn: this.bizSn || this.$route.params.sn
  661. }
  662. _this.spinning = true
  663. exportExcel(salesDetailTypeExcel, params, '销售分类' + moment().format('YYYYMMDDHHmmss'), () => {
  664. _this.spinning = false
  665. _this.$store.state.app.curActionPermission = ''
  666. })
  667. } else {
  668. this.detailData.authCode = authCode
  669. this.nowType = type
  670. this.openModal = true
  671. }
  672. },
  673. // 关闭打印弹框
  674. closePrint () {
  675. this.$store.state.app.curActionPermission = ''
  676. this.openModal = false
  677. },
  678. // 确定打印或预览,导出
  679. handleOk (objs) {
  680. const _this = this
  681. const params = JSON.parse(JSON.stringify(objs))
  682. _this.$store.state.app.curActionPermission = this.detailData.authCode
  683. delete params.type
  684. _this.spinning = true
  685. if (this.nowType == 'export') { // 导出
  686. exportExcel(salesDetailExcel, params, '销售' + moment().format('YYYYMMDDHHmmss'), () => {
  687. _this.spinning = false
  688. _this.$store.state.app.curActionPermission = ''
  689. })
  690. } else { // 打印
  691. const taskName = this.nowType == 'SALES_BILL' ? '销售单' : '销售分类'
  692. printFun(salesDetailPrint, params, objs.type, taskName, () => {
  693. _this.spinning = false
  694. _this.$store.state.app.curActionPermission = ''
  695. })
  696. }
  697. }
  698. },
  699. mounted () {
  700. if (!this.$store.state.app.isNewTab || this.bizSn) { // 页签刷新时调用
  701. this.getDetail()
  702. }
  703. },
  704. activated () {
  705. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  706. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  707. this.getDetail()
  708. }
  709. },
  710. beforeRouteEnter (to, from, next) {
  711. next(vm => {
  712. vm.fromRouter = from
  713. vm.authCode = to.meta.permission
  714. })
  715. }
  716. }
  717. </script>
  718. <style lang="less">
  719. .salesDetail-wrap{
  720. position: relative;
  721. height: 100%;
  722. padding-bottom: 45px;
  723. box-sizing: border-box;
  724. >.ant-spin-nested-loading{
  725. overflow-y: auto;
  726. height: 100%;
  727. }
  728. .salesDetail-cont{
  729. margin-bottom: 6px;
  730. }
  731. .active-title{
  732. display: flex;
  733. align-items: center;
  734. justify-content: space-between;
  735. padding: 10px;
  736. background: #f3f8fa;
  737. }
  738. .flexBox{
  739. display: flex;
  740. justify-content: space-between;
  741. align-items: center;
  742. }
  743. .footer-cont{
  744. margin-top: 5px;
  745. text-align: center;
  746. }
  747. .redStyle{
  748. font-weight: bold;
  749. color: red;
  750. }
  751. }
  752. </style>