detail.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <template>
  2. <div 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. <Print :disabled="localDataSource.length==0" @handlePrint="handlePrint"></Print>
  17. </template>
  18. </a-page-header>
  19. <!-- 基础信息 -->
  20. <a-card size="small" :bordered="false" class="salesDetail-cont">
  21. <a-collapse :activeKey="['1']">
  22. <a-collapse-panel key="1" header="基础信息">
  23. <a-descriptions size="small" :column="3">
  24. <a-descriptions-item label="客户名称">{{ detailData&&detailData.buyerName || '--' }}</a-descriptions-item>
  25. <a-descriptions-item label="客户地址" :span="2">
  26. <div v-if="detailData&&(detailData.shippingAddressProvinceName || detailData.shippingAddressCityName || detailData.shippingAddressCountyName || detailData.shippingAddress)">
  27. {{ detailData&&detailData.shippingAddressProvinceName || '' }}
  28. {{ detailData&&detailData.shippingAddressCityName || '' }}
  29. {{ detailData&&detailData.shippingAddressCountyName || '' }}
  30. {{ detailData&&detailData.shippingAddress || '' }}
  31. </div>
  32. <span v-else>--</span>
  33. </a-descriptions-item>
  34. <a-descriptions-item label="收款方式">{{ detailData&&detailData.settleStyleEntity&&detailData.settleStyleEntity.name || '--' }}</a-descriptions-item>
  35. <a-descriptions-item label="联系电话">{{ detailData&&detailData.consigneeTel || '--' }}</a-descriptions-item>
  36. <a-descriptions-item label="备注">{{ detailData&&detailData.remarks || '--' }}</a-descriptions-item>
  37. <a-descriptions-item label="销售单号">{{ detailData&&detailData.salesBillNo || '--' }}</a-descriptions-item>
  38. <a-descriptions-item label="制单人">{{ detailData&&detailData.operatorName || '--' }}</a-descriptions-item>
  39. <a-descriptions-item label="业务员">{{ detailData&&detailData.salesManName || '--' }}</a-descriptions-item>
  40. <a-descriptions-item label="来源">{{ detailData&&detailData.salesBillSourceDictValue || '--' }}</a-descriptions-item>
  41. <a-descriptions-item label="下级采购单号" v-if="detailData&&detailData.salesBillSource=='PURCHASE'">{{ detailData&&detailData.purchaseBillNo || '--' }}</a-descriptions-item>
  42. <a-descriptions-item label="业务状态">{{ detailData&&detailData.billStatusDictValue || '--' }}</a-descriptions-item>
  43. <a-descriptions-item label="财务状态">{{ detailData&&detailData.financialStatusDictValue || '--' }}</a-descriptions-item>
  44. </a-descriptions>
  45. </a-collapse-panel>
  46. </a-collapse>
  47. </a-card>
  48. <a-card size="small" :bordered="false" class="pages-wrap">
  49. <!-- alert -->
  50. <a-alert type="info" style="margin-bottom: 10px;">
  51. <div slot="message">
  52. 总款数:<strong>{{ detailData&&(detailData.totalCategory || detailData.totalCategory==0) ? detailData.totalCategory : '--' }}</strong>;
  53. 总数量:<strong>{{ detailData&&(detailData.totalQty || detailData.totalQty==0) ? detailData.totalQty : '--' }}</strong>;
  54. 总赠品数量:<strong>{{ detailData&&(detailData.giftQty || detailData.giftQty==0) ? detailData.giftQty : '--' }}</strong>;
  55. 急件总款数:<strong>{{ detailData&&(detailData.oosCategory || detailData.oosCategory==0) ? detailData.oosCategory : '--' }}</strong>;
  56. 急件总数量:<strong>{{ detailData&&(detailData.oosQty || detailData.oosQty==0) ? detailData.oosQty : '--' }}</strong>;<br/>
  57. 总售价:<strong>{{ detailData&&(detailData.totalAmount || detailData.totalAmount==0) ? detailData.totalAmount : '--' }}</strong>;
  58. 总成本:<strong>{{ detailData&&(detailData.totalCost || detailData.totalCost==0) ? detailData.totalCost : '--' }}</strong>;
  59. 总毛利:<strong>{{ detailData&&(detailData.grossProfit || detailData.grossProfit==0) ? detailData.grossProfit : '--' }}</strong>;
  60. 折后总售价:<strong>{{ detailData&&(detailData.discountedAmount || detailData.discountedAmount==0) ? detailData.discountedAmount : '--' }}</strong>;
  61. 折扣:<strong>{{ detailData&&(detailData.discountRate || detailData.discountRate==0) ? detailData.discountRate+'%' : '--' }}</strong>;
  62. 折扣金额:<strong>{{ detailData&&(detailData.discountAmount || detailData.discountAmount==0) ? detailData.discountAmount : '--' }}</strong>;
  63. </div>
  64. </a-alert>
  65. <!-- 列表 -->
  66. <s-table
  67. class="sTable"
  68. ref="table"
  69. size="small"
  70. :rowKey="(record) => record.id"
  71. :columns="columns"
  72. :data="loadData"
  73. :defaultLoadData="false"
  74. bordered>
  75. </s-table>
  76. </a-card>
  77. </a-spin>
  78. </div>
  79. </template>
  80. <script>
  81. import { getOperationalPrecision } from '@/libs/tools.js'
  82. import { STable, VSelect } from '@/components'
  83. import { salesDetailBySn, salesDetailPrint, salesDetailExport } from '@/api/sales'
  84. import { salesDetailList } from '@/api/salesDetail'
  85. import Print from '@/views/common/print.vue'
  86. import { hdPrint } from '@/libs/JGPrint'
  87. export default {
  88. name: 'SalesDetail',
  89. components: { STable, VSelect, Print },
  90. props: {
  91. outBizSn: { // 有值则为弹框,无值则为页面
  92. type: [Number, String],
  93. default: ''
  94. }
  95. },
  96. data () {
  97. return {
  98. spinning: false,
  99. disabled: false,
  100. // 表头
  101. columns: [
  102. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  103. { title: '产品编码', dataIndex: 'productCode', width: '11%', align: 'center', customRender: function (text) { return text || '--' } },
  104. { title: '产品名称', dataIndex: 'productName', width: '11%', align: 'center', customRender: function (text) { return text || '--' } },
  105. { title: '原厂编码', dataIndex: 'productOrigCode', width: '9%', align: 'center', customRender: function (text) { return text || '--' } },
  106. { title: '成本价', dataIndex: 'cost', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  107. { title: '售价', dataIndex: 'price', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  108. { title: '折后售价', dataIndex: 'discountedPrice', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  109. { title: '销售数量', dataIndex: 'qty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  110. { title: '单位', dataIndex: 'productOrigUnit', width: '4%', align: 'center', customRender: function (text) { return text || '--' } },
  111. { title: '售价小计', dataIndex: 'totalAmount', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  112. { title: '折后小计', dataIndex: 'discountedAmount', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  113. { title: '折扣金额', dataIndex: 'discountAmount', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  114. { title: '仓库', dataIndex: 'warehouseName', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  115. { title: '仓位', dataIndex: 'warehouseLocationName', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  116. { title: '是否急件', dataIndex: 'oosFlagDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } }
  117. ],
  118. // 加载数据方法 必须为 Promise 对象
  119. loadData: parameter => {
  120. this.disabled = true
  121. return salesDetailList(Object.assign(parameter, { salesBillSn: this.outBizSn || this.$route.params.sn })).then(res => {
  122. let data
  123. if (res.status == 200) {
  124. data = res.data
  125. const no = (data.pageNo - 1) * data.pageSize
  126. for (var i = 0; i < data.list.length; i++) {
  127. data.list[i].no = no + i + 1
  128. const productCode = (data.list[i].productEntity && data.list[i].productEntity.code) || (data.list[i].dealerProductEntity && data.list[i].dealerProductEntity.code)
  129. const productName = (data.list[i].productEntity && data.list[i].productEntity.name) || (data.list[i].dealerProductEntity && data.list[i].dealerProductEntity.name)
  130. const productOrigCode = (data.list[i].productEntity && data.list[i].productEntity.origCode) || (data.list[i].dealerProductEntity && data.list[i].dealerProductEntity.origCode)
  131. const productOrigUnit = (data.list[i].productEntity && data.list[i].productEntity.unit) || (data.list[i].dealerProductEntity && data.list[i].dealerProductEntity.unit)
  132. data.list[i].productCode = productCode || '--'
  133. data.list[i].productName = productName || '--'
  134. data.list[i].productOrigCode = productOrigCode || '--'
  135. data.list[i].productOrigUnit = productOrigUnit || '--'
  136. data.list[i].warehouseName = data.list[i].warehouseEntity && data.list[i].warehouseEntity.name || '--'
  137. data.list[i].warehouseLocationName = data.list[i].warehouseLocationEntity && data.list[i].warehouseLocationEntity.name || '--'
  138. // 售价小计 由于数据库内小数位数为4位,页面则需显示2位。因此会做小数运算精度处理
  139. data.list[i].salePriceSubtotal = getOperationalPrecision(data.list[i].price, data.list[i].qty)
  140. }
  141. this.localDataSource = data.list
  142. this.disabled = false
  143. }
  144. return data
  145. })
  146. },
  147. localDataSource: [],
  148. detailData: null // 详情数据
  149. }
  150. },
  151. methods: {
  152. // 打印预览/快捷打印
  153. handlePrint (type, printerType) {
  154. const _this = this
  155. _this.spinning = true
  156. let url = salesDetailPrint
  157. const params = { sn: this.outBizSn || this.$route.params.sn }
  158. if (type == 'export') { // 导出
  159. url = salesDetailExport
  160. }
  161. // 打印或导出
  162. hdPrint(printerType, type, url, params, '销售单', function () {
  163. _this.spinning = false
  164. })
  165. },
  166. // 返回
  167. handleBack () {
  168. this.$router.push({ path: '/salesManagement/salesQuery/list', query: { closeLastOldTab: true } })
  169. },
  170. // 编辑
  171. handleEdit () {
  172. const row = this.detailData
  173. this.$router.push({ name: 'salesEdit', params: { id: row.id, sn: row.salesBillSn, priceType: row.priceType } })
  174. },
  175. // 详情
  176. getDetail () {
  177. salesDetailBySn({ salesBillSn: this.outBizSn || this.$route.params.sn }).then(res => {
  178. if (res.status == 200) {
  179. this.detailData = res.data
  180. } else {
  181. this.detailData = null
  182. }
  183. })
  184. }
  185. },
  186. mounted () {
  187. if (!this.$store.state.app.isNewTab || this.outBizSn) { // 页签刷新 或 为弹框时调用
  188. this.$refs.table.refresh(true)
  189. this.getDetail()
  190. }
  191. },
  192. activated () {
  193. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  194. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  195. this.$refs.table.refresh(true)
  196. this.getDetail()
  197. }
  198. },
  199. beforeRouteEnter (to, from, next) {
  200. next(vm => {})
  201. }
  202. }
  203. </script>
  204. <style lang="less">
  205. .salesDetail-wrap{
  206. .salesDetail-cont{
  207. margin-bottom: 10px;
  208. }
  209. }
  210. </style>