detail.vue 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780
  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.spinning = true
  453. getThirdStockQty({ salesBillSn: this.bizSn || this.$route.params.sn }).then(res => {
  454. if (res.status == 200) {
  455. this.$refs.productList.showThreeStock()
  456. this.resetSearchForm()
  457. }
  458. this.spinning = false
  459. })
  460. },
  461. // 详情
  462. getDetail () {
  463. salesDetailBySn({ salesBillSn: this.bizSn || this.$route.params.sn }).then(res => {
  464. if (res.status == 200) {
  465. this.detailData = res.data || null
  466. this.detailData.totalDiscountAmount = Number(this.detailData.totalOrigAmount || 0) - Number(this.detailData.totalAmount || 0)
  467. }
  468. this.$refs.productList.pageInit()
  469. })
  470. },
  471. // 打开缺货明细弹框
  472. openStockOut () {
  473. if (this.$refs.productList.outStockStr != '') {
  474. this.showStockOut = true
  475. } else {
  476. this.$info({
  477. title: '提示',
  478. content: '此销售单暂无缺货产品!',
  479. centered: true
  480. })
  481. }
  482. },
  483. // 下推
  484. handleDispatch (row) {
  485. this.$router.push({ name: 'waitDispatchNew', params: { salesBillSn: row.salesBillSn } })
  486. },
  487. // 验证转单
  488. handleOrder () {
  489. const _this = this
  490. if (!_this.selectedDealerSn) {
  491. _this.$message.warning('请选择发货经销商!')
  492. return
  493. }
  494. transferVerify({ salesBillSn: _this.$route.params.sn, transferDealerSn: _this.selectedDealerSn }).then(res => {
  495. if (res.status == 200) {
  496. if (res.data && Object.keys(res.data).length) {
  497. _this.$confirm({
  498. title: '提示',
  499. content: <div><strong style="color:#ed1c24;">{res.data.dealerName}</strong>非<strong style="color:#ed1c24;">{res.data.buyerName}</strong>的轮胎上级或省仓,提交后待上级审核通过完成转单</div>,
  500. centered: true,
  501. closable: true,
  502. okText: '提交',
  503. onOk () {
  504. _this.spinning = true
  505. // 验证成功
  506. _this.handleTransfer()
  507. }
  508. })
  509. } else {
  510. this.handleTransfer()
  511. }
  512. }
  513. })
  514. },
  515. // 转单
  516. handleTransfer () {
  517. transfer({ salesBillSn: this.$route.params.sn, transferDealerSn: this.selectedDealerSn }).then(res => {
  518. if (res.status == 200) {
  519. this.spinning = false
  520. this.$message.success(res.message)
  521. // 转单成功 关闭详情跳列表
  522. this.handleBack()
  523. }
  524. })
  525. },
  526. // 打开 转单审核弹窗
  527. handleTransferAudit () {
  528. this.openTransferOrder = true
  529. },
  530. // 转单审核
  531. transferOrderAuditOk (val) {
  532. transferAudit({ salesBillSn: this.$route.params.sn, auditPassFlag: val }).then(res => {
  533. if (res.status == 200) {
  534. this.openTransferOrder = false
  535. this.$message.success(res.message)
  536. // 转单成功 关闭详情跳列表
  537. this.handleBack()
  538. }
  539. })
  540. },
  541. // 打开审核/一键审核弹框
  542. async handleAudit (isBatch) {
  543. // 校验产品是否付个促销活动规则
  544. const vaildActive = await salesPromoValidaSubmit({ salesBillSn: this.bizSn || this.$route.params.sn }).then(res => res.data)
  545. if (vaildActive && vaildActive.length > 0) {
  546. const a = vaildActive.filter(item => item.type == 1) // 不可提交
  547. const b = vaildActive.filter(item => item.type == 0) // 可跳过继续提交
  548. // 弹出不符合规则弹框,不可提交
  549. if (a.length) {
  550. this.$info({
  551. title: '提示',
  552. centered: true,
  553. class: 'confirm-center',
  554. okText: '关闭',
  555. width: 600,
  556. content: <div style="padding-top:15px;">
  557. <ol>
  558. {a.map(item => (
  559. <li style="padding:3px 0;">{item.message}</li>
  560. ))}
  561. </ol>
  562. <div style="padding:10px 0;text-align:center"><strong>请按照以上提示修改后再提交</strong></div>
  563. </div>
  564. })
  565. this.spinning = false
  566. } else {
  567. const _this = this
  568. // 弹出确认提示信息,可跳过继续提交
  569. if (b.length) {
  570. _this.$confirm({
  571. title: '提示',
  572. centered: true,
  573. class: 'confirm-center',
  574. okText: '提交',
  575. width: 600,
  576. content: <div style="padding-top:15px;">
  577. <ol>
  578. {b.map(item => (
  579. <li style="padding:3px 0;">{item.message}</li>
  580. ))}
  581. </ol>
  582. </div>,
  583. onOk () {
  584. _this.verificationSuccess(isBatch)
  585. }
  586. })
  587. _this.spinning = false
  588. } else {
  589. _this.verificationSuccess(isBatch)
  590. }
  591. }
  592. } else {
  593. this.verificationSuccess(isBatch)
  594. }
  595. },
  596. // 验证通过
  597. verificationSuccess (isBatch) {
  598. if (isBatch) { // 一键审核
  599. if (this.$refs.productList.hasOutStockOfActive) {
  600. this.$info({
  601. title: '提示',
  602. content: '参加促销活动的产品存在缺货,不可一键审核!',
  603. centered: true
  604. })
  605. return
  606. }
  607. if (this.$refs.productList.showConvertPromoGifts) {
  608. this.$info({
  609. title: '提示',
  610. content: '该活动规则中,促销产品可转费用报销单,不可一键审核!',
  611. centered: true
  612. })
  613. return
  614. }
  615. if (this.$refs.productList.hasJGtire) {
  616. this.$info({
  617. title: '提示',
  618. content: '销售单内有品牌是【箭冠】,且三级分类是【轮胎】的产品,不可一键审核!',
  619. centered: true
  620. })
  621. return
  622. }
  623. // 一键审核成功
  624. this.showDsModal = true
  625. this.$refs.dsModal.setDetail(this.detailData)
  626. } else {
  627. this.auditText = null
  628. this.visibleAudit = true
  629. }
  630. },
  631. // 一键审核
  632. handleOnceAudit (data) {
  633. const params = {
  634. salesBillSn: this.bizSn || this.$route.params.sn,
  635. billStatus: 'AUDIT_PASS',
  636. dispatchBill: data
  637. }
  638. this.spinningAudit = true
  639. this.spinning = true
  640. salesWriteAuditPush(params).then(res => {
  641. if (res.status == 200) {
  642. this.$message.success(res.message)
  643. // 关闭详情跳列表
  644. this.handleBack()
  645. }
  646. this.spinningAudit = false
  647. this.spinning = false
  648. })
  649. },
  650. // 审核
  651. auditOrder (billStatus) {
  652. this.spinningAudit = true
  653. const auditFun = billStatus == 'AUDIT_PASS' ? salesWriteAuditPass : salesWriteAuditReject
  654. auditFun({
  655. salesBillSn: this.bizSn || this.$route.params.sn,
  656. billStatus: billStatus
  657. }).then(res => {
  658. if (res.status == 200) {
  659. this.visibleAudit = false
  660. this.$message.success(res.message)
  661. this.spinningAudit = false
  662. const _this = this
  663. this.$nextTick(() => {
  664. if (billStatus == 'AUDIT_PASS' && !_this.auditText) {
  665. _this.$router.push({ name: 'waitDispatchNew', params: { salesBillSn: _this.bizSn || _this.$route.params.sn } })
  666. } else {
  667. // 关闭详情跳列表
  668. _this.handleBack()
  669. }
  670. })
  671. } else {
  672. this.visibleAudit = false
  673. this.spinningAudit = false
  674. }
  675. })
  676. },
  677. // 打印导出弹框
  678. handlePrint (type, authCode) {
  679. const _this = this
  680. _this.$store.state.app.curActionPermission = authCode
  681. // 销售分类导出
  682. if (type == 'typeExport') {
  683. const params = {
  684. salesBillSn: this.bizSn || this.$route.params.sn
  685. }
  686. _this.spinning = true
  687. exportExcel(salesDetailTypeExcel, params, '销售分类' + moment().format('YYYYMMDDHHmmss'), () => {
  688. _this.spinning = false
  689. _this.$store.state.app.curActionPermission = ''
  690. })
  691. } else {
  692. this.detailData.authCode = authCode
  693. this.nowType = type
  694. this.openModal = true
  695. }
  696. },
  697. // 关闭打印弹框
  698. closePrint () {
  699. this.$store.state.app.curActionPermission = ''
  700. this.openModal = false
  701. },
  702. // 确定打印或预览,导出
  703. handleOk (objs) {
  704. const _this = this
  705. const params = JSON.parse(JSON.stringify(objs))
  706. _this.$store.state.app.curActionPermission = this.detailData.authCode
  707. delete params.type
  708. _this.spinning = true
  709. if (this.nowType == 'export') { // 导出
  710. exportExcel(salesDetailExcel, params, '销售' + moment().format('YYYYMMDDHHmmss'), () => {
  711. _this.spinning = false
  712. _this.$store.state.app.curActionPermission = ''
  713. })
  714. } else { // 打印
  715. const taskName = this.nowType == 'SALES_BILL' ? '销售单' : '销售分类'
  716. printFun(salesDetailPrint, params, objs.type, taskName, () => {
  717. _this.spinning = false
  718. _this.$store.state.app.curActionPermission = ''
  719. })
  720. }
  721. }
  722. },
  723. mounted () {
  724. if (!this.$store.state.app.isNewTab || this.bizSn) { // 页签刷新时调用
  725. this.getDetail()
  726. }
  727. },
  728. activated () {
  729. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  730. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  731. this.getDetail()
  732. }
  733. },
  734. beforeRouteEnter (to, from, next) {
  735. next(vm => {
  736. vm.fromRouter = from
  737. vm.authCode = to.meta.permission
  738. })
  739. }
  740. }
  741. </script>
  742. <style lang="less">
  743. .salesDetail-wrap{
  744. position: relative;
  745. height: 100%;
  746. padding-bottom: 45px;
  747. box-sizing: border-box;
  748. >.ant-spin-nested-loading{
  749. overflow-y: auto;
  750. height: 100%;
  751. }
  752. .salesDetail-cont{
  753. margin-bottom: 6px;
  754. }
  755. .active-title{
  756. display: flex;
  757. align-items: center;
  758. justify-content: space-between;
  759. padding: 10px;
  760. background: #f3f8fa;
  761. }
  762. .flexBox{
  763. display: flex;
  764. justify-content: space-between;
  765. align-items: center;
  766. }
  767. .footer-cont{
  768. margin-top: 5px;
  769. text-align: center;
  770. }
  771. .redStyle{
  772. font-weight: bold;
  773. color: red;
  774. }
  775. }
  776. </style>