detail.vue 31 KB

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