detailAll.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  1. <template>
  2. <div class="salesDetail-All-wrap">
  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 href="javascript:;" @click="handleBack"><a-icon type="left"></a-icon> 返回列表</a>
  7. </template>
  8. <template slot="extra">
  9. <a-button
  10. key="1"
  11. type="primary"
  12. class="button-info"
  13. id="salesDetail-xs-print-btn"
  14. v-if="$hasPermissions('B_salesPrint')"
  15. :disabled="localDataSource.length==0"
  16. @click="handlePrint('SALES_BILL','B_salesPrint')">销售打印</a-button>
  17. <a-button
  18. key="2"
  19. type="primary"
  20. class="button-info"
  21. id="salesDetail-xsfl-print-btn"
  22. v-if="$hasPermissions('B_salesTypePrint')"
  23. :disabled="localDataSource.length==0"
  24. @click="handlePrint('SALES_BILL_TYPE','B_salesTypePrint')">销售分类打印</a-button>
  25. <a-divider type="vertical" />
  26. <a-button
  27. key="3"
  28. type="default"
  29. class="button-info"
  30. id="salesDetail-export-btn"
  31. v-if="$hasPermissions('B_salesDetailExport')"
  32. :disabled="localDataSource.length==0"
  33. @click="handlePrint('export','B_salesDetailExport')">导出Excel</a-button>
  34. <a-button
  35. key="4"
  36. type="default"
  37. class="button-info"
  38. id="salesDetail-export-btn"
  39. v-if="$hasPermissions('B_salesTypeExport')"
  40. :disabled="localDataSource.length==0"
  41. @click="handlePrint('typeExport','B_salesTypeExport')">销售分类导出</a-button>
  42. </template>
  43. </a-page-header>
  44. <a-card size="small" :bordered="false" class="pages-wrap">
  45. <!-- 基础信息 -->
  46. <a-collapse :activeKey="['1']">
  47. <a-collapse-panel key="1" header="基础信息">
  48. <a-descriptions size="small" :column="3">
  49. <a-descriptions-item label="销售单号" :span="2">
  50. {{ detailData&&detailData.salesBillNo || '--' }}
  51. <span v-if="detailData&&detailData.salesBillNoSource">(原:{{ detailData&&detailData.salesBillNoSource || '--' }})</span>
  52. </a-descriptions-item>
  53. <a-descriptions-item label="客户名称">{{ detailData&&detailData.buyerName || '--' }}</a-descriptions-item>
  54. <a-descriptions-item label="收货地址" :span="2">{{ shippingAddress }}</a-descriptions-item>
  55. <a-descriptions-item label="收款方式">{{ detailData&&detailData.settleStyleSnDictValue || '--' }}</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.auditDate || '--' }}</a-descriptions-item>
  59. <a-descriptions-item label="业务状态">{{ detailData&&detailData.billStatusDictValue || '--' }}</a-descriptions-item>
  60. <a-descriptions-item label="财务状态">{{ detailData&&detailData.financialStatusDictValue || '--' }}</a-descriptions-item>
  61. <a-descriptions-item label="备注" :span="3">{{ detailData&&detailData.remarks || '--' }}</a-descriptions-item>
  62. </a-descriptions>
  63. </a-collapse-panel>
  64. </a-collapse>
  65. <!-- 统计信息 -->
  66. <a-alert type="info" style="margin: 10px 0;">
  67. <div slot="message">
  68. <div>
  69. 总销售数量:<strong>{{ detailData&&(detailData.totalQty || detailData.totalQty==0) ? detailData.totalQty : '--' }}</strong>;
  70. 已取消数量:<strong>{{ detailData&&(detailData.totalCancelQty || detailData.totalCancelQty==0) ? detailData.totalCancelQty : '--' }}</strong>;
  71. 已下推数量:<strong>{{ detailData&&(detailData.totalPushedQty || detailData.totalPushedQty==0) ? detailData.totalPushedQty : '--' }}</strong>;
  72. 待下推数量:<strong>{{ detailData&&(detailData.totalUnpushedQty || detailData.totalUnpushedQty==0) ? detailData.totalUnpushedQty : '--' }}</strong>;
  73. 已发货数量:<strong>{{ detailData&&(detailData.totalDispatchQty || detailData.totalDispatchQty==0) ? detailData.totalDispatchQty : '--' }}</strong>;
  74. 待发货数量:<strong>{{ detailData&&(detailData.totalUndispatchQty || detailData.totalUndispatchQty==0) ? detailData.totalUndispatchQty : '--' }}</strong>;<br/>
  75. <span v-if="$hasPermissions(authCode + '_salesPrice')">总售价:<strong>{{ detailData&&(detailData.totalAmount || detailData.totalAmount==0) ? toThousands(detailData.totalAmount) : '--' }}</strong>;</span>
  76. <span v-if="$hasPermissions(authCode + '_costPrice')">总成本:<strong>{{ detailData&&(detailData.totalCost || detailData.totalCost==0) ? toThousands(detailData.totalCost) : '--' }}</strong>;</span>
  77. <span v-if="$hasPermissions(authCode + '_costPrice')">总毛利:<strong>{{ detailData&&(detailData.grossProfit || detailData.grossProfit==0) ? toThousands(detailData.grossProfit) : '--' }}</strong>;</span>
  78. <span v-if="$hasPermissions(authCode + '_salesPrice')">已取消金额:<strong>{{ detailData&&(detailData.totalCancelAmount || detailData.totalCancelAmount==0) ? toThousands(detailData.totalCancelAmount) : '--' }}</strong>;</span>
  79. <span v-if="$hasPermissions(authCode + '_salesPrice')">已下推金额:<strong>{{ detailData&&(detailData.totalPushedAmount || detailData.totalPushedAmount==0) ? toThousands(detailData.totalPushedAmount) : '--' }}</strong>;</span>
  80. <span v-if="$hasPermissions(authCode + '_salesPrice')">待下推金额:<strong>{{ detailData&&(detailData.totalUnpushedAmount || detailData.totalUnpushedAmount==0) ? toThousands(detailData.totalUnpushedAmount) : '--' }}</strong>;</span>
  81. <span v-if="$hasPermissions(authCode + '_salesPrice')">已发货金额:<strong>{{ detailData&&(detailData.totalDispatchAmount || detailData.totalDispatchAmount==0) ? toThousands(detailData.totalDispatchAmount) : '--' }}</strong>;</span>
  82. <span v-if="$hasPermissions(authCode + '_salesPrice')">待发货金额:<strong>{{ detailData&&(detailData.totalUndispatchAmount || detailData.totalUndispatchAmount==0) ? toThousands(detailData.totalUndispatchAmount) : '--' }}</strong>;</span>
  83. <span v-if="isCityPrice">市级总售价:<strong>{{ detailData&&(detailData.totalCityAmount || detailData.totalCityAmount==0) ? toThousands(detailData.totalCityAmount) : '--' }}</strong>;</span>
  84. <span v-if="$hasPermissions(authCode + '_salesPrice')&&detailData&&detailData.totalDiscountAmount" style="color: red;">优惠金额:<strong>{{ toThousands(detailData.totalDiscountAmount) }}</strong>;</span>
  85. </div>
  86. </div>
  87. </a-alert>
  88. <!-- 查询 -->
  89. <div class="table-page-search-wrapper">
  90. <div style="display: flex;justify-content: space-between;align-items: center;">
  91. <div style="flex-grow: 1;width: 60%;">
  92. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  93. <a-row :gutter="15" type="flex">
  94. <a-col :md="6" :sm="24" flex="350px">
  95. <a-form-item label="出库仓库">
  96. <chooseWarehouse ref="warehouse" v-model="queryParam.warehouseSn"></chooseWarehouse>
  97. </a-form-item>
  98. </a-col>
  99. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  100. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="productInfoList-refresh">查询</a-button>
  101. <a-button style="margin-left: 5px" @click="resetSearchForm" id="productInfoList-reset">重置</a-button>
  102. </a-col>
  103. </a-row>
  104. </a-form>
  105. </div>
  106. <div>
  107. <a-button v-if="detailData && (detailData.billStatus == 'WAIT_AUDIT' || detailData.billStatus == 'HQ_CHANGE')" type="link" @click="openStockOut">缺货明细</a-button>
  108. <a-checkbox v-model="isCityPrice" v-if="$hasPermissions(authCode + '_cityPrice')"><span style="display: inline-block;margin-top: 1px;">市级价</span></a-checkbox>
  109. </div>
  110. </div>
  111. </div>
  112. <!-- 列表 -->
  113. <s-table
  114. class="sTable"
  115. ref="table"
  116. size="small"
  117. :rowKey="(record) => record.no"
  118. rowKeyName="no"
  119. :columns="columns"
  120. :data="loadData"
  121. :scroll="{ y: 300 }"
  122. :defaultLoadData="false"
  123. :showPagination="false"
  124. bordered>
  125. <!-- 产品编码 -->
  126. <template slot="productCode" slot-scope="text, record">
  127. <div>
  128. <span>{{ text }}</span>
  129. <a-badge count="促" v-if="record.promotionFlag=='GIFT'" :number-style="{ backgroundColor: '#52c41a', zoom:'80%' }"></a-badge>
  130. <a-badge count="特" v-if="record.promotionFlag=='DISCOUNT'" :number-style="{ backgroundColor: '#faad14', zoom:'80%' }"></a-badge>
  131. <!-- 可审核时才可显示“缺”货产品 -->
  132. <a-badge count="缺" v-if="(Number(record.stockQty) < Number(record.unpushedQty)) && (detailData&&(detailData.billStatus == 'WAIT_AUDIT'||detailData.billStatus == 'HQ_CHANGE')&&$hasPermissions('B_salesAudit'))">
  133. </a-badge>
  134. </div>
  135. </template>
  136. <!-- 当前库存 -->
  137. <template slot="stockQty" slot-scope="text, record">
  138. <div v-if="record.stockQty || record.stockQty==0">
  139. <p style="margin: 0;" v-if="Number(record.stockQty) < Number(record.unpushedQty)">{{ record.stockQty }}(<span class="redStyle">缺{{ Number(record.unpushedQty) - Number(record.stockQty) }}</span>)</p>
  140. <p style="margin: 0;" v-else>{{ record.stockQty }}</p>
  141. </div>
  142. <span v-else>--</span>
  143. </template>
  144. </s-table>
  145. </a-card>
  146. </a-spin>
  147. <div class="affix-cont">
  148. <a-button
  149. size="large"
  150. style="width: 100px;"
  151. :disabled="spinning"
  152. type="primary"
  153. class="button-info"
  154. id="salesDetail-audit-btn"
  155. v-if="detailData&&detailData.billStatus == 'WAIT_AUDIT'&&$hasPermissions('B_salesAudit')"
  156. @click="handleAudit()"
  157. >
  158. 审核
  159. </a-button>
  160. <a-button
  161. type="default"
  162. :disabled="spinning"
  163. class="button-info"
  164. size="large"
  165. style="width: 100px;margin: 0 20px;"
  166. id="salesDetail-edit-btn"
  167. v-if="detailData&&detailData.salesBillSource != 'PURCHASE' && (detailData.billStatus == 'WAIT_SUBMIT' || detailData.billStatus == 'WAIT_AUDIT' || detailData.billStatus == 'AUDIT_REJECT')&&$hasPermissions('B_salesEdit')"
  168. @click="handleEdit()"
  169. >
  170. 编辑
  171. </a-button>
  172. <a-button
  173. size="large"
  174. style="width: 100px;margin: 0 20px;"
  175. :disabled="spinning"
  176. type="default"
  177. class="button-info"
  178. id="salesDetail-edit-btn"
  179. v-if="detailData&&detailData.salesBillSource == 'PURCHASE' && (detailData.billStatus == 'WAIT_AUDIT'||detailData.billStatus == 'HQ_CHANGE')&&$hasPermissions('B_salesEdit')"
  180. @click="handleEdit()"
  181. >
  182. 改单
  183. </a-button>
  184. <a-button
  185. size="large"
  186. style="width: 100px;"
  187. :disabled="spinning"
  188. type="primary"
  189. class="button-success"
  190. id="salesDetail-batchAudit-btn"
  191. v-if="detailData&&detailData.billStatus == 'WAIT_AUDIT'&&$hasPermissions('B_salesAudit')"
  192. @click="handleAudit('batch')"
  193. >
  194. 一键审核
  195. </a-button>
  196. </div>
  197. <!-- 打印导出 -->
  198. <print-modal :openModal="openModal" :itemData="detailData" :nowType="nowType" @ok="handleOk" @close="closePrint" />
  199. <!-- 审核 -->
  200. <auditModal
  201. :openModal="visibleAudit"
  202. :content="auditText"
  203. :spinning="spinningAudit"
  204. @close="visibleAudit=false"
  205. @ok="auditOrder('AUDIT_PASS')"
  206. @fail="auditOrder('AUDIT_REJECT')" />
  207. <!-- 审核加下推 -->
  208. <dsModal ref="dsModal" title="销售单一键审核" :openModal="showDsModal" @close="showDsModal=false" @ok="handleOnceAudit" />
  209. <!-- 缺货明细 -->
  210. <stockOutDetail :openModal="showStockOut" :detailData="detailData" :salesBillSn="$route.params.sn || bizSn" @close="showStockOut=false"></stockOutDetail>
  211. </div>
  212. </template>
  213. <script>
  214. import { printFun, exportExcel } from '@/libs/JGPrint.js'
  215. import { commonMixin } from '@/utils/mixin'
  216. import moment from 'moment'
  217. import { STable, VSelect } from '@/components'
  218. import printModal from './printModal.vue'
  219. import auditModal from '@/views/common/auditModal.vue'
  220. import dsModal from '@/views/salesManagement/waitDispatchNew/dsModal.vue'
  221. import stockOutDetail from './stockOutDetailModal.vue'
  222. import chooseWarehouse from '@/views/common/chooseWarehouse'
  223. import { salesDetailBySn, salesDetailAllList, salesDetailPrint, salesDetailExcel, salesDetailTypeExcel, salesWriteAuditReject, salesWriteAuditPass, salesWriteAuditPush } from '@/api/salesNew'
  224. export default {
  225. name: 'SalesDetailALL',
  226. mixins: [commonMixin],
  227. components: { STable, VSelect, printModal, auditModal, dsModal, stockOutDetail, chooseWarehouse },
  228. props: {
  229. bizSn: { // 有值则为弹框,无值则为页面
  230. type: [Number, String],
  231. default: ''
  232. }
  233. },
  234. data () {
  235. return {
  236. spinning: false,
  237. disabled: false,
  238. showDsModal: false, // 销售单一键审核弹框
  239. showStockOut: false, // 缺货明细弹框
  240. queryParam: {
  241. warehouseSn: undefined // 仓库sn
  242. },
  243. // 加载数据方法 必须为 Promise 对象
  244. loadData: parameter => {
  245. this.disabled = true
  246. this.$store.state.app.curActionPermission = this.authCode
  247. const params = Object.assign(parameter, { salesBillSn: this.bizSn || this.$route.params.sn, warehouseSn: this.queryParam.warehouseSn })
  248. // 审核,需用到库存
  249. if (this.detailData && (this.detailData.billStatus == 'WAIT_AUDIT' || this.detailData.billStatus == 'HQ_CHANGE') && this.$hasPermissions('B_salesAudit')) {
  250. params.showStock = true
  251. } else { // 非审核
  252. params.showStock = false
  253. }
  254. return salesDetailAllList(params).then(res => {
  255. let data
  256. if (res.status == 200) {
  257. data = res.data
  258. const no = 0
  259. this.outStockStr = ''
  260. let str = ''
  261. for (var i = 0; i < data.length; i++) {
  262. data[i].no = no + i + 1
  263. const productCode = (data[i].productEntity && data[i].productEntity.code) || (data[i].dealerProductEntity && data[i].dealerProductEntity.code)
  264. const productName = (data[i].productEntity && data[i].productEntity.name) || (data[i].dealerProductEntity && data[i].dealerProductEntity.name)
  265. const productOrigCode = (data[i].productEntity && data[i].productEntity.origCode) || (data[i].dealerProductEntity && data[i].dealerProductEntity.origCode)
  266. const productOrigUnit = (data[i].productEntity && data[i].productEntity.unit) || (data[i].dealerProductEntity && data[i].dealerProductEntity.unit)
  267. data[i].productCode = productCode || '--'
  268. data[i].productName = productName || '--'
  269. data[i].productOrigCode = productOrigCode == ' ' ? '--' : productOrigCode
  270. data[i].productOrigUnit = productOrigUnit || '--'
  271. if (data[i].unpushedQty && (Number(data[i].stockQty) < Number(data[i].unpushedQty))) {
  272. str += data[i].productCode + '、'
  273. }
  274. }
  275. if (str.length > 0) {
  276. str = str.substr(0, str.length - 1)
  277. this.outStockStr = '产品编号为:' + str + '的产品库存不足;'
  278. }
  279. this.localDataSource = data
  280. this.disabled = false
  281. }
  282. return data
  283. })
  284. },
  285. localDataSource: [], // 原始列表数据
  286. openModal: false, // 打印导出弹框
  287. detailData: null, // 详情数据
  288. nowType: null, // 打印导出类型
  289. isCityPrice: false, // 是否显示市级价
  290. visibleAudit: false, // 审核弹框
  291. spinningAudit: false, // 审核loading
  292. outStockStr: '', // 缺货产品信息说明
  293. auditText: null, // 审核备注
  294. authCode: '' // 当前权限码
  295. }
  296. },
  297. computed: {
  298. // 详细地址
  299. shippingAddress () {
  300. const shippingAddrProvinceName = this.detailData && this.detailData.salesBillExtEntity && this.detailData.salesBillExtEntity.shippingAddrProvinceName ? this.detailData.salesBillExtEntity.shippingAddrProvinceName : ''
  301. const shippingAddrCityName = this.detailData && this.detailData.salesBillExtEntity && this.detailData.salesBillExtEntity.shippingAddrCityName ? this.detailData.salesBillExtEntity.shippingAddrCityName : ''
  302. const shippingAddrCountyName = this.detailData && this.detailData.salesBillExtEntity && this.detailData.salesBillExtEntity.shippingAddrCountyName ? this.detailData.salesBillExtEntity.shippingAddrCountyName : ''
  303. const shippingAddr = this.detailData && this.detailData.salesBillExtEntity && this.detailData.salesBillExtEntity.shippingAddr ? this.detailData.salesBillExtEntity.shippingAddr : ''
  304. if (!shippingAddrProvinceName && !shippingAddrCityName && !shippingAddrCountyName && !shippingAddr) {
  305. return '--'
  306. } else {
  307. return shippingAddrProvinceName + shippingAddrCityName + shippingAddrCountyName + shippingAddr
  308. }
  309. },
  310. // 列定义
  311. columns () {
  312. const _this = this
  313. const arr = [
  314. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  315. { title: '产品编码', dataIndex: 'productCode', width: '10%', scopedSlots: { customRender: 'productCode' }, align: 'left' },
  316. { title: '产品名称', dataIndex: 'productName', width: '20%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  317. { title: '原厂编码', dataIndex: 'productOrigCode', width: '10%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  318. { title: '出库仓库', dataIndex: 'warehouseName', width: '8%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  319. // { title: '成本价', dataIndex: 'showCost', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  320. // { title: '省级价', dataIndex: 'provincePrice', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  321. // { title: '市级价', dataIndex: 'cityPrice', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  322. // { title: '销售价', dataIndex: 'price', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  323. { title: '单位', dataIndex: 'productOrigUnit', width: '4%', align: 'center', customRender: function (text) { return text || '--' } },
  324. { title: '销售数量', dataIndex: 'qty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  325. // { title: '库存', dataIndex: 'stockQty', scopedSlots: { customRender: 'stockQty' }, width: '6%', align: 'center' },
  326. { title: '待下推数', dataIndex: 'unpushedQty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  327. { title: '已下推数', dataIndex: 'pushedQty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  328. { title: '已取消数', dataIndex: 'cancelQty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  329. ]
  330. if (this.$hasPermissions(this.authCode + '_costPrice')) { // 成本价权限
  331. arr.splice(5, 0, { title: '成本价', dataIndex: 'showCost', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  332. }
  333. const ind = this.$hasPermissions(this.authCode + '_costPrice') ? 6 : 5
  334. if (this.$hasPermissions(this.authCode + '_provincePrice')) {
  335. arr.splice(ind, 0, { title: '省级价', dataIndex: 'provincePrice', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  336. }
  337. // 是否勾选市级价格
  338. if (this.isCityPrice) {
  339. arr.splice(ind + 1, 0, { title: '市级价', dataIndex: 'cityPrice', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  340. if (this.$hasPermissions(this.authCode + '_salesPrice')) { // 售价权限
  341. arr.splice(ind + 2, 0, { title: '销售价', dataIndex: 'price', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  342. }
  343. } else {
  344. if (this.$hasPermissions(this.authCode + '_salesPrice')) { // 售价权限
  345. arr.splice(ind + 1, 0, { title: '销售价', dataIndex: 'price', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  346. }
  347. }
  348. // 审核,需用到库存
  349. if (this.detailData && (this.detailData.billStatus == 'WAIT_AUDIT' || this.detailData.billStatus == 'HQ_CHANGE') && this.$hasPermissions('B_salesAudit')) {
  350. arr.splice(arr.length - 3, 0, { title: '库存', dataIndex: 'stockQty', scopedSlots: { customRender: 'stockQty' }, width: '6%', align: 'center' })
  351. }
  352. return arr
  353. }
  354. },
  355. methods: {
  356. // 返回
  357. handleBack () {
  358. this.$router.push({ name: 'salesQueryList' })
  359. },
  360. // 编辑
  361. handleEdit () {
  362. const row = this.detailData
  363. this.$router.push({ name: 'salesEdit', params: { sn: row.salesBillSn, wSn: row.warehouseSn } })
  364. },
  365. // 重置
  366. resetSearchForm () {
  367. this.queryParam.warehouseSn = undefined
  368. this.$refs.table.refresh()
  369. },
  370. // 打开缺货明细
  371. openStockOut () {
  372. if (this.outStockStr != '') {
  373. this.showStockOut = true
  374. } else {
  375. this.$info({
  376. title: '提示',
  377. content: '此销售单暂无缺货产品!',
  378. centered: true
  379. })
  380. }
  381. },
  382. // 详情
  383. getDetail () {
  384. salesDetailBySn({ salesBillSn: this.bizSn || this.$route.params.sn }).then(res => {
  385. if (res.status == 200) {
  386. this.detailData = res.data || null
  387. this.detailData.totalDiscountAmount = Number(this.detailData.totalOrigAmount || 0) - Number(this.detailData.totalAmount || 0)
  388. this.$refs.table.refresh(true)
  389. } else {
  390. this.detailData = null
  391. }
  392. })
  393. },
  394. // 打开审核/一键审核弹框
  395. handleAudit (isBatch) {
  396. if (isBatch) { // 一键审核
  397. if (this.detailData && this.detailData.promoFlag == 1 && this.outStockStr != '') {
  398. this.$info({
  399. title: '提示',
  400. content: '参加促销活动的销售单,有缺货产品,不可一键审核!',
  401. centered: true
  402. })
  403. return
  404. }
  405. this.showDsModal = true
  406. this.$refs.dsModal.setDetail(this.detailData)
  407. } else {
  408. this.auditText = null
  409. this.visibleAudit = true
  410. }
  411. },
  412. // 一键审核
  413. handleOnceAudit (data) {
  414. const params = {
  415. salesBillSn: this.bizSn || this.$route.params.sn,
  416. billStatus: 'AUDIT_PASS',
  417. dispatchBill: data
  418. }
  419. this.spinningAudit = true
  420. this.spinning = true
  421. salesWriteAuditPush(params).then(res => {
  422. if (res.status == 200) {
  423. this.$message.success(res.message)
  424. // 关闭详情跳列表
  425. this.handleBack()
  426. }
  427. this.spinningAudit = false
  428. this.spinning = false
  429. })
  430. },
  431. // 审核
  432. auditOrder (billStatus) {
  433. this.spinningAudit = true
  434. const auditFun = billStatus == 'AUDIT_PASS' ? salesWriteAuditPass : salesWriteAuditReject
  435. auditFun({
  436. salesBillSn: this.bizSn || this.$route.params.sn,
  437. billStatus: billStatus
  438. }).then(res => {
  439. if (res.status == 200) {
  440. this.visibleAudit = false
  441. this.$message.success(res.message)
  442. this.spinningAudit = false
  443. const _this = this
  444. this.$nextTick(() => {
  445. if (billStatus == 'AUDIT_PASS' && !_this.auditText) {
  446. _this.$router.push({ name: 'waitDispatchNew', params: { salesBillSn: _this.bizSn || _this.$route.params.sn } })
  447. } else {
  448. // 关闭详情跳列表
  449. _this.handleBack()
  450. }
  451. })
  452. } else {
  453. this.visibleAudit = false
  454. this.spinningAudit = false
  455. }
  456. })
  457. },
  458. // 打印导出弹框
  459. handlePrint (type, authCode) {
  460. const _this = this
  461. _this.$store.state.app.curActionPermission = authCode
  462. // 销售分类导出
  463. if (type == 'typeExport') {
  464. const params = {
  465. salesBillSn: this.bizSn || this.$route.params.sn
  466. }
  467. _this.spinning = true
  468. exportExcel(salesDetailTypeExcel, params, '销售分类' + moment().format('YYYYMMDDHHmmss'), () => {
  469. _this.spinning = false
  470. _this.$store.state.app.curActionPermission = ''
  471. })
  472. } else {
  473. this.detailData.authCode = authCode
  474. this.nowType = type
  475. this.openModal = true
  476. }
  477. },
  478. // 关闭打印弹框
  479. closePrint () {
  480. this.$store.state.app.curActionPermission = ''
  481. this.openModal = false
  482. },
  483. // 确定打印或预览,导出
  484. handleOk (objs) {
  485. const _this = this
  486. const params = JSON.parse(JSON.stringify(objs))
  487. _this.$store.state.app.curActionPermission = this.detailData.authCode
  488. delete params.type
  489. _this.spinning = true
  490. if (this.nowType == 'export') { // 导出
  491. exportExcel(salesDetailExcel, params, '销售' + moment().format('YYYYMMDDHHmmss'), () => {
  492. _this.spinning = false
  493. _this.$store.state.app.curActionPermission = ''
  494. })
  495. } else { // 打印
  496. const taskName = this.nowType == 'SALES_BILL' ? '销售单' : '销售分类'
  497. printFun(salesDetailPrint, params, objs.type, taskName, () => {
  498. _this.spinning = false
  499. _this.$store.state.app.curActionPermission = ''
  500. })
  501. }
  502. }
  503. },
  504. mounted () {
  505. if (!this.$store.state.app.isNewTab || this.bizSn) { // 页签刷新时调用
  506. this.getDetail()
  507. }
  508. },
  509. activated () {
  510. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  511. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  512. this.getDetail()
  513. }
  514. }
  515. }
  516. </script>
  517. <style lang="less">
  518. .salesDetail-All-wrap{
  519. position: relative;
  520. height: 100%;
  521. padding-bottom: 51px;
  522. box-sizing: border-box;
  523. >.ant-spin-nested-loading{
  524. overflow-y: auto;
  525. height: 100%;
  526. }
  527. .flexBox{
  528. display: flex;
  529. justify-content: space-between;
  530. align-items: center;
  531. }
  532. .footer-cont{
  533. margin-top: 5px;
  534. text-align: center;
  535. }
  536. .redStyle{
  537. font-weight: bold;
  538. color: red;
  539. }
  540. }
  541. </style>