detail.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  1. <template>
  2. <div v-if="showPage" class="jg-page-wrap salesDetail-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <a-page-header :ghost="false" :backIcon="false" class="salesDetail-cont" :style="{ padding: !outBizSn ? '16px 24px' : '0px 24px' }">
  5. <!-- 自定义的二级文字标题 -->
  6. <template slot="subTitle" v-if="!outBizSn && detailData">
  7. <span class="billno">单号:{{ detailData.salesBillNo ||'--' }}</span>
  8. <a-tag color="green" v-if="detailData.billStatusDictValue">{{ detailData.billStatusDictValue }}</a-tag>
  9. <a-tag color="orange" v-if="detailData.financialStatusDictValue">{{ detailData.financialStatusDictValue }}</a-tag>
  10. <a-button type="link" class="button-default" @click="isShowBisiceInfo=!isShowBisiceInfo" style="margin-left:10px;vertical-align:middle;">
  11. <a-icon :type="isShowBisiceInfo ? 'eye-invisible' : 'eye'"/>
  12. {{ isShowBisiceInfo?'隐藏':'查看' }}信息
  13. </a-button>
  14. <a-button id="purchaseNewOrderEdit-back-btn" type="link" @click="handleBack" class="button-default"> <a-icon type="rollback" /> 返回列表</a-button>
  15. </template>
  16. <!-- 操作区,位于 title 行的行尾 -->
  17. <template slot="extra" v-if="outBizSn ? $hasPermissions('B_outboundOrderDetail') : $hasPermissions('B_salesPrint')">
  18. <div style="margin-top: 5px;">
  19. <PrintPanel ref="printBox" position="bottomRight" :disabled="localDataSource.length==0" @handlePrint="handlePrint">
  20. <div style="padding:10px;" slot="extendCons">
  21. <a-checkbox v-model="printAllName" :checked="printAllName" id="salesQuery-printAllName">打印完整产品名称</a-checkbox>
  22. <a-checkbox v-model="printOrgCode" :checked="printOrgCode" id="salesQuery-printOrgCode">打印原厂编码</a-checkbox>
  23. <a-checkbox v-model="printPrice" :checked="printPrice" id="salesQuery-printPrice">打印售价</a-checkbox>
  24. <a-checkbox v-model="printRemarks" :checked="printRemarks" id="salesQuery-printRemarks">打印备注</a-checkbox>
  25. </div>
  26. </PrintPanel>
  27. </div>
  28. </template>
  29. </a-page-header>
  30. <div class="sales-detail-body">
  31. <!-- 基础信息 -->
  32. <a-card size="small" :bordered="false" class="salesDetail-cont" v-show="isShowBisiceInfo">
  33. <a-descriptions size="small" :column="3">
  34. <div slot="title">基础信息</div>
  35. <a-descriptions-item label="客户名称">{{ detailData&&detailData.buyerNameCurrent?detailData.buyerName?detailData.buyerName==detailData.buyerNameCurrent?detailData.buyerNameCurrent:detailData.buyerNameCurrent+'('+detailData.buyerName+')':detailData.buyerNameCurrent:'--' }}</a-descriptions-item>
  36. <a-descriptions-item label="客户地址" :span="2">
  37. <div v-if="detailData&&(detailData.shippingAddressProvinceName || detailData.shippingAddressCityName || detailData.shippingAddressCountyName || detailData.shippingAddress)">
  38. {{ detailData&&detailData.shippingAddressProvinceName || '' }}
  39. {{ detailData&&detailData.shippingAddressCityName || '' }}
  40. {{ detailData&&detailData.shippingAddressCountyName || '' }}
  41. {{ detailData&&detailData.shippingAddress || '' }}
  42. </div>
  43. <span v-else>--</span>
  44. </a-descriptions-item>
  45. <a-descriptions-item label="收款方式">{{ detailData&&detailData.settleStyleSnDictValue || '--' }}</a-descriptions-item>
  46. <a-descriptions-item label="联系电话">{{ detailData&&detailData.consigneeTel || '--' }}</a-descriptions-item>
  47. <a-descriptions-item label="备注">{{ detailData&&detailData.remarks || '--' }}</a-descriptions-item>
  48. <a-descriptions-item label="销售单号">{{ detailData&&detailData.salesBillNo || '--' }}</a-descriptions-item>
  49. <a-descriptions-item label="制单人">{{ detailData&&detailData.operatorName || '--' }}</a-descriptions-item>
  50. <a-descriptions-item label="业务员">{{ detailData&&detailData.salesManName || '--' }}</a-descriptions-item>
  51. <a-descriptions-item label="来源">{{ detailData&&detailData.sourceTypeDictValue || '--' }}</a-descriptions-item>
  52. <a-descriptions-item label="下级采购单号" v-if="detailData&&detailData.sourceType=='PURCHASE'">{{ detailData&&detailData.purchaseBillNo || '--' }}</a-descriptions-item>
  53. <a-descriptions-item label="业务状态">{{ detailData&&detailData.billStatusDictValue || '--' }}</a-descriptions-item>
  54. <a-descriptions-item label="财务状态">{{ detailData&&detailData.financialStatusDictValue || '--' }}</a-descriptions-item>
  55. </a-descriptions>
  56. </a-card>
  57. <a-card size="small" :bordered="false" class="pages-wrap">
  58. <!-- alert -->
  59. <div style="display: flex;align-items: center;justify-content: space-between;margin-bottom:10px;">
  60. <div>
  61. 总款数:<strong>{{ detailData&&(detailData.totalCategory || detailData.totalCategory==0) ? detailData.totalCategory : '--' }}</strong>;
  62. 总数量:<strong>{{ detailData&&(detailData.totalQty || detailData.totalQty==0) ? detailData.totalQty : '--' }}</strong>;
  63. 总赠品数量:<strong>{{ detailData&&(detailData.giftQty || detailData.giftQty==0) ? detailData.giftQty : '--' }}</strong>;
  64. 急件总款数:<strong>{{ detailData&&(detailData.oosCategory || detailData.oosCategory==0) ? detailData.oosCategory : '--' }}</strong>;
  65. 急件总数量:<strong>{{ detailData&&(detailData.oosQty || detailData.oosQty==0) ? detailData.oosQty : '--' }}</strong>;<br/>
  66. 总售价:<strong>{{ detailData&&(detailData.totalAmount || detailData.totalAmount==0) ? toThousands(detailData.totalAmount) : '--' }}</strong>;
  67. <template v-if="showCost">
  68. 总成本:<strong>{{ detailData&&(detailData.totalCost || detailData.totalCost==0) ? toThousands(detailData.totalCost) : '--' }}</strong>;
  69. 总毛利:<strong>{{ detailData&&(detailData.grossProfit || detailData.grossProfit==0) ? toThousands(detailData.grossProfit) : '--' }}</strong>;
  70. </template>
  71. 折后总售价:<strong>{{ detailData&&(detailData.discountedAmount || detailData.discountedAmount==0) ? toThousands(detailData.discountedAmount) : '--' }}</strong>;
  72. 折扣:<strong>{{ detailData&&(detailData.discountRate || detailData.discountRate==0) ? detailData.discountRate+'%' : '--' }}</strong>;
  73. 折扣金额:<strong>{{ detailData&&(detailData.discountAmount || detailData.discountAmount==0) ? toThousands(detailData.discountAmount) : '--' }}</strong>;
  74. <span v-if="detailData&&detailData.sourceType&&detailData.sourceType==='XPRH_PURCHASE'"> 返券金额:<strong>{{ detailData&&(detailData.totalGiveAmount || detailData.totalGiveAmount==0) ? toThousands(detailData.totalGiveAmount) : '--' }}</strong>;</span>
  75. </div>
  76. <div>
  77. <a-checkbox v-model="showCost" v-if="$hasPermissions('M_ShowAllCost')" id="salesQuery-cost">成本价</a-checkbox>
  78. </div>
  79. </div>
  80. <!-- 列表 -->
  81. <s-table
  82. class="sTable"
  83. ref="table"
  84. size="small"
  85. :rowKey="(record) => record.id"
  86. :columns="columns"
  87. :data="loadData"
  88. :defaultLoadData="false"
  89. bordered>
  90. <div slot="costTitle">
  91. <a-tooltip placement="top">
  92. <template slot="title">
  93. 系统中不同批次的产品,成本价可能不同,此值是按照实际出库批次的成本计算得到。
  94. </template>
  95. <span style="margin-right: 5px;">实际总成本</span> <a-icon type="question-circle" />
  96. </a-tooltip>
  97. </div>
  98. <!-- 产品编码 -->
  99. <template slot="productCode" slot-scope="text, record">
  100. <div v-if="detailData">
  101. <div v-if="isOwerEdit">
  102. <a-badge count="急" v-if="record.oosFlag == 1">
  103. <div style="padding-right: 15px;">{{ text }}</div>
  104. </a-badge>
  105. <span v-else>{{ text }}</span>
  106. </div>
  107. <div v-else>
  108. <a-badge count="急" v-if="isAudit&&record.oosFlag == 1">
  109. <div style="padding-right: 15px;">{{ text }}</div>
  110. </a-badge>
  111. <a-badge count="缺" v-else-if="!isAudit&&(!record.currentStockQty || record.currentStockQty < record.qty)">
  112. <div style="padding-right: 15px;">{{ text }}</div>
  113. </a-badge>
  114. <span v-else>{{ text }}</span>
  115. </div>
  116. </div>
  117. </template>
  118. <!-- 操作 -->
  119. <template slot="action" slot-scope="text, record">
  120. <a-button size="small" type="link" v-if="record.oosFlag == 0 && (isOwerEdit || isAudit)" class="button-primary" @click="handleViewDetail(record)">出库明细</a-button>
  121. <span v-else>--</span>
  122. </template>
  123. </s-table>
  124. </a-card>
  125. </div>
  126. </a-spin>
  127. <!-- 出入库明细 -->
  128. <outInDetialModal ref="outInDetialModal" outBizType="SALES" :openModal="showOutInModal" @close="showOutInModal=false"></outInDetialModal>
  129. </div>
  130. </template>
  131. <script>
  132. import { commonMixin } from '@/utils/mixin'
  133. import { getOperationalPrecision } from '@/libs/tools.js'
  134. import { STable, VSelect } from '@/components'
  135. import { salesDetailBySn, salesDetailPrint, salesDetailExport } from '@/api/sales'
  136. import { salesDetailList } from '@/api/salesDetail'
  137. import outInDetialModal from './outInDetialModal.vue'
  138. import PrintPanel from '@/views/common/printPanel.vue'
  139. import { hdPrint } from '@/libs/JGPrint'
  140. export default {
  141. name: 'SalesDetail',
  142. components: { STable, VSelect, PrintPanel, outInDetialModal },
  143. mixins: [commonMixin],
  144. props: {
  145. outBizSn: { // 有值则为弹框,无值则为页面
  146. type: [Number, String],
  147. default: ''
  148. }
  149. },
  150. data () {
  151. return {
  152. showPage: false,
  153. spinning: false,
  154. disabled: false,
  155. showCost: false,
  156. printOrgCode: false, // 打印原创编码
  157. printAllName: false, // 打印全部名称
  158. printRemarks: false,
  159. printPrice: false,
  160. showOutInModal: false,
  161. // 加载数据方法 必须为 Promise 对象
  162. loadData: parameter => {
  163. this.disabled = true
  164. return salesDetailList(Object.assign(parameter, { orderBy: 'sales_bill_detail.CREATE_DATE desc', salesBillSn: this.outBizSn || this.$route.params.sn })).then(res => {
  165. let data
  166. if (res.status == 200) {
  167. data = res.data
  168. const no = (data.pageNo - 1) * data.pageSize
  169. for (var i = 0; i < data.list.length; i++) {
  170. data.list[i].no = no + i + 1
  171. const productCode = (data.list[i].productEntity && data.list[i].productEntity.code) || (data.list[i].dealerProductEntity && data.list[i].dealerProductEntity.code)
  172. const productName = (data.list[i].productEntity && data.list[i].productEntity.name) || (data.list[i].dealerProductEntity && data.list[i].dealerProductEntity.name)
  173. const productOrigCode = (data.list[i].productEntity && data.list[i].productEntity.origCode) || (data.list[i].dealerProductEntity && data.list[i].dealerProductEntity.origCode) || '--'
  174. const productOrigUnit = (data.list[i].productEntity && data.list[i].productEntity.unit) || (data.list[i].dealerProductEntity && data.list[i].dealerProductEntity.unit)
  175. data.list[i].productCode = productCode || '--'
  176. data.list[i].productName = productName || '--'
  177. data.list[i].productOrigCode = productOrigCode || '--'
  178. data.list[i].productOrigUnit = productOrigUnit || '--'
  179. data.list[i].warehouseName = data.list[i].warehouseEntity && data.list[i].warehouseEntity.name || '--'
  180. data.list[i].warehouseLocationName = data.list[i].warehouseLocationEntity && data.list[i].warehouseLocationEntity.name || '--'
  181. // 售价小计 由于数据库内小数位数为4位,页面则需显示2位。因此会做小数运算精度处理
  182. data.list[i].salePriceSubtotal = getOperationalPrecision(data.list[i].price, data.list[i].qty)
  183. }
  184. this.localDataSource = data.list
  185. this.disabled = false
  186. }
  187. return data
  188. })
  189. },
  190. localDataSource: [],
  191. detailData: null, // 详情数据
  192. isShowBisiceInfo: false// 显示基础内容
  193. }
  194. },
  195. computed: {
  196. // 是否自建单据
  197. isOwerEdit () {
  198. return this.detailData && this.detailData.sourceType == 'SALES'
  199. },
  200. // 是否审核通过
  201. isAudit () {
  202. return this.detailData ? (this.detailData.billStatus == 'WAIT_OUT_WAREHOUSE' || this.detailData.billStatus == 'FINISH') : false
  203. },
  204. columns () {
  205. const _this = this
  206. const arr = [
  207. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  208. { title: '产品编码', dataIndex: 'dealerProductEntity.code', width: '11%', scopedSlots: { customRender: 'productCode' }, align: 'center' },
  209. { title: '产品名称', dataIndex: 'productName', width: '11%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  210. { title: '原厂编码', dataIndex: 'productOrigCode', width: '9%', align: 'center', customRender: function (text) { return text && text != ' ' ? text : '--' } },
  211. { title: '售价', dataIndex: 'price', width: '5%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  212. { title: '折后售价', dataIndex: 'discountedPrice', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  213. { title: '销售数量', dataIndex: 'qty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  214. { title: '单位', dataIndex: 'productOrigUnit', width: '4%', align: 'center', customRender: function (text) { return text || '--' } },
  215. { title: '售价小计', dataIndex: 'totalAmount', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  216. { title: '折后小计', dataIndex: 'discountedAmount', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  217. { title: '折扣金额', dataIndex: 'discountAmount', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  218. // { title: '仓库', dataIndex: 'warehouseName', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  219. // { title: '仓位', dataIndex: 'warehouseLocationName', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  220. { title: '是否急件', dataIndex: 'oosFlagDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  221. { title: '操作', scopedSlots: { customRender: 'action' }, width: '7%', align: 'center' }
  222. ]
  223. // 实际总成本
  224. if (this.showCost) {
  225. arr.splice(12, 0, { slots: { title: 'costTitle' }, dataIndex: 'totalCost', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  226. } else {
  227. arr.splice(12, 1)
  228. }
  229. if (this.detailData && this.detailData.sourceType && this.detailData.sourceType === 'XPRH_PURCHASE') {
  230. arr.splice(11, 1, { title: <a-tooltip placement="bottom" title='返券金额以销售单完结时的活动规则为准'>返券金额&nbsp;<a-icon type="question-circle" /></a-tooltip>, dataIndex: 'giveAmount', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  231. }
  232. // 下级创建,不显示仓库仓位
  233. if (!this.isOwerEdit) {
  234. arr.splice(this.showCost ? 13 : 12, 0, { title: '库存数量', dataIndex: 'currentStockQty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  235. } else {
  236. arr.splice(this.showCost ? 13 : 12, 0, { title: '仓库', dataIndex: 'warehouseName', width: '7%', align: 'center', customRender: function (text) { return text || '--' } })
  237. arr.splice(this.showCost ? 14 : 13, 0, { title: '仓位', dataIndex: 'warehouseLocationName', width: '7%', align: 'center', customRender: function (text) { return text || '--' } })
  238. }
  239. return arr
  240. }
  241. },
  242. methods: {
  243. // 打印预览/快捷打印
  244. handlePrint (type, printerType) {
  245. const _this = this
  246. _this.spinning = true
  247. let url = salesDetailPrint
  248. const params = {
  249. sn: this.outBizSn || this.$route.params.sn,
  250. printOrgCode: this.printOrgCode ? 1 : 0,
  251. printAllName: this.printAllName ? 1 : 0,
  252. remarksShowFlag: this.printRemarks ? 1 : 0,
  253. priceFlag: this.printPrice ? 1 : 0
  254. }
  255. if (type == 'export') { // 导出
  256. url = salesDetailExport
  257. }
  258. // 打印或导出
  259. hdPrint(printerType, type, url, params, '销售单', function () {
  260. _this.spinning = false
  261. })
  262. },
  263. // 返回
  264. handleBack () {
  265. this.$router.push({ name: 'salesNewList' })
  266. },
  267. // 编辑
  268. // handleEdit () {
  269. // const row = this.detailData
  270. // this.$router.push({ name: 'salesNewEdit', params: { id: row.id, sn: row.salesBillSn, priceType: row.priceType } })
  271. // },
  272. // 详情
  273. getDetail () {
  274. salesDetailBySn({ salesBillSn: this.outBizSn || this.$route.params.sn }).then(res => {
  275. if (res.status == 200) {
  276. this.detailData = res.data
  277. } else {
  278. this.detailData = null
  279. }
  280. })
  281. },
  282. // 出入库明细
  283. handleViewDetail (row) {
  284. this.showOutInModal = true
  285. this.$refs.outInDetialModal.getData(row)
  286. },
  287. pageInit () {
  288. const vm = this
  289. vm.$nextTick(() => {
  290. vm.spinning = false
  291. vm.disabled = false
  292. // 是否默认打印原厂编码
  293. vm.printOrgCode = localStorage.getItem('printOrgCode-' + this.$store.state.user.info.orgId) == 'true'
  294. vm.printAllName = localStorage.getItem('printAllName-' + this.$store.state.user.info.orgId) == 'true'
  295. vm.printRemarks = localStorage.getItem('printRemarks-' + this.$store.state.user.info.orgId) == 'true'
  296. vm.printPrice = localStorage.getItem('printPrice-' + this.$store.state.user.info.orgId) == 'true'
  297. vm.$refs.table.refresh(true)
  298. vm.getDetail()
  299. })
  300. }
  301. },
  302. watch: {
  303. printOrgCode (newValue, oldValue) {
  304. localStorage.setItem('printOrgCode-' + this.$store.state.user.info.orgId, newValue)
  305. },
  306. printRemarks (newValue, oldValue) {
  307. localStorage.setItem('printRemarks-' + this.$store.state.user.info.orgId, newValue)
  308. },
  309. printPrice (newValue, oldValue) {
  310. localStorage.setItem('printPrice-' + this.$store.state.user.info.orgId, newValue)
  311. },
  312. printAllName (newValue, oldValue) {
  313. localStorage.setItem('printAllName-' + this.$store.state.user.info.orgId, newValue)
  314. }
  315. },
  316. mounted () {
  317. if (!this.$store.state.app.isNewTab || this.outBizSn) { // 页签刷新时调用
  318. this.showPage = true
  319. this.pageInit()
  320. }
  321. },
  322. activated () {
  323. this.showPage = true
  324. this.pageInit()
  325. },
  326. beforeRouteEnter (to, from, next) {
  327. next(vm => {
  328. })
  329. }
  330. }
  331. </script>
  332. <style lang="less" scoped>
  333. .salesDetail-wrap{
  334. position: relative;
  335. height: 100%;
  336. .billno{
  337. font-size: 16px;
  338. font-weight: 600;
  339. display: inline-block;
  340. vertical-align: middle;
  341. color: #333;
  342. margin-right: 15px;
  343. }
  344. .ant-tag-green,.ant-tag-orange{
  345. vertical-align: middle;
  346. }
  347. .salesDetail-cont{
  348. margin-bottom: 10px;
  349. /deep/ .ant-descriptions-title{
  350. margin-bottom: 10px;
  351. }
  352. }
  353. .pages-wrap{
  354. strong{
  355. color:#f12929;
  356. }
  357. }
  358. }
  359. </style>