detail.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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="$hasPermissions('B_salesPrint')">
  16. <!-- <span>打印字段:</span>
  17. <a-select key="1" style="width:150px" id="salesDetail-pritKey" placeholder="请选择打印字段" allowClear>
  18. <a-select-option v-for="item in pritKey" :key="item.id" :value="item.id">{{ item.name }}</a-select-option>
  19. </a-select>
  20. <span><i style="color: red;">*</i>打印模板:</span>
  21. <a-select key="2" style="width:150px" id="salesDetail-pritKey" placeholder="请选择打印模板" allowClear>
  22. <a-select-option v-for="item in pritModal" :key="item.id" :value="item.id">{{ item.name }}</a-select-option>
  23. </a-select> -->
  24. <!-- <a-button key="5" id="salesDetail-export-btn">导出</a-button> -->
  25. <a-radio-group key="3" v-model="printerType">
  26. <a-radio value="NEEDLE">针式</a-radio>
  27. <a-radio value="INK">喷墨</a-radio>
  28. </a-radio-group>
  29. <a-button key="2" id="salesDetail-preview-btn" :disabled="localDataSource.length==0" @click="handlePrint('preview')">打印预览</a-button>
  30. <a-button key="1" type="primary" id="salesDetail-print-btn" :disabled="localDataSource.length==0" @click="handlePrint('print')">快捷打印</a-button>
  31. </template>
  32. </a-page-header>
  33. <!-- 基础信息 -->
  34. <a-card size="small" :bordered="false" class="salesDetail-cont">
  35. <a-collapse :activeKey="['1']">
  36. <a-collapse-panel key="1" header="基础信息">
  37. <a-descriptions size="small" :column="3">
  38. <a-descriptions-item label="客户名称">{{ detailData&&detailData.buyerName || '--' }}</a-descriptions-item>
  39. <a-descriptions-item label="客户地址">
  40. <div v-if="detailData&&(detailData.shippingAddressProvinceName || detailData.shippingAddressCityName || detailData.shippingAddressCountyName || detailData.shippingAddress)">
  41. {{ detailData&&detailData.shippingAddressProvinceName || '' }}
  42. {{ detailData&&detailData.shippingAddressCityName || '' }}
  43. {{ detailData&&detailData.shippingAddressCountyName || '' }}
  44. {{ detailData&&detailData.shippingAddress || '' }}
  45. </div>
  46. <span v-else>--</span>
  47. </a-descriptions-item>
  48. <a-descriptions-item label="收款方式">{{ detailData&&detailData.settleStyleEntity&&detailData.settleStyleEntity.name || '--' }}</a-descriptions-item>
  49. <a-descriptions-item label="联系电话">{{ detailData&&detailData.consigneeTel || '--' }}</a-descriptions-item>
  50. <a-descriptions-item label="备注">{{ detailData&&detailData.remarks || '--' }}</a-descriptions-item>
  51. <a-descriptions-item label="销售单号">{{ detailData&&detailData.salesBillNo || '--' }}</a-descriptions-item>
  52. <a-descriptions-item label="制单人">{{ detailData&&detailData.operatorName || '--' }}</a-descriptions-item>
  53. <a-descriptions-item label="业务员">{{ detailData&&detailData.salesManName || '--' }}</a-descriptions-item>
  54. <a-descriptions-item label="业务状态">{{ detailData&&detailData.billStatusDictValue || '--' }}</a-descriptions-item>
  55. <a-descriptions-item label="财务状态">{{ detailData&&detailData.financialStatusDictValue || '--' }}</a-descriptions-item>
  56. </a-descriptions>
  57. </a-collapse-panel>
  58. </a-collapse>
  59. </a-card>
  60. <a-card size="small" :bordered="false" class="pages-wrap">
  61. <!-- alert -->
  62. <a-alert type="info" style="margin-bottom: 15px;">
  63. <div slot="message">
  64. 总款数:<strong>{{ detailData&&(detailData.totalCategory || detailData.totalCategory==0) ? detailData.totalCategory : '--' }}</strong>;
  65. 总数量:<strong>{{ detailData&&(detailData.totalQty || detailData.totalQty==0) ? detailData.totalQty : '--' }}</strong>;
  66. 总赠品数量:<strong>{{ detailData&&(detailData.giftQty || detailData.giftQty==0) ? detailData.giftQty : '--' }}</strong>;
  67. 急件总款数:<strong>{{ detailData&&(detailData.oosCategory || detailData.oosCategory==0) ? detailData.oosCategory : '--' }}</strong>;
  68. 急件总数量:<strong>{{ detailData&&(detailData.oosQty || detailData.oosQty==0) ? detailData.oosQty : '--' }}</strong>;<br/>
  69. 总售价:<strong>{{ detailData&&(detailData.totalAmount || detailData.totalAmount==0) ? detailData.totalAmount : '--' }}</strong>;
  70. 总成本:<strong>{{ detailData&&(detailData.totalCost || detailData.totalCost==0) ? detailData.totalCost : '--' }}</strong>;
  71. 总毛利:<strong>{{ detailData&&(detailData.grossProfit || detailData.grossProfit==0) ? detailData.grossProfit : '--' }}</strong>;
  72. 折后总售价:<strong>{{ detailData&&(detailData.discountedAmount || detailData.discountedAmount==0) ? detailData.discountedAmount : '--' }}</strong>;
  73. 折扣:<strong>{{ detailData&&(detailData.discountRate || detailData.discountRate==0) ? detailData.discountRate+'%' : '--' }}</strong>;
  74. 折扣金额:<strong>{{ detailData&&(detailData.discountAmount || detailData.discountAmount==0) ? detailData.discountAmount : '--' }}</strong>;
  75. </div>
  76. </a-alert>
  77. <!-- 列表 -->
  78. <s-table
  79. class="sTable"
  80. ref="table"
  81. size="small"
  82. :rowKey="(record) => record.id"
  83. :columns="columns"
  84. :data="loadData"
  85. :scroll="{ x: 1660 }"
  86. bordered>
  87. </s-table>
  88. </a-card>
  89. </a-spin>
  90. <!-- 打印 -->
  91. <div id="print"></div>
  92. </div>
  93. </template>
  94. <script>
  95. import { getOperationalPrecision } from '@/libs/tools.js'
  96. import { STable, VSelect } from '@/components'
  97. import { salesDetailBySn, salesDetailPrint } from '@/api/sales'
  98. import { salesDetailList } from '@/api/salesDetail'
  99. export default {
  100. name: 'SalesDetail',
  101. components: { STable, VSelect },
  102. props: {
  103. outBizSn: { // 有值则为弹框,无值则为页面
  104. type: [Number, String],
  105. default: ''
  106. }
  107. },
  108. data () {
  109. return {
  110. spinning: false,
  111. disabled: false,
  112. pritKey: [
  113. { id: 0, name: '打印促销' },
  114. { id: 1, name: '打印支付方式' },
  115. { id: 2, name: '打印收款方式' }
  116. ],
  117. pritModal: [
  118. { id: 0, name: '普通模板一' },
  119. { id: 1, name: '普通模板二' },
  120. { id: 2, name: '仓库模板一' }
  121. ],
  122. // 表头
  123. columns: [
  124. { title: '序号', dataIndex: 'no', width: 80, align: 'center', fixed: 'left' },
  125. { title: '产品编码', dataIndex: 'productCode', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
  126. { title: '产品名称', dataIndex: 'productName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  127. { title: '原厂编码', dataIndex: 'productOrigCode', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
  128. { title: '成本价', dataIndex: 'cost', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? ('¥' + text) : '--') } },
  129. { title: '售价', dataIndex: 'price', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? ('¥' + text) : '--') } },
  130. { title: '折后售价', dataIndex: 'discountedPrice', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? ('¥' + text) : '--') } },
  131. { title: '销售数量', dataIndex: 'qty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  132. { title: '单位', dataIndex: 'productOrigUnit', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  133. { title: '售价小计', dataIndex: 'totalAmount', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? ('¥' + text) : '--') } },
  134. { title: '折后小计', dataIndex: 'discountedAmount', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? ('¥' + text) : '--') } },
  135. { title: '折扣金额', dataIndex: 'discountAmount', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? ('¥' + text) : '--') } },
  136. { title: '仓库', dataIndex: 'warehouseName', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  137. { title: '仓位', dataIndex: 'warehouseLocationName', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  138. { title: '是否急件', dataIndex: 'oosFlagDictValue', width: 100, align: 'center', customRender: function (text) { return text || '--' } }
  139. ],
  140. // 加载数据方法 必须为 Promise 对象
  141. loadData: parameter => {
  142. this.disabled = true
  143. return salesDetailList(Object.assign(parameter, { salesBillSn: this.outBizSn || this.$route.params.sn })).then(res => {
  144. const data = res.data
  145. const no = (data.pageNo - 1) * data.pageSize
  146. for (var i = 0; i < data.list.length; i++) {
  147. data.list[i].no = no + i + 1
  148. const productCode = (data.list[i].productEntity && data.list[i].productEntity.code) || (data.list[i].dealerProductEntity && data.list[i].dealerProductEntity.code)
  149. const productName = (data.list[i].productEntity && data.list[i].productEntity.name) || (data.list[i].dealerProductEntity && data.list[i].dealerProductEntity.name)
  150. const productOrigCode = (data.list[i].productEntity && data.list[i].productEntity.origCode) || (data.list[i].dealerProductEntity && data.list[i].dealerProductEntity.origCode)
  151. const productOrigUnit = (data.list[i].productEntity && data.list[i].productEntity.unit) || (data.list[i].dealerProductEntity && data.list[i].dealerProductEntity.unit)
  152. data.list[i].productCode = productCode || '--'
  153. data.list[i].productName = productName || '--'
  154. data.list[i].productOrigCode = productOrigCode || '--'
  155. data.list[i].productOrigUnit = productOrigUnit || '--'
  156. data.list[i].warehouseName = data.list[i].warehouseEntity && data.list[i].warehouseEntity.name || '--'
  157. data.list[i].warehouseLocationName = data.list[i].warehouseLocationEntity && data.list[i].warehouseLocationEntity.name || '--'
  158. // 售价小计 由于数据库内小数位数为4位,页面则需显示2位。因此会做小数运算精度处理
  159. data.list[i].salePriceSubtotal = getOperationalPrecision(data.list[i].price, data.list[i].qty)
  160. }
  161. this.localDataSource = data.list
  162. this.disabled = false
  163. return data
  164. })
  165. },
  166. localDataSource: [],
  167. detailData: null, // 详情数据
  168. printerType: 'NEEDLE' // 打印机类型
  169. }
  170. },
  171. methods: {
  172. // 返回
  173. handleBack () {
  174. this.$router.push({ path: '/salesManagement/salesQuery/list', query: { closeLastOldTab: true } })
  175. },
  176. // 编辑
  177. handleEdit () {
  178. const row = this.detailData
  179. this.$router.push({ name: 'salesEdit', params: { id: row.id, sn: row.salesBillSn, priceType: row.priceType } })
  180. },
  181. // 详情
  182. getDetail () {
  183. salesDetailBySn({ salesBillSn: this.outBizSn || this.$route.params.sn }).then(res => {
  184. if (res.status == 200) {
  185. this.detailData = res.data
  186. } else {
  187. this.detailData = null
  188. }
  189. })
  190. },
  191. // 打印预览/快捷打印
  192. handlePrint (type) {
  193. const _this = this
  194. _this.spinning = true
  195. salesDetailPrint({ sn: this.outBizSn || this.$route.params.sn, type: this.printerType }).then(res => {
  196. _this.spinning = false
  197. if (res.type == 'application/json') {
  198. var reader = new FileReader()
  199. reader.addEventListener('loadend', function () {
  200. const obj = JSON.parse(reader.result)
  201. _this.$notification.error({
  202. message: '提示',
  203. description: obj.message
  204. })
  205. })
  206. reader.readAsText(res)
  207. } else {
  208. this.print(res, type)
  209. }
  210. })
  211. },
  212. print (data, type) {
  213. if (!data) {
  214. return
  215. }
  216. const url = window.URL.createObjectURL(new Blob([data], { type: 'application/pdf' }))
  217. document.getElementById('print').innerHTML = '<iframe id="printf" name="printf" src="' + url + '" hidden></iframe>'
  218. if (type == 'preview') { // 预览
  219. window.open(url)
  220. } else if (type == 'print') { // 打印
  221. window.frames['printf'].focus()
  222. window.frames['printf'].print()
  223. }
  224. }
  225. },
  226. mounted () {
  227. this.getDetail()
  228. }
  229. }
  230. </script>
  231. <style lang="less">
  232. .salesDetail-wrap{
  233. .salesDetail-cont{
  234. margin-bottom: 15px;
  235. }
  236. }
  237. </style>