detail.vue 42 KB

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