detail.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <template>
  2. <div class="salesDetail-wrap">
  3. <a-page-header :ghost="false" :backIcon="false" class="salesDetail-cont">
  4. <template slot="subTitle">
  5. <a href="javascript:;" @click="handleBack"><a-icon type="left"></a-icon> 返回列表</a>
  6. </template>
  7. <template slot="extra">
  8. <span>打印字段:</span>
  9. <a-select key="1" style="width:150px" id="salesDetail-pritKey" placeholder="请选择打印字段" allowClear>
  10. <a-select-option v-for="item in pritKey" :key="item.id" :value="item.id">{{ item.name }}</a-select-option>
  11. </a-select>
  12. <span><i style="color: red;">*</i>打印模板:</span>
  13. <a-select key="2" style="width:150px" id="salesDetail-pritKey" placeholder="请选择打印模板" allowClear>
  14. <a-select-option v-for="item in pritModal" :key="item.id" :value="item.id">{{ item.name }}</a-select-option>
  15. </a-select>
  16. <a-button key="3" id="salesDetail-preview-btn">打印预览</a-button>
  17. <a-button key="4" type="primary" id="salesDetail-print-btn">快速打印</a-button>
  18. <a-button key="5" id="salesDetail-export-btn">导出</a-button>
  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" v-if="detailData">
  26. <a-descriptions-item label="客户名称">{{ detailData.buyerName || '--' }}</a-descriptions-item>
  27. <a-descriptions-item label="客户地址">{{ detailData.shippingAddressProvinceName || '--' }}{{ detailData.shippingAddressCityName || '--' }}{{ detailData.shippingAddressCountyName || '--' }}{{ detailData.shippingAddress || '--' }}</a-descriptions-item>
  28. <a-descriptions-item label="收款方式">{{ detailData.settleStyleEntity.name || '--' }}</a-descriptions-item>
  29. <a-descriptions-item label="联系电话">{{ detailData.consigneeTel || '--' }}</a-descriptions-item>
  30. <a-descriptions-item label="备注">{{ detailData.remarks || '--' }}</a-descriptions-item>
  31. <a-descriptions-item label="销售单号">{{ detailData.salesBillNo || '--' }}</a-descriptions-item>
  32. <a-descriptions-item label="制单人">{{ detailData.operatorName || '--' }}</a-descriptions-item>
  33. <a-descriptions-item label="业务员">{{ detailData.salesManName || '--' }}</a-descriptions-item>
  34. <a-descriptions-item label="业务状态">{{ detailData.billStatusDictValue || '--' }}</a-descriptions-item>
  35. <a-descriptions-item label="财务状态">{{ detailData.financialStatusDictValue || '--' }}</a-descriptions-item>
  36. </a-descriptions>
  37. </a-collapse-panel>
  38. </a-collapse>
  39. </a-card>
  40. <a-card size="small" :bordered="false" class="pages-wrap">
  41. <!-- alert -->
  42. <a-alert type="info" style="margin-bottom: 15px;" v-if="detailData">
  43. <div slot="message">
  44. 总款数:<strong>{{ detailData.totalCategory || 0 }}</strong>;总数量:<strong>{{ detailData.totalQty || 0 }}</strong>;总赠品数量:<strong>{{ detailData.totalGiftNum || 0 }}</strong>;急件总款数:<strong>{{ detailData.urgentTotalCategory || 0 }}</strong>;急件总数量:<strong>{{ detailData.urgentTotalQty || 0 }}</strong>;<br/>
  45. 总售价:<strong>{{ detailData.totalAmount || 0 }}</strong>;总成本:<strong>{{ detailData.totalCost || 0 }}</strong>;总毛利:<strong>{{ detailData.grossProfit || 0 }}</strong>;折后总售价:<strong>{{ detailData.discountedAmount || 0 }}</strong>;折扣:<strong>{{ detailData.discountRate || 0 }}%</strong>;折扣金额:<strong>{{ detailData.discountAmount || 0 }}</strong>;
  46. </div>
  47. </a-alert>
  48. <!-- 列表 -->
  49. <s-table
  50. class="sTable"
  51. ref="table"
  52. size="default"
  53. :rowKey="(record) => record.id"
  54. :columns="columns"
  55. :data="loadData"
  56. :scroll="{ x: 1660 }"
  57. bordered>
  58. </s-table>
  59. </a-card>
  60. <a-card size="small" :bordered="false" class="footer-cont">
  61. <a-button
  62. type="primary"
  63. class="button-info"
  64. size="large"
  65. style="width: 150px;"
  66. v-if="detailData&&detailData.billStatus !== 'CANCEL' && detailData.billStatus !== 'FINISH' && detailData.billStatus != 'WAIT_OUT_WAREHOUSE'"
  67. @click="handleEdit()"
  68. id="salesDetail-edit-btn">编辑</a-button>
  69. </a-card>
  70. </div>
  71. </template>
  72. <script>
  73. import { getOperationalPrecision } from '@/libs/tools.js'
  74. import { STable, VSelect } from '@/components'
  75. import { salesDetailBySn } from '@/api/sales'
  76. import { salesDetailList } from '@/api/salesDetail'
  77. export default {
  78. name: 'SalesDetail',
  79. components: { STable, VSelect },
  80. data () {
  81. return {
  82. disabled: false,
  83. pritKey: [
  84. { id: 0, name: '打印促销' },
  85. { id: 1, name: '打印支付方式' },
  86. { id: 2, name: '打印收款方式' }
  87. ],
  88. pritModal: [
  89. { id: 0, name: '普通模板一' },
  90. { id: 1, name: '普通模板二' },
  91. { id: 2, name: '仓库模板一' }
  92. ],
  93. // 表头
  94. columns: [
  95. { title: '序号', dataIndex: 'no', width: 80, align: 'center', fixed: 'left' },
  96. { title: '产品编码', dataIndex: 'productCode', width: 140, align: 'center' },
  97. { title: '产品名称', dataIndex: 'productName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  98. { title: '原厂编码', dataIndex: 'productOrigCode', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
  99. { title: '成本价', dataIndex: 'cost', width: 100, align: 'center', customRender: function (text) { return '¥' + (text || 0) } },
  100. { title: '售价', dataIndex: 'price', width: 100, align: 'center', customRender: function (text) { return '¥' + (text || 0) } },
  101. { title: '折后售价', dataIndex: 'discountedPrice', width: 100, align: 'center', customRender: function (text) { return '¥' + (text || 0) } },
  102. { title: '销售数量', dataIndex: 'qty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  103. { title: '单位', dataIndex: 'productOrigUnit', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  104. { title: '售价小计', dataIndex: 'totalAmount', width: 100, align: 'center', customRender: function (text) { return '¥' + (text || 0) } },
  105. { title: '折后小计', dataIndex: 'discountedAmount', width: 100, align: 'center', customRender: function (text) { return '¥' + (text || 0) } },
  106. { title: '折扣金额', dataIndex: 'discountAmount', width: 100, align: 'center', customRender: function (text) { return '¥' + (text || 0) } },
  107. { title: '仓库', dataIndex: 'warehouseName', width: 100, align: 'center' },
  108. { title: '仓位', dataIndex: 'warehouseLocationName', width: 100, align: 'center' },
  109. { title: '是否急件', dataIndex: 'oosFlagDictValue', width: 100, align: 'center', customRender: function (text) { return text || '--' } }
  110. ],
  111. // 加载数据方法 必须为 Promise 对象
  112. loadData: parameter => {
  113. this.disabled = true
  114. return salesDetailList(Object.assign(parameter, { salesBillSn: this.$route.params.sn })).then(res => {
  115. const data = res.data
  116. const no = (data.pageNo - 1) * data.pageSize
  117. for (var i = 0; i < data.list.length; i++) {
  118. data.list[i].no = no + i + 1
  119. const productCode = (data.list[i].productEntity && data.list[i].productEntity.code) || (data.list[i].dealerProductEntity && data.list[i].dealerProductEntity.code)
  120. const productName = (data.list[i].productEntity && data.list[i].productEntity.name) || (data.list[i].dealerProductEntity && data.list[i].dealerProductEntity.name)
  121. const productOrigCode = (data.list[i].productEntity && data.list[i].productEntity.origCode) || (data.list[i].dealerProductEntity && data.list[i].dealerProductEntity.origCode)
  122. const productOrigUnit = (data.list[i].productEntity && data.list[i].productEntity.unit) || (data.list[i].dealerProductEntity && data.list[i].dealerProductEntity.unit)
  123. data.list[i].productCode = productCode || '--'
  124. data.list[i].productName = productName || '--'
  125. data.list[i].productOrigCode = productOrigCode || '--'
  126. data.list[i].productOrigUnit = productOrigUnit || '--'
  127. data.list[i].warehouseName = data.list[i].warehouseEntity && data.list[i].warehouseEntity.name || '--'
  128. data.list[i].warehouseLocationName = data.list[i].warehouseLocationEntity && data.list[i].warehouseLocationEntity.name || '--'
  129. // 售价小计 由于数据库内小数位数为4位,页面则需显示2位。因此会做小数运算精度处理
  130. data.list[i].salePriceSubtotal = getOperationalPrecision(data.list[i].price, data.list[i].qty)
  131. }
  132. this.disabled = false
  133. return data
  134. })
  135. },
  136. detailData: null // 详情数据
  137. }
  138. },
  139. methods: {
  140. // 返回
  141. handleBack () {
  142. this.$router.push({ name: 'salesQueryList' })
  143. },
  144. // 编辑
  145. handleEdit () {
  146. const row = this.detailData
  147. this.$router.push({ name: 'salesEdit', params: { id: row.id, sn: row.salesBillSn } })
  148. },
  149. // 详情
  150. getDetail () {
  151. salesDetailBySn({ salesBillSn: this.$route.params.sn }).then(res => {
  152. if (res.status == 200) {
  153. this.detailData = res.data
  154. } else {
  155. this.detailData = null
  156. }
  157. })
  158. }
  159. },
  160. mounted () {
  161. this.getDetail()
  162. }
  163. }
  164. </script>
  165. <style lang="less">
  166. .salesDetail-wrap{
  167. .salesDetail-cont{
  168. margin-bottom: 15px;
  169. }
  170. .footer-cont{
  171. margin-top: 5px;
  172. text-align: center;
  173. }
  174. }
  175. </style>