detail.vue 14 KB

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