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. <!-- alert -->
  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/waitDispatch/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: 'SalesDetail',
  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. authCode: '',
  241. queryParam: {
  242. warehouseSn: undefined
  243. },
  244. // 加载数据方法 必须为 Promise 对象
  245. loadData: parameter => {
  246. this.disabled = true
  247. this.$store.state.app.curActionPermission = this.authCode
  248. const params = Object.assign(parameter, { salesBillSn: this.bizSn || this.$route.params.sn, warehouseSn: this.queryParam.warehouseSn })
  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. auditInfo: null,
  292. spinningAudit: false,
  293. outStockStr: '', // 缺货产品信息说明
  294. auditText: null,
  295. authCode: ""
  296. }
  297. },
  298. computed: {
  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. columns () {
  311. const _this = this
  312. const arr = [
  313. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  314. { title: '产品编码', dataIndex: 'productCode', width: '10%', scopedSlots: { customRender: 'productCode' }, align: 'left' },
  315. { title: '产品名称', dataIndex: 'productName', width: '20%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  316. { title: '原厂编码', dataIndex: 'productOrigCode', width: '10%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  317. { title: '出库仓库', dataIndex: 'warehouseName', width: '8%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  318. // { title: '成本价', dataIndex: 'showCost', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  319. // { title: '省级价', dataIndex: 'provincePrice', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  320. // { title: '市级价', dataIndex: 'cityPrice', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  321. // { title: '销售价', dataIndex: 'price', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  322. { title: '单位', dataIndex: 'productOrigUnit', width: '4%', align: 'center', customRender: function (text) { return text || '--' } },
  323. { title: '销售数量', dataIndex: 'qty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  324. // { title: '库存', dataIndex: 'stockQty', scopedSlots: { customRender: 'stockQty' }, width: '6%', align: 'center' },
  325. { title: '待下推数', dataIndex: 'unpushedQty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  326. { title: '已下推数', dataIndex: 'pushedQty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  327. { title: '已取消数', dataIndex: 'cancelQty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  328. ]
  329. if (this.$hasPermissions(this.authCode + '_costPrice')) { // 成本价权限
  330. arr.splice(5, 0, { title: '成本价', dataIndex: 'showCost', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  331. }
  332. const ind = this.$hasPermissions(this.authCode + '_costPrice') ? 6 : 5
  333. if (this.$hasPermissions(this.authCode + '_provincePrice')) {
  334. arr.splice(ind, 0, { title: '省级价', dataIndex: 'provincePrice', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  335. }
  336. // 是否勾选市级价格
  337. if (this.isCityPrice) {
  338. arr.splice(ind + 1, 0, { title: '市级价', dataIndex: 'cityPrice', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  339. if (this.$hasPermissions(this.authCode + '_salesPrice')) { // 售价权限
  340. arr.splice(ind + 2, 0, { title: '销售价', dataIndex: 'price', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  341. }
  342. } else {
  343. if (this.$hasPermissions(this.authCode + '_salesPrice')) { // 售价权限
  344. arr.splice(ind + 1, 0, { title: '销售价', dataIndex: 'price', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  345. }
  346. }
  347. if (this.detailData && (this.detailData.billStatus == 'WAIT_AUDIT' || this.detailData.billStatus == 'HQ_CHANGE') && this.$hasPermissions('B_salesAudit')) { // 审核,需用到库存
  348. arr.splice(arr.length - 3, 0, { title: '库存', dataIndex: 'stockQty', scopedSlots: { customRender: 'stockQty' }, width: '6%', align: 'center' })
  349. }
  350. return arr
  351. }
  352. },
  353. methods: {
  354. // 返回
  355. handleBack () {
  356. this.$router.push({ name: 'salesQueryList' })
  357. },
  358. // 编辑
  359. handleEdit () {
  360. const row = this.detailData
  361. this.$router.push({ name: 'salesEdit', params: { sn: row.salesBillSn, wSn: row.warehouseSn } })
  362. },
  363. // 重置
  364. resetSearchForm () {
  365. this.queryParam.warehouseSn = undefined
  366. this.$refs.table.refresh()
  367. },
  368. // 打开缺货明细
  369. openStockOut () {
  370. if (this.outStockStr != '') {
  371. this.showStockOut = true
  372. } else {
  373. this.$info({
  374. title: '提示',
  375. content: '此销售单暂无缺货产品!',
  376. centered: true
  377. })
  378. }
  379. },
  380. // 详情
  381. getDetail () {
  382. salesDetailBySn({ salesBillSn: this.bizSn || this.$route.params.sn }).then(res => {
  383. if (res.status == 200) {
  384. this.detailData = res.data || null
  385. this.detailData.totalDiscountAmount = Number(this.detailData.totalOrigAmount||0) - Number(this.detailData.totalAmount||0)
  386. this.$refs.table.refresh(true)
  387. } else {
  388. this.detailData = null
  389. }
  390. })
  391. },
  392. // 打开审核/一键审核弹框
  393. handleAudit (isBatch) {
  394. if (isBatch) { // 一键审核
  395. if(this.detailData&&this.detailData.promoFlag==1&&this.outStockStr != ''){
  396. this.$info({
  397. title: '提示',
  398. content: '参加促销活动的销售单,有缺货产品,不可一键审核!',
  399. centered: true
  400. })
  401. return
  402. }
  403. this.showDsModal = true
  404. this.$refs.dsModal.setDetail(this.detailData)
  405. } else {
  406. this.auditText = null
  407. this.visibleAudit = true
  408. }
  409. },
  410. // 一键审核
  411. handleOnceAudit (data) {
  412. const params = {
  413. salesBillSn: this.bizSn || this.$route.params.sn,
  414. billStatus: 'AUDIT_PASS',
  415. dispatchBill: data
  416. }
  417. this.spinningAudit = true
  418. this.spinning = true
  419. salesWriteAuditPush(params).then(res => {
  420. if (res.status == 200) {
  421. this.$message.success(res.message)
  422. // 关闭详情跳列表
  423. this.handleBack()
  424. }
  425. this.spinningAudit = false
  426. this.spinning = false
  427. })
  428. },
  429. // 审核
  430. auditOrder (billStatus) {
  431. this.spinningAudit = true
  432. const auditFun = billStatus =='AUDIT_PASS' ? salesWriteAuditPass : salesWriteAuditReject
  433. auditFun({
  434. salesBillSn: this.bizSn || this.$route.params.sn,
  435. billStatus: billStatus
  436. }).then(res => {
  437. if (res.status == 200) {
  438. this.visibleAudit = false
  439. this.$message.success(res.message)
  440. this.spinningAudit = false
  441. const _this = this
  442. this.$nextTick(() => {
  443. if (billStatus == 'AUDIT_PASS' && !_this.auditText) {
  444. _this.$router.push({ name: 'waitDispatchNew', params: { salesBillSn: _this.bizSn || _this.$route.params.sn } })
  445. } else {
  446. // 关闭详情跳列表
  447. _this.handleBack()
  448. }
  449. })
  450. } else {
  451. this.visibleAudit = false
  452. this.spinningAudit = false
  453. }
  454. })
  455. },
  456. // 打印导出
  457. handlePrint (type, authCode) {
  458. const _this = this
  459. _this.$store.state.app.curActionPermission = authCode
  460. // 销售分类导出
  461. if (type == 'typeExport') {
  462. const params = {
  463. salesBillSn: this.bizSn || this.$route.params.sn
  464. }
  465. _this.spinning = true
  466. exportExcel(salesDetailTypeExcel, params, '销售分类' + moment().format('YYYYMMDDHHmmss'), () => {
  467. _this.spinning = false
  468. _this.$store.state.app.curActionPermission = ''
  469. })
  470. } else {
  471. this.detailData.authCode = authCode
  472. this.nowType = type
  473. this.openModal = true
  474. }
  475. },
  476. closePrint () {
  477. console.log(9)
  478. this.$store.state.app.curActionPermission = ''
  479. this.openModal = false
  480. },
  481. // 确定打印或预览,导出
  482. handleOk (objs) {
  483. const _this = this
  484. const params = JSON.parse(JSON.stringify(objs))
  485. _this.$store.state.app.curActionPermission = this.detailData.authCode
  486. delete params.type
  487. _this.spinning = true
  488. if (this.nowType == 'export') { // 导出
  489. exportExcel(salesDetailExcel, params, '销售' + moment().format('YYYYMMDDHHmmss'), () => {
  490. _this.spinning = false
  491. _this.$store.state.app.curActionPermission = ''
  492. })
  493. } else { // 打印
  494. const taskName = this.nowType == 'SALES_BILL' ? '销售单' : '销售分类'
  495. printFun(salesDetailPrint, params, objs.type, taskName, () => {
  496. _this.spinning = false
  497. _this.$store.state.app.curActionPermission = ''
  498. })
  499. }
  500. }
  501. },
  502. mounted () {
  503. if (!this.$store.state.app.isNewTab || this.bizSn) { // 页签刷新时调用
  504. this.getDetail()
  505. }
  506. },
  507. activated () {
  508. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  509. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  510. this.getDetail()
  511. }
  512. }
  513. }
  514. </script>
  515. <style lang="less">
  516. .salesDetail-All-wrap{
  517. position: relative;
  518. height: 100%;
  519. padding-bottom: 51px;
  520. box-sizing: border-box;
  521. >.ant-spin-nested-loading{
  522. overflow-y: auto;
  523. height: 100%;
  524. }
  525. .flexBox{
  526. display: flex;
  527. justify-content: space-between;
  528. align-items: center;
  529. }
  530. .footer-cont{
  531. margin-top: 5px;
  532. text-align: center;
  533. }
  534. .redStyle{
  535. font-weight: bold;
  536. color: red;
  537. }
  538. }
  539. </style>