detail.vue 34 KB

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