detail.vue 35 KB

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