detail.vue 35 KB

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