detail.vue 42 KB

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