detail.vue 37 KB

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