detailAll.vue 30 KB

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