detail.vue 17 KB

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