detail.vue 37 KB

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